Mercurial > pidgin
diff libpurple/protocols/jabber/jabber.c @ 28650:9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 27 Nov 2009 17:07:19 +0000 |
parents | 1a4b6f47258c |
children | d9c70a78fad5 3bf5dbff753b c4f836780e1c cb8b53a6f238 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Fri Nov 27 17:07:19 2009 +0000 @@ -81,8 +81,8 @@ char *open_stream; open_stream = g_strdup_printf("<stream:stream to='%s' " - "xmlns='jabber:client' " - "xmlns:stream='http://etherx.jabber.org/streams' " + "xmlns='" NS_XMPP_CLIENT "' " + "xmlns:stream='" NS_XMPP_STREAMS "' " "version='1.0'>", js->user->domain); /* setup the parser fresh for each stream */ @@ -116,7 +116,7 @@ jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); session = xmlnode_new_child(iq->node, "session"); - xmlnode_set_namespace(session, "urn:ietf:params:xml:ns:xmpp-session"); + xmlnode_set_namespace(session, NS_XMPP_SESSION); jabber_iq_send(iq); } @@ -128,7 +128,7 @@ xmlnode *bind; if (type == JABBER_IQ_RESULT && - (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { + (bind = xmlnode_get_child_with_namespace(packet, "bind", NS_XMPP_BIND))) { xmlnode *jid; char *full_jid; if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { @@ -217,7 +217,7 @@ char *requested_resource; JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); bind = xmlnode_new_child(iq->node, "bind"); - xmlnode_set_namespace(bind, "urn:ietf:params:xml:ns:xmpp-bind"); + xmlnode_set_namespace(bind, NS_XMPP_BIND); requested_resource = jabber_prep_resource(js->user->resource); if (requested_resource != NULL) { @@ -272,11 +272,11 @@ } else if(!strcmp((*packet)->name, "stream:features")) { jabber_stream_features_parse(js, *packet); } else if (!strcmp((*packet)->name, "features") && xmlns && - !strcmp(xmlns, "http://etherx.jabber.org/streams")) { + !strcmp(xmlns, NS_XMPP_STREAMS)) { jabber_stream_features_parse(js, *packet); } else if(!strcmp((*packet)->name, "stream:error") || (!strcmp((*packet)->name, "error") && xmlns && - !strcmp(xmlns, "http://etherx.jabber.org/streams"))) + !strcmp(xmlns, NS_XMPP_STREAMS))) { jabber_stream_handle_error(js, *packet); } else if(!strcmp((*packet)->name, "challenge")) { @@ -385,7 +385,7 @@ if(js->state != JABBER_STREAM_CONNECTED && /* Either <auth> or <query><password>... */ (((tag_start = strstr(data, "<auth ")) && - strstr(data, "xmlns='urn:ietf:params:xml:ns:xmpp-sasl'")) || + strstr(data, "xmlns='" NS_XMPP_SASL "'")) || ((tag_start = strstr(data, "<query ")) && strstr(data, "xmlns='jabber:iq:auth'>") && (tag_start = strstr(tag_start, "<password>"))))) { @@ -488,7 +488,7 @@ if (g_str_equal((*packet)->name, "message") || g_str_equal((*packet)->name, "iq") || g_str_equal((*packet)->name, "presence")) - xmlnode_set_namespace(*packet, "jabber:client"); + xmlnode_set_namespace(*packet, NS_XMPP_CLIENT); txt = xmlnode_to_str(*packet, &len); jabber_send_raw(js, txt, len); g_free(txt); @@ -1213,7 +1213,7 @@ jabber_x_data_request(js, x, jabber_register_x_data_cb, g_strdup(from)); return; - } else if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:oob"))) { + } else if((x = xmlnode_get_child_with_namespace(query, "x", NS_OOB_X_DATA))) { xmlnode *url; if((url = xmlnode_get_child(x, "url"))) { @@ -1642,7 +1642,7 @@ error = xmlnode_new_child(result->node, "error"); xmlnode_set_attrib(error, "type", "cancel"); x = xmlnode_new_child(error, "not-allowed"); - xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(x, NS_XMPP_STANZAS); jabber_iq_send(result); return; @@ -1668,7 +1668,7 @@ error = xmlnode_new_child(result->node, "error"); xmlnode_set_attrib(error, "type", "modify"); x = xmlnode_new_child(error, "bad-request"); - xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(x, NS_XMPP_STANZAS); jabber_iq_send(result); return; @@ -1698,7 +1698,7 @@ PurpleAccount *account; blocklist = xmlnode_get_child_with_namespace(packet, - "blocklist", "urn:xmpp:blocking"); + "blocklist", NS_SIMPLE_BLOCKING); account = purple_connection_get_account(js->gc); if (type == JABBER_IQ_ERROR || blocklist == NULL) @@ -1731,7 +1731,7 @@ iq = jabber_iq_new(js, JABBER_IQ_GET); blocklist = xmlnode_new_child(iq->node, "blocklist"); - xmlnode_set_namespace(blocklist, "urn:xmpp:blocking"); + xmlnode_set_namespace(blocklist, NS_SIMPLE_BLOCKING); jabber_iq_set_callback(iq, jabber_blocklist_parse, NULL); @@ -1764,7 +1764,7 @@ iq = jabber_iq_new(js, JABBER_IQ_SET); block = xmlnode_new_child(iq->node, "block"); - xmlnode_set_namespace(block, "urn:xmpp:blocking"); + xmlnode_set_namespace(block, NS_SIMPLE_BLOCKING); item = xmlnode_new_child(block, "item"); xmlnode_set_attrib(item, "jid", who); @@ -1794,7 +1794,7 @@ iq = jabber_iq_new(js, JABBER_IQ_SET); unblock = xmlnode_new_child(iq->node, "unblock"); - xmlnode_set_namespace(unblock, "urn:xmpp:blocking"); + xmlnode_set_namespace(unblock, NS_SIMPLE_BLOCKING); item = xmlnode_new_child(unblock, "item"); xmlnode_set_attrib(item, "jid", who); @@ -2458,7 +2458,7 @@ } else if(xmlnode_get_child(error, "undefined-condition")) { text = _("Unknown Error"); } - } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { + } else if(xmlns && !strcmp(xmlns, NS_XMPP_SASL)) { /* Most common reason can be the default */ SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR); if(xmlnode_get_child(packet, "aborted")) { @@ -2486,7 +2486,7 @@ } } else if(!strcmp(packet->name, "stream:error") || (!strcmp(packet->name, "error") && xmlns && - !strcmp(xmlns, "http://etherx.jabber.org/streams"))) { + !strcmp(xmlns, NS_XMPP_STREAMS))) { /* Most common reason as default: */ SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR); if(xmlnode_get_child(packet, "bad-format")) { @@ -3267,7 +3267,7 @@ if (jabber_resource_has_capability(jbr, "http://jabber.org/protocol/si/profile/file-transfer") && (jabber_resource_has_capability(jbr, - "http://jabber.org/protocol/bytestreams") + NS_BYTESTREAMS) || jabber_resource_has_capability(jbr, NS_IBB))) { return TRUE; } @@ -3479,22 +3479,22 @@ jabber_add_identity("client", type, NULL, ui_name); /* initialize jabber_features list */ - jabber_add_feature("jabber:iq:last", 0); - jabber_add_feature("jabber:iq:oob", 0); - jabber_add_feature("urn:xmpp:time", 0); + jabber_add_feature(NS_LAST_ACTIVITY, 0); + jabber_add_feature(NS_OOB_IQ_DATA, 0); + jabber_add_feature(NS_ENTITY_TIME, 0); jabber_add_feature("jabber:iq:version", 0); jabber_add_feature("jabber:x:conference", 0); - jabber_add_feature("http://jabber.org/protocol/bytestreams", 0); + jabber_add_feature(NS_BYTESTREAMS, 0); jabber_add_feature("http://jabber.org/protocol/caps", 0); jabber_add_feature("http://jabber.org/protocol/chatstates", 0); - jabber_add_feature("http://jabber.org/protocol/disco#info", 0); - jabber_add_feature("http://jabber.org/protocol/disco#items", 0); + jabber_add_feature(NS_DISCO_INFO, 0); + jabber_add_feature(NS_DISCO_ITEMS, 0); jabber_add_feature(NS_IBB, 0); jabber_add_feature("http://jabber.org/protocol/muc", 0); jabber_add_feature("http://jabber.org/protocol/muc#user", 0); jabber_add_feature("http://jabber.org/protocol/si", 0); jabber_add_feature("http://jabber.org/protocol/si/profile/file-transfer", 0); - jabber_add_feature("http://jabber.org/protocol/xhtml-im", 0); + jabber_add_feature(NS_XHTML_IM, 0); jabber_add_feature(NS_PING, 0); /* Buzz/Attention */