libpurple/protocols/jabber/buddy.c

branch
xmpp.custom_smiley
changeset 24251
c463b357854c
parent 23630
e21bf8ee9197
parent 24200
6c6870d15155
child 24398
4865c2ee6ea8
child 24589
4027dd2acdbf
child 24942
ec72b773a9da
child 26142
20ed0b892829
equal deleted inserted replaced
23630:e21bf8ee9197 24251:c463b357854c
34 #include "iq.h" 34 #include "iq.h"
35 #include "presence.h" 35 #include "presence.h"
36 #include "xdata.h" 36 #include "xdata.h"
37 #include "pep.h" 37 #include "pep.h"
38 #include "adhoccommands.h" 38 #include "adhoccommands.h"
39
40 #define MAX_HTTP_BUDDYICON_BYTES (200 * 1024)
39 41
40 typedef struct { 42 typedef struct {
41 long idle_seconds; 43 long idle_seconds;
42 } JabberBuddyInfoResource; 44 } JabberBuddyInfoResource;
43 45
1247 if(child->type != XMLNODE_TYPE_TAG) 1249 if(child->type != XMLNODE_TYPE_TAG)
1248 continue; 1250 continue;
1249 1251
1250 text = xmlnode_get_data(child); 1252 text = xmlnode_get_data(child);
1251 if(text && !strcmp(child->name, "FN")) { 1253 if(text && !strcmp(child->name, "FN")) {
1252 /* If we havne't found a name yet, use this one as the serverside name */
1253 if (!serverside_alias) 1254 if (!serverside_alias)
1254 serverside_alias = g_strdup(text); 1255 serverside_alias = g_strdup(text);
1255 1256
1256 purple_notify_user_info_add_pair(user_info, _("Full Name"), text); 1257 purple_notify_user_info_add_pair(user_info, _("Full Name"), text);
1257 } else if(!strcmp(child->name, "N")) { 1258 } else if(!strcmp(child->name, "N")) {
1271 purple_notify_user_info_add_pair(user_info, _("Middle Name"), text2); 1272 purple_notify_user_info_add_pair(user_info, _("Middle Name"), text2);
1272 } 1273 }
1273 g_free(text2); 1274 g_free(text2);
1274 } 1275 }
1275 } else if(text && !strcmp(child->name, "NICKNAME")) { 1276 } else if(text && !strcmp(child->name, "NICKNAME")) {
1276 /* Prefer the Nickcname to the Full Name as the serverside alias */ 1277 /* Prefer the Nickcname to the Full Name as the serverside alias if it's not just part of the jid.
1277 g_free(serverside_alias); 1278 * Ignore it if it's part of the jid. */
1278 serverside_alias = g_strdup(text); 1279 if (strstr(bare_jid, text) == NULL) {
1279 1280 g_free(serverside_alias);
1280 purple_notify_user_info_add_pair(user_info, _("Nickname"), text); 1281 serverside_alias = g_strdup(text);
1282
1283 purple_notify_user_info_add_pair(user_info, _("Nickname"), text);
1284 }
1281 } else if(text && !strcmp(child->name, "BDAY")) { 1285 } else if(text && !strcmp(child->name, "BDAY")) {
1282 purple_notify_user_info_add_pair(user_info, _("Birthday"), text); 1286 purple_notify_user_info_add_pair(user_info, _("Birthday"), text);
1283 } else if(!strcmp(child->name, "ADR")) { 1287 } else if(!strcmp(child->name, "ADR")) {
1284 gboolean address_line_added = FALSE; 1288 gboolean address_line_added = FALSE;
1285 1289
1533 if(type && id && !goodinfo && !strcmp(type, "image/png")) 1537 if(type && id && !goodinfo && !strcmp(type, "image/png"))
1534 goodinfo = info; 1538 goodinfo = info;
1535 } 1539 }
1536 } 1540 }
1537 if(goodinfo) { 1541 if(goodinfo) {
1538 const char *url = xmlnode_get_attrib(goodinfo,"url"); 1542 const char *url = xmlnode_get_attrib(goodinfo, "url");
1539 const char *id = xmlnode_get_attrib(goodinfo,"id"); 1543 const char *id = xmlnode_get_attrib(goodinfo,"id");
1540 1544
1541 /* the avatar might either be stored in a pep node, or on a HTTP/HTTPS URL */ 1545 /* the avatar might either be stored in a pep node, or on a HTTP/HTTPS URL */
1542 if(!url) 1546 if(!url)
1543 jabber_pep_request_item(js, from, AVATARNAMESPACEDATA, id, do_buddy_avatar_update_data); 1547 jabber_pep_request_item(js, from, AVATARNAMESPACEDATA, id, do_buddy_avatar_update_data);
1544 else { 1548 else {
1549 PurpleUtilFetchUrlData *url_data;
1545 JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1); 1550 JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1);
1546 info->js = js; 1551 info->js = js;
1547 info->from = g_strdup(from); 1552
1548 info->id = g_strdup(id); 1553 url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE,
1549 purple_util_fetch_url(url, TRUE, NULL, TRUE, do_buddy_avatar_update_fromurl, info); 1554 MAX_HTTP_BUDDYICON_BYTES,
1555 do_buddy_avatar_update_fromurl, info);
1556 if (url_data) {
1557 info->from = g_strdup(from);
1558 info->id = g_strdup(id);
1559 js->url_datas = g_slist_prepend(js->url_datas, url_data);
1560 } else
1561 g_free(info);
1562
1550 } 1563 }
1551 } 1564 }
1552 } 1565 }
1553 } 1566 }
1554 1567
1790 if(bare_jid) { 1803 if(bare_jid) {
1791 jabber_buddy_get_info_for_jid(js, bare_jid); 1804 jabber_buddy_get_info_for_jid(js, bare_jid);
1792 g_free(bare_jid); 1805 g_free(bare_jid);
1793 } 1806 }
1794 } 1807 }
1795
1796 void jabber_buddy_get_info_chat(PurpleConnection *gc, int id,
1797 const char *resource)
1798 {
1799 JabberStream *js = gc->proto_data;
1800 JabberChat *chat = jabber_chat_find_by_id(js, id);
1801 char *full_jid;
1802
1803 if(!chat)
1804 return;
1805
1806 full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, resource);
1807 jabber_buddy_get_info_for_jid(js, full_jid);
1808 g_free(full_jid);
1809 }
1810
1811 1808
1812 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who, 1809 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who,
1813 gboolean invisible) 1810 gboolean invisible)
1814 { 1811 {
1815 PurplePresence *gpresence; 1812 PurplePresence *gpresence;

mercurial