Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/family_icbm.c @ 27958:518b4a900f19
propagate from branch 'im.pidgin.pidgin' (head 11d28a9362597cbea7fa0957f4202037131a3d6b)
to branch 'im.pidgin.pidgin.yaz' (head c88eab6ab06f08ebe8a58bbc9614d11818aad9e9)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 29 Jun 2009 06:24:37 +0000 |
parents | a2508ac2e536 d8e6a2d592a4 |
children | e1cd44c7c7af |
comparison
equal
deleted
inserted
replaced
27294:862b8208a546 | 27958:518b4a900f19 |
---|---|
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, SNAC_FAMILY_ICBM))) | 468 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM))) |
466 return -EINVAL; | 469 return -EINVAL; |
467 | 470 |
468 if (!bn || !msg || !roomname) | 471 if (!bn || !msg || !roomname) |
497 * Sigh. AOL was rather inconsistent right here. So we have | 500 * Sigh. AOL was rather inconsistent right here. So we have |
498 * to play some minor tricks. Right inside the type 5 is some | 501 * to play some minor tricks. Right inside the type 5 is some |
499 * raw data, followed by a series of TLVs. | 502 * raw data, followed by a series of TLVs. |
500 * | 503 * |
501 */ | 504 */ |
505 #if 0 | |
502 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); | 506 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); |
503 | 507 |
504 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ | 508 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ |
505 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ | 509 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ |
506 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); | 510 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); |
507 | 511 #endif |
512 //yaz | |
513 // convert msg to ascii first. if it succeed, send as plain ascii. | |
514 // if it fails, convert msg into UTF-16BE, and send it. | |
515 ucs = g_convert(msg, strlen(msg), "ASCII", "UTF-8", NULL, &bytes, NULL); | |
516 if(ucs){ | |
517 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); | |
518 | |
519 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ | |
520 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ | |
521 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); | |
522 | |
523 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); | |
524 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); | |
525 aim_tlvlist_add_raw(&inner_tlvlist, 0x000c, strlen(msg), (guint8 *)msg); | |
526 free(ucs); | |
527 } else { | |
528 byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2+4+11); | |
529 | |
530 byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ | |
531 byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ | |
532 byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT); | |
533 | |
534 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); | |
535 aim_tlvlist_add_raw(&inner_tlvlist, 0x000d, 11, (guint8 *)"unicode-2-0"); | |
536 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); | |
537 //yaz | |
538 ucs = g_convert(msg, strlen(msg), "UTF-16BE", "UTF-8", NULL, &bytes, NULL); | |
539 if(ucs){ | |
540 botch_ucs(ucs, bytes); | |
541 aim_tlvlist_add_raw(&inner_tlvlist, 0x000c, bytes, (guint8 *)ucs); | |
542 free(ucs); | |
543 } | |
544 } | |
545 #if 0 | |
508 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); | 546 aim_tlvlist_add_16(&inner_tlvlist, 0x000a, 0x0001); |
509 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); | 547 aim_tlvlist_add_noval(&inner_tlvlist, 0x000f); |
510 aim_tlvlist_add_str(&inner_tlvlist, 0x000c, msg); | 548 aim_tlvlist_add_str(&inner_tlvlist, 0x000c, msg); |
549 #endif | |
511 aim_tlvlist_add_chatroom(&inner_tlvlist, 0x2711, exchange, roomname, instance); | 550 aim_tlvlist_add_chatroom(&inner_tlvlist, 0x2711, exchange, roomname, instance); |
512 aim_tlvlist_write(&hdrbs, &inner_tlvlist); | 551 aim_tlvlist_write(&hdrbs, &inner_tlvlist); |
513 | 552 |
514 aim_tlvlist_add_raw(&outer_tlvlist, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); | 553 aim_tlvlist_add_raw(&outer_tlvlist, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); |
515 byte_stream_destroy(&hdrbs); | 554 byte_stream_destroy(&hdrbs); |