Mercurial > pidgin.yaz
diff libpurple/protocols/jabber/disco.c @ 25987:c4fd9222dda1
propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
to branch 'im.pidgin.cpw.darkrain42.xmpp.bosh' (head 650d82b8a5f0c8860804dd8004cd54badea48e1e)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 07 Mar 2009 01:59:40 +0000 |
parents | 5f9a24d1c25e 6a369035fd20 |
children | 2597de135090 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/disco.c Thu Mar 05 23:54:50 2009 +0000 +++ b/libpurple/protocols/jabber/disco.c Sat Mar 07 01:59:40 2009 +0000 @@ -98,6 +98,10 @@ xmlnode *in_query; const char *node = NULL; + char *node_uri = NULL; + + /* create custom caps node URI */ + node_uri = g_strconcat(CAPS0115_NODE, "#", jabber_caps_get_own_hash(js), NULL); if((in_query = xmlnode_get_child(packet, "query"))) { node = xmlnode_get_attrib(in_query, "node"); @@ -123,80 +127,39 @@ * web */ xmlnode_set_attrib(identity, "name", PACKAGE); - SUPPORT_FEATURE("jabber:iq:last") - SUPPORT_FEATURE("jabber:iq:oob") - SUPPORT_FEATURE("jabber:iq:time") - SUPPORT_FEATURE("xmpp:urn:time") - SUPPORT_FEATURE("jabber:iq:version") - SUPPORT_FEATURE("jabber:x:conference") - SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams") - SUPPORT_FEATURE("http://jabber.org/protocol/disco#info") - SUPPORT_FEATURE("http://jabber.org/protocol/disco#items") - SUPPORT_FEATURE("http://jabber.org/protocol/ibb"); - SUPPORT_FEATURE("http://jabber.org/protocol/muc") - SUPPORT_FEATURE("http://jabber.org/protocol/muc#user") - SUPPORT_FEATURE("http://jabber.org/protocol/si") - SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer") - SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im") - SUPPORT_FEATURE("urn:xmpp:ping") - SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0199.html#ns") - - if(!node) { /* non-caps disco#info, add all enabled extensions */ - GList *features; - for(features = jabber_features; features; features = features->next) { - JabberFeature *feat = (JabberFeature*)features->data; - if(feat->is_enabled == NULL || feat->is_enabled(js, feat->shortname, feat->namespace) == TRUE) - SUPPORT_FEATURE(feat->namespace); - } + if(!node || !strcmp(node, node_uri)) { + GList *features, *identities; + for(identities = jabber_identities; identities; identities = identities->next) { + JabberIdentity *ident = (JabberIdentity*)identities->data; + identity = xmlnode_new_child(query, "identity"); + xmlnode_set_attrib(identity, "category", ident->category); + xmlnode_set_attrib(identity, "type", ident->type); + if (ident->lang) + xmlnode_set_attrib(identity, "xml:lang", ident->lang); + if (ident->name) + xmlnode_set_attrib(identity, "name", ident->name); + } + for(features = jabber_features; features; features = features->next) { + JabberFeature *feat = (JabberFeature*)features->data; + if (!feat->is_enabled || feat->is_enabled(js, feat->namespace)) { + feature = xmlnode_new_child(query, "feature"); + xmlnode_set_attrib(feature, "var", feat->namespace); + } } } else { - const char *ext = NULL; - unsigned pos; - unsigned nodelen = strlen(node); - unsigned capslen = strlen(CAPS0115_NODE); - /* do a basic plausability check */ - if(nodelen > capslen+1) { - /* verify that the string is CAPS0115#<ext> and get the pointer to the ext part */ - for(pos = 0; pos < capslen+1; ++pos) { - if(pos == capslen) { - if(node[pos] == '#') - ext = &node[pos+1]; - else - break; - } else if(node[pos] != CAPS0115_NODE[pos]) - break; - } - - if(ext != NULL) { - /* look for that ext */ - GList *features; - for(features = jabber_features; features; features = features->next) { - JabberFeature *feat = (JabberFeature*)features->data; - if(!strcmp(feat->shortname, ext)) { - SUPPORT_FEATURE(feat->namespace); - break; - } - } - if(features == NULL) - ext = NULL; - } - } - - if(ext == NULL) { - xmlnode *error, *inf; - - /* XXX: gross hack, implement jabber_iq_set_type or something */ - xmlnode_set_attrib(iq->node, "type", "error"); - iq->type = JABBER_IQ_ERROR; - - error = xmlnode_new_child(query, "error"); - xmlnode_set_attrib(error, "code", "404"); - xmlnode_set_attrib(error, "type", "cancel"); - inf = xmlnode_new_child(error, "item-not-found"); - xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); - } + xmlnode *error, *inf; + + /* XXX: gross hack, implement jabber_iq_set_type or something */ + xmlnode_set_attrib(iq->node, "type", "error"); + iq->type = JABBER_IQ_ERROR; + + error = xmlnode_new_child(query, "error"); + xmlnode_set_attrib(error, "code", "404"); + xmlnode_set_attrib(error, "type", "cancel"); + inf = xmlnode_new_child(error, "item-not-found"); + xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); } - + g_free(node_uri); jabber_iq_send(iq); } else if(!strcmp(type, "result")) { xmlnode *query = xmlnode_get_child(packet, "query"); @@ -349,9 +312,6 @@ jabber_roster_request(js); } - /* Send initial presence; this will trigger receipt of presence for contacts on the roster */ - jabber_presence_send(js->gc->account, NULL); - if (js->server_caps & JABBER_CAP_ADHOC) { /* The server supports ad-hoc commands, so let's request the list */ jabber_adhoc_server_get_list(js);