# HG changeset patch # User Marcus Lundblad # Date 1234214478 0 # Node ID 1d32741111809a3c35ca1e717ad2abfe8cccbcfe # Parent cddd7961901f5f81e245829ebdc868396f8acd96 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" diff -r cddd7961901f -r 1d3274111180 finch/finch.c --- a/finch/finch.c Sun Feb 08 10:34:31 2009 +0000 +++ b/finch/finch.c Mon Feb 09 21:21:18 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, "type", "console"); } return ui_info; diff -r cddd7961901f -r 1d3274111180 libpurple/core.h --- a/libpurple/core.h Sun Feb 08 10:34:31 2009 +0000 +++ b/libpurple/core.h Mon Feb 09 21:21:18 2009 +0000 @@ -186,6 +186,10 @@ * *
dev_website
*
the UI's development/support website, such as http://developer.pidgin.im.
+ * + *
type
+ *
the type of UI (pc, console, phone, handheld, web, bot)
+ * * * * @return A GHashTable with strings for keys and values. This diff -r cddd7961901f -r 1d3274111180 libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Sun Feb 08 10:34:31 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Mon Feb 09 21:21:18 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; +} diff -r cddd7961901f -r 1d3274111180 libpurple/protocols/jabber/buddy.h --- a/libpurple/protocols/jabber/buddy.h Sun Feb 08 10:34:31 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.h Mon Feb 09 21:21:18 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_ */ diff -r cddd7961901f -r 1d3274111180 libpurple/protocols/jabber/disco.c --- a/libpurple/protocols/jabber/disco.c Sun Feb 08 10:34:31 2009 +0000 +++ b/libpurple/protocols/jabber/disco.c Mon Feb 09 21:21:18 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, "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") diff -r cddd7961901f -r 1d3274111180 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Sun Feb 08 10:34:31 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Mon Feb 09 21:21:18 2009 +0000 @@ -1620,7 +1620,7 @@ { JabberStream *js; JabberBuddy *jb = NULL; - + if(!b->account->gc) return NULL; @@ -1633,6 +1633,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; } diff -r cddd7961901f -r 1d3274111180 pidgin/gtkmain.c --- a/pidgin/gtkmain.c Sun Feb 08 10:34:31 2009 +0000 +++ b/pidgin/gtkmain.c Mon Feb 09 21:21:18 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, "type", "pc"); } return ui_info;