Mercurial > hg
changeset 1348:26d1dd2c948f
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.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 09 Nov 2007 23:33:52 +0100 |
parents | 07816313073b |
children | 1a82a0a87fc7 |
files | mcabber/mcabberrc.example mcabber/src/jab_iq.c |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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) "<jid/resource>" # - 1: "name <jid/resource>" (name is omitted if same as the jid)
--- 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); }