about summary refs log tree commit diff stats
path: root/src/room_chat.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-07 22:24:50 +0000
committerJames Booth <boothj5@gmail.com>2012-11-07 22:24:50 +0000
commit54e591fea34c1168a48457d25a500ce9f506a13b (patch)
tree9bf1299de9b48ab2eee59465c3fa20c1c720dcb3 /src/room_chat.c
parent5fe12bbd153c6989542a7ffa2b10c880f1ace9e7 (diff)
downloadprofani-tty-54e591fea34c1168a48457d25a500ce9f506a13b.tar.gz
jabber: wait until full room roster received before showing
Diffstat (limited to 'src/room_chat.c')
-rw-r--r--src/room_chat.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/room_chat.c b/src/room_chat.c
index dd8ae91a..6b560bbf 100644
--- a/src/room_chat.c
+++ b/src/room_chat.c
@@ -28,6 +28,7 @@
 typedef struct _muc_room_t {
     char *jid;
     char *nick;
+    GSList *roster;
 } muc_room;
 
 GHashTable *rooms = NULL;
@@ -45,6 +46,7 @@ room_join(const char * const jid, const char * const nick)
     muc_room *new_room = malloc(sizeof(muc_room));
     new_room->jid = strdup(jid);
     new_room->nick = strdup(nick);
+    new_room->roster = NULL;
 
     g_hash_table_insert(rooms, strdup(jid), new_room);
 }
@@ -107,6 +109,28 @@ room_parse_room_jid(const char * const room_jid, char **room, char **nick)
     }
 }
 
+void
+room_add_to_roster(const char * const jid, const char * const nick)
+{
+    muc_room *room = g_hash_table_lookup(rooms, jid);
+
+    if (room != NULL) {
+        room->roster = g_slist_append(room->roster, strdup(nick));
+    }
+}
+
+GSList *
+room_get_roster(const char * const jid)
+{
+    muc_room *room = g_hash_table_lookup(rooms, jid);
+
+    if (room != NULL) {
+        return room->roster;
+    } else {
+        return NULL;
+    }
+}
+
 static void
 _room_free(muc_room *room)
 {
@@ -119,6 +143,10 @@ _room_free(muc_room *room)
             g_free(room->nick);
             room->nick = NULL;
         }
+        if (room->roster != NULL) {
+            g_slist_free_full(room->roster, g_free);
+            room->roster = NULL;
+        }
         g_free(room);
     }
     room = NULL;