libpurple/protocols/msn/cmdproc.c

Mon, 12 Sep 2016 08:55:35 -0500

author
Mike Ruprecht <cmaiku@gmail.com>
date
Mon, 12 Sep 2016 08:55:35 -0500
changeset 38142
1dff6e343f9f
parent 32008
56d1c64759d6
permissions
-rw-r--r--

gg: Protect against issues when closing while connecting

Since the GIOStream is cancelled when data is freed, any cancelled
callbacks are called after such data is freed. This patch guards against
cancelled calls by safely returning without accessing any freed data if
the connection has been cancelled (aka closed).

Futhermore, if GG tries to connect and is quickly disconnected,
ggp_tcpsocket_close() is never called. As far as I can tell, it's an
existing bug, but PurpleSockets both work differently when closing and
are closed by the connection if any leak. So the issue wasn't a major
problem. This patch lessens the issue by guarding against it, but it
should be fixed at some point.

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

mercurial