Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo.c @ 27959:fd3869a9337b
propagate from branch 'im.pidgin.pidgin' (head 8c1fa13e01e278e3a2c91c7c595ff091b87f0c3c)
to branch 'im.pidgin.pidgin.yaz' (head a4c69669e1b622aaf72d11d169f8f8503d0b00b3)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 01 Jul 2009 04:12:32 +0000 |
parents | b2465d7fdeac 518b4a900f19 |
children | f058edca3d66 |
comparison
equal
deleted
inserted
replaced
27308:40a670f599ae | 27959:fd3869a9337b |
---|---|
1458 } | 1458 } |
1459 } | 1459 } |
1460 | 1460 |
1461 #define OUT_CHARSET "utf-8" | 1461 #define OUT_CHARSET "utf-8" |
1462 | 1462 |
1463 static char *yahoo_decode(const char *text) | 1463 static char *yahoo_decode(PurpleConnection *gc, const char *text) |
1464 { | 1464 { |
1465 struct yahoo_data *yd = gc->proto_data; | |
1465 char *converted = NULL; | 1466 char *converted = NULL; |
1466 char *n, *new; | 1467 char *n, *new; |
1467 const char *end, *p; | 1468 const char *end, *p; |
1468 int i, k; | 1469 int i, k; |
1469 | 1470 |
1500 *n = *p; | 1501 *n = *p; |
1501 } | 1502 } |
1502 | 1503 |
1503 *n = '\0'; | 1504 *n = '\0'; |
1504 | 1505 |
1505 if (strstr(text, "\033$B")) | 1506 if (yd->jp) { |
1506 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | 1507 converted = g_convert(new, n - new, OUT_CHARSET, "UTF-8", NULL, NULL, NULL); |
1507 if (!converted) | 1508 } |
1508 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | 1509 if (!yd->jp || !converted) { |
1509 g_free(new); | 1510 if (strstr(text, "\033$B")) |
1511 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | |
1512 if (!converted) | |
1513 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | |
1514 g_free(new); | |
1515 } | |
1510 | 1516 |
1511 return converted; | 1517 return converted; |
1512 } | 1518 } |
1513 | 1519 |
1514 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) | 1520 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) |
1537 subj = pair->value; | 1543 subj = pair->value; |
1538 l = l->next; | 1544 l = l->next; |
1539 } | 1545 } |
1540 | 1546 |
1541 if (who && subj && email && *email) { | 1547 if (who && subj && email && *email) { |
1542 char *dec_who = yahoo_decode(who); | 1548 char *dec_who = yahoo_decode(gc, who); |
1543 char *dec_subj = yahoo_decode(subj); | 1549 char *dec_subj = yahoo_decode(gc, subj); |
1544 char *from = g_strdup_printf("%s (%s)", dec_who, email); | 1550 char *from = g_strdup_printf("%s (%s)", dec_who, email); |
1545 | 1551 |
1546 purple_notify_email(gc, dec_subj, from, purple_account_get_username(account), | 1552 purple_notify_email(gc, dec_subj, from, purple_account_get_username(account), |
1547 yahoo_mail_url, NULL, NULL); | 1553 yahoo_mail_url, NULL, NULL); |
1548 | 1554 |
4464 { | 4470 { |
4465 struct yahoo_data *yd = gc->proto_data; | 4471 struct yahoo_data *yd = gc->proto_data; |
4466 struct yahoo_packet *pkt = NULL; | 4472 struct yahoo_packet *pkt = NULL; |
4467 char *msg = NULL, *msg2 = NULL; | 4473 char *msg = NULL, *msg2 = NULL; |
4468 PurpleStatus *status = NULL; | 4474 PurpleStatus *status = NULL; |
4475 gboolean utf8 = TRUE; | |
4469 | 4476 |
4470 if (idle && yd->current_status != YAHOO_STATUS_CUSTOM) | 4477 if (idle && yd->current_status != YAHOO_STATUS_CUSTOM) |
4471 yd->current_status = YAHOO_STATUS_IDLE; | 4478 yd->current_status = YAHOO_STATUS_IDLE; |
4472 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | 4479 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { |
4473 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4480 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4481 const char *tmp; | 4488 const char *tmp; |
4482 if (status == NULL) | 4489 if (status == NULL) |
4483 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4490 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4484 tmp = purple_status_get_attr_string(status, "message"); | 4491 tmp = purple_status_get_attr_string(status, "message"); |
4485 if (tmp != NULL) { | 4492 if (tmp != NULL) { |
4486 gboolean utf8 = TRUE; | |
4487 msg = yahoo_string_encode(gc, tmp, &utf8); | 4493 msg = yahoo_string_encode(gc, tmp, &utf8); |
4488 msg2 = purple_markup_strip_html(msg); | 4494 msg2 = purple_markup_strip_html(msg); |
4489 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | 4495 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
4490 yahoo_packet_hash_str(pkt, 19, msg2); | 4496 yahoo_packet_hash_str(pkt, 19, msg2); |
4491 } else { | 4497 } else { |
4492 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for | 4498 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for |
4493 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ | 4499 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ |
4500 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | |
4494 yahoo_packet_hash_str(pkt, 19, _("Away")); | 4501 yahoo_packet_hash_str(pkt, 19, _("Away")); |
4495 } | 4502 } |
4496 } else { | 4503 } else { |
4497 yahoo_packet_hash_str(pkt, 19, ""); | 4504 yahoo_packet_hash_str(pkt, 19, ""); |
4498 } | 4505 } |
5227 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5234 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5228 | 5235 |
5229 option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); | 5236 option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); |
5230 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5237 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5231 | 5238 |
5232 option = purple_account_option_string_new(_("Encoding"), "local_charset", "ISO-8859-1"); | 5239 option = purple_account_option_string_new(_("Encoding"), "local_charset", "UTF-8"); |
5233 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5240 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5234 | 5241 |
5235 | 5242 |
5236 #if 0 | 5243 #if 1 |
5237 option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); | 5244 option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); |
5238 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5245 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5239 | 5246 |
5240 option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); | 5247 option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); |
5241 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5248 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |