# HG changeset patch # User Mikael Berthe # Date 1127333143 -7200 # Node ID 51b8f10cfeb886ef72ad36302e4deebd128b34d0 # Parent 264f402228722ca01ad28d158dba650c8eb0b572 Handle g_locale_from_utf8() failures The biggest issue was that when a message couldn't be utf8-decoded, the user was not notified of the failure, and sometimes didn't even know a message had been sent to him... I don't know if we can ask for a partial decoding, so the message isn't displayed but an error message is now displayed. diff -r 264f40222872 -r 51b8f10cfeb8 mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Tue Sep 20 23:19:36 2005 +0200 +++ b/mcabber/src/jabglue.c Wed Sep 21 22:05:43 2005 +0200 @@ -29,6 +29,7 @@ #include "hooks.h" #include "utils.h" #include "settings.h" +#include "hbuf.h" #define JABBERPORT 5222 #define JABBERSSLPORT 5223 @@ -540,11 +541,11 @@ gchar *name_noutf8 = NULL; gchar *group_noutf8 = NULL; + buddyname = cleanalias; if (name) { name_noutf8 = from_utf8(name); - buddyname = name_noutf8; - } else - buddyname = cleanalias; + if (name_noutf8) buddyname = name_noutf8; + } if (group) group_noutf8 = from_utf8(group); @@ -565,6 +566,18 @@ char *jid; gchar *buffer = from_utf8(body); + jid = jidtodisp(from); + + if (!buffer && body) { + scr_LogPrint(LPRINT_LOGNORM, "Decoding of message from <%s> has failed", + from); + scr_WriteIncomingMessage(jid, "Cannot display message: " + "UTF-8 conversion failure", + 0, HBB_PREFIX_ERR | HBB_PREFIX_IN); + g_free(jid); + return; + } + /* //char *u, *h, *r; //jidsplit(from, &u, &h, &r); @@ -576,7 +589,6 @@ // jidtodisp(from), type); */ - jid = jidtodisp(from); hk_message_in(jid, timestamp, buffer, type); g_free(jid); g_free(buffer);