about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-11 00:02:05 +0000
committerJames Booth <boothj5@gmail.com>2013-01-11 00:02:05 +0000
commitce8faa8d34b22a671324d437e7e4737bc9d8a10b (patch)
treeb639597b77472ccd1bab3b0687626e881afde0ae
parent96b7b6bc7149d4193360e28e8dc69d91d6cc7002 (diff)
downloadprofani-tty-ce8faa8d34b22a671324d437e7e4737bc9d8a10b.tar.gz
Added nickname autocompleter to chat rooms
-rw-r--r--src/room_chat.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/room_chat.c b/src/room_chat.c
index 46cb8ee6..d70fca9c 100644
--- a/src/room_chat.c
+++ b/src/room_chat.c
@@ -25,13 +25,15 @@
 
 #include <glib.h>
 
-#include <contact.h>
+#include "contact.h"
+#include "prof_autocomplete.h"
 
 typedef struct _muc_room_t {
     char *room;
     char *nick;
     gboolean pending_nick_change;
     GHashTable *roster;
+    PAutocomplete nick_ac;
     GHashTable *nick_changes;
     gboolean roster_received;
 } muc_room;
@@ -53,6 +55,7 @@ room_join(const char * const room, const char * const nick)
     new_room->nick = strdup(nick);
     new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
         (GDestroyNotify)p_contact_free);
+    new_room->nick_ac = p_autocomplete_new();
     new_room->nick_changes = g_hash_table_new_full(g_str_hash, g_str_equal,
         g_free, g_free);
     new_room->roster_received = FALSE;
@@ -247,6 +250,7 @@ room_add_to_roster(const char * const room, const char * const nick,
 
         if (old == NULL) {
             updated = TRUE;
+            p_autocomplete_add(chat_room->nick_ac, strdup(nick));
         } else if ((g_strcmp0(p_contact_presence(old), show) != 0) ||
                     (g_strcmp0(p_contact_status(old), status) != 0)) {
             updated = TRUE;
@@ -266,6 +270,7 @@ room_remove_from_roster(const char * const room, const char * const nick)
 
     if (chat_room != NULL) {
         g_hash_table_remove(chat_room->roster, nick);
+        p_autocomplete_remove(chat_room->nick_ac, nick);
     }
 }
 
@@ -352,6 +357,9 @@ _room_free(muc_room *room)
             g_hash_table_remove_all(room->roster);
             room->roster = NULL;
         }
+        if (room->nick_ac != NULL) {
+            p_autocomplete_clear(room->nick_ac);
+        }
         if (room->nick_changes != NULL) {
             g_hash_table_remove_all(room->nick_changes);
             room->nick_changes = NULL;