wip - Store roles and affiliations with occupants
This commit is contained in:
18
src/muc.c
18
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user