Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/oscar.c @ 28592:493f48f8d17f 2.6.2_jp
merged with im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 07 Sep 2009 20:39:36 +0900 |
parents | 336d03cdced6 3b820f5d7d6a |
children | 75aab8587e90 |
comparison
equal
deleted
inserted
replaced
28533:7336033277da | 28592:493f48f8d17f |
---|---|
239 */ | 239 */ |
240 while (utf8[i]) | 240 while (utf8[i]) |
241 { | 241 { |
242 if ((unsigned char)utf8[i] > 0x7f) { | 242 if ((unsigned char)utf8[i] > 0x7f) { |
243 /* not ASCII! */ | 243 /* not ASCII! */ |
244 charset = AIM_CHARSET_CUSTOM; | 244 charset = AIM_CHARSET_LATIN_1; |
245 break; | 245 break; |
246 } | 246 } |
247 i++; | 247 i++; |
248 } | 248 } |
249 | 249 |
447 return NULL; | 447 return NULL; |
448 | 448 |
449 if (charset == AIM_CHARSET_UNICODE) { | 449 if (charset == AIM_CHARSET_UNICODE) { |
450 charsetstr1 = "UTF-16BE"; | 450 charsetstr1 = "UTF-16BE"; |
451 charsetstr2 = "UTF-8"; | 451 charsetstr2 = "UTF-8"; |
452 } else if (charset == AIM_CHARSET_CUSTOM) { | 452 } else if (charset == AIM_CHARSET_LATIN_1) { |
453 if ((sourcebn != NULL) && oscar_util_valid_name_icq(sourcebn)) | 453 if ((sourcebn != NULL) && oscar_util_valid_name_icq(sourcebn)) |
454 charsetstr1 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | 454 charsetstr1 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
455 else | 455 else |
456 charsetstr1 = "ISO-8859-1"; | 456 charsetstr1 = "ISO-8859-1"; |
457 charsetstr2 = "UTF-8"; | 457 charsetstr2 = "UTF-8"; |
563 /* nosuke reported that this portion caused unexpected | 563 /* nosuke reported that this portion caused unexpected |
564 * conversion from utf-8 fullwidth tilde/numbers/alphabets to | 564 * conversion from utf-8 fullwidth tilde/numbers/alphabets to |
565 * halfwidth ones on windows environment. --yaz */ | 565 * halfwidth ones on windows environment. --yaz */ |
566 *msg = g_convert(from, -1, charsetstr, "UTF-8", NULL, &msglen, &err); | 566 *msg = g_convert(from, -1, charsetstr, "UTF-8", NULL, &msglen, &err); |
567 if (*msg != NULL) { | 567 if (*msg != NULL) { |
568 *charset = AIM_CHARSET_CUSTOM; | 568 *charset = AIM_CHARSET_LATIN_1; |
569 *charsubset = 0x0000; | 569 *charsubset = 0x0000; |
570 *msglen_int = msglen; | 570 *msglen_int = msglen; |
571 return; | 571 return; |
572 } | 572 } |
573 | 573 |
855 /* If we have both b and userinfo we favor userinfo, because if we're | 855 /* If we have both b and userinfo we favor userinfo, because if we're |
856 viewing someone's profile then we want the HTML away message, and | 856 viewing someone's profile then we want the HTML away message, and |
857 the "message" attribute of the status contains only the plaintext | 857 the "message" attribute of the status contains only the plaintext |
858 message. */ | 858 message. */ |
859 if (userinfo) { | 859 if (userinfo) { |
860 if ((userinfo->flags & AIM_FLAG_AWAY)) { | 860 if ((userinfo->flags & AIM_FLAG_AWAY) |
861 /* Away message? */ | 861 && userinfo->away_len > 0 |
862 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | 862 && userinfo->away != NULL |
863 tmp = oscar_encoding_extract(userinfo->away_encoding); | 863 && userinfo->away_encoding != NULL) |
864 message = oscar_encoding_to_utf8(account, tmp, userinfo->away, | 864 { |
865 userinfo->away_len); | 865 /* Away message */ |
866 g_free(tmp); | 866 tmp = oscar_encoding_extract(userinfo->away_encoding); |
867 } | 867 message = oscar_encoding_to_utf8(account, |
868 tmp, userinfo->away, userinfo->away_len); | |
869 g_free(tmp); | |
868 } else { | 870 } else { |
869 /* Available message? */ | 871 /* |
872 * Available message or non-HTML away message (because that's | |
873 * all we have right now. | |
874 */ | |
870 if ((userinfo->status != NULL) && userinfo->status[0] != '\0') { | 875 if ((userinfo->status != NULL) && userinfo->status[0] != '\0') { |
871 message = oscar_encoding_to_utf8(account, userinfo->status_encoding, | 876 message = oscar_encoding_to_utf8(account, |
872 userinfo->status, userinfo->status_len); | 877 userinfo->status_encoding, userinfo->status, |
878 userinfo->status_len); | |
873 } | 879 } |
874 #if defined (_WIN32) || defined (__APPLE__) | 880 #if defined (_WIN32) || defined (__APPLE__) |
875 if (userinfo->itmsurl && (userinfo->itmsurl[0] != '\0')) | 881 if (userinfo->itmsurl && (userinfo->itmsurl[0] != '\0')) |
876 itmsurl = oscar_encoding_to_utf8(account, userinfo->itmsurl_encoding, | 882 itmsurl = oscar_encoding_to_utf8(account, userinfo->itmsurl_encoding, |
877 userinfo->itmsurl, userinfo->itmsurl_len); | 883 userinfo->itmsurl, userinfo->itmsurl_len); |
2832 struct name_data *data = g_new(struct name_data, 1); | 2838 struct name_data *data = g_new(struct name_data, 1); |
2833 gchar *bn = g_strdup_printf("%u", args->uin); | 2839 gchar *bn = g_strdup_printf("%u", args->uin); |
2834 gchar *reason = NULL; | 2840 gchar *reason = NULL; |
2835 | 2841 |
2836 if (msg2[5] != NULL) | 2842 if (msg2[5] != NULL) |
2837 reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5])); | 2843 reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_LATIN_1, 0x0000, msg2[5], strlen(msg2[5])); |
2838 | 2844 |
2839 purple_debug_info("oscar", | 2845 purple_debug_info("oscar", |
2840 "Received an authorization request from UIN %u\n", | 2846 "Received an authorization request from UIN %u\n", |
2841 args->uin); | 2847 args->uin); |
2842 data->gc = gc; | 2848 data->gc = gc; |
3261 } | 3267 } |
3262 | 3268 |
3263 static int purple_parse_mtn(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { | 3269 static int purple_parse_mtn(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { |
3264 PurpleConnection *gc = od->gc; | 3270 PurpleConnection *gc = od->gc; |
3265 va_list ap; | 3271 va_list ap; |
3266 guint16 type1, type2; | 3272 guint16 channel, event; |
3267 char *bn; | 3273 char *bn; |
3268 | 3274 |
3269 va_start(ap, fr); | 3275 va_start(ap, fr); |
3270 type1 = (guint16) va_arg(ap, unsigned int); | 3276 channel = (guint16) va_arg(ap, unsigned int); |
3271 bn = va_arg(ap, char *); | 3277 bn = va_arg(ap, char *); |
3272 type2 = (guint16) va_arg(ap, unsigned int); | 3278 event = (guint16) va_arg(ap, unsigned int); |
3273 va_end(ap); | 3279 va_end(ap); |
3274 | 3280 |
3275 switch (type2) { | 3281 switch (event) { |
3276 case 0x0000: { /* Text has been cleared */ | 3282 case 0x0000: { /* Text has been cleared */ |
3277 serv_got_typing_stopped(gc, bn); | 3283 serv_got_typing_stopped(gc, bn); |
3278 } break; | 3284 } break; |
3279 | 3285 |
3280 case 0x0001: { /* Paused typing */ | 3286 case 0x0001: { /* Paused typing */ |
3283 | 3289 |
3284 case 0x0002: { /* Typing */ | 3290 case 0x0002: { /* Typing */ |
3285 serv_got_typing(gc, bn, 0, PURPLE_TYPING); | 3291 serv_got_typing(gc, bn, 0, PURPLE_TYPING); |
3286 } break; | 3292 } break; |
3287 | 3293 |
3294 case 0x000f: { /* Closed IM window */ | |
3295 serv_got_typing_stopped(gc, bn); | |
3296 } break; | |
3297 | |
3288 default: { | 3298 default: { |
3289 /* | 3299 purple_debug_info("oscar", "Received unknown typing " |
3290 * It looks like iChat sometimes sends typing notification | 3300 "notification message from %s. Channel is 0x%04x " |
3291 * with type1=0x0001 and type2=0x000f. Not sure why. | 3301 "and event is 0x%04hx.\n", bn, channel, event); |
3292 */ | |
3293 purple_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", bn, type1, type2); | |
3294 } break; | 3302 } break; |
3295 } | 3303 } |
3296 | 3304 |
3297 return 1; | 3305 return 1; |
3298 } | 3306 } |
4714 charset = oscar_charset_check(str); | 4722 charset = oscar_charset_check(str); |
4715 if (charset == AIM_CHARSET_UNICODE) { | 4723 if (charset == AIM_CHARSET_UNICODE) { |
4716 encoded = g_convert(str, strlen(str), "UTF-16BE", "UTF-8", NULL, ret_len, NULL); | 4724 encoded = g_convert(str, strlen(str), "UTF-16BE", "UTF-8", NULL, ret_len, NULL); |
4717 botch_ucs(encoded, *ret_len); | 4725 botch_ucs(encoded, *ret_len); |
4718 *encoding = "unicode-2-0"; | 4726 *encoding = "unicode-2-0"; |
4719 } else if (charset == AIM_CHARSET_CUSTOM) { | 4727 } else if (charset == AIM_CHARSET_LATIN_1) { |
4720 encoded = g_convert(str, -1, "ISO-8859-1", "UTF-8", NULL, ret_len, NULL); | 4728 encoded = g_convert(str, -1, "ISO-8859-1", "UTF-8", NULL, ret_len, NULL); |
4721 *encoding = "iso-8859-1"; | 4729 *encoding = "iso-8859-1"; |
4722 } else { | 4730 } else { |
4723 encoded = g_strdup(str); | 4731 encoded = g_strdup(str); |
4724 *ret_len = strlen(str); | 4732 *ret_len = strlen(str); |
5617 "ssi: received authorization request from %s\n", bn); | 5625 "ssi: received authorization request from %s\n", bn); |
5618 | 5626 |
5619 buddy = purple_find_buddy(account, bn); | 5627 buddy = purple_find_buddy(account, bn); |
5620 | 5628 |
5621 if (msg != NULL) | 5629 if (msg != NULL) |
5622 reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg)); | 5630 reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_LATIN_1, 0x0000, msg, strlen(msg)); |
5623 | 5631 |
5624 data = g_new(struct name_data, 1); | 5632 data = g_new(struct name_data, 1); |
5625 data->gc = gc; | 5633 data->gc = gc; |
5626 data->name = g_strdup(bn); | 5634 data->name = g_strdup(bn); |
5627 data->nick = (buddy ? g_strdup(purple_buddy_get_alias_only(buddy)) : NULL); | 5635 data->nick = (buddy ? g_strdup(purple_buddy_get_alias_only(buddy)) : NULL); |
5854 | 5862 |
5855 if (charset == AIM_CHARSET_ASCII) | 5863 if (charset == AIM_CHARSET_ASCII) |
5856 charsetstr = "us-ascii"; | 5864 charsetstr = "us-ascii"; |
5857 else if (charset == AIM_CHARSET_UNICODE) | 5865 else if (charset == AIM_CHARSET_UNICODE) |
5858 charsetstr = "unicode-2-0"; | 5866 charsetstr = "unicode-2-0"; |
5859 else if (charset == AIM_CHARSET_CUSTOM) | 5867 else if (charset == AIM_CHARSET_LATIN_1) |
5860 charsetstr = "iso-8859-1"; | 5868 charsetstr = "iso-8859-1"; |
5861 aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "JA"); | 5869 aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "JA"); |
5862 g_free(buf2); | 5870 g_free(buf2); |
5863 g_free(buf); | 5871 g_free(buf); |
5864 | 5872 |