soc.2008.xmpp: 11fbf67a: Removing short-names for features and ca...

tfar at soc.pidgin.im tfar at soc.pidgin.im
Mon Jun 16 10:00:50 EDT 2008


-----------------------------------------------------------------
Revision: 11fbf67ad3ffe9ffc3c549950d226662a1e315cf
Ancestor: 9e2358867e786b26132017b225710d5c9d230c5a
Author: tfar at soc.pidgin.im
Date: 2008-06-16T13:52:45
Branch: im.pidgin.soc.2008.xmpp
URL: http://d.pidgin.im/viewmtn/revision/info/11fbf67ad3ffe9ffc3c549950d226662a1e315cf

Modified files:
        libpurple/protocols/jabber/caps.c
        libpurple/protocols/jabber/caps.h
        libpurple/protocols/jabber/disco.c
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/jabber.h
        libpurple/protocols/jabber/libxmpp.c
        libpurple/protocols/jabber/message.c
        libpurple/protocols/jabber/message.h
        libpurple/protocols/jabber/pep.c
        libpurple/protocols/jabber/pep.h
        libpurple/protocols/jabber/presence.c
        libpurple/protocols/jabber/usermood.c
        libpurple/protocols/jabber/usernick.c
        libpurple/protocols/jabber/usertune.c

ChangeLog: 

Removing short-names for features and calculating own caps hash.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	ce2b1c9933e7c617f55ff2da3801ada27fcb0c36
+++ libpurple/protocols/jabber/caps.c	cd4966b0100aaf98589103883ad4c342e58ee949
@@ -21,7 +21,9 @@
 
 #include "internal.h"
 
+#include <glib.h>
 #include "caps.h"
+#include "cipher.h"
 #include <string.h>
 #include "internal.h"
 #include "util.h"
@@ -30,6 +32,7 @@ static GHashTable *capstable = NULL; /* 
 #define JABBER_CAPS_FILENAME "xmpp-caps.xml"
 
 static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsValue */
+static gchar *caps_hash = NULL;
 
 typedef struct _JabberCapsKey {
 	char *node;
@@ -111,6 +114,7 @@ void jabber_caps_init(void) {
 void jabber_caps_init(void) {
 	capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, jabber_caps_destroy_value);
 	jabber_caps_load();
+	jabber_caps_calculate_hash();
 }
 
 static void jabber_caps_load(void) {
@@ -499,7 +503,6 @@ void jabber_caps_get_info(JabberStream *
 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *ext, jabber_caps_get_info_cb cb, gpointer user_data) {
 	JabberCapsValue *client;
 	JabberCapsKey *key = g_new0(JabberCapsKey, 1);
-	char *originalext = g_strdup(ext);
 	jabber_caps_cbplususerdata *userdata = g_new0(jabber_caps_cbplususerdata, 1);
 	userdata->cb = cb;
 	userdata->user_data = user_data;
@@ -507,17 +510,6 @@ void jabber_caps_get_info(JabberStream *
 	userdata->node = g_strdup(node);
 	userdata->ver = g_strdup(ver);
 
-	if(originalext) {
-		int i;
-		gchar **splat = g_strsplit(originalext, " ", 0);
-		for(i =0; splat[i]; i++) {
-			userdata->ext = g_list_append(userdata->ext, splat[i]);
-			++userdata->extOutstanding;
-		}
-		g_free(splat);
-	}
-	g_free(originalext);
-
 	key->node = (char *)node;
 	key->ver = (char *)ver;
 
@@ -570,3 +562,95 @@ void jabber_caps_get_info(JabberStream *
 	}
 }
 
+static gint jabber_caps_jabber_identity_compare(gconstpointer a, gconstpointer b) {
+	const JabberIdentity *ac;
+	const JabberIdentity *bc;
+	gint cat_cmp;
+	
+	ac = a;
+	bc = b;
+	
+	if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
+		return strcmp(ac->type, bc->type);
+	} else {
+		return cat_cmp;
+	}
+}
+
+static gint jabber_caps_jabber_feature_compare(gconstpointer a, gconstpointer b) {
+	const JabberFeature *ac;
+	const JabberFeature *bc;
+	
+	ac = a;
+	bc = b;
+	
+	return strcmp(ac->namespace, bc->namespace);
+}
+
+
+void jabber_caps_calculate_hash() {
+	gchar *verification = 0;
+	gchar *free_verification;
+	gchar *identity_string, *feature_string;
+	GList *identities, *features;
+	PurpleCipherContext *context;
+	guint8 checksum[20];
+	gsize checksum_size = 20;
+
+	/* sort identities */
+	jabber_identities = g_list_sort(jabber_identities, jabber_caps_jabber_identity_compare);
+	
+	/* concat identities to the verification string */
+	for(identities = jabber_identities; identities; identities = identities->next) {
+		JabberIdentity *ident = (JabberIdentity*)identities->data;
+		identity_string = g_strdup_printf("%s/%s//%s<", ident->category, ident->type, ident->name);
+		free_verification = verification;
+		if(verification == 0) verification = g_strdup(identity_string);
+		 	else verification = g_strconcat(verification, identity_string, NULL);
+		g_free(identity_string);
+		if(free_verification) g_free(free_verification);
+	}
+	
+	/* sort features */
+	jabber_features = g_list_sort(jabber_features, jabber_caps_jabber_feature_compare);
+	
+	/* concat features to the verification string */
+	for(features = jabber_features; features; features = features->next) {
+		JabberFeature *feat = (JabberFeature*)features->data;
+		feature_string = g_strdup_printf("%s<", feat->namespace);
+		free_verification = verification;
+		if(verification == 0) g_strdup(feature_string);
+			else verification = g_strconcat(verification, feature_string, NULL);
+		g_free(feature_string);
+		if(free_verification) g_free(free_verification);
+	}
+	printf("\n%s", verification);
+	
+	
+	/* generate SHA-1 hash */
+	context = purple_cipher_context_new_by_name("sha1", NULL);
+	if (context == NULL) {
+		purple_debug_error("jabber", "Could not find sha1 cipher\n");
+		return;
+	}
+	purple_cipher_context_append(context, verification, strlen(verification));
+	
+	if (!purple_cipher_context_digest(context, strlen(verification), checksum, &checksum_size)) {
+		purple_debug_error("util", "Failed to get SHA-1 digest.\n");
+	}
+	purple_cipher_context_destroy(context);
+	
+	/* apply Base64 on hash */
+	
+	g_free(verification);
+	verification = purple_base64_encode(checksum, checksum_size); // for 2.0 compability
+	printf("\n%s", verification);
+	
+	if (caps_hash != 0) g_free(caps_hash);
+	caps_hash = verification;
+}
+
+const gchar* jabber_caps_get_hash() {
+	return caps_hash;
+}
+
============================================================
--- libpurple/protocols/jabber/caps.h	54e06b19e06eab75e72c513e76a90644b8433318
+++ libpurple/protocols/jabber/caps.h	108ac08b4fb4e733d7b53796e588a94251b02def
@@ -46,4 +46,12 @@ void jabber_caps_free_clientinfo(JabberC
 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *ext, jabber_caps_get_info_cb cb, gpointer user_data);
 void jabber_caps_free_clientinfo(JabberCapsClientInfo *clientinfo);
 
+
+void jabber_caps_calculate_hash();
+
+/** Get the current caps hash.
+ * 	@ret hash
+**/
+const gchar* jabber_caps_get_hash();
+
 #endif /* _PURPLE_JABBER_CAPS_H_ */
============================================================
--- libpurple/protocols/jabber/disco.c	091b432ce26cf0eeed08aa0b0198e38098df1765
+++ libpurple/protocols/jabber/disco.c	9ed292e7e5bd84c7faf85c8e850164773b60ea85
@@ -79,7 +79,6 @@ void jabber_disco_info_parse(JabberStrea
 void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
 	const char *from = xmlnode_get_attrib(packet, "from");
 	const char *type = xmlnode_get_attrib(packet, "type");
-
 	if(!from || !type)
 		return;
 
@@ -89,6 +88,10 @@ void jabber_disco_info_parse(JabberStrea
 
 		xmlnode *in_query;
 		const char *node = NULL;
+		const char *node_uri = NULL;
+		
+		// create custom caps node URI
+		node_uri = g_strconcat(CAPS0115_NODE, "#", jabber_caps_get_hash(), NULL);
 
 		if((in_query = xmlnode_get_child(packet, "query"))) {
 			node = xmlnode_get_attrib(in_query, "node");
@@ -106,90 +109,38 @@ void jabber_disco_info_parse(JabberStrea
 		if(node)
 			xmlnode_set_attrib(query, "node", node);
 
-		if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) {
-			identity = xmlnode_new_child(query, "identity");
-			xmlnode_set_attrib(identity, "category", "client");
-			xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console,
-														 * handheld, pc, phone,
-														 * 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")
-#if 0
-				SUPPORT_FEATURE("http://jabber.org/protocol/ibb")
-#endif
-			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 *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->name != 0) xmlnode_set_attrib(identity, "name", ident->name);
 			}
+			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->namespace) == TRUE) {
+					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;
-				}
+			xmlnode *error, *inf;
 				
-				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;
-				}
-			}
+			/* XXX: gross hack, implement jabber_iq_set_type or something */
+			xmlnode_set_attrib(iq->node, "type", "error");
+			iq->type = JABBER_IQ_ERROR;
 			
