Mercurial > pidgin
annotate src/protocols/msn/switchboard.c @ 10403:e5455f1dc9b6
[gaim-migrate @ 11648]
This is "Yet another MSN fix" from Felipe, it actually turned into "Several
MSN fixes", see bug 1088651 for the details.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 23 Dec 2004 20:13:54 +0000 |
parents | 38256d3e8324 |
children | 6be6da69d603 |
rev | line source |
---|---|
4542 | 1 /** |
2 * @file switchboard.c MSN switchboard functions | |
3 * | |
4 * gaim | |
5 * | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
6 * Gaim is the legal property of its developers, whose names are too numerous |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
8 * source distribution. |
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
9 * |
4542 | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
8207
aa44049e8891
[gaim-migrate @ 8930]
Christian Hammond <chipx86@chipx86.com>
parents:
7639
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4542 | 23 */ |
24 #include "msn.h" | |
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
25 #include "prefs.h" |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
26 #include "switchboard.h" |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
27 #include "notification.h" |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
28 #include "utils.h" |
4542 | 29 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
30 #include "error.h" |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
31 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
32 static MsnTable *cbs_table; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
33 |
10345 | 34 static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, |
35 MsnMsgErrorType error); | |
36 | |
37 /************************************************************************** | |
38 * Main stuff | |
39 **************************************************************************/ | |
40 MsnSwitchBoard * | |
41 msn_switchboard_new(MsnSession *session) | |
42 { | |
43 MsnSwitchBoard *swboard; | |
44 MsnServConn *servconn; | |
45 MsnCmdProc *cmdproc; | |
46 | |
47 g_return_val_if_fail(session != NULL, NULL); | |
48 | |
49 swboard = g_new0(MsnSwitchBoard, 1); | |
50 | |
51 swboard->session = session; | |
52 swboard->servconn = servconn = msn_servconn_new(session, MSN_SERVER_SB); | |
53 cmdproc = servconn->cmdproc; | |
54 | |
55 swboard->im_queue = g_queue_new(); | |
56 swboard->empty = TRUE; | |
57 | |
58 servconn->data = swboard; | |
59 | |
60 session->switches = g_list_append(session->switches, swboard); | |
61 | |
62 cmdproc->cbs_table = cbs_table; | |
63 | |
64 return swboard; | |
65 } | |
66 | |
67 void | |
68 msn_switchboard_destroy(MsnSwitchBoard *swboard) | |
69 { | |
70 MsnSession *session; | |
71 MsnMessage *msg; | |
72 GList *l; | |
73 | |
74 g_return_if_fail(swboard != NULL); | |
75 | |
76 if (swboard->destroying) | |
77 return; | |
78 | |
79 swboard->destroying = TRUE; | |
80 | |
81 /* If it linked us is because its looking for trouble */ | |
82 if (swboard->slplink != NULL) | |
83 msn_slplink_destroy(swboard->slplink); | |
84 | |
85 /* Destroy the message queue */ | |
86 while ((msg = g_queue_pop_head(swboard->im_queue)) != NULL) | |
87 { | |
88 if (swboard->error != MSN_SB_ERROR_NONE) | |
89 { | |
90 /* The messages could not be sent due to a switchboard error */ | |
91 msg_error_helper(swboard->servconn->cmdproc, msg, | |
92 MSN_MSG_ERROR_SB); | |
93 } | |
10403 | 94 msn_message_unref(msg); |
10345 | 95 } |
96 | |
97 g_queue_free(swboard->im_queue); | |
98 | |
10403 | 99 for (l = swboard->ack_list; l != NULL; l = l->next) |
100 msn_message_unref(l->data); | |
101 | |
10345 | 102 if (swboard->im_user != NULL) |
103 g_free(swboard->im_user); | |
104 | |
105 if (swboard->auth_key != NULL) | |
106 g_free(swboard->auth_key); | |
107 | |
108 if (swboard->session_id != NULL) | |
109 g_free(swboard->session_id); | |
110 | |
111 for (l = swboard->users; l != NULL; l = l->next) | |
112 g_free(l->data); | |
113 | |
114 session = swboard->session; | |
115 session->switches = g_list_remove(session->switches, swboard); | |
116 | |
117 if (swboard->servconn != NULL) | |
118 msn_servconn_destroy(swboard->servconn); | |
119 | |
120 g_free(swboard); | |
121 } | |
122 | |
123 void | |
124 msn_switchboard_set_auth_key(MsnSwitchBoard *swboard, const char *key) | |
125 { | |
126 g_return_if_fail(swboard != NULL); | |
127 g_return_if_fail(key != NULL); | |
128 | |
129 swboard->auth_key = g_strdup(key); | |
130 } | |
131 | |
132 const char * | |
133 msn_switchboard_get_auth_key(MsnSwitchBoard *swboard) | |
134 { | |
135 g_return_val_if_fail(swboard != NULL, NULL); | |
136 | |
137 return swboard->auth_key; | |
138 } | |
139 | |
140 void | |
141 msn_switchboard_set_session_id(MsnSwitchBoard *swboard, const char *id) | |
142 { | |
143 g_return_if_fail(swboard != NULL); | |
144 g_return_if_fail(id != NULL); | |
145 | |
146 if (swboard->session_id != NULL) | |
147 g_free(swboard->session_id); | |
148 | |
149 swboard->session_id = g_strdup(id); | |
150 } | |
151 | |
152 const char * | |
153 msn_switchboard_get_session_id(MsnSwitchBoard *swboard) | |
154 { | |
155 g_return_val_if_fail(swboard != NULL, NULL); | |
156 | |
157 return swboard->session_id; | |
158 } | |
159 | |
160 void | |
161 msn_switchboard_set_invited(MsnSwitchBoard *swboard, gboolean invited) | |
162 { | |
163 g_return_if_fail(swboard != NULL); | |
164 | |
165 swboard->invited = invited; | |
166 } | |
167 | |
168 gboolean | |
169 msn_switchboard_is_invited(MsnSwitchBoard *swboard) | |
170 { | |
171 g_return_val_if_fail(swboard != NULL, FALSE); | |
172 | |
173 return swboard->invited; | |
174 } | |
10225 | 175 |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
176 /************************************************************************** |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
177 * Utility functions |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
178 **************************************************************************/ |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
179 static void |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
180 send_clientcaps(MsnSwitchBoard *swboard) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
181 { |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
182 MsnMessage *msg; |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
183 |
10225 | 184 msg = msn_message_new(MSN_MSG_CAPS); |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
185 msn_message_set_content_type(msg, "text/x-clientcaps"); |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
186 msn_message_set_flag(msg, 'U'); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
187 msn_message_set_bin_data(msg, MSN_CLIENTINFO, strlen(MSN_CLIENTINFO)); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
188 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
189 msn_switchboard_send_msg(swboard, msg); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
190 |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
191 msn_message_destroy(msg); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
192 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
193 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
194 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
195 msn_switchboard_add_user(MsnSwitchBoard *swboard, const char *user) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
196 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
197 MsnCmdProc *cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
198 GaimAccount *account; |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
199 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
200 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
201 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
202 cmdproc = swboard->servconn->cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
203 account = swboard->servconn->session->account; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
204 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
205 swboard->users = g_list_prepend(swboard->users, g_strdup(user)); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
206 swboard->current_users++; |
10346 | 207 swboard->empty = FALSE; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
208 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
209 /* gaim_debug_info("msn", "user=[%s], total=%d\n", user, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
210 * swboard->current_users); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
211 |
10345 | 212 if ((swboard->conv != NULL) && |
213 (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) | |
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
214 { |
10345 | 215 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), user, NULL, |
216 GAIM_CBFLAGS_NONE, TRUE); | |
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
217 } |
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
218 else if (swboard->current_users > 1 || swboard->total_users > 1) |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
219 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
220 if (swboard->conv == NULL || |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
221 gaim_conversation_get_type(swboard->conv) != GAIM_CONV_CHAT) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
222 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
223 GList *l; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
224 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
225 /* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
226 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
227 if (swboard->conv != NULL) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
228 gaim_conversation_destroy(swboard->conv); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
229 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
230 cmdproc->session->conv_seq++; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
231 swboard->chat_id = cmdproc->session->conv_seq; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
232 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
233 swboard->conv = serv_got_joined_chat(account->gc, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
234 swboard->chat_id, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
235 "MSN Chat"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
236 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
237 for (l = swboard->users; l != NULL; l = l->next) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
238 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
239 const char *tmp_user; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
240 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
241 tmp_user = l->data; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
242 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
243 /* gaim_debug_info("msn", "[chat] Adding [%s].\n", |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
244 * tmp_user); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
245 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
246 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
9846 | 247 tmp_user, NULL, GAIM_CBFLAGS_NONE, TRUE); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
248 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
249 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
250 /* gaim_debug_info("msn", "[chat] We add ourselves.\n"); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
251 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
252 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
253 gaim_account_get_username(account), |
9846 | 254 NULL, GAIM_CBFLAGS_NONE, TRUE); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
255 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
256 g_free(swboard->im_user); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
257 swboard->im_user = NULL; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
258 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
259 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
260 else if (swboard->conv == NULL) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
261 { |
10246 | 262 /* XXX - I think this should probably be GAIM_CONV_CHAT, but I'm hedging */ |
263 swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_ANY, | |
264 user, account); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
265 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
266 else |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
267 { |
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
268 gaim_debug_warning("msn", "This should not happen!" |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
269 "(msn_switchboard_add_user)\n"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
270 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
271 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
272 |
10225 | 273 GaimConversation * |
274 msn_switchboard_get_conv(MsnSwitchBoard *swboard) | |
275 { | |
276 GaimAccount *account; | |
277 | |
278 g_return_val_if_fail(swboard != NULL, NULL); | |
279 | |
280 if (swboard->conv != NULL) | |
281 return swboard->conv; | |
282 | |
10346 | 283 gaim_debug_error("msn", "Switchboard with unassigned conversation\n"); |
10345 | 284 |
10225 | 285 account = swboard->session->account; |
286 | |
10246 | 287 /* XXX - I think this should probably be GAIM_CONV_IM, but I'm hedging */ |
288 return gaim_find_conversation_with_account(GAIM_CONV_IM, | |
289 swboard->im_user, account); | |
10225 | 290 } |
291 | |
292 void | |
293 msn_switchboard_report_user(MsnSwitchBoard *swboard, GaimMessageFlags flags, const char *msg) | |
294 { | |
295 GaimConversation *conv; | |
296 | |
297 g_return_if_fail(swboard != NULL); | |
298 g_return_if_fail(msg != NULL); | |
299 | |
300 if ((conv = msn_switchboard_get_conv(swboard)) != NULL) | |
301 { | |
302 gaim_conversation_write(conv, NULL, msg, flags, time(NULL)); | |
303 } | |
304 } | |
305 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
306 static void |
10345 | 307 swboard_error_helper(MsnSwitchBoard *swboard, int reason, const char *passport) |
308 { | |
309 gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport); | |
310 | |
311 if (swboard->total_users == 0) | |
312 { | |
313 swboard->error = reason; | |
314 msn_switchboard_destroy(swboard); | |
315 } | |
316 } | |
317 | |
318 static void | |
319 cal_error_helper(MsnTransaction *trans, int reason) | |
320 { | |
321 MsnSwitchBoard *swboard; | |
322 const char *passport; | |
323 char **params; | |
324 | |
325 params = g_strsplit(trans->params, " ", 0); | |
326 | |
327 passport = params[0]; | |
328 | |
329 swboard = trans->data; | |
330 | |
331 swboard_error_helper(swboard, reason, passport); | |
332 | |
333 g_strfreev(params); | |
334 } | |
335 | |
336 static void | |
337 msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, MsnMsgErrorType error) | |
338 { | |
10403 | 339 MsnSwitchBoard *swboard; |
340 | |
10345 | 341 g_return_if_fail(cmdproc != NULL); |
342 g_return_if_fail(msg != NULL); | |
343 | |
10403 | 344 if ((error != MSN_MSG_ERROR_SB) && (msg->nak_cb != NULL)) |
10345 | 345 msg->nak_cb(msg, msg->ack_data); |
346 | |
10403 | 347 swboard = cmdproc->servconn->data; |
348 | |
10345 | 349 if (msg->type == MSN_MSG_TEXT) |
350 { | |
10346 | 351 const char *format; |
352 char *body_str, *body_enc, *pre, *post; | |
10345 | 353 char *str_reason; |
354 | |
355 #if 0 | |
356 if (swboard->conv == NULL) | |
357 { | |
10346 | 358 if (msg->ack_ref) |
10403 | 359 msn_message_unref(msg); |
10346 | 360 |
10345 | 361 return; |
362 } | |
363 #endif | |
364 | |
10346 | 365 if (error == MSN_MSG_ERROR_TIMEOUT) |
10345 | 366 { |
367 str_reason = _("Message may have not been sent " | |
10391 | 368 "because a time out occurred:"); |
10345 | 369 } |
10346 | 370 else if (error == MSN_MSG_ERROR_SB) |
10345 | 371 { |
372 switch (swboard->error) | |
373 { | |
374 case MSN_SB_ERROR_OFFLINE: | |
375 str_reason = _("Message could not be sent, " | |
10346 | 376 "not allowed while invisible:"); |
10345 | 377 break; |
378 case MSN_SB_ERROR_USER_OFFLINE: | |
379 str_reason = _("Message could not be sent " | |
10346 | 380 "because the user is offline:"); |
10345 | 381 break; |
382 case MSN_SB_ERROR_CONNECTION: | |
383 str_reason = _("Message could not be sent " | |
10391 | 384 "because a connection error occurred:"); |
10345 | 385 break; |
386 default: | |
387 str_reason = _("Message could not be sent " | |
388 "because an error with " | |
10391 | 389 "the switchboard occurred:"); |
10345 | 390 break; |
391 } | |
392 } | |
393 else | |
394 { | |
395 str_reason = _("Message may have not been sent " | |
10391 | 396 "because an unknown error occurred:"); |
10345 | 397 } |
398 | |
10346 | 399 body_str = msn_message_to_string(msg); |
400 body_enc = gaim_escape_html(body_str); | |
401 g_free(body_str); | |
402 | |
403 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
404 msn_parse_format(format, &pre, &post); | |
405 body_str = g_strdup_printf("%s%s%s", pre, body_enc, post); | |
406 g_free(body_enc); | |
407 g_free(pre); | |
408 g_free(post); | |
10345 | 409 |
10403 | 410 msn_switchboard_report_user(swboard, GAIM_MESSAGE_ERROR, |
411 str_reason); | |
412 msn_switchboard_report_user(swboard, GAIM_MESSAGE_RAW, | |
413 body_str); | |
10345 | 414 |
10346 | 415 g_free(body_str); |
10345 | 416 } |
417 | |
10403 | 418 /* If a timeout occures we will want the msg around just in case we |
419 * receive the ACK after the timeout. */ | |
420 if (msg->ack_ref && error != MSN_MSG_ERROR_TIMEOUT) | |
421 { | |
422 swboard->ack_list = g_list_remove(swboard->ack_list, msg); | |
10346 | 423 msn_message_unref(msg); |
10403 | 424 } |
10345 | 425 } |
426 | |
427 /************************************************************************** | |
428 * Switchboard Commands | |
429 **************************************************************************/ | |
430 static void | |
431 ans_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
432 { | |
433 MsnSwitchBoard *swboard; | |
434 | |
435 swboard = cmdproc->servconn->data; | |
436 swboard->ready = TRUE; | |
437 } | |
438 | |
439 static void | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
440 bye_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
441 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
442 MsnSwitchBoard *swboard; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
443 const char *user; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
444 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
445 swboard = cmdproc->servconn->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
446 user = cmd->params[0]; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
447 |
10345 | 448 if (swboard->conv == NULL) |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
449 { |
10345 | 450 /* This is a helper switchboard */ |
451 msn_switchboard_disconnect(swboard); | |
452 } | |
453 else if (swboard->current_users > 1) | |
454 { | |
455 /* This is a switchboard used for a chat */ | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
456 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL); |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
457 } |
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
458 else |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
459 { |
10345 | 460 /* This is a switchboard used for a im session */ |
461 | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
462 char *str = NULL; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
463 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
464 if (cmd->param_count == 2 && atoi(cmd->params[1]) == 1) |
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
465 { |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
466 if (gaim_prefs_get_bool("/plugins/prpl/msn/conv_timeout_notice")) |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
467 { |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
468 str = g_strdup_printf(_("The conversation has become " |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
469 "inactive and timed out.")); |
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
470 } |
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
471 } |
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
472 else |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
473 { |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
474 if (gaim_prefs_get_bool("/plugins/prpl/msn/conv_close_notice")) |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
475 { |
10225 | 476 char *username; |
477 GaimAccount *account; | |
478 GaimBuddy *b; | |
479 | |
480 account = cmdproc->session->account; | |
481 | |
482 if ((b = gaim_find_buddy(account, user)) != NULL) | |
483 username = gaim_escape_html(gaim_buddy_get_alias(b)); | |
484 else | |
485 username = gaim_escape_html(user); | |
486 | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
487 str = g_strdup_printf(_("%s has closed the conversation " |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
488 "window."), username); |
10225 | 489 |
490 g_free(username); | |
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
491 } |
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
492 } |
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
493 |
10225 | 494 if (str != NULL) |
495 msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str); | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
496 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
497 msn_switchboard_disconnect(swboard); |
4542 | 498 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
499 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
500 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
501 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
502 iro_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
503 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
504 GaimAccount *account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
505 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
506 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
507 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
508 account = cmdproc->session->account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
509 gc = account->gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
510 swboard = cmdproc->servconn->data; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
511 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
512 swboard->total_users = atoi(cmd->params[2]); |
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
513 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
514 msn_switchboard_add_user(swboard, cmd->params[3]); |
4542 | 515 } |
516 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
517 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
518 joi_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
4542 | 519 { |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
520 MsnSession *session; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
521 GaimAccount *account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
522 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
523 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
524 const char *passport; |
4542 | 525 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
526 passport = cmd->params[0]; |
4542 | 527 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
528 session = cmdproc->session; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
529 account = session->account; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
530 gc = account->gc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
531 swboard = cmdproc->servconn->data; |
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
532 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
533 msn_switchboard_add_user(swboard, passport); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
534 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
535 msn_switchboard_process_queue(swboard); |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
536 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
537 send_clientcaps(swboard); |
10403 | 538 |
539 if (swboard->closed) | |
540 msn_switchboard_close(swboard); | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
541 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
542 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
543 static void |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
544 msg_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, size_t len) |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
545 { |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
546 MsnMessage *msg; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
547 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
548 msg = msn_message_new_from_cmd(cmdproc->session, cmd); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
549 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
550 msn_message_parse_payload(msg, payload, len); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
551 /* msn_message_show_readable(msg, "SB RECV", FALSE); */ |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
552 |
10284 | 553 if (msg->remote_user != NULL) |
554 g_free (msg->remote_user); | |
555 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
556 msg->remote_user = g_strdup(cmd->params[0]); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
557 msn_cmdproc_process_msg(cmdproc, msg); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
558 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
559 msn_message_destroy(msg); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
560 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
561 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
562 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
563 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
564 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
565 cmdproc->servconn->payload_len = atoi(cmd->params[2]); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
566 cmdproc->last_cmd->payload_cb = msg_cmd_post; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
567 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
568 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
569 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
570 nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
571 { |
10345 | 572 MsnMessage *msg; |
573 | |
574 msg = cmd->trans->data; | |
575 g_return_if_fail(msg != NULL); | |
576 | |
577 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_NAK); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
578 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
579 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
580 static void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
581 ack_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
582 { |
10403 | 583 MsnSwitchBoard *swboard; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
584 MsnMessage *msg; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
585 |
10345 | 586 msg = cmd->trans->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
587 |
10345 | 588 if (msg->ack_cb != NULL) |
589 msg->ack_cb(msg, msg->ack_data); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
590 |
10403 | 591 swboard = cmdproc->servconn->data; |
592 swboard->ack_list = g_list_remove(swboard->ack_list, msg); | |
10345 | 593 msn_message_unref(msg); |
4542 | 594 } |
595 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
596 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
597 out_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
598 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
599 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
600 MsnSwitchBoard *swboard; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
601 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
602 gc = cmdproc->session->account->gc; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
603 swboard = cmdproc->servconn->data; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
604 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
605 if (swboard->current_users > 1) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
606 serv_got_chat_left(gc, swboard->chat_id); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
607 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
608 msn_switchboard_disconnect(swboard); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
609 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
610 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
611 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
612 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
4542 | 613 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
614 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
615 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
616 swboard = cmdproc->servconn->data; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
617 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
618 #if 0 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
619 GList *l; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
620 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
621 for (l = swboard->users; l != NULL; l = l->next) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
622 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
623 const char *user; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
624 user = l->data; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
625 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
626 msn_cmdproc_send(cmdproc, "CAL", "%s", user); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
627 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
628 #endif |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
629 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
630 swboard->ready = TRUE; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
631 msn_cmdproc_process_queue(cmdproc); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
632 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
633 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
634 /************************************************************************** |
10345 | 635 * Message Handlers |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
636 **************************************************************************/ |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
637 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
638 plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
639 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
640 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
641 MsnSwitchBoard *swboard; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
642 const char *body; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
643 char *body_str; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
644 char *body_enc; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
645 char *body_final; |
10112 | 646 size_t body_len; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
647 const char *passport; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
648 const char *value; |
4542 | 649 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
650 gc = cmdproc->session->account->gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
651 swboard = cmdproc->servconn->data; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
652 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
653 body = msn_message_get_bin_data(msg, &body_len); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
654 body_str = g_strndup(body, body_len); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
655 body_enc = gaim_escape_html(body_str); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
656 g_free(body_str); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
657 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
658 passport = msg->remote_user; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
659 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
660 if (!strcmp(passport, "messenger@microsoft.com") && |
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
661 strstr(body, "immediate security update")) |
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
662 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
663 return; |
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
664 } |
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
665 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
666 #if 0 |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
667 if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
668 { |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
669 gaim_debug_misc("msn", "User-Agent = '%s'\n", value); |
4542 | 670 } |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
671 #endif |
4542 | 672 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
673 if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
674 { |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
675 char *pre_format, *post_format; |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
676 |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
677 msn_parse_format(value, &pre_format, &post_format); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
678 |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
679 body_final = g_strdup_printf("%s%s%s", pre_format, body_enc, post_format); |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
680 |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
681 g_free(pre_format); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
682 g_free(post_format); |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
683 g_free(body_enc); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
684 } |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
685 else |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
686 { |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
687 body_final = body_enc; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
688 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
689 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
690 if (swboard->current_users > 1) |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
691 { |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
692 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
693 time(NULL)); |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
694 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
695 else |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
696 serv_got_im(gc, passport, body_final, 0, time(NULL)); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
697 |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
698 g_free(body_final); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
699 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
700 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
701 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
702 control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
703 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
704 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
705 MsnSwitchBoard *swboard; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
706 const char *value; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
707 char *passport; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
708 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
709 gc = cmdproc->session->account->gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
710 swboard = cmdproc->servconn->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
711 passport = msg->remote_user; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
712 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
713 if (swboard->current_users == 1 && |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
714 (value = msn_message_get_attr(msg, "TypingUser")) != NULL) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
715 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
716 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
717 GAIM_TYPING); |
4542 | 718 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
719 } |
4542 | 720 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
721 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
722 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
723 { |
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
724 #if 0 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
725 MsnSession *session; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
726 MsnSwitchBoard *swboard; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
727 MsnUser *user; |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
728 GHashTable *clientcaps; |
5351
2aa7e4237142
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
729 const char *value; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
730 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
731 char *passport = msg->sender; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
732 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
733 session = cmdproc->session; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
734 swboard = cmdproc->servconn->swboard; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
735 |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
736 clientcaps = msn_message_get_hashtable_from_body(msg); |
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
737 #endif |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
738 } |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
739 |
10345 | 740 /************************************************************************** |
741 * Message stuff | |
742 **************************************************************************/ | |
743 /** Called when a message times out. */ | |
10225 | 744 static void |
745 msg_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
746 { | |
747 MsnMessage *msg; | |
748 | |
749 msg = trans->data; | |
750 | |
10345 | 751 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_TIMEOUT); |
10225 | 752 } |
753 | |
10345 | 754 /** Called when we receive an error of a message. */ |
10225 | 755 static void |
756 msg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
757 { | |
10345 | 758 msg_error_helper(cmdproc, trans->data, MSN_MSG_ERROR_UNKNOWN); |
10225 | 759 } |
760 | |
10345 | 761 #if 0 |
762 /** Called when we receive an ack of a special message. */ | |
10225 | 763 static void |
10345 | 764 msg_ack(MsnCmdProc *cmdproc, MsnCommand *cmd) |
10225 | 765 { |
766 MsnMessage *msg; | |
767 | |
768 msg = cmd->trans->data; | |
769 | |
10306
56cc5d49472b
[gaim-migrate @ 11492]
Luke Schierer <lschiere@pidgin.im>
parents:
10284
diff
changeset
|
770 if (msg->ack_cb != NULL) |
56cc5d49472b
[gaim-migrate @ 11492]
Luke Schierer <lschiere@pidgin.im>
parents:
10284
diff
changeset
|
771 msg->ack_cb(msg->ack_data); |
10284 | 772 |
773 msn_message_unref(msg); | |
10225 | 774 } |
775 | |
10345 | 776 /** Called when we receive a nak of a special message. */ |
777 static void | |
778 msg_nak(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
779 { | |
780 MsnMessage *msg; | |
781 | |
782 msg = cmd->trans->data; | |
783 | |
784 msn_message_unref(msg); | |
785 } | |
786 #endif | |
787 | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
788 void |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
789 msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg) |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
790 { |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
791 MsnCmdProc *cmdproc; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
792 MsnTransaction *trans; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
793 char *payload; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
794 gsize payload_len; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
795 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
796 g_return_if_fail(swboard != NULL); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
797 g_return_if_fail(msg != NULL); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
798 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
799 cmdproc = swboard->servconn->cmdproc; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
800 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
801 payload = msn_message_gen_payload(msg, &payload_len); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
802 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
803 /* msn_message_show_readable(msg, "SB SEND", FALSE); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
804 |
10225 | 805 trans = msn_transaction_new(cmdproc, "MSG", "%c %d", |
806 msn_message_get_flag(msg), payload_len); | |
807 | |
808 /* Data for callbacks */ | |
809 msn_transaction_set_data(trans, msg); | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
810 |
10345 | 811 if (msg->type == MSN_MSG_TEXT) |
10225 | 812 { |
10346 | 813 msg->ack_ref = TRUE; |
10345 | 814 msn_message_ref(msg); |
10403 | 815 swboard->ack_list = g_list_append(swboard->ack_list, msg); |
10225 | 816 msn_transaction_set_timeout_cb(trans, msg_timeout); |
817 } | |
10345 | 818 else if (msg->type == MSN_MSG_SLP) |
819 { | |
10346 | 820 msg->ack_ref = TRUE; |
10345 | 821 msn_message_ref(msg); |
10403 | 822 swboard->ack_list = g_list_append(swboard->ack_list, msg); |
10225 | 823 msn_transaction_set_timeout_cb(trans, msg_timeout); |
10345 | 824 #if 0 |
825 if (msg->ack_cb != NULL) | |
826 { | |
827 msn_transaction_add_cb(trans, "ACK", msg_ack); | |
828 msn_transaction_add_cb(trans, "NAK", msg_nak); | |
829 } | |
830 #endif | |
831 } | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
832 |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
833 trans->payload = payload; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
834 trans->payload_len = payload_len; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
835 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
836 msg->trans = trans; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
837 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
838 msn_cmdproc_send_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
839 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
840 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
841 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
842 msn_switchboard_queue_msg(MsnSwitchBoard *swboard, MsnMessage *msg) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
843 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
844 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
845 g_return_if_fail(msg != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
846 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
847 gaim_debug_info("msn", "Appending message to queue.\n"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
848 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
849 g_queue_push_tail(swboard->im_queue, msg); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
850 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
851 msn_message_ref(msg); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
852 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
853 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
854 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
855 msn_switchboard_process_queue(MsnSwitchBoard *swboard) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
856 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
857 MsnMessage *msg; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
858 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
859 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
860 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
861 gaim_debug_info("msn", "Processing queue\n"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
862 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
863 while ((msg = g_queue_pop_head(swboard->im_queue)) != NULL) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
864 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
865 gaim_debug_info("msn", "Sending message\n"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
866 msn_switchboard_send_msg(swboard, msg); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
867 msn_message_unref(msg); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
868 } |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
869 } |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
870 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
871 /************************************************************************** |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
872 * Connect stuff |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
873 **************************************************************************/ |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
874 static void |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
875 connect_cb(MsnServConn *servconn) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
876 { |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
877 MsnSwitchBoard *swboard; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
878 MsnCmdProc *cmdproc; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
879 GaimAccount *account; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
880 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
881 cmdproc = servconn->cmdproc; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
882 g_return_if_fail(cmdproc != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
883 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
884 cmdproc->ready = TRUE; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
885 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
886 account = servconn->session->account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
887 swboard = servconn->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
888 g_return_if_fail(swboard != NULL); |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
889 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
890 if (msn_switchboard_is_invited(swboard)) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
891 { |
10346 | 892 swboard->empty = FALSE; |
893 | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
894 msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
895 gaim_account_get_username(account), |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
896 swboard->auth_key, swboard->session_id); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
897 } |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
898 else |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
899 { |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
900 msn_cmdproc_send(cmdproc, "USR", "%s %s", |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
901 gaim_account_get_username(account), |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
902 swboard->auth_key); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
903 } |
4542 | 904 } |
905 | |
906 static void | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
907 disconnect_cb(MsnServConn *servconn) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
908 { |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
909 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
910 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
911 swboard = servconn->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
912 g_return_if_fail(swboard != NULL); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
913 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
914 msn_switchboard_destroy(swboard); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
915 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
916 |
10345 | 917 gboolean |
918 msn_switchboard_connect(MsnSwitchBoard *swboard, const char *host, int port) | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
919 { |
10345 | 920 g_return_val_if_fail(swboard != NULL, FALSE); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
921 |
10345 | 922 msn_servconn_set_connect_cb(swboard->servconn, connect_cb); |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
923 |
10345 | 924 return msn_servconn_connect(swboard->servconn, host, port); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
925 } |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
926 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
927 void |
10345 | 928 msn_switchboard_disconnect(MsnSwitchBoard *swboard) |
4542 | 929 { |
10345 | 930 g_return_if_fail(swboard != NULL); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
931 |
10345 | 932 msn_servconn_set_disconnect_cb(swboard->servconn, disconnect_cb); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
933 |
10345 | 934 msn_servconn_disconnect(swboard->servconn); |
4542 | 935 } |
936 | |
10345 | 937 /************************************************************************** |
938 * Call stuff | |
939 **************************************************************************/ | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
940 static void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
941 got_cal(MsnCmdProc *cmdproc, MsnCommand *cmd) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
942 { |
10403 | 943 #if 0 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
944 MsnSwitchBoard *swboard; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
945 const char *user; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
946 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
947 swboard = cmdproc->servconn->data; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
948 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
949 user = cmd->params[0]; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
950 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
951 msn_switchboard_add_user(swboard, user); |
10403 | 952 #endif |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
953 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
954 |
10225 | 955 static void |
956 cal_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
957 { | |
958 cal_error_helper(trans, MSN_SB_ERROR_UNKNOWN); | |
959 } | |
960 | |
961 static void | |
962 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
963 { | |
964 int reason = MSN_SB_ERROR_UNKNOWN; | |
965 | |
966 if (error == 217) | |
967 reason = MSN_SB_ERROR_USER_OFFLINE; | |
968 | |
969 cal_error_helper(trans, reason); | |
970 } | |
971 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
972 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
973 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
974 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
975 MsnTransaction *trans; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
976 MsnCmdProc *cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
977 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
978 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
979 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
980 cmdproc = swboard->servconn->cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
981 |
10225 | 982 trans = msn_transaction_new(cmdproc, "CAL", "%s", user); |
10403 | 983 /* this doesn't do anything, but users seem to think that |
984 * 'Unhandled command' is some kind of error, so we don't report it */ | |
985 msn_transaction_add_cb(trans, "CAL", got_cal); | |
10225 | 986 |
987 msn_transaction_set_data(trans, swboard); | |
988 msn_transaction_set_timeout_cb(trans, cal_timeout); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
989 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
990 if (swboard->ready) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
991 msn_cmdproc_send_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
992 else |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
993 msn_cmdproc_queue_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
994 } |
4542 | 995 |
10345 | 996 /************************************************************************** |
997 * Create & Transfer stuff | |
998 **************************************************************************/ | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
999 static void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1000 got_swboard(MsnCmdProc *cmdproc, MsnCommand *cmd) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1001 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1002 MsnSwitchBoard *swboard; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1003 char *host; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1004 int port; |
9218 | 1005 swboard = cmd->trans->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1006 |
10403 | 1007 if (g_list_find(cmdproc->session->switches, swboard) == NULL) |
1008 /* The conversation window was closed. */ | |
1009 return; | |
1010 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1011 msn_switchboard_set_auth_key(swboard, cmd->params[4]); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1012 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1013 msn_parse_socket(cmd->params[2], &host, &port); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1014 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1015 if (swboard->session->http_method) |
10044 | 1016 { |
1017 GaimAccount *account; | |
1018 MsnSession *session; | |
1019 MsnServConn *servconn; | |
1020 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1021 port = 80; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1022 |
10044 | 1023 session = swboard->session; |
1024 servconn = swboard->servconn; | |
1025 account = session->account; | |
1026 | |
10345 | 1027 swboard->empty = FALSE; |
10044 | 1028 |
1029 servconn->http_data->gateway_host = g_strdup(host); | |
1030 | |
1031 #if 0 | |
1032 servconn->connected = TRUE; | |
1033 servconn->cmdproc->ready = TRUE; | |
1034 #endif | |
1035 | |
1036 if (msn_switchboard_is_invited(swboard)) | |
1037 { | |
1038 msn_cmdproc_send(servconn->cmdproc, "ANS", "%s %s %s", | |
1039 gaim_account_get_username(account), | |
1040 swboard->auth_key, swboard->session_id); | |
1041 } | |
1042 else | |
1043 { | |
1044 msn_cmdproc_send(servconn->cmdproc, "USR", "%s %s", | |
1045 gaim_account_get_username(account), | |
1046 swboard->auth_key); | |
1047 } | |
1048 } | |
1049 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1050 msn_switchboard_connect(swboard, host, port); |
10093 | 1051 |
1052 g_free(host); | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
1053 } |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1054 |
10225 | 1055 static void |
1056 xfr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
1057 { | |
1058 MsnSwitchBoard *swboard; | |
1059 int reason = MSN_SB_ERROR_UNKNOWN; | |
1060 | |
1061 if (error == 913) | |
1062 reason = MSN_SB_ERROR_OFFLINE; | |
1063 | |
1064 swboard = trans->data; | |
1065 | |
1066 swboard_error_helper(swboard, reason, swboard->im_user); | |
1067 } | |
1068 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1069 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1070 msn_switchboard_request(MsnSwitchBoard *swboard) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1071 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1072 MsnCmdProc *cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1073 MsnTransaction *trans; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1074 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1075 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1076 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1077 cmdproc = swboard->session->notification->cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1078 |
10225 | 1079 trans = msn_transaction_new(cmdproc, "XFR", "%s", "SB"); |
1080 msn_transaction_add_cb(trans, "XFR", got_swboard); | |
10403 | 1081 |
10225 | 1082 msn_transaction_set_data(trans, swboard); |
1083 msn_transaction_set_error_cb(trans, xfr_error); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1084 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1085 msn_cmdproc_send_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1086 } |
10345 | 1087 |
10403 | 1088 void |
1089 msn_switchboard_close(MsnSwitchBoard *swboard) | |
1090 { | |
1091 g_return_if_fail(swboard != NULL); | |
1092 | |
1093 if (g_queue_is_empty(swboard->im_queue)) | |
1094 { | |
1095 MsnCmdProc *cmdproc; | |
1096 | |
1097 cmdproc = swboard->servconn->cmdproc; | |
1098 | |
1099 msn_cmdproc_send_quick(cmdproc, "OUT", NULL, NULL); | |
1100 | |
1101 msn_switchboard_destroy(swboard); | |
1102 } | |
1103 else | |
1104 swboard->closed = TRUE; | |
1105 } | |
1106 | |
10345 | 1107 /************************************************************************** |
1108 * Init stuff | |
1109 **************************************************************************/ | |
1110 void | |
1111 msn_switchboard_init(void) | |
1112 { | |
1113 cbs_table = msn_table_new(); | |
1114 | |
1115 msn_table_add_cmd(cbs_table, "ANS", "ANS", ans_cmd); | |
1116 msn_table_add_cmd(cbs_table, "ANS", "IRO", iro_cmd); | |
1117 | |
1118 msn_table_add_cmd(cbs_table, "MSG", "ACK", ack_cmd); | |
1119 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); | |
1120 | |
1121 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); | |
1122 | |
1123 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); | |
1124 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); | |
1125 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); | |
1126 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); | |
1127 | |
1128 #if 0 | |
1129 /* They might skip the history */ | |
1130 msn_table_add_cmd(cbs_table, NULL, "ACK", NULL); | |
1131 #endif | |
1132 | |
1133 msn_table_add_error(cbs_table, "MSG", msg_error); | |
1134 msn_table_add_error(cbs_table, "CAL", cal_error); | |
1135 | |
1136 /* Register the message type callbacks. */ | |
1137 msn_table_add_msg_type(cbs_table, "text/plain", | |
1138 plain_msg); | |
1139 msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", | |
1140 control_msg); | |
1141 msn_table_add_msg_type(cbs_table, "text/x-clientcaps", | |
1142 clientcaps_msg); | |
1143 msn_table_add_msg_type(cbs_table, "text/x-clientinfo", | |
1144 clientcaps_msg); | |
1145 msn_table_add_msg_type(cbs_table, "application/x-msnmsgrp2p", | |
1146 msn_p2p_msg); | |
1147 msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", | |
1148 msn_emoticon_msg); | |
1149 #if 0 | |
1150 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", | |
1151 msn_invite_msg); | |
1152 #endif | |
1153 } | |
1154 | |
1155 void | |
1156 msn_switchboard_end(void) | |
1157 { | |
1158 msn_table_destroy(cbs_table); | |
1159 } |