cpw.malu.client_type: 24f10a7c: Set a value "type" in the ui_info hash t...

malu at pidgin.im malu at pidgin.im
Mon Feb 9 16:25:30 EST 2009


-----------------------------------------------------------------
Revision: 24f10a7c63bc238236989461230f97a0eedf0fcd
Ancestor: 0e02d55d1b8b8badfa78439d77bda433a7c66a73
Author: malu at pidgin.im
Date: 2009-02-09T21:21:18
Branch: im.pidgin.cpw.malu.client_type
URL: http://d.pidgin.im/viewmtn/revision/info/24f10a7c63bc238236989461230f97a0eedf0fcd

Modified files:
        finch/finch.c libpurple/core.h
        libpurple/protocols/jabber/buddy.c
        libpurple/protocols/jabber/buddy.h
        libpurple/protocols/jabber/disco.c
        libpurple/protocols/jabber/jabber.c pidgin/gtkmain.c

ChangeLog: 

Set a value "type" in the ui_info hash table
Set client type in resonse to an XMPP XEP-0115 request (client type).
Makes Pidgin report itself as "pc", Finch as "console"
Display emblems on XMPP buddies corresponding to their client type
(if available). Currently there is no emblem for "console"


-------------- next part --------------
============================================================
--- finch/finch.c	7de9b76dc4808a46137c007229f0210ea9ffd659
+++ finch/finch.c	0c604a8c5f91af7c8da259a07998c9bcb9eb9fdf
@@ -65,6 +65,7 @@ static GHashTable *finch_ui_get_info(voi
 		g_hash_table_insert(ui_info, "version", VERSION);
 		g_hash_table_insert(ui_info, "website", "http://pidgin.im");
 		g_hash_table_insert(ui_info, "dev_website", "http://developer.pidgin.im");
+		g_hash_table_insert(ui_info, "type", "console");
 	}
 
 	return ui_info;
============================================================
--- libpurple/core.h	0670db53150867309d624b6166c360895e4900f4
+++ libpurple/core.h	ecfd21f14feec2986bb0a22b21365986df82b40c
@@ -186,6 +186,10 @@ gboolean purple_core_ensure_single_insta
  *
  *   <dt><tt>dev_website</tt></dt>
  *   <dd>the UI's development/support website, such as http://developer.pidgin.im.</dd>
+ *
+ *   <dt><tt>type</tt></dt>
+ *   <dd>the type of UI (pc, console, phone, handheld, web, bot)</dd>
+ *   
  * </dl>
  *
  * @return A GHashTable with strings for keys and values.  This
============================================================
--- libpurple/protocols/jabber/buddy.c	9ff67c9f62fa077196d25f2e4458bfec2e759991
+++ libpurple/protocols/jabber/buddy.c	7593a32f0123416777139bb3c1063e7ec50a68fe
@@ -2526,3 +2526,22 @@ jabber_buddy_has_capability(const Jabber
 	return jabber_resource_has_capability(jbr, cap);
 }
 
+const gchar *
+jabber_resource_get_identity_category_type(const JabberBuddyResource *jbr,
+	const gchar *category)
+{
+	const GList *iter = NULL;
+	
+	if (jbr->caps) {
+		for (iter = jbr->caps->identities ; iter ; iter = g_list_next(iter)) {
+			const JabberCapsIdentity *identity = 
+				(JabberCapsIdentity *) iter->data;
+		
+			if (strcmp(identity->category, category) == 0) {
+				return identity->type;
+			}
+		}
+	}
+		
+	return NULL;
+}
============================================================
--- libpurple/protocols/jabber/buddy.h	b72ccdfffb3ac98b1f2cab34a3fddfef59c086e5
+++ libpurple/protocols/jabber/buddy.h	75eb288e9236474f9ccf33d0290be7d168a2df4b
@@ -121,4 +121,8 @@ gboolean jabber_buddy_has_capability(con
 										const gchar *cap);
 gboolean jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap);
 
