changeset 7747:3906c0957d4f

[gaim-migrate @ 8392] Felipe Contreras (revo) gives us i18n yahoo email notification committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 04 Dec 2003 12:20:30 +0000
parents d7fd01f7bdcb
children 8165ab2a00e6
files src/protocols/yahoo/yahoo.c
diffstat 1 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Thu Dec 04 12:12:11 2003 +0000
+++ b/src/protocols/yahoo/yahoo.c	Thu Dec 04 12:20:30 2003 +0000
@@ -799,6 +799,32 @@
 	}
 }
 
+#define OUT_CHARSET "utf-8"
+
+static char *yahoo_decode(const char *text)
+{
+	char *converted;
+	char *p, *n, *new;
+	
+	n = new = g_malloc(strlen (text));
+
+	for (p = (char *)text; *p; p++, n++) {
+		if (*p == '\\') {
+			sscanf(p + 1, "%3o\n", (int *)n);
+			p += 3;
+		}
+		else
+			*n = *p;
+	}
+
+	*n = '\0';
+	
+	converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
+	g_free(new);
+
+	return converted;
+}
+
 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
 {
 	GaimAccount *account = gaim_connection_get_account(gc);
@@ -825,11 +851,15 @@
 	}
 
 	if (who && subj && email && *email) {
-		char *from = g_strdup_printf("%s (%s)", who, email);
-
-		gaim_notify_email(gc, subj, from, gaim_account_get_username(account),
+		char *dec_who = yahoo_decode(who);
+		char *dec_subj = yahoo_decode(subj);
+		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);
 
+		g_free(dec_who);
+		g_free(dec_subj);
 		g_free(from);
 	} else if (count > 0) {
 		const char *to = gaim_account_get_username(account);