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