annotate libpurple/protocols/msn/cmdproc.c @ 30758:230caecf5435

Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
author masca@cpw.pidgin.im
date Fri, 28 May 2010 22:45:52 +0000
parents e8e4c4207d30
children 4bc5b483699e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file cmdproc.c MSN command processor functions
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15822
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30716
diff changeset
24
30758
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 30753
diff changeset
25 #include "internal.h"
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30716
diff changeset
26 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30716
diff changeset
27
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "cmdproc.h"
30753
e8e4c4207d30 A little header cleanup.
masca@cpw.pidgin.im
parents: 30742
diff changeset
29 #include "error.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 MsnCmdProc *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 msn_cmdproc_new(MsnSession *session)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 MsnCmdProc *cmdproc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 cmdproc = g_new0(MsnCmdProc, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 cmdproc->session = session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 cmdproc->txqueue = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 cmdproc->history = msn_history_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
42 cmdproc->multiparts = g_hash_table_new_full(g_str_hash, g_str_equal,
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
43 NULL, (GDestroyNotify)msn_message_unref);
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
44
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 return cmdproc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 msn_cmdproc_destroy(MsnCmdProc *cmdproc)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 MsnTransaction *trans;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 msn_transaction_destroy(trans);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 g_queue_free(cmdproc->txqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 msn_history_destroy(cmdproc->history);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 if (cmdproc->last_cmd != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 msn_command_destroy(cmdproc->last_cmd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
63 g_hash_table_destroy(cmdproc->multiparts);
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
64
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 g_free(cmdproc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 msn_cmdproc_process_queue(MsnCmdProc *cmdproc)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 MsnTransaction *trans;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 msn_cmdproc_send_trans(cmdproc, trans);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 msn_cmdproc_queue_trans(MsnCmdProc *cmdproc, MsnTransaction *trans)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 g_return_if_fail(cmdproc != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 g_return_if_fail(trans != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 g_queue_push_tail(cmdproc->txqueue, trans);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 show_debug_cmd(MsnCmdProc *cmdproc, gboolean incoming, const char *command)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 MsnServConn *servconn;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 const char *names[] = { "NS", "SB" };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 char *show;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 char tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 size_t len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 servconn = cmdproc->servconn;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 len = strlen(command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 show = g_strdup(command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 tmp = (incoming) ? 'S' : 'C';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 if ((show[len - 1] == '\n') && (show[len - 2] == '\r'))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 show[len - 2] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
106 purple_debug_misc("msn", "%c: %s %03d: %s\n", tmp,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 names[servconn->type], servconn->num, show);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 g_free(show);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 msn_cmdproc_send_trans(MsnCmdProc *cmdproc, MsnTransaction *trans)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 MsnServConn *servconn;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 char *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 size_t len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 g_return_if_fail(cmdproc != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 g_return_if_fail(trans != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 servconn = cmdproc->servconn;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
26232
1977e930ab03 Make sure we free itmsurl when showing the info window for a buddy
Mark Doliner <mark@kingant.net>
parents: 25377
diff changeset
124 if (!servconn->connected) {
1977e930ab03 Make sure we free itmsurl when showing the info window for a buddy
Mark Doliner <mark@kingant.net>
parents: 25377
diff changeset
125 /* TODO: Need to free trans */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 return;
26232
1977e930ab03 Make sure we free itmsurl when showing the info window for a buddy
Mark Doliner <mark@kingant.net>
parents: 25377
diff changeset
127 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
30716
c316749944c1 I don't really like this name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30714
diff changeset
129 if (trans->saveable)
30714
7b310568cd87 Messages without TrID's should not be saved in the history.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30710
diff changeset
130 msn_history_add(cmdproc->history, trans);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 data = msn_transaction_to_string(trans);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 len = strlen(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 show_debug_cmd(cmdproc, FALSE, data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 if (trans->callbacks == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 trans->callbacks = g_hash_table_lookup(cmdproc->cbs_table->cmds,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 trans->command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 if (trans->payload != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 data = g_realloc(data, len + trans->payload_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 memcpy(data + len, trans->payload, trans->payload_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 len += trans->payload_len;
23011
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
147
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
148 /*
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
149 * We're done with trans->payload. Free it so that the memory
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
150 * doesn't sit around in cmdproc->history.
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
151 */
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
152 g_free(trans->payload);
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
153 trans->payload = NULL;
ba47ec8a2477 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents: 20514
diff changeset
154 trans->payload_len = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 msn_servconn_write(servconn, data, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 g_free(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 msn_cmdproc_process_payload(MsnCmdProc *cmdproc, char *payload,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 int payload_len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 MsnCommand *last;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 g_return_if_fail(cmdproc != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 last = cmdproc->last_cmd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 last->payload = g_memdup(payload, payload_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 last->payload_len = payload_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 if (last->payload_cb != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 last->payload_cb(cmdproc, last, payload, payload_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 msn_cmdproc_process_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 MsnMsgTypeCb cb;
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
182 const char *message_id = NULL;
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
183
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
184 /* Multi-part messages */
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
185 message_id = msn_message_get_header_value(msg, "Message-ID");
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
186 if (message_id != NULL) {
30696
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
187 /* This is the first in a series of chunks */
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
188
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27898
diff changeset
189 const char *chunk_text = msn_message_get_header_value(msg, "Chunks");
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
190 guint chunk;
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
191 if (chunk_text != NULL) {
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
192 chunk = strtol(chunk_text, NULL, 10);
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
193 /* 1024 chunks of ~1300 bytes is ~1MB, which seems OK to prevent
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
194 some random client causing pidgin to hog a ton of memory.
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
195 Probably should figure out the maximum that the official client
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
196 actually supports, though. */
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
197 if (chunk > 0 && chunk < 1024) {
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
198 msg->total_chunks = chunk;
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
199 msg->received_chunks = 1;
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
200 g_hash_table_insert(cmdproc->multiparts, (gpointer)message_id, msn_message_ref(msg));
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
201 purple_debug_info("msn", "Received chunked message, message_id: '%s', total chunks: %d\n",
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
202 message_id, chunk);
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
203 } else {
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
204 purple_debug_error("msn", "MessageId '%s' has too many chunks: %d\n", message_id, chunk);
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
205 }
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
206 return;
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
207 } else {
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27898
diff changeset
208 chunk_text = msn_message_get_header_value(msg, "Chunk");
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
209 if (chunk_text != NULL) {
30696
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
210 /* This is one chunk in a series of chunks */
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
211
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
212 MsnMessage *first = g_hash_table_lookup(cmdproc->multiparts, message_id);
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
213 chunk = strtol(chunk_text, NULL, 10);
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
214 if (first == NULL) {
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
215 purple_debug_error("msn",
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
216 "Unable to find first chunk of message_id '%s' to correspond with chunk %d.\n",
30696
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
217 message_id, chunk + 1);
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
218 } else if (first->received_chunks != chunk) {
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
219 /*
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
220 * We received an out of order chunk number (i.e. not the
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
221 * next one in the sequence). Not sure if this can happen
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
222 * legitimately, but we definitely don't handle it right
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
223 * now.
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
224 */
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
225 g_hash_table_remove(cmdproc->multiparts, message_id);
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
226 return;
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
227 }
30696
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
228
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
229 /* Chunk is from 1 to total-1 (doesn't count first one) */
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
230 purple_debug_info("msn", "Received chunk %d of %d, message_id: '%s'\n",
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
231 chunk + 1, first->total_chunks, message_id);
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
232 first->body = g_realloc(first->body, first->body_len + msg->body_len);
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
233 memcpy(first->body + first->body_len, msg->body, msg->body_len);
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
234 first->body_len += msg->body_len;
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
235 first->received_chunks++;
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
236 if (first->received_chunks != first->total_chunks)
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
237 /* We're waiting for more chunks */
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
238 return;
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
239
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
240 /*
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
241 * We have all the chunks for this message, great! Send
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
242 * it along... The caller takes care of freeing the old one.
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
243 */
d22b9e73c929 Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents: 30695
diff changeset
244 msg = first;
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
245 } else {
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
246 purple_debug_error("msn", "Received MessageId '%s' with no chunk number!\n", message_id);
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
247 }
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
248 }
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
249 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 if (msn_message_get_content_type(msg) == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
253 purple_debug_misc("msn", "failed to find message content\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 cb = g_hash_table_lookup(cmdproc->cbs_table->msgs,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 msn_message_get_content_type(msg));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
25377
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
260 if (cb != NULL)
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
261 cb(cmdproc, msg);
0ffa511ac165 Re-combine large (multi-part) messages on MSN since we seem to say that we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23552
diff changeset
262 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
263 purple_debug_warning("msn", "Unhandled content-type '%s'\n",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 msn_message_get_content_type(msg));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265
30695
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
266 if (message_id != NULL)
d827357c6ce9 Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
267 g_hash_table_remove(cmdproc->multiparts, message_id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 msn_cmdproc_process_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 MsnTransCb cb = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 MsnTransaction *trans = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 if (cmd->trId)
23552
e069c16db597 Always save the MSN transaction in each command, not just for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23011
diff changeset
277 cmd->trans = trans = msn_history_find(cmdproc->history, cmd->trId);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 if (trans != NULL)
20493
9e2ed6cd824b Reset the timer to 0 after removing it. It looks like this may be required here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15822
diff changeset
280 if (trans->timer) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
281 purple_timeout_remove(trans->timer);
20493
9e2ed6cd824b Reset the timer to 0 after removing it. It looks like this may be required here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15822
diff changeset
282 trans->timer = 0;
9e2ed6cd824b Reset the timer to 0 after removing it. It looks like this may be required here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15822
diff changeset
283 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
285 if (g_ascii_isdigit(cmd->command[0]) && trans != NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 {
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
287 MsnErrorCb error_cb;
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
288 int error;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
290 error = atoi(cmd->command);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
292 error_cb = trans->error_cb;
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
293 if (error_cb == NULL)
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
294 error_cb = g_hash_table_lookup(cmdproc->cbs_table->errors, trans->command);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
296 if (error_cb != NULL)
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
297 error_cb(cmdproc, trans, error);
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
298 else
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
299 msn_error_handle(cmdproc->session, error);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
301 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
304 cb = g_hash_table_lookup(cmdproc->cbs_table->async, cmd->command);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
306 if (cb == NULL && trans != NULL && trans->callbacks != NULL)
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
307 cb = g_hash_table_lookup(trans->callbacks, cmd->command);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308
27898
28485b9ea656 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents: 27894
diff changeset
309 if (cb == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 cb = g_hash_table_lookup(cmdproc->cbs_table->fallback, cmd->command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 if (cb != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 cb(cmdproc, cmd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
315 purple_debug_warning("msn", "Unhandled command '%s'\n",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 cmd->command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 if (trans != NULL && trans->pendent_cmd != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 msn_transaction_unqueue_cmd(trans, cmdproc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 msn_cmdproc_process_cmd_text(MsnCmdProc *cmdproc, const char *command)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 show_debug_cmd(cmdproc, TRUE, command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 if (cmdproc->last_cmd != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 msn_command_destroy(cmdproc->last_cmd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 cmdproc->last_cmd = msn_command_from_string(command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 msn_cmdproc_process_cmd(cmdproc, cmdproc->last_cmd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }