Mercurial > pidgin.yaz
changeset 29031: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 | 8d8a1afc4268 |
children | 31497213393c 588a7aef5f7c d9c70a78fad5 |
files | libpurple/protocols/jabber/adhoccommands.c libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/caps.c libpurple/protocols/jabber/chat.c libpurple/protocols/jabber/disco.c libpurple/protocols/jabber/google.c libpurple/protocols/jabber/ibb.c libpurple/protocols/jabber/iq.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/message.c libpurple/protocols/jabber/namespaces.h libpurple/protocols/jabber/oob.c libpurple/protocols/jabber/presence.c libpurple/protocols/jabber/si.c |
diffstat | 14 files changed, 143 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/adhoccommands.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/adhoccommands.c Fri Nov 27 17:07:19 2009 +0000 @@ -97,7 +97,7 @@ if (type == JABBER_IQ_ERROR) return; - query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); + query = xmlnode_get_child_with_namespace(packet, "query", NS_DISCO_ITEMS); if (!query) return; node = xmlnode_get_attrib(query, "node"); @@ -275,7 +275,8 @@ JabberIqType type, const char *id, xmlnode *packet, gpointer data) { - xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); + xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", + NS_DISCO_ITEMS); jabber_adhoc_got_server_list(js, from, query); @@ -291,8 +292,9 @@ } void jabber_adhoc_server_get_list(JabberStream *js) { - JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#items"); - xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items"); + JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS); + xmlnode *query = xmlnode_get_child_with_namespace(iq->node, "query", + NS_DISCO_ITEMS); xmlnode_set_attrib(iq->node,"to",js->user->domain); xmlnode_set_attrib(query,"node","http://jabber.org/protocol/commands");
--- a/libpurple/protocols/jabber/buddy.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Fri Nov 27 17:07:19 2009 +0000 @@ -1466,7 +1466,7 @@ if(!jbr->client.name) return FALSE; - if(!strcmp(ns, "jabber:iq:last")) { + if(!strcmp(ns, NS_LAST_ACTIVITY)) { if(!strcmp(jbr->client.name, "Trillian")) { /* verified by nwalp 2007/05/09 */ if(!strcmp(jbr->client.version, "3.1.0.121") || @@ -1512,8 +1512,8 @@ * respond (with an error or otherwise) to jabber:iq:last * requests. There are a number of Trillian users in my * office. */ - if(!_client_is_blacklisted(jbr, "jabber:iq:last")) { - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last"); + if(!_client_is_blacklisted(jbr, NS_LAST_ACTIVITY)) { + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY); xmlnode_set_attrib(iq->node, "to", to); jabber_iq_set_callback(iq, jabber_last_parse, jbi); jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); @@ -1522,12 +1522,12 @@ if (jbr->tz_off == PURPLE_NO_TZ_OFF && (!jbr->caps.info || - jabber_resource_has_capability(jbr, "urn:xmpp:time"))) { + jabber_resource_has_capability(jbr, NS_ENTITY_TIME))) { xmlnode *child; iq = jabber_iq_new(js, JABBER_IQ_GET); xmlnode_set_attrib(iq->node, "to", to); child = xmlnode_new_child(iq->node, "time"); - xmlnode_set_namespace(child, "urn:xmpp:time"); + xmlnode_set_namespace(child, NS_ENTITY_TIME); jabber_iq_set_callback(iq, jabber_time_parse, jbi); jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); jabber_iq_send(iq); @@ -1590,7 +1590,7 @@ if (!jb->resources && is_bare_jid) { /* user is offline, send a jabber:iq:last to find out last time online */ - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY); xmlnode_set_attrib(iq->node, "to", jid); jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi); jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
--- a/libpurple/protocols/jabber/caps.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/caps.c Fri Nov 27 17:07:19 2009 +0000 @@ -440,7 +440,7 @@ const char *id, xmlnode *packet, gpointer data) { xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", - "http://jabber.org/protocol/disco#info"); + NS_DISCO_INFO); jabber_caps_cbplususerdata *userdata = data; JabberCapsClientInfo *info = NULL, *value; JabberCapsTuple key; @@ -531,7 +531,7 @@ const char *id, xmlnode *packet, gpointer data) { xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", - "http://jabber.org/protocol/disco#info"); + NS_DISCO_INFO); xmlnode *child; ext_iq_data *userdata = data; GList *features = NULL; @@ -638,10 +638,9 @@ xmlnode *query; char *nodever; - iq = jabber_iq_new_query(js, JABBER_IQ_GET, - "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); query = xmlnode_get_child_with_namespace(iq->node, "query", - "http://jabber.org/protocol/disco#info"); + NS_DISCO_INFO); nodever = g_strdup_printf("%s#%s", node, ver); xmlnode_set_attrib(query, "node", nodever); g_free(nodever); @@ -679,10 +678,9 @@ cbdata->name = exts[i]; cbdata->data = cbplususerdata_ref(userdata); - iq = jabber_iq_new_query(js, JABBER_IQ_GET, - "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); query = xmlnode_get_child_with_namespace(iq->node, "query", - "http://jabber.org/protocol/disco#info"); + NS_DISCO_INFO); nodeext = g_strdup_printf("%s#%s", node, exts[i]); xmlnode_set_attrib(query, "node", nodeext); g_free(nodeext); @@ -771,7 +769,7 @@ xmlnode *child; JabberCapsClientInfo *info; - if (!query || strcmp(query->xmlns, "http://jabber.org/protocol/disco#info")) + if (!query || strcmp(query->xmlns, NS_DISCO_INFO)) return 0; info = g_new0(JabberCapsClientInfo, 1);
--- a/libpurple/protocols/jabber/chat.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/chat.c Fri Nov 27 17:07:19 2009 +0000 @@ -825,7 +825,7 @@ purple_roomlist_set_in_progress(js->roomlist, TRUE); - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS); xmlnode_set_attrib(iq->node, "to", server); @@ -1201,7 +1201,7 @@ for(x = xmlnode_get_child(query, "feature"); x; x = xmlnode_get_next_twin(x)) { const char *var = xmlnode_get_attrib(x, "var"); - if(var && !strcmp(var, "http://jabber.org/protocol/xhtml-im")) { + if(var && !strcmp(var, NS_XHTML_IM)) { chat->xhtml = TRUE; } } @@ -1216,8 +1216,7 @@ room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); - iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, - "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, NS_DISCO_INFO); xmlnode_set_attrib(iq->node, "to", room_jid);
--- a/libpurple/protocols/jabber/disco.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/disco.c Fri Nov 27 17:07:19 2009 +0000 @@ -60,7 +60,7 @@ { JabberBytestreamsStreamhost *sh = data; xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", - "http://jabber.org/protocol/bytestreams"); + NS_BYTESTREAMS); if (from && !strcmp(from, sh->jid) && query != NULL) { xmlnode *sh_node = xmlnode_get_child(query, "streamhost"); @@ -109,8 +109,7 @@ /* create custom caps node URI */ node_uri = g_strconcat(CAPS0115_NODE, "#", jabber_caps_get_own_hash(js), NULL); - iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, - "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, NS_DISCO_INFO); jabber_iq_set_id(iq, id); @@ -189,7 +188,7 @@ 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_set_namespace(inf, NS_XMPP_STANZAS); } g_free(node_uri); jabber_iq_send(iq); @@ -204,7 +203,7 @@ error = xmlnode_new_child(iq->node, "error"); xmlnode_set_attrib(error, "type", "modify"); bad_request = xmlnode_new_child(error, "bad-request"); - xmlnode_set_namespace(bad_request, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(bad_request, NS_XMPP_STANZAS); jabber_iq_set_id(iq, id); if (from) @@ -221,8 +220,7 @@ struct _jabber_disco_info_cb_data *jdicd = data; xmlnode *query; - query = xmlnode_get_child_with_namespace(packet, "query", - "http://jabber.org/protocol/disco#info"); + query = xmlnode_get_child_with_namespace(packet, "query", NS_DISCO_INFO); if (type == JABBER_IQ_RESULT && query) { xmlnode *child; @@ -257,7 +255,7 @@ } else if(!strcmp(category, "directory") && !strcmp(type, "user")) { /* we found a JUD */ js->user_directories = g_list_prepend(js->user_directories, g_strdup(from)); - } else if(!strcmp(category, "proxy") && !strcmp(type, "bytestreams")) { + } else if(!strcmp(category, "proxy") && !strcmp(type, NS_BYTESTREAMS)) { /* This is a bytestream proxy */ JabberIq *iq; JabberBytestreamsStreamhost *sh; @@ -269,7 +267,7 @@ js->bs_proxies = g_list_prepend(js->bs_proxies, sh); iq = jabber_iq_new_query(js, JABBER_IQ_GET, - "http://jabber.org/protocol/bytestreams"); + NS_BYTESTREAMS); xmlnode_set_attrib(iq->node, "to", sh->jid); jabber_iq_set_callback(iq, jabber_disco_bytestream_server_cb, sh); jabber_iq_send(iq); @@ -284,7 +282,7 @@ capabilities |= JABBER_CAP_SI; else if(!strcmp(var, "http://jabber.org/protocol/si/profile/file-transfer")) capabilities |= JABBER_CAP_SI_FILE_XFER; - else if(!strcmp(var, "http://jabber.org/protocol/bytestreams")) + else if(!strcmp(var, NS_BYTESTREAMS)) capabilities |= JABBER_CAP_BYTESTREAMS; else if(!strcmp(var, "jabber:iq:search")) capabilities |= JABBER_CAP_IQ_SEARCH; @@ -292,12 +290,12 @@ capabilities |= JABBER_CAP_IQ_REGISTER; else if(!strcmp(var, NS_PING)) capabilities |= JABBER_CAP_PING; - else if(!strcmp(var, "http://jabber.org/protocol/disco#items")) + else if(!strcmp(var, NS_DISCO_ITEMS)) capabilities |= JABBER_CAP_ITEMS; else if(!strcmp(var, "http://jabber.org/protocol/commands")) { capabilities |= JABBER_CAP_ADHOC; } - else if(!strcmp(var, "http://jabber.org/protocol/ibb")) { + else if(!strcmp(var, NS_IBB)) { purple_debug_info("jabber", "remote supports IBB\n"); capabilities |= JABBER_CAP_IBB; } @@ -341,7 +339,7 @@ { if(type == JABBER_IQ_GET) { JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, - "http://jabber.org/protocol/disco#items"); + NS_DISCO_ITEMS); /* preserve node */ xmlnode *iq_query = xmlnode_get_child(iq->node, "query"); @@ -409,8 +407,7 @@ sh->jid = g_strdup(ft_proxy_list[i]); js->bs_proxies = g_list_prepend(js->bs_proxies, sh); - iq = jabber_iq_new_query(js, JABBER_IQ_GET, - "http://jabber.org/protocol/bytestreams"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_BYTESTREAMS); xmlnode_set_attrib(iq->node, "to", sh->jid); jabber_iq_set_callback(iq, jabber_disco_bytestream_server_cb, sh); jabber_iq_send(iq); @@ -555,7 +552,7 @@ if (!var) continue; - if (!strcmp("google:mail:notify", var)) { + if (!strcmp(NS_GOOGLE_MAIL_NOTIFY, var)) { js->server_caps |= JABBER_CAP_GMAIL_NOTIFY; jabber_gmail_init(js); } else if (!strcmp("google:roster", var)) { @@ -563,7 +560,7 @@ jabber_google_roster_init(js); } else if (!strcmp("http://jabber.org/protocol/commands", var)) { js->server_caps |= JABBER_CAP_ADHOC; - } else if (!strcmp("urn:xmpp:blocking", var)) { + } else if (!strcmp(NS_SIMPLE_BLOCKING, var)) { js->server_caps |= JABBER_CAP_BLOCKING; } } @@ -604,7 +601,7 @@ if((node = xmlnode_get_attrib(child, "node"))) continue; - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); xmlnode_set_attrib(iq->node, "to", jid); jabber_iq_set_callback(iq, jabber_disco_info_cb, NULL); jabber_iq_send(iq); @@ -613,15 +610,14 @@ void jabber_disco_items_server(JabberStream *js) { - JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, - "http://jabber.org/protocol/disco#items"); + JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS); xmlnode_set_attrib(iq->node, "to", js->user->domain); jabber_iq_set_callback(iq, jabber_disco_server_items_result_cb, NULL); jabber_iq_send(iq); - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); xmlnode_set_attrib(iq->node, "to", js->user->domain); jabber_iq_set_callback(iq, jabber_disco_server_info_result_cb, NULL); jabber_iq_send(iq); @@ -650,7 +646,7 @@ jdicd->data = data; jdicd->callback = callback; - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); xmlnode_set_attrib(iq->node, "to", who); jabber_iq_set_callback(iq, jabber_disco_info_cb, jdicd);
--- a/libpurple/protocols/jabber/google.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Fri Nov 27 17:07:19 2009 +0000 @@ -910,7 +910,7 @@ purple_debug_misc("jabber", "Got new mail notification. Sending request for more info\n"); - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY); jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); query = xmlnode_get_child(iq->node, "query"); @@ -944,7 +944,7 @@ xmlnode_set_attrib(mailnotifications, "value", "true"); jabber_iq_send(iq); - iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); + iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY); jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); jabber_iq_send(iq); }
--- a/libpurple/protocols/jabber/ibb.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/ibb.c Fri Nov 27 17:07:19 2009 +0000 @@ -361,8 +361,7 @@ xmlnode *error = xmlnode_new("error"); xmlnode *item_not_found = xmlnode_new("item-not-found"); - xmlnode_set_namespace(item_not_found, - "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(item_not_found, NS_XMPP_STANZAS); xmlnode_set_attrib(error, "code", "440"); xmlnode_set_attrib(error, "type", "cancel"); jabber_iq_set_id(result, id);
--- a/libpurple/protocols/jabber/iq.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/iq.c Fri Nov 27 17:07:19 2009 +0000 @@ -155,7 +155,7 @@ char *idle_time; if(type == JABBER_IQ_GET) { - iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last"); + iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, NS_LAST_ACTIVITY); jabber_iq_set_id(iq, id); if (from) xmlnode_set_attrib(iq->node, "to", from); @@ -190,7 +190,7 @@ xmlnode_set_attrib(iq->node, "to", from); child = xmlnode_new_child(iq->node, child->name); - xmlnode_set_namespace(child, "urn:xmpp:time"); + xmlnode_set_namespace(child, NS_ENTITY_TIME); /* <tzo>-06:00</tzo> */ tm = localtime(&now_t); @@ -332,7 +332,7 @@ error = xmlnode_new_child(iq->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(iq); } else @@ -397,7 +397,7 @@ xmlnode_set_attrib(error, "type", "cancel"); xmlnode_set_attrib(error, "code", "501"); x = xmlnode_new_child(error, "feature-not-implemented"); - xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(x, NS_XMPP_STANZAS); jabber_iq_send(iq); } @@ -458,21 +458,19 @@ signal_iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); jabber_iq_register_handler("jingle", JINGLE, jingle_parse); - jabber_iq_register_handler("mailbox", "google:mail:notify", + jabber_iq_register_handler("mailbox", NS_GOOGLE_MAIL_NOTIFY, jabber_gmail_poke); - jabber_iq_register_handler("new-mail", "google:mail:notify", + jabber_iq_register_handler("new-mail", NS_GOOGLE_MAIL_NOTIFY, jabber_gmail_poke); jabber_iq_register_handler("ping", NS_PING, jabber_ping_parse); jabber_iq_register_handler("query", NS_GOOGLE_JINGLE_INFO, jabber_google_handle_jingle_info); - jabber_iq_register_handler("query", "http://jabber.org/protocol/bytestreams", + jabber_iq_register_handler("query", NS_BYTESTREAMS, jabber_bytestreams_parse); - jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#info", - jabber_disco_info_parse); - jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#items", - jabber_disco_items_parse); - jabber_iq_register_handler("query", "jabber:iq:last", jabber_iq_last_parse); - jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse); + jabber_iq_register_handler("query", NS_DISCO_INFO, jabber_disco_info_parse); + jabber_iq_register_handler("query", NS_DISCO_ITEMS, jabber_disco_items_parse); + jabber_iq_register_handler("query", NS_LAST_ACTIVITY, jabber_iq_last_parse); + jabber_iq_register_handler("query", NS_OOB_IQ_DATA, jabber_oob_parse); jabber_iq_register_handler("query", "jabber:iq:register", jabber_register_parse); jabber_iq_register_handler("query", "jabber:iq:roster", @@ -483,9 +481,9 @@ jabber_iq_register_handler("session", NS_GOOGLE_SESSION, jabber_google_session_parse); #endif - jabber_iq_register_handler("block", "urn:xmpp:blocking", jabber_blocklist_parse_push); - jabber_iq_register_handler("unblock", "urn:xmpp:blocking", jabber_blocklist_parse_push); - jabber_iq_register_handler("time", "urn:xmpp:time", jabber_time_parse); + jabber_iq_register_handler("block", NS_SIMPLE_BLOCKING, jabber_blocklist_parse_push); + jabber_iq_register_handler("unblock", NS_SIMPLE_BLOCKING, jabber_blocklist_parse_push); + jabber_iq_register_handler("time", NS_ENTITY_TIME, jabber_time_parse); }
--- 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 */
--- a/libpurple/protocols/jabber/message.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/message.c Fri Nov 27 17:07:19 2009 +0000 @@ -178,7 +178,7 @@ for(etc = jm->etc; etc; etc = etc->next) { xmlnode *x = etc->data; const char *xmlns = xmlnode_get_namespace(x); - if(xmlns && !strcmp(xmlns, "jabber:x:oob")) { + if(xmlns && !strcmp(xmlns, NS_OOB_X_DATA)) { xmlnode *url, *desc; char *urltxt, *desctxt; @@ -611,22 +611,22 @@ jm->etc = g_list_append(jm->etc, child); /* The following tests expect xmlns != NULL */ continue; - } else if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) { + } else if(!strcmp(child->name, "subject") && !strcmp(xmlns, NS_XMPP_CLIENT)) { if(!jm->subject) { jm->subject = xmlnode_get_data(child); if(!jm->subject) jm->subject = g_strdup(""); } - } else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) { + } else if(!strcmp(child->name, "thread") && !strcmp(xmlns, NS_XMPP_CLIENT)) { if(!jm->thread_id) jm->thread_id = xmlnode_get_data(child); - } else if(!strcmp(child->name, "body") && !strcmp(xmlns,"jabber:client")) { + } else if(!strcmp(child->name, "body") && !strcmp(xmlns, NS_XMPP_CLIENT)) { if(!jm->body) { char *msg = xmlnode_to_str(child, NULL); jm->body = purple_strdup_withhtml(msg); g_free(msg); } - } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) { + } else if(!strcmp(child->name, "html") && !strcmp(xmlns, NS_XHTML_IM)) { if(!jm->xhtml && xmlnode_get_child(child, "body")) { char *c; @@ -800,7 +800,7 @@ } } else if (g_str_equal(child->name, "query")) { const char *node = xmlnode_get_attrib(child, "node"); - if (purple_strequal(xmlns, "http://jabber.org/protocol/disco#items") + if (purple_strequal(xmlns, NS_DISCO_ITEMS) && purple_strequal(node, "http://jabber.org/protocol/commands")) { jabber_adhoc_got_list(js, jm->from, child); } @@ -1204,9 +1204,9 @@ * the user's roster, allow sending XHTML-IM markup. */ if (!jbr || !jbr->caps.info || - jabber_resource_has_capability(jbr, "http://jabber.org/protocol/xhtml-im")) { + jabber_resource_has_capability(jbr, NS_XHTML_IM)) { if (!jabber_xhtml_plain_equal(xhtml, jm->body)) - jm->xhtml = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", xhtml); + jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'>%s</body></html>", xhtml); } g_free(xhtml); @@ -1249,7 +1249,7 @@ } if (chat->xhtml && !jabber_xhtml_plain_equal(xhtml, jm->body)) - jm->xhtml = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", xhtml); + jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'>%s</body></html>", xhtml); g_free(xhtml);
--- a/libpurple/protocols/jabber/namespaces.h Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/namespaces.h Fri Nov 27 17:07:19 2009 +0000 @@ -24,11 +24,34 @@ #ifndef PURPLE_JABBER_NAMESPACES_H_ #define PURPLE_JABBER_NAMESPACES_H_ -/* Implementation of XEP-0084 */ +#define NS_XMPP_BIND "urn:ietf:params:xml:ns:xmpp-bind" +#define NS_XMPP_CLIENT "jabber:client" +#define NS_XMPP_SASL "urn:ietf:params:xml:ns:xmpp-sasl" +#define NS_XMPP_SESSION "urn:ietf:params:xml:ns:xmpp-session" +#define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas" +#define NS_XMPP_STREAMS "http://etherx.jabber.org/streams" + +/* XEP-0012 Last Activity (and XEP-0256 Last Activity in Presence) */ +#define NS_LAST_ACTIVITY "jabber:iq:last" + +/* XEP-0030 Service Discovery */ +#define NS_DISCO_INFO "http://jabber.org/protocol/disco#info" +#define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" /* XEP-0047 IBB (In-band bytestreams) */ #define NS_IBB "http://jabber.org/protocol/ibb" +/* XEP-0065 SOCKS5 Bytestreams */ +#define NS_BYTESTREAMS "http://jabber.org/protocol/bytestreams" + +/* XEP-0066 Out of Band Data (OOB) */ +#define NS_OOB_IQ_DATA "jabber:iq:oob" +#define NS_OOB_X_DATA "jabber:x:oob" + +/* XEP-0071 XHTML-IM (rich-text messages) */ +#define NS_XHTML_IM "http://jabber.org/protocol/xhtml-im" +#define NS_XHTML "http://www.w3.org/1999/xhtml" + /* XEP-0084 v0.12 User Avatar */ #define NS_AVATAR_0_12_DATA "http://www.xmpp.org/extensions/xep-0084.html#ns-data" #define NS_AVATAR_0_12_METADATA "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata" @@ -37,9 +60,15 @@ #define NS_AVATAR_1_1_DATA "urn:xmpp:avatar:data" #define NS_AVATAR_1_1_METADATA "urn:xmpp:avatar:metadata" +/* XEP-0191 Simple Communications Blocking */ +#define NS_SIMPLE_BLOCKING "urn:xmpp:blocking" + /* XEP-0199 Ping */ #define NS_PING "urn:xmpp:ping" +/* XEP-0202 Entity Time */ +#define NS_ENTITY_TIME "urn:xmpp:time" + /* XEP-0224 Attention */ #define NS_ATTENTION "urn:xmpp:attention:0" @@ -52,6 +81,8 @@ #define NS_GOOGLE_VOICE "http://www.google.com/xmpp/protocol/voice/v1" #define NS_GOOGLE_JINGLE_INFO "google:jingleinfo" +#define NS_GOOGLE_MAIL_NOTIFY "google:mail:notify" + #define NS_GOOGLE_PROTOCOL_SESSION "http://www.google.com/xmpp/protocol/session" #define NS_GOOGLE_SESSION "http://www.google.com/session" #define NS_GOOGLE_SESSION_PHONE "http://www.google.com/session/phone"
--- a/libpurple/protocols/jabber/oob.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/oob.c Fri Nov 27 17:07:19 2009 +0000 @@ -170,11 +170,11 @@ if(!strcmp(code, "406")) { z = xmlnode_new_child(y, "not-acceptable"); xmlnode_set_attrib(y, "type", "modify"); - xmlnode_set_namespace(z, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(z, NS_XMPP_STANZAS); } else if(!strcmp(code, "404")) { z = xmlnode_new_child(y, "not-found"); xmlnode_set_attrib(y, "type", "cancel"); - xmlnode_set_namespace(z, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(z, NS_XMPP_STANZAS); } jabber_iq_send(iq);
--- a/libpurple/protocols/jabber/presence.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/presence.c Fri Nov 27 17:07:19 2009 +0000 @@ -297,7 +297,7 @@ gchar seconds[10]; g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle)); - xmlnode_set_namespace(query, "jabber:iq:last"); + xmlnode_set_namespace(query, NS_LAST_ACTIVITY); xmlnode_set_attrib(query, "seconds", seconds); } @@ -462,8 +462,8 @@ goto out; if (!jbr->commands_fetched && jabber_resource_has_capability(jbr, "http://jabber.org/protocol/commands")) { - JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); - xmlnode *query = xmlnode_get_child_with_namespace(iq->node, "query", "http://jabber.org/protocol/disco#items"); + JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, NS_DISCO_ITEMS); + xmlnode *query = xmlnode_get_child_with_namespace(iq->node, "query", NS_DISCO_ITEMS); xmlnode_set_attrib(iq->node, "to", userdata->from); xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands"); jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL); @@ -655,7 +655,7 @@ } } } else if (!strcmp(y->name, "query") && - !strcmp(xmlnode_get_namespace(y), "jabber:iq:last")) { + !strcmp(xmlnode_get_namespace(y), NS_LAST_ACTIVITY)) { /* resource has specified idle */ const gchar *seconds = xmlnode_get_attrib(y, "seconds"); if (seconds) {
--- a/libpurple/protocols/jabber/si.c Fri Nov 27 16:21:29 2009 +0000 +++ b/libpurple/protocols/jabber/si.c Fri Nov 27 17:07:19 2009 +0000 @@ -144,7 +144,7 @@ if(xfer->type == PURPLE_XFER_SEND) { xmlnode *activate; - iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, "http://jabber.org/protocol/bytestreams"); + iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, NS_BYTESTREAMS); xmlnode_set_attrib(iq->node, "to", streamhost->jid); query = xmlnode_get_child(iq->node, "query"); xmlnode_set_attrib(query, "sid", jsx->stream_id); @@ -155,7 +155,7 @@ } else { - iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, "http://jabber.org/protocol/bytestreams"); + iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, NS_BYTESTREAMS); xmlnode_set_attrib(iq->node, "to", xfer->who); jabber_iq_set_id(iq, jsx->iq_id); query = xmlnode_get_child(iq->node, "query"); @@ -232,7 +232,7 @@ 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_set_namespace(inf, NS_XMPP_STANZAS); jabber_iq_send(iq); @@ -843,8 +843,7 @@ purple_xfer_unref(xfer); - iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, - "http://jabber.org/protocol/bytestreams"); + iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, NS_BYTESTREAMS); xmlnode_set_attrib(iq->node, "to", xfer->who); query = xmlnode_get_child(iq->node, "query"); @@ -1206,7 +1205,7 @@ if(var && !strcmp(var, "stream-method")) { if((value = xmlnode_get_child(field, "value"))) { char *val = xmlnode_get_data(value); - if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) { + if(val && !strcmp(val, NS_BYTESTREAMS)) { jabber_si_xfer_bytestreams_send_init(xfer); jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; found_method = TRUE; @@ -1268,10 +1267,10 @@ behind troublesome firewalls */ option = xmlnode_new_child(field, "option"); value = xmlnode_new_child(option, "value"); - xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1); + xmlnode_insert_data(value, NS_BYTESTREAMS, -1); option = xmlnode_new_child(field, "option"); value = xmlnode_new_child(option, "value"); - xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1); + xmlnode_insert_data(value, NS_IBB, -1); jabber_iq_set_callback(iq, jabber_si_xfer_send_method_cb, xfer); @@ -1372,9 +1371,9 @@ error = xmlnode_new_child(iq->node, "error"); xmlnode_set_attrib(error, "type", "cancel"); child = xmlnode_new_child(error, "forbidden"); - xmlnode_set_namespace(child, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(child, NS_XMPP_STANZAS); child = xmlnode_new_child(error, "text"); - xmlnode_set_namespace(child, "urn:ietf:params:xml:ns:xmpp-stanzas"); + xmlnode_set_namespace(child, NS_XMPP_STANZAS); xmlnode_insert_data(child, "Offer Declined", -1); jabber_iq_send(iq); @@ -1580,10 +1579,10 @@ for people who know their firewalls are very restrictive */ if (jsx->stream_method & STREAM_METHOD_BYTESTREAMS) { value = xmlnode_new_child(field, "value"); - xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1); + xmlnode_insert_data(value, NS_BYTESTREAMS, -1); } else if(jsx->stream_method & STREAM_METHOD_IBB) { value = xmlnode_new_child(field, "value"); - xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1); + xmlnode_insert_data(value, NS_IBB, -1); } jabber_iq_send(iq); @@ -1687,9 +1686,9 @@ if((value = xmlnode_get_child(option, "value"))) { char *val; if((val = xmlnode_get_data(value))) { - if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) { + if(!strcmp(val, NS_BYTESTREAMS)) { jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; - } else if(!strcmp(val, "http://jabber.org/protocol/ibb")) { + } else if(!strcmp(val, NS_IBB)) { jsx->stream_method |= STREAM_METHOD_IBB; } g_free(val);