Mercurial > pidgin.yaz
annotate src/protocols/msn/slp.c @ 19738:bc30c6270d9f
[gaim-migrate @ 16473]
add the Framework of SOAP request
Now can retrieve the Contact via SOAP Request.
so many bug still exist!
commited by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Sun, 09 Jul 2006 16:48:25 +0000 |
parents | 967ef719cb62 |
children | 99b9b58b19dd bddd32f36bde |
rev | line source |
---|---|
9193 | 1 /** |
2 * @file msnslp.c MSNSLP support | |
3 * | |
4 * gaim | |
5 * | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
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:
9193
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:
9193
diff
changeset
|
8 * source distribution. |
9193 | 9 * |
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 | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 #include "msn.h" | |
25 #include "slp.h" | |
26 #include "slpcall.h" | |
27 #include "slpmsg.h" | |
28 #include "slpsession.h" | |
29 | |
30 #include "object.h" | |
31 #include "user.h" | |
32 #include "switchboard.h" | |
33 | |
13125 | 34 /* ms to delay between sending buddy icon requests to the server. */ |
35 #define BUDDY_ICON_DELAY 20000 | |
36 | |
9193 | 37 static void send_ok(MsnSlpCall *slpcall, const char *branch, |
38 const char *type, const char *content); | |
39 | |
40 static void send_decline(MsnSlpCall *slpcall, const char *branch, | |
41 const char *type, const char *content); | |
42 | |
9860 | 43 void msn_request_user_display(MsnUser *user); |
44 | |
9193 | 45 /************************************************************************** |
46 * Util | |
47 **************************************************************************/ | |
48 | |
11897 | 49 static char * |
9193 | 50 get_token(const char *str, const char *start, const char *end) |
51 { | |
52 const char *c, *c2; | |
53 | |
54 if ((c = strstr(str, start)) == NULL) | |
55 return NULL; | |
56 | |
57 c += strlen(start); | |
58 | |
59 if (end != NULL) | |
60 { | |
61 if ((c2 = strstr(c, end)) == NULL) | |
62 return NULL; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
63 |
9193 | 64 return g_strndup(c, c2 - c); |
65 } | |
66 else | |
67 { | |
68 /* This has to be changed */ | |
69 return g_strdup(c); | |
70 } | |
71 | |
72 } | |
73 | |
74 /************************************************************************** | |
75 * Xfer | |
76 **************************************************************************/ | |
77 | |
78 static void | |
79 msn_xfer_init(GaimXfer *xfer) | |
80 { | |
81 MsnSlpCall *slpcall; | |
82 /* MsnSlpLink *slplink; */ | |
83 char *content; | |
84 | |
85 gaim_debug_info("msn", "xfer_init\n"); | |
86 | |
87 slpcall = xfer->data; | |
88 | |
89 /* Send Ok */ | |
90 content = g_strdup_printf("SessionID: %lu\r\n\r\n", | |
91 slpcall->session_id); | |
92 | |
93 send_ok(slpcall, slpcall->branch, "application/x-msnmsgr-sessionreqbody", | |
94 content); | |
95 | |
96 g_free(content); | |
97 msn_slplink_unleash(slpcall->slplink); | |
98 } | |
99 | |
100 void | |
101 msn_xfer_cancel(GaimXfer *xfer) | |
102 { | |
103 MsnSlpCall *slpcall; | |
104 char *content; | |
105 | |
9788 | 106 g_return_if_fail(xfer != NULL); |
107 g_return_if_fail(xfer->data != NULL); | |
108 | |
9193 | 109 slpcall = xfer->data; |
110 | |
111 if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) | |
112 { | |
113 if (slpcall->started) | |
114 { | |
115 msn_slp_call_close(slpcall); | |
116 } | |
117 else | |
118 { | |
119 content = g_strdup_printf("SessionID: %lu\r\n\r\n", | |
120 slpcall->session_id); | |
121 | |
122 send_decline(slpcall, slpcall->branch, "application/x-msnmsgr-sessionreqbody", | |
123 content); | |
124 | |
125 g_free(content); | |
126 msn_slplink_unleash(slpcall->slplink); | |
10773 | 127 |
128 msn_slp_call_destroy(slpcall); | |
9193 | 129 } |
130 } | |
131 } | |
132 | |
133 void | |
134 msn_xfer_progress_cb(MsnSlpCall *slpcall, gsize total_length, gsize len, gsize offset) | |
135 { | |
136 GaimXfer *xfer; | |
137 | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
138 xfer = slpcall->xfer; |
9193 | 139 |
9226
7a00289f2ef1
[gaim-migrate @ 10022]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
140 xfer->bytes_sent = (offset + len); |
7a00289f2ef1
[gaim-migrate @ 10022]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
141 xfer->bytes_remaining = total_length - (offset + len); |
9193 | 142 |
143 gaim_xfer_update_progress(xfer); | |
144 } | |
145 | |
146 void | |
13125 | 147 msn_xfer_end_cb(MsnSlpCall *slpcall, MsnSession *session) |
9193 | 148 { |
10225 | 149 if ((gaim_xfer_get_status(slpcall->xfer) != GAIM_XFER_STATUS_DONE) && |
150 (gaim_xfer_get_status(slpcall->xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) && | |
151 (gaim_xfer_get_status(slpcall->xfer) != GAIM_XFER_STATUS_CANCEL_LOCAL)) | |
9226
7a00289f2ef1
[gaim-migrate @ 10022]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
152 { |
10226 | 153 gaim_xfer_cancel_remote(slpcall->xfer); |
9226
7a00289f2ef1
[gaim-migrate @ 10022]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
154 } |
9193 | 155 } |
156 | |
9259
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
157 void |
11138 | 158 msn_xfer_completed_cb(MsnSlpCall *slpcall, const guchar *body, |
11137 | 159 gsize size) |
9259
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
160 { |
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
161 gaim_xfer_set_completed(slpcall->xfer, TRUE); |
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
162 } |
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
163 |
9193 | 164 /************************************************************************** |
165 * SLP Control | |
166 **************************************************************************/ | |
167 | |
168 #if 0 | |
169 static void | |
170 got_transresp(MsnSlpCall *slpcall, const char *nonce, | |
171 const char *ips_str, int port) | |
172 { | |
173 MsnDirectConn *directconn; | |
174 char **ip_addrs, **c; | |
175 | |
176 directconn = msn_directconn_new(slpcall->slplink); | |
177 | |
178 directconn->initial_call = slpcall; | |
179 | |
180 /* msn_directconn_parse_nonce(directconn, nonce); */ | |
181 directconn->nonce = g_strdup(nonce); | |
182 | |
183 ip_addrs = g_strsplit(ips_str, " ", -1); | |
184 | |
185 for (c = ip_addrs; *c != NULL; c++) | |
186 { | |
187 gaim_debug_info("msn", "ip_addr = %s\n", *c); | |
188 if (msn_directconn_connect(directconn, *c, port)) | |
189 break; | |
190 } | |
191 | |
192 g_strfreev(ip_addrs); | |
193 } | |
194 #endif | |
195 | |
196 static void | |
197 send_ok(MsnSlpCall *slpcall, const char *branch, | |
198 const char *type, const char *content) | |
199 { | |
200 MsnSlpLink *slplink; | |
201 MsnSlpMessage *slpmsg; | |
202 | |
203 slplink = slpcall->slplink; | |
204 | |
205 /* 200 OK */ | |
206 slpmsg = msn_slpmsg_sip_new(slpcall, 1, | |
207 "MSNSLP/1.0 200 OK", | |
208 branch, type, content); | |
209 | |
10345 | 210 #ifdef MSN_DEBUG_SLP |
9193 | 211 slpmsg->info = "SLP 200 OK"; |
212 slpmsg->text_body = TRUE; | |
213 #endif | |
214 | |
215 msn_slplink_queue_slpmsg(slplink, slpmsg); | |
216 | |
217 msn_slp_call_session_init(slpcall); | |
218 } | |
219 | |
220 static void | |
221 send_decline(MsnSlpCall *slpcall, const char *branch, | |
222 const char *type, const char *content) | |
223 { | |
224 MsnSlpLink *slplink; | |
225 MsnSlpMessage *slpmsg; | |
226 | |
227 slplink = slpcall->slplink; | |
228 | |
229 /* 603 Decline */ | |
230 slpmsg = msn_slpmsg_sip_new(slpcall, 1, | |
231 "MSNSLP/1.0 603 Decline", | |
232 branch, type, content); | |
233 | |
10345 | 234 #ifdef MSN_DEBUG_SLP |
9193 | 235 slpmsg->info = "SLP 603 Decline"; |
236 slpmsg->text_body = TRUE; | |
237 #endif | |
238 | |
239 msn_slplink_queue_slpmsg(slplink, slpmsg); | |
240 } | |
241 | |
10047 | 242 #define MAX_FILE_NAME_LEN 0x226 |
243 | |
9193 | 244 static void |
245 got_sessionreq(MsnSlpCall *slpcall, const char *branch, | |
246 const char *euf_guid, const char *context) | |
247 { | |
248 if (!strcmp(euf_guid, "A4268EEC-FEC5-49E5-95C3-F126696BDBF6")) | |
249 { | |
250 /* Emoticon or UserDisplay */ | |
251 MsnSlpSession *slpsession; | |
252 MsnSlpLink *slplink; | |
253 MsnSlpMessage *slpmsg; | |
254 MsnObject *obj; | |
255 char *msnobj_data; | |
256 const char *file_name; | |
257 char *content; | |
11127 | 258 gsize len; |
9193 | 259 int type; |
260 | |
261 /* Send Ok */ | |
262 content = g_strdup_printf("SessionID: %lu\r\n\r\n", | |
263 slpcall->session_id); | |
264 | |
265 send_ok(slpcall, branch, "application/x-msnmsgr-sessionreqbody", | |
266 content); | |
267 | |
268 g_free(content); | |
269 | |
270 slplink = slpcall->slplink; | |
271 | |
11127 | 272 msnobj_data = (char *)gaim_base64_decode(context, &len); |
9193 | 273 obj = msn_object_new_from_string(msnobj_data); |
274 type = msn_object_get_type(obj); | |
275 g_free(msnobj_data); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
276 |
9193 | 277 if (!(type == MSN_OBJECT_USERTILE)) |
278 { | |
279 gaim_debug_error("msn", "Wrong object?\n"); | |
280 msn_object_destroy(obj); | |
281 g_return_if_reached(); | |
282 } | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
283 |
9193 | 284 file_name = msn_object_get_real_location(obj); |
285 | |
9858 | 286 if (file_name == NULL) |
287 { | |
288 gaim_debug_error("msn", "Wrong object.\n"); | |
289 msn_object_destroy(obj); | |
290 g_return_if_reached(); | |
291 } | |
292 | |
10519 | 293 msn_object_destroy(obj); |
294 | |
9193 | 295 slpsession = msn_slplink_find_slp_session(slplink, |
9861 | 296 slpcall->session_id); |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
297 |
9193 | 298 /* DATA PREP */ |
299 slpmsg = msn_slpmsg_new(slplink); | |
10345 | 300 slpmsg->slpcall = slpcall; |
9193 | 301 slpmsg->slpsession = slpsession; |
302 slpmsg->session_id = slpsession->id; | |
303 msn_slpmsg_set_body(slpmsg, NULL, 4); | |
10345 | 304 #ifdef MSN_DEBUG_SLP |
9193 | 305 slpmsg->info = "SLP DATA PREP"; |
306 #endif | |
307 msn_slplink_queue_slpmsg(slplink, slpmsg); | |
308 | |
309 /* DATA */ | |
310 slpmsg = msn_slpmsg_new(slplink); | |
10345 | 311 slpmsg->slpcall = slpcall; |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
312 slpmsg->slpsession = slpsession; |
9193 | 313 slpmsg->flags = 0x20; |
10345 | 314 #ifdef MSN_DEBUG_SLP |
9193 | 315 slpmsg->info = "SLP DATA"; |
316 #endif | |
317 msn_slpmsg_open_file(slpmsg, file_name); | |
318 msn_slplink_queue_slpmsg(slplink, slpmsg); | |
319 } | |
320 else if (!strcmp(euf_guid, "5D3E02AB-6190-11D3-BBBB-00C04F795683")) | |
321 { | |
322 /* File Transfer */ | |
323 GaimAccount *account; | |
324 GaimXfer *xfer; | |
325 char *bin; | |
11127 | 326 gsize bin_len; |
9193 | 327 guint32 file_size; |
328 char *file_name; | |
10047 | 329 gunichar2 *uni_name; |
9193 | 330 |
331 account = slpcall->slplink->session->account; | |
332 | |
9259
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
333 slpcall->cb = msn_xfer_completed_cb; |
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9231
diff
changeset
|
334 slpcall->end_cb = msn_xfer_end_cb; |
9193 | 335 slpcall->progress_cb = msn_xfer_progress_cb; |
336 slpcall->branch = g_strdup(branch); | |
337 | |
10296 | 338 slpcall->pending = TRUE; |
339 | |
9193 | 340 xfer = gaim_xfer_new(account, GAIM_XFER_RECEIVE, |
341 slpcall->slplink->remote_user); | |
342 | |
11127 | 343 bin = (char *)gaim_base64_decode(context, &bin_len); |
9263
70153c759016
[gaim-migrate @ 10062]
Christian Hammond <chipx86@chipx86.com>
parents:
9259
diff
changeset
|
344 file_size = GUINT32_FROM_LE(*((gsize *)bin + 2)); |
10225 | 345 |
10047 | 346 uni_name = (gunichar2 *)(bin + 20); |
347 while(*uni_name != 0 && ((char *)uni_name - (bin + 20)) < MAX_FILE_NAME_LEN) { | |
348 *uni_name = GUINT16_FROM_LE(*uni_name); | |
349 uni_name++; | |
350 } | |
10225 | 351 |
9193 | 352 file_name = g_utf16_to_utf8((const gunichar2 *)(bin + 20), -1, |
353 NULL, NULL, NULL); | |
354 | |
355 g_free(bin); | |
356 | |
357 gaim_xfer_set_filename(xfer, file_name); | |
358 gaim_xfer_set_size(xfer, file_size); | |
359 gaim_xfer_set_init_fnc(xfer, msn_xfer_init); | |
360 gaim_xfer_set_request_denied_fnc(xfer, msn_xfer_cancel); | |
361 gaim_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel); | |
362 | |
363 slpcall->xfer = xfer; | |
364 xfer->data = slpcall; | |
365 | |
366 gaim_xfer_request(xfer); | |
367 } | |
368 } | |
369 | |
370 void | |
371 send_bye(MsnSlpCall *slpcall, const char *type) | |
372 { | |
373 MsnSlpLink *slplink; | |
374 MsnSlpMessage *slpmsg; | |
375 char *header; | |
376 | |
377 slplink = slpcall->slplink; | |
378 | |
379 g_return_if_fail(slplink != NULL); | |
380 | |
381 header = g_strdup_printf("BYE MSNMSGR:%s MSNSLP/1.0", | |
382 slplink->local_user); | |
383 | |
384 slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, | |
385 "A0D624A6-6C0C-4283-A9E0-BC97B4B46D32", | |
386 type, | |
387 "\r\n"); | |
388 g_free(header); | |
389 | |
10345 | 390 #ifdef MSN_DEBUG_SLP |
9193 | 391 slpmsg->info = "SLP BYE"; |
392 slpmsg->text_body = TRUE; | |
393 #endif | |
394 | |
395 msn_slplink_queue_slpmsg(slplink, slpmsg); | |
396 } | |
397 | |
398 static void | |
399 got_invite(MsnSlpCall *slpcall, | |
400 const char *branch, const char *type, const char *content) | |
401 { | |
402 MsnSlpLink *slplink; | |
403 | |
404 slplink = slpcall->slplink; | |
405 | |
406 if (!strcmp(type, "application/x-msnmsgr-sessionreqbody")) | |
407 { | |
408 char *euf_guid, *context; | |
409 char *temp; | |
410 | |
411 euf_guid = get_token(content, "EUF-GUID: {", "}\r\n"); | |
412 | |
413 temp = get_token(content, "SessionID: ", "\r\n"); | |
414 if (temp != NULL) | |
415 slpcall->session_id = atoi(temp); | |
416 g_free(temp); | |
417 | |
418 temp = get_token(content, "AppID: ", "\r\n"); | |
419 if (temp != NULL) | |
420 slpcall->app_id = atoi(temp); | |
421 g_free(temp); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
422 |
9193 | 423 context = get_token(content, "Context: ", "\r\n"); |
424 | |
425 got_sessionreq(slpcall, branch, euf_guid, context); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
426 |
9193 | 427 g_free(context); |
428 g_free(euf_guid); | |
429 } | |
430 else if (!strcmp(type, "application/x-msnmsgr-transreqbody")) | |
431 { | |
432 /* A direct connection? */ | |
433 | |
434 char *listening, *nonce; | |
435 char *content; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
436 |
9193 | 437 if (FALSE) |
438 { | |
439 #if 0 | |
440 MsnDirectConn *directconn; | |
441 /* const char *ip_addr; */ | |
442 char *ip_port; | |
443 int port; | |
444 | |
445 /* ip_addr = gaim_prefs_get_string("/core/ft/public_ip"); */ | |
446 ip_port = "5190"; | |
447 listening = "true"; | |
448 nonce = rand_guid(); | |
449 | |
450 directconn = msn_directconn_new(slplink); | |
451 | |
452 /* msn_directconn_parse_nonce(directconn, nonce); */ | |
453 directconn->nonce = g_strdup(nonce); | |
454 | |
455 msn_directconn_listen(directconn); | |
456 | |
457 port = directconn->port; | |
458 | |
459 content = g_strdup_printf( | |
460 "Bridge: TCPv1\r\n" | |
461 "Listening: %s\r\n" | |
462 "Nonce: {%s}\r\n" | |
463 "Ipv4Internal-Addrs: 192.168.0.82\r\n" | |
464 "Ipv4Internal-Port: %d\r\n" | |
465 "\r\n", | |
466 listening, | |
467 nonce, | |
468 port); | |
469 #endif | |
470 } | |
471 else | |
472 { | |
473 listening = "false"; | |
474 nonce = g_strdup("00000000-0000-0000-0000-000000000000"); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
475 |
9193 | 476 content = g_strdup_printf( |
477 "Bridge: TCPv1\r\n" | |
478 "Listening: %s\r\n" | |
479 "Nonce: {%s}\r\n" | |
480 "\r\n", | |
481 listening, | |
482 nonce); | |
483 } | |
484 | |
485 send_ok(slpcall, branch, | |
486 "application/x-msnmsgr-transrespbody", content); | |
487 | |
488 g_free(content); | |
489 g_free(nonce); | |
490 } | |
491 else if (!strcmp(type, "application/x-msnmsgr-transrespbody")) | |
492 { | |
493 #if 0 | |
494 char *ip_addrs; | |
495 char *temp; | |
496 char *nonce; | |
497 int port; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
498 |
9193 | 499 nonce = get_token(content, "Nonce: {", "}\r\n"); |
500 ip_addrs = get_token(content, "IPv4Internal-Addrs: ", "\r\n"); | |
501 | |
502 temp = get_token(content, "IPv4Internal-Port: ", "\r\n"); | |
503 if (temp != NULL) | |
504 port = atoi(temp); | |
505 else | |
506 port = -1; | |
507 g_free(temp); | |
508 | |
509 if (ip_addrs == NULL) | |
510 return; | |
511 | |
512 if (port > 0) | |
513 got_transresp(slpcall, nonce, ip_addrs, port); | |
514 | |
515 g_free(nonce); | |
516 g_free(ip_addrs); | |
517 #endif | |
518 } | |
519 } | |
520 | |
521 static void | |
522 got_ok(MsnSlpCall *slpcall, | |
523 const char *type, const char *content) | |
524 { | |
525 g_return_if_fail(slpcall != NULL); | |
526 g_return_if_fail(type != NULL); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
527 |
9193 | 528 if (!strcmp(type, "application/x-msnmsgr-sessionreqbody")) |
529 { | |
530 #if 0 | |
531 if (slpcall->type == MSN_SLPCALL_DC) | |
532 { | |
533 /* First let's try a DirectConnection. */ | |
534 | |
535 MsnSlpLink *slplink; | |
536 MsnSlpMessage *slpmsg; | |
537 char *header; | |
538 char *content; | |
539 char *branch; | |
540 | |
541 slplink = slpcall->slplink; | |
542 | |
543 branch = rand_guid(); | |
544 | |
545 content = g_strdup_printf( | |
546 "Bridges: TRUDPv1 TCPv1\r\n" | |
547 "NetID: 0\r\n" | |
548 "Conn-Type: Direct-Connect\r\n" | |
549 "UPnPNat: false\r\n" | |
550 "ICF: false\r\n" | |
551 ); | |
552 | |
553 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", | |
554 slplink->remote_user); | |
555 | |
556 slpmsg = msn_slp_sipmsg_new(slpcall, 0, header, branch, | |
557 "application/x-msnmsgr-transreqbody", | |
558 content); | |
559 | |
10345 | 560 #ifdef MSN_DEBUG_SLP |
9193 | 561 slpmsg->info = "SLP INVITE"; |
562 slpmsg->text_body = TRUE; | |
563 #endif | |
564 msn_slplink_send_slpmsg(slplink, slpmsg); | |
565 | |
566 g_free(header); | |
567 g_free(content); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
568 |
9193 | 569 g_free(branch); |
570 } | |
571 else | |
572 { | |
573 msn_slp_call_session_init(slpcall); | |
574 } | |
575 #else | |
576 msn_slp_call_session_init(slpcall); | |
577 #endif | |
578 } | |
579 else if (!strcmp(type, "application/x-msnmsgr-transreqbody")) | |
580 { | |
581 /* Do we get this? */ | |
582 gaim_debug_info("msn", "OK with transreqbody\n"); | |
583 } | |
584 else if (!strcmp(type, "application/x-msnmsgr-transrespbody")) | |
585 { | |
586 #if 0 | |
587 char *ip_addrs; | |
588 char *temp; | |
589 char *nonce; | |
590 int port; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
591 |
9193 | 592 nonce = get_token(content, "Nonce: {", "}\r\n"); |
593 ip_addrs = get_token(content, "IPv4Internal-Addrs: ", "\r\n"); | |
594 | |
595 temp = get_token(content, "IPv4Internal-Port: ", "\r\n"); | |
596 if (temp != NULL) | |
597 port = atoi(temp); | |
598 else | |
599 port = -1; | |
600 g_free(temp); | |
601 | |
602 if (ip_addrs == NULL) | |
603 return; | |
604 | |
605 if (port > 0) | |
606 got_transresp(slpcall, nonce, ip_addrs, port); | |
607 | |
608 g_free(nonce); | |
609 g_free(ip_addrs); | |
610 #endif | |
611 } | |
612 } | |
613 | |
614 MsnSlpCall * | |
11236 | 615 msn_slp_sip_recv(MsnSlpLink *slplink, const char *body) |
9193 | 616 { |
617 MsnSlpCall *slpcall; | |
618 | |
10907 | 619 if (body == NULL) |
620 { | |
621 gaim_debug_warning("msn", "received bogus message\n"); | |
622 return NULL; | |
623 } | |
624 | |
9193 | 625 if (!strncmp(body, "INVITE", strlen("INVITE"))) |
626 { | |
627 char *branch; | |
628 char *content; | |
629 char *content_type; | |
630 | |
631 slpcall = msn_slp_call_new(slplink); | |
632 | |
633 /* From: <msnmsgr:buddy@hotmail.com> */ | |
634 #if 0 | |
635 slpcall->remote_user = get_token(body, "From: <msnmsgr:", ">\r\n"); | |
636 #endif | |
637 | |
638 branch = get_token(body, ";branch={", "}"); | |
639 | |
640 slpcall->id = get_token(body, "Call-ID: {", "}"); | |
641 | |
642 #if 0 | |
643 long content_len = -1; | |
644 | |
645 temp = get_token(body, "Content-Length: ", "\r\n"); | |
646 if (temp != NULL) | |
647 content_len = atoi(temp); | |
648 g_free(temp); | |
649 #endif | |
650 content_type = get_token(body, "Content-Type: ", "\r\n"); | |
651 | |
652 content = get_token(body, "\r\n\r\n", NULL); | |
653 | |
654 got_invite(slpcall, branch, content_type, content); | |
655 | |
10519 | 656 g_free(branch); |
9193 | 657 g_free(content_type); |
658 g_free(content); | |
659 } | |
660 else if (!strncmp(body, "MSNSLP/1.0 ", strlen("MSNSLP/1.0 "))) | |
661 { | |
662 char *content; | |
663 char *content_type; | |
664 /* Make sure this is "OK" */ | |
665 const char *status = body + strlen("MSNSLP/1.0 "); | |
666 char *call_id; | |
667 | |
668 call_id = get_token(body, "Call-ID: {", "}"); | |
669 slpcall = msn_slplink_find_slp_call(slplink, call_id); | |
670 g_free(call_id); | |
671 | |
9231
ac8790437abe
[gaim-migrate @ 10027]
Christian Hammond <chipx86@chipx86.com>
parents:
9226
diff
changeset
|
672 g_return_val_if_fail(slpcall != NULL, NULL); |
ac8790437abe
[gaim-migrate @ 10027]
Christian Hammond <chipx86@chipx86.com>
parents:
9226
diff
changeset
|
673 |
9193 | 674 if (strncmp(status, "200 OK", 6)) |
675 { | |
676 /* It's not valid. Kill this off. */ | |
677 char temp[32]; | |
678 const char *c; | |
679 | |
680 /* Eww */ | |
681 if ((c = strchr(status, '\r')) || (c = strchr(status, '\n')) || | |
682 (c = strchr(status, '\0'))) | |
683 { | |
9739 | 684 size_t offset = c - status; |
685 if (offset >= sizeof(temp)) | |
686 offset = sizeof(temp) - 1; | |
10225 | 687 |
9739 | 688 strncpy(temp, status, offset); |
689 temp[offset] = '\0'; | |
9193 | 690 } |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
691 |
9193 | 692 gaim_debug_error("msn", "Received non-OK result: %s\n", temp); |
693 | |
694 slpcall->wasted = TRUE; | |
695 | |
696 /* msn_slp_call_destroy(slpcall); */ | |
697 return slpcall; | |
698 } | |
699 | |
700 content_type = get_token(body, "Content-Type: ", "\r\n"); | |
701 | |
702 content = get_token(body, "\r\n\r\n", NULL); | |
703 | |
704 got_ok(slpcall, content_type, content); | |
705 | |
706 g_free(content_type); | |
707 g_free(content); | |
708 } | |
709 else if (!strncmp(body, "BYE", strlen("BYE"))) | |
710 { | |
711 char *call_id; | |
712 | |
713 call_id = get_token(body, "Call-ID: {", "}"); | |
714 slpcall = msn_slplink_find_slp_call(slplink, call_id); | |
715 g_free(call_id); | |
716 | |
717 if (slpcall != NULL) | |
718 slpcall->wasted = TRUE; | |
719 | |
720 /* msn_slp_call_destroy(slpcall); */ | |
721 } | |
722 else | |
723 slpcall = NULL; | |
724 | |
725 return slpcall; | |
726 } | |
727 | |
728 /************************************************************************** | |
729 * Msg Callbacks | |
730 **************************************************************************/ | |
731 | |
732 void | |
733 msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | |
734 { | |
735 MsnSession *session; | |
736 MsnSlpLink *slplink; | |
737 | |
738 session = cmdproc->servconn->session; | |
739 slplink = msn_session_get_slplink(session, msg->remote_user); | |
740 | |
10602 | 741 if (slplink->swboard == NULL) |
742 { | |
10887 | 743 /* We will need this in order to change its flags. */ |
10602 | 744 slplink->swboard = (MsnSwitchBoard *)cmdproc->data; |
10887 | 745 /* If swboard is NULL, something has probably gone wrong earlier on |
746 * I didn't want to do this, but MSN 7 is somehow causing us to crash | |
747 * here, I couldn't reproduce it to debug more, and people are | |
748 * reporting bugs. Hopefully this doesn't cause more crashes. Stu. | |
749 */ | |
750 if (slplink->swboard != NULL) | |
751 slplink->swboard->slplink = slplink; | |
752 else | |
753 gaim_debug_error("msn", "msn_p2p_msg, swboard is NULL, ouch!\n"); | |
10602 | 754 } |
755 | |
9193 | 756 msn_slplink_process_msg(slplink, msg); |
757 } | |
758 | |
11137 | 759 static void |
9193 | 760 got_emoticon(MsnSlpCall *slpcall, |
11137 | 761 const guchar *data, gsize size) |
9193 | 762 { |
10526 | 763 |
764 GaimConversation *conv; | |
765 GaimConnection *gc; | |
766 const char *who; | |
9193 | 767 |
10526 | 768 gc = slpcall->slplink->session->account->gc; |
769 who = slpcall->slplink->remote_user; | |
10773 | 770 |
11338 | 771 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who, gc->account); |
10403 | 772 |
10526 | 773 /* FIXME: it would be better if we wrote the data as we received it |
774 instead of all at once, calling write multiple times and | |
775 close once at the very end | |
776 */ | |
777 gaim_conv_custom_smiley_write(conv, slpcall->data_info, data, size); | |
778 gaim_conv_custom_smiley_close(conv, slpcall->data_info ); | |
10773 | 779 #ifdef MSN_DEBUG_UD |
10526 | 780 gaim_debug_info("msn", "Got smiley: %s\n", slpcall->data_info); |
10773 | 781 #endif |
9193 | 782 } |
783 | |
784 void | |
785 msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | |
786 { | |
787 MsnSession *session; | |
788 MsnSlpLink *slplink; | |
789 MsnObject *obj; | |
790 char **tokens; | |
11235 | 791 char *smile, *body_str; |
792 const char *body, *who, *sha1c; | |
11518 | 793 guint tok; |
11235 | 794 size_t body_len; |
9193 | 795 |
11518 | 796 GaimConversation *conv; |
10526 | 797 |
9193 | 798 session = cmdproc->servconn->session; |
799 | |
12886 | 800 if (!gaim_account_get_bool(session->account, "custom_smileys", TRUE)) |
801 return; | |
802 | |
11235 | 803 body = msn_message_get_bin_data(msg, &body_len); |
804 body_str = g_strndup(body, body_len); | |
805 | |
11518 | 806 /* MSN Messenger 7 may send more than one MSNObject in a single message... |
807 * Maybe 10 tokens is a reasonable max value. */ | |
808 tokens = g_strsplit(body_str, "\t", 10); | |
11235 | 809 |
810 g_free(body_str); | |
9193 | 811 |
11518 | 812 for (tok = 0; tok < 9; tok += 2) { |
813 if (tokens[tok] == NULL || tokens[tok + 1] == NULL) { | |
814 break; | |
815 } | |
816 | |
817 smile = tokens[tok]; | |
818 obj = msn_object_new_from_string(gaim_url_decode(tokens[tok + 1])); | |
9193 | 819 |
11518 | 820 who = msn_object_get_creator(obj); |
821 sha1c = msn_object_get_sha1c(obj); | |
9193 | 822 |
11518 | 823 slplink = msn_session_get_slplink(session, who); |
824 | |
825 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who, | |
826 session->account); | |
9193 | 827 |
11518 | 828 /* If the conversation doesn't exist then this is a custom smiley |
829 * used in the first message in a MSN conversation: we need to create | |
830 * the conversation now, otherwise the custom smiley won't be shown. | |
831 * This happens because every GtkIMHtml has its own smiley tree: if | |
832 * the conversation doesn't exist then we cannot associate the new | |
833 * smiley with its GtkIMHtml widget. */ | |
834 if (!conv) { | |
835 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, session->account, who); | |
836 } | |
10526 | 837 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12323
diff
changeset
|
838 if (gaim_conv_custom_smiley_add(conv, smile, "sha1", sha1c, TRUE)) { |
11518 | 839 msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj); |
840 } | |
841 | |
842 msn_object_destroy(obj); | |
843 obj = NULL; | |
844 who = NULL; | |
845 sha1c = NULL; | |
10526 | 846 } |
9193 | 847 g_strfreev(tokens); |
848 } | |
849 | |
850 static gboolean | |
851 buddy_icon_cached(GaimConnection *gc, MsnObject *obj) | |
852 { | |
853 GaimAccount *account; | |
854 GaimBuddy *buddy; | |
855 const char *old; | |
856 const char *new; | |
857 | |
858 g_return_val_if_fail(obj != NULL, FALSE); | |
859 | |
860 account = gaim_connection_get_account(gc); | |
861 | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
862 buddy = gaim_find_buddy(account, msn_object_get_creator(obj)); |
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
863 if (buddy == NULL) |
9193 | 864 return FALSE; |
865 | |
866 old = gaim_blist_node_get_string((GaimBlistNode *)buddy, "icon_checksum"); | |
867 new = msn_object_get_sha1c(obj); | |
868 | |
869 if (new == NULL) | |
870 return FALSE; | |
871 | |
11020 | 872 /* If the old and new checksums are the same, and the file actually exists, |
873 * then return TRUE */ | |
874 if (old != NULL && !strcmp(old, new) && (gaim_buddy_icons_find(account, gaim_buddy_get_name(buddy)) != NULL)) | |
9193 | 875 return TRUE; |
876 | |
877 return FALSE; | |
878 } | |
879 | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
12126
diff
changeset
|
880 static void |
9860 | 881 msn_release_buddy_icon_request(MsnUserList *userlist) |
9193 | 882 { |
883 MsnUser *user; | |
9860 | 884 |
10225 | 885 g_return_if_fail(userlist != NULL); |
886 | |
10773 | 887 #ifdef MSN_DEBUG_UD |
10225 | 888 gaim_debug_info("msn", "Releasing buddy icon request\n"); |
10773 | 889 #endif |
10225 | 890 |
13125 | 891 if (userlist->buddy_icon_window > 0) |
9860 | 892 { |
893 GQueue *queue; | |
894 GaimAccount *account; | |
895 const char *username; | |
896 | |
897 queue = userlist->buddy_icon_requests; | |
898 | |
899 if (g_queue_is_empty(userlist->buddy_icon_requests)) | |
13125 | 900 return; |
9860 | 901 |
902 user = g_queue_pop_head(queue); | |
9193 | 903 |
9860 | 904 account = userlist->session->account; |
905 username = user->passport; | |
9193 | 906 |
13125 | 907 userlist->buddy_icon_window--; |
9860 | 908 msn_request_user_display(user); |
10225 | 909 |
10773 | 910 #ifdef MSN_DEBUG_UD |
13028 | 911 gaim_debug_info("msn", "msn_release_buddy_icon_request(): buddy_icon_window-- yields =%d\n", |
10225 | 912 userlist->buddy_icon_window); |
10773 | 913 #endif |
9860 | 914 } |
915 } | |
9193 | 916 |
13125 | 917 /* |
918 * Called on a timeout from end_user_display(). Frees a buddy icon window slow and dequeues the next | |
919 * buddy icon request if there is one. | |
920 */ | |
921 static gboolean | |
922 msn_release_buddy_icon_request_timeout(gpointer data) | |
923 { | |
924 MsnUserList *userlist = (MsnUserList *)data; | |
925 | |
926 /* Free one window slot */ | |
927 userlist->buddy_icon_window++; | |
928 | |
929 /* Clear the tag for our former request timer */ | |
930 userlist->buddy_icon_request_timer = 0; | |
931 | |
932 msn_release_buddy_icon_request(userlist); | |
933 | |
934 return FALSE; | |
935 } | |
936 | |
9860 | 937 void |
938 msn_queue_buddy_icon_request(MsnUser *user) | |
939 { | |
940 GaimAccount *account; | |
941 MsnObject *obj; | |
942 GQueue *queue; | |
9193 | 943 |
10225 | 944 g_return_if_fail(user != NULL); |
945 | |
9860 | 946 account = user->userlist->session->account; |
9193 | 947 |
948 obj = msn_user_get_object(user); | |
949 | |
950 if (obj == NULL) | |
9860 | 951 { |
9193 | 952 /* It seems the user has not set a msnobject */ |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
953 GSList *sl, *list; |
9860 | 954 |
955 /* TODO: I think we need better buddy icon core functions. */ | |
956 gaim_buddy_icons_set_for_user(account, user->passport, NULL, -1); | |
957 | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
958 list = gaim_find_buddies(account, user->passport); |
9860 | 959 |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
960 for (sl = list; sl != NULL; sl = sl->next) |
9860 | 961 { |
962 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
963 gaim_blist_node_remove_setting((GaimBlistNode*)buddy, "icon_checksum"); | |
964 } | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
965 g_slist_free(list); |
9860 | 966 |
9193 | 967 return; |
9860 | 968 } |
969 | |
970 if (!buddy_icon_cached(account->gc, obj)) | |
971 { | |
972 MsnUserList *userlist; | |
973 | |
974 userlist = user->userlist; | |
975 queue = userlist->buddy_icon_requests; | |
976 | |
10773 | 977 #ifdef MSN_DEBUG_UD |
13125 | 978 gaim_debug_info("msn", "Queueing buddy icon request for %s (buddy_icon_window = %i)\n", |
979 user->passport, userlist->buddy_icon_window); | |
10773 | 980 #endif |
10225 | 981 |
9860 | 982 g_queue_push_tail(queue, user); |
983 | |
984 if (userlist->buddy_icon_window > 0) | |
985 msn_release_buddy_icon_request(userlist); | |
986 } | |
987 } | |
988 | |
11897 | 989 static void |
9860 | 990 got_user_display(MsnSlpCall *slpcall, |
11137 | 991 const guchar *data, gsize size) |
9860 | 992 { |
10225 | 993 MsnUserList *userlist; |
9860 | 994 const char *info; |
995 GaimAccount *account; | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
996 GSList *sl, *list; |
9860 | 997 |
10225 | 998 g_return_if_fail(slpcall != NULL); |
999 | |
9860 | 1000 info = slpcall->data_info; |
10773 | 1001 #ifdef MSN_DEBUG_UD |
13125 | 1002 gaim_debug_info("msn", "Got User Display: %s\n", slpcall->slplink->remote_user); |
10773 | 1003 #endif |
9860 | 1004 |
10225 | 1005 userlist = slpcall->slplink->session->userlist; |
9860 | 1006 account = slpcall->slplink->session->account; |
1007 | |
1008 /* TODO: I think we need better buddy icon core functions. */ | |
1009 gaim_buddy_icons_set_for_user(account, slpcall->slplink->remote_user, | |
1010 (void *)data, size); | |
1011 | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1012 list = gaim_find_buddies(account, slpcall->slplink->remote_user); |
9860 | 1013 |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1014 for (sl = list; sl != NULL; sl = sl->next) |
9860 | 1015 { |
1016 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
1017 gaim_blist_node_set_string((GaimBlistNode*)buddy, "icon_checksum", info); | |
1018 } | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1019 g_slist_free(list); |
9860 | 1020 |
10225 | 1021 #if 0 |
1022 /* Free one window slot */ | |
1023 userlist->buddy_icon_window++; | |
1024 | |
13028 | 1025 gaim_debug_info("msn", "got_user_display(): buddy_icon_window++ yields =%d\n", |
10225 | 1026 userlist->buddy_icon_window); |
1027 | |
1028 msn_release_buddy_icon_request(userlist); | |
1029 #endif | |
1030 } | |
1031 | |
11897 | 1032 static void |
13125 | 1033 end_user_display(MsnSlpCall *slpcall, MsnSession *session) |
10225 | 1034 { |
1035 MsnUserList *userlist; | |
1036 | |
13125 | 1037 g_return_if_fail(session != NULL); |
10225 | 1038 |
10773 | 1039 #ifdef MSN_DEBUG_UD |
10225 | 1040 gaim_debug_info("msn", "End User Display\n"); |
10773 | 1041 #endif |
1042 | |
13125 | 1043 userlist = session->userlist; |
10225 | 1044 |
10296 | 1045 /* If the session is being destroyed we better stop doing anything. */ |
13125 | 1046 if (session->destroying) |
10296 | 1047 return; |
13125 | 1048 |
1049 /* Delay before freeing a buddy icon window slot and requesting the next icon, if appropriate. | |
1050 * If we don't delay, we'll rapidly hit the MSN equivalent of AIM's rate limiting; the server will | |
1051 * send us an error 800 like so: | |
1052 * | |
1053 * C: NS 000: XFR 21 SB | |
1054 * S: NS 000: 800 21 | |
1055 */ | |
1056 if (userlist->buddy_icon_request_timer) { | |
1057 /* Free the window slot used by this previous request */ | |
1058 userlist->buddy_icon_window++; | |
1059 | |
1060 /* Clear our pending timeout */ | |
1061 gaim_timeout_remove(userlist->buddy_icon_request_timer); | |
13028 | 1062 } |
10296 | 1063 |
13125 | 1064 /* Wait BUDDY_ICON_DELAY ms before freeing our window slot and requesting the next icon. */ |
1065 userlist->buddy_icon_request_timer = gaim_timeout_add(BUDDY_ICON_DELAY, | |
1066 msn_release_buddy_icon_request_timeout, userlist); | |
9860 | 1067 } |
1068 | |
1069 void | |
1070 msn_request_user_display(MsnUser *user) | |
1071 { | |
1072 GaimAccount *account; | |
1073 MsnSession *session; | |
1074 MsnSlpLink *slplink; | |
1075 MsnObject *obj; | |
1076 const char *info; | |
1077 | |
1078 session = user->userlist->session; | |
1079 account = session->account; | |
1080 | |
1081 slplink = msn_session_get_slplink(session, user->passport); | |
1082 | |
1083 obj = msn_user_get_object(user); | |
9193 | 1084 |
1085 info = msn_object_get_sha1c(obj); | |
1086 | |
9860 | 1087 if (g_ascii_strcasecmp(user->passport, |
1088 gaim_account_get_username(account))) | |
1089 { | |
10225 | 1090 msn_slplink_request_object(slplink, info, got_user_display, |
1091 end_user_display, obj); | |
9860 | 1092 } |
1093 else | |
1094 { | |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1095 MsnObject *my_obj = NULL; |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1096 gchar *data = NULL; |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1097 gsize len = 0; |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1098 GSList *sl, *list; |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1099 |
10773 | 1100 #ifdef MSN_DEBUG_UD |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1101 gaim_debug_info("msn", "Requesting our own user display\n"); |
10773 | 1102 #endif |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1103 |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1104 my_obj = msn_user_get_object(session->user); |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1105 |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1106 if (my_obj != NULL) |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1107 { |
13711
967ef719cb62
[gaim-migrate @ 16115]
Richard Laager <rlaager@wiktel.com>
parents:
13125
diff
changeset
|
1108 const char *filename = msn_object_get_real_location(my_obj); |
967ef719cb62
[gaim-migrate @ 16115]
Richard Laager <rlaager@wiktel.com>
parents:
13125
diff
changeset
|
1109 |
967ef719cb62
[gaim-migrate @ 16115]
Richard Laager <rlaager@wiktel.com>
parents:
13125
diff
changeset
|
1110 if (filename != NULL) |
967ef719cb62
[gaim-migrate @ 16115]
Richard Laager <rlaager@wiktel.com>
parents:
13125
diff
changeset
|
1111 g_file_get_contents(filename, &data, &len, NULL); |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1112 } |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1113 |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1114 /* TODO: I think we need better buddy icon core functions. */ |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1115 gaim_buddy_icons_set_for_user(account, user->passport, (void *)data, len); |
10519 | 1116 g_free(data); |
10225 | 1117 |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1118 list = gaim_find_buddies(account, user->passport); |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1119 |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1120 for (sl = list; sl != NULL; sl = sl->next) |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1121 { |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1122 GaimBuddy *buddy = (GaimBuddy *)sl->data; |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1123 gaim_blist_node_set_string((GaimBlistNode*)buddy, "icon_checksum", info); |
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1124 } |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11897
diff
changeset
|
1125 g_slist_free(list); |
10072
cf3454eadc22
[gaim-migrate @ 11051]
Luke Schierer <lschiere@pidgin.im>
parents:
10047
diff
changeset
|
1126 |
10225 | 1127 /* Free one window slot */ |
9860 | 1128 session->userlist->buddy_icon_window++; |
10225 | 1129 |
10773 | 1130 #ifdef MSN_DEBUG_UD |
13028 | 1131 gaim_debug_info("msn", "msn_request_user_display(): buddy_icon_window++ yields =%d\n", |
10225 | 1132 session->userlist->buddy_icon_window); |
10773 | 1133 #endif |
10225 | 1134 |
9860 | 1135 msn_release_buddy_icon_request(session->userlist); |
1136 } | |
9193 | 1137 } |