diff -ruN gaim-1.5.0.org/src/gtkconv.c gaim-1.5.0/src/gtkconv.c --- gaim-1.5.0.org/src/gtkconv.c 2005-07-22 16:12:01.000000000 +0900 +++ gaim-1.5.0/src/gtkconv.c 2005-08-13 18:08:50.000000000 +0900 @@ -110,6 +110,10 @@ #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) +/* yaz. If you want to use shortcut keys that may conflict with + inputmethods, change this to 1. */ +#define ENABLE_SHORTCUT 0 + typedef struct { GtkWidget *window; @@ -2537,7 +2541,8 @@ gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), MAX(gdk_pixbuf_get_height(buf) * scale_height / gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), - GDK_INTERP_NEAREST); + GDK_INTERP_BILINEAR); +// GDK_INTERP_NEAREST); gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); g_object_unref(G_OBJECT(scale)); @@ -3216,7 +3221,11 @@ } /* Build the Send As menu */ +#if ENABLE_SHORTCUT gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); +#else + gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("Send As")); +#endif gtk_widget_show(gtkwin->menu.send_as); menu = gtk_menu_new(); @@ -3676,21 +3685,33 @@ 0, "", GAIM_STOCK_IM }, { "/Conversation/sep0", NULL, NULL, 0, "" }, - +#if ENABLE_SHORTCUT { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, "", GTK_STOCK_FIND }, +#else + { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, + "", NULL }, +#endif { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, "", GTK_STOCK_SAVE_AS }, +#if ENABLE_SHORTCUT { N_("/Conversation/Clear"), "L", menu_clear_cb, 0, "", GTK_STOCK_CLEAR }, - +#else + { N_("/Conversation/Clear"), NULL, menu_clear_cb, 0, "", GTK_STOCK_CLEAR }, +#endif { "/Conversation/sep1", NULL, NULL, 0, "" }, { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "", GAIM_STOCK_FILE_TRANSFER }, { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, 0, NULL }, +#if ENABLE_SHORTCUT { N_("/Conversation/_Get Info"), "O", menu_get_info_cb, 0, "", GAIM_STOCK_INFO }, +#else + { N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0, + "", GAIM_STOCK_INFO }, +#endif { N_("/Conversation/_Warn..."), NULL, menu_warn_cb, 0, "", GAIM_STOCK_WARN }, { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, @@ -5914,7 +5935,8 @@ gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), MAX(gdk_pixbuf_get_height(buf) * scale_height / gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), - GDK_INTERP_NEAREST); + GDK_INTERP_BILINEAR); +// GDK_INTERP_NEAREST); gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); g_object_unref(G_OBJECT(scale)); diff -ruN gaim-1.5.0.org/src/gtkdialogs.h gaim-1.5.0/src/gtkdialogs.h --- gaim-1.5.0.org/src/gtkdialogs.h 2004-08-20 14:11:30.000000000 +0900 +++ gaim-1.5.0/src/gtkdialogs.h 2005-08-13 18:08:51.000000000 +0900 @@ -59,8 +59,8 @@ gtk_window_set_type_hint(GTK_WINDOW(x), GDK_WINDOW_TYPE_HINT_DIALOG) #define GAIM_WINDOW_ICONIFIED(x) (gdk_window_get_state(GTK_WIDGET(x)->window) & GDK_WINDOW_STATE_ICONIFIED) -#define DEFAULT_FONT_FACE "Helvetica" - +//#define DEFAULT_FONT_FACE "Helvetica" +#define DEFAULT_FONT_FACE "Sans" /* this is used for queuing messages received while away. This is really a UI function * which is why the struct is here. */ diff -ruN gaim-1.5.0.org/src/gtkimhtml.c gaim-1.5.0/src/gtkimhtml.c --- gaim-1.5.0.org/src/gtkimhtml.c 2005-07-08 06:03:13.000000000 +0900 +++ gaim-1.5.0/src/gtkimhtml.c 2005-08-13 18:08:51.000000000 +0900 @@ -79,6 +79,10 @@ gint y, guint time); +/* yaz. If you want to use shortcut keys that may conflict with + inputmethods, change this to 1. */ +#define ENABLE_SHORTCUT 0 + static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); @@ -607,7 +611,8 @@ return TRUE; break; #endif /* !(Gtk+ >= 2.2.0) */ - +#if ENABLE_SHORTCUT + case 'b': /* ctrl-b is GDK_Left, which moves backwards. */ case 'B': if (imhtml->format_functions & GTK_IMHTML_BOLD) { @@ -629,7 +634,7 @@ } return FALSE; break; - + case 'u': /* ctrl-u is GDK_Clear, which clears the line. */ case 'U': if (imhtml->format_functions & GTK_IMHTML_UNDERLINE) { @@ -640,7 +645,7 @@ } return FALSE; break; - +#endif case '-': if (imhtml->format_functions & GTK_IMHTML_SHRINK) gtk_imhtml_font_shrink(imhtml); diff -ruN gaim-1.5.0.org/src/gtkimhtmltoolbar.h gaim-1.5.0/src/gtkimhtmltoolbar.h --- gaim-1.5.0.org/src/gtkimhtmltoolbar.h 2005-04-07 09:47:37.000000000 +0900 +++ gaim-1.5.0/src/gtkimhtmltoolbar.h 2005-08-13 18:08:51.000000000 +0900 @@ -30,7 +30,8 @@ extern "C" { #endif -#define GTK_IMHTMLTOOLBAR_DEFAULT_FONT_FACE "Helvetica 12" +//#define GTK_IMHTMLTOOLBAR_DEFAULT_FONT_FACE "Helvetica 12" +#define GTK_IMHTMLTOOLBAR_DEFAULT_FONT_FACE "Sans 12" #define GTK_TYPE_IMHTMLTOOLBAR (gtk_imhtmltoolbar_get_type ()) #define GTK_IMHTMLTOOLBAR(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_IMHTMLTOOLBAR, GtkIMHtmlToolbar)) diff -ruN gaim-1.5.0.org/src/protocols/irc/irc.c gaim-1.5.0/src/protocols/irc/irc.c --- gaim-1.5.0.org/src/protocols/irc/irc.c 2005-07-25 04:27:36.000000000 +0900 +++ gaim-1.5.0/src/protocols/irc/irc.c 2005-08-13 18:08:53.000000000 +0900 @@ -725,6 +725,12 @@ option = gaim_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + option = gaim_account_option_bool_new(_("Use SO/SI to send hankaku kana"), "irc_use_sosi", FALSE); + prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + + option = gaim_account_option_bool_new(_("Use 8bit to send hankaku kana"), "irc_use_8bit", FALSE); + prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + option = gaim_account_option_string_new(_("Username"), "username", ""); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); diff -ruN gaim-1.5.0.org/src/protocols/irc/parse.c gaim-1.5.0/src/protocols/irc/parse.c --- gaim-1.5.0.org/src/protocols/irc/parse.c 2005-07-21 12:51:20.000000000 +0900 +++ gaim-1.5.0/src/protocols/irc/parse.c 2005-08-13 18:55:13.000000000 +0900 @@ -35,7 +35,7 @@ #include static char *irc_send_convert(struct irc_conn *irc, const char *string); -static char *irc_recv_convert(struct irc_conn *irc, const char *string); +static char *irc_recv_convert(struct irc_conn *irc, char *string); static void irc_parse_error_cb(struct irc_conn *irc, char *input); @@ -141,6 +141,20 @@ { NULL, NULL, NULL } }; +/* yaz */ +#define ASCII 0 +#define KANJI 1 +#define KANA 2 +#define ROMAN 3 +char seq_ascii[] = {0x1B,0x28,0x42,0x00}; /* ESC ( B */ +char seq_kanji[] = {0x1B,0x24,0x42,0x00}; /* ESC $ B */ +char seq_kana[] = {0x1B,0x28,0x49,0x00}; /* ESC ( I */ +char seq_roman[] = {0x1B,0x28,0x4A,0x00}; /* ESC ( J */ +char *seq[4] = {seq_ascii, seq_kanji, seq_kana, seq_roman}; +char *jisstate[5] = {"ASCII", "KANJI", "KANA", "ROMAN"}; +char SO[] = {0x0E,0x00}; +char SI[] = {0x0F,0x00}; + static GaimCmdRet irc_parse_gaim_cmd(GaimConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) { @@ -208,10 +222,18 @@ GError *err = NULL; gchar **encodings; const gchar *enclist; + char *escpos = NULL; + char *temp = NULL; + gboolean iskana = FALSE; + char *pos = NULL; + gboolean irc_use_sosi, irc_use_8bit; enclist = gaim_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET); encodings = g_strsplit(enclist, ",", 2); + irc_use_sosi = gaim_account_get_bool(irc->account, "irc_use_sosi", FALSE); + irc_use_8bit = gaim_account_get_bool(irc->account, "irc_use_8bit", FALSE); + if (encodings[0] == NULL || !strcasecmp("UTF-8", encodings[0])) { g_strfreev(encodings); return g_strdup(string); @@ -224,17 +246,79 @@ utf8 = g_strdup(string); g_error_free(err); } - g_strfreev(encodings); + /* yaz */ + if (!strncasecmp("iso-2022-jp", encodings[0], strlen("iso-2022-jp"))) { + escpos = strrchr(utf8, 0x1B); + if(escpos && (!strncmp(seq_kanji, escpos, 3) || !strncmp(seq_kana, escpos, 3))){ + char *oldutf8 = utf8; + utf8 = g_realloc(utf8, strlen(utf8)+1+3); + if(utf8) + strncat(utf8, seq_ascii, 3); + else + utf8 = oldutf8; + } + + if(irc_use_sosi || irc_use_8bit){ + /* SO/SI */ + //find kana escape and replace with roman+SO + temp = g_malloc0(strlen(utf8) * 7); //XXX should be reasonable size + pos = utf8; + while(pos < utf8+strlen(utf8)){ + escpos = strchr(pos, 0x1B); + if(escpos){ + if(!strncmp(seq_kana, escpos, 3)){ /* kana found */ + iskana = TRUE; + strncat(temp, pos, escpos-pos); + strcat(temp, seq_roman); + if(irc_use_sosi) + strcat(temp, SO); + pos = escpos+3; + } else { + if(iskana){ + char *ptr; + ptr = temp + strlen(temp); + while(posaccount, "encoding", IRC_DEFAULT_CHARSET); encodings = g_strsplit(enclist, ",", -1); @@ -252,11 +336,119 @@ if (!strcasecmp("UTF-8", charset)) { if (g_utf8_validate(string, strlen(string), NULL)) utf8 = g_strdup(string); + } else if (!strncasecmp("iso-2022-jp-2", charset, strlen("iso-2022-jp-2"))){ + /* pre-process quirky jis */ + unsigned char *jisstr; + unsigned char *ptr, *ptr2; + int state = ASCII; + int is8bit = FALSE; + + jisstr = (unsigned char *)calloc(1, strlen(string)*7); /* enough? */ + ptr = (unsigned char *)string; ptr2 = jisstr; + + while(*ptr){ + if(*ptr == 0x1B){ + /* escape sequence. */ + if(*(ptr+1) == 0x28 && *(ptr+2) == 0x42){ + state = ASCII; + + } else if(*(ptr+1) == 0x24 && *(ptr+2) == 0x42){ + state = KANJI; + + } else if(*(ptr+1) == 0x28 && *(ptr+2) == 0x49){ + state = KANA; + + } else if(*(ptr+1) == 0x28 && *(ptr+2) == 0x4a){ + state = ROMAN; + + } + gaim_debug(GAIM_DEBUG_INFO, "irc", "state %s\n", jisstate[state]); + } + if(*ptr >= 0xA1 && *ptr <= 0xDF){ + /* raw 8bit */ + if(!is8bit){ + strcat(jisstr, seq[KANA]); + ptr2 += 3; + is8bit = TRUE; + gaim_debug(GAIM_DEBUG_INFO, "irc", "8bit = TRUE\n"); + } + *ptr2 = *ptr - 0x80; + ptr++ ; ptr2++; + } else { + /* 7bit */ + if(*ptr == 0x0E){ + /* SO */ + strcat(jisstr, seq[KANA]); + ptr++; ptr2 += 3; + gaim_debug(GAIM_DEBUG_INFO, "irc", "SO\n"); + continue; + } else if(*ptr == 0x0F){ + /* SI */ + strcat(jisstr, seq[state]); + gaim_debug(GAIM_DEBUG_INFO, "irc", "SI to %s\n", jisstate[state]); + ptr++; ptr2 += 3; + gaim_debug(GAIM_DEBUG_INFO, "irc", "SI\n"); + continue; + } + if(is8bit){ /* the edge of 8bit -> 7bit */ + gaim_debug(GAIM_DEBUG_INFO, "irc", "8bit to %s\n", jisstate[state]); + strcat(jisstr, seq[state]); + ptr2 += 3; + is8bit=FALSE; + gaim_debug(GAIM_DEBUG_INFO, "irc", "8bit = FALSE\n"); + } + /* copy str */ + *ptr2 = *ptr; + ptr++; ptr2++; + } + } + + /* convert & error recovery */ + do { + err = NULL; + retry = FALSE; + + conv_len = strlen(jisstr); + utf8 = g_convert_with_fallback(jisstr, conv_len, "UTF-8", charset, + "?", &in_len, &out_len, &err); + if(err != NULL){ + if(err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE){ + memmove(jisstr + in_len, jisstr + in_len + 1, + conv_len - in_len -1); + conv_len--; + *(jisstr + conv_len) = '\0'; + retry = TRUE; + } + g_error_free(err); + } + } while(retry); + + if(jisstr) + free(jisstr); + } else { - utf8 = g_convert(string, strlen(string), "UTF-8", charset, NULL, NULL, NULL); + do { + err = NULL; + retry = FALSE; + + conv_len = strlen(string); + utf8 = g_convert_with_fallback(string, conv_len, "UTF-8", charset, + "?", &in_len, &out_len, &err); + if(err != NULL){ + if(err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE){ + memmove(string + in_len, string + in_len + 1, + conv_len - in_len -1); + conv_len--; + *(string + conv_len) = '\0'; + retry = TRUE; + } + g_error_free(err); + } + } while(retry); } - if (utf8) { + + if(utf8){ g_strfreev(encodings); return utf8; } diff -ruN gaim-1.5.0.org/src/protocols/msn/msg.c gaim-1.5.0/src/protocols/msn/msg.c --- gaim-1.5.0.org/src/protocols/msn/msg.c 2005-08-12 04:25:27.000000000 +0900 +++ gaim-1.5.0/src/protocols/msn/msg.c 2005-08-13 18:08:57.000000000 +0900 @@ -514,9 +514,7 @@ if (data != NULL && len > 0) { - msg->body = g_malloc0(len + 1); - memcpy(msg->body, data, len); - msg->body_len = len; + msg->body = botch_utf((void *)data, len, &msg->body_len); /* yaz */ } else { diff -ruN gaim-1.5.0.org/src/protocols/msn/switchboard.c gaim-1.5.0/src/protocols/msn/switchboard.c --- gaim-1.5.0.org/src/protocols/msn/switchboard.c 2005-04-11 01:48:53.000000000 +0900 +++ gaim-1.5.0/src/protocols/msn/switchboard.c 2005-08-13 18:08:58.000000000 +0900 @@ -857,7 +857,7 @@ char *body_str; char *body_enc; char *body_final; - size_t body_len; + size_t body_len, newlen; const char *passport; const char *value; @@ -865,7 +865,7 @@ swboard = cmdproc->data; body = msn_message_get_bin_data(msg, &body_len); - body_str = g_strndup(body, body_len); + body_str = sanitize_utf(body, body_len, &newlen); body_enc = gaim_escape_html(body_str); g_free(body_str); diff -ruN gaim-1.5.0.org/src/protocols/oscar/im.c gaim-1.5.0/src/protocols/oscar/im.c --- gaim-1.5.0.org/src/protocols/oscar/im.c 2005-06-14 09:24:28.000000000 +0900 +++ gaim-1.5.0/src/protocols/oscar/im.c 2005-08-13 18:08:59.000000000 +0900 @@ -33,6 +33,8 @@ #include "win32dep.h" #endif +#include "debug.h" + /** * Add a standard ICBM header to the given bstream with the given * information. @@ -432,6 +434,10 @@ fu8_t *hdr; int hdrlen; aim_bstream_t hdrbs; + // yaz + char *ucs = NULL; + int bytes; + if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) return -EINVAL; @@ -477,17 +483,43 @@ * raw data, followed by a series of TLVs. * */ - hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2; - hdr = malloc(hdrlen); - aim_bstream_init(&hdrbs, hdr, hdrlen); - aimbs_put16(&hdrbs, 0x0000); /* Unknown! */ - aimbs_putraw(&hdrbs, ck, sizeof(ck)); /* I think... */ - aim_putcap(&hdrbs, AIM_CAPS_CHAT); + //yaz + // convert msg to ascii7 first. if it succeed, send as plain ascii. + // if it fails, convert msg into ucs-2be, and send it. + ucs = g_convert(msg, strlen(msg), "ASCII", "UTF-8", NULL, &bytes, NULL); + if(ucs){ + hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2; + hdr = malloc(hdrlen); + aim_bstream_init(&hdrbs, hdr, hdrlen); + + aimbs_put16(&hdrbs, 0x0000); /* Unknown! */ + aimbs_putraw(&hdrbs, ck, sizeof(ck)); /* I think... */ + aim_putcap(&hdrbs, AIM_CAPS_CHAT); + + aim_tlvlist_add_16(&itl, 0x000a, 0x0001); + aim_tlvlist_add_noval(&itl, 0x000f); + aim_tlvlist_add_raw(&itl, 0x000c, strlen(msg), msg); + free(ucs); + } else { + hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2+4+11; + hdr = malloc(hdrlen); + aim_bstream_init(&hdrbs, hdr, hdrlen); + + aimbs_put16(&hdrbs, 0x0000); /* Unknown! */ + aimbs_putraw(&hdrbs, ck, sizeof(ck)); /* I think... */ + aim_putcap(&hdrbs, AIM_CAPS_CHAT); + + aim_tlvlist_add_16(&itl, 0x000a, 0x0001); + aim_tlvlist_add_raw(&itl, 0x000d, 11, "unicode-2-0"); + aim_tlvlist_add_noval(&itl, 0x000f); + //yaz + ucs = g_convert(msg, strlen(msg), "UCS-2BE", "UTF-8", NULL, &bytes, NULL); + botch_ucs(ucs, bytes); + aim_tlvlist_add_raw(&itl, 0x000c, bytes, ucs); + free(ucs); + } - aim_tlvlist_add_16(&itl, 0x000a, 0x0001); - aim_tlvlist_add_noval(&itl, 0x000f); - aim_tlvlist_add_raw(&itl, 0x000c, strlen(msg), msg); aim_tlvlist_add_chatroom(&itl, 0x2711, exchange, roomname, instance); aim_tlvlist_write(&hdrbs, &itl); diff -ruN gaim-1.5.0.org/src/protocols/oscar/oscar.c gaim-1.5.0/src/protocols/oscar/oscar.c --- gaim-1.5.0.org/src/protocols/oscar/oscar.c 2005-08-12 09:57:27.000000000 +0900 +++ gaim-1.5.0/src/protocols/oscar/oscar.c 2005-08-13 18:09:01.000000000 +0900 @@ -362,7 +362,9 @@ /* Make sure encoding begins with charset= */ if (strncmp(encoding, "text/aolrtf; charset=", 21) && - strncmp(encoding, "text/x-aolrtf; charset=", 23)) + strncmp(encoding, "text/x-aolrtf; charset=", 23) && + strncmp(encoding, "text/plain; charset=", 20)) /* for iChat */ + { return NULL; } @@ -390,6 +392,7 @@ } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); } else if (!strcasecmp(encoding, "unicode-2-0")) { + sanitize_ucs(text, textlen); utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " @@ -529,6 +532,7 @@ if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) { *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, NULL); + botch_ucs(*msg, *msglen); /* yaz */ if (*msg != NULL) { *charset = AIM_CHARSET_UNICODE; @@ -557,6 +561,7 @@ * Nothing else worked, so send as UCS-2BE. */ *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, &err); + botch_ucs(*msg, *msglen); /* yaz */ if (*msg != NULL) { *charset = AIM_CHARSET_UNICODE; *charsubset = 0x0000; @@ -1193,24 +1198,35 @@ GaimConnection *gc = sess->aux_data; GaimConvImFlags imflags = 0; gchar *utf8; + gchar *yazutf8 = NULL; GString *newmsg = g_string_new(""); GSList *images = NULL; va_list ap; - const char *sn, *msg, *msgend, *binary; + const char *sn, *tmpmsg, *msg, *msgend, *binary; size_t len; int encoding, isawaymsg; va_start(ap, fr); sn = va_arg(ap, const char *); - msg = va_arg(ap, const char *); + tmpmsg = va_arg(ap, const char *); len = va_arg(ap, size_t); encoding = va_arg(ap, int); isawaymsg = va_arg(ap, int); va_end(ap); - msgend = msg + len; + msgend = tmpmsg + len; + /* yaz debug */ gaim_debug_info("oscar", - "Got DirectIM message from %s\n", sn); + "Got DirectIM message from %s encoding %d\n", sn, encoding); + + /* yaz convert to utf-8 first. */ + if(encoding == AIM_CHARSET_UNICODE){ + yazutf8 = g_convert(tmpmsg, len, "UTF-8", "UCS-2BE", NULL, &len, NULL); + msg = yazutf8; + msgend = msg +len; + } else { + msg = tmpmsg; + } if (isawaymsg) imflags |= GAIM_CONV_IM_AUTO_RESP; @@ -1259,7 +1275,7 @@ /* if we have a stored image... */ if (imgid) { /* append the message up to the tag */ - utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); + utf8 = oscar_encoding_to_utf8("UTF-8", tmp, start - tmp); if (utf8 != NULL) { newmsg = g_string_append(newmsg, utf8); g_free(utf8); @@ -1272,7 +1288,7 @@ images = g_slist_append(images, GINT_TO_POINTER(imgid)); } else { /* otherwise, copy up to the end of the tag */ - utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); + utf8 = oscar_encoding_to_utf8("UTF-8", tmp, (end + 1) - tmp); if (utf8 != NULL) { newmsg = g_string_append(newmsg, utf8); g_free(utf8); @@ -1294,6 +1310,7 @@ if (images) imflags |= GAIM_CONV_IM_IMAGES; } else { + gaim_debug_info("oscar", "DirectIM %s\n",msg); /* yaz: for debug */ g_string_append_len(newmsg, msg, len); } @@ -1315,6 +1332,8 @@ g_slist_free(images); } + if(yazutf8 != NULL) + g_free(yazutf8); /* yaz */ return 1; } @@ -1351,6 +1370,9 @@ GData *attribs; const char *start, *end, *last; int oscar_id = 0; + GString *ucsmsg = g_string_new(""); + size_t ucslen; + char *ucs; last = message; @@ -1384,11 +1406,32 @@ "", oscar_id, size); + /* yaz: convert msg so far here */ + ucs = g_convert(msg->str, msg->len, "UCS-2BE", "UTF-8", NULL, &ucslen, NULL); + ucsmsg = g_string_append_len(ucsmsg, ucs, ucslen); + g_free(ucs); + /* ... and append the data to the binary section ... */ g_string_append_printf(data, "", oscar_id, size); - data = g_string_append_len(data, imgdata, size); - data = g_string_append(data, ""); + /* yaz: append data header */ + ucs = g_convert(data->str, data->len, "UCS-2BE", "UTF-8", NULL, &ucslen, NULL); + ucsmsg = g_string_append_len(ucsmsg, ucs, ucslen); + g_free(ucs); + + /* yaz: append imgdata */ + ucsmsg = g_string_append_len(ucsmsg, imgdata, size); + + ucs = g_convert("", strlen(""), "UCS-2BE", "UTF-8", + NULL, &ucslen, NULL); + ucsmsg = g_string_append_len(ucsmsg, ucs, ucslen); + g_free(ucs); + } else { + /* yaz: if no image */ + ucs = g_convert(msg->str, msg->len, "UCS-2BE", "UTF-8", NULL, &ucslen, NULL); + botch_ucs(ucs, ucslen); + ucsmsg = g_string_append_len(ucsmsg, ucs, ucslen); + g_free(ucs); } /* If the tag is invalid, skip it, thus no else here */ @@ -1399,26 +1442,33 @@ } /* append any remaining message data (without the > :-) */ - if (last && *last) - msg = g_string_append(msg, last); + if (last && *last){ + ucs = g_convert(last, strlen(last), "UCS-2BE", "UTF-8", NULL, &ucslen, NULL); + botch_ucs(ucs, ucslen); /* yaz */ + ucsmsg = g_string_append_len(ucsmsg, ucs, ucslen); + g_free(ucs); + } /* if we inserted any images in the binary section, append it */ if (oscar_id) { - msg = g_string_append_len(msg, data->str, data->len); - msg = g_string_append(msg, ""); + ucs = g_convert("", strlen(""), "UCS-2BE", "UTF-8", NULL, + &ucslen, NULL); + botch_ucs(ucs, ucslen); + ucsmsg = g_string_append_len(ucsmsg, ucs, ucslen); + g_free(ucs); } - len = msg->len; - buf = msg->str; + len = ucsmsg->len; + buf = ucsmsg->str; g_string_free(msg, FALSE); + g_string_free(ucsmsg, FALSE); g_string_free(data, TRUE); - /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ if (imflags & GAIM_CONV_IM_AUTO_RESP) - ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); + ret = aim_odc_send_im(sess, conn, buf, len, 2, 1); else - ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); + ret = aim_odc_send_im(sess, conn, buf, len, 2, 0); g_free(buf); @@ -5702,8 +5752,9 @@ text_html = gaim_strdup_withhtml(text); charset = oscar_charset_check(text_html); if (charset == AIM_CHARSET_UNICODE) { - msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); - aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); + /* yaz */ + msg = g_convert(text_html, strlen(text_html), "UTF-8", "UTF-8", NULL, &msglen, NULL); + aim_locate_setprofile(od->sess, "utf-8", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); g_free(msg); } else if (charset == AIM_CHARSET_CUSTOM) { msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); @@ -5775,8 +5826,9 @@ text_html = gaim_strdup_withhtml(text); charset = oscar_charset_check(text_html); if (charset == AIM_CHARSET_UNICODE) { - msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); - aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, + /* yaz */ + msg = g_convert(text_html, strlen(text_html), "UTF-8", "UTF-8", NULL, &msglen, NULL); + aim_locate_setprofile(od->sess, NULL, NULL, 0, "utf-8", msg, (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); g_free(msg); gc->away = g_strndup(text, od->rights.maxawaymsglen/2); @@ -6696,7 +6748,7 @@ charsetstr = "unicode-2-0"; else if (charset == AIM_CHARSET_CUSTOM) charsetstr = "iso-8859-1"; - aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); + aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "JA"); g_free(buf2); return 0; diff -ruN gaim-1.5.0.org/src/protocols/yahoo/util.c gaim-1.5.0/src/protocols/yahoo/util.c --- gaim-1.5.0.org/src/protocols/yahoo/util.c 2005-05-05 22:08:38.000000000 +0900 +++ gaim-1.5.0/src/protocols/yahoo/util.c 2005-08-13 21:13:25.000000000 +0900 @@ -27,6 +27,7 @@ #include "prpl.h" #include "debug.h" #include "yahoo.h" +#include "util.h" #include @@ -45,7 +46,8 @@ char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8) { struct yahoo_data *yd = gc->proto_data; - char *ret; + char *ret, *strtmp; + int newlen; const char *to_codeset; if (yd->jp && utf8 && *utf8) @@ -59,7 +61,11 @@ else to_codeset = "ISO-8859-1"; - ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL); + strtmp = sanitize_utf((char *)str, strlen((char *)str), &newlen); + + ret = g_convert_with_fallback(strtmp, strlen(strtmp), to_codeset, "UTF-8", "?", NULL, NULL, NULL); + + g_free(strtmp); if (ret) return ret; else @@ -77,8 +83,9 @@ char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8) { struct yahoo_data *yd = gc->proto_data; - char *ret; + char *ret, *tmp; char *from_codeset; + int newlen; if (utf8) { if (g_utf8_validate(str, -1, NULL)) @@ -90,10 +97,22 @@ else from_codeset = "ISO-8859-1"; - ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL); + /* yaz: it's a kind of voodoo to avoid malconversion of "~". */ + tmp = g_convert(str, strlen(str), "EUC-JP", from_codeset, NULL, NULL, NULL); + if(tmp) { + ret = g_convert(tmp, strlen(tmp), "UTF-8", "EUC-JP", NULL, NULL, NULL); + g_free(tmp); + } else { + ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL); + } - if (ret) + + if (ret){ + tmp = ret; + ret = botch_utf(ret, strlen(ret), &newlen); + g_free(tmp); return ret; + } else return g_strdup(""); } diff -ruN gaim-1.5.0.org/src/protocols/yahoo/yahoo.c gaim-1.5.0/src/protocols/yahoo/yahoo.c --- gaim-1.5.0.org/src/protocols/yahoo/yahoo.c 2005-08-04 09:57:44.000000000 +0900 +++ gaim-1.5.0/src/protocols/yahoo/yahoo.c 2005-08-13 18:09:01.000000000 +0900 @@ -3686,10 +3686,10 @@ option = gaim_account_option_string_new(_("Chat Room Locale"), "room_list_locale", YAHOO_ROOMLIST_LOCALE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); -#if 0 + option = gaim_account_option_string_new(_("Chat Room List Url"), "room_list", YAHOO_ROOMLIST_URL); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); - +#if 0 option = gaim_account_option_string_new(_("YCHT Host"), "ycht-server", YAHOO_YCHT_HOST); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); diff -ruN gaim-1.5.0.org/src/util.c gaim-1.5.0/src/util.c --- gaim-1.5.0.org/src/util.c 2005-08-12 09:53:33.000000000 +0900 +++ gaim-1.5.0/src/util.c 2005-08-13 19:52:49.000000000 +0900 @@ -3342,3 +3342,232 @@ } +void botch_ucs(gchar *ucs, gssize len) +{ + gint i; + + for(i=0;i