about summary refs log tree commit diff stats
path: root/preferences.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-05-10 22:44:23 +0100
committerJames Booth <boothj5@gmail.com>2012-05-10 22:44:23 +0100
commit5e3962a129c32e5c7f4304124a22987158f75d0b (patch)
treef7ecfcc985249338cbee1b1fa9d3e97dd156bd47 /preferences.c
parent4e23031c7444d64fb93c1f044f71e0df331e0ecd (diff)
downloadprofani-tty-5e3962a129c32e5c7f4304124a22987158f75d0b.tar.gz
Create GSList of jids on preferences load
Diffstat (limited to 'preferences.c')
-rw-r--r--preferences.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/preferences.c b/preferences.c
index 2b16e000..ebf9b274 100644
--- a/preferences.c
+++ b/preferences.c
@@ -28,7 +28,13 @@
 static GString *prefs_loc;
 static GKeyFile *prefs;
 
+// search logins list
+static GSList *logins = NULL;
+//static GSList *last_found = NULL;
+//static gchar *search_str = NULL;
+
 static void _save_prefs(void);
+static gint _compare_jids(gconstpointer a, gconstpointer b);
 
 void prefs_load(void)
 {
@@ -37,6 +43,24 @@ void prefs_load(void)
 
     prefs = g_key_file_new();
     g_key_file_load_from_file(prefs, prefs_loc->str, G_KEY_FILE_NONE, NULL);
+
+    // create the logins searchable list for autocompletion
+    gsize njids;
+    gchar **jids =
+        g_key_file_get_string_list(prefs, "connections", "logins", &njids, NULL);
+
+    gsize i;
+    for (i = 0; i < njids; i++) {
+        logins = g_slist_insert_sorted(logins, jids[0], _compare_jids);
+    }
+}
+
+static gint _compare_jids(gconstpointer a, gconstpointer b)
+{
+    const gchar *str_a = (const gchar *) a;
+    const gchar *str_b = (const gchar *) b;
+
+    return g_strcmp0(str_a, str_b);
 }
 
 gboolean prefs_get_beep(void)