changeset 24224:9396a2124893

Add some debug output to the oscar encoding process.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 02 Oct 2008 14:19:47 +0000
parents 3612a4fbd88c
children 37b501040985
files libpurple/protocols/oscar/oscar.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Thu Oct 02 06:53:24 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Oct 02 14:19:47 2008 +0000
@@ -508,7 +508,7 @@
 		b = purple_find_buddy(account, destsn);
 		if ((b != NULL) && (PURPLE_BUDDY_IS_ONLINE(b)))
 		{
-			*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, NULL);
+			*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, &err);
 			if (*msg != NULL)
 			{
 				*charset = AIM_CHARSET_UNICODE;
@@ -516,6 +516,11 @@
 				*msglen_int = msglen;
 				return;
 			}
+
+			purple_debug_error("oscar", "Conversion from UTF-8 to UTF-16BE failed: %s.\n",
+							   err->message);
+			g_error_free(err);
+			err = NULL;
 		}
 	}
 
@@ -531,7 +536,7 @@
 	 * XXX - We need a way to only attempt to convert if we KNOW "from"
 	 * can be converted to "charsetstr"
 	 */
-	*msg = g_convert(from, -1, charsetstr, "UTF-8", NULL, &msglen, NULL);
+	*msg = g_convert(from, -1, charsetstr, "UTF-8", NULL, &msglen, &err);
 	if (*msg != NULL) {
 		*charset = AIM_CHARSET_CUSTOM;
 		*charsubset = 0x0000;
@@ -539,6 +544,11 @@
 		return;
 	}
 
+	purple_debug_info("oscar", "Conversion from UTF-8 to %s failed (%s), falling back to unicode.\n",
+					  charsetstr, err->message);
+	g_error_free(err);
+	err = NULL;
+
 	/*
 	 * Nothing else worked, so send as UTF-16BE.
 	 */
@@ -552,6 +562,7 @@
 
 	purple_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message);
 	g_error_free(err);
+	err = NULL;
 
 	purple_debug_error("oscar", "This should NEVER happen!  Sending UTF-8 text flagged as ASCII.\n");
 	*msg = g_strdup(from);