Mercurial > pidgin
changeset 26794:cf44519c2eb4
merge of '2cc4b9096219b80544460c7419be088836ee4705'
and '990fb79f4d87ff08cfe2a68db0da873a1b63a4c4'
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 03 May 2009 06:45:46 +0000 |
parents | c4aeea36c77b (current diff) 76de9455154c (diff) |
children | ca7daa65bf0d |
files | |
diffstat | 4 files changed, 57 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/caps.c Sun May 03 01:49:16 2009 +0000 +++ b/libpurple/protocols/jabber/caps.c Sun May 03 06:45:46 2009 +0000 @@ -826,8 +826,13 @@ JabberIdentity *id = (JabberIdentity*)node->data; char *category = g_markup_escape_text(id->category, -1); char *type = g_markup_escape_text(id->type, -1); - char *lang = g_markup_escape_text(id->lang, -1); - char *name = g_markup_escape_text(id->name, -1); + char *lang = NULL; + char *name = NULL; + + if (id->lang) + lang = g_markup_escape_text(id->lang, -1); + if (id->name) + name = g_markup_escape_text(id->name, -1); g_string_append_printf(verification, "%s/%s/%s/%s<", category, type, lang ? lang : "", name ? name : "");
--- a/libpurple/protocols/jabber/pep.c Sun May 03 01:49:16 2009 +0000 +++ b/libpurple/protocols/jabber/pep.c Sun May 03 06:45:46 2009 +0000 @@ -67,12 +67,15 @@ JabberIqType type, const char *id, xmlnode *packet, gpointer data) { - xmlnode *pubsub = xmlnode_get_child_with_namespace(packet,"pubsub","http://jabber.org/protocol/pubsub"); + xmlnode *pubsub; xmlnode *items = NULL; JabberPEPHandler *cb = data; - if(pubsub) - items = xmlnode_get_child(pubsub, "items"); + if (type == JABBER_IQ_RESULT) { + pubsub = xmlnode_get_child_with_namespace(packet, "pubsub", "http://jabber.org/protocol/pubsub"); + if(pubsub) + items = xmlnode_get_child(pubsub, "items"); + } cb(js, from, items); }
--- a/libpurple/protocols/jabber/useravatar.c Sun May 03 01:49:16 2009 +0000 +++ b/libpurple/protocols/jabber/useravatar.c Sun May 03 06:45:46 2009 +0000 @@ -33,9 +33,6 @@ void jabber_avatar_init(void) { - jabber_pep_register_handler(NS_AVATAR_0_12_METADATA, - update_buddy_metadata); - jabber_add_feature(NS_AVATAR_1_1_METADATA, jabber_pep_namespace_only_when_pep_enabled_cb); jabber_add_feature(NS_AVATAR_1_1_DATA, @@ -48,8 +45,32 @@ static void remove_avatar_0_12_nodes(JabberStream *js) { + /* Publish an empty avatar according to the XEP-0084 v0.12 semantics */ + xmlnode *publish, *item, *metadata; + /* publish the metadata */ + publish = xmlnode_new("publish"); + xmlnode_set_attrib(publish, "node", NS_AVATAR_0_12_METADATA); + + item = xmlnode_new_child(publish, "item"); + xmlnode_set_attrib(item, "id", "stop"); + + metadata = xmlnode_new_child(item, "metadata"); + xmlnode_set_namespace(metadata, NS_AVATAR_0_12_METADATA); + + xmlnode_new_child(metadata, "stop"); + + /* publish */ + jabber_pep_publish(js, publish); + + /* + * This causes ejabberd 2.0.0 to RST our connection unceremoniously, + * so disable it for now (we publish a <stop/> to the metadata node + * instead. + */ +#if 0 jabber_pep_delete_node(js, NS_AVATAR_0_12_METADATA); jabber_pep_delete_node(js, NS_AVATAR_0_12_DATA); +#endif } void jabber_avatar_set(JabberStream *js, PurpleStoredImage *img) @@ -59,6 +80,7 @@ if (!js->pep) return; + /* Hmmm, not sure if this is worth the traffic, but meh */ remove_avatar_0_12_nodes(js); if (!img) { @@ -169,35 +191,29 @@ } static void +do_got_own_avatar_0_12_cb(JabberStream *js, const char *from, xmlnode *items) +{ + if (items) + /* It wasn't an error (i.e. 'item-not-found') */ + remove_avatar_0_12_nodes(js); +} + +static void do_got_own_avatar_cb(JabberStream *js, const char *from, xmlnode *items) { xmlnode *item = NULL, *metadata = NULL, *info = NULL; PurpleAccount *account = purple_connection_get_account(js->gc); const char *server_hash = NULL; - const char *ns; - if ((item = xmlnode_get_child(items, "item")) && + if (items && (item = xmlnode_get_child(items, "item")) && (metadata = xmlnode_get_child(item, "metadata")) && (info = xmlnode_get_child(metadata, "info"))) { server_hash = xmlnode_get_attrib(info, "id"); } - if (!metadata) - return; - - ns = xmlnode_get_namespace(metadata); - if (!ns) + if (items && !metadata) return; - /* - * We no longer publish avatars to the older namespace. If there is one - * there, delete it. - */ - if (g_str_equal(ns, NS_AVATAR_0_12_METADATA) && server_hash) { - remove_avatar_0_12_nodes(js); - return; - } - /* Publish ours if it's different than the server's */ if (!purple_strequal(server_hash, js->initial_avatar_hash)) { PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); @@ -210,7 +226,7 @@ { char *jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); jabber_pep_request_item(js, jid, NS_AVATAR_0_12_METADATA, NULL, - do_got_own_avatar_cb); + do_got_own_avatar_0_12_cb); jabber_pep_request_item(js, jid, NS_AVATAR_1_1_METADATA, NULL, do_got_own_avatar_cb); g_free(jid); @@ -247,7 +263,7 @@ do_buddy_avatar_update_data(JabberStream *js, const char *from, xmlnode *items) { xmlnode *item, *data; - const char *checksum, *ns; + const char *checksum; char *b64data; void *img; size_t size; @@ -262,12 +278,6 @@ if(!data) return; - ns = xmlnode_get_namespace(data); - /* Make sure the namespace is one of the two valid possibilities */ - if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_DATA) && - !g_str_equal(ns, NS_AVATAR_1_1_DATA))) - return; - checksum = xmlnode_get_attrib(item,"id"); if(!checksum) return; @@ -290,7 +300,7 @@ update_buddy_metadata(JabberStream *js, const char *from, xmlnode *items) { PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); - const char *checksum, *ns; + const char *checksum; xmlnode *item, *metadata; if(!buddy) return; @@ -306,15 +316,9 @@ if(!metadata) return; - ns = xmlnode_get_namespace(metadata); - /* Make sure the namespace is one of the two valid possibilities */ - if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_METADATA) && - !g_str_equal(ns, NS_AVATAR_1_1_METADATA))) - return; - checksum = purple_buddy_icons_get_checksum_for_user(buddy); - /* check if we have received a stop */ + /* <stop/> was the pre-v1.1 method of publishing an empty avatar */ if(xmlnode_get_child(metadata, "stop")) { purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); } else { @@ -347,10 +351,7 @@ /* the avatar might either be stored in a pep node, or on a HTTP(S) URL */ if(!url) { - const char *data_ns; - data_ns = (g_str_equal(ns, NS_AVATAR_0_12_METADATA) ? - NS_AVATAR_0_12_DATA : NS_AVATAR_1_1_DATA); - jabber_pep_request_item(js, from, data_ns, id, + jabber_pep_request_item(js, from, NS_AVATAR_1_1_DATA, id, do_buddy_avatar_update_data); } else { PurpleUtilFetchUrlData *url_data;
--- a/libpurple/protocols/jabber/usernick.c Sun May 03 01:49:16 2009 +0000 +++ b/libpurple/protocols/jabber/usernick.c Sun May 03 06:45:46 2009 +0000 @@ -65,7 +65,10 @@ static void do_nick_got_own_nick_cb(JabberStream *js, const char *from, xmlnode *items) { char *oldnickname = NULL; - xmlnode *item = xmlnode_get_child(items,"item"); + xmlnode *item = NULL; + + if (items) + item = xmlnode_get_child(items,"item"); if(item) { xmlnode *nick = xmlnode_get_child_with_namespace(item,"nick","http://jabber.org/protocol/nick");