changeset 6292:6651ecdda5d6

[gaim-migrate @ 6791] This makes umlauts and accents and other suck iso-8859-1 characters show up in available messages--and not crash Gaim. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 24 Jul 2003 02:04:19 +0000
parents 9287c2897a07
children 70f48f166aee
files ChangeLog src/protocols/oscar/aim.h src/protocols/oscar/info.c src/protocols/oscar/oscar.c
diffstat 4 files changed, 38 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jul 23 23:42:29 2003 +0000
+++ b/ChangeLog	Thu Jul 24 02:04:19 2003 +0000
@@ -4,15 +4,15 @@
 	* Various bug fixes (larne from irc, Tim Ringenbach, Bjoern 
 	  Voigt, Paul A (darkrain))
 	* British English "translation" updated (Sam Halliday)
+	* Chinese (Simplified) translation updated (Funda Wang)
 	* Chinese (Traditional) translation updated (Ambrose C. Li)
-	* German translation updated (Bjoern Voigt)
-	* Italian translation updated (Luca Beltrame, Claudio Satriano)
-	* Serbian translation updated (Danilo Segan)
 	* Dutch translation updated (Vincent van Adrighem)
+	* German translation updated (Bjoern Voigt)
 	* Hungarian translation updated (Zoltan Sutto)
+	* Italian translation updated (Luca Beltrame, Claudio Satriano)
+	* Portuguese (Brazilian) translation added (Mauricio de Lemos Rodrigues Collares Neto)
+	* Serbian translation updated (Danilo Segan)
 	* Spanish translation updated (Javier Fernandez-Sanguino Pena)
-	* Chinese (Simplified) translation updated (Funda Wang)
-	* Portuguese (Brazilian) translation added (Mauricio de Lemos Rodrigues Collares Neto)
 
 version 0.66 (07/18/2003):
 	* Freebsd compile fix (Matthew Luckie)
--- a/src/protocols/oscar/aim.h	Wed Jul 23 23:42:29 2003 +0000
+++ b/src/protocols/oscar/aim.h	Thu Jul 24 02:04:19 2003 +0000
@@ -977,7 +977,9 @@
 	fu32_t present;
 	fu16_t iconcsumlen;
 	fu8_t *iconcsum;
-	char *availablemsg;
+	char *availmsg_encoding;
+	char *availmsg;
+	int availmsg_len;
 } aim_userinfo_t;
 
 faim_export const char *aim_userinfo_sn(aim_userinfo_t *ui);
--- a/src/protocols/oscar/info.c	Wed Jul 23 23:42:29 2003 +0000
+++ b/src/protocols/oscar/info.c	Thu Jul 24 02:04:19 2003 +0000
@@ -450,7 +450,8 @@
 faim_internal void aim_info_free(aim_userinfo_t *info)
 {
 	free(info->iconcsum);
-	free(info->availablemsg);
+	free(info->availmsg_encoding);
+	free(info->availmsg);
 }
 
 /*
@@ -675,7 +676,7 @@
 
 				switch (type2) {
 					case 0x0000: { /* This is an official buddy icon? */
-						/* This is always 5 bytes? */
+						/* This is always 5 bytes of "0x02 01 d2 04 72"? */
 						aim_bstream_advance(bs, length2);
 					} break;
 
@@ -690,8 +691,16 @@
 
 					case 0x0002: { /* An available message */
 						if (length2 > 4) {
-							free(outinfo->availablemsg);
-							outinfo->availablemsg = aimbs_getstr(bs, aimbs_get16(bs));
+							free(outinfo->availmsg);
+							outinfo->availmsg_len = aimbs_get16(bs);
+							outinfo->availmsg = aimbs_getraw(bs, outinfo->availmsg_len);
+							if (aimbs_get16(bs) == 0x0001) { /* We have an encoding */
+								aimbs_get16(bs);
+								outinfo->availmsg_encoding = aimbs_getstr(bs, aimbs_get16(bs));
+							} else {
+								/* No explicit encoding, client should use UTF-8 */
+								outinfo->availmsg_encoding = NULL;
+							}
 						} else
 							aim_bstream_advance(bs, length2);
 					} break;
--- a/src/protocols/oscar/oscar.c	Wed Jul 23 23:42:29 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Thu Jul 24 02:04:19 2003 +0000
@@ -148,7 +148,7 @@
 	time_t signon;
 	int caps;
 	gboolean typingnot;
-	gchar *availablemsg;
+	gchar *availmsg;
 
 	unsigned long ico_me_len;
 	unsigned long ico_me_csum;
@@ -285,7 +285,7 @@
 
 static void oscar_free_buddyinfo(void *data) {
 	struct buddyinfo *bi = data;
-	g_free(bi->availablemsg);
+	g_free(bi->availmsg);
 	g_free(bi->iconcsum);
 	g_free(bi);
 }
@@ -1804,11 +1804,18 @@
 		bi->caps = caps;
 	bi->typingnot = FALSE;
 	bi->ico_informed = FALSE;
-	free(bi->availablemsg);
-	if (info->availablemsg)
-		bi->availablemsg = g_strdup(info->availablemsg);
+	free(bi->availmsg);
+	if (info->availmsg)
+		if (info->availmsg_encoding) {
+			gchar *enc = g_strdup_printf("charset=\"%s\"", info->availmsg_encoding);
+			bi->availmsg = oscar_encoding_to_utf8(enc, info->availmsg, info->availmsg_len);
+			g_free(enc);
+		} else {
+			/* No explicit encoding means utf8.  Yay. */
+			bi->availmsg = g_strdup(info->availmsg);
+		}
 	else
-		bi->availablemsg = NULL;
+		bi->availmsg = NULL;
 
 	/* Server stored icon stuff */
 	if (info->iconcsumlen) {
@@ -5407,8 +5414,8 @@
 				free(tmp);
 			}
 
-			if (bi->availablemsg && !(b->uc & UC_UNAVAILABLE)) {
-				gchar *escaped = g_markup_escape_text(bi->availablemsg, strlen(bi->availablemsg));
+			if (bi->availmsg && !(b->uc & UC_UNAVAILABLE)) {
+				gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg));
 				tmp = yay;
 				yay = g_strconcat(tmp, _("<b>Available:</b> "), escaped, "\n", NULL);
 				free(tmp);
@@ -5446,8 +5453,8 @@
 			ret = g_strdup(_("Away"));
 	} else if (GAIM_BUDDY_IS_ONLINE(b)) {
 		struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name));
-		if (bi->availablemsg)
-			ret = g_markup_escape_text(bi->availablemsg, strlen(bi->availablemsg));
+		if (bi->availmsg)
+			ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg));
 	} else {
 		char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name);
 		if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))