Mercurial > pidgin.yaz
changeset 29026:7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 26 Nov 2009 22:35:07 +0000 |
parents | 932661a155b7 |
children | 9feec7d1d95c |
files | libpurple/protocols/jabber/data.c libpurple/protocols/jabber/data.h libpurple/protocols/jabber/disco.c libpurple/protocols/jabber/google.c libpurple/protocols/jabber/google.h libpurple/protocols/jabber/ibb.c libpurple/protocols/jabber/ibb.h libpurple/protocols/jabber/iq.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/message.c libpurple/protocols/jabber/message.h libpurple/protocols/jabber/ping.c libpurple/protocols/jabber/si.c libpurple/protocols/jabber/useravatar.h |
diffstat | 15 files changed, 50 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/data.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/data.c Thu Nov 26 22:35:07 2009 +0000 @@ -140,7 +140,7 @@ xmlnode *tag = xmlnode_new("data"); char *base64data = purple_base64_encode(data->data, data->size); - xmlnode_set_namespace(tag, XEP_0231_NAMESPACE); + xmlnode_set_namespace(tag, NS_BOB); xmlnode_set_attrib(tag, "cid", data->cid); xmlnode_set_attrib(tag, "type", data->type); @@ -169,7 +169,7 @@ { xmlnode *tag = xmlnode_new("data"); - xmlnode_set_namespace(tag, XEP_0231_NAMESPACE); + xmlnode_set_namespace(tag, NS_BOB); xmlnode_set_attrib(tag, "cid", cid); return tag; @@ -254,7 +254,7 @@ remote_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_data_delete); - jabber_iq_register_handler("data", XEP_0231_NAMESPACE, jabber_data_parse); + jabber_iq_register_handler("data", NS_BOB, jabber_data_parse); } void
--- a/libpurple/protocols/jabber/data.h Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/data.h Thu Nov 26 22:35:07 2009 +0000 @@ -24,8 +24,6 @@ #include "xmlnode.h" #include "jabber.h" -#define XEP_0231_NAMESPACE "urn:xmpp:bob" - #include <glib.h> typedef struct {
--- a/libpurple/protocols/jabber/disco.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/disco.c Thu Nov 26 22:35:07 2009 +0000 @@ -152,7 +152,7 @@ * advertises as 'voice-v1'. */ xmlnode *feature = xmlnode_new_child(query, "feature"); - xmlnode_set_attrib(feature, "var", "http://www.google.com/xmpp/protocol/voice/v1"); + xmlnode_set_attrib(feature, "var", NS_GOOGLE_VOICE); } else if (g_str_equal(node, CAPS0115_NODE "#" "video-v1")) { /* * HUGE HACK! We advertise this ext (see jabber_presence_create_js @@ -164,7 +164,7 @@ * advertises as 'video-v1'. */ xmlnode *feature = xmlnode_new_child(query, "feature"); - xmlnode_set_attrib(feature, "var", "http://www.google.com/xmpp/protocol/video/v1"); + xmlnode_set_attrib(feature, "var", NS_GOOGLE_VIDEO); } else if (g_str_equal(node, CAPS0115_NODE "#" "camera-v1")) { /* * HUGE HACK! We advertise this ext (see jabber_presence_create_js @@ -176,7 +176,7 @@ * advertises as 'camera-v1'. */ xmlnode *feature = xmlnode_new_child(query, "feature"); - xmlnode_set_attrib(feature, "var", "http://www.google.com/xmpp/protocol/camera/v1"); + xmlnode_set_attrib(feature, "var", NS_GOOGLE_CAMERA); #endif } else { xmlnode *error, *inf; @@ -290,7 +290,7 @@ capabilities |= JABBER_CAP_IQ_SEARCH; else if(!strcmp(var, "jabber:iq:register")) capabilities |= JABBER_CAP_IQ_REGISTER; - else if(!strcmp(var, "urn:xmpp:ping")) + else if(!strcmp(var, NS_PING)) capabilities |= JABBER_CAP_PING; else if(!strcmp(var, "http://jabber.org/protocol/disco#items")) capabilities |= JABBER_CAP_ITEMS;
--- a/libpurple/protocols/jabber/google.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Thu Nov 26 22:35:07 2009 +0000 @@ -37,9 +37,6 @@ #ifdef USE_VV -#define NS_GOOGLE_VIDEO "http://www.google.com/session/video" -#define NS_GOOGLE_PHONE "http://www.google.com/session/phone" - typedef struct { char *id; char *initiator; @@ -213,9 +210,9 @@ xmlnode_insert_child(iq->node, sess); desc = xmlnode_new_child(sess, "description"); if (session->video) - xmlnode_set_namespace(desc, NS_GOOGLE_VIDEO); + xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO); else - xmlnode_set_namespace(desc, NS_GOOGLE_PHONE); + xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE); codecs = purple_media_get_codecs(media, "google-video"); @@ -248,7 +245,7 @@ purple_media_codec_get_clock_rate(codec)); payload = xmlnode_new_child(desc, "payload-type"); if (session->video) - xmlnode_set_namespace(payload, NS_GOOGLE_PHONE); + xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE); xmlnode_set_attrib(payload, "id", id); /* * Hack to make Gmail accept speex as the codec. @@ -439,9 +436,9 @@ desc_element = xmlnode_get_child(sess, "description"); xmlns = xmlnode_get_namespace(desc_element); - if (purple_strequal(xmlns, NS_GOOGLE_PHONE)) + if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) session->video = FALSE; - else if (purple_strequal(xmlns, NS_GOOGLE_VIDEO)) + else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) session->video = TRUE; else { purple_debug_error("jabber", "Received initiate with " @@ -498,7 +495,7 @@ id = xmlnode_get_attrib(codec_element, "id"); if (!session->video || - (xmlns && !strcmp(xmlns, NS_GOOGLE_PHONE))) { + (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) { clock_rate = xmlnode_get_attrib( codec_element, "clockrate"); video = FALSE; @@ -623,7 +620,7 @@ GList *codecs = NULL, *video_codecs = NULL; JabberIq *result = NULL; const gchar *xmlns = xmlnode_get_namespace(desc_element); - gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_VIDEO)); + gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO)); for (; codec_element; codec_element = codec_element->next) { const gchar *xmlns, *encoding_name, *id, @@ -637,7 +634,7 @@ encoding_name = xmlnode_get_attrib(codec_element, "name"); id = xmlnode_get_attrib(codec_element, "id"); - if (!video || purple_strequal(xmlns, NS_GOOGLE_PHONE)) + if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) clock_rate = xmlnode_get_attrib( codec_element, "clockrate"); else { @@ -1401,7 +1398,7 @@ xmlnode *packet, gpointer data) { xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", - GOOGLE_JINGLE_INFO_NAMESPACE); + NS_GOOGLE_JINGLE_INFO); if (query) jabber_google_jingle_info_common(js, from, type, query); @@ -1421,7 +1418,7 @@ jabber_google_send_jingle_info(JabberStream *js) { JabberIq *jingle_info = - jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE); + jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_JINGLE_INFO); jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, NULL);
--- a/libpurple/protocols/jabber/google.h Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/google.h Thu Nov 26 22:35:07 2009 +0000 @@ -25,11 +25,6 @@ * such that they don't intermingle with code for the XMPP RFCs and XEPs :) */ #include "jabber.h" -#include "media.h" - -#define GOOGLE_VOICE_CAP "http://www.google.com/xmpp/protocol/voice/v1" -#define GOOGLE_VIDEO_CAP "http://www.google.com/xmpp/protocol/video/v1" -#define GOOGLE_JINGLE_INFO_NAMESPACE "google:jingleinfo" #define GOOGLE_GROUPCHAT_SERVER "groupchat.google.com"
--- a/libpurple/protocols/jabber/ibb.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/ibb.c Thu Nov 26 22:35:07 2009 +0000 @@ -228,7 +228,7 @@ gchar block_size[10]; xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess)); - xmlnode_set_namespace(open, XEP_0047_NAMESPACE); + xmlnode_set_namespace(open, NS_IBB); xmlnode_set_attrib(open, "sid", jabber_ibb_session_get_sid(sess)); g_snprintf(block_size, sizeof(block_size), "%" G_GSIZE_FORMAT, jabber_ibb_session_get_block_size(sess)); @@ -256,7 +256,7 @@ xmlnode *close = xmlnode_new("close"); xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess)); - xmlnode_set_namespace(close, XEP_0047_NAMESPACE); + xmlnode_set_namespace(close, NS_IBB); xmlnode_set_attrib(close, "sid", jabber_ibb_session_get_sid(sess)); xmlnode_insert_child(set->node, close); jabber_iq_send(set); @@ -333,7 +333,7 @@ g_snprintf(seq, sizeof(seq), "%u", jabber_ibb_session_get_send_seq(sess)); xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess)); - xmlnode_set_namespace(data_element, XEP_0047_NAMESPACE); + xmlnode_set_namespace(data_element, NS_IBB); xmlnode_set_attrib(data_element, "sid", jabber_ibb_session_get_sid(sess)); xmlnode_set_attrib(data_element, "seq", seq); xmlnode_insert_data(data_element, base64, -1); @@ -507,11 +507,11 @@ { jabber_ibb_sessions = g_hash_table_new(g_str_hash, g_str_equal); - jabber_add_feature(XEP_0047_NAMESPACE, NULL); + jabber_add_feature(NS_IBB, NULL); - jabber_iq_register_handler("close", XEP_0047_NAMESPACE, jabber_ibb_parse); - jabber_iq_register_handler("data", XEP_0047_NAMESPACE, jabber_ibb_parse); - jabber_iq_register_handler("open", XEP_0047_NAMESPACE, jabber_ibb_parse); + jabber_iq_register_handler("close", NS_IBB, jabber_ibb_parse); + jabber_iq_register_handler("data", NS_IBB, jabber_ibb_parse); + jabber_iq_register_handler("open", NS_IBB, jabber_ibb_parse); } void
--- a/libpurple/protocols/jabber/ibb.h Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/ibb.h Thu Nov 26 22:35:07 2009 +0000 @@ -24,8 +24,6 @@ #include "jabber.h" #include "iq.h" -#define XEP_0047_NAMESPACE "http://jabber.org/protocol/ibb" - typedef struct _JabberIBBSession JabberIBBSession; typedef void
--- a/libpurple/protocols/jabber/iq.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/iq.c Thu Nov 26 22:35:07 2009 +0000 @@ -462,8 +462,8 @@ jabber_gmail_poke); jabber_iq_register_handler("new-mail", "google:mail:notify", jabber_gmail_poke); - jabber_iq_register_handler("ping", "urn:xmpp:ping", jabber_ping_parse); - jabber_iq_register_handler("query", GOOGLE_JINGLE_INFO_NAMESPACE, + 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_bytestreams_parse);
--- a/libpurple/protocols/jabber/jabber.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Thu Nov 26 22:35:07 2009 +0000 @@ -2835,7 +2835,7 @@ return FALSE; } - if (jabber_resource_has_capability(jbr, XEP_0224_NAMESPACE)) { + if (jabber_resource_has_capability(jbr, NS_ATTENTION)) { xmlnode *buzz, *msg = xmlnode_new("message"); gchar *to; @@ -2847,7 +2847,7 @@ xmlnode_set_attrib(msg, "type", "headline"); buzz = xmlnode_new_child(msg, "attention"); - xmlnode_set_namespace(buzz, XEP_0224_NAMESPACE); + xmlnode_set_namespace(buzz, NS_ATTENTION); jabber_send(js, msg); xmlnode_free(msg); @@ -3012,8 +3012,7 @@ if (type & PURPLE_MEDIA_AUDIO && !jabber_resource_has_capability(jbr, JINGLE_APP_RTP_SUPPORT_AUDIO) && - jabber_resource_has_capability(jbr, - GOOGLE_VOICE_CAP)) + jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) return jabber_google_session_initiate(js, who, type); else return jingle_rtp_initiate_media(js, who, type); @@ -3182,10 +3181,9 @@ caps |= PURPLE_MEDIA_CAPS_MODIFY_SESSION | PURPLE_MEDIA_CAPS_CHANGE_DIRECTION; } - if (jabber_resource_has_capability(jbr, GOOGLE_VOICE_CAP)) { + if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) { caps |= PURPLE_MEDIA_CAPS_AUDIO; - if (jabber_resource_has_capability(jbr, - GOOGLE_VIDEO_CAP)) + if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO)) caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO; } return caps; @@ -3263,8 +3261,7 @@ "http://jabber.org/protocol/si/profile/file-transfer") && (jabber_resource_has_capability(jbr, "http://jabber.org/protocol/bytestreams") - || jabber_resource_has_capability(jbr, - XEP_0047_NAMESPACE))) { + || jabber_resource_has_capability(jbr, NS_IBB))) { return TRUE; } } @@ -3485,28 +3482,28 @@ 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("http://jabber.org/protocol/ibb", 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("urn:xmpp:ping", 0); + jabber_add_feature(NS_PING, 0); /* Buzz/Attention */ - jabber_add_feature(XEP_0224_NAMESPACE, jabber_buzz_isenabled); + jabber_add_feature(NS_ATTENTION, jabber_buzz_isenabled); /* Bits Of Binary */ - jabber_add_feature(XEP_0231_NAMESPACE, 0); + jabber_add_feature(NS_BOB, 0); /* Jingle features! */ jabber_add_feature(JINGLE, 0); #ifdef USE_VV - jabber_add_feature("http://www.google.com/xmpp/protocol/session", jabber_audio_enabled); - jabber_add_feature("http://www.google.com/xmpp/protocol/voice/v1", jabber_audio_enabled); - jabber_add_feature("http://www.google.com/xmpp/protocol/video/v1", jabber_video_enabled); - jabber_add_feature("http://www.google.com/xmpp/protocol/camera/v1", jabber_video_enabled); + jabber_add_feature(NS_GOOGLE_SESSION, jabber_audio_enabled); + jabber_add_feature(NS_GOOGLE_VOICE, jabber_audio_enabled); + jabber_add_feature(NS_GOOGLE_VIDEO, jabber_video_enabled); + jabber_add_feature(NS_GOOGLE_CAMERA, jabber_video_enabled); jabber_add_feature(JINGLE_APP_RTP, 0); jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, jabber_audio_enabled); jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, jabber_video_enabled);
--- a/libpurple/protocols/jabber/jabber.h Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.h Thu Nov 26 22:35:07 2009 +0000 @@ -64,6 +64,8 @@ #include "roomlist.h" #include "sslconn.h" +#include "namespaces.h" + #include "iq.h" #include "jutil.h" #include "xmlnode.h"
--- a/libpurple/protocols/jabber/message.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/message.c Thu Nov 26 22:35:07 2009 +0000 @@ -460,7 +460,7 @@ jabber_message_add_remote_smileys(const xmlnode *message) { xmlnode *data_tag; - for (data_tag = xmlnode_get_child_with_namespace(message, "data", XEP_0231_NAMESPACE) ; + for (data_tag = xmlnode_get_child_with_namespace(message, "data", NS_BOB) ; data_tag ; data_tag = xmlnode_get_next_twin(data_tag)) { const gchar *cid = xmlnode_get_attrib(data_tag, "cid"); @@ -740,7 +740,7 @@ jm->type = JABBER_MESSAGE_EVENT; for(items = xmlnode_get_child(child,"items"); items; items = items->next) jm->eventitems = g_list_append(jm->eventitems, items); - } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, XEP_0224_NAMESPACE)) { + } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, NS_ATTENTION)) { jm->hasBuzz = TRUE; } else if(!strcmp(child->name, "delay") && !strcmp(xmlns,"urn:xmpp:delay")) { const char *timestamp = xmlnode_get_attrib(child, "stamp"); @@ -946,7 +946,7 @@ case PURPLE_CONV_TYPE_IM: jb = jabber_buddy_find(js, who, FALSE); if (jb) { - return jabber_buddy_has_capability(jb, XEP_0231_NAMESPACE); + return jabber_buddy_has_capability(jb, NS_BOB); } else { return FALSE; } @@ -958,7 +958,7 @@ 10 people, to avoid getting too many BoB requests */ return jabber_chat_get_num_participants(chat) <= 10 && jabber_chat_all_participants_have_capability(chat, - XEP_0231_NAMESPACE); + NS_BOB); } else { return FALSE; }
--- a/libpurple/protocols/jabber/message.h Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/message.h Thu Nov 26 22:35:07 2009 +0000 @@ -28,8 +28,6 @@ #include "jabber.h" #include "xmlnode.h" -#define XEP_0224_NAMESPACE "urn:xmpp:attention:0" - typedef struct _JabberMessage { JabberStream *js; enum {
--- a/libpurple/protocols/jabber/ping.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/ping.c Thu Nov 26 22:35:07 2009 +0000 @@ -74,7 +74,7 @@ iq = jabber_iq_new(js, JABBER_IQ_GET); ping = xmlnode_new_child(iq->node, "ping"); - xmlnode_set_namespace(ping, "urn:xmpp:ping"); + xmlnode_set_namespace(ping, NS_PING); jabber_iq_set_callback(iq, jabber_keepalive_pong_cb, NULL); jabber_iq_send(iq); @@ -90,7 +90,7 @@ xmlnode_set_attrib(iq->node, "to", jid); ping = xmlnode_new_child(iq->node, "ping"); - xmlnode_set_namespace(ping, "urn:xmpp:ping"); + xmlnode_set_namespace(ping, NS_PING); jabber_iq_set_callback(iq, jabber_ping_result_cb, NULL); jabber_iq_send(iq);
--- a/libpurple/protocols/jabber/si.c Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/si.c Thu Nov 26 22:35:07 2009 +0000 @@ -1210,7 +1210,7 @@ jabber_si_xfer_bytestreams_send_init(xfer); jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; found_method = TRUE; - } else if (val && !strcmp(val, XEP_0047_NAMESPACE)) { + } else if (val && !strcmp(val, NS_IBB)) { jsx->stream_method |= STREAM_METHOD_IBB; if (!found_method) { /* we haven't tried to init a bytestream session, yet @@ -1452,7 +1452,7 @@ if (jbr) { char *msg; - if (jabber_resource_has_capability(jbr, XEP_0047_NAMESPACE)) + if (jabber_resource_has_capability(jbr, NS_IBB)) jsx->stream_method |= STREAM_METHOD_IBB; if (jabber_resource_has_capability(jbr, "http://jabber.org/protocol/si/profile/file-transfer")) { jabber_si_xfer_send_request(xfer);
--- a/libpurple/protocols/jabber/useravatar.h Thu Nov 26 19:47:39 2009 +0000 +++ b/libpurple/protocols/jabber/useravatar.h Thu Nov 26 22:35:07 2009 +0000 @@ -29,12 +29,6 @@ /* Implementation of XEP-0084 */ -#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" - -#define NS_AVATAR_1_1_DATA "urn:xmpp:avatar:data" -#define NS_AVATAR_1_1_METADATA "urn:xmpp:avatar:metadata" - void jabber_avatar_init(void); void jabber_avatar_set(JabberStream *js, PurpleStoredImage *img);