pidgin: abe3ff7c: Make the JabberCapsTuple (nee Key) avail...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Thu May 7 22:45:35 EDT 2009


-----------------------------------------------------------------
Revision: abe3ff7cd54c6a92781ca00b89f83e384c35c886
Ancestor: 0d3e7183f1b6345a8fda3322c688e7e922536162
Author: darkrain42 at pidgin.im
Date: 2009-05-07T23:46:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/abe3ff7cd54c6a92781ca00b89f83e384c35c886

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

ChangeLog: 

Make the JabberCapsTuple (nee Key) available to the rest of the prpl

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	f110487c8aef3f256260f5a8661a33a1bb9e9276
+++ libpurple/protocols/jabber/caps.c	a26e85997dfaed2d57763448d3aa4296ee11ca1a
@@ -35,13 +35,7 @@ typedef struct _JabberDataFormField {
 	GList *values;
 } JabberDataFormField;
 
-typedef struct _JabberCapsKey {
-	char *node;
-	char *ver;
-	char *hash;
-} JabberCapsKey;
-
-static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsClientInfo */
+static GHashTable *capstable = NULL; /* JabberCapsTuple -> JabberCapsClientInfo */
 static GHashTable *nodetable = NULL; /* char *node -> JabberCapsNodeExts */
 static guint       save_timer = 0;
 
@@ -86,7 +80,7 @@ static guint jabber_caps_hash(gconstpoin
 }
 
 static guint jabber_caps_hash(gconstpointer data) {
-	const JabberCapsKey *key = data;
+	const JabberCapsTuple *key = data;
 	guint nodehash = g_str_hash(key->node);
 	guint verhash  = g_str_hash(key->ver);
 	/*
@@ -99,22 +93,14 @@ static gboolean jabber_caps_compare(gcon
 }
 
 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
-	const JabberCapsKey *name1 = v1;
-	const JabberCapsKey *name2 = v2;
+	const JabberCapsTuple *name1 = v1;
+	const JabberCapsTuple *name2 = v2;
 
 	return g_str_equal(name1->node, name2->node) &&
 	       g_str_equal(name1->ver, name2->ver) &&
 	       purple_strequal(name1->hash, name2->hash);
 }
 
-void jabber_caps_destroy_key(gpointer data) {
-	JabberCapsKey *key = data;
-	g_free(key->node);
-	g_free(key->ver);
-	g_free(key->hash);
-	g_free(key);
-}
-
 static void
 jabber_caps_client_info_destroy(JabberCapsClientInfo *info)
 {
@@ -140,6 +126,10 @@ jabber_caps_client_info_destroy(JabberCa
 
 	jabber_caps_node_exts_unref(info->exts);
 
+	g_free((char *)info->tuple.node);
+	g_free((char *)info->tuple.ver);
+	g_free((char *)info->tuple.hash);
+
 	g_free(info);
 }
 
@@ -176,16 +166,16 @@ static void jabber_caps_store_client(gpo
 }
 
 static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user_data) {
-	JabberCapsKey *clientinfo = key;
-	JabberCapsClientInfo *props = value;
+	const JabberCapsTuple *tuple = key;
+	const JabberCapsClientInfo *props = value;
 	xmlnode *root = user_data;
 	xmlnode *client = xmlnode_new_child(root, "client");
 	GList *iter;
 
-	xmlnode_set_attrib(client, "node", clientinfo->node);
-	xmlnode_set_attrib(client, "ver", clientinfo->ver);
-	if (clientinfo->hash)
-		xmlnode_set_attrib(client, "hash", clientinfo->hash);
+	xmlnode_set_attrib(client, "node", tuple->node);
+	xmlnode_set_attrib(client, "ver", tuple->ver);
+	if (tuple->hash)
+		xmlnode_set_attrib(client, "hash", tuple->hash);
 	for(iter = props->identities; iter; iter = g_list_next(iter)) {
 		JabberIdentity *id = iter->data;
 		xmlnode *identity = xmlnode_new_child(client, "identity");
@@ -255,8 +245,8 @@ jabber_caps_load(void)
 		if(client->type != XMLNODE_TYPE_TAG)
 			continue;
 		if(!strcmp(client->name, "client")) {
-			JabberCapsKey *key = g_new0(JabberCapsKey, 1);
 			JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
+			JabberCapsTuple *key = (JabberCapsTuple*)&value->tuple;
 			xmlnode *child;
 			JabberCapsNodeExts *exts = NULL;
 			key->node = g_strdup(xmlnode_get_attrib(client,"node"));
@@ -340,7 +330,7 @@ void jabber_caps_init(void)
 void jabber_caps_init(void)
 {
 	nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref); 
-	capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, (GDestroyNotify)jabber_caps_client_info_destroy);
+	capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, NULL, (GDestroyNotify)jabber_caps_client_info_destroy);
 	jabber_caps_load();
 }
 
@@ -429,7 +419,7 @@ jabber_caps_client_iqcb(JabberStream *js
 		"http://jabber.org/protocol/disco#info");
 	jabber_caps_cbplususerdata *userdata = data;
 	JabberCapsClientInfo *info = NULL, *value;
-	JabberCapsKey key;
+	JabberCapsTuple key;
 
 	if (!query || type == JABBER_IQ_ERROR) {
 		/* Any outstanding exts will be dealt with via ref-counting */
@@ -481,7 +471,7 @@ jabber_caps_client_iqcb(JabberStream *js
 		jabber_caps_client_info_destroy(info);
 		info = value;
 	} else {
-		JabberCapsKey *n_key = g_new(JabberCapsKey, 1);
+		JabberCapsTuple *n_key = (JabberCapsTuple *)&info->tuple;
 		n_key->node = userdata->node;
 		n_key->ver  = userdata->ver;
 		n_key->hash = userdata->hash;
@@ -553,7 +543,7 @@ void jabber_caps_get_info(JabberStream *
         jabber_caps_get_info_cb cb, gpointer user_data)
 {
 	JabberCapsClientInfo *info;
-	JabberCapsKey key;
+	JabberCapsTuple key;
 	jabber_caps_cbplususerdata *userdata;
 
 	if (ext && *ext && hash)
============================================================
--- libpurple/protocols/jabber/caps.h	860c4a20163f7bc9eb490ec0496ebd2efa173422
+++ libpurple/protocols/jabber/caps.h	0a0f3d9612b85717f508aef8b380aba02d82156b
@@ -30,11 +30,19 @@ typedef struct _JabberCapsNodeExts Jabbe
 
 typedef struct _JabberCapsNodeExts JabberCapsNodeExts;
 
+typedef struct _JabberCapsTuple {
+	const char *node;
+	const char *ver;
+	const char *hash;
+} JabberCapsTuple;
+
 struct _JabberCapsClientInfo {
 	GList *identities; /* JabberIdentity */
 	GList *features; /* char * */
 	GList *forms; /* xmlnode * */
 	JabberCapsNodeExts *exts;
+
+	const JabberCapsTuple tuple;
 };
 
 /*


More information about the Commits mailing list