soc.2008.xmpp: 1641961a: * fixing a bug in jabber_caps_compare()

tfar at soc.pidgin.im tfar at soc.pidgin.im
Sun Jul 6 17:16:30 EDT 2008


-----------------------------------------------------------------
Revision: 1641961a876037d80ff7baac077c2c8959e19d43
Ancestor: 07105106d9c17d65a16e0516e1348dc644df9937
Author: tfar at soc.pidgin.im
Date: 2008-07-06T18:51:26
Branch: im.pidgin.soc.2008.xmpp
URL: http://d.pidgin.im/viewmtn/revision/info/1641961a876037d80ff7baac077c2c8959e19d43

Modified files:
        libpurple/protocols/jabber/caps.c
        libpurple/protocols/jabber/caps.h
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/jabber.h

ChangeLog: 

* fixing a bug in jabber_caps_compare()
* preparing contact capabilities lookup functionality

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	eab7c3ab8139e1bf3494fcdf8e4c8ccaba0acbdf
+++ libpurple/protocols/jabber/caps.c	d7820b8d81d836f09792255aa1ed77a179e4de4b
@@ -34,12 +34,6 @@ static gchar *caps_hash = NULL;
 static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsValue */
 static gchar *caps_hash = NULL;
 
-typedef struct _JabberCapsKey {
-	char *node;
-	char *ver;
-	char *hash;
-} JabberCapsKey;
-
 #if 0
 typedef struct _JabberCapsValue {
 	GList *identities; /* JabberCapsIdentity */
@@ -53,18 +47,18 @@ static guint jabber_caps_hash(gconstpoin
 	const JabberCapsKey *name = key;
 	guint nodehash = g_str_hash(name->node);
 	guint verhash = g_str_hash(name->ver);
-	
-	return nodehash ^ verhash;
+	guint hashhash = g_str_hash(name->hash);
+	return nodehash ^ verhash ^ hashhash;
 }
 
 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
 	const JabberCapsKey *name1 = v1;
 	const JabberCapsKey *name2 = v2;
 	
-	return strcmp(name1->node,name2->node) == 0 && strcmp(name1->ver,name2->ver) == 0;
+	return strcmp(name1->node,name2->node) == 0 && strcmp(name1->ver,name2->ver) == 0 && strcmp(name1->hash,name2->hash) == 0;
 }
 
-static void jabber_caps_destroy_key(gpointer key) {
+void jabber_caps_destroy_key(gpointer key) {
 	JabberCapsKey *keystruct = key;
 	g_free(keystruct->node);
 	g_free(keystruct->ver);
@@ -412,8 +406,6 @@ static void jabber_caps_ext_iqcb(JabberS
 				value->identities = g_list_append(value->identities,id);
 			}
 		}
-		//g_hash_table_replace(client->ext, g_strdup(key), value);
-
 		jabber_caps_store();
 	}
 
============================================================
--- libpurple/protocols/jabber/caps.h	2db130cd73de16bcea4af85b697dec1403778664
+++ libpurple/protocols/jabber/caps.h	82d6db33203f3191493dd0f2ff4219bebb0e4b2b
@@ -43,10 +43,18 @@ typedef struct _JabberDataFormField {
 	GList *values;
 } JabberDataFormField;
 
+typedef struct _JabberCapsKey {
+	char *node;
+	char *ver;
+	char *hash;
+} JabberCapsKey;
+
 typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, gpointer user_data);
 
 void jabber_caps_init(void);
 
+void jabber_caps_destroy_key(gpointer value);
+
 /**
  *	Main entity capabilites function to get the capabilities of a contact.
  */
============================================================
--- libpurple/protocols/jabber/jabber.c	3863113a86a04b8c154c5969c31851f812dc70f7
+++ libpurple/protocols/jabber/jabber.c	875a9b8f56a42fd9f6f27472f463bc147896ac62
@@ -39,6 +39,7 @@
 #include "version.h"
 #include "xmlnode.h"
 
+#include "caps.h"
 #include "auth.h"
 #include "buddy.h"
 #include "chat.h"
@@ -2445,6 +2446,20 @@ void jabber_register_commands(void)
 					  _("buzz: Buzz a user to get their attention"), NULL);
 }
 
+static void
+jabber_client_info_destroy_key(gpointer key) {
+	gchar *s = key;
+	g_free(s);
+}
+
+static gboolean 
+jabber_client_info_compare(gconstpointer v1, gconstpointer v2) {
+	const gchar *name1 = v1;
+	const gchar *name2 = v2;
+	
+	return strcmp(name1,name2) == 0;
+}
+
 void
 jabber_init_plugin(PurplePlugin *plugin)
 {
@@ -2471,4 +2486,6 @@ jabber_init_plugin(PurplePlugin *plugin)
 	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_contact_info = g_hash_table_new_full(g_str_hash, jabber_client_info_compare, jabber_client_info_destroy_key, jabber_caps_destroy_key);
 }
============================================================
--- libpurple/protocols/jabber/jabber.h	2c98d562c32775ee0f07339523f2096a9f50eab7
+++ libpurple/protocols/jabber/jabber.h	4463842f12357bf2adf3f6acdc6306fbbc8e916d
@@ -230,6 +230,8 @@ extern GList *jabber_identities;
 extern GList *jabber_features;
 extern GList *jabber_identities;
 
+extern GHashTable *jabber_contact_info; /* char * -> JabberCapsKey */
+
 void jabber_process_packet(JabberStream *js, xmlnode **packet);
 void jabber_send(JabberStream *js, xmlnode *data);
 void jabber_send_raw(JabberStream *js, const char *data, int len);


More information about the Commits mailing list