changeset 25521:3a0c2526364f

propagate from branch 'im.pidgin.pidgin' (head 53ec2e73334e6dc99c29f0f13b5ebf4700f5a92c) to branch 'im.pidgin.cpw.malu.client_type' (head 5c51de850198f962f69b002e0750d918deb8bcfe)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 24 Feb 2009 20:27:09 +0000
parents 7c21fb8132f7 (current diff) d971b6a6be2c (diff)
children ae2b4394fbe2
files libpurple/protocols/jabber/jabber.c libpurple/protocols/msn/state.c
diffstat 8 files changed, 95 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/finch/finch.c	Tue Feb 24 14:37:38 2009 +0000
+++ b/finch/finch.c	Tue Feb 24 20:27:09 2009 +0000
@@ -65,6 +65,7 @@
 		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, "client_type", "console");
 	}
 
 	return ui_info;
--- a/libpurple/core.h	Tue Feb 24 14:37:38 2009 +0000
+++ b/libpurple/core.h	Tue Feb 24 20:27:09 2009 +0000
@@ -186,6 +186,10 @@
  *
  *   <dt><tt>dev_website</tt></dt>
  *   <dd>the UI's development/support website, such as http://developer.pidgin.im.</dd>
+ *
+ *   <dt><tt>client_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
--- a/libpurple/protocols/jabber/buddy.c	Tue Feb 24 14:37:38 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Feb 24 20:27:09 2009 +0000
@@ -2526,3 +2526,22 @@
 	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;
+}
--- a/libpurple/protocols/jabber/buddy.h	Tue Feb 24 14:37:38 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.h	Tue Feb 24 20:27:09 2009 +0000
@@ -121,4 +121,8 @@
 										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_ */
--- a/libpurple/protocols/jabber/disco.c	Tue Feb 24 14:37:38 2009 +0000
+++ b/libpurple/protocols/jabber/disco.c	Tue Feb 24 20:27:09 2009 +0000
@@ -20,6 +20,7 @@
  */
 
 #include "internal.h"
+#include "core.h"
 #include "prefs.h"
 #include "debug.h"
 
@@ -116,11 +117,24 @@
 			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, "client_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")
--- a/libpurple/protocols/jabber/jabber.c	Tue Feb 24 14:37:38 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Tue Feb 24 20:27:09 2009 +0000
@@ -1633,7 +1633,7 @@
 {
 	JabberStream *js;
 	JabberBuddy *jb = NULL;
-
+	
 	if(!b->account->gc)
 		return NULL;
 
@@ -1646,6 +1646,28 @@
 					!(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;
 }
 
--- a/libpurple/protocols/msn/state.c	Tue Feb 24 14:37:38 2009 +0000
+++ b/libpurple/protocols/msn/state.c	Tue Feb 24 20:27:09 2009 +0000
@@ -21,6 +21,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
+
+#include "internal.h"
+#include "core.h"
+
 #include "msn.h"
 #include "state.h"
 
@@ -288,10 +292,29 @@
 	MsnUser *user;
 	MsnObject *msnobj;
 	const char *state_text;
-
+	GHashTable *ui_info = purple_core_get_ui_info();
+	MsnClientCaps caps = MSN_CLIENT_ID;
+	
 	g_return_if_fail(session != NULL);
 	g_return_if_fail(session->notification != NULL);
 
+	/* set client caps based on what the UI tells us it is... */
+	if (ui_info) {
+		const gchar *client_type = g_hash_table_lookup(ui_info, "client_type");
+		if (client_type) {
+			if (strcmp(client_type, "phone") == 0 ||
+				strcmp(client_type, "handheld") == 0) {
+				caps |= MSN_CLIENT_CAP_WIN_MOBILE;
+			} else if (strcmp(client_type, "web")) {
+				caps |= MSN_CLIENT_CAP_WEBMSGR;
+			} else if (strcmp(client_type, "bot")) {
+				caps |= MSN_CLIENT_CAP_BOT;
+			}
+			/* MSN doesn't a "console" type... 
+			 What, they have no ncurses UI? :-) */
+		}
+	}
+	
 	account = session->account;
 	cmdproc = session->notification->cmdproc;
 	user = session->user;
@@ -307,8 +330,7 @@
 
 	if (msnobj == NULL)
 	{
-		msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text,
-						 MSN_CLIENT_ID);
+		msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text, caps);
 	}
 	else
 	{
@@ -317,7 +339,7 @@
 		msnobj_str = msn_object_to_string(msnobj);
 
 		msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text,
-						 MSN_CLIENT_ID, purple_url_encode(msnobj_str));
+						 caps, purple_url_encode(msnobj_str));
 
 		g_free(msnobj_str);
 	}
--- a/pidgin/gtkmain.c	Tue Feb 24 14:37:38 2009 +0000
+++ b/pidgin/gtkmain.c	Tue Feb 24 20:27:09 2009 +0000
@@ -349,6 +349,7 @@
 		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, "client_type", "pc");
 	}
 
 	return ui_info;