comparison libpurple/protocols/msn/slplink.c @ 15373:5fe8042783c1

Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author Sean Egan <seanegan@gmail.com>
date Sat, 20 Jan 2007 02:32:10 +0000
parents
children 32c366eeeb99
comparison
equal deleted inserted replaced
15372:f79e0f4df793 15373:5fe8042783c1
1 /**
2 * @file slplink.c MSNSLP Link support
3 *
4 * gaim
5 *
6 * Gaim is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * source distribution.
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 "slplink.h"
26
27 #include "switchboard.h"
28 #include "slp.h"
29
30 void msn_slplink_send_msgpart(MsnSlpLink *slplink, MsnSlpMessage *slpmsg);
31
32 #ifdef MSN_DEBUG_SLP_FILES
33 static int m_sc = 0;
34 static int m_rc = 0;
35
36 static void
37 debug_msg_to_file(MsnMessage *msg, gboolean send)
38 {
39 char *tmp;
40 char *dir;
41 char *pload;
42 FILE *tf;
43 int c;
44 gsize pload_size;
45
46 dir = send ? "send" : "recv";
47 c = send ? m_sc++ : m_rc++;
48 tmp = g_strdup_printf("%s/msntest/%s/%03d", g_get_home_dir(), dir, c);
49 tf = g_fopen(tmp, "wb");
50 if (tf == NULL)
51 {
52 gaim_debug_error("msn", "could not open debug file");
53 return;
54 }
55 pload = msn_message_gen_payload(msg, &pload_size);
56 fwrite(pload, 1, pload_size, tf);
57 fclose(tf);
58 g_free(tmp);
59 }
60 #endif
61
62 /**************************************************************************
63 * Main
64 **************************************************************************/
65
66 MsnSlpLink *
67 msn_slplink_new(MsnSession *session, const char *username)
68 {
69 MsnSlpLink *slplink;
70
71 g_return_val_if_fail(session != NULL, NULL);
72
73 slplink = g_new0(MsnSlpLink, 1);
74
75 #ifdef MSN_DEBUG_SLPLINK
76 gaim_debug_info("msn", "slplink_new: slplink(%p)\n", slplink);
77 #endif
78
79 slplink->session = session;
80 slplink->slp_seq_id = rand() % 0xFFFFFF00 + 4;
81
82 slplink->local_user = g_strdup(msn_user_get_passport(session->user));
83 slplink->remote_user = g_strdup(username);
84
85 slplink->slp_msg_queue = g_queue_new();
86
87 session->slplinks =
88 g_list_append(session->slplinks, slplink);
89
90 return slplink;
91 }
92
93 void
94 msn_slplink_destroy(MsnSlpLink *slplink)
95 {
96 MsnSession *session;
97
98 #ifdef MSN_DEBUG_SLPLINK
99 gaim_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink);
100 #endif
101
102 g_return_if_fail(slplink != NULL);
103
104 if (slplink->swboard != NULL)
105 slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink);
106
107 session = slplink->session;
108
109 if (slplink->local_user != NULL)
110 g_free(slplink->local_user);
111
112 if (slplink->remote_user != NULL)
113 g_free(slplink->remote_user);
114
115 if (slplink->directconn != NULL)
116 msn_directconn_destroy(slplink->directconn);
117
118 while (slplink->slp_calls != NULL)
119 msn_slp_call_destroy(slplink->slp_calls->data);
120
121 session->slplinks =
122 g_list_remove(session->slplinks, slplink);
123
124 g_free(slplink);
125 }
126
127 MsnSlpLink *
128 msn_session_find_slplink(MsnSession *session, const char *who)
129 {
130 GList *l;
131
132 for (l = session->slplinks; l != NULL; l = l->next)
133 {
134 MsnSlpLink *slplink;
135
136 slplink = l->data;
137
138 if (!strcmp(slplink->remote_user, who))
139 return slplink;
140 }
141
142 return NULL;
143 }
144
145 MsnSlpLink *
146 msn_session_get_slplink(MsnSession *session, const char *username)
147 {
148 MsnSlpLink *slplink;
149
150 g_return_val_if_fail(session != NULL, NULL);
151 g_return_val_if_fail(username != NULL, NULL);
152
153 slplink = msn_session_find_slplink(session, username);
154
155 if (slplink == NULL)
156 slplink = msn_slplink_new(session, username);
157
158 return slplink;
159 }
160
161 MsnSlpSession *
162 msn_slplink_find_slp_session(MsnSlpLink *slplink, long session_id)
163 {
164 GList *l;
165 MsnSlpSession *slpsession;
166
167 for (l = slplink->slp_sessions; l != NULL; l = l->next)
168 {
169 slpsession = l->data;
170
171 if (slpsession->id == session_id)
172 return slpsession;
173 }
174
175 return NULL;
176 }
177
178 void
179 msn_slplink_add_slpcall(MsnSlpLink *slplink, MsnSlpCall *slpcall)
180 {
181 if (slplink->swboard != NULL)
182 slplink->swboard->flag |= MSN_SB_FLAG_FT;
183
184 slplink->slp_calls = g_list_append(slplink->slp_calls, slpcall);
185 }
186
187 void
188 msn_slplink_remove_slpcall(MsnSlpLink *slplink, MsnSlpCall *slpcall)
189 {
190 slplink->slp_calls = g_list_remove(slplink->slp_calls, slpcall);
191
192 /* The slplink has no slpcalls in it. If no one is using it, we might
193 * destroy the switchboard, but we should be careful not to use the slplink
194 * again. */
195 if (slplink->slp_calls == NULL)
196 {
197 if (slplink->swboard != NULL)
198 {
199 if (msn_switchboard_release(slplink->swboard, MSN_SB_FLAG_FT))
200 /* I'm not sure this is the best thing to do, but it's better
201 * than nothing. */
202 slpcall->slplink = NULL;
203 }
204 }
205 }
206
207 MsnSlpCall *
208 msn_slplink_find_slp_call(MsnSlpLink *slplink, const char *id)
209 {
210 GList *l;
211 MsnSlpCall *slpcall;
212
213 if (!id)
214 return NULL;
215
216 for (l = slplink->slp_calls; l != NULL; l = l->next)
217 {
218 slpcall = l->data;
219
220 if (slpcall->id && !strcmp(slpcall->id, id))
221 return slpcall;
222 }
223
224 return NULL;
225 }
226
227 MsnSlpCall *
228 msn_slplink_find_slp_call_with_session_id(MsnSlpLink *slplink, long id)
229 {
230 GList *l;
231 MsnSlpCall *slpcall;
232
233 for (l = slplink->slp_calls; l != NULL; l = l->next)
234 {
235 slpcall = l->data;
236
237 if (slpcall->session_id == id)
238 return slpcall;
239 }
240
241 return NULL;
242 }
243
244 void
245 msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg)
246 {
247 if (slplink->directconn != NULL)
248 {
249 msn_directconn_send_msg(slplink->directconn, msg);
250 }
251 else
252 {
253 if (slplink->swboard == NULL)
254 {
255 slplink->swboard = msn_session_get_swboard(slplink->session,
256 slplink->remote_user, MSN_SB_FLAG_FT);
257
258 if (slplink->swboard == NULL)
259 return;
260
261 /* If swboard is destroyed we will be too */
262 slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink);
263 }
264
265 msn_switchboard_send_msg(slplink->swboard, msg, TRUE);
266 }
267 }
268
269 /* We have received the message ack */
270 static void
271 msg_ack(MsnMessage *msg, void *data)
272 {
273 MsnSlpMessage *slpmsg;
274 long long real_size;
275
276 slpmsg = data;
277
278 real_size = (slpmsg->flags == 0x2) ? 0 : slpmsg->size;
279
280 slpmsg->offset += msg->msnslp_header.length;
281
282 if (slpmsg->offset < real_size)
283 {
284 msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
285 }
286 else
287 {
288 /* The whole message has been sent */
289 if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
290 {
291 if (slpmsg->slpcall != NULL)
292 {
293 if (slpmsg->slpcall->cb)
294 slpmsg->slpcall->cb(slpmsg->slpcall,
295 NULL, 0);
296 }
297 }
298 }
299
300 slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
301 }
302
303 /* We have received the message nak. */
304 static void
305 msg_nak(MsnMessage *msg, void *data)
306 {
307 MsnSlpMessage *slpmsg;
308
309 slpmsg = data;
310
311 msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
312
313 slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
314 }
315
316 void
317 msn_slplink_send_msgpart(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
318 {
319 MsnMessage *msg;
320 long long real_size;
321 size_t len = 0;
322
323 /* Maybe we will want to create a new msg for this slpmsg instead of
324 * reusing the same one all the time. */
325 msg = slpmsg->msg;
326
327 real_size = (slpmsg->flags == 0x2) ? 0 : slpmsg->size;
328
329 if (slpmsg->offset < real_size)
330 {
331 if (slpmsg->fp)
332 {
333 char data[1202];
334 len = fread(data, 1, sizeof(data), slpmsg->fp);
335 msn_message_set_bin_data(msg, data, len);
336 }
337 else
338 {
339 len = slpmsg->size - slpmsg->offset;
340
341 if (len > 1202)
342 len = 1202;
343
344 msn_message_set_bin_data(msg, slpmsg->buffer + slpmsg->offset, len);
345 }
346
347 msg->msnslp_header.offset = slpmsg->offset;
348 msg->msnslp_header.length = len;
349 }
350
351 #ifdef MSN_DEBUG_SLP
352 msn_message_show_readable(msg, slpmsg->info, slpmsg->text_body);
353 #endif
354
355 #ifdef MSN_DEBUG_SLP_FILES
356 debug_msg_to_file(msg, TRUE);
357 #endif
358
359 slpmsg->msgs =
360 g_list_append(slpmsg->msgs, msg);
361 msn_slplink_send_msg(slplink, msg);
362
363 if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) &&
364 (slpmsg->slpcall != NULL))
365 {
366 slpmsg->slpcall->progress = TRUE;
367
368 if (slpmsg->slpcall->progress_cb != NULL)
369 {
370 slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
371 len, slpmsg->offset);
372 }
373 }
374
375 /* slpmsg->offset += len; */
376 }
377
378 void
379 msn_slplink_release_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
380 {
381 MsnMessage *msg;
382
383 slpmsg->msg = msg = msn_message_new_msnslp();
384
385 if (slpmsg->flags == 0x0)
386 {
387 msg->msnslp_header.session_id = slpmsg->session_id;
388 msg->msnslp_header.ack_id = rand() % 0xFFFFFF00;
389 }
390 else if (slpmsg->flags == 0x2)
391 {
392 msg->msnslp_header.session_id = slpmsg->session_id;
393 msg->msnslp_header.ack_id = slpmsg->ack_id;
394 msg->msnslp_header.ack_size = slpmsg->ack_size;
395 msg->msnslp_header.ack_sub_id = slpmsg->ack_sub_id;
396 }
397 else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
398 {
399 MsnSlpSession *slpsession;
400 slpsession = slpmsg->slpsession;
401
402 g_return_if_fail(slpsession != NULL);
403 msg->msnslp_header.session_id = slpsession->id;
404 msg->msnslp_footer.value = slpsession->app_id;
405 msg->msnslp_header.ack_id = rand() % 0xFFFFFF00;
406 }
407 else if (slpmsg->flags == 0x100)
408 {
409 msg->msnslp_header.ack_id = slpmsg->ack_id;
410 msg->msnslp_header.ack_sub_id = slpmsg->ack_sub_id;
411 msg->msnslp_header.ack_size = slpmsg->ack_size;
412 }
413
414 msg->msnslp_header.id = slpmsg->id;
415 msg->msnslp_header.flags = slpmsg->flags;
416
417 msg->msnslp_header.total_size = slpmsg->size;
418
419 msn_message_set_attr(msg, "P2P-Dest", slplink->remote_user);
420
421 msg->ack_cb = msg_ack;
422 msg->nak_cb = msg_nak;
423 msg->ack_data = slpmsg;
424
425 msn_slplink_send_msgpart(slplink, slpmsg);
426
427 msn_message_destroy(msg);
428 }
429
430 void
431 msn_slplink_queue_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
432 {
433 slpmsg->id = slplink->slp_seq_id++;
434
435 g_queue_push_head(slplink->slp_msg_queue, slpmsg);
436 }
437
438 void
439 msn_slplink_send_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
440 {
441 slpmsg->id = slplink->slp_seq_id++;
442
443 msn_slplink_release_slpmsg(slplink, slpmsg);
444 }
445
446 void
447 msn_slplink_unleash(MsnSlpLink *slplink)
448 {
449 MsnSlpMessage *slpmsg;
450
451 /* Send the queued msgs in the order they came. */
452
453 while ((slpmsg = g_queue_pop_tail(slplink->slp_msg_queue)) != NULL)
454 {
455 msn_slplink_release_slpmsg(slplink, slpmsg);
456 }
457 }
458
459 void
460 msn_slplink_send_ack(MsnSlpLink *slplink, MsnMessage *msg)
461 {
462 MsnSlpMessage *slpmsg;
463
464 slpmsg = msn_slpmsg_new(slplink);
465
466 slpmsg->session_id = msg->msnslp_header.session_id;
467 slpmsg->size = msg->msnslp_header.total_size;
468 slpmsg->flags = 0x02;
469 slpmsg->ack_id = msg->msnslp_header.id;
470 slpmsg->ack_sub_id = msg->msnslp_header.ack_id;
471 slpmsg->ack_size = msg->msnslp_header.total_size;
472
473 #ifdef MSN_DEBUG_SLP
474 slpmsg->info = "SLP ACK";
475 #endif
476
477 msn_slplink_send_slpmsg(slplink, slpmsg);
478 }
479
480 static void
481 send_file_cb(MsnSlpSession *slpsession)
482 {
483 MsnSlpCall *slpcall;
484 MsnSlpMessage *slpmsg;
485
486 slpcall = slpsession->slpcall;
487 slpmsg = msn_slpmsg_new(slpcall->slplink);
488 slpmsg->slpcall = slpcall;
489 slpmsg->flags = 0x1000030;
490 slpmsg->slpsession = slpsession;
491 #ifdef MSN_DEBUG_SLP
492 slpmsg->info = "SLP FILE";
493 #endif
494 msn_slpmsg_open_file(slpmsg, gaim_xfer_get_local_filename(slpcall->xfer));
495
496 msn_slplink_send_slpmsg(slpcall->slplink, slpmsg);
497 }
498
499 void
500 msn_slplink_process_msg(MsnSlpLink *slplink, MsnMessage *msg)
501 {
502 MsnSlpMessage *slpmsg;
503 const char *data;
504 gsize offset;
505 gsize len;
506
507 #ifdef MSN_DEBUG_SLP
508 msn_slpmsg_show(msg);
509 #endif
510
511 #ifdef MSN_DEBUG_SLP_FILES
512 debug_msg_to_file(msg, FALSE);
513 #endif
514
515 if (msg->msnslp_header.total_size < msg->msnslp_header.length)
516 {
517 gaim_debug_error("msn", "This can't be good\n");
518 g_return_if_reached();
519 }
520
521 slpmsg = NULL;
522 data = msn_message_get_bin_data(msg, &len);
523
524 /*
525 OVERHEAD!
526 if (msg->msnslp_header.length < msg->msnslp_header.total_size)
527 */
528
529 offset = msg->msnslp_header.offset;
530
531 if (offset == 0)
532 {
533 slpmsg = msn_slpmsg_new(slplink);
534 slpmsg->id = msg->msnslp_header.id;
535 slpmsg->session_id = msg->msnslp_header.session_id;
536 slpmsg->size = msg->msnslp_header.total_size;
537 slpmsg->flags = msg->msnslp_header.flags;
538
539 if (slpmsg->session_id)
540 {
541 if (slpmsg->slpcall == NULL)
542 slpmsg->slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id);
543
544 if (slpmsg->slpcall != NULL)
545 {
546 if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
547 {
548 GaimXfer *xfer;
549
550 xfer = slpmsg->slpcall->xfer;
551
552 if (xfer != NULL)
553 {
554 slpmsg->fp =
555 g_fopen(gaim_xfer_get_local_filename(slpmsg->slpcall->xfer),
556 "wb");
557 }
558 }
559 }
560 }
561 if (!slpmsg->fp && slpmsg->size)
562 {
563 slpmsg->buffer = g_try_malloc(slpmsg->size);
564 if (slpmsg->buffer == NULL)
565 {
566 gaim_debug_error("msn", "Failed to allocate buffer for slpmsg\n");
567 return;
568 }
569 }
570 }
571 else
572 {
573 slpmsg = msn_slplink_message_find(slplink, msg->msnslp_header.session_id, msg->msnslp_header.id);
574 }
575
576 if (slpmsg == NULL)
577 {
578 /* Probably the transfer was canceled */
579 gaim_debug_error("msn", "Couldn't find slpmsg\n");
580 return;
581 }
582
583 if (slpmsg->fp)
584 {
585 /* fseek(slpmsg->fp, offset, SEEK_SET); */
586 len = fwrite(data, 1, len, slpmsg->fp);
587 }
588 else if (slpmsg->size)
589 {
590 if ((offset + len) > slpmsg->size)
591 {
592 gaim_debug_error("msn", "Oversized slpmsg\n");
593 g_return_if_reached();
594 }
595 else
596 memcpy(slpmsg->buffer + offset, data, len);
597 }
598
599 if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) &&
600 (slpmsg->slpcall != NULL))
601 {
602 slpmsg->slpcall->progress = TRUE;
603
604 if (slpmsg->slpcall->progress_cb != NULL)
605 {
606 slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
607 len, offset);
608 }
609 }
610
611 #if 0
612 if (slpmsg->buffer == NULL)
613 return;
614 #endif
615
616 if (msg->msnslp_header.offset + msg->msnslp_header.length
617 >= msg->msnslp_header.total_size)
618 {
619 /* All the pieces of the slpmsg have been received */
620 MsnSlpCall *slpcall;
621
622 slpcall = msn_slp_process_msg(slplink, slpmsg);
623
624 if (slpmsg->flags == 0x100)
625 {
626 MsnDirectConn *directconn;
627
628 directconn = slplink->directconn;
629
630 if (!directconn->acked)
631 msn_directconn_send_handshake(directconn);
632 }
633 else if (slpmsg->flags == 0x0 || slpmsg->flags == 0x20 ||
634 slpmsg->flags == 0x1000030)
635 {
636 /* Release all the messages and send the ACK */
637
638 msn_slplink_send_ack(slplink, msg);
639 msn_slplink_unleash(slplink);
640 }
641
642 msn_slpmsg_destroy(slpmsg);
643
644 if (slpcall != NULL && slpcall->wasted)
645 msn_slp_call_destroy(slpcall);
646 }
647 }
648
649 MsnSlpMessage *
650 msn_slplink_message_find(MsnSlpLink *slplink, long session_id, long id)
651 {
652 GList *e;
653
654 for (e = slplink->slp_msgs; e != NULL; e = e->next)
655 {
656 MsnSlpMessage *slpmsg = e->data;
657
658 if ((slpmsg->session_id == session_id) && (slpmsg->id == id))
659 return slpmsg;
660 }
661
662 return NULL;
663 }
664
665 typedef struct
666 {
667 guint32 length;
668 guint32 unk1;
669 guint32 file_size;
670 guint32 unk2;
671 guint32 unk3;
672 } MsnContextHeader;
673
674 #define MAX_FILE_NAME_LEN 0x226
675
676 static gchar *
677 gen_context(const char *file_name, const char *file_path)
678 {
679 struct stat st;
680 gsize size = 0;
681 MsnContextHeader header;
682 gchar *u8 = NULL;
683 guchar *base;
684 guchar *n;
685 gchar *ret;
686 gunichar2 *uni = NULL;
687 glong currentChar = 0;
688 glong uni_len = 0;
689 gsize len;
690
691 if (g_stat(file_path, &st) == 0)
692 size = st.st_size;
693
694 if(!file_name) {
695 u8 = gaim_utf8_try_convert(g_basename(file_path));
696 file_name = u8;
697 }
698
699 uni = g_utf8_to_utf16(file_name, -1, NULL, &uni_len, NULL);
700
701 if(u8) {
702 g_free(u8);
703 file_name = NULL;
704 u8 = NULL;
705 }
706
707 len = sizeof(MsnContextHeader) + MAX_FILE_NAME_LEN + 4;
708
709 header.length = GUINT32_TO_LE(len);
710 header.unk1 = GUINT32_TO_LE(2);
711 header.file_size = GUINT32_TO_LE(size);
712 header.unk2 = GUINT32_TO_LE(0);
713 header.unk3 = GUINT32_TO_LE(0);
714
715 base = g_malloc(len + 1);
716 n = base;
717
718 memcpy(n, &header, sizeof(MsnContextHeader));
719 n += sizeof(MsnContextHeader);
720
721 memset(n, 0x00, MAX_FILE_NAME_LEN);
722 for(currentChar = 0; currentChar < uni_len; currentChar++) {
723 *((gunichar2 *)n + currentChar) = GUINT16_TO_LE(uni[currentChar]);
724 }
725 n += MAX_FILE_NAME_LEN;
726
727 memset(n, 0xFF, 4);
728 n += 4;
729
730 g_free(uni);
731 ret = gaim_base64_encode(base, len);
732 g_free(base);
733 return ret;
734 }
735
736 void
737 msn_slplink_request_ft(MsnSlpLink *slplink, GaimXfer *xfer)
738 {
739 MsnSlpCall *slpcall;
740 char *context;
741 const char *fn;
742 const char *fp;
743
744 fn = gaim_xfer_get_filename(xfer);
745 fp = gaim_xfer_get_local_filename(xfer);
746
747 g_return_if_fail(slplink != NULL);
748 g_return_if_fail(fp != NULL);
749
750 slpcall = msn_slp_call_new(slplink);
751 msn_slp_call_init(slpcall, MSN_SLPCALL_DC);
752
753 slpcall->session_init_cb = send_file_cb;
754 slpcall->end_cb = msn_xfer_end_cb;
755 slpcall->progress_cb = msn_xfer_progress_cb;
756 slpcall->cb = msn_xfer_completed_cb;
757 slpcall->xfer = xfer;
758
759 slpcall->pending = TRUE;
760
761 gaim_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel);
762
763 xfer->data = slpcall;
764
765 context = gen_context(fn, fp);
766
767 msn_slp_call_invite(slpcall, "5D3E02AB-6190-11D3-BBBB-00C04F795683", 2,
768 context);
769
770 g_free(context);
771 }
772
773 void
774 msn_slplink_request_object(MsnSlpLink *slplink,
775 const char *info,
776 MsnSlpCb cb,
777 MsnSlpEndCb end_cb,
778 const MsnObject *obj)
779 {
780 MsnSlpCall *slpcall;
781 char *msnobj_data;
782 char *msnobj_base64;
783
784 g_return_if_fail(slplink != NULL);
785 g_return_if_fail(obj != NULL);
786
787 msnobj_data = msn_object_to_string(obj);
788 msnobj_base64 = gaim_base64_encode((const guchar *)msnobj_data, strlen(msnobj_data));
789 g_free(msnobj_data);
790
791 slpcall = msn_slp_call_new(slplink);
792 msn_slp_call_init(slpcall, MSN_SLPCALL_ANY);
793
794 slpcall->data_info = g_strdup(info);
795 slpcall->cb = cb;
796 slpcall->end_cb = end_cb;
797
798 msn_slp_call_invite(slpcall, "A4268EEC-FEC5-49E5-95C3-F126696BDBF6", 1,
799 msnobj_base64);
800
801 g_free(msnobj_base64);
802 }