# HG changeset patch # User John Bailey # Date 1200418940 0 # Node ID 4ab154a14e55e3c09d8da48f3fb8aaa62de020c0 # Parent 1aeac7b2051fc3974180b2f97fe85a35aa54346e Patch from Yusuke Odate, modified by me, to support retrieving the full name and nickname/alias from the address book for Yahoo! Japan. As usual, if it works thank Yusuke and if it's broken blame me. Fixes #3295. diff -r 1aeac7b2051f -r 4ab154a14e55 COPYRIGHT --- a/COPYRIGHT Tue Jan 15 17:21:51 2008 +0000 +++ b/COPYRIGHT Tue Jan 15 17:42:20 2008 +0000 @@ -270,6 +270,7 @@ Padraig O'Briain Christopher O'Brien (siege) Jon Oberheide +Yusuke Odate Ruediger Oertel Gudmundur Bjarni Olafsson Bartosz Oler diff -r 1aeac7b2051f -r 4ab154a14e55 ChangeLog --- a/ChangeLog Tue Jan 15 17:21:51 2008 +0000 +++ b/ChangeLog Tue Jan 15 17:42:20 2008 +0000 @@ -10,6 +10,8 @@ * Partial support for viewing ICQ status notes (Collin from ComBOTS GmbH). * Support for Yahoo Messenger 7.0+ file transfer method (Thanumalayan S.) + * Support for retrieving full names and addresses from the address book + on Yahoo! Japan (Yusuke Odate) Pidgin: * Added the ability to theme conversation name colors (red and blue) diff -r 1aeac7b2051f -r 4ab154a14e55 libpurple/protocols/yahoo/util.c --- a/libpurple/protocols/yahoo/util.c Tue Jan 15 17:21:51 2008 +0000 +++ b/libpurple/protocols/yahoo/util.c Tue Jan 15 17:42:20 2008 +0000 @@ -164,6 +164,20 @@ return g_strdup(""); } +char *yahoo_convert_to_numeric(const char *str) +{ + char *retstr, buf[7]; + const char *p; + + retstr = (char*)malloc(strlen(str) * 6 + 1); + memset(retstr, 0x00, sizeof(retstr)); + for (p = str; *p; p++) { + sprintf(buf, "&#%d;", (unsigned char)*p); + strcat(retstr, buf); + } + return retstr; +} + /* * I found these on some website but i don't know that they actually * work (or are supposed to work). I didn't implement them yet. diff -r 1aeac7b2051f -r 4ab154a14e55 libpurple/protocols/yahoo/yahoo.h --- a/libpurple/protocols/yahoo/yahoo.h Tue Jan 15 17:21:51 2008 +0000 +++ b/libpurple/protocols/yahoo/yahoo.h Tue Jan 15 17:42:20 2008 +0000 @@ -218,6 +218,8 @@ */ char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8); +char *yahoo_convert_to_numeric(const char *str); + /* previously-static functions, now needed for yahoo_profile.c */ void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full); diff -r 1aeac7b2051f -r 4ab154a14e55 libpurple/protocols/yahoo/yahoo_aliases.c --- a/libpurple/protocols/yahoo/yahoo_aliases.c Tue Jan 15 17:21:51 2008 +0000 +++ b/libpurple/protocols/yahoo/yahoo_aliases.c Tue Jan 15 17:42:20 2008 +0000 @@ -37,6 +37,8 @@ /* I hate hardcoding this stuff, but Yahoo never sends us anything to use. Someone in the know may be able to tweak this URL */ #define YAHOO_ALIAS_FETCH_URL "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252" #define YAHOO_ALIAS_UPDATE_URL "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252" +#define YAHOOJP_ALIAS_FETCH_URL "http://address.yahoo.co.jp/yab/jp?v=XM&prog=ymsgr&.intl=jp&diffs=1&t=0&tags=short&rt=0&prog-ver=7.0.0.7" +#define YAHOOJP_ALIAS_UPDATE_URL "http://address.yahoo.co.jp/yab/jp?v=XM&prog=ymsgr&.intl=jp&sync=1&tags=short&noclear=1" void yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias); @@ -90,7 +92,10 @@ id = xmlnode_get_attrib(item,"id"); /* Yahoo stores first and last names separately, lets put them together into a full name */ - full_name = g_strstrip(g_strdup_printf("%s %s", (fn != NULL ? fn : "") , (ln != NULL ? ln : ""))); + if (yd->jp) + full_name = g_strstrip(g_strdup_printf("%s %s", (ln != NULL ? ln : "") , (fn != NULL ? fn : ""))); + else + full_name = g_strstrip(g_strdup_printf("%s %s", (fn != NULL ? fn : "") , (ln != NULL ? ln : ""))); nick_name = (nn != NULL ? g_strstrip(g_strdup_printf("%s", nn)) : NULL); if (nick_name != NULL) @@ -139,7 +144,7 @@ { struct yahoo_data *yd = gc->proto_data; struct callback_data *cb; - const char *url = YAHOO_ALIAS_FETCH_URL; + const char *url; char *request, *webpage, *webaddress; PurpleUtilFetchUrlData *url_data; @@ -148,6 +153,7 @@ cb->gc = gc; /* Build all the info to make the web request */ + url = yd->jp ? YAHOOJP_ALIAS_FETCH_URL : YAHOO_ALIAS_FETCH_URL; purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL); request = g_strdup_printf("GET /%s HTTP/1.1\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" @@ -225,10 +231,11 @@ struct callback_data *cb; PurpleBuddy *buddy; PurpleUtilFetchUrlData *url_data; + char *alias_jp, *converted_alias_jp; - g_return_if_fail(alias!= NULL); - g_return_if_fail(who!=NULL); - g_return_if_fail(gc!=NULL); + g_return_if_fail(alias != NULL); + g_return_if_fail(who != NULL); + g_return_if_fail(gc != NULL); purple_debug_info("yahoo", "Sending '%s' as new alias for user '%s'.\n",alias, who); @@ -247,12 +254,23 @@ cb->gc = gc; /* Build all the info to make the web request */ - url = g_strdup(YAHOO_ALIAS_UPDATE_URL); + url = g_strdup(yd->jp? YAHOOJP_ALIAS_UPDATE_URL: YAHOO_ALIAS_UPDATE_URL); purple_url_parse(url, &webaddress, &inttmp, &webpage, &strtmp, &strtmp); - content = g_strdup_printf("\n" - "\n\r\n", - gc->account->username, who, yu->id, g_markup_escape_text(alias, strlen(alias))); + if (yd->jp) { + alias_jp = g_convert(alias, strlen(alias), "EUC-JP", "UTF-8", NULL, NULL, NULL); + converted_alias_jp = yahoo_convert_to_numeric(alias_jp); + content = g_strdup_printf("\n" + "\n\r\n", + gc->account->username, who, yu->id, converted_alias_jp); + free(converted_alias_jp); + g_free(alias_jp); + } + else { + content = g_strdup_printf("\n" + "\n\r\n", + gc->account->username, who, yu->id, g_markup_escape_text(alias, strlen(alias))); + } request = g_strdup_printf("POST /%s HTTP/1.1\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"