about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-18 23:58:57 +0000
committerJames Booth <boothj5@gmail.com>2012-11-18 23:58:57 +0000
commit6c52ccae1f8da4b49ba3b3eafb44f05441e57b04 (patch)
treee72e77143298c5bc65263ee8e592aaf4ca106adb
parentbd3f1d1575830aa4236ea1a3585c9b3c33b32be9 (diff)
downloadprofani-tty-6c52ccae1f8da4b49ba3b3eafb44f05441e57b04.tar.gz
Return whether or not room member presence was changed
-rw-r--r--src/room_chat.c14
-rw-r--r--src/room_chat.h2
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);
27;print' functions' href='/akkartik/mu/commit/generic.mu?h=main&id=4b62edd8a63cfdde37b0537c9be1e91062bb2892'>4b62edd8 ^
7d2c2d55 ^
f184c95e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22