pidgin: efa9e9f4: Plucked d2a1d52b3bbf29baa53b9ddaa635d50b...
evands at pidgin.im
evands at pidgin.im
Sun Nov 22 13:56:29 EST 2009
-----------------------------------------------------------------
Revision: efa9e9f485d998244d637d1ff62dbb333ef8abd4
Ancestor: 0462ae6a305d43cfeacb4f4f442633f6a6fdf0cb
Author: evands at pidgin.im
Date: 2009-11-22T18:56:06
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/efa9e9f485d998244d637d1ff62dbb333ef8abd4
Modified files:
libpurple/protocols/oscar/odc.c
libpurple/protocols/oscar/oscar.c
ChangeLog:
Plucked d2a1d52b3bbf29baa53b9ddaa635d50b6332064f from im.pidgin.adium
by Zac West:
Fixed sending DIM messages' encoding. Fixes #9087.
The encoding bytes were being written in the wrong location, so the messages
were being read back as ASCII and failing conversion, ending up being empty
and not being displayed.
Plucked f5376d42261b8efc3d889314df9896bb10d3fe16 from im.pidgin.adium:
iChat sends direct IM messages with its encoding as 0x000d, which was being
forced-interpreted as ASCII. Also, added better debug logging for charset
information being received.
applied changes from 212bd3655451599364562cabe553c5b7a19134ae
through d2a1d52b3bbf29baa53b9ddaa635d50b6332064f
applied changes from d2a1d52b3bbf29baa53b9ddaa635d50b6332064f
through f5376d42261b8efc3d889314df9896bb10d3fe16
-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/odc.c 246f66c33d1a709c1dd5efd1c16b8d80aaa858ba
+++ libpurple/protocols/oscar/odc.c 19fbe86624736cfb6024181ae455a938fd746c2a
@@ -110,8 +110,8 @@ peer_odc_send(PeerConnection *conn, OdcF
byte_stream_put16(&bs, 0x0000);
byte_stream_put16(&bs, 0x0000);
byte_stream_put32(&bs, frame->payload.len);
- byte_stream_put16(&bs, 0x0000);
byte_stream_put16(&bs, frame->encoding);
+ byte_stream_put16(&bs, 0x0000);
byte_stream_put16(&bs, 0x0000);
byte_stream_put16(&bs, frame->flags);
byte_stream_put16(&bs, 0x0000);
============================================================
--- libpurple/protocols/oscar/oscar.c f41ef1f0f7cd829184d74dd5cf3232bfda3867a1
+++ libpurple/protocols/oscar/oscar.c b49b57bc7e89a7fa5e1fbe14d89db22f448feb83
@@ -438,10 +438,8 @@ purple_plugin_oscar_decode_im_part(Purpl
purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcebn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen)
{
gchar *ret = NULL;
- const gchar *charsetstr1, *charsetstr2;
+ const gchar *charsetstr1, *charsetstr2, *charsetstr3 = NULL;
- purple_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%" G_GSIZE_FORMAT "\n", charset, charsubset, datalen);
-
if ((datalen == 0) || (data == NULL))
return NULL;
@@ -459,19 +457,33 @@ purple_plugin_oscar_decode_im_part(Purpl
charsetstr1 = "ASCII";
charsetstr2 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
} else if (charset == 0x000d) {
- /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */
- charsetstr1 = "ISO-8859-1";
- charsetstr2 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
+ /* iChat sending unicode over a Direct IM connection = Unicode */
+ /* Mobile AIM client on a Nokia 3100 and an LG VX6000 = ISO-8859-1 */
+ charsetstr1 = "UTF-16BE";
+ charsetstr2 = "UTF-8";
+ charsetstr3 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
} else {
/* Unknown, hope for valid UTF-8... */
charsetstr1 = "UTF-8";
charsetstr2 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
}
+
+ purple_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%" G_GSIZE_FORMAT ", choice1=%s, choice2=%s, choise3=%s\n",
+ charset, charsubset, datalen, charsetstr1, charsetstr2, (charsetstr3 ? charsetstr3 : ""));
ret = purple_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE);
- if (ret == NULL)
- ret = purple_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE);
if (ret == NULL) {
+ if (charsetstr3 != NULL) {
+ /* Try charsetstr2 without allowing substitutions, then fall through to charsetstr3 if needed */
+ ret = purple_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, FALSE);
+ if (ret == NULL)
+ ret = purple_plugin_oscar_convert_to_utf8(data, datalen, charsetstr3, TRUE);
+ } else {
+ /* Try charsetstr2, allowing substitutions */
+ ret = purple_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE);
+ }
+ }
+ if (ret == NULL) {
char *str, *salvage, *tmp;
str = g_malloc(datalen + 1);
@@ -575,6 +587,9 @@ purple_plugin_oscar_convert_to_best_enco
*/
*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, &err);
if (*msg != NULL) {
+ purple_debug_info("oscar", "Conversion from UTF-8 to UTF-16BE results in %s.\n",
+ *msg);
+
*charset = AIM_CHARSET_UNICODE;
*charsubset = 0x0000;
*msglen_int = msglen;
@@ -4552,6 +4567,8 @@ purple_odc_send_im(PeerConnection *conn,
}
g_string_free(data, TRUE);
+ purple_debug_info("oscar", "sending direct IM %s using charset %i", msg->str, charset);
+
peer_odc_send_im(conn, msg->str, msg->len, charset,
imflags & PURPLE_MESSAGE_AUTO_RESP);
g_string_free(msg, TRUE);
More information about the Commits
mailing list