Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo.c @ 27940:b623c1824f29
propagate from branch 'im.pidgin.pidgin' (head 58fbcc161c5eadf3f307cd460a6ce0a209d908df)
to branch 'im.pidgin.pidgin.yaz' (head a378a1d9618c47f5b0e6c67daf613d3c4275f7cf)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 16 Apr 2009 05:51:42 +0000 |
parents | 3712d32363dd 26f40c154689 |
children | 684690dbda4a |
comparison
equal
deleted
inserted
replaced
26650:3712d32363dd | 27940:b623c1824f29 |
---|---|
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, |
4262 "Host: login.yahoo.com\r\n" | 4270 "Host: login.yahoo.com\r\n" |
4263 "Content-Length: 0\r\n\r\n", | 4271 "Content-Length: 0\r\n\r\n", |
4264 use_whole_url ? base_url : "", | 4272 use_whole_url ? base_url : "", |
4265 yd->cookie_t, yd->cookie_y); | 4273 yd->cookie_t, yd->cookie_y); |
4266 | 4274 |
4267 url_data = purple_util_fetch_url_request(base_url, use_whole_url, | 4275 if (yd->jp) |
4276 url_data = NULL; | |
4277 else | |
4278 url_data = purple_util_fetch_url_request(base_url, use_whole_url, | |
4268 "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, request, FALSE, | 4279 "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, request, FALSE, |
4269 yahoo_get_inbox_token_cb, gc); | 4280 yahoo_get_inbox_token_cb, gc); |
4270 | 4281 |
4271 g_free(request); | 4282 g_free(request); |
4272 | 4283 |
4686 | 4697 |
4687 return; | 4698 return; |
4688 } | 4699 } |
4689 | 4700 |
4690 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4701 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); |
4702 if(!pkt) { // yaz | |
4703 purple_debug_info("yahoo", "yahoo_set_idle: pkt == NULL\n"); | |
4704 return; | |
4705 } | |
4706 | |
4691 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4707 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
4692 | 4708 |
4693 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4709 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
4694 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | 4710 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
4695 yahoo_packet_hash_str(pkt, 19, conv_msg); | 4711 yahoo_packet_hash_str(pkt, 19, conv_msg); |
4730 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4746 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4731 yd->current_status = get_yahoo_status_from_purple_status(status); | 4747 yd->current_status = get_yahoo_status_from_purple_status(status); |
4732 } | 4748 } |
4733 | 4749 |
4734 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4750 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); |
4751 if(!pkt) { | |
4752 purple_debug_info("yahoo", "yahoo_set_idle: pkt == NULL\n"); | |
4753 return; | |
4754 } | |
4735 | 4755 |
4736 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4756 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
4737 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4757 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
4738 const char *tmp; | 4758 const char *tmp; |
4759 gboolean utf8 = TRUE; | |
4739 if (status == NULL) | 4760 if (status == NULL) |
4740 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4761 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4741 tmp = purple_status_get_attr_string(status, "message"); | 4762 tmp = purple_status_get_attr_string(status, "message"); |
4742 if (tmp != NULL) { | 4763 if (tmp != NULL) { |
4743 msg = yahoo_string_encode(gc, tmp, NULL); | 4764 msg = yahoo_string_encode(gc, tmp, &utf8); |
4744 msg2 = purple_markup_strip_html(msg); | 4765 msg2 = purple_markup_strip_html(msg); |
4745 yahoo_packet_hash_str(pkt, 19, msg2); | 4766 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
4767 yahoo_packet_hash_str(pkt, 19, msg2); // yaz: pkt may be NULL. | |
4746 } else { | 4768 } else { |
4747 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for | 4769 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for |
4748 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ | 4770 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ |
4771 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | |
4749 yahoo_packet_hash_str(pkt, 19, _("Away")); | 4772 yahoo_packet_hash_str(pkt, 19, _("Away")); |
4750 } | 4773 } |
4751 } else { | 4774 } else { |
4752 yahoo_packet_hash_str(pkt, 19, ""); | 4775 yahoo_packet_hash_str(pkt, 19, ""); |
4753 } | 4776 } |
5482 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5505 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5483 | 5506 |
5484 option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); | 5507 option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); |
5485 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5508 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5486 | 5509 |
5487 option = purple_account_option_string_new(_("Encoding"), "local_charset", "ISO-8859-1"); | 5510 option = purple_account_option_string_new(_("Encoding"), "local_charset", "UTF-8"); |
5488 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5511 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5489 | 5512 |
5490 | 5513 |
5491 #if 0 | 5514 #if 1 |
5492 option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); | 5515 option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); |
5493 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5516 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5494 | 5517 |
5495 option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); | 5518 option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); |
5496 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 5519 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |