# HG changeset patch # User Mikael Berthe # Date 1194647632 -3600 # Node ID 26d1dd2c948ff984d61fc90dcbb1cd250562003b # Parent 07816313073bb10ed91ded5a670c76ae4d720e6a Add option 'roster_hide_domain' Add an option to only display usernames (not the full JIDs) in the roster window when no name has been specified. diff -r 07816313073b -r 26d1dd2c948f mcabber/mcabberrc.example --- a/mcabber/mcabberrc.example Fri Nov 09 23:14:03 2007 +0100 +++ b/mcabber/mcabberrc.example Fri Nov 09 23:33:52 2007 +0100 @@ -324,6 +324,11 @@ #set log_win_on_top = 0 #set roster_win_on_right = 0 # +# By default, the displayed name of a contact in the roster window will +# be the jid if no name has been specified. You can use the following +# option if you only want to see the username part. +#set roster_hide_domain = 0 +# # Buddy name format (in status window): # - 0: (default) "" # - 1: "name " (name is omitted if same as the jid) diff -r 07816313073b -r 26d1dd2c948f mcabber/src/jab_iq.c --- a/mcabber/src/jab_iq.c Fri Nov 09 23:14:03 2007 +0100 +++ b/mcabber/src/jab_iq.c Fri Nov 09 23:33:52 2007 +0100 @@ -263,6 +263,7 @@ guint roster_type; for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) { + char *name_tmp = NULL; fjid = xmlnode_get_attrib(y, "jid"); name = xmlnode_get_attrib(y, "name"); @@ -296,8 +297,16 @@ if (ask && !strcmp(ask, "subscribe")) esub |= sub_pending; - if (!name) - name = cleanalias; + if (!name) { + if (!settings_opt_get_int("roster_hide_domain")) { + name = cleanalias; + } else { + char *p; + name = name_tmp = g_strdup(cleanalias); + p = strchr(name_tmp, JID_DOMAIN_SEPARATOR); + if (p) *p = '\0'; + } + } // Tricky... :-\ My guess is that if there is no JID_DOMAIN_SEPARATOR, // this is an agent. @@ -308,6 +317,7 @@ roster_add_user(cleanalias, name, group, roster_type, esub); + g_free(name_tmp); g_free(cleanalias); }