libpurple/protocols/msn/cmdproc.c

Sat, 27 Nov 2010 07:08:24 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sat, 27 Nov 2010 07:08:24 +0000
changeset 31178
303c44f64d2c
parent 31109
b04f3af0fd58
child 31240
db0cb3d72bc9
permissions
-rw-r--r--

Call msn_transaction_destroy from msn_cmdproc_send_trans. This way, it
always owns in some way the transaction after being called.

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)
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10481
diff changeset
61 msn_command_destroy(cmdproc->last_cmd);
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
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 void
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;
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 g_return_if_fail(cmdproc != NULL);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 g_return_if_fail(trans != NULL);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 servconn = cmdproc->servconn;
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10403
diff changeset
123
26569
75f5eac5703c Make sure we free itmsurl when showing the info window for a buddy
Mark Doliner <markdoliner@pidgin.im>
parents: 25469
diff changeset
124 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
125 msn_transaction_destroy(trans);
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10403
diff changeset
126 return;
26569
75f5eac5703c Make sure we free itmsurl when showing the info window for a buddy
Mark Doliner <markdoliner@pidgin.im>
parents: 25469
diff changeset
127 }
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10403
diff changeset
128
30915
56295f0a8ade I don't really like this name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30913
diff changeset
129 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
130 msn_history_add(cmdproc->history, trans);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 data = msn_transaction_to_string(trans);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
133
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 len = strlen(data);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 show_debug_cmd(cmdproc, FALSE, data);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 if (trans->callbacks == NULL)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 trans->callbacks = g_hash_table_lookup(cmdproc->cbs_table->cmds,
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 trans->command);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 if (trans->payload != NULL)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 {
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 data = g_realloc(data, len + trans->payload_len);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 memcpy(data + len, trans->payload, trans->payload_len);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 len += trans->payload_len;
23235
cb7d22017162 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <markdoliner@pidgin.im>
parents: 20597
diff changeset
147
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 * 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
150 * 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
151 */
cb7d22017162 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <markdoliner@pidgin.im>
parents: 20597
diff changeset
152 g_free(trans->payload);
cb7d22017162 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <markdoliner@pidgin.im>
parents: 20597
diff changeset
153 trans->payload = NULL;
cb7d22017162 When adding outgoing MSN commands to the MsnHistory, free
Mark Doliner <markdoliner@pidgin.im>
parents: 20597
diff changeset
154 trans->payload_len = 0;
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 }
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 msn_servconn_write(servconn, data, len);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
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
159 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
160 msn_transaction_destroy(trans);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 g_free(data);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 }
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 void
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
165 msn_cmdproc_process_payload(MsnCmdProc *cmdproc, char *payload,
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
166 int payload_len)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
167 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
168 MsnCommand *last;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
169
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
170 g_return_if_fail(cmdproc != NULL);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
171
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
172 last = cmdproc->last_cmd;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
173 last->payload = g_memdup(payload, payload_len);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
174 last->payload_len = payload_len;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
175
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
176 if (last->payload_cb != NULL)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
177 last->payload_cb(cmdproc, last, payload, payload_len);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
178 }
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
179
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
180 void
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 msn_cmdproc_process_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 {
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10310
diff changeset
183 MsnMsgTypeCb cb;
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
184 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
185
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
186 /* Multi-part messages */
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
187 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
188 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
189 /* 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
190
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28175
diff changeset
191 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
192 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
193 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
194 chunk = strtol(chunk_text, NULL, 10);
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
195 /* 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
196 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
197 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
198 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
199 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
200 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
201 msg->received_chunks = 1;
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
202 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
203 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
204 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
205 } else {
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
206 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
207 }
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
208 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
209 } else {
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28175
diff changeset
210 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
211 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
212 /* 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
213
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
214 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
215 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
216 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
217 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
218 /*
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 * 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
220 * 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
221 * 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
222 * 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
223 */
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 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
225 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
226 }
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
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 /* 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
229 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
230 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
231 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
232 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
233 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 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
235 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
236 /* 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
237 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
238
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 /*
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 * 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
241 * 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
242 */
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 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
244 } 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
245 purple_debug_error("msn",
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
246 "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
247 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
248 }
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
249 } else {
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
250 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
251 }
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
252 }
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 }
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254
9881
c63823101be4 [gaim-migrate @ 10760]
Mark Doliner <markdoliner@pidgin.im>
parents: 9641
diff changeset
255 if (msn_message_get_content_type(msg) == NULL)
c63823101be4 [gaim-migrate @ 10760]
Mark Doliner <markdoliner@pidgin.im>
parents: 9641
diff changeset
256 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
257 purple_debug_misc("msn", "failed to find message content\n");
9881
c63823101be4 [gaim-migrate @ 10760]
Mark Doliner <markdoliner@pidgin.im>
parents: 9641
diff changeset
258 return;
c63823101be4 [gaim-migrate @ 10760]
Mark Doliner <markdoliner@pidgin.im>
parents: 9641
diff changeset
259 }
c63823101be4 [gaim-migrate @ 10760]
Mark Doliner <markdoliner@pidgin.im>
parents: 9641
diff changeset
260
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 cb = g_hash_table_lookup(cmdproc->cbs_table->msgs,
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 msn_message_get_content_type(msg));
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263
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
264 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
265 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
266 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
267 purple_debug_warning("msn", "Unhandled content-type '%s'\n",
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
268 msn_message_get_content_type(msg));
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
29458
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
270 if (message_id != NULL)
84e15cd5c969 Since when do we use camel case?
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
271 g_hash_table_remove(cmdproc->multiparts, message_id);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 }
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 void
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 msn_cmdproc_process_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
277 MsnTransCb cb = NULL;
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 MsnTransaction *trans = NULL;
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 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
281 cmd->trans = trans = msn_history_find(cmdproc->history, cmd->trId);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10043
diff changeset
283 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
284 if (trans->timer) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
285 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
286 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
287 }
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10043
diff changeset
288
28175
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
289 if (g_ascii_isdigit(cmd->command[0]) && trans != NULL)
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
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 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
292 int error;
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293
28175
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
294 error = atoi(cmd->command);
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10043
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_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
297 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
298 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
299
28175
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
300 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
301 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
302 else
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
303 msn_error_handle(cmdproc->session, error);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304
28175
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
305 return;
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 }
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307
28175
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
308 cb = g_hash_table_lookup(cmdproc->cbs_table->async, cmd->command);
8810
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 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
311 cb = g_hash_table_lookup(trans->callbacks, cmd->command);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312
28175
fa8b01d12ef1 Simplify. A lot of these checks aren't necessary because msn_table_new()
Mark Doliner <markdoliner@pidgin.im>
parents: 28171
diff changeset
313 if (cb == NULL)
10043
4d4cc1ee9b69 [gaim-migrate @ 11002]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9881
diff changeset
314 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
315
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 if (cb != NULL)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 cb(cmdproc, cmd);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
319 purple_debug_warning("msn", "Unhandled command '%s'\n",
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8830
diff changeset
320 cmd->command);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
322 if (trans != NULL && trans->pendent_cmd != NULL)
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10403
diff changeset
323 msn_transaction_unqueue_cmd(trans, cmdproc);
8810
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 }
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 void
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 msn_cmdproc_process_cmd_text(MsnCmdProc *cmdproc, const char *command)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 {
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 show_debug_cmd(cmdproc, TRUE, 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 if (cmdproc->last_cmd != NULL)
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 msn_command_destroy(cmdproc->last_cmd);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 cmdproc->last_cmd = msn_command_from_string(command);
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 msn_cmdproc_process_cmd(cmdproc, cmdproc->last_cmd);
2240097956a7 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 }

mercurial