comparison src/protocols/oscar/oscar.c @ 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 f50c059b6384
children 609a62b8e748
comparison
equal deleted inserted replaced
8232:1c6a9bc1ceea 8233:4f70e8b3e05e
378 "Unrecognized character encoding '%s', falling back to ASCII\n", encoding); 378 "Unrecognized character encoding '%s', falling back to ASCII\n", encoding);
379 return 0; 379 return 0;
380 } 380 }
381 } 381 }
382 382
383 gchar *oscar_encoding_to_utf8(const char *encoding, char *text, int textlen) 383 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen)
384 { 384 {
385 gchar *utf8 = NULL; 385 gchar *utf8 = NULL;
386 int flags = oscar_encoding_parse(encoding); 386 int flags = oscar_encoding_parse(encoding);
387 387
388 switch (flags) { 388 switch (flags) {
5446 5446
5447 buf = gaim_strdup_withhtml(message); 5447 buf = gaim_strdup_withhtml(message);
5448 len = strlen(buf); 5448 len = strlen(buf);
5449 5449
5450 encoding = oscar_encoding_check(buf); 5450 encoding = oscar_encoding_check(buf);
5451 if (encoding == AIM_IMFLAGS_UNICODE) { 5451 if (encoding & AIM_IMFLAGS_UNICODE) {
5452 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode Chat\n"); 5452 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode Chat\n");
5453 charset = "unicode-2-0"; 5453 charset = "unicode-2-0";
5454 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); 5454 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
5455 if (err) { 5455 if (err) {
5456 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 5456 gaim_debug(GAIM_DEBUG_ERROR, "oscar",
5495 if (strlen(buf) > c->maxvis) { 5495 if (strlen(buf) > c->maxvis) {
5496 g_free(buf); 5496 g_free(buf);
5497 return -E2BIG; 5497 return -E2BIG;
5498 } 5498 }
5499 5499
5500 aim_chat_send_im(od->sess, c->conn, 0, buf, len, charset); 5500 aim_chat_send_im(od->sess, c->conn, 0, buf, len, charset, "en");
5501 g_free(buf); 5501 g_free(buf);
5502 return 0; 5502 return 0;
5503 } 5503 }
5504 5504
5505 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { 5505 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) {
5876 * </BINARY> 5876 * </BINARY>
5877 */ 5877 */
5878 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { 5878 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) {
5879 GaimConnection *gc = sess->aux_data; 5879 GaimConnection *gc = sess->aux_data;
5880 GaimConvImFlags imflags = 0; 5880 GaimConvImFlags imflags = 0;
5881 gchar *utf8;
5881 GString *newmsg = g_string_new(""); 5882 GString *newmsg = g_string_new("");
5882 GSList *images = NULL; 5883 GSList *images = NULL;
5883 va_list ap; 5884 va_list ap;
5884 const char *sn, *msg, *msgend, *binary; 5885 const char *sn, *msg, *msgend, *binary;
5885 size_t len; 5886 size_t len;
5932 5933
5933 /* check the data is here and store it */ 5934 /* check the data is here and store it */
5934 if (data + (size = atoi(datasize)) <= msgend) 5935 if (data + (size = atoi(datasize)) <= msgend)
5935 imgid = gaim_imgstore_add(data, size, src); 5936 imgid = gaim_imgstore_add(data, size, src);
5936 5937
5938 /*
5939 * XXX - The code below contains some calls to oscar_encoding_to_utf8
5940 * The hardcoded "us-ascii" value REALLY needs to be removed.
5941 */
5937 /* if we have a stored image... */ 5942 /* if we have a stored image... */
5938 if (imgid) { 5943 if (imgid) {
5939 /* append the message up to the tag */ 5944 /* append the message up to the tag */
5940 newmsg = g_string_append_len(newmsg, tmp, start - tmp); 5945 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp);
5946 if (utf8 != NULL) {
5947 newmsg = g_string_append(newmsg, utf8);
5948 g_free(utf8);
5949 }
5941 5950
5942 /* write the new image tag */ 5951 /* write the new image tag */
5943 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); 5952 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid);
5944 5953
5945 /* and record the image number */ 5954 /* and record the image number */
5946 images = g_slist_append(images, GINT_TO_POINTER(imgid)); 5955 images = g_slist_append(images, GINT_TO_POINTER(imgid));
5947 } else { 5956 } else {
5948 /* otherwise, copy up to the end of the tag */ 5957 /* otherwise, copy up to the end of the tag */
5949 newmsg = g_string_append_len(newmsg, tmp, (end + 1) - tmp); 5958 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp);
5959 if (utf8 != NULL) {
5960 newmsg = g_string_append(newmsg, utf8);
5961 g_free(utf8);
5962 }
5950 } 5963 }
5951 5964
5952 /* clear the attribute list */ 5965 /* clear the attribute list */
5953 g_datalist_clear(&attribs); 5966 g_datalist_clear(&attribs);
5954 5967