cpw.darkrain42.xmpp.bosh: da702f88: Entity Capabilities must be per-JabberSt...

paul at darkrain42.org paul at darkrain42.org
Sat Jan 17 23:56:51 EST 2009


-----------------------------------------------------------------
Revision: da702f886f1200f900bee02d615b4588ba021589
Ancestor: 6a0655f6e6ee12ccc2502829134b86662f3bf9c6
Author: paul at darkrain42.org
Date: 2008-11-21T00:35:44
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/da702f886f1200f900bee02d615b4588ba021589

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/presence.c

ChangeLog: 

Entity Capabilities must be per-JabberStream

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	5b626ca36f99f9c61c4a02b8648944f2e726c319
+++ libpurple/protocols/jabber/caps.c	f311a1db924ae3f3c6c682f1b306e6d9c0ff47e0
@@ -32,7 +32,6 @@ GHashTable *capstable = NULL; /* JabberC
 #define JABBER_CAPS_FILENAME "xmpp-caps.xml"
 
 GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsValue */
-static gchar *caps_hash = NULL;
 
 #if 0
 typedef struct _JabberCapsValue {
@@ -853,14 +852,19 @@ void jabber_caps_calculate_own_hash(Jabb
 	info->identities = jabber_identities;
 	info->forms = 0;
 	
-	if (caps_hash) g_free(caps_hash);
-	caps_hash = jabber_caps_calculate_hash(info, "sha1");
+	if (js->caps_hash)
+		g_free(js->caps_hash);
+	js->caps_hash = jabber_caps_calculate_hash(info, "sha1");
 	g_free(info);
 	g_list_free(features);
 }
 
-const gchar* jabber_caps_get_own_hash() {
-	return caps_hash;
+const gchar* jabber_caps_get_own_hash(JabberStream *js)
+{
+	if (!js->caps_hash)
+		jabber_caps_calculate_own_hash(js);
+
+	return js->caps_hash;
 }
 
 void jabber_caps_broadcast_change() {
============================================================
--- libpurple/protocols/jabber/caps.h	8d3932473e0e673b040137f43bcf275d4dca521a
+++ libpurple/protocols/jabber/caps.h	7dce8ca9f4d56119c2ccd3fb474693bc538b19b3
@@ -89,7 +89,7 @@ void jabber_caps_calculate_own_hash(Jabb
 /** Get the current caps hash.
  * 	@ret hash
 **/
-const gchar* jabber_caps_get_own_hash(void);
+const gchar* jabber_caps_get_own_hash(JabberStream *js);
 
 /**
  *  Broadcast a new calculated hash using a <presence> stanza.
============================================================
--- libpurple/protocols/jabber/disco.c	4bf59bce2e3d4d1fb99d747d8e16ad62f320ee0d
+++ libpurple/protocols/jabber/disco.c	5780a5e11050b0bf71ec9b88ef7bcb9491326f39
@@ -100,7 +100,7 @@ void jabber_disco_info_parse(JabberStrea
 		char *node_uri = NULL;
 		
 		// create custom caps node URI
-		node_uri = g_strconcat(CAPS0115_NODE, "#", jabber_caps_get_own_hash(), NULL);
+		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");
============================================================
--- libpurple/protocols/jabber/jabber.c	586480e6466228d724430f8d5360880c84903048
+++ libpurple/protocols/jabber/jabber.c	b2a3be597ea57a78fc8c0d84c566fc738620288e
@@ -1390,6 +1390,7 @@ void jabber_close(PurpleConnection *gc)
 	if(js->user)
 		jabber_id_free(js->user);
 	g_free(js->avatar_hash);
+	g_free(js->caps_hash);
 
 	purple_circ_buffer_destroy(js->write_buffer);
 	if(js->writeh)
@@ -2540,7 +2541,7 @@ void jabber_register_commands(void)
 					  _("buzz: Buzz a user to get their attention"), NULL);
 }
 
-/* IPC fucntions*/
+/* IPC functions*/
 
 /*
  * IPC function for checking wheather a client at a full JID supports a certain feature.
============================================================
--- libpurple/protocols/jabber/jabber.h	22f47b9efbc1a1013b7bb8c0cb25ec33e0c27ac2
+++ libpurple/protocols/jabber/jabber.h	cb6ec6c7d61abbf7f8e51230ed20a12cdb0f489c
@@ -206,6 +206,9 @@ struct _JabberStream
 	
 	gboolean vcard_fetched;
 
+	/* Entity Capabilities hash */
+	char *caps_hash;
+
 	/* does the local server support PEP? */
 	gboolean pep;
 
============================================================
--- libpurple/protocols/jabber/presence.c	76178b842b9c0139299bec49d14a744fff84027a
+++ libpurple/protocols/jabber/presence.c	5956307bffa04bd8c71f10a7ce181436ae6b5667
@@ -268,7 +268,7 @@ xmlnode *jabber_presence_create_js(Jabbe
 	xmlnode_set_namespace(c, "http://jabber.org/protocol/caps");
 	xmlnode_set_attrib(c, "node", CAPS0115_NODE);
 	xmlnode_set_attrib(c, "hash", "sha-1");
-	xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash());
+	xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash(js));
 
 #if 0
 	if(js != NULL) {


More information about the Commits mailing list