diff options
author | James Booth <boothj5@gmail.com> | 2012-11-18 23:58:57 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-11-18 23:58:57 +0000 |
commit | 6c52ccae1f8da4b49ba3b3eafb44f05441e57b04 (patch) | |
tree | e72e77143298c5bc65263ee8e592aaf4ca106adb | |
parent | bd3f1d1575830aa4236ea1a3585c9b3c33b32be9 (diff) | |
download | profani-tty-6c52ccae1f8da4b49ba3b3eafb44f05441e57b04.tar.gz |
Return whether or not room member presence was changed
-rw-r--r-- | src/room_chat.c | 14 | ||||
-rw-r--r-- | 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); |