[tracker/journal-rotating] libtracker-db: Moved the journal configs to a tracker-db.cfg



commit 8219a456f23f05485510f9ec38733e4fc4419864
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon May 10 19:01:46 2010 +0200

    libtracker-db: Moved the journal configs to a tracker-db.cfg

 src/libtracker-db/Makefile.am          |    6 +-
 src/libtracker-db/tracker-db-config.c  |  400 ++++++++++++++++++++++++++++++++
 src/libtracker-db/tracker-db-config.h  |   70 ++++++
 src/libtracker-db/tracker-db-manager.c |    5 +-
 src/libtracker-db/tracker-db.h         |    1 +
 src/tracker-control/tracker-control.c  |   48 +---
 src/tracker-store/tracker-config.c     |  133 +----------
 src/tracker-store/tracker-config.h     |    6 -
 src/tracker-store/tracker-main.c       |   10 +-
 9 files changed, 502 insertions(+), 177 deletions(-)
---
diff --git a/src/libtracker-db/Makefile.am b/src/libtracker-db/Makefile.am
index 3376aaf..43fa0af 100644
--- a/src/libtracker-db/Makefile.am
+++ b/src/libtracker-db/Makefile.am
@@ -19,7 +19,8 @@ libtracker_db_la_SOURCES = 						\
 	tracker-db-interface.c						\
 	tracker-db-interface-sqlite.c					\
 	tracker-db-manager.c						\
-	tracker-db-journal.c						
+	tracker-db-journal.c						\
+	tracker-db-config.c
 
 noinst_HEADERS =							\
 	tracker-db.h							\
@@ -27,7 +28,8 @@ noinst_HEADERS =							\
 	tracker-db-interface.h						\
 	tracker-db-interface-sqlite.h					\
 	tracker-db-manager.h 						\
-	tracker-db-journal.h
+	tracker-db-journal.h						\
+	tracker-db-config.h
 
 libtracker_db_la_LIBADD = 						\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
