From 6c52ccae1f8da4b49ba3b3eafb44f05441e57b04 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 18 Nov 2012 23:58:57 +0000 Subject: [PATCH] Return whether or not room member presence was changed --- src/room_chat.c | 14 +++++++++++++- src/room_chat.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/room_chat.c b/src/room_chat.c index b72bff83..d6a80b9d 100644 --- a/src/room_chat.c +++ b/src/room_chat.c @@ -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 diff --git a/src/room_chat.h b/src/room_chat.h index b0bb8db5..c5260605 100644 --- a/src/room_chat.h +++ b/src/room_chat.h @@ -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);