about summary refs log tree commit diff stats
path: root/src/muc.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-03-29 03:17:41 +0100
committerJames Booth <boothj5@gmail.com>2015-03-29 03:17:41 +0100
commitc8c12a8f7aa5a908aa22f6a143f50bd8a077a408 (patch)
tree0323aa6c21727a92a439fa6df8d6b5c1e5d29a16 /src/muc.c
parentc36d4b36437b790d67e6631320c6d78a5bc978be (diff)
parent71c2be599b54fb3cf7beb2a0855ad2a9d1bf6a0b (diff)
downloadprofani-tty-c8c12a8f7aa5a908aa22f6a143f50bd8a077a408.tar.gz
Merge branch 'master' into pgp
Diffstat (limited to 'src/muc.c')
-rw-r--r--src/muc.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/muc.c b/src/muc.c
index ae48d66b..6fd09de3 100644
--- a/src/muc.c
+++ b/src/muc.c
@@ -66,6 +66,7 @@ typedef struct _muc_room_t {
 } ChatRoom;
 
 GHashTable *rooms = NULL;
+GHashTable *invite_passwords = NULL;
 Autocomplete invite_ac;
 
 static void _free_room(ChatRoom *room);
@@ -83,6 +84,7 @@ muc_init(void)
 {
     invite_ac = autocomplete_new();
     rooms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_free_room);
+    invite_passwords = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
 }
 
 void
@@ -90,19 +92,25 @@ muc_close(void)
 {
     autocomplete_free(invite_ac);
     g_hash_table_destroy(rooms);
+    g_hash_table_destroy(invite_passwords);
     rooms = NULL;
+    invite_passwords = NULL;
 }
 
 void
-muc_invites_add(const char * const room)
+muc_invites_add(const char * const room, const char * const password)
 {
     autocomplete_add(invite_ac, room);
+    if (password) {
+        g_hash_table_replace(invite_passwords, strdup(room), strdup(password));
+    }
 }
 
 void
 muc_invites_remove(const char * const room)
 {
     autocomplete_remove(invite_ac, room);
+    g_hash_table_remove(invite_passwords, room);
 }
 
 gint
@@ -117,6 +125,12 @@ muc_invites(void)
     return autocomplete_create_list(invite_ac);
 }
 
+char *
+muc_invite_password(const char * const room)
+{
+    return g_hash_table_lookup(invite_passwords, room);
+}
+
 gboolean
 muc_invites_contain(const char * const room)
 {
@@ -151,6 +165,7 @@ void
 muc_invites_clear(void)
 {
     autocomplete_clear(invite_ac);
+    g_hash_table_remove_all(invite_passwords);
 }
 
 void