soc.2008.xmpp: 09cddf37: * adding IPC function 'contact_has_featu...

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


-----------------------------------------------------------------
Revision: 09cddf377e019b3d78535d75e9c038f64ddb56b5
Ancestor: 1641961a876037d80ff7baac077c2c8959e19d43
Author: tfar at soc.pidgin.im
Date: 2008-07-06T21:09:50
Branch: im.pidgin.soc.2008.xmpp
URL: http://d.pidgin.im/viewmtn/revision/info/09cddf377e019b3d78535d75e9c038f64ddb56b5

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

ChangeLog: 

* adding IPC function 'contact_has_feature'
* keep track of the contacts' resources' caps hashes

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	d7820b8d81d836f09792255aa1ed77a179e4de4b
+++ libpurple/protocols/jabber/caps.c	ee100752e9e980e51fd3030f289ec3af62911002
@@ -31,7 +31,7 @@
 
 #define JABBER_CAPS_FILENAME "xmpp-caps.xml"
 
-static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsValue */
+GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsValue */
 static gchar *caps_hash = NULL;
 
 #if 0
@@ -528,8 +528,10 @@ void jabber_caps_get_info(JabberStream *
 	
 	client = g_hash_table_lookup(capstable, key);
 
-	g_free(key);
+	//g_free(key);
 
+	g_hash_table_replace(jabber_contact_info, g_strdup(who), key);
+
 	if(!client) {
 		JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info");
 		xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info");
============================================================
--- libpurple/protocols/jabber/caps.h	82d6db33203f3191493dd0f2ff4219bebb0e4b2b
+++ libpurple/protocols/jabber/caps.h	4d66abcbf83e79b1b2707f675cbfaa38d0c0b44f
@@ -27,6 +27,7 @@ typedef struct _JabberCapsClientInfo Jab
 #include "jabber.h"
 
 /* Implementation of XEP-0115 */
+extern GHashTable *capstable;
 
 typedef struct _JabberIdentity JabberCapsIdentity;
 
============================================================
--- libpurple/protocols/jabber/jabber.c	875a9b8f56a42fd9f6f27472f463bc147896ac62
+++ libpurple/protocols/jabber/jabber.c	5fad87da1f52d8fbe8f3b09986ee2fb927d0b5ea
@@ -65,6 +65,8 @@ GList *jabber_identities = NULL;
 GList *jabber_features = NULL;
 GList *jabber_identities = NULL;
 
+GHashTable *jabber_contact_info = NULL;
+
 static void jabber_unregister_account_cb(JabberStream *js);
 
 static void jabber_stream_init(JabberStream *js)
@@ -2446,18 +2448,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;
+/* IPC fucntions*/
+static gboolean
+jabber_ipc_contact_has_feature(gchar *fulljid, gchar *feature)
+{
+	JabberCapsKey *caps_info = NULL;
+	JabberCapsValueExt *capabilities = NULL;
 	
-	return strcmp(name1,name2) == 0;
+	caps_info = g_hash_table_lookup(jabber_contact_info, fulljid);
+	
+	if (!caps_info) return FALSE;
+	capabilities = g_hash_table_lookup(capstable, caps_info);
+	
+	if (g_list_find(capabilities->features, feature) == NULL) return FALSE ;
+	return TRUE;
 }
 
 void
@@ -2467,7 +2471,7 @@ jabber_init_plugin(PurplePlugin *plugin)
 
 	jabber_add_identity("client", "pc", PACKAGE);
 
-	// initialize jabber_features list
+	/* 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);
@@ -2487,5 +2491,12 @@ jabber_init_plugin(PurplePlugin *plugin)
 	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);
+	jabber_contact_info = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_caps_destroy_key);
+	
+	/* IPC functions */
+	purple_plugin_ipc_register(plugin, "contact_has_feature", PURPLE_CALLBACK(jabber_ipc_contact_has_feature),
+							 purple_marshal_BOOLEAN__POINTER_POINTER,
+							 purple_value_new(PURPLE_TYPE_BOOLEAN), 2,
+							 purple_value_new(PURPLE_TYPE_STRING),
+							 purple_value_new(PURPLE_TYPE_STRING));
 }


More information about the Commits mailing list