# HG changeset patch # User Paul Aurich # Date 1244269299 0 # Node ID f5369bdd02851b476b3ea69b816432a89c3181ce # Parent 5d4e33e3938a155c9147a5cbd54ffc65e6cabda9# Parent 68d6c6517ef8e823cbe08ec58b5c3fffb37dfc7e propagate from branch 'im.pidgin.pidgin' (head 6fb44be5a32516ac1d940330c4f7b8d530208a16) to branch 'im.pidgin.cpw.malu.client_type' (head d22d5bca23b57e3cc71ec9b4d23bf4ff4cb44fc6) diff -r 5d4e33e3938a -r f5369bdd0285 finch/finch.c --- a/finch/finch.c Sat Jun 06 04:02:28 2009 +0000 +++ b/finch/finch.c Sat Jun 06 06:21:39 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; diff -r 5d4e33e3938a -r f5369bdd0285 libpurple/core.h --- a/libpurple/core.h Sat Jun 06 04:02:28 2009 +0000 +++ b/libpurple/core.h Sat Jun 06 06:21:39 2009 +0000 @@ -186,6 +186,10 @@ * *
dev_website
*
the UI's development/support website, such as http://developer.pidgin.im.
+ * + *
client_type
+ *
the type of UI (pc, console, phone, handheld, web, bot)
+ * * * * @return A GHashTable with strings for keys and values. This diff -r 5d4e33e3938a -r f5369bdd0285 libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Sat Jun 06 04:02:28 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Sat Jun 06 06:21:39 2009 +0000 @@ -2520,3 +2520,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.info) { + for (iter = jbr->caps.info->identities ; iter ; iter = g_list_next(iter)) { + const JabberIdentity *identity = + (JabberIdentity *) iter->data; + + if (strcmp(identity->category, category) == 0) { + return identity->type; + } + } + } + + return NULL; +} diff -r 5d4e33e3938a -r f5369bdd0285 libpurple/protocols/jabber/buddy.h --- a/libpurple/protocols/jabber/buddy.h Sat Jun 06 04:02:28 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.h Sat Jun 06 06:21:39 2009 +0000 @@ -123,4 +123,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 5d4e33e3938a -r f5369bdd0285 libpurple/protocols/jabber/disco.c --- a/libpurple/protocols/jabber/disco.c Sat Jun 06 04:02:28 2009 +0000 +++ b/libpurple/protocols/jabber/disco.c Sat Jun 06 06:21:39 2009 +0000 @@ -122,7 +122,7 @@ if(node) xmlnode_set_attrib(query, "node", node); - if(!node || g_str_equal(node, node_uri)) { + if(!node || !strcmp(node, node_uri)) { GList *features, *identities; for(identities = jabber_identities; identities; identities = identities->next) { JabberIdentity *ident = (JabberIdentity*)identities->data; diff -r 5d4e33e3938a -r f5369bdd0285 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Sat Jun 06 04:02:28 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Sat Jun 06 06:21:39 2009 +0000 @@ -23,6 +23,7 @@ #include "account.h" #include "accountopt.h" #include "blist.h" +#include "core.h" #include "cmds.h" #include "connection.h" #include "conversation.h" @@ -1906,7 +1907,7 @@ JabberStream *js; JabberBuddy *jb = NULL; PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(b)); - + if(!gc) return NULL; @@ -1919,6 +1920,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; } @@ -3396,9 +3419,24 @@ void jabber_init_plugin(PurplePlugin *plugin) { + 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; + } + } jabber_plugin = plugin; - jabber_add_identity("client", "pc", NULL, PACKAGE); + jabber_add_identity("client", type, NULL, PACKAGE); /* initialize jabber_features list */ jabber_add_feature("jabber:iq:last", 0); diff -r 5d4e33e3938a -r f5369bdd0285 libpurple/protocols/msn/state.c --- a/libpurple/protocols/msn/state.c Sat Jun 06 04:02:28 2009 +0000 +++ b/libpurple/protocols/msn/state.c Sat Jun 06 06:21:39 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); } diff -r 5d4e33e3938a -r f5369bdd0285 pidgin/gtkmain.c --- a/pidgin/gtkmain.c Sat Jun 06 04:02:28 2009 +0000 +++ b/pidgin/gtkmain.c Sat Jun 06 06:21:39 2009 +0000 @@ -353,6 +353,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;