-			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");
-			}
+			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");
============================================================
--- libpurple/protocols/jabber/jabber.c	cc3fd99cf97449784f8e06a850c9a705e34da3bd
+++ libpurple/protocols/jabber/jabber.c	3863113a86a04b8c154c5969c31851f812dc70f7
@@ -60,7 +60,9 @@ static PurplePlugin *my_protocol = NULL;
 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5)
 
 static PurplePlugin *my_protocol = NULL;
+
 GList *jabber_features = NULL;
+GList *jabber_identities = NULL;
 
 static void jabber_unregister_account_cb(JabberStream *js);
 
@@ -1394,31 +1396,27 @@ void jabber_idle_set(PurpleConnection *g
 	js->idle = idle ? time(NULL) - idle : idle;
 }
 
-void jabber_add_feature(const char *shortname, const char *namespace, JabberFeatureEnabled cb) {
+void jabber_add_feature(const char *namespace, JabberFeatureEnabled cb) {
 	JabberFeature *feat;
 
-	g_return_if_fail(shortname != NULL);
 	g_return_if_fail(namespace != NULL);
 
 	feat = g_new0(JabberFeature,1);
-	feat->shortname = g_strdup(shortname);
 	feat->namespace = g_strdup(namespace);
 	feat->is_enabled = cb;
 	
 	/* try to remove just in case it already exists in the list */
-	jabber_remove_feature(shortname);
+	jabber_remove_feature(namespace);
 	
 	jabber_features = g_list_append(jabber_features, feat);
 }
 
-void jabber_remove_feature(const char *shortname) {
+void jabber_remove_feature(const char *namespace) {
 	GList *feature;
 	for(feature = jabber_features; feature; feature = feature->next) {
 		JabberFeature *feat = (JabberFeature*)feature->data;
-		if(!strcmp(feat->shortname, shortname)) {
-			g_free(feat->shortname);
+		if(!strcmp(feat->namespace, namespace)) {
 			g_free(feat->namespace);
-			
 			g_free(feature->data);
 			jabber_features = g_list_delete_link(jabber_features, feature);
 			break;
@@ -1426,6 +1424,27 @@ void jabber_remove_feature(const char *s
 	}
 }
 
+void jabber_add_identity(const gchar *category, const gchar *type, const gchar *name) {
+	GList *identity;
+	JabberIdentity *ident;
+	/* both required according to XEP-0030 */
+	g_return_if_fail(category != NULL);
+	g_return_if_fail(type != NULL);
+	
+	for(identity = jabber_identities; identity; identity = identity->next) {
+		JabberIdentity *ident = (JabberIdentity*)identity->data;
+		if(!strcmp(ident->category, category)) {
+			if (!strcmp(ident->type, type)) return;
+		}	
+	}
+	
+	ident = g_new0(JabberIdentity, 1);
+	ident->category = g_strdup(category);
+	ident->type = g_strdup(type);
+	ident->name = g_strdup(name);
+	jabber_identities = g_list_append(jabber_identities, ident);
+}
+
 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b)
 {
 	return "jabber";
@@ -2429,5 +2448,27 @@ jabber_init_plugin(PurplePlugin *plugin)
 void
 jabber_init_plugin(PurplePlugin *plugin)
 {
-        my_protocol = plugin;
+	my_protocol = plugin;
+
+	jabber_add_identity("client", "pc", PACKAGE);
+
+	// initialize jabber_features list
+	jabber_add_feature("jabber:iq:last", 0);
+	jabber_add_feature("jabber:iq:oob", 0);
+	jabber_add_feature("jabber:iq:time", 0);
+	jabber_add_feature("xmpp:urn: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("http://jabber.org/protocol/disco#info", 0);
+	jabber_add_feature("http://jabber.org/protocol/disco#items", 0);
+#if 0
+	jabber_add_feature("http://jabber.org/protocol/ibb", 0);
+#endif
+	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);
 }
============================================================
--- libpurple/protocols/jabber/jabber.h	9ac68a50935a4f775fff15e205e9dc61dff2843c
+++ libpurple/protocols/jabber/jabber.h	d660634ecff65c1c63cbf4daa2320dd72da6b760
@@ -203,15 +203,21 @@ struct _JabberStream
 	int keepalive_timeout;
 };
 
-typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *shortname, const gchar *namespace);
+typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *namespace);
 
 typedef struct _JabberFeature
 {
-	gchar *shortname;
 	gchar *namespace;
 	JabberFeatureEnabled *is_enabled;
 } JabberFeature;
 
+typedef struct _JabberIdentity
+{
+	gchar *category;
+	gchar *type;
+	gchar *name;
+} JabberIdentity;
+
 typedef struct _JabberBytestreamsStreamhost {
 	char *jid;
 	char *host;
@@ -221,6 +227,7 @@ extern GList *jabber_features;
 
 /* what kind of additional features as returned from disco#info are supported? */
 extern GList *jabber_features;
+extern GList *jabber_identities;
 
 void jabber_process_packet(JabberStream *js, xmlnode **packet);
 void jabber_send(JabberStream *js, xmlnode *data);
@@ -242,9 +249,17 @@ char *jabber_parse_error(JabberStream *j
  */
 char *jabber_parse_error(JabberStream *js, xmlnode *packet, PurpleConnectionError *reason);
 
-void jabber_add_feature(const gchar *shortname, const gchar *namespace, JabberFeatureEnabled cb); /* cb may be NULL */
-void jabber_remove_feature(const gchar *shortname);
+void jabber_add_feature(const gchar *namespace, JabberFeatureEnabled cb); /* cb may be NULL */
+void jabber_remove_feature(const gchar *namespace);
 
+/** Adds an identitiy to this jabber library instance. For list of valid values vistit the 
+ *	webiste of the XMPP Registrar ( http://www.xmpp.org/registrar/disco-categories.html#client ).
+ *  @param category the category of the identity.
+ *	@param type the type of the identity.
+ *	@param name the name of the identity.
+ */
+void jabber_add_identity(const gchar *category, const gchar *type, const gchar *name); 
+
 /** PRPL functions */
 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b);
 const char* jabber_list_emblem(PurpleBuddy *b);
============================================================
--- libpurple/protocols/jabber/libxmpp.c	b56db1a878a32e93e80e36ccaa343dc7422f18cf
+++ libpurple/protocols/jabber/libxmpp.c	e938d7e7ae486cab9c29e39b19a1986c6e5ede63
@@ -263,11 +263,13 @@ init_plugin(PurplePlugin *plugin)
 	jabber_tune_init();
 	jabber_caps_init();
 
-	jabber_add_feature("avatarmeta", AVATARNAMESPACEMETA, jabber_pep_namespace_only_when_pep_enabled_cb);
-	jabber_add_feature("avatardata", AVATARNAMESPACEDATA, jabber_pep_namespace_only_when_pep_enabled_cb);
-	jabber_add_feature("buzz", "http://www.xmpp.org/extensions/xep-0224.html#ns", jabber_buzz_isenabled);
+	#warning implement adding and retrieving own features via IPC API
+
+	jabber_add_feature(AVATARNAMESPACEMETA, jabber_pep_namespace_only_when_pep_enabled_cb);
+	jabber_add_feature(AVATARNAMESPACEDATA, jabber_pep_namespace_only_when_pep_enabled_cb);
+	jabber_add_feature("http://www.xmpp.org/extensions/xep-0224.html#ns", jabber_buzz_isenabled);
 	
-	jabber_pep_register_handler("avatar", AVATARNAMESPACEMETA, jabber_buddy_avatar_update_metadata);
+	jabber_pep_register_handler(AVATARNAMESPACEMETA, jabber_buddy_avatar_update_metadata);
 }
 
 
============================================================
--- libpurple/protocols/jabber/message.c	1cf8a8c3a5b3799261f1efa1d3888e3732063fb0
+++ libpurple/protocols/jabber/message.c	c201641f8aaec58256c0d9732c8ff08147b9f9a4
@@ -758,7 +758,7 @@ void jabber_message_conv_closed(JabberSt
 	jabber_message_free(jm);
 }
 
-gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *shortname, const gchar *namespace) {
+gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace) {
 	return js->allowBuzz;
 }
 
============================================================
--- libpurple/protocols/jabber/message.h	8de79d751c731eb68f6282872ae73f790de60789
+++ libpurple/protocols/jabber/message.h	d3c05f9d241341c1a1471f6ef5b80094f794ee79
@@ -78,6 +78,6 @@ void jabber_message_conv_closed(JabberSt
 unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state);
 void jabber_message_conv_closed(JabberStream *js, const char *who);
 
-gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *shortname, const gchar *namespace);
+gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace);
 
 #endif /* _PURPLE_JABBER_MESSAGE_H_ */