+const gchar *
+jabber_resource_get_identity_category_type(const JabberBuddyResource *jbr,
+	const gchar *category);
+
 #endif /* _PURPLE_JABBER_BUDDY_H_ */
============================================================
--- libpurple/protocols/jabber/disco.c	15e05aeaa2b1e64bc8b77794391c734d82691a3e
+++ libpurple/protocols/jabber/disco.c	6b2c3a2bc94412e24d78940c18a25453a41d7a3e
@@ -20,6 +20,7 @@
  */
 
 #include "internal.h"
+#include "core.h"
 #include "prefs.h"
 #include "debug.h"
 
@@ -116,11 +117,24 @@ void jabber_disco_info_parse(JabberStrea
 			xmlnode_set_attrib(query, "node", node);
 
 		if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) {
+			GHashTable *ui_info = purple_core_get_ui_info();
+			const gchar *ui_type = g_hash_table_lookup(ui_info, "type");
+			const gchar *type = "pc"; /* default client type, if unknown or
+										unspecified */
+
+			if (ui_type) {
+				if (strcmp(ui_type, "pc") == 0 ||
+					strcmp(ui_type, "console") == 0 ||
+					strcmp(ui_type, "phone") == 0 ||
+					strcmp(ui_type, "handheld") == 0 ||
+					strcmp(ui_type, "web") == 0 ||
+					strcmp(ui_type, "bot") == 0) {
+					type = ui_type;
+				}
+			}
 			identity = xmlnode_new_child(query, "identity");
 			xmlnode_set_attrib(identity, "category", "client");
-			xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console,
-														 * handheld, pc, phone,
-														 * web */
+			xmlnode_set_attrib(identity, "type",  type);
 			xmlnode_set_attrib(identity, "name", PACKAGE);
 
 			SUPPORT_FEATURE("jabber:iq:last")
============================================================
--- libpurple/protocols/jabber/jabber.c	687026e2691399edddca701e1ed503668fc1feaf
+++ libpurple/protocols/jabber/jabber.c	fd3d2af3e3fdaf14dfc7acecf2ce855e941bf8a5
@@ -1620,7 +1620,7 @@ const char* jabber_list_emblem(PurpleBud
 {
 	JabberStream *js;
 	JabberBuddy *jb = NULL;
-
+	
 	if(!b->account->gc)
 		return NULL;
 
@@ -1633,6 +1633,28 @@ const char* jabber_list_emblem(PurpleBud
 					!(jb->subscription & JABBER_SUB_TO)))
 			return "not-authorized";
 	}
+	
+	if (jb) {
+		JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL);
+		if (jbr) {
+			const gchar *client_type = 
+				jabber_resource_get_identity_category_type(jbr, "client");
+		
+			if (client_type) {
+				if (strcmp(client_type, "phone") == 0) {
+					return "mobile";
+				} else if (strcmp(client_type, "web") == 0) {
+					return "external";
+				} else if (strcmp(client_type, "handheld") == 0) {
+					return "hiptop";
+				} else if (strcmp(client_type, "bot") == 0) {
+					return "bot";
+				}
+				/* the default value "pc" falls through and has no emblem */
+			}
+		}
+	}
+		
 	return NULL;
 }
 
============================================================
--- pidgin/gtkmain.c	9969c0180c98f26e1312f35b33092667914b9dea
+++ pidgin/gtkmain.c	fffd0ce914d5d854bafe11106dcb61bb436b132a
@@ -349,6 +349,7 @@ static GHashTable *pidgin_ui_get_info(vo
 		g_hash_table_insert(ui_info, "version", VERSION);
 		g_hash_table_insert(ui_info, "website", "http://pidgin.im");
 		g_hash_table_insert(ui_info, "dev_website", "http://developer.pidgin.im");
+		g_hash_table_insert(ui_info, "type", "pc");
 	}
 
 	return ui_info;


More information about the Commits mailing list