comparison libgaim/protocols/msn/slplink.c @ 14192:60b1bc8dbf37

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