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