diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-07-01 09:41:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-01 09:41:07 +0200 |
commit | aae252e1b54c147bcf9404031e7862c0e955f571 (patch) | |
tree | 66844e760babe0b15f561b41165d1db8cb9d9ca6 /src/xmpp | |
parent | dc79c514be403cff93a1165b47d456182a03fd05 (diff) | |
parent | e4bf7335d889d82dedf962f2a2590f1a1b7455b6 (diff) | |
download | profani-tty-aae252e1b54c147bcf9404031e7862c0e955f571.tar.gz |
Merge pull request #1529 from dustinlagoy/access-roster-from-plugins
Access roster from plugins
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/roster_list.c | 24 | ||||
-rw-r--r-- | src/xmpp/roster_list.h | 1 |
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); |