[tracker/libtracker-common-cleanup: 16/16] libtracker-common: Remove TrackerConfigFile, TrackerKeyfileObject
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-common-cleanup: 16/16] libtracker-common: Remove TrackerConfigFile, TrackerKeyfileObject
- Date: Wed, 8 Oct 2014 16:19:29 +0000 (UTC)
commit 00478efc54121956453a1b49d98880f9928b5aa4
Author: Martyn Russell <martyn lanedo com>
Date: Wed Oct 8 12:29:59 2014 +0100
libtracker-common: Remove TrackerConfigFile, TrackerKeyfileObject
Migrated the KeyFile work in most apps to GSettings
src/libtracker-common/Makefile.am | 4 -
src/libtracker-common/tracker-common.h | 2 -
src/libtracker-common/tracker-config-file.c | 730 ------------------------
src/libtracker-common/tracker-config-file.h | 84 ---
src/libtracker-common/tracker-keyfile-object.c | 436 --------------
src/libtracker-common/tracker-keyfile-object.h | 99 ----
src/libtracker-data/tracker-db-config.c | 17 -
src/libtracker-data/tracker-db-config.h | 2 -
src/libtracker-fts/tracker-fts-config.c | 20 -
src/libtracker-fts/tracker-fts-config.h | 7 +-
src/libtracker-fts/tracker-fts-tokenizer.c | 3 +
src/miners/fs/tracker-config.c | 165 +++----
src/miners/fs/tracker-config.h | 2 -
src/tracker-extract/tracker-config.c | 84 ++-
src/tracker-extract/tracker-config.h | 6 +-
src/tracker-store/tracker-config.c | 20 +-
src/tracker-writeback/tracker-config.c | 23 +-
17 files changed, 138 insertions(+), 1566 deletions(-)
---
diff --git a/src/libtracker-common/Makefile.am b/src/libtracker-common/Makefile.am
index a3223f2..baa7298 100644
--- a/src/libtracker-common/Makefile.am
+++ b/src/libtracker-common/Makefile.am
@@ -18,12 +18,10 @@ endif
libtracker_common_la_SOURCES = \
$(BUILT_SOURCES) \
$(os_sources) \
- tracker-config-file.c \
tracker-date-time.c \
tracker-dbus.c \
tracker-file-utils.c \
tracker-ioprio.c \
- tracker-keyfile-object.c \
tracker-log.c \
tracker-sched.c \
tracker-storage.c \
@@ -38,11 +36,9 @@ noinst_HEADERS = \
tracker-ioprio.h \
tracker-log.h \
tracker-os-dependant.h \
- tracker-config-file.h \
tracker-common.h \
tracker-date-time.h \
tracker-file-utils.h \
- tracker-keyfile-object.h \
tracker-ontologies.h \
tracker-sched.h \
tracker-storage.h \
diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h
index f072baa..c82684f 100644
--- a/src/libtracker-common/tracker-common.h
+++ b/src/libtracker-common/tracker-common.h
@@ -28,12 +28,10 @@
#define __LIBTRACKER_COMMON_INSIDE__
-#include "tracker-config-file.h"
#include "tracker-date-time.h"
#include "tracker-dbus.h"
#include "tracker-file-utils.h"
#include "tracker-ioprio.h"
-#include "tracker-keyfile-object.h"
#include "tracker-language.h"
#include "tracker-log.h"
#include "tracker-ontologies.h"
diff --git a/src/libtracker-data/tracker-db-config.c b/src/libtracker-data/tracker-db-config.c
index 461c6f3..eb3c65d 100644
--- a/src/libtracker-data/tracker-db-config.c
+++ b/src/libtracker-data/tracker-db-config.c
@@ -25,8 +25,6 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-common/tracker-keyfile-object.h>
-
#include "tracker-db-config.h"
/* GKeyFile defines */
@@ -55,11 +53,6 @@ enum {
PROP_JOURNAL_ROTATE_DESTINATION
};
-static TrackerConfigMigrationEntry migration[] = {
- { G_TYPE_INT, GROUP_JOURNAL, "JournalChunkSize", "journal-chunk-size", FALSE, FALSE },
- { G_TYPE_STRING, GROUP_JOURNAL, "JournalRotateDestination", "journal-rotate-destination", FALSE,
FALSE },
-};
-
G_DEFINE_TYPE (TrackerDBConfig, tracker_db_config, G_TYPE_SETTINGS);
static void
@@ -150,19 +143,9 @@ config_finalize (GObject *object)
static void
config_constructed (GObject *object)
{
- TrackerConfigFile *config_file;
-
(G_OBJECT_CLASS (tracker_db_config_parent_class)->constructed) (object);
g_settings_delay (G_SETTINGS (object));
-
- /* Migrate keyfile-based configuration */
- config_file = tracker_config_file_new ();
- if (config_file) {
- tracker_config_file_migrate (config_file,
- G_SETTINGS (object), migration);
- g_object_unref (config_file);
- }
}
TrackerDBConfig *
diff --git a/src/libtracker-data/tracker-db-config.h b/src/libtracker-data/tracker-db-config.h
index 6e4f791..543b519 100644
--- a/src/libtracker-data/tracker-db-config.h
+++ b/src/libtracker-data/tracker-db-config.h
@@ -29,8 +29,6 @@
#include <glib-object.h>
-#include <libtracker-common/tracker-config-file.h>
-
G_BEGIN_DECLS
#define TRACKER_TYPE_DB_CONFIG (tracker_db_config_get_type ())
diff --git a/src/libtracker-fts/tracker-fts-config.c b/src/libtracker-fts/tracker-fts-config.c
index 8f65357..34ebc61 100644
--- a/src/libtracker-fts/tracker-fts-config.c
+++ b/src/libtracker-fts/tracker-fts-config.c
@@ -25,8 +25,6 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-common/tracker-keyfile-object.h>
-
#include "tracker-fts-config.h"
/* GKeyFile defines */
@@ -65,15 +63,6 @@ enum {
PROP_MAX_WORDS_TO_INDEX,
};
-static TrackerConfigMigrationEntry migration[] = {
- { G_TYPE_INT, GROUP_INDEXING, "MaxWordLength", "max-word-length", FALSE, FALSE },
- { G_TYPE_BOOLEAN, GROUP_INDEXING, "EnableStemmer" , "enable-stemmer", FALSE, FALSE },
- { G_TYPE_BOOLEAN, GROUP_INDEXING, "EnableUnaccent", "enable-unaccent", FALSE, FALSE },
- { G_TYPE_BOOLEAN, GROUP_INDEXING, "IgnoreNumbers", "ignore-numbers", FALSE, FALSE },
- { G_TYPE_BOOLEAN, GROUP_INDEXING, "IgnoreStopWords", "ignore-stop-words", FALSE, FALSE },
- { G_TYPE_INT, GROUP_INDEXING, "MaxWordsToIndex", "max-words-to-index", FALSE, FALSE },
-};
-
G_DEFINE_TYPE (TrackerFTSConfig, tracker_fts_config, G_TYPE_SETTINGS);
static void
@@ -228,18 +217,9 @@ config_finalize (GObject *object)
static void
config_constructed (GObject *object)
{
- TrackerConfigFile *config_file;
-
(G_OBJECT_CLASS (tracker_fts_config_parent_class)->constructed) (object);
g_settings_delay (G_SETTINGS (object));
-
- /* migrate keyfile-based configuration */
- config_file = tracker_config_file_new ();
- if (config_file) {
- tracker_config_file_migrate (config_file, G_SETTINGS (object), migration);
- g_object_unref (config_file);
- }
}
TrackerFTSConfig *
diff --git a/src/libtracker-fts/tracker-fts-config.h b/src/libtracker-fts/tracker-fts-config.h
index 46b7450..fb75fb9 100644
--- a/src/libtracker-fts/tracker-fts-config.h
+++ b/src/libtracker-fts/tracker-fts-config.h
@@ -20,13 +20,14 @@
#ifndef __TRACKER_FTS_CONFIG_H__
#define __TRACKER_FTS_CONFIG_H__
-#include <glib-object.h>
+#include "config.h"
-#include <libtracker-common/tracker-config-file.h>
+#include <glib-object.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
-#define TRACKER_TYPE_FTS_CONFIG (tracker_fts_config_get_type ())
+#define TRACKER_TYPE_FTS_CONFIG (tracker_fts_config_get_type ())
#define TRACKER_FTS_CONFIG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_FTS_CONFIG,
TrackerFTSConfig))
#define TRACKER_FTS_CONFIG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TRACKER_TYPE_FTS_CONFIG,
TrackerFTSConfigClass))
#define TRACKER_IS_FTS_CONFIG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_FTS_CONFIG))
diff --git a/src/libtracker-fts/tracker-fts-tokenizer.c b/src/libtracker-fts/tracker-fts-tokenizer.c
index 2e12326..d61ae79 100644
--- a/src/libtracker-fts/tracker-fts-tokenizer.c
+++ b/src/libtracker-fts/tracker-fts-tokenizer.c
@@ -21,8 +21,11 @@
/* FTS3/4 Tokenizer using TrackerParser */
+#include "config.h"
+
#include <assert.h>
#include <string.h>
+
#include "tracker-fts-tokenizer.h"
#include "tracker-fts-config.h"
#include "tracker-parser.h"
diff --git a/src/miners/fs/tracker-config.c b/src/miners/fs/tracker-config.c
index 2333a90..3ffa922 100644
--- a/src/miners/fs/tracker-config.c
+++ b/src/miners/fs/tracker-config.c
@@ -25,14 +25,16 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-common/tracker-keyfile-object.h>
-#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-type-utils.h>
-#include <libtracker-common/tracker-enum-types.h>
-#include <libtracker-common/tracker-log.h>
+#define G_SETTINGS_ENABLE_BACKEND
+#include <gio/gsettingsbackend.h>
+
+#include <libtracker-common/tracker-common.h>
#include "tracker-config.h"
+#define CONFIG_SCHEMA "org.freedesktop.Tracker.Miner.Files"
+#define CONFIG_PATH "/org/freedesktop/tracker/miner/files/"
+
/* Default values */
#define DEFAULT_VERBOSITY 0
#define DEFAULT_SCHED_IDLE 1
@@ -49,9 +51,6 @@
#define DEFAULT_ENABLE_WRITEBACK FALSE
typedef struct {
- /* NOTE: Only used with TRACKER_USE_CONFIG_FILES env var. */
- gpointer config_file;
-
/* IMPORTANT: There are 3 versions of the directories:
* 1. a GStrv stored in GSettings
* 2. a GSList stored here which is the GStrv without any
@@ -59,19 +58,19 @@ typedef struct {
* 3. a GSList stored here which has duplicates and aliases
* resolved.
*/
- GSList *index_recursive_directories;
- GSList *index_recursive_directories_unfiltered;
- GSList *index_single_directories;
- GSList *index_single_directories_unfiltered;
- GSList *ignored_directories;
- GSList *ignored_directories_with_content;
- GSList *ignored_files;
+ GSList *index_recursive_directories;
+ GSList *index_recursive_directories_unfiltered;
+ GSList *index_single_directories;
+ GSList *index_single_directories_unfiltered;
+ GSList *ignored_directories;
+ GSList *ignored_directories_with_content;
+ GSList *ignored_files;
/* Convenience data */
- GSList *ignored_directory_patterns;
- GSList *ignored_directory_paths;
- GSList *ignored_file_patterns;
- GSList *ignored_file_paths;
+ GSList *ignored_directory_patterns;
+ GSList *ignored_directory_paths;
+ GSList *ignored_file_patterns;
+ GSList *ignored_file_paths;
} TrackerConfigPrivate;
static void config_set_property (GObject *object,
@@ -84,8 +83,6 @@ static void config_get_property (GObject *obje
GParamSpec *pspec);
static void config_finalize (GObject *object);
static void config_constructed (GObject *object);
-static void config_file_changed_cb (TrackerConfigFile *config,
- gpointer user_data);
static void config_set_index_recursive_directories (TrackerConfig *config,
GSList *roots);
static void config_set_index_single_directories (TrackerConfig *config,
@@ -128,28 +125,6 @@ enum {
};
-static TrackerConfigMigrationEntry migration[] = {
- { G_TYPE_ENUM, "General", "Verbosity", "verbosity",
FALSE, FALSE },
- { G_TYPE_ENUM, "General", "SchedIdle", "sched-idle",
FALSE, FALSE },
- { G_TYPE_INT, "General", "InitialSleep", "initial-sleep",
FALSE, FALSE },
- { G_TYPE_BOOLEAN, "Monitors", "EnableMonitors", "enable-monitors",
FALSE, FALSE },
- { G_TYPE_INT, "Indexing", "Throttle", "throttle",
FALSE, FALSE },
- { G_TYPE_BOOLEAN, "Indexing", "IndexOnBattery", "index-on-battery",
FALSE, FALSE },
- { G_TYPE_BOOLEAN, "Indexing", "IndexOnBatteryFirstTime", "index-on-battery-first-time",
FALSE, FALSE },
- { G_TYPE_BOOLEAN, "Indexing", "IndexRemovableMedia", "index-removable-devices",
FALSE, FALSE },
- { G_TYPE_BOOLEAN, "Indexing", "IndexOpticalDiscs", "index-optical-discs",
FALSE, FALSE },
- { G_TYPE_INT, "Indexing", "LowDiskSpaceLimit", "low-disk-space-limit",
FALSE, FALSE },
- { G_TYPE_POINTER, "Indexing", "IndexRecursiveDirectories", "index-recursive-directories",
TRUE, TRUE },
- { G_TYPE_POINTER, "Indexing", "IndexSingleDirectories", "index-single-directories",
TRUE, FALSE },
- { G_TYPE_POINTER, "Indexing", "IgnoredDirectories", "ignored-directories",
FALSE, FALSE },
- { G_TYPE_POINTER, "Indexing", "IgnoredDirectoriesWithContent", "ignored-directories-with-content",
FALSE, FALSE },
- { G_TYPE_POINTER, "Indexing", "IgnoredFiles", "ignored-files",
FALSE, FALSE },
- { G_TYPE_INT, "Indexing", "CrawlingInterval", "crawling-interval",
FALSE, FALSE },
- { G_TYPE_INT, "Indexing", "RemovableDaysThreshold", "removable-days-threshold",
FALSE, FALSE },
- { G_TYPE_BOOLEAN, "Writeback", "EnableWriteback", "enable-writeback",
FALSE, FALSE },
- { 0 }
-};
-
G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_SETTINGS)
static void
@@ -343,18 +318,18 @@ config_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
+ TrackerConfig *config = TRACKER_CONFIG (object);
+
switch (param_id) {
/* General */
/* NOTE: We handle these because we have to be able
* to save these based on command line overrides.
*/
case PROP_VERBOSITY:
- tracker_config_set_verbosity (TRACKER_CONFIG (object),
- g_value_get_enum (value));
+ tracker_config_set_verbosity (config, g_value_get_enum (value));
break;
case PROP_INITIAL_SLEEP:
- tracker_config_set_initial_sleep (TRACKER_CONFIG (object),
- g_value_get_int (value));
+ tracker_config_set_initial_sleep (config, g_value_get_int (value));
break;
/* Indexing */
@@ -365,7 +340,7 @@ config_set_property (GObject *object,
GStrv strv = g_value_get_boxed (value);
GSList *dirs = tracker_string_list_to_gslist (strv, -1);
- config_set_index_recursive_directories (TRACKER_CONFIG (object), dirs);
+ config_set_index_recursive_directories (config, dirs);
g_slist_foreach (dirs, (GFunc) g_free, NULL);
g_slist_free (dirs);
@@ -376,7 +351,7 @@ config_set_property (GObject *object,
GStrv strv = g_value_get_boxed (value);
GSList *dirs = tracker_string_list_to_gslist (strv, -1);
- config_set_index_single_directories (TRACKER_CONFIG (object), dirs);
+ config_set_index_single_directories (config, dirs);
g_slist_foreach (dirs, (GFunc) g_free, NULL);
g_slist_free (dirs);
@@ -386,7 +361,7 @@ config_set_property (GObject *object,
GStrv strv = g_value_get_boxed (value);
GSList *dirs = tracker_string_list_to_gslist (strv, -1);
- config_set_ignored_directories (TRACKER_CONFIG (object), dirs);
+ config_set_ignored_directories (config, dirs);
g_slist_foreach (dirs, (GFunc) g_free, NULL);
g_slist_free (dirs);
@@ -396,7 +371,7 @@ config_set_property (GObject *object,
GStrv strv = g_value_get_boxed (value);
GSList *dirs = tracker_string_list_to_gslist (strv, -1);
- config_set_ignored_directories_with_content (TRACKER_CONFIG (object), dirs);
+ config_set_ignored_directories_with_content (config, dirs);
g_slist_foreach (dirs, (GFunc) g_free, NULL);
g_slist_free (dirs);
@@ -406,7 +381,7 @@ config_set_property (GObject *object,
GStrv strv = g_value_get_boxed (value);
GSList *files = tracker_string_list_to_gslist (strv, -1);
- config_set_ignored_files (TRACKER_CONFIG (object), files);
+ config_set_ignored_files (config, files);
g_slist_foreach (files, (GFunc) g_free, NULL);
g_slist_free (files);
@@ -545,14 +520,6 @@ config_finalize (GObject *object)
g_slist_foreach (priv->index_recursive_directories_unfiltered, (GFunc) g_free, NULL);
g_slist_free (priv->index_recursive_directories_unfiltered);
- if (priv->config_file) {
- g_signal_handlers_disconnect_by_func (priv->config_file,
- config_file_changed_cb,
- TRACKER_CONFIG (object));
- g_object_unref (priv->config_file);
- priv->config_file = NULL;
- }
-
(G_OBJECT_CLASS (tracker_config_parent_class)->finalize) (object);
}
@@ -704,13 +671,10 @@ config_set_ignored_directory_conveniences (TrackerConfig *config)
static void
config_constructed (GObject *object)
{
- TrackerConfig *config;
- TrackerConfigFile *config_file;
GSettings *settings;
(G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
- config = TRACKER_CONFIG (object);
settings = G_SETTINGS (object);
/* NOTE: Without the _delay() call the updates to settings
@@ -725,7 +689,9 @@ config_constructed (GObject *object)
* We need this for overriding things like verbosity on start
* up.
*/
- g_settings_delay (settings);
+ if (G_LIKELY (!g_getenv ("TRACKER_USE_CONFIG_FILES"))) {
+ g_settings_delay (settings);
+ }
/* Set up bindings */
g_settings_bind (settings, "verbosity", object, "verbosity", G_SETTINGS_BIND_GET_NO_CHANGES);
@@ -748,47 +714,52 @@ config_constructed (GObject *object)
g_settings_bind (settings, "ignored-directories", object, "ignored-directories", G_SETTINGS_BIND_GET);
g_settings_bind (settings, "ignored-directories-with-content", object,
"ignored-directories-with-content", G_SETTINGS_BIND_GET);
- /* Migrate keyfile-based configuration */
- config_file = tracker_config_file_new ();
+ config_set_ignored_file_conveniences (TRACKER_CONFIG (object));
+ config_set_ignored_directory_conveniences (TRACKER_CONFIG (object));
+}
+
+TrackerConfig *
+tracker_config_new (void)
+{
+ TrackerConfig *config = NULL;
- if (config_file) {
- /* NOTE: Migration works both ways... */
- tracker_config_file_migrate (config_file, settings, migration);
+ /* FIXME: should we unset GSETTINGS_BACKEND env var? */
- if (G_UNLIKELY (g_getenv ("TRACKER_USE_CONFIG_FILES"))) {
- TrackerConfigPrivate *priv;
+ if (G_UNLIKELY (g_getenv ("TRACKER_USE_CONFIG_FILES"))) {
+ GSettingsBackend *backend;
+ gchar *filename, *basename;
+ gboolean need_to_save;
- tracker_config_file_load_from_file (config_file, G_OBJECT (config), migration);
- g_signal_connect (config_file, "changed", G_CALLBACK (config_file_changed_cb),
config);
+ basename = g_strdup_printf ("%s.cfg", g_get_prgname ());
+ filename = g_build_filename (g_get_user_config_dir (), "tracker", basename, NULL);
+ g_free (basename);
- priv = config->priv;
- priv->config_file = config_file;
- } else {
- g_object_unref (config_file);
- }
- }
+ need_to_save = g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE;
- config_set_ignored_file_conveniences (TRACKER_CONFIG (object));
- config_set_ignored_directory_conveniences (TRACKER_CONFIG (object));
-}
+ backend = g_keyfile_settings_backend_new (filename, CONFIG_PATH, NULL);
+ g_info ("Using config file '%s'", filename);
+ g_free (filename);
-static void
-config_file_changed_cb (TrackerConfigFile *config_file,
- gpointer user_data)
-{
- GSettings *settings = G_SETTINGS (user_data);
+ /* settings = g_settings_new_with_backend (CONFIG_SCHEME, backend); */
+ config = g_object_new (TRACKER_TYPE_CONFIG,
+ "backend", backend,
+ "schema-id", CONFIG_SCHEMA,
+ "path", CONFIG_PATH,
+ NULL);
+ g_object_unref (backend);
- tracker_info ("Settings have changed in INI file, we need to restart to take advantage of those
changes!");
- tracker_config_file_import_to_settings (config_file, settings, migration);
-}
+ if (need_to_save) {
+ g_info (" Config file did not exist, creating...");
+ g_settings_apply (G_SETTINGS (config));
+ }
+ } else {
+ config = g_object_new (TRACKER_TYPE_CONFIG,
+ "schema-id", CONFIG_SCHEMA,
+ "path", CONFIG_PATH,
+ NULL);
+ }
-TrackerConfig *
-tracker_config_new (void)
-{
- return g_object_new (TRACKER_TYPE_CONFIG,
- "schema-id", "org.freedesktop.Tracker.Miner.Files",
- "path", "/org/freedesktop/tracker/miner/files/",
- NULL);
+ return config;
}
gint
diff --git a/src/miners/fs/tracker-config.h b/src/miners/fs/tracker-config.h
index 856a5a1..9a5190b 100644
--- a/src/miners/fs/tracker-config.h
+++ b/src/miners/fs/tracker-config.h
@@ -22,8 +22,6 @@
#include <glib-object.h>
-#include <libtracker-common/tracker-config-file.h>
-
G_BEGIN_DECLS
#define TRACKER_TYPE_CONFIG (tracker_config_get_type ())
diff --git a/src/tracker-extract/tracker-config.c b/src/tracker-extract/tracker-config.c
index 9861dd6..04b0e28 100644
--- a/src/tracker-extract/tracker-config.c
+++ b/src/tracker-extract/tracker-config.c
@@ -19,12 +19,20 @@
#include "config.h"
-#include <libtracker-common/tracker-keyfile-object.h>
-#include <libtracker-common/tracker-enum-types.h>
-#include <libtracker-common/tracker-enums.h>
+#define G_SETTINGS_ENABLE_BACKEND
+#include <gio/gsettingsbackend.h>
+
+#include <libtracker-common/tracker-common.h>
#include "tracker-config.h"
+#define CONFIG_SCHEME "org.freedesktop.Tracker.Extract"
+#define CONFIG_PATH "/org/freedesktop/tracker/extract/"
+
+typedef struct {
+ GSettings *settings;
+} TrackerConfigPrivate;
+
static void config_set_property (GObject *object,
guint param_id,
const GValue *value,
@@ -38,6 +46,7 @@ static void config_constructed (GObject *object);
enum {
PROP_0,
+ PROP_SETTINGS,
PROP_VERBOSITY,
PROP_SCHED_IDLE,
PROP_MAX_BYTES,
@@ -45,15 +54,7 @@ enum {
PROP_WAIT_FOR_MINER_FS,
};
-static TrackerConfigMigrationEntry migration[] = {
- { G_TYPE_ENUM, "General", "Verbosity", "verbosity" },
- { G_TYPE_ENUM, "General", "SchedIdle", "sched-idle" },
- { G_TYPE_INT, "General", "MaxBytes", "max-bytes" },
- { G_TYPE_INT, "General", "MaxMediaArtWidth", "max-media-art-width" },
- { 0 }
-};
-
-G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_SETTINGS);
+G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_OBJECT);
static void
tracker_config_class_init (TrackerConfigClass *klass)
@@ -65,6 +66,14 @@ tracker_config_class_init (TrackerConfigClass *klass)
object_class->finalize = config_finalize;
object_class->constructed = config_constructed;
+ g_object_class_install_property (object_class,
+ PROP_SETTINGS,
+ g_param_spec_object ("settings",
+ "GSettings",
+ "GSettings GObject used",
+ G_TYPE_SETTINGS,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
/* General */
g_object_class_install_property (object_class,
PROP_VERBOSITY,
@@ -109,11 +118,14 @@ tracker_config_class_init (TrackerConfigClass *klass)
"%TRUE to wait for tracker-miner-fs is done
before extracting. %FAlSE otherwise",
FALSE,
G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof (TrackerConfigPrivate));
}
static void
tracker_config_init (TrackerConfig *object)
{
+ object->priv = G_TYPE_INSTANCE_GET_PRIVATE (object, TRACKER_TYPE_CONFIG, TrackerConfigPrivate);
}
static void
@@ -125,6 +137,14 @@ config_set_property (GObject *object,
TrackerConfig *config = TRACKER_CONFIG (object);
switch (param_id) {
+ case PROP_SETTINGS: {
+ TrackerConfigPrivate *priv;
+
+ priv = config->priv;
+ priv->settings = g_value_get_object (value);
+ break;
+ }
+
/* General */
/* NOTE: We handle these because we have to be able
* to save these based on command line overrides.
@@ -199,12 +219,17 @@ config_finalize (GObject *object)
static void
config_constructed (GObject *object)
{
- TrackerConfigFile *config_file;
+ TrackerConfigPrivate *priv;
GSettings *settings;
(G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
- settings = G_SETTINGS (object);
+ priv = TRACKER_CONFIG (object)->priv;
+ settings = priv->settings;
+
+ if (!settings) {
+ priv->settings = settings = g_settings_new_with_path (CONFIG_SCHEME, CONFIG_PATH);
+ }
g_settings_delay (settings);
@@ -214,23 +239,30 @@ config_constructed (GObject *object)
g_settings_bind (settings, "max-bytes", object, "max-bytes", G_SETTINGS_BIND_GET);
g_settings_bind (settings, "max-media-art-width", object, "max-media-art-width", G_SETTINGS_BIND_GET);
g_settings_bind (settings, "wait-for-miner-fs", object, "wait-for-miner-fs", G_SETTINGS_BIND_GET);
-
- /* Migrate keyfile-based configuration */
- config_file = tracker_config_file_new ();
-
- if (config_file) {
- tracker_config_file_migrate (config_file, settings, migration);
- g_object_unref (config_file);
- }
}
TrackerConfig *
tracker_config_new (void)
{
- return g_object_new (TRACKER_TYPE_CONFIG,
- "schema-id", "org.freedesktop.Tracker.Extract",
- "path", "/org/freedesktop/tracker/extract/",
- NULL);
+ GSettings *settings = NULL;
+
+ if (G_UNLIKELY (g_getenv ("TRACKER_USE_CONFIG_FILES"))) {
+ /* FIXME: should we unset GSETTINGS_BACKEND env var? */
+ GSettingsBackend *backend;
+ gchar *filename, *basename;
+
+ basename = g_strdup_printf ("%s.cfg", g_get_prgname ());
+ filename = g_build_filename (g_get_user_config_dir (), "tracker", basename, NULL);
+ g_free (basename);
+
+ backend = g_keyfile_settings_backend_new (filename, CONFIG_PATH, NULL);
+ g_free (filename);
+
+ settings = g_settings_new_with_backend (CONFIG_SCHEME, backend);
+ g_object_unref (backend);
+ }
+
+ return g_object_new (TRACKER_TYPE_CONFIG, "settings", settings, NULL);
}
gint
diff --git a/src/tracker-extract/tracker-config.h b/src/tracker-extract/tracker-config.h
index b19f01f..c350310 100644
--- a/src/tracker-extract/tracker-config.h
+++ b/src/tracker-extract/tracker-config.h
@@ -22,8 +22,6 @@
#include <glib-object.h>
-#include <libtracker-common/tracker-config-file.h>
-
G_BEGIN_DECLS
#define TRACKER_TYPE_CONFIG (tracker_config_get_type ())
@@ -37,12 +35,12 @@ typedef struct TrackerConfig TrackerConfig;
typedef struct TrackerConfigClass TrackerConfigClass;
struct TrackerConfig {
- GSettings parent;
+ GObject parent;
gpointer priv;
};
struct TrackerConfigClass {
- GSettingsClass parent_class;
+ GObjectClass parent_class;
};
GType tracker_config_get_type (void) G_GNUC_CONST;
diff --git a/src/tracker-store/tracker-config.c b/src/tracker-store/tracker-config.c
index 1294fa2..384c378 100644
--- a/src/tracker-store/tracker-config.c
+++ b/src/tracker-store/tracker-config.c
@@ -25,9 +25,7 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-common/tracker-enum-types.h>
-#include <libtracker-common/tracker-config-file.h>
-#include <libtracker-common/tracker-keyfile-object.h>
+#include <libtracker-common/tracker-common.h>
#include "tracker-config.h"
@@ -50,12 +48,6 @@ enum {
PROP_GRAPHUPDATED_DELAY,
};
-static TrackerConfigMigrationEntry migration[] = {
- { G_TYPE_ENUM, "General", "Verbosity", "verbosity", FALSE, FALSE },
- { G_TYPE_INT, "General", "GraphUpdatedDelay", "graphupdated-delay" },
- { 0 }
-};
-
G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_SETTINGS);
static void
@@ -150,19 +142,9 @@ config_finalize (GObject *object)
static void
config_constructed (GObject *object)
{
- TrackerConfigFile *config_file;
-
(G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
g_settings_delay (G_SETTINGS (object));
-
- /* Migrate keyfile-based configuration */
- config_file = tracker_config_file_new ();
-
- if (config_file) {
- tracker_config_file_migrate (config_file, G_SETTINGS (object), migration);
- g_object_unref (config_file);
- }
}
TrackerConfig *
diff --git a/src/tracker-writeback/tracker-config.c b/src/tracker-writeback/tracker-config.c
index 5fb3b78..59e7940 100644
--- a/src/tracker-writeback/tracker-config.c
+++ b/src/tracker-writeback/tracker-config.c
@@ -25,11 +25,7 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-common/tracker-enum-types.h>
-#include <libtracker-common/tracker-config-file.h>
-#include <libtracker-common/tracker-keyfile-object.h>
-#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-type-utils.h>
+#include <libtracker-common/tracker-common.h>
#include "tracker-config.h"
@@ -49,12 +45,7 @@ enum {
PROP_VERBOSITY,
};
-static TrackerConfigMigrationEntry migration[] = {
- { G_TYPE_ENUM, "General", "Verbosity", "verbosity", FALSE, FALSE },
- { 0 }
-};
-
-G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_SETTINGS);
+G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_OBJECT);
static void
tracker_config_class_init (TrackerConfigClass *klass)
@@ -123,19 +114,9 @@ config_finalize (GObject *object)
static void
config_constructed (GObject *object)
{
- TrackerConfigFile *config_file;
-
(G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
g_settings_delay (G_SETTINGS (object));
-
- /* Migrate keyfile-based configuration */
- config_file = tracker_config_file_new ();
-
- if (config_file) {
- tracker_config_file_migrate (config_file, G_SETTINGS (object), migration);
- g_object_unref (config_file);
- }
}
TrackerConfig *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]