comparison libpurple/protocols/oscar/oscar.c @ 30824:5661f30d1b8e

Got rid of receiving multipart messages over channel 1, which simplified the code immensely. No client sends them these days, so this is safe. In addition to that, I moved decoding logic from oscar.c to family_icbm.c. Also, removed family_odir stuff which I forgot to remove earlier and which resulted in liboscar failing to load. :(
author ivan.komarov@soc.pidgin.im
date Wed, 28 Jul 2010 23:11:14 +0000
parents 553cd883a29a
children ed520e6e972b 1dd3ed053628
comparison
equal deleted inserted replaced
30823:553cd883a29a 30824:5661f30d1b8e
1498 PurpleConnection *gc = od->gc; 1498 PurpleConnection *gc = od->gc;
1499 PurpleAccount *account = purple_connection_get_account(gc); 1499 PurpleAccount *account = purple_connection_get_account(gc);
1500 PurpleMessageFlags flags = 0; 1500 PurpleMessageFlags flags = 0;
1501 struct buddyinfo *bi; 1501 struct buddyinfo *bi;
1502 PurpleStoredImage *img; 1502 PurpleStoredImage *img;
1503 GString *message;
1504 gchar *tmp; 1503 gchar *tmp;
1505 aim_mpmsg_section_t *curpart;
1506 const char *start, *end; 1504 const char *start, *end;
1507 GData *attribs; 1505 GData *attribs;
1508 1506
1509 purple_debug_misc("oscar", "Received IM from %s with %d parts\n", 1507 purple_debug_misc("oscar", "Received IM from %s\n", userinfo->bn);
1510 userinfo->bn, args->mpmsg.numparts);
1511
1512 if (args->mpmsg.numparts == 0)
1513 return 1;
1514 1508
1515 bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->bn)); 1509 bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->bn));
1516 if (!bi) { 1510 if (!bi) {
1517 bi = g_new0(struct buddyinfo, 1); 1511 bi = g_new0(struct buddyinfo, 1);
1518 g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, userinfo->bn)), bi); 1512 g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, userinfo->bn)), bi);
1548 purple_buddy_icons_get_account_icon_timestamp(account), 1542 purple_buddy_icons_get_account_icon_timestamp(account),
1549 aimutil_iconsum(data, len)); 1543 aimutil_iconsum(data, len));
1550 } 1544 }
1551 purple_imgstore_unref(img); 1545 purple_imgstore_unref(img);
1552 1546
1553 message = g_string_new(""); 1547 tmp = g_strdup(args->msg);
1554 curpart = args->mpmsg.parts;
1555 while (curpart != NULL) {
1556 tmp = oscar_decode_im_part(account, userinfo->bn, curpart->charset,
1557 curpart->charsubset, curpart->data, curpart->datalen);
1558 if (tmp != NULL) {
1559 g_string_append(message, tmp);
1560 g_free(tmp);
1561 }
1562
1563 curpart = curpart->next;
1564 }
1565 tmp = g_string_free(message, FALSE);
1566 1548
1567 /* 1549 /*
1568 * Convert iChat color tags to normal font tags. 1550 * Convert iChat color tags to normal font tags.
1569 */ 1551 */
1570 if (purple_markup_find_tag("body", tmp, &start, &end, &attribs)) 1552 if (purple_markup_find_tag("body", tmp, &start, &end, &attribs))
1644 tmp2 = g_strdup_printf("%.*s%s", len, tmp, end + 1); 1626 tmp2 = g_strdup_printf("%.*s%s", len, tmp, end + 1);
1645 g_free(tmp); 1627 g_free(tmp);
1646 tmp = tmp2; 1628 tmp = tmp2;
1647 } 1629 }
1648 1630
1649 serv_got_im(gc, userinfo->bn, tmp, flags, 1631 serv_got_im(gc, userinfo->bn, tmp, flags, (args->icbmflags & AIM_IMFLAGS_OFFLINE) ? args->timestamp : time(NULL));
1650 (args->icbmflags & AIM_IMFLAGS_OFFLINE) ? args->timestamp : time(NULL));
1651 g_free(tmp); 1632 g_free(tmp);
1652 1633
1653 return 1; 1634 return 1;
1654 } 1635 }
1655 1636
1825 for (i=0; msg1[i]; i++) { 1806 for (i=0; msg1[i]; i++) {
1826 gchar *uin = g_strdup_printf("%u", args->uin); 1807 gchar *uin = g_strdup_printf("%u", args->uin);
1827 1808
1828 purple_str_strip_char(msg1[i], '\r'); 1809 purple_str_strip_char(msg1[i], '\r');
1829 /* TODO: Should use an encoding other than ASCII? */ 1810 /* TODO: Should use an encoding other than ASCII? */
1830 msg2[i] = oscar_decode_im_part(account, uin, AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); 1811 msg2[i] = oscar_decode_im(account, uin, AIM_CHARSET_ASCII, msg1[i], strlen(msg1[i]));
1831 g_free(uin); 1812 g_free(uin);
1832 } 1813 }
1833 msg2[i] = NULL; 1814 msg2[i] = NULL;
1834 1815
1835 switch (args->type) { 1816 switch (args->type) {
1882 if (i >= 6) { 1863 if (i >= 6) {
1883 gchar *bn = g_strdup_printf("%u", args->uin); 1864 gchar *bn = g_strdup_printf("%u", args->uin);
1884 gchar *reason = NULL; 1865 gchar *reason = NULL;
1885 1866
1886 if (msg2[5] != NULL) 1867 if (msg2[5] != NULL)
1887 reason = oscar_decode_im_part(account, bn, AIM_CHARSET_LATIN_1, 0x0000, msg2[5], strlen(msg2[5])); 1868 reason = oscar_decode_im(account, bn, AIM_CHARSET_LATIN_1, msg2[5], strlen(msg2[5]));
1888 1869
1889 purple_debug_info("oscar", 1870 purple_debug_info("oscar",
1890 "Received an authorization request from UIN %u\n", 1871 "Received an authorization request from UIN %u\n",
1891 args->uin); 1872 args->uin);
1892 aim_icq_getalias(od, bn, TRUE, reason); 1873 aim_icq_getalias(od, bn, TRUE, reason);