aboutsummaryrefslogtreecommitdiff
path: root/src/seen-db.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-24 21:05:07 -0500
committerTed Gould <ted@gould.cx>2010-03-24 21:05:07 -0500
commit288cb93d92574b947ab5addafcbf58fc7d907670 (patch)
tree02e2257ee10a30022237c8a9efbd7d76338ff6d7 /src/seen-db.c
parentb840c918e0a355eabcfff49efc2f4c61803b5c52 (diff)
downloadayatana-indicator-messages-288cb93d92574b947ab5addafcbf58fc7d907670.tar.gz
ayatana-indicator-messages-288cb93d92574b947ab5addafcbf58fc7d907670.tar.bz2
ayatana-indicator-messages-288cb93d92574b947ab5addafcbf58fc7d907670.zip
Code to read in the keyfile
Diffstat (limited to 'src/seen-db.c')
-rw-r--r--src/seen-db.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/seen-db.c b/src/seen-db.c
index 027100d..7849781 100644
--- a/src/seen-db.c
+++ b/src/seen-db.c
@@ -1,5 +1,8 @@
#include "seen-db.h"
+#define GROUP_NAME "Seen Database"
+#define KEY_NAME "DesktopFiles"
+
GHashTable * seendb = NULL;
gchar * filename = NULL;
@@ -20,7 +23,35 @@ seen_db_init(void)
}
if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
+ GKeyFile * keyfile = g_key_file_new();
+
+ if (!g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_NONE, NULL)) {
+ g_key_file_free(keyfile);
+ keyfile = NULL;
+ }
+
+ if (keyfile != NULL && !g_key_file_has_key(keyfile, GROUP_NAME, KEY_NAME, NULL)) {
+ g_warning("Seen DB '%s' does not have key '%s' in group '%s'", filename, KEY_NAME, GROUP_NAME);
+ g_key_file_free(keyfile);
+ keyfile = NULL;
+ }
+
+ if (keyfile != NULL) {
+ gchar ** desktops = g_key_file_get_string_list(keyfile, GROUP_NAME, KEY_NAME, NULL, NULL);
+ gint i = 0;
+
+ while (desktops[i] != NULL) {
+ g_hash_table_insert(seendb,
+ g_strdup(desktops[i]),
+ GINT_TO_POINTER(TRUE));
+ }
+
+ g_strfreev(desktops);
+ }
+ if (keyfile != NULL) {
+ g_key_file_free(keyfile);
+ }
}
return;