============================================================
--- libpurple/protocols/jabber/pep.c	e23f33cb18be2ecd93000dc2c56fc51ec2efbee5
+++ libpurple/protocols/jabber/pep.c	253a88c5dd79f299f7ec2b69e8e6d4ffd80524e9
@@ -45,9 +45,9 @@ void jabber_pep_init_actions(GList **m) 
 	jabber_nick_init_action(m);
 }
 
-void jabber_pep_register_handler(const char *shortname, const char *xmlns, JabberPEPHandler handlerfunc) {
+void jabber_pep_register_handler(const char *xmlns, JabberPEPHandler handlerfunc) {
 	gchar *notifyns = g_strdup_printf("%s+notify", xmlns);
-	jabber_add_feature(shortname, notifyns, NULL); /* receiving PEPs is always supported */
+	jabber_add_feature(notifyns, NULL); /* receiving PEPs is always supported */
 	g_free(notifyns);
 	g_hash_table_replace(pep_handlers, g_strdup(xmlns), handlerfunc);
 }
@@ -85,7 +85,7 @@ void jabber_pep_request_item(JabberStrea
 	jabber_iq_send(iq);
 }
 
-gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *shortname, const gchar *namespace) {
+gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *namespace) {
 	return js->pep;
 }
 
============================================================
--- libpurple/protocols/jabber/pep.h	9d0e2298f38126dcf5e549482a0d09672e195498
+++ libpurple/protocols/jabber/pep.h	17aebaccfe8893f115e5b36b0cccef8c18db154d
@@ -42,11 +42,10 @@ typedef void (JabberPEPHandler)(JabberSt
  * Registers a callback for PEP events. Also automatically announces this receiving capability via disco#info.
  * Don't forget to use jabber_add_feature when supporting the sending of PEP events of this type.
  *
- * @parameter shortname		A short name for this feature for XEP-0115. It has no semantic meaning, it just has to be unique.
- * @parameter xmlns		The namespace for this event
+ * @parameter xmlns			The namespace for this event
  * @parameter handlerfunc	The callback to be used when receiving an event with this namespace
  */
-void jabber_pep_register_handler(const char *shortname, const char *xmlns, JabberPEPHandler handlerfunc);
+void jabber_pep_register_handler(const char *xmlns, JabberPEPHandler handlerfunc);
 
 /*
  * Request a specific item from another PEP node.
@@ -64,13 +63,12 @@ void jabber_pep_request_item(JabberStrea
 /*
  * Default callback that can be used for namespaces which should only be enabled when PEP is supported
  *
- * @parameter js	The JabberStream struct for this connection
- * @parameter shortname	The namespace's shortname (for caps), ignored.
+ * @parameter js		The JabberStream struct for this connection
  * @parameter namespace The namespace that's queried, ignored.
  *
  * @returns TRUE when PEP is enabled, FALSE otherwise
  */
-gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *shortname, const gchar *namespace);
+gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *namespace);
 
 void jabber_handle_event(JabberMessage *jm);
 
