about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jabber.c18
-rw-r--r--src/room_chat.c16
-rw-r--r--src/room_chat.h1
3 files changed, 33 insertions, 2 deletions
diff --git a/src/jabber.c b/src/jabber.c
index 3ceb238d..bb5f192f 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -346,6 +346,21 @@ jabber_update_presence(jabber_presence_t status, const char * const msg)
         xmpp_stanza_add_child(presence, priority);
     }
     xmpp_send(jabber_conn.conn, presence);
+
+    // send presence for each room
+    GList *rooms = room_get_rooms();
+    while (rooms != NULL) {
+        char *room = rooms->data;
+        char *nick = room_get_nick_for_room(room);
+        char *full_room_jid = room_create_full_room_jid(room, nick);
+
+        xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
+        xmpp_send(jabber_conn.conn, presence);
+
+        rooms = g_list_next(rooms);
+    }
+    g_list_free(rooms);
+
     xmpp_stanza_release(presence);
 }
 
@@ -730,8 +745,9 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
             prof_handle_room_nick_change(room, nick);
 
         // handle roster complete
-        } else {
+        } else if (!room_get_roster_received(room)) {
             prof_handle_room_roster_complete(room);
+
         }
 
     // handle presence from room members
diff --git a/src/room_chat.c b/src/room_chat.c
index cc295c18..d84a23fe 100644
--- a/src/room_chat.c
+++ b/src/room_chat.c
@@ -120,6 +120,16 @@ room_is_active(const char * const full_room_jid)
     }
 }
 
+GList *
+room_get_rooms(void)
+{
+    if (rooms != NULL) {
+        return g_hash_table_get_keys(rooms);
+    } else {
+        return NULL;
+    }
+}
+
 char *
 room_get_nick_for_room(const char * const room)
 {
@@ -313,9 +323,13 @@ room_complete_pending_nick_change(const char * const room,
 
     if (chat_room != NULL) {
         char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick);
+        char *old_nick_cpy;
 
         if (old_nick != NULL) {
-            return strdup(old_nick);
+            old_nick_cpy = strdup(old_nick);
+            g_hash_table_remove(chat_room->nick_changes, nick);
+
+            return old_nick_cpy;
         }
     }
 
diff --git a/src/room_chat.h b/src/room_chat.h
index 0761bc48..64bc4873 100644
--- a/src/room_chat.h
+++ b/src/room_chat.h
@@ -51,5 +51,6 @@ char * room_create_full_room_jid(const char * const room,
     const char * const nick);
 void room_set_pending_nick_change(const char * const room);
 gboolean room_is_pending_nick_change(const char * const room);
+GList* room_get_rooms(void);
 
 #endif