Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 3659:5b439da85c3b
[gaim-migrate @ 3788]
more i18n work from paco-paco and a fix for colors with high intensity from
Alex Converse (alex4)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 12 Oct 2002 20:45:00 +0000 |
parents | 498e78765620 |
children | a9445dd25786 |
comparison
equal
deleted
inserted
replaced
3658:50122d258d6d | 3659:5b439da85c3b |
---|---|
1711 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { | 1711 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
1712 char *tmp; | 1712 char *tmp; |
1713 struct gaim_connection *gc = sess->aux_data; | 1713 struct gaim_connection *gc = sess->aux_data; |
1714 struct oscar_data *od = gc->proto_data; | 1714 struct oscar_data *od = gc->proto_data; |
1715 int flags = 0; | 1715 int flags = 0; |
1716 int convlen; | |
1717 GError *err = NULL; | |
1716 | 1718 |
1717 if (args->icbmflags & AIM_IMFLAGS_AWAY) | 1719 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
1718 flags |= IM_FLAG_AWAY; | 1720 flags |= IM_FLAG_AWAY; |
1719 | 1721 |
1720 if (args->icbmflags & AIM_IMFLAGS_HASICON) { | 1722 if (args->icbmflags & AIM_IMFLAGS_HASICON) { |
1767 * Quickly convert it to eight bit format, replacing | 1769 * Quickly convert it to eight bit format, replacing |
1768 * non-ASCII UNICODE characters with their equivelent | 1770 * non-ASCII UNICODE characters with their equivelent |
1769 * HTML entity. | 1771 * HTML entity. |
1770 */ | 1772 */ |
1771 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { | 1773 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
1772 int i, j; | 1774 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
1773 GError *err = NULL; | 1775 if (err) { |
1774 | 1776 debug_printf("Unicode IM conversion: %s\n", err->message); |
1775 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", &j, &i, &err); | 1777 tmp = strdup(_("(There was an error receiving this message)")); |
1776 if (err) | |
1777 debug_printf("Unicode IM conversion: %s\n", err->message); | |
1778 if (!tmp) { | |
1779 /* Conversion to HTML entities isn't a bad fallback */ | |
1780 debug_printf ("AIM charset conversion failed!\n"); | |
1781 for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) { | |
1782 unsigned short uni; | |
1783 | |
1784 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff); | |
1785 | |
1786 if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ | |
1787 | |
1788 g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "%c", uni); | |
1789 | |
1790 } else { /* something else, do UNICODE entity */ | |
1791 g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni); | |
1792 } | |
1793 | |
1794 } | |
1795 } | 1778 } |
1796 } else if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) { | 1779 } else if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) { |
1797 int i; | 1780 int i; |
1798 debug_printf("ISO-8859-1 IM"); | 1781 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
1799 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &i, NULL); | 1782 if (err) { |
1783 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); | |
1784 tmp = strdup(_("(There was an error receiving this message)")); | |
1785 } | |
1800 } else { | 1786 } else { |
1801 /* ASCII is valid UTF-8 */ | 1787 /* ASCII is valid UTF-8 */ |
1802 debug_printf("ASCII IM\n"); | |
1803 tmp = g_strdup(args->msg); | 1788 tmp = g_strdup(args->msg); |
1804 } | 1789 } |
1805 | 1790 |
1806 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) { | 1791 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) { |
1807 char *who = normalize(userinfo->sn); | 1792 char *who = normalize(userinfo->sn); |
3287 | 3272 |
3288 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) { | 3273 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) { |
3289 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | 3274 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
3290 struct direct_im *dim = find_direct_im(odata, name); | 3275 struct direct_im *dim = find_direct_im(odata, name); |
3291 int ret = 0; | 3276 int ret = 0; |
3277 GError *err = NULL; | |
3292 | 3278 |
3293 if (dim) { | 3279 if (dim) { |
3294 if (dim->connected) { /* If we're not connected yet, send through server */ | 3280 if (dim->connected) { /* If we're not connected yet, send through server */ |
3295 ret = aim_send_im_direct(odata->sess, dim->conn, message, len == -1 ? strlen(message) : len); | 3281 ret = aim_send_im_direct(odata->sess, dim->conn, message, len == -1 ? strlen(message) : len); |
3296 if (ret == 0) | 3282 if (ret == 0) |
3372 i++; | 3358 i++; |
3373 } | 3359 } |
3374 while (message[i]) { | 3360 while (message[i]) { |
3375 /* ISO-8859-1 is 0x00-0xbf in the first byte | 3361 /* ISO-8859-1 is 0x00-0xbf in the first byte |
3376 * followed by 0xc0-0xc3 in the second */ | 3362 * followed by 0xc0-0xc3 in the second */ |
3377 if ((unsigned char)message[i] > 0x80 && ((unsigned char)message[i] > 0xbf || | 3363 if ((unsigned char)message[i] < 0x80 || |
3378 ((unsigned char)message[i + 1] < 0xc0 || (unsigned char)message[i + 1] > 0xc3))) { | 3364 ((unsigned char)message[i] & 0xc0 == 0x80 && |
3379 args.flags ^= AIM_IMFLAGS_ISO_8859_1; | 3365 (unsigned char)message[i + 1] & 0xfc == 0xc0)) { |
3380 args.flags |= AIM_IMFLAGS_UNICODE; | 3366 i++; |
3381 break; | 3367 continue; |
3382 } | 3368 } |
3383 i++; | 3369 args.flags ^= AIM_IMFLAGS_ISO_8859_1; |
3370 args.flags |= AIM_IMFLAGS_UNICODE; | |
3371 break; | |
3384 } | 3372 } |
3385 if (args.flags & AIM_IMFLAGS_UNICODE) { | 3373 if (args.flags & AIM_IMFLAGS_UNICODE) { |
3386 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, NULL); | 3374 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3375 if (err) { | |
3376 debug_printf("Error converting a unicode message: %s\n", err->message); | |
3377 debug_printf("This really shouldn't happen!\n"); | |
3378 /* We really shouldn't try to send the | |
3379 * IM now, but I'm not sure what to do */ | |
3380 } | |
3387 } else if (args.flags & AIM_IMFLAGS_UNICODE) { | 3381 } else if (args.flags & AIM_IMFLAGS_UNICODE) { |
3388 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, NULL); | 3382 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3389 if (!args.msg) { | 3383 if (err) { |
3384 debug_printf("conversion error: %s\n", err->message); | |
3390 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); | 3385 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); |
3391 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; | 3386 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
3392 len = strlen(message); | 3387 len = strlen(message); |
3393 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, NULL); | 3388 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3389 if (err) { | |
3390 debug_printf ("Error in unicode fallback: %s\n", err->message); | |
3391 } | |
3394 } | 3392 } |
3395 } else { | 3393 } else { |
3396 args.msg = message; | 3394 args.msg = message; |
3397 } | 3395 } |
3398 args.msglen = len; | 3396 args.msglen = len; |