im.pidgin.pidgin: ff1804f8ae79963a3b8a380c41af69ea5a69b01f

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Tue Jan 15 12:45:49 EST 2008


-----------------------------------------------------------------
Revision: ff1804f8ae79963a3b8a380c41af69ea5a69b01f
Ancestor: 650c97ec8f66c218b6d6cb44d636801cd55be7a8
Author: rekkanoryo at pidgin.im
Date: 2008-01-15T17:42:20
Branch: im.pidgin.pidgin

Modified files:
        COPYRIGHT ChangeLog libpurple/protocols/yahoo/util.c
        libpurple/protocols/yahoo/yahoo.h
        libpurple/protocols/yahoo/yahoo_aliases.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- COPYRIGHT	15754acfe71086e3e670e3912f952cc20c53a005
+++ COPYRIGHT	163511708a2ab12e140250aebc917cf840a1a7f0
@@ -270,6 +270,7 @@ Jon Oberheide
 Padraig O'Briain
 Christopher O'Brien (siege)
 Jon Oberheide
+Yusuke Odate
 Ruediger Oertel
 Gudmundur Bjarni Olafsson
 Bartosz Oler
============================================================
--- ChangeLog	2c5a8842dc74f009ca27e6ff47d67816588c48fd
+++ ChangeLog	c7001d9b4bb78aa669b7e6ae8f95c09c09d5a007
@@ -10,6 +10,8 @@ version 2.4.0 (??/??/????):
 	* 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)
============================================================
--- libpurple/protocols/yahoo/util.c	857b60dc62d7be89baa0c3703ec9fc0a9112e602
+++ libpurple/protocols/yahoo/util.c	78228f35e1c403abedb0df427c17eaef5d9d21dd
@@ -164,6 +164,20 @@ char *yahoo_string_decode(PurpleConnecti
 		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.
============================================================
--- libpurple/protocols/yahoo/yahoo.h	908634fe89ad4df26985215b10f04aa75b0c40a5
+++ libpurple/protocols/yahoo/yahoo.h	121ad9f8529b2ec369465de980f841ba4897ecc6
@@ -218,6 +218,8 @@ char *yahoo_string_decode(PurpleConnecti
  */
 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);
 
============================================================
--- libpurple/protocols/yahoo/yahoo_aliases.c	6c500c519679c800f3a43df22d8fb28f603dbed5
+++ libpurple/protocols/yahoo/yahoo_aliases.c	a85386747ce002282ac12c68c51943767099f804
@@ -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 @@ yahoo_fetch_aliases_cb(PurpleUtilFetchUr
 				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 @@ yahoo_fetch_aliases(PurpleConnection *gc
 {
 	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 @@ yahoo_fetch_aliases(PurpleConnection *gc
 	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 @@ yahoo_update_alias(PurpleConnection *gc,
 	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 @@ yahoo_update_alias(PurpleConnection *gc,
 	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("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n"
-				  "<ct e=\"1\"  yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\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("<ab k=\"%s\" cc=\"1\">\n"
+		                          "<ct e=\"1\"  yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n",
+		                          gc->account->username, who, yu->id, converted_alias_jp);
+		free(converted_alias_jp);
+		g_free(alias_jp);
+	}
+	else {
+		content = g_strdup_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n"
+		                          "<ct e=\"1\"  yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\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"


More information about the Commits mailing list