libpurple/protocols/jabber/jabber.c

branch
cpw.malu.client_type
changeset 27287
d3ececcf09d1
parent 27110
05ca719b901b
parent 27286
f637c4c27815
child 27289
32591a46eb78
equal deleted inserted replaced
27110:05ca719b901b 27287:d3ececcf09d1
21 #include "internal.h" 21 #include "internal.h"
22 22
23 #include "account.h" 23 #include "account.h"
24 #include "accountopt.h" 24 #include "accountopt.h"
25 #include "blist.h" 25 #include "blist.h"
26 #include "core.h"
26 #include "cmds.h" 27 #include "cmds.h"
27 #include "connection.h" 28 #include "connection.h"
28 #include "conversation.h" 29 #include "conversation.h"
29 #include "debug.h" 30 #include "debug.h"
30 #include "dnssrv.h" 31 #include "dnssrv.h"
1843 const char* jabber_list_emblem(PurpleBuddy *b) 1844 const char* jabber_list_emblem(PurpleBuddy *b)
1844 { 1845 {
1845 JabberStream *js; 1846 JabberStream *js;
1846 JabberBuddy *jb = NULL; 1847 JabberBuddy *jb = NULL;
1847 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(b)); 1848 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(b));
1848 1849
1849 if(!gc) 1850 if(!gc)
1850 return NULL; 1851 return NULL;
1851 1852
1852 js = gc->proto_data; 1853 js = gc->proto_data;
1853 if(js) 1854 if(js)
1856 if(!PURPLE_BUDDY_IS_ONLINE(b)) { 1857 if(!PURPLE_BUDDY_IS_ONLINE(b)) {
1857 if(jb && (jb->subscription & JABBER_SUB_PENDING || 1858 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
1858 !(jb->subscription & JABBER_SUB_TO))) 1859 !(jb->subscription & JABBER_SUB_TO)))
1859 return "not-authorized"; 1860 return "not-authorized";
1860 } 1861 }
1862
1863 if (jb) {
1864 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL);
1865 if (jbr) {
1866 const gchar *client_type =
1867 jabber_resource_get_identity_category_type(jbr, "client");
1868
1869 if (client_type) {
1870 if (strcmp(client_type, "phone") == 0) {
1871 return "mobile";
1872 } else if (strcmp(client_type, "web") == 0) {
1873 return "external";
1874 } else if (strcmp(client_type, "handheld") == 0) {
1875 return "hiptop";
1876 } else if (strcmp(client_type, "bot") == 0) {
1877 return "bot";
1878 }
1879 /* the default value "pc" falls through and has no emblem */
1880 }
1881 }
1882 }
1883
1861 return NULL; 1884 return NULL;
1862 } 1885 }
1863 1886
1864 char *jabber_status_text(PurpleBuddy *b) 1887 char *jabber_status_text(PurpleBuddy *b)
1865 { 1888 {
3329 } 3352 }
3330 3353
3331 void 3354 void
3332 jabber_init_plugin(PurplePlugin *plugin) 3355 jabber_init_plugin(PurplePlugin *plugin)
3333 { 3356 {
3357 GHashTable *ui_info = purple_core_get_ui_info();
3358 const gchar *ui_type = g_hash_table_lookup(ui_info, "client_type");
3359 const gchar *type = "pc"; /* default client type, if unknown or
3360 unspecified */
3361
3362 if (ui_type) {
3363 if (strcmp(ui_type, "pc") == 0 ||
3364 strcmp(ui_type, "console") == 0 ||
3365 strcmp(ui_type, "phone") == 0 ||
3366 strcmp(ui_type, "handheld") == 0 ||
3367 strcmp(ui_type, "web") == 0 ||
3368 strcmp(ui_type, "bot") == 0) {
3369 type = ui_type;
3370 }
3371 }
3334 my_protocol = plugin; 3372 my_protocol = plugin;
3335 3373
3336 jabber_add_identity("client", "pc", NULL, PACKAGE); 3374 jabber_add_identity("client", type, NULL, PACKAGE);
3337 3375
3338 /* initialize jabber_features list */ 3376 /* initialize jabber_features list */
3339 jabber_add_feature("jabber:iq:last", 0); 3377 jabber_add_feature("jabber:iq:last", 0);
3340 jabber_add_feature("jabber:iq:oob", 0); 3378 jabber_add_feature("jabber:iq:oob", 0);
3341 jabber_add_feature("jabber:iq:time", 0); 3379 jabber_add_feature("jabber:iq:time", 0);

mercurial