From 0365e88b7b461123f213beea43a9f55524bd9688 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 30 Sep 2014 19:46:35 +0100 Subject: wip - Store roles and affiliations with occupants --- src/xmpp/presence.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index a3cd2173..cfbf18fe 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -766,20 +766,32 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, } char *show_str = stanza_get_show(stanza, "online"); + char *role = NULL; + char *affiliation = NULL; + + xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + if (x) { + xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); + if (item) { + role = xmpp_stanza_get_attribute(item, "role"); + affiliation = xmpp_stanza_get_attribute(item, "affiliation"); + } + } + if (!muc_roster_complete(from_room)) { - muc_roster_add(from_room, from_nick, show_str, status_str); + muc_roster_add(from_room, from_nick, role, affiliation, show_str, status_str); } else { char *old_nick = muc_roster_nick_change_complete(from_room, from_nick); if (old_nick != NULL) { - muc_roster_add(from_room, from_nick, show_str, status_str); + muc_roster_add(from_room, from_nick, role, affiliation, show_str, status_str); handle_room_member_nick_change(from_room, old_nick, from_nick); free(old_nick); } else { if (!muc_roster_contains_nick(from_room, from_nick)) { - handle_room_member_online(from_room, from_nick, show_str, status_str); + handle_room_member_online(from_room, from_nick, role, affiliation, show_str, status_str); } else { - handle_room_member_presence(from_room, from_nick, show_str, status_str); + handle_room_member_presence(from_room, from_nick, role, affiliation, show_str, status_str); } } } -- cgit 1.4.1-2-gfad0