Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo.c @ 27937:1337d2813b2d
propagate from branch 'im.pidgin.pidgin' (head 5ab68ddb0251205f7ef97f4c280e65696cbd5ff2)
to branch 'im.pidgin.pidgin.yaz' (head 7a5d48783707dd377fd754961d3b009c3e492827)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 07 Apr 2009 14:32:50 +0000 |
parents | 38238d41923b f44832c6a65b |
children | 26f40c154689 |
comparison
equal
deleted
inserted
replaced
26588:1a94a964bddf | 27937:1337d2813b2d |
---|---|
1428 } | 1428 } |
1429 } | 1429 } |
1430 | 1430 |
1431 #define OUT_CHARSET "utf-8" | 1431 #define OUT_CHARSET "utf-8" |
1432 | 1432 |
1433 static char *yahoo_decode(const char *text) | 1433 static char *yahoo_decode(PurpleConnection *gc, const char *text) |
1434 { | 1434 { |
1435 struct yahoo_data *yd = gc->proto_data; | |
1435 char *converted = NULL; | 1436 char *converted = NULL; |
1436 char *n, *new; | 1437 char *n, *new; |
1437 const char *end, *p; | 1438 const char *end, *p; |
1438 int i, k; | 1439 int i, k; |
1439 | 1440 |
1470 *n = *p; | 1471 *n = *p; |
1471 } | 1472 } |
1472 | 1473 |
1473 *n = '\0'; | 1474 *n = '\0'; |
1474 | 1475 |
1475 if (strstr(text, "\033$B")) | 1476 if (yd->jp) { |
1476 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | 1477 converted = g_convert(new, n - new, OUT_CHARSET, "UTF-8", NULL, NULL, NULL); |
1477 if (!converted) | 1478 } |
1478 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | 1479 if (!yd->jp || !converted) { |
1479 g_free(new); | 1480 if (strstr(text, "\033$B")) |
1481 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | |
1482 if (!converted) | |
1483 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | |
1484 g_free(new); | |
1485 } | |
1480 | 1486 |
1481 return converted; | 1487 return converted; |
1482 } | 1488 } |
1483 | 1489 |
1484 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) | 1490 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) |
1507 subj = pair->value; | 1513 subj = pair->value; |
1508 l = l->next; | 1514 l = l->next; |
1509 } | 1515 } |
1510 | 1516 |
1511 if (who && subj && email && *email) { | 1517 if (who && subj && email && *email) { |
1512 char *dec_who = yahoo_decode(who); | 1518 char *dec_who = yahoo_decode(gc, who); |
1513 char *dec_subj = yahoo_decode(subj); | 1519 char *dec_subj = yahoo_decode(gc, subj); |
1514 char *from = g_strdup_printf("%s (%s)", dec_who, email); | 1520 char *from = g_strdup_printf("%s (%s)", dec_who, email); |
1515 | 1521 |
1516 purple_notify_email(gc, dec_subj, from, purple_account_get_username(account), | 1522 purple_notify_email(gc, dec_subj, from, purple_account_get_username(account), |
1517 yahoo_mail_url, NULL, NULL); | 1523 yahoo_mail_url, NULL, NULL); |
1518 | 1524 |
1665 to_y64(result96, digest, 16); | 1671 to_y64(result96, digest, 16); |
1666 | 1672 |
1667 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | 1673 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); |
1668 | 1674 |
1669 if(yd->jp) { | 1675 if(yd->jp) { |
1670 yahoo_packet_hash(pack, "sssss", | 1676 yahoo_packet_hash(pack, "ssssss", |
1671 0, name, | 1677 0, name, |
1672 6, result6, | 1678 6, result6, |
1673 96, result96, | 1679 96, result96, |
1674 1, name, | 1680 1, name, |
1681 244, YAHOOJP_CLIENT_VERSION_ID, | |
1675 135, YAHOOJP_CLIENT_VERSION); | 1682 135, YAHOOJP_CLIENT_VERSION); |
1676 } else { | 1683 } else { |
1677 yahoo_packet_hash(pack, "ssssss", | 1684 yahoo_packet_hash(pack, "ssssss", |
1678 0, name, | 1685 0, name, |
1679 6, result6, | 1686 6, result6, |
2128 } | 2135 } |
2129 purple_debug_info("yahoo", "yahoo status: %d\n", yd->current_status); | 2136 purple_debug_info("yahoo", "yahoo status: %d\n", yd->current_status); |
2130 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, 0); | 2137 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, 0); |
2131 | 2138 |
2132 if(yd->jp) { | 2139 if(yd->jp) { |
2133 yahoo_packet_hash(pack, "sssss", | 2140 yahoo_packet_hash(pack, "ssssss", |
2134 0, name, | 2141 0, name, |
2135 6, resp_6, | 2142 6, resp_6, |
2136 96, resp_96, | 2143 96, resp_96, |
2137 1, name, | 2144 1, name, |
2145 244, YAHOOJP_CLIENT_VERSION_ID, | |
2138 135, YAHOOJP_CLIENT_VERSION); | 2146 135, YAHOOJP_CLIENT_VERSION); |
2139 } else { | 2147 } else { |
2140 yahoo_packet_hash(pack, "ssssss", | 2148 yahoo_packet_hash(pack, "ssssss", |
2141 0, name, | 2149 0, name, |
2142 6, resp_6, | 2150 6, resp_6, |
4260 "Host: login.yahoo.com\r\n" | 4268 "Host: login.yahoo.com\r\n" |
4261 "Content-Length: 0\r\n\r\n", | 4269 "Content-Length: 0\r\n\r\n", |
4262 use_whole_url ? base_url : "", | 4270 use_whole_url ? base_url : "", |
4263 yd->cookie_t, yd->cookie_y); | 4271 yd->cookie_t, yd->cookie_y); |
4264 | 4272 |
4265 url_data = purple_util_fetch_url_request(base_url, use_whole_url, | 4273 if (yd->jp) |
4274 url_data = NULL; | |
4275 else | |
4276 url_data = purple_util_fetch_url_request(base_url, use_whole_url, | |
4266 "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, request, FALSE, | 4277 "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, request, FALSE, |
4267 yahoo_get_inbox_token_cb, gc); | 4278 yahoo_get_inbox_token_cb, gc); |
4268 | 4279 |
4269 g_free(request); | 4280 g_free(request); |
4270 | 4281 |
4684 | 4695 |
4685 return; | 4696 return; |
4686 } | 4697 } |
4687 | 4698 |
4688 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4699 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); |
4700 if(!pkt) { // yaz | |
4701 purple_debug_info("yahoo", "yahoo_set_idle: pkt == NULL\n"); | |
4702 return; | |
4703 } | |
4704 | |
4689 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4705 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
4690 | 4706 |
4691 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4707 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
4692 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | 4708 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
4693 yahoo_packet_hash_str(pkt, 19, conv_msg); | 4709 yahoo_packet_hash_str(pkt, 19, conv_msg); |
4728 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4744 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4729 yd->current_status = get_yahoo_status_from_purple_status(status); | 4745 yd->current_status = get_yahoo_status_from_purple_status(status); |
4730 } | 4746 } |
4731 | 4747 |
4732 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4748 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); |
4749 if(!pkt) { | |
4750 purple_debug_info("yahoo", "yahoo_set_idle: pkt == NULL\n"); | |
4751 return; | |
4752 } | |
4733 | 4753 |
4734 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4754 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
4735 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4755 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
4736 const char *tmp; | 4756 const char *tmp; |
4757 gboolean utf8 = TRUE; | |
4737 if (status == NULL) | 4758 if (status == NULL) |
4738 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4759 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4739 tmp = purple_status_get_attr_string(status, "message"); | 4760 tmp = purple_status_get_attr_string(status, "message"); |
4740 if (tmp != NULL) { | 4761 if (tmp != NULL) { |
4741 msg = yahoo_string_encode(gc, tmp, NULL); | 4762 msg = yahoo_string_encode(gc, tmp, &utf8); |
4742 msg2 = purple_markup_strip_html(msg); | 4763 msg2 = purple_markup_strip_html(msg); |
4743 yahoo_packet_hash_str(pkt, 19, msg2); | 4764 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
4765 yahoo_packet_hash_str(pkt, 19, msg2); // yaz: pkt may be NULL. | |
4744 } else { | 4766 } else { |
4745 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for | 4767 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for |
4746 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ | 4768 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ |
4769 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | |
4747 yahoo_packet_hash_str(pkt, 19, _("Away")); | 4770 yahoo_packet_hash_str(pkt, 19, _("Away")); |
4748 } | 4771 } |
4749 } else { | 4772 } else { |
4750 yahoo_packet_hash_str(pkt, 19, ""); | 4773 yahoo_packet_hash_str(pkt, 19, ""); |
4751 } | 4774 } |
5480 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5503 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5481 | 5504 |
5482 option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); | 5505 option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); |
5483 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5506 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5484 | 5507 |
5485 option = purple_account_option_string_new(_("Encoding"), "local_charset", "ISO-8859-1"); | 5508 option = purple_account_option_string_new(_("Encoding"), "local_charset", "UTF-8"); |
5486 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5509 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5487 | 5510 |
5488 | 5511 |
5489 #if 0 | 5512 #if 1 |
5490 option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); | 5513 option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); |
5491 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5514 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5492 | 5515 |
5493 option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); | 5516 option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); |
5494 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5517 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |