Mercurial > pidgin
comparison src/protocols/jabber/jabber.c @ 3642:5e50f6746509
[gaim-migrate @ 3766]
(10:16:03) deryni: we're fully 'compliant'? (sorry if that betrays some underlying stupidity)
(10:16:55) Paco-Paco: yes
(10:17:24) Paco-Paco: provided the user has the font, on any of the services supporting unicode we should support every known language in the world :-)
(10:17:36) Paco-Paco: well, as soon as we have a proper utf-8 input widget
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 11 Oct 2002 14:19:24 +0000 |
parents | 9682c0e022c6 |
children | 1a6d3f3bc682 |
comparison
equal
deleted
inserted
replaced
3641:e2391338c394 | 3642:5e50f6746509 |
---|---|
1302 } else | 1302 } else |
1303 */ | 1303 */ |
1304 if ((y = xmlnode_get_tag(p->x, "body"))) { | 1304 if ((y = xmlnode_get_tag(p->x, "body"))) { |
1305 msg = xmlnode_get_data(y); | 1305 msg = xmlnode_get_data(y); |
1306 } | 1306 } |
1307 | |
1308 msg = utf8_to_str(msg); | |
1309 | 1307 |
1310 if (!from) | 1308 if (!from) |
1311 return; | 1309 return; |
1312 | 1310 |
1313 if (conference_room) { | 1311 if (conference_room) { |
1360 else | 1358 else |
1361 serv_got_typing_stopped(GJ_GC(gjc), from); | 1359 serv_got_typing_stopped(GJ_GC(gjc), from); |
1362 g_free(from); | 1360 g_free(from); |
1363 } | 1361 } |
1364 | 1362 |
1365 if (msg) | |
1366 g_free(msg); | |
1367 | |
1368 } else if (!strcasecmp(type, "error")) { | 1363 } else if (!strcasecmp(type, "error")) { |
1369 if ((y = xmlnode_get_tag(p->x, "error"))) { | 1364 if ((y = xmlnode_get_tag(p->x, "error"))) { |
1370 type = xmlnode_get_attrib(y, "code"); | 1365 type = xmlnode_get_attrib(y, "code"); |
1371 msg = xmlnode_get_data(y); | 1366 msg = xmlnode_get_data(y); |
1372 } | 1367 } |
1387 */ | 1382 */ |
1388 if ((y = xmlnode_get_tag(p->x, "body"))) { | 1383 if ((y = xmlnode_get_tag(p->x, "body"))) { |
1389 msg = xmlnode_get_data(y); | 1384 msg = xmlnode_get_data(y); |
1390 } | 1385 } |
1391 | 1386 |
1392 msg = utf8_to_str(msg); | |
1393 | |
1394 if ((subj = xmlnode_get_tag(p->x, "subject"))) { | 1387 if ((subj = xmlnode_get_tag(p->x, "subject"))) { |
1395 topic = xmlnode_get_data(subj); | 1388 topic = xmlnode_get_data(subj); |
1396 } | 1389 } |
1397 topic = utf8_to_str(topic); | |
1398 | 1390 |
1399 jc = find_existing_chat(GJ_GC(gjc), p->from); | 1391 jc = find_existing_chat(GJ_GC(gjc), p->from); |
1400 if (!jc) { | 1392 if (!jc) { |
1401 /* we're not in this chat. are we supposed to be? */ | 1393 /* we're not in this chat. are we supposed to be? */ |
1402 if ((jc = find_pending_chat(GJ_GC(gjc), p->from)) != NULL) { | 1394 if ((jc = find_pending_chat(GJ_GC(gjc), p->from)) != NULL) { |
1435 char tbuf[8192]; | 1427 char tbuf[8192]; |
1436 g_snprintf(tbuf, sizeof(tbuf), "%s", topic); | 1428 g_snprintf(tbuf, sizeof(tbuf), "%s", topic); |
1437 chat_set_topic(jc->b, "", tbuf); | 1429 chat_set_topic(jc->b, "", tbuf); |
1438 } | 1430 } |
1439 } | 1431 } |
1440 | |
1441 g_free(msg); | |
1442 g_free(topic); | |
1443 | 1432 |
1444 } else { | 1433 } else { |
1445 debug_printf("unhandled message %s\n", type); | 1434 debug_printf("unhandled message %s\n", type); |
1446 } | 1435 } |
1447 } | 1436 } |
1762 } | 1751 } |
1763 | 1752 |
1764 /* | 1753 /* |
1765 * Add or remove a buddy? Change buddy's alias or group? | 1754 * Add or remove a buddy? Change buddy's alias or group? |
1766 */ | 1755 */ |
1767 if(name) | |
1768 name = utf8_to_str(name); | |
1769 | |
1770 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { | 1756 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { |
1771 if ((b = find_buddy(GJ_GC(gjc), buddyname)) == NULL) { | 1757 if ((b = find_buddy(GJ_GC(gjc), buddyname)) == NULL) { |
1772 debug_printf("adding buddy [4]: %s\n", buddyname); | 1758 debug_printf("adding buddy [4]: %s\n", buddyname); |
1773 b = add_buddy(GJ_GC(gjc), groupname ? groupname : _("Buddies"), buddyname, | 1759 b = add_buddy(GJ_GC(gjc), groupname ? groupname : _("Buddies"), buddyname, |
1774 name ? name : buddyname); | 1760 name ? name : buddyname); |
1803 } | 1789 } |
1804 } | 1790 } |
1805 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) { | 1791 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) { |
1806 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname); | 1792 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname); |
1807 } | 1793 } |
1808 | |
1809 if(name) | |
1810 g_free(name); | |
1811 | 1794 |
1812 g_free(buddyname); | 1795 g_free(buddyname); |
1813 | 1796 |
1814 } | 1797 } |
1815 | 1798 |
2476 y = xmlnode_insert_tag(x, "x"); | 2459 y = xmlnode_insert_tag(x, "x"); |
2477 xmlnode_put_attrib(y, "xmlns", "jabber:x:event"); | 2460 xmlnode_put_attrib(y, "xmlns", "jabber:x:event"); |
2478 xmlnode_insert_tag(y, "composing"); | 2461 xmlnode_insert_tag(y, "composing"); |
2479 | 2462 |
2480 if (message && strlen(message)) { | 2463 if (message && strlen(message)) { |
2481 char *utf8 = str_to_utf8((char*)message); | |
2482 y = xmlnode_insert_tag(x, "body"); | 2464 y = xmlnode_insert_tag(x, "body"); |
2483 xmlnode_insert_cdata(y, utf8, -1); | 2465 xmlnode_insert_cdata(y, message, -1); |
2484 g_free(utf8); | |
2485 } | 2466 } |
2486 | 2467 |
2487 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); | 2468 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); |
2488 xmlnode_free(x); | 2469 xmlnode_free(x); |
2489 return 1; | 2470 return 1; |
2537 /* If there's an alias for the buddy, it's not 0-length | 2518 /* If there's an alias for the buddy, it's not 0-length |
2538 * and it doesn't match his JID, add the "name" attribute. | 2519 * and it doesn't match his JID, add the "name" attribute. |
2539 */ | 2520 */ |
2540 if(my_alias != NULL && my_alias[0] != '\0' && strcmp(realwho, my_alias)) | 2521 if(my_alias != NULL && my_alias[0] != '\0' && strcmp(realwho, my_alias)) |
2541 { | 2522 { |
2542 char *utf8 = str_to_utf8(my_alias); | 2523 xmlnode_put_attrib(y, "name", my_alias); |
2543 xmlnode_put_attrib(y, "name", utf8); | |
2544 g_free(utf8); | |
2545 } | 2524 } |
2546 | 2525 |
2547 /* | 2526 /* |
2548 * See if there's an explict (new?) group for the buddy or pull | 2527 * See if there's an explict (new?) group for the buddy or pull |
2549 * one out of current Gaim buddylist data for him. | 2528 * one out of current Gaim buddylist data for him. |
2963 subject = g_strdup_printf("%s@%s", jc->gjid->user, jc->gjid->server); | 2942 subject = g_strdup_printf("%s@%s", jc->gjid->user, jc->gjid->server); |
2964 xmlnode_put_attrib(y, "jid", subject); | 2943 xmlnode_put_attrib(y, "jid", subject); |
2965 g_free(subject); | 2944 g_free(subject); |
2966 | 2945 |
2967 if (message && strlen(message)) { | 2946 if (message && strlen(message)) { |
2968 char *utf8 = str_to_utf8((char*)message); | |
2969 y = xmlnode_insert_tag(x, "body"); | 2947 y = xmlnode_insert_tag(x, "body"); |
2970 xmlnode_insert_cdata(y, utf8, -1); | 2948 xmlnode_insert_cdata(y, message, -1); |
2971 g_free(utf8); | |
2972 } | 2949 } |
2973 | 2950 |
2974 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); | 2951 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); |
2975 xmlnode_free(x); | 2952 xmlnode_free(x); |
2976 } | 2953 } |
3015 xmlnode_put_attrib(x, "type", "groupchat"); | 2992 xmlnode_put_attrib(x, "type", "groupchat"); |
3016 | 2993 |
3017 if (message && strlen(message) > strlen("/topic ") && | 2994 if (message && strlen(message) > strlen("/topic ") && |
3018 !g_strncasecmp(message, "/topic ", strlen("/topic "))) { | 2995 !g_strncasecmp(message, "/topic ", strlen("/topic "))) { |
3019 char buf[8192]; | 2996 char buf[8192]; |
3020 char *utf8 = str_to_utf8(message + strlen("/topic ")); | |
3021 y = xmlnode_insert_tag(x, "subject"); | 2997 y = xmlnode_insert_tag(x, "subject"); |
3022 xmlnode_insert_cdata(y, utf8, -1); | 2998 xmlnode_insert_cdata(y, message + strlen("/topic "), -1); |
3023 y = xmlnode_insert_tag(x, "body"); | 2999 y = xmlnode_insert_tag(x, "body"); |
3024 g_snprintf(buf, sizeof(buf), "/me has changed the subject to: %s", utf8); | 3000 g_snprintf(buf, sizeof(buf), "/me has changed the subject to: %s", message + strlen("/topic")); |
3025 xmlnode_insert_cdata(y, buf, -1); | 3001 xmlnode_insert_cdata(y, buf, -1); |
3026 g_free(utf8); | |
3027 } else if (message && strlen(message)) { | 3002 } else if (message && strlen(message)) { |
3028 char *utf8 = str_to_utf8(message); | |
3029 y = xmlnode_insert_tag(x, "body"); | 3003 y = xmlnode_insert_tag(x, "body"); |
3030 xmlnode_insert_cdata(y, utf8, -1); | 3004 xmlnode_insert_cdata(y, message, -1); |
3031 g_free(utf8); | |
3032 } | 3005 } |
3033 | 3006 |
3034 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); | 3007 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); |
3035 xmlnode_free(x); | 3008 xmlnode_free(x); |
3036 return 0; | 3009 return 0; |
3052 xmlnode_put_attrib(x, "to", chatname); | 3025 xmlnode_put_attrib(x, "to", chatname); |
3053 g_free(chatname); | 3026 g_free(chatname); |
3054 xmlnode_put_attrib(x, "type", "normal"); | 3027 xmlnode_put_attrib(x, "type", "normal"); |
3055 | 3028 |
3056 if (message && strlen(message)) { | 3029 if (message && strlen(message)) { |
3057 char *utf8 = str_to_utf8(message); | |
3058 y = xmlnode_insert_tag(x, "body"); | 3030 y = xmlnode_insert_tag(x, "body"); |
3059 xmlnode_insert_cdata(y, utf8, -1); | 3031 xmlnode_insert_cdata(y, message, -1); |
3060 g_free(utf8); | |
3061 } | 3032 } |
3062 | 3033 |
3063 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); | 3034 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x); |
3064 xmlnode_free(x); | 3035 xmlnode_free(x); |
3065 } | 3036 } |