# HG changeset patch # User Paul Aurich # Date 1227227744 0 # Node ID 4040da08a733d5a1e45ae8069ce8ea1a9b1d14e1 # Parent 1225f3dcf5ab329649992971457be4ab1b8ade90 Entity Capabilities must be per-JabberStream diff -r 1225f3dcf5ab -r 4040da08a733 libpurple/protocols/jabber/caps.c --- a/libpurple/protocols/jabber/caps.c Thu Nov 20 23:58:17 2008 +0000 +++ b/libpurple/protocols/jabber/caps.c Fri Nov 21 00:35:44 2008 +0000 @@ -32,7 +32,6 @@ #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 @@ 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() { diff -r 1225f3dcf5ab -r 4040da08a733 libpurple/protocols/jabber/caps.h --- a/libpurple/protocols/jabber/caps.h Thu Nov 20 23:58:17 2008 +0000 +++ b/libpurple/protocols/jabber/caps.h Fri Nov 21 00:35:44 2008 +0000 @@ -89,7 +89,7 @@ /** 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 stanza. diff -r 1225f3dcf5ab -r 4040da08a733 libpurple/protocols/jabber/disco.c --- a/libpurple/protocols/jabber/disco.c Thu Nov 20 23:58:17 2008 +0000 +++ b/libpurple/protocols/jabber/disco.c Fri Nov 21 00:35:44 2008 +0000 @@ -100,7 +100,7 @@ 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"); diff -r 1225f3dcf5ab -r 4040da08a733 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Thu Nov 20 23:58:17 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.c Fri Nov 21 00:35:44 2008 +0000 @@ -1390,6 +1390,7 @@ 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 @@ _("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. diff -r 1225f3dcf5ab -r 4040da08a733 libpurple/protocols/jabber/jabber.h --- a/libpurple/protocols/jabber/jabber.h Thu Nov 20 23:58:17 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.h Fri Nov 21 00:35:44 2008 +0000 @@ -206,6 +206,9 @@ gboolean vcard_fetched; + /* Entity Capabilities hash */ + char *caps_hash; + /* does the local server support PEP? */ gboolean pep; diff -r 1225f3dcf5ab -r 4040da08a733 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Thu Nov 20 23:58:17 2008 +0000 +++ b/libpurple/protocols/jabber/presence.c Fri Nov 21 00:35:44 2008 +0000 @@ -268,7 +268,7 @@ 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) {