diff options
author | James Booth <boothj5@gmail.com> | 2014-09-30 19:46:35 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-30 19:46:35 +0100 |
commit | 0365e88b7b461123f213beea43a9f55524bd9688 (patch) | |
tree | 3692a3a276e5e30229aa2640c0c4aec024e277f5 /src/muc.c | |
parent | b7088363e66d0ee2e00c807b81a5abbdc0c5275f (diff) | |
download | profani-tty-0365e88b7b461123f213beea43a9f55524bd9688.tar.gz |
wip - Store roles and affiliations with occupants
Diffstat (limited to 'src/muc.c')
-rw-r--r-- | src/muc.c | 18 |
1 files changed, 11 insertions, 7 deletions
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; } |