Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/family_icbm.c @ 27771:085d0a18a7f7
propagate from branch 'im.pidgin.pidgin' (head 7bbbd3b5812df69c6884596a4343b688d73c3124)
to branch 'im.pidgin.pidgin.yaz' (head 9cfa4c04679a643911c1b80123ea1e531b825074)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 28 Feb 2008 12:28:35 +0000 |
parents | 03b2b21b4c42 969a2aeae461 |
children | 0f3a131d23da |
comparison
equal
deleted
inserted
replaced
22346:561729870929 | 27771:085d0a18a7f7 |
---|---|
50 #ifdef _WIN32 | 50 #ifdef _WIN32 |
51 #include "win32dep.h" | 51 #include "win32dep.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #include "util.h" | 54 #include "util.h" |
55 | 55 /* yaz */ |
56 | 56 #include "debug.h" |
57 /** | 57 /** |
58 * Add a standard ICBM header to the given bstream with the given | 58 * Add a standard ICBM header to the given bstream with the given |
59 * information. | 59 * information. |
60 * | 60 * |
61 * @param bs The bstream to write the ICBM header to. | 61 * @param bs The bstream to write the ICBM header to. |
459 IcbmCookie *msgcookie; | 459 IcbmCookie *msgcookie; |
460 struct aim_invite_priv *priv; | 460 struct aim_invite_priv *priv; |
461 guchar cookie[8]; | 461 guchar cookie[8]; |
462 GSList *outer_tlvlist = NULL, *inner_tlvlist = NULL; | 462 GSList *outer_tlvlist = NULL, *inner_tlvlist = NULL; |
463 ByteStream hdrbs; | 463 ByteStream hdrbs; |
464 // yaz | |
465 char *ucs = NULL; | |
466 gsize bytes; | |
464 | 467 |
465 if (!od || !(conn = flap_connection_findbygroup(od, 0x0004))) | 468 if (!od || !(conn = flap_connection_findbygroup(od, 0x0004))) |
466 return -EINVAL; | 469 return -EINVAL; |
467 | 470 |
468 if (!sn || !msg || !roomname) | 471 if (!sn || !msg || !roomname) |
498 * Sigh. AOL was rather inconsistent right here. So we have | 501 * Sigh. AOL was rather inconsistent right here. So we have |
499 * to play some minor tricks. Right inside the type 5 is some | 502 * to play some minor tricks. Right inside the type 5 is some |
500 * raw data, followed by a series of TLVs. | 503 * raw data, followed by a series of TLVs. |
501 * | 504 * |
502 */ | 505 */ |
506 #if 0 | |
503 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); | 507 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); |
504 | 508 |
505 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ | 509 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ |
506 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ | 510 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ |
507 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); | 511 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); |
508 | 512 #endif |
513 //yaz | |
514 // convert msg to ascii first. if it succeed, send as plain ascii. | |
515 // if it fails, convert msg into ucs-2be, and send it. | |
516 ucs = g_convert(msg, strlen(msg), "ASCII", "UTF-8", NULL, &bytes, NULL); | |
517 if(ucs){ | |
518 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); | |
519 | |
520 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ | |
521 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ | |
522 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); | |
523 | |
524 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); | |
525 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); | |
526 aim_tlvlist_add_raw(&inner_tlvlist, 0x000c, strlen(msg), msg); | |
527 free(ucs); | |
528 } else { | |
529 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2+4+11); | |
530 | |
531 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ | |
532 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ | |
533 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); | |
534 | |
535 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); | |
536 aim_tlvlist_add_raw(&inner_tlvlist, 0x000d, 11, "unicode-2-0"); | |
537 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); | |
538 //yaz | |
539 ucs = g_convert(msg, strlen(msg), "UCS-2BE", "UTF-8", NULL, &bytes, NULL); | |
540 if(ucs){ | |
541 botch_ucs(ucs, bytes); | |
542 aim_tlvlist_add_raw(&inner_tlvlist, 0x000c, bytes, ucs); | |
543 free(ucs); | |
544 } | |
545 } | |
546 #if 0 | |
509 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); | 547 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); |
510 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); | 548 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); |
511 aim_tlvlist_add_str(&inner_tlvlist, 0x000c, msg); | 549 aim_tlvlist_add_str(&inner_tlvlist, 0x000c, msg); |
550 #endif | |
512 aim_tlvlist_add_chatroom(&inner_tlvlist, 0x2711, exchange, roomname, instance); | 551 aim_tlvlist_add_chatroom(&inner_tlvlist, 0x2711, exchange, roomname, instance); |
513 aim_tlvlist_write(&hdrbs, &inner_tlvlist); | 552 aim_tlvlist_write(&hdrbs, &inner_tlvlist); |
514 | 553 |
515 aim_tlvlist_add_raw(&outer_tlvlist, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); | 554 aim_tlvlist_add_raw(&outer_tlvlist, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); |
516 g_free(hdrbs.data); | 555 g_free(hdrbs.data); |