Mercurial > pidgin
annotate libpurple/protocols/msn/cmdproc.c @ 30710:f7ee91763c6b
msn: Remove msn_cmdproc_send_quick in favor of msn_cmdproc_send_trans
With this changes whe have an unified and robust way to send commands.
We avoid duplicated code and it's easier to find problems since the code is only
in one place.
author | masca@cpw.pidgin.im |
---|---|
date | Wed, 10 Mar 2010 22:16:04 +0000 |
parents | 4d7dfeae29c6 |
children | 7b310568cd87 |
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 | 4 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
15822 | 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 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 #include "msn.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "cmdproc.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 MsnCmdProc * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 msn_cmdproc_new(MsnSession *session) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 MsnCmdProc *cmdproc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 cmdproc = g_new0(MsnCmdProc, 1); |
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 cmdproc->session = session; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 cmdproc->txqueue = g_queue_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 cmdproc->history = msn_history_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 |
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
|
38 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
|
39 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
|
40 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 return cmdproc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 msn_cmdproc_destroy(MsnCmdProc *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 MsnTransaction *trans; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 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
|
50 msn_transaction_destroy(trans); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 g_queue_free(cmdproc->txqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 msn_history_destroy(cmdproc->history); |
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 if (cmdproc->last_cmd != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 msn_command_destroy(cmdproc->last_cmd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 |
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
|
59 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
|
60 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 g_free(cmdproc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 msn_cmdproc_process_queue(MsnCmdProc *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 MsnTransaction *trans; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 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
|
70 msn_cmdproc_send_trans(cmdproc, trans); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 } |
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 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 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
|
75 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 g_return_if_fail(cmdproc != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 g_return_if_fail(trans != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 g_queue_push_tail(cmdproc->txqueue, trans); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 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
|
84 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 MsnServConn *servconn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 const char *names[] = { "NS", "SB" }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 char *show; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 char tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 size_t len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 servconn = cmdproc->servconn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 len = strlen(command); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 show = g_strdup(command); |
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 tmp = (incoming) ? 'S' : 'C'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 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
|
98 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 show[len - 2] = '\0'; |
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 |
15822 | 102 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
|
103 names[servconn->type], servconn->num, show); |
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 g_free(show); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 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
|
110 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 MsnServConn *servconn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 char *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 size_t len; |
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 g_return_if_fail(cmdproc != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 g_return_if_fail(trans != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 servconn = cmdproc->servconn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
26232
1977e930ab03
Make sure we free itmsurl when showing the info window for a buddy
Mark Doliner <mark@kingant.net>
parents:
25377
diff
changeset
|
120 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
|
121 /* TODO: Need to free trans */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 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
|
123 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 msn_history_add(cmdproc->history, trans); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 data = msn_transaction_to_string(trans); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 len = strlen(data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 show_debug_cmd(cmdproc, FALSE, data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 if (trans->callbacks == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 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
|
135 trans->command); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 if (trans->payload != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 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
|
140 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
|
141 len += trans->payload_len; |
23011
ba47ec8a2477
When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents:
20514
diff
changeset
|
142 |
ba47ec8a2477
When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents:
20514
diff
changeset
|
143 /* |
ba47ec8a2477
When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents:
20514
diff
changeset
|
144 * 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
|
145 * 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
|
146 */ |
ba47ec8a2477
When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents:
20514
diff
changeset
|
147 g_free(trans->payload); |
ba47ec8a2477
When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents:
20514
diff
changeset
|
148 trans->payload = NULL; |
ba47ec8a2477
When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <mark@kingant.net>
parents:
20514
diff
changeset
|
149 trans->payload_len = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 msn_servconn_write(servconn, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 g_free(data); |
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 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 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
|
159 int payload_len) |
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 MsnCommand *last; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 g_return_if_fail(cmdproc != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 last = cmdproc->last_cmd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 last->payload = g_memdup(payload, payload_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 last->payload_len = payload_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 if (last->payload_cb != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 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
|
171 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 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
|
175 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 MsnMsgTypeCb cb; |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
177 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
|
178 |
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
|
179 /* Multi-part messages */ |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
180 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
|
181 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
|
182 /* 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
|
183 |
30694
33b4ae796648
Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents:
27898
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 chunk = strtol(chunk_text, NULL, 10); |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
188 /* 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 msg->received_chunks = 1; |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 } else { |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
199 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
|
200 } |
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
|
201 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
|
202 } else { |
30694
33b4ae796648
Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents:
27898
diff
changeset
|
203 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
|
204 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
|
205 /* 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
|
206 |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 purple_debug_error("msn", |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
211 "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
|
212 message_id, chunk + 1); |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
213 } 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
|
214 /* |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
215 * 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
|
216 * 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
|
217 * 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
|
218 * now. |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
219 */ |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
220 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
|
221 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
|
222 } |
30696
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
223 |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
224 /* 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 first->received_chunks++; |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
231 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
|
232 /* 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
|
233 return; |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
234 |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
235 /* |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
236 * 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
|
237 * 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
|
238 */ |
d22b9e73c929
Shuffle some things around and add some comments. Hopefully cleaner.
Mark Doliner <mark@kingant.net>
parents:
30695
diff
changeset
|
239 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
|
240 } else { |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
241 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
|
242 } |
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
|
243 } |
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
|
244 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 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
|
247 { |
15822 | 248 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
|
249 return; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 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
|
253 msn_message_get_content_type(msg)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
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
|
255 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
|
256 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
|
257 else |
15822 | 258 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
|
259 msn_message_get_content_type(msg)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 |
30695
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
261 if (message_id != NULL) |
d827357c6ce9
Since when do we use camel case?
Mark Doliner <mark@kingant.net>
parents:
30694
diff
changeset
|
262 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
|
263 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 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
|
267 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 MsnTransCb cb = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 MsnTransaction *trans = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 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
|
272 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
|
273 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 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
|
275 if (trans->timer) { |
15822 | 276 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
|
277 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
|
278 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
27898
28485b9ea656
Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents:
27894
diff
changeset
|
280 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
|
281 { |
27898
28485b9ea656
Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents:
27894
diff
changeset
|
282 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
|
283 int error; |
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 error = atoi(cmd->command); |
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 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
|
288 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
|
289 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
|
290 |
27898
28485b9ea656
Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents:
27894
diff
changeset
|
291 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
|
292 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
|
293 else |
28485b9ea656
Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents:
27894
diff
changeset
|
294 msn_error_handle(cmdproc->session, error); |
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 return; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 |
27898
28485b9ea656
Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <mark@kingant.net>
parents:
27894
diff
changeset
|
299 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
|
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 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
|
302 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
|
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 if (cb == NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 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
|
306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 if (cb != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 cb(cmdproc, cmd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 else |
15822 | 310 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
|
311 cmd->command); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 if (trans != NULL && trans->pendent_cmd != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 msn_transaction_unqueue_cmd(trans, cmdproc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 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
|
319 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 show_debug_cmd(cmdproc, TRUE, command); |
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 if (cmdproc->last_cmd != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 msn_command_destroy(cmdproc->last_cmd); |
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 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
|
326 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 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
|
328 } |