annotate libpurple/protocols/msn/cmdproc.c @ 30716:c316749944c1

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