============================================================
--- libpurple/protocols/jabber/presence.c	969cd4281c60264367322996c483c2695daffa61
+++ libpurple/protocols/jabber/presence.c	8153fc3bf0331f9de06b3c7940c1259485f4268b
@@ -264,8 +264,10 @@ xmlnode *jabber_presence_create_js(Jabbe
 	c = xmlnode_new_child(presence, "c");
 	xmlnode_set_namespace(c, "http://jabber.org/protocol/caps");
 	xmlnode_set_attrib(c, "node", CAPS0115_NODE);
-	xmlnode_set_attrib(c, "ver", VERSION);
-	
+	xmlnode_set_attrib(c, "hash", "sha-1");
+	xmlnode_set_attrib(c, "ver", jabber_caps_get_hash());
+
+#if 0
 	if(js != NULL) {
 		/* add the extensions */
 		char extlist[1024];
@@ -277,7 +279,7 @@ xmlnode *jabber_presence_create_js(Jabbe
 			JabberFeature *feat = (JabberFeature*)feature->data;
 			unsigned featlen;
 			
-			if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE)
+			if(feat->is_enabled != NULL && feat->is_enabled(js, feat->namespace) == FALSE)
 				continue; /* skip this feature */
 			
 			featlen = strlen(feat->shortname);
@@ -297,7 +299,7 @@ xmlnode *jabber_presence_create_js(Jabbe
 		if(remaining < 1023)
 			xmlnode_set_attrib(c, "ext", extlist);
 	}
-	
+#endif
 	return presence;
 }
 
============================================================
--- libpurple/protocols/jabber/usermood.c	a5f486606cd6c1400ac958b09919bfc0780578ce
+++ libpurple/protocols/jabber/usermood.c	bb8afb5dfab589d41c1d62390cd637c756d3f4a5
@@ -141,8 +141,8 @@ void jabber_mood_init(void) {
 }
 
 void jabber_mood_init(void) {
-	jabber_add_feature("mood", "http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb);
-	jabber_pep_register_handler("moodn", "http://jabber.org/protocol/mood", jabber_mood_cb);
+	jabber_add_feature("http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb);
+	jabber_pep_register_handler("http://jabber.org/protocol/mood", jabber_mood_cb);
 }
 
 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) {
============================================================
--- libpurple/protocols/jabber/usernick.c	e0e09357277521664d7f14ecf84033d6e84aa564
+++ libpurple/protocols/jabber/usernick.c	6895e8effa282270898018d2e0494c544fcf3fc9
@@ -92,8 +92,8 @@ void jabber_nick_init(void) {
 }
 
 void jabber_nick_init(void) {
-	jabber_add_feature("nick", "http://jabber.org/protocol/nick", jabber_pep_namespace_only_when_pep_enabled_cb);
-	jabber_pep_register_handler("nickn", "http://jabber.org/protocol/nick", jabber_nick_cb);
+	jabber_add_feature("http://jabber.org/protocol/nick", jabber_pep_namespace_only_when_pep_enabled_cb);
+	jabber_pep_register_handler("http://jabber.org/protocol/nick", jabber_nick_cb);
 }
 
 void jabber_nick_init_action(GList **m) {
============================================================
--- libpurple/protocols/jabber/usertune.c	93238d3049ccd7895d225f13dfb808b8d6c0f2f6
+++ libpurple/protocols/jabber/usertune.c	431989ab6eb627830fd9d2442b48a9b9749f8d7c
@@ -109,8 +109,8 @@ void jabber_tune_init(void) {
 }
 
 void jabber_tune_init(void) {
-	jabber_add_feature("tune", "http://jabber.org/protocol/tune", jabber_pep_namespace_only_when_pep_enabled_cb);
-	jabber_pep_register_handler("tunen", "http://jabber.org/protocol/tune", jabber_tune_cb);
+	jabber_add_feature("http://jabber.org/protocol/tune", jabber_pep_namespace_only_when_pep_enabled_cb);
+	jabber_pep_register_handler("http://jabber.org/protocol/tune", jabber_tune_cb);
 }
 
 void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo) {


More information about the Commits mailing list