1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Return whether or not room member presence was changed

This commit is contained in:
James Booth 2012-11-18 23:58:57 +00:00
parent bd3f1d1575
commit 6c52ccae1f
2 changed files with 14 additions and 2 deletions

View File

@ -201,16 +201,28 @@ room_parse_room_jid(const char * const full_room_jid, char **room, char **nick)
}
}
void
gboolean
room_add_to_roster(const char * const room, const char * const nick,
const char * const show, const char * const status)
{
muc_room *chat_room = g_hash_table_lookup(rooms, room);
gboolean updated = FALSE;
if (chat_room != NULL) {
PContact old = g_hash_table_lookup(chat_room->roster, nick);
if (old == NULL) {
updated = TRUE;
} else if ((g_strcmp0(p_contact_presence(old), show) != 0) ||
(g_strcmp0(p_contact_status(old), status) != 0)) {
updated = TRUE;
}
PContact contact = p_contact_new(nick, NULL, show, status, NULL);
g_hash_table_replace(chat_room->roster, strdup(nick), contact);
}
return updated;
}
void

View File

@ -34,7 +34,7 @@ char * room_get_room_from_full_jid(const char * const full_room_jid);
char * room_get_nick_from_full_jid(const char * const full_room_jid);
gboolean room_parse_room_jid(const char * const full_room_jid, char **room,
char **nick);
void room_add_to_roster(const char * const room, const char * const nick,
gboolean room_add_to_roster(const char * const room, const char * const nick,
const char * const show, const char * const status);
void room_add_pending_nick_change(const char * const room,
const char * const new_nick, const char * const old_nick);