soc.2008.xmpp: 24b5f892: * defined JabberCapsIdentity as struct _...

tfar at soc.pidgin.im tfar at soc.pidgin.im
Sun Jun 22 15:17:29 EDT 2008


-----------------------------------------------------------------
Revision: 24b5f892917273cef92a91180006ec8bbd802a25
Ancestor: f77de9f5b0ad1188e6d09263aa09aecf42effc10
Author: tfar at soc.pidgin.im
Date: 2008-06-22T18:59:33
Branch: im.pidgin.soc.2008.xmpp
URL: http://d.pidgin.im/viewmtn/revision/info/24b5f892917273cef92a91180006ec8bbd802a25

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

ChangeLog: 

* defined JabberCapsIdentity as struct _JabberIdentity
* added jabber_caps_jabber_xdata_compare() which compares two x-data forms as required by XEP-0115

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	8a55f614ad25914530c13954fb6af18fc077ae1a
+++ libpurple/protocols/jabber/caps.c	f94e52da14d281a9806174d7fe470bbe1e930a3e
@@ -595,6 +595,42 @@ static gint jabber_caps_jabber_feature_c
 	return strcmp(ac->namespace, bc->namespace);
 }
 
+static gint jabber_caps_string_compare(gconstpointer a, gconstpointer b) {
+	const gchar *ac;
+	const gchar *bc;
+	
+	ac = a;
+	bc = b;
+	
+	return strcmp(ac, bc);
+}
+
+static gint jabber_caps_jabber_xdata_compare(gconstpointer a, gconstpointer b) {
+	const xmlnode *ac;
+	const xmlnode *bc;
+	xmlnode *aformtypefield;
+	xmlnode *bformtypefield;
+	char *aformtype;
+	char *bformtype;
+	int result;
+	
+	ac = a;
+	bc = b;
+
+	aformtypefield = xmlnode_get_child(ac, "field");
+	while (aformtypefield && strcmp(xmlnode_get_attrib(aformtypefield, "var"), "FORM_TYPE")) aformtypefield = xmlnode_get_next_twin(aformtypefield);
+	aformtype = xmlnode_get_data(aformtypefield);
+	
+	bformtypefield = xmlnode_get_child(bc, "field");
+	while (bformtypefield && strcmp(xmlnode_get_attrib(bformtypefield, "var"), "FORM_TYPE")) bformtypefield = xmlnode_get_next_twin(bformtypefield);
+	bformtype = xmlnode_get_data(bformtypefield);
+	
+	result = strcmp(aformtype, bformtype);
+	g_free(aformtype);
+	g_free(bformtype);
+	return result;
+}
+
 JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query) {
 	xmlnode *child;
 	
@@ -636,6 +672,10 @@ gchar *jabber_caps_calcualte_hash(Jabber
 gchar *jabber_caps_calcualte_hash(JabberCapsClientInfo *info) {
 	if (!info) return 0;
 	
+	/* sort identities, features and x-data forms */
+	info->identities = g_list_sort(info->identities, jabber_caps_jabber_identity_compare);
+	info->features = g_list_sort(info->features, jabber_caps_string_compare);
+	info->forms = g_list_sort(info->forms, jabber_caps_jabber_xdata_compare);
 }
 
 void jabber_caps_calculate_own_hash() {
============================================================
--- libpurple/protocols/jabber/caps.h	2a972dbeb85d600bbda754a9a480debaaa3458d5
+++ libpurple/protocols/jabber/caps.h	f32f510059e82487b840fc379893b7d808d3ce90
@@ -28,12 +28,7 @@ typedef struct _JabberCapsClientInfo Jab
 
 /* Implementation of XEP-0115 */
 
-typedef struct _JabberCapsIdentity {
-	char *category;
-	char *type;
-	char *name;
-	char *lang;
-} JabberCapsIdentity;
+typedef struct _JabberIdentity JabberCapsIdentity;
 
 struct _JabberCapsClientInfo {
 	GList *identities; /* JabberCapsIdentity */
============================================================
--- libpurple/protocols/jabber/jabber.h	d660634ecff65c1c63cbf4daa2320dd72da6b760
+++ libpurple/protocols/jabber/jabber.h	742698a4946f1a58976f55f2fecf5720bd6faab3
@@ -216,6 +216,7 @@ typedef struct _JabberIdentity
 	gchar *category;
 	gchar *type;
 	gchar *name;
+	gchar *lang;
 } JabberIdentity;
 
 typedef struct _JabberBytestreamsStreamhost {


More information about the Commits mailing list