about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/roster_list.c24
-rw-r--r--src/xmpp/roster_list.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/xmpp/roster_list.c b/src/xmpp/roster_list.c
index 04d16a17..9d7ac427 100644
--- a/src/xmpp/roster_list.c
+++ b/src/xmpp/roster_list.c
@@ -171,6 +171,30 @@ roster_get_contact(const char* const barejid)
 }
 
 char*
+roster_get_display_name(const char* const barejid)
+{
+    assert(roster != NULL);
+
+    GString* result = g_string_new("");
+
+    PContact contact = roster_get_contact(barejid);
+    if (contact) {
+        if (p_contact_name(contact)) {
+            g_string_append(result, p_contact_name(contact));
+        } else {
+            g_string_append(result, barejid);
+        }
+    } else {
+        g_string_append(result, barejid);
+    }
+
+    char* result_str = result->str;
+    g_string_free(result, FALSE);
+
+    return result_str;
+}
+
+char*
 roster_get_msg_display_name(const char* const barejid, const char* const resource)
 {
     assert(roster != NULL);
diff --git a/src/xmpp/roster_list.h b/src/xmpp/roster_list.h
index e47a29cb..f9548d97 100644
--- a/src/xmpp/roster_list.h
+++ b/src/xmpp/roster_list.h
@@ -70,6 +70,7 @@ GList* roster_get_groups(void);
 char* roster_group_autocomplete(const char* const search_str, gboolean previous, void* context);
 char* roster_barejid_autocomplete(const char* const search_str, gboolean previous, void* context);
 GSList* roster_get_contacts_by_presence(const char* const presence);
+char* roster_get_display_name(const char* const barejid);
 char* roster_get_msg_display_name(const char* const barejid, const char* const resource);
 gint roster_compare_name(PContact a, PContact b);
 gint roster_compare_presence(PContact a, PContact b);