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/muc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/muc.c') diff --git a/src/muc.c b/src/muc.c index c1a89473..6c48f342 100644 --- a/src/muc.c +++ b/src/muc.c @@ -71,7 +71,8 @@ static muc_role_t _role_from_string(const char * const role); static muc_affiliation_t _affiliation_from_string(const char * const affiliation); static char* _role_to_string(muc_role_t role); static char* _affiliation_to_string(muc_affiliation_t affiliation); -static Occupant* _muc_occupant_new(const char *const nick, resource_presence_t presence, const char * const status); +static Occupant* _muc_occupant_new(const char *const nick, muc_role_t role, muc_affiliation_t affiliation, + resource_presence_t presence, const char * const status); static void _occupant_free(Occupant *occupant); void @@ -382,8 +383,8 @@ muc_roster_contains_nick(const char * const room, const char * const nick) * Add a new chat room member to the room's roster */ gboolean -muc_roster_add(const char * const room, const char * const nick, - const char * const show, const char * const status) +muc_roster_add(const char * const room, const char * const nick, const char * const role, + const char * const affiliation, const char * const show, const char * const status) { ChatRoom *chat_room = g_hash_table_lookup(rooms, room); gboolean updated = FALSE; @@ -401,7 +402,9 @@ muc_roster_add(const char * const room, const char * const nick, } resource_presence_t presence = resource_presence_from_string(show); - Occupant *occupant = _muc_occupant_new(nick, presence, status); + muc_role_t role_t = _role_from_string(role); + muc_affiliation_t affiliation_t = _affiliation_from_string(affiliation); + Occupant *occupant = _muc_occupant_new(nick, role_t, affiliation_t, presence, status); g_hash_table_replace(chat_room->roster, strdup(nick), occupant); } @@ -770,7 +773,8 @@ _affiliation_to_string(muc_affiliation_t affiliation) } static Occupant* -_muc_occupant_new(const char *const nick, resource_presence_t presence, const char * const status) +_muc_occupant_new(const char *const nick, muc_role_t role, muc_affiliation_t affiliation, resource_presence_t presence, + const char * const status) { Occupant *occupant = malloc(sizeof(Occupant)); @@ -788,8 +792,8 @@ _muc_occupant_new(const char *const nick, resource_presence_t presence, const ch occupant->status = NULL; } - occupant->role = MUC_ROLE_NONE; - occupant->affiliation = MUC_AFFILIATION_NONE; + occupant->role = role; + occupant->affiliation = affiliation; return occupant; } -- cgit 1.4.1-2-gfad0