diff options
author | Richard van der Hoff <richard@matrix.org> | 2015-11-02 18:03:09 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2015-11-02 18:03:09 +0000 |
commit | 8efee869304ed95823767363df39a5617e38ce7c (patch) | |
tree | 03a802fd6a89e035632ec2e36817d33744c05bdf /matrix-roommembers.c | |
parent | e78ea22ac644ecb3bb08ca2059068825fc77324c (diff) | |
download | purple-matrix-8efee869304ed95823767363df39a5617e38ce7c.tar.gz |
Implement get_cb_real_name
Fixing this means purple is slightly less confused about who the users in our
chats are.
Diffstat (limited to 'matrix-roommembers.c')
-rw-r--r-- | matrix-roommembers.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/matrix-roommembers.c b/matrix-roommembers.c index a437796..cfe36a0 100644 --- a/matrix-roommembers.c +++ b/matrix-roommembers.c @@ -314,3 +314,27 @@ GList *matrix_roommembers_get_active_members( } return members; } + + +/** + * Get the userid of a member of a room, given their displayname + * + * @returns a string, which will be freed by the caller, or null if not known + */ +gchar *matrix_roommembers_displayname_to_userid( + MatrixRoomMemberTable *table, const gchar *who) +{ + /* TODO: make this more efficient */ + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init (&iter, table->hash_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const gchar *user_id = key; + MatrixRoomMember *member = value; + if(member->current_displayname != NULL + && strcmp(who, member->current_displayname) == 0) { + return g_strdup(user_id); + } + } + return NULL; +} |