Mercurial > pidgin.yaz
changeset 8233:4f70e8b3e05e
[gaim-migrate @ 8956]
Smore changes to oscar chat stuff. Shouldn't be anything noticable.
For some reason when I paste "c?mo" followed by some Japanese text
into a chat it isn't received correctly. I think there is
something weird with the conversation to UCS-2BE, but I'm not
really sure what.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 12 Feb 2004 03:07:52 +0000 |
parents | 1c6a9bc1ceea |
children | a2662eb5955b |
files | src/protocols/oscar/aim.h src/protocols/oscar/chat.c src/protocols/oscar/oscar.c src/protocols/oscar/ssi.c |
diffstat | 4 files changed, 45 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h Thu Feb 12 00:50:16 2004 +0000 +++ b/src/protocols/oscar/aim.h Thu Feb 12 03:07:52 2004 +0000 @@ -1120,7 +1120,7 @@ #define AIM_CHATFLAGS_NOREFLECT 0x0001 #define AIM_CHATFLAGS_AWAY 0x0002 -faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen, char *charset); +faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen, const char *encoding, const char *language); faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); faim_export int aim_chat_attachname(aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); faim_export char *aim_chat_getname(aim_conn_t *conn);
--- a/src/protocols/oscar/chat.c Thu Feb 12 00:50:16 2004 +0000 +++ b/src/protocols/oscar/chat.c Thu Feb 12 03:07:52 2004 +0000 @@ -320,8 +320,8 @@ * * XXX convert this to use tlvchains */ -faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen, char *charset) -{ +faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen, const char *encoding, const char *language) +{ int i; aim_frame_t *fr; aim_msgcookie_t *cookie; @@ -378,10 +378,17 @@ */ aim_tlvlist_add_raw(&itl, 0x0001, msglen, msg); - /* - * SubTLV: Type 2: Encoding - */ - aim_tlvlist_add_raw(&itl, 0x0002, strlen(charset), charset); + /* + * SubTLV: Type 2: Encoding + */ + if (encoding != NULL) + aim_tlvlist_add_raw(&itl, 0x0002, strlen(encoding), encoding); + + /* + * SubTLV: Type 3: Language + */ + if (language != NULL) + aim_tlvlist_add_raw(&itl, 0x0003, strlen(language), language); /* * Type 5: Message block. Contains more TLVs. @@ -437,7 +444,7 @@ aim_tlvlist_t *otl; char *msg = NULL; int len; - char *charset = NULL; + char *encoding = NULL, *language = NULL; aim_msgcookie_t *ck; memset(&userinfo, 0, sizeof(aim_userinfo_t)); @@ -511,17 +518,23 @@ len = aim_tlv_gettlv(itl, 0x0001, 1)->length; } - /* - * Type 0x0002: Charset. + /* + * Type 0x0002: Encoding. */ if (aim_tlv_gettlv(itl, 0x0002, 1)) - charset = aim_tlv_getstr(itl, 0x0002, 1); + encoding = aim_tlv_getstr(itl, 0x0002, 1); + + /* + * Type 0x0003: Language. + */ + if (aim_tlv_gettlv(itl, 0x0003, 1)) + language = aim_tlv_getstr(itl, 0x0003, 1); aim_tlvlist_free(&itl); } if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - ret = userfunc(sess, rx, &userinfo, len, msg, charset); + ret = userfunc(sess, rx, &userinfo, len, msg, encoding, language); aim_info_free(&userinfo); free(msg);
--- a/src/protocols/oscar/oscar.c Thu Feb 12 00:50:16 2004 +0000 +++ b/src/protocols/oscar/oscar.c Thu Feb 12 03:07:52 2004 +0000 @@ -380,7 +380,7 @@ } } -gchar *oscar_encoding_to_utf8(const char *encoding, char *text, int textlen) +gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) { gchar *utf8 = NULL; int flags = oscar_encoding_parse(encoding); @@ -5448,7 +5448,7 @@ len = strlen(buf); encoding = oscar_encoding_check(buf); - if (encoding == AIM_IMFLAGS_UNICODE) { + if (encoding & AIM_IMFLAGS_UNICODE) { gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode Chat\n"); charset = "unicode-2-0"; buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); @@ -5497,7 +5497,7 @@ return -E2BIG; } - aim_chat_send_im(od->sess, c->conn, 0, buf, len, charset); + aim_chat_send_im(od->sess, c->conn, 0, buf, len, charset, "en"); g_free(buf); return 0; } @@ -5878,6 +5878,7 @@ static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { GaimConnection *gc = sess->aux_data; GaimConvImFlags imflags = 0; + gchar *utf8; GString *newmsg = g_string_new(""); GSList *images = NULL; va_list ap; @@ -5934,10 +5935,18 @@ if (data + (size = atoi(datasize)) <= msgend) imgid = gaim_imgstore_add(data, size, src); + /* + * XXX - The code below contains some calls to oscar_encoding_to_utf8 + * The hardcoded "us-ascii" value REALLY needs to be removed. + */ /* if we have a stored image... */ if (imgid) { /* append the message up to the tag */ - newmsg = g_string_append_len(newmsg, tmp, start - tmp); + utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); + if (utf8 != NULL) { + newmsg = g_string_append(newmsg, utf8); + g_free(utf8); + } /* write the new image tag */ g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); @@ -5946,7 +5955,11 @@ images = g_slist_append(images, GINT_TO_POINTER(imgid)); } else { /* otherwise, copy up to the end of the tag */ - newmsg = g_string_append_len(newmsg, tmp, (end + 1) - tmp); + utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); + if (utf8 != NULL) { + newmsg = g_string_append(newmsg, utf8); + g_free(utf8); + } } /* clear the attribute list */
--- a/src/protocols/oscar/ssi.c Thu Feb 12 00:50:16 2004 +0000 +++ b/src/protocols/oscar/ssi.c Thu Feb 12 03:07:52 2004 +0000 @@ -1091,7 +1091,8 @@ } /** - * Stores your setting for whether you should show up as idle or not. + * Stores your setting for various SSI settings. Whether you + * should show up as idle or not, etc. * * @param sess The oscar session. * @param presence I think it's a bitmask, but I only know what one of the bits is: