changeset 9221:8054855f2bb9

[gaim-migrate @ 10017] a yahoo japan patch from wing: 1. Recognize ISO2022 in Subject header 2. Go to mail.yahoo.co.jp if account is marked as "Yahoo Japan" 3. Make profiles.yahoo.co.jp a #define and use it in yahoo_profile.c I poked at it myself some too, to make it give the right profile url in the get info box for yahoo japan. I also added a new macro to connection.h to check if a connection is valid. I'm not very good at macros, however, and used its argument twice. Someone should fix that :) committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sun, 06 Jun 2004 18:45:06 +0000
parents f0488214826f
children 316b1afb5974
files src/connection.h src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo.h src/protocols/yahoo/yahoo_profile.c
diffstat 4 files changed, 33 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/connection.h	Sun Jun 06 18:01:32 2004 +0000
+++ b/src/connection.h	Sun Jun 06 18:45:06 2004 +0000
@@ -269,6 +269,13 @@
  */
 GList *gaim_connections_get_connecting(void);
 
+/**
+ * Checks if gc is still a valid pointer to a gc.
+ *
+ * @return @c TRUE if gc is valid.
+ */
+#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc)) || g_list_find(gaim_connections_get_connecting(), (gc)))
+
 /*@}*/
 
 /**************************************************************************/
--- a/src/protocols/yahoo/yahoo.c	Sun Jun 06 18:01:32 2004 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sun Jun 06 18:45:06 2004 +0000
@@ -894,7 +894,7 @@
 
 static char *yahoo_decode(const char *text)
 {
-	char *converted;
+	char *converted = NULL;
 	char *n, *new;
 	const char *end, *p;
 	int i, k;
@@ -934,7 +934,10 @@
 
 	*n = '\0';
 
-	converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
+	if (strstr(text, "\033$B"))
+		converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL);
+	if (!converted)
+		converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
 	g_free(new);
 
 	return converted;
@@ -943,9 +946,11 @@
 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
 {
 	GaimAccount *account = gaim_connection_get_account(gc);
+	struct yahoo_data *yd = gc->proto_data;
 	char *who = NULL;
 	char *email = NULL;
 	char *subj = NULL;
+	char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL);
 	int count = 0;
 	GSList *l = pkt->hash;
 
@@ -971,14 +976,14 @@
 		char *from = g_strdup_printf("%s (%s)", dec_who, email);
 
 		gaim_notify_email(gc, dec_subj, from, gaim_account_get_username(account),
-						  "http://mail.yahoo.com/", NULL, NULL);
+						  yahoo_mail_url, NULL, NULL);
 
 		g_free(dec_who);
 		g_free(dec_subj);
 		g_free(from);
 	} else if (count > 0) {
 		const char *to = gaim_account_get_username(account);
-		const char *url = "http://mail.yahoo.com/";
+		const char *url = yahoo_mail_url;
 
 		gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url,
 						   NULL, NULL);
--- a/src/protocols/yahoo/yahoo.h	Sun Jun 06 18:01:32 2004 +0000
+++ b/src/protocols/yahoo/yahoo.h	Sun Jun 06 18:45:06 2004 +0000
@@ -30,6 +30,7 @@
 #define YAHOO_PAGER_HOST "scs.msg.yahoo.com"
 #define YAHOO_PAGER_PORT 5050
 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
+#define YAHOO_MAIL_URL "http://mail.yahoo.com/"
 #define YAHOO_XFER_HOST "filetransfer.msg.yahoo.com"
 #define YAHOO_XFER_PORT 80
 #define YAHOO_ROOMLIST_URL "http://insider.msg.yahoo.com/ycontent/"
@@ -37,9 +38,10 @@
 /* really we should get the list of servers from
  http://update.messenger.yahoo.co.jp/servers.html */
 #define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp"
+#define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/"
+#define YAHOOJP_MAIL_URL "http://mail.yahoo.co.jp/"
 #define YAHOOJP_XFER_HOST "filetransfer.msg.yahoo.co.jp"
 #define YAHOOJP_WEBCAM_HOST "wc.yahoo.co.jp"
-#define YAHOOJP_PROFILE_URL "profiles.yahoo.co.jp"
 
 #define WEBMESSENGER_URL "http://login.yahoo.com/config/login?.src=pg"
 
--- a/src/protocols/yahoo/yahoo_profile.c	Sun Jun 06 18:01:32 2004 +0000
+++ b/src/protocols/yahoo/yahoo_profile.c	Sun Jun 06 18:45:06 2004 +0000
@@ -626,9 +626,18 @@
 	char *last_updated_utf8_string;
 	int lang, strid;
 	GaimBuddy *b;
+	struct yahoo_data *yd;
+
+	if (!GAIM_CONNECTION_IS_VALID(info_data->gc)) {
+		g_free(info_data->name);
+		g_free(info_data);
+		return;
+	}
 
 	gaim_debug_info("yahoo", "In yahoo_got_info\n");
 
+	yd = info_data->gc->proto_data;
+	
 	/* we failed to grab the profile URL. this should never happen */
 	if (url_text == NULL || strcmp(url_text, "") == 0) {
 		gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
@@ -673,7 +682,7 @@
 	}
 	if (p) {
 		for (strid = 0; profile_strings[strid].lang != XX; strid += 1) {
-		if (profile_strings[strid].lang == profile_langs[lang].lang) break;
+			if (profile_strings[strid].lang == profile_langs[lang].lang) break;
 		}
 		gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang);
 	}
@@ -895,8 +904,8 @@
 	/* put a link to the actual profile URL */
 	g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL"));
 	g_string_append_printf(s, "<a href=\"%s%s\">%s%s</a><br>",
-			YAHOO_PROFILE_URL, info_data->name,
-			YAHOO_PROFILE_URL, info_data->name);
+			(yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), info_data->name,
+			(yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), info_data->name);
 
 	/* finish off the html */
 	g_string_append(s, "</body></html>\n");
@@ -934,11 +943,8 @@
 	data->gc   = gc;
 	data->name = g_strdup(name);
 
-	if (yd->jp) {
-		url = g_strdup_printf("%s%s", "http://profiles.yahoo.co.jp/", name);
-	} else {
-		url = g_strdup_printf("%s%s", YAHOO_PROFILE_URL, name);
-	}
+	url = g_strdup_printf("%s%s",
+			(yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), name);
 
 	gaim_url_fetch(url, FALSE, NULL, FALSE, yahoo_got_info, data);