diff --git a/src/libtracker-db/tracker-db-config.c b/src/libtracker-db/tracker-db-config.c
new file mode 100644
index 0000000..14502aa
--- /dev/null
+++ b/src/libtracker-db/tracker-db-config.c
@@ -0,0 +1,400 @@
+/*
+ * Copyright (C) 2009, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301  USA
+ *
+ * Authors:
+ * Philip Van Hoof <philip codeminded be>
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <libtracker-common/tracker-keyfile-object.h>
+
+#include "tracker-db-config.h"
+
+#define TRACKER_DB_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DB_CONFIG, TrackerDBConfigPrivate))
+
+/* GKeyFile defines */
+#define GROUP_JOURNAL     "Journal"
+
+/* Default values */
+#define DEFAULT_JOURNAL_CHUNK_SIZE           500
+#define DEFAULT_JOURNAL_ROTATE_DESTINATION   ""
+
+typedef struct {
+	/* Journal */
+	gint journal_chunk_size;
+	gchar *journal_rotate_destination;
+}  TrackerDBConfigPrivate;
+
+typedef struct {
+	GType  type;
+	const gchar *property;
+	const gchar *group;
+	const gchar *key;
+} ObjectToKeyFile;
+
+static void config_set_property         (GObject       *object,
+                                         guint          param_id,
+                                         const GValue  *value,
+                                         GParamSpec    *pspec);
+static void config_get_property         (GObject       *object,
+                                         guint          param_id,
+                                         GValue        *value,
+                                         GParamSpec    *pspec);
+static void config_finalize             (GObject       *object);
+static void config_constructed          (GObject       *object);
+static void config_create_with_defaults (TrackerDBConfig *config,
+                                         GKeyFile      *key_file,
+                                         gboolean       overwrite);
+static void config_load                 (TrackerDBConfig *config);
+
+enum {
+	PROP_0,
+
+	/* Journal */
+	PROP_JOURNAL_CHUNK_SIZE,
+	PROP_JOURNAL_ROTATE_DESTINATION
+};
+
+static ObjectToKeyFile conversions[] = {
+	{ G_TYPE_INT,     "journal-chunk-size",         GROUP_JOURNAL,  "JournalChunkSize"         },
+	{ G_TYPE_STRING,  "journal-rotate-destination", GROUP_JOURNAL,  "JournalRotateDestination" },
+};
+
+G_DEFINE_TYPE (TrackerDBConfig, tracker_db_config, TRACKER_TYPE_CONFIG_FILE);
+
+static void
+tracker_db_config_class_init (TrackerDBConfigClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->set_property = config_set_property;
+	object_class->get_property = config_get_property;
+	object_class->finalize     = config_finalize;
+	object_class->constructed  = config_constructed;
+
+	g_object_class_install_property (object_class,
+	                                 PROP_JOURNAL_CHUNK_SIZE,
+	                                 g_param_spec_int ("journal-chunk-size",
+	                                                   "Journal chunk size",
+	                                                   " Size of the journal at rotation in MB. Use -1 to disable rotating",
+	                                                   -1,
+	                                                   G_MAXINT,
+	                                                   DEFAULT_JOURNAL_CHUNK_SIZE,
+	                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+	g_object_class_install_property (object_class,
+	                                 PROP_JOURNAL_ROTATE_DESTINATION,
+	                                 g_param_spec_string ("journal-rotate-destination",
+	                                                      "Journal rotate destination",
+	                                                      " Destination to rotate journal chunks to",
+	                                                      DEFAULT_JOURNAL_ROTATE_DESTINATION,
+	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+	g_type_class_add_private (object_class, sizeof (TrackerDBConfigPrivate));
+}
+
+static void
+tracker_db_config_init (TrackerDBConfig *object)
+{
+}
+
+static void
+config_set_property (GObject      *object,
+                     guint         param_id,
+                     const GValue *value,
+                     GParamSpec           *pspec)
+{
+	switch (param_id) {
+		/* Journal */
+	case PROP_JOURNAL_CHUNK_SIZE:
+		tracker_db_config_set_journal_chunk_size (TRACKER_DB_CONFIG (object),
+		                                          g_value_get_int(value));
+		break;
+	case PROP_JOURNAL_ROTATE_DESTINATION:
+		tracker_db_config_set_journal_rotate_destination (TRACKER_DB_CONFIG (object),
+		                                                  g_value_get_string(value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	};
+}
+
+static void
+config_get_property (GObject    *object,
+                     guint       param_id,
+                     GValue     *value,
+                     GParamSpec *pspec)
+{
+	TrackerDBConfigPrivate *priv;
+
+	priv = TRACKER_DB_CONFIG_GET_PRIVATE (object);
+
+	switch (param_id) {
+	case PROP_JOURNAL_CHUNK_SIZE:
+		g_value_set_int (value, priv->journal_chunk_size);
+		break;
+	case PROP_JOURNAL_ROTATE_DESTINATION:
+		g_value_set_string (value, priv->journal_rotate_destination);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	};
+}
+
+static void
+config_finalize (GObject *object)
+{
+	TrackerDBConfigPrivate *priv;
+
+	priv = TRACKER_DB_CONFIG_GET_PRIVATE (object);
+
+	g_free (priv->journal_rotate_destination);
+
+	(G_OBJECT_CLASS (tracker_db_config_parent_class)->finalize) (object);
+}
+
+static void
+config_constructed (GObject *object)
+{
+	(G_OBJECT_CLASS (tracker_db_config_parent_class)->constructed) (object);
+
+	config_load (TRACKER_DB_CONFIG (object));
+}
+
+static void
+config_create_with_defaults (TrackerDBConfig *config,
+                             GKeyFile      *key_file,
+                             gboolean       overwrite)
+{
+	gint i;
+
+	g_message ("Loading defaults into GKeyFile...");
+
+	for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
+		gboolean has_key;
+
+		has_key = g_key_file_has_key (key_file,
+		                              conversions[i].group,
+		                              conversions[i].key,
+		                              NULL);
+		if (!overwrite && has_key) {
+			continue;
+		}
+
+		switch (conversions[i].type) {
+		case G_TYPE_INT:
+			g_key_file_set_integer (key_file,
+			                        conversions[i].group,
+			                        conversions[i].key,
+			                        tracker_keyfile_object_default_int (config,
+			                                                            conversions[i].property));
+			break;
+
+		case G_TYPE_STRING:
+			g_key_file_set_string (key_file,
+			                       conversions[i].group,
+			                       conversions[i].key,
+			                       tracker_keyfile_object_default_string (config,
+			                                                              conversions[i].property));
+			break;
+
+		default:
+			g_assert_not_reached ();
+			break;
+		}
+
+		g_key_file_set_comment (key_file,
+		                        conversions[i].group,
+		                        conversions[i].key,
+		                        tracker_keyfile_object_blurb (config,
+		                                                      conversions[i].property),
+		                        NULL);
+	}
+}
+
+static void
+config_load (TrackerDBConfig *config)
+{
+	TrackerConfigFile *file;
+	gint i;
+
+	file = TRACKER_CONFIG_FILE (config);
+	config_create_with_defaults (config, file->key_file, FALSE);
+
+	if (!file->file_exists) {
+		tracker_config_file_save (file);
+	}
+
+	for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
+		gboolean has_key;
+
+		has_key = g_key_file_has_key (file->key_file,
+		                              conversions[i].group,
+		                              conversions[i].key,
+		                              NULL);
+
+		switch (conversions[i].type) {
+		case G_TYPE_INT:
+			tracker_keyfile_object_load_int (G_OBJECT (file),
+			                                 conversions[i].property,
+			                                 file->key_file,
+			                                 conversions[i].group,
+			                                 conversions[i].key);
+			break;
+
+		case G_TYPE_STRING:
+			tracker_keyfile_object_load_string (G_OBJECT (file),
+			                                    conversions[i].property,
+			                                    file->key_file,
+			                                    conversions[i].group,
+			                                    conversions[i].key);
+			break;
+
+		default:
+			g_assert_not_reached ();
+			break;
+		}
+	}
+}
+
+static gboolean
+config_save (TrackerDBConfig *config)
+{
+	TrackerConfigFile *file;
+	gint i;
+
+	file = TRACKER_CONFIG_FILE (config);
+
+	if (!file->key_file) {
+		g_critical ("Could not save config, GKeyFile was NULL, has the config been loaded?");
+
+		return FALSE;
+	}
+
+	g_message ("Setting details to GKeyFile object...");
+
+	for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
+		switch (conversions[i].type) {
+		case G_TYPE_INT:
+			tracker_keyfile_object_save_int (file,
+			                                 conversions[i].property,
+			                                 file->key_file,
+			                                 conversions[i].group,
+			                                 conversions[i].key);
+			break;
+
+		case G_TYPE_STRING:
+			tracker_keyfile_object_save_string (file,
+			                                    conversions[i].property,
+			                                    file->key_file,
+			                                    conversions[i].group,
+			                                    conversions[i].key);
+			break;
+
+		default:
+			g_assert_not_reached ();
+			break;
+		}
+	}
+
+	return tracker_config_file_save (TRACKER_CONFIG_FILE (config));
+}
+
+TrackerDBConfig *
+tracker_db_config_new (void)
+{
+	return g_object_new (TRACKER_TYPE_DB_CONFIG,
+	                     "domain", "tracker-db",
+	                     NULL);
+}
+
+gboolean
+tracker_db_config_save (TrackerDBConfig *config)
+{
+	g_return_val_if_fail (TRACKER_IS_DB_CONFIG (config), FALSE);
+
+	return config_save (config);
+}
+
+
+gint
+tracker_db_config_get_journal_chunk_size (TrackerDBConfig *config)
+{
+	TrackerDBConfigPrivate *priv;
+
+	g_return_val_if_fail (TRACKER_IS_DB_CONFIG (config), DEFAULT_JOURNAL_CHUNK_SIZE);
+
+	priv = TRACKER_DB_CONFIG_GET_PRIVATE (config);
+
+	return priv->journal_chunk_size;
+}
+
+const gchar *
+tracker_db_config_get_journal_rotate_destination (TrackerDBConfig *config)
+{
+	TrackerDBConfigPrivate *priv;
+
+	g_return_val_if_fail (TRACKER_IS_DB_CONFIG (config), DEFAULT_JOURNAL_ROTATE_DESTINATION);
+
+	priv = TRACKER_DB_CONFIG_GET_PRIVATE (config);
+
+	return priv->journal_rotate_destination;
+}
+
+void
+tracker_db_config_set_journal_chunk_size (TrackerDBConfig *config,
+                                          gint             value)
+{
+	TrackerDBConfigPrivate *priv;
+
+	g_return_if_fail (TRACKER_IS_DB_CONFIG (config));
+
+	if (!tracker_keyfile_object_validate_int (config, "journal-chunk-size", value)) {
+		return;
+	}
+
+	priv = TRACKER_DB_CONFIG_GET_PRIVATE (config);
+
+	priv->journal_chunk_size = value;
+	g_object_notify (G_OBJECT (config), "journal-chunk-size");
+}
+
+void
+tracker_db_config_set_journal_rotate_destination (TrackerDBConfig *config,
+                                                  const gchar     *value)
+{
+	TrackerDBConfigPrivate *priv;
+
+	g_return_if_fail (TRACKER_IS_DB_CONFIG (config));
+
+	priv = TRACKER_DB_CONFIG_GET_PRIVATE (config);
+
+	g_free (priv->journal_rotate_destination);
+	priv->journal_rotate_destination = g_strdup (value);
+
+	g_object_notify (G_OBJECT (config), "journal-rotate-destination");
+}
diff --git a/src/libtracker-db/tracker-db-config.h b/src/libtracker-db/tracker-db-config.h
new file mode 100644
index 0000000..ff573a2
--- /dev/null
+++ b/src/libtracker-db/tracker-db-config.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2009, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301  USA
+ *
+ * Authors:
+ * Philip Van Hoof <philip codeminded be>
+ */
+
+#ifndef __TRACKER_DB_CONFIG_H__
+#define __TRACKER_DB_CONFIG_H__
+
+#if !defined (__LIBTRACKER_DB_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "only <libtracker-db/tracker-db.h> must be included directly."
+#endif
+
+#include <glib-object.h>
+
+#include <libtracker-common/tracker-config-file.h>
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_DB_CONFIG         (tracker_db_config_get_type ())
+#define TRACKER_DB_CONFIG(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_DB_CONFIG, TrackerDBConfig))
+#define TRACKER_DB_CONFIG_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), TRACKER_TYPE_DB_CONFIG, TrackerDBConfigClass))
+#define TRACKER_IS_DB_CONFIG(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_DB_CONFIG))
+#define TRACKER_IS_DB_CONFIG_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TRACKER_TYPE_DB_CONFIG))
+#define TRACKER_DB_CONFIG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_DB_CONFIG, TrackerDBConfigClass))
+
+typedef struct TrackerDBConfig              TrackerDBConfig;
+typedef struct TrackerDBConfigClass TrackerDBConfigClass;
+
+struct TrackerDBConfig {
+	TrackerConfigFile parent;
+};
+
+struct TrackerDBConfigClass {
+	TrackerConfigFileClass parent_class;
+};
+
+GType            tracker_db_config_get_type                       (void) G_GNUC_CONST;
+
+TrackerDBConfig *tracker_db_config_new                            (void);
+gboolean         tracker_db_config_save                           (TrackerDBConfig *config);
+
+gint             tracker_db_config_get_journal_chunk_size         (TrackerDBConfig *config);
+const gchar *    tracker_db_config_get_journal_rotate_destination (TrackerDBConfig *config);
+
+void             tracker_db_config_set_journal_chunk_size         (TrackerDBConfig *config,
+                                                                   gint             value);
+void             tracker_db_config_set_journal_rotate_destination (TrackerDBConfig *config,
+                                                                   const gchar     *value);
+
+G_END_DECLS
+
+#endif /* __TRACKER_DB_CONFIG_H__ */
+
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index e30dacb..a208eb2 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -428,7 +428,6 @@ db_manager_remove_all (gboolean rm_journal)
 			const gchar *dirs[3] = { NULL, NULL, NULL };
 
 			cpath = g_strdup (opath);
-			tracker_db_journal_shutdown ();
 
 			g_message ("  Removing journal:'%s'", cpath);
 
@@ -436,6 +435,8 @@ db_manager_remove_all (gboolean rm_journal)
 
 			tracker_db_journal_get_rotating (&do_rotate, &chunk_size, &rotate_to);
 
+			tracker_db_journal_shutdown ();
+
 			dirs[0] = directory;
 			dirs[1] = do_rotate ? rotate_to : NULL;
 
@@ -457,7 +458,7 @@ db_manager_remove_all (gboolean rm_journal)
 						}
 					}
 
-					fullpath = g_build_filename (directory, f_name, NULL);
+					fullpath = g_build_filename (dirs[i], f_name, NULL);
 					file = g_file_new_for_path (fullpath);
 					g_file_delete (file, NULL, NULL);
 					g_object_unref (file);
diff --git a/src/libtracker-db/tracker-db.h b/src/libtracker-db/tracker-db.h
index 5af852f..ea11902 100644
--- a/src/libtracker-db/tracker-db.h
+++ b/src/libtracker-db/tracker-db.h
@@ -33,6 +33,7 @@ G_BEGIN_DECLS
 #include "tracker-db-interface-sqlite.h"
 #include "tracker-db-journal.h"
 #include "tracker-db-manager.h"
+#include "tracker-db-config.h"
 
 #undef __LIBTRACKER_DB_INSIDE__
 
diff --git a/src/tracker-control/tracker-control.c b/src/tracker-control/tracker-control.c
index 61aed09..9363d47 100644
--- a/src/tracker-control/tracker-control.c
+++ b/src/tracker-control/tracker-control.c
@@ -401,15 +401,13 @@ main (int argc, char **argv)
 
 	if (hard_reset || soft_reset) {
 		guint log_handler_id;
-		gboolean do_rotating = FALSE;
-		gsize chunk_size = G_MAXSIZE;
-		gchar *rotate_to = NULL;
-		GKeyFile *key_file;
-		gchar *tracker_store_config;
+		const gchar *rotate_to = NULL;
+		TrackerDBConfig *db_config;
+		gsize chunk_size;
+		gint chunk_size_mb;
 
-		tracker_store_config = g_build_filename (g_get_user_config_dir (),
-		                                         "tracker", "tracker-store.cfg",
-		                                         NULL);
+
+		db_config = tracker_db_config_new ();
 
 		/* Set log handler for library messages */
 		log_handler_id = g_log_set_handler (NULL,
@@ -419,37 +417,15 @@ main (int argc, char **argv)
 
 		g_log_set_default_handler (log_handler, NULL);
 
-		key_file = g_key_file_new ();
-
-		if (g_key_file_load_from_file (key_file, tracker_store_config,
-		                               G_KEY_FILE_NONE, NULL)) {
-			gint chunk_size;
-			GError *error = NULL;
-
-			chunk_size = g_key_file_get_integer (key_file, "Journal",
-			                                     "JournalChunkSize", &error);
-
-			if (error) {
-				g_clear_error (&error);
-			} else if (chunk_size > 0) {
-				do_rotating = TRUE;
-			}
-
-			rotate_to = g_key_file_get_string (key_file, "Journal",
-			                                   "JournalRotateDestination", &error);
+		chunk_size_mb = tracker_db_config_get_journal_chunk_size (db_config);
+		chunk_size = (gsize) ((gsize) chunk_size_mb * (gsize) 1024 * (gsize) 1024);
+		rotate_to = tracker_db_config_get_journal_rotate_destination (db_config);
 
-			if (error) {
-				g_error_free (error);
-				rotate_to = NULL;
-			}
-		}
-		
 		/* This call is needed to set the journal's filename */
-		tracker_db_journal_init (NULL, FALSE, do_rotating, chunk_size, rotate_to);
+		tracker_db_journal_init (NULL, FALSE, (chunk_size_mb != -1),
+		                         chunk_size, rotate_to);
 
-		g_free (rotate_to);
-		g_free (tracker_store_config);
-		g_key_file_free (key_file);
+		g_object_unref (db_config);
 
 		/* Clean up */
 		if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL, NULL, FALSE)) {
diff --git a/src/tracker-store/tracker-config.c b/src/tracker-store/tracker-config.c
index bcd5d2d..349b9e8 100644
--- a/src/tracker-store/tracker-config.c
+++ b/src/tracker-store/tracker-config.c
@@ -33,22 +33,15 @@
 
 /* GKeyFile defines */
 #define GROUP_GENERAL     "General"
-#define GROUP_JOURNAL     "Journal"
 
 /* Default values */
 #define DEFAULT_VERBOSITY                    2
-#define DEFAULT_JOURNAL_CHUNK_SIZE           500
-#define DEFAULT_JOURNAL_ROTATE_DESTINATION   ""
 
 /* typedef struct TrackerConfigPrivate TrackerConfigPrivate; */
 
 typedef struct {
 	/* General */
 	gint verbosity;
-
-	/* Journal */
-	gint journal_chunk_size;
-	gchar *journal_rotate_destination;
 } TrackerConfigPrivate;
 
 typedef struct {
@@ -78,20 +71,10 @@ enum {
 
 	/* General */
 	PROP_VERBOSITY,
-
-	/* Journal */
-	PROP_JOURNAL_CHUNK_SIZE,
-	PROP_JOURNAL_ROTATE_DESTINATION
 };
 
-/* If you change these values, please also check
- * ../src/tracker-control/tracker-control.c~417 */
-
 static ObjectToKeyFile conversions[] = {
-	{ G_TYPE_INT,     "verbosity",                  GROUP_GENERAL,  "Verbosity"                },
-	{ G_TYPE_INT,     "journal-chunk-size",         GROUP_JOURNAL,  "JournalChunkSize"         },
-	{ G_TYPE_STRING,  "journal-rotate-destination", GROUP_JOURNAL,  "JournalRotateDestination" },
-
+	{ G_TYPE_INT, "verbosity", GROUP_GENERAL,  "Verbosity" },
 };
 
 G_DEFINE_TYPE (TrackerConfig, tracker_config, TRACKER_TYPE_CONFIG_FILE);
@@ -117,24 +100,6 @@ tracker_config_class_init (TrackerConfigClass *klass)
 	                                                   DEFAULT_VERBOSITY,
 	                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-	g_object_class_install_property (object_class,
-	                                 PROP_JOURNAL_CHUNK_SIZE,
-	                                 g_param_spec_int ("journal-chunk-size",
-	                                                   "Journal chunk size",
-	                                                   " Size of the journal at rotation in MB. Use -1 to disable rotating",
-	                                                   -1,
-	                                                   G_MAXINT,
-	                                                   DEFAULT_JOURNAL_CHUNK_SIZE,
-	                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-	g_object_class_install_property (object_class,
-	                                 PROP_JOURNAL_ROTATE_DESTINATION,
-	                                 g_param_spec_string ("journal-rotate-destination",
-	                                                      "Journal rotate destination",
-	                                                      " Destination to rotate journal chunks to",
-	                                                      DEFAULT_JOURNAL_ROTATE_DESTINATION,
-	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
 	g_type_class_add_private (object_class, sizeof (TrackerConfigPrivate));
 }
 
@@ -155,15 +120,6 @@ config_set_property (GObject      *object,
 		tracker_config_set_verbosity (TRACKER_CONFIG (object),
 		                              g_value_get_int (value));
 		break;
-		/* Journal */
-	case PROP_JOURNAL_CHUNK_SIZE:
-		tracker_config_set_journal_chunk_size (TRACKER_CONFIG (object),
-		                                       g_value_get_int(value));
-		break;
-	case PROP_JOURNAL_ROTATE_DESTINATION:
-		tracker_config_set_journal_rotate_destination (TRACKER_CONFIG (object),
-		                                               g_value_get_string(value));
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 		break;
@@ -185,12 +141,6 @@ config_get_property (GObject    *object,
 	case PROP_VERBOSITY:
 		g_value_set_int (value, priv->verbosity);
 		break;
-	case PROP_JOURNAL_CHUNK_SIZE:
-		g_value_set_int (value, priv->journal_chunk_size);
-		break;
-	case PROP_JOURNAL_ROTATE_DESTINATION:
-		g_value_set_string (value, priv->journal_rotate_destination);
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 		break;
@@ -200,11 +150,9 @@ config_get_property (GObject    *object,
 static void
 config_finalize (GObject *object)
 {
-	TrackerConfigPrivate *priv;
-
-	priv = TRACKER_CONFIG_GET_PRIVATE (object);
-
-	g_free (priv->journal_rotate_destination);
+	/* For now we do nothing here, we left this override in for
+	 * future expansion.
+	 */
 
 	(G_OBJECT_CLASS (tracker_config_parent_class)->finalize) (object);
 }
@@ -254,14 +202,6 @@ config_create_with_defaults (TrackerConfig *config,
 			                                                                conversions[i].property));
 			break;
 
-		case G_TYPE_STRING:
-			g_key_file_set_string (key_file,
-			                       conversions[i].group,
-			                       conversions[i].key,
-			                       tracker_keyfile_object_default_string (config,
-			                                                              conversions[i].property));
-			break;
-
 		default:
 			g_assert_not_reached ();
 			break;
@@ -314,14 +254,6 @@ config_load (TrackerConfig *config)
 			                                     conversions[i].key);
 			break;
 
-		case G_TYPE_STRING:
-			tracker_keyfile_object_load_string (G_OBJECT (file),
-			                                    conversions[i].property,
-			                                    file->key_file,
-			                                    conversions[i].group,
-			                                    conversions[i].key);
-			break;
-
 		default:
 			g_assert_not_reached ();
 			break;
@@ -398,48 +330,6 @@ tracker_config_get_verbosity (TrackerConfig *config)
 	return priv->verbosity;
 }
 
-gint
-tracker_config_get_journal_chunk_size (TrackerConfig *config)
-{
-	TrackerConfigPrivate *priv;
-
-	g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_JOURNAL_CHUNK_SIZE);
-
-	priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
-	return priv->journal_chunk_size;
-}
-
-const gchar *
-tracker_config_get_journal_rotate_destination (TrackerConfig *config)
-{
-	TrackerConfigPrivate *priv;
-
-	g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_JOURNAL_ROTATE_DESTINATION);
-
-	priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
-	return priv->journal_rotate_destination;
-}
-
-void
-tracker_config_set_journal_chunk_size (TrackerConfig *config,
-                                       gint           value)
-{
-	TrackerConfigPrivate *priv;
-
-	g_return_if_fail (TRACKER_IS_CONFIG (config));
-
-	if (!tracker_keyfile_object_validate_int (config, "journal-chunk-size", value)) {
-		return;
-	}
-
-	priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
-	priv->journal_chunk_size = value;
-	g_object_notify (G_OBJECT (config), "journal-chunk-size");
-}
-
 void
 tracker_config_set_verbosity (TrackerConfig *config,
                               gint           value)
@@ -458,18 +348,3 @@ tracker_config_set_verbosity (TrackerConfig *config,
 	g_object_notify (G_OBJECT (config), "verbosity");
 }
 
-void
-tracker_config_set_journal_rotate_destination (TrackerConfig *config,
-                                               const gchar   *value)
-{
-	TrackerConfigPrivate *priv;
-
-	g_return_if_fail (TRACKER_IS_CONFIG (config));
-
-	priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
-	g_free (priv->journal_rotate_destination);
-	priv->journal_rotate_destination = g_strdup (value);
-
-	g_object_notify (G_OBJECT (config), "journal-rotate-destination");
-}
diff --git a/src/tracker-store/tracker-config.h b/src/tracker-store/tracker-config.h
index 2d56e4b..a7dbe6b 100644
--- a/src/tracker-store/tracker-config.h
+++ b/src/tracker-store/tracker-config.h
@@ -49,15 +49,9 @@ GType          tracker_config_get_type                             (void) G_GNUC
 TrackerConfig *tracker_config_new                                  (void);
 gboolean       tracker_config_save                                 (TrackerConfig *config);
 gint           tracker_config_get_verbosity                        (TrackerConfig *config);
-gint           tracker_config_get_journal_chunk_size               (TrackerConfig *config);
-const gchar *  tracker_config_get_journal_rotate_destination       (TrackerConfig *config);
 
 void           tracker_config_set_verbosity                        (TrackerConfig *config,
                                                                     gint           value);
-void           tracker_config_set_journal_chunk_size               (TrackerConfig *config,
-                                                                    gint           value);
-void           tracker_config_set_journal_rotate_destination       (TrackerConfig *config,
-                                                                    const gchar   *value);
 
 G_END_DECLS
 
diff --git a/src/tracker-store/tracker-main.c b/src/tracker-store/tracker-main.c
index 415f0d0..3e1ad3e 100644
--- a/src/tracker-store/tracker-main.c
+++ b/src/tracker-store/tracker-main.c
@@ -44,6 +44,7 @@
 
 #include <libtracker-db/tracker-db-manager.h>
 #include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-db/tracker-db-config.h>
 
 #include <libtracker-data/tracker-data-manager.h>
 #include <libtracker-data/tracker-data-backup.h>
@@ -336,6 +337,7 @@ main (gint argc, gchar *argv[])
 	gint chunk_size_mb;
 	gsize chunk_size;
 	const gchar *rotate_to;
+	TrackerDBConfig *db_config;
 
 	g_type_init ();
 
@@ -401,6 +403,7 @@ main (gint argc, gchar *argv[])
 
 	/* Initialize major subsystems */
 	config = tracker_config_new ();
+	db_config = tracker_db_config_new ();
 
 	g_signal_connect (config, "notify::verbosity",
 	                  G_CALLBACK (config_verbosity_changed_cb),
@@ -417,6 +420,7 @@ main (gint argc, gchar *argv[])
 	initialize_directories ();
 
 	if (!tracker_dbus_init ()) {
+		g_object_unref (db_config);
 		return EXIT_FAILURE;
 	}
 
@@ -440,9 +444,9 @@ main (gint argc, gchar *argv[])
 	busy_callback = tracker_status_get_callback (notifier, 
 	                                            &busy_user_data);
 
-	chunk_size_mb = tracker_config_get_journal_chunk_size (config);
+	chunk_size_mb = tracker_db_config_get_journal_chunk_size (db_config);
 	chunk_size = (gsize) ((gsize) chunk_size_mb * (gsize) 1024 * (gsize) 1024);
-	rotate_to = tracker_config_get_journal_rotate_destination (config);
+	rotate_to = tracker_db_config_get_journal_rotate_destination (db_config);
 
 	if (rotate_to[0] == '\0')
 		rotate_to = NULL;
@@ -458,10 +462,12 @@ main (gint argc, gchar *argv[])
 	                                busy_user_data,
 	                                "Journal replaying")) {
 
+		g_object_unref (db_config);
 		g_object_unref (notifier);
 		return EXIT_FAILURE;
 	}
 
+	g_object_unref (db_config);
 	g_object_unref (notifier);
 
 	tracker_store_init ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]