diff options
Diffstat (limited to 'src/roster_list.c')
-rw-r--r-- | src/roster_list.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/roster_list.c b/src/roster_list.c index ad1864f1..a320ab2b 100644 --- a/src/roster_list.c +++ b/src/roster_list.c @@ -42,6 +42,7 @@ #include "contact.h" #include "jid.h" #include "tools/autocomplete.h" +#include "config/preferences.h" // nicknames static Autocomplete name_ac; @@ -116,6 +117,33 @@ roster_get_contact(const char * const barejid) return contact; } +char * +roster_get_msg_display_name(const char * const barejid, const char * const resource) +{ + GString *result = g_string_new(""); + + PContact contact = roster_get_contact(barejid); + if (contact != NULL) { + if (p_contact_name(contact) != NULL) { + g_string_append(result, p_contact_name(contact)); + } else { + g_string_append(result, barejid); + } + } else { + g_string_append(result, barejid); + } + + if (resource && prefs_get_boolean(PREF_RESOURCE_MESSAGE)) { + g_string_append(result, "/"); + g_string_append(result, resource); + } + + char *result_str = result->str; + g_string_free(result, FALSE); + + return result_str; +} + gboolean roster_contact_offline(const char * const barejid, const char * const resource, const char * const status) |