tracker r1519 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/tracker-indexer src/trackerd



Author: mr
Date: Wed May 28 14:44:35 2008
New Revision: 1519
URL: http://svn.gnome.org/viewvc/tracker?rev=1519&view=rev

Log:
	* src/libtracker-common/Makefile.am:
	* src/libtracker-common/tracker-dbus.c: Added this for the most
	common DBus functionality, such as creating requests and logging
	request comments, etc.

	* src/libtracker-db/Makefile.am:
	* src/libtracker-db/tracker-db-dbus.c: Added for converting
	TrackerDBResultSet information into Glib types to be transported
	over DBus.

	* src/tracker-indexer/Makefile.am:
	* src/tracker-indexer/tracker-dbus.c:
	* src/tracker-indexer/tracker-indexer.h:
	* src/tracker-indexer/tracker-main.c: Added initial DBus support
	to register the tracker-indexer name on startup to start receiving
	requests from the daemon.

	* src/trackerd/Makefile.am:
	* src/trackerd/tracker-dbus-daemon.[ch]:
	* src/trackerd/tracker-dbus-files.[ch]:
	* src/trackerd/tracker-dbus-keywords.[ch]:
	* src/trackerd/tracker-dbus-metadata.[ch]:
	* src/trackerd/tracker-dbus-search.[ch]:
	* src/trackerd/tracker-dbus-xesam.[ch]:
	* src/trackerd/tracker-dbus.[ch]:
	* src/trackerd/tracker-main.c:
	* src/trackerd/tracker-xesam-live-search.c: Cleaned up the
	includes which were overly bloated. Also improved the tracker-dbus
	API so it is obvious we initialise it first (for registering the
	name) and we register objects later. Before with init() and
	preinit() it wasn't clear why we needed that.


Added:
   branches/indexer-split/src/libtracker-common/tracker-dbus.c
   branches/indexer-split/src/libtracker-db/tracker-db-dbus.c
   branches/indexer-split/src/tracker-indexer/tracker-dbus.c
Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/libtracker-common/Makefile.am
   branches/indexer-split/src/libtracker-db/Makefile.am
   branches/indexer-split/src/tracker-indexer/Makefile.am
   branches/indexer-split/src/tracker-indexer/tracker-indexer.h
   branches/indexer-split/src/tracker-indexer/tracker-main.c
   branches/indexer-split/src/trackerd/Makefile.am
   branches/indexer-split/src/trackerd/tracker-dbus-daemon.c
   branches/indexer-split/src/trackerd/tracker-dbus-daemon.h
   branches/indexer-split/src/trackerd/tracker-dbus-files.c
   branches/indexer-split/src/trackerd/tracker-dbus-files.h
   branches/indexer-split/src/trackerd/tracker-dbus-keywords.c
   branches/indexer-split/src/trackerd/tracker-dbus-keywords.h
   branches/indexer-split/src/trackerd/tracker-dbus-metadata.c
   branches/indexer-split/src/trackerd/tracker-dbus-metadata.h
   branches/indexer-split/src/trackerd/tracker-dbus-search.c
   branches/indexer-split/src/trackerd/tracker-dbus-search.h
   branches/indexer-split/src/trackerd/tracker-dbus-xesam.c
   branches/indexer-split/src/trackerd/tracker-dbus-xesam.h
   branches/indexer-split/src/trackerd/tracker-dbus.c
   branches/indexer-split/src/trackerd/tracker-dbus.h
   branches/indexer-split/src/trackerd/tracker-main.c
   branches/indexer-split/src/trackerd/tracker-xesam-live-search.c

Modified: branches/indexer-split/src/libtracker-common/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-common/Makefile.am	(original)
+++ branches/indexer-split/src/libtracker-common/Makefile.am	Wed May 28 14:44:35 2008
@@ -2,9 +2,10 @@
 	-DSHAREDIR=\""$(datadir)"\"		\
 	-DG_LOG_DOMAIN=\"Tracker\"		\
 	-I$(top_srcdir)/src			\
-	$(GLIB2_CFLAGS)				\
+	$(HAL_CFLAGS)				\
+	$(DBUS_CFLAGS)				\
 	$(PANGO_CFLAGS)				\
-	$(HAL_CFLAGS)
+	$(GLIB2_CFLAGS)
 
 noinst_LTLIBRARIES = libtracker-common.la
 
@@ -27,6 +28,8 @@
 	tracker-configuration.h 		\
 	tracker-config.c 			\
 	tracker-config.h			\
+	tracker-dbus.c	 			\
+	tracker-dbus.h				\
 	tracker-field.c				\
 	tracker-field.h				\
 	tracker-field-data.c			\
@@ -55,7 +58,8 @@
 
 libtracker_common_la_LDFLAGS = -version-info 0:0:0
 libtracker_common_la_LIBADD = 			\
-	$(GLIB2_LIBS)				\
+	$(HAL_LIBS)				\
+	$(DBUS_LIBS)				\
 	$(PANGO_LIBS)				\
-	$(HAL_LIBS)
+	$(GLIB2_LIBS)
 

Added: branches/indexer-split/src/libtracker-common/tracker-dbus.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libtracker-common/tracker-dbus.c	Wed May 28 14:44:35 2008
@@ -0,0 +1,153 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include "tracker-dbus.h"
+
+GValue *
+tracker_dbus_g_value_slice_new (GType type)
+{
+	GValue *value;
+
+	value = g_slice_new0 (GValue);
+	g_value_init (value, type);
+
+	return value;
+}
+
+void
+tracker_dbus_g_value_slice_free (GValue *value)
+{
+	g_value_unset (value);
+	g_slice_free (GValue, value);
+}
+
+GQuark
+tracker_dbus_error_quark (void)
+{
+	return g_quark_from_static_string (TRACKER_DBUS_ERROR_DOMAIN);
+}
+
+TrackerDBusData *
+tracker_dbus_data_new (const gpointer arg1, 
+                       const gpointer arg2)
+{
+        TrackerDBusData *data;
+
+        data = g_new0 (TrackerDBusData, 1);
+
+        data->id = tracker_dbus_get_next_request_id ();
+
+        data->data1 = arg1;
+        data->data2 = arg2;
+
+        return data;
+}
+
+gchar **
+tracker_dbus_slist_to_strv (GSList *list)
+{
+	GSList  *l;
+	gchar  **strv;
+	gint     i = 0;
+
+	strv = g_new0 (gchar*, g_slist_length (list) + 1);
+				
+        for (l = list; l != NULL; l = l->next) {
+                strv[i++] = g_strdup (l->data);
+	}
+
+        strv[i] = NULL;
+
+	return strv;
+}
+
+guint
+tracker_dbus_get_next_request_id (void)
+{
+        static guint request_id = 1;
+	
+        return request_id++;
+}
+
+void
+tracker_dbus_request_new (gint          request_id,
+			  const gchar  *format, 
+			  ...)
+{
+	gchar   *str;
+	va_list  args;
+
+	va_start (args, format);
+	str = g_strdup_vprintf (format, args);
+	va_end (args);
+	
+	g_message ("<--- [%d] %s",
+		   request_id,
+		   str);
+
+	g_free (str);
+}
+
+void
+tracker_dbus_request_success (gint request_id)
+{
+	g_message ("---> [%d] Success, no error given", 
+		   request_id);
+}
+
+void
+tracker_dbus_request_failed (gint          request_id,
+			     GError      **error,
+			     const gchar  *format, 
+			     ...)
+{
+	gchar   *str;
+	va_list  args;
+
+	va_start (args, format);
+	str = g_strdup_vprintf (format, args);
+	va_end (args);
+
+	g_set_error (error, TRACKER_DBUS_ERROR, 0, str);
+
+	g_message ("---> [%d] Failed, %s",
+		   request_id,
+		   str);
+	g_free (str);
+}
+
+void
+tracker_dbus_request_comment (gint         request_id,
+			      const gchar *format,
+			      ...)
+{
+	gchar   *str;
+	va_list  args;
+
+	va_start (args, format);
+	str = g_strdup_vprintf (format, args);
+	va_end (args);
+
+	g_message ("---- [%d] %s", 
+		   request_id, 
+		   str);
+	g_free (str);
+}

Modified: branches/indexer-split/src/libtracker-db/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-db/Makefile.am	(original)
+++ branches/indexer-split/src/libtracker-db/Makefile.am	Wed May 28 14:44:35 2008
@@ -3,15 +3,18 @@
 	-DSHAREDIR=\""$(datadir)"\"					\
 	-DG_LOG_DOMAIN=\"Tracker\"					\
 	-I$(top_srcdir)/src						\
-	$(GLIB2_CFLAGS)							\
 	$(SQLITE3_CFLAGS)						\
-	$(QDBM_CFLAGS)
+	$(QDBM_CFLAGS)							\
+	$(DBUS_CFLAGS)							\
+	$(GLIB2_CFLAGS)
 
 noinst_LTLIBRARIES = libtracker-db.la
 
 libtracker_db_la_SOURCES = 						\
 	tracker-db-action.c						\
 	tracker-db-action.h						\
+	tracker-db-dbus.c						\
+	tracker-db-dbus.h						\
 	tracker-db-file-info.c						\
 	tracker-db-file-info.h						\
 	tracker-db-interface.c						\
@@ -23,6 +26,7 @@
 
 libtracker_db_la_LDFLAGS = -version-info 0:0:0
 libtracker_db_la_LIBADD = 						\
-	$(GLIB2_LIBS)							\
 	$(SQLITE3_LIBS)							\
-	$(QDBM_LIBS)
+	$(QDBM_LIBS)							\
+	$(DBUS_LIBS)							\
+	$(GLIB2_LIBS)

Added: branches/indexer-split/src/libtracker-db/tracker-db-dbus.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libtracker-db/tracker-db-dbus.c	Wed May 28 14:44:35 2008
@@ -0,0 +1,164 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include <libtracker-common/tracker-dbus.h>
+
+#include "tracker-db-dbus.h"
+
+gchar **
+tracker_dbus_query_result_to_strv (TrackerDBResultSet *result_set, 
+                                   gint               *count)
+{
+	gchar **strv = NULL;
+        gint    rows = 0;
+
+	if (result_set) {
+		gboolean valid = TRUE;
+		gint     i = 0;
+
+                rows = tracker_db_result_set_get_n_rows (result_set);
+		strv = g_new (gchar*, rows + 1);
+		
+		while (valid) {
+			tracker_db_result_set_get (result_set, 0, &strv[i], -1);
+			valid = tracker_db_result_set_iter_next (result_set);
+			i++;
+		}
+		strv[i] = NULL;
+	}
+
+        if (count) {
+                *count = rows;
+        }
+
+	return strv;
+}
+
+GHashTable *
+tracker_dbus_query_result_to_hash_table (TrackerDBResultSet *result_set)
+{
+        GHashTable *hash_table;
+	gint        field_count;
+	gboolean    valid = FALSE;
+
+	hash_table = g_hash_table_new_full (g_str_hash,
+                                            g_str_equal,
+                                            (GDestroyNotify) g_free,
+                                            (GDestroyNotify) tracker_dbus_g_value_slice_free);       
+
+	if (result_set) {
+		valid = TRUE;
+		field_count = tracker_db_result_set_get_n_columns (result_set);
+        }
+
+	while (valid) {
+		GValue   transform;
+		GValue  *values;
+                gchar  **p;
+                gint     field_count;
+                gint     i = 0;
+		gchar   *key;
+		GSList  *list = NULL;
+
+		g_value_init (&transform, G_TYPE_STRING);
+
+		tracker_db_result_set_get (result_set, 0, &key, -1);
+		values = tracker_dbus_g_value_slice_new (G_TYPE_STRV);
+
+                for (i = 1; i < field_count; i++) {
+			GValue       value;
+			const gchar *str;
+
+			_tracker_db_result_set_get_value (result_set, i, &value);
+
+			if (g_value_transform (&value, &transform)) {
+				str = g_value_dup_string (&transform);
+			} else {
+				str = g_strdup ("");
+			}
+
+			list = g_slist_prepend (list, (gchar*) str);
+		}
+
+		list = g_slist_reverse (list);
+		p = tracker_dbus_slist_to_strv (list);
+		g_slist_free (list);
+		g_value_take_boxed (values, p);
+		g_hash_table_insert (hash_table, key, values);
+
+		valid = tracker_db_result_set_iter_next (result_set);
+        }
+
+        return hash_table;
+}
+
+GPtrArray *
+tracker_dbus_query_result_to_ptr_array (TrackerDBResultSet *result_set)
+{
+        GPtrArray *ptr_array;
+	gboolean   valid = FALSE;
+	gint       columns;
+        gint       i;
+
+	ptr_array = g_ptr_array_new ();
+
+	if (result_set) {
+		valid = TRUE;
+		columns = tracker_db_result_set_get_n_columns (result_set);
+	}
+
+	while (valid) {
+		GSList  *list = NULL;
+		GValue   transform = { 0, };
+		gchar  **p;
+
+		g_value_init (&transform, G_TYPE_STRING);
+
+		/* Append fields to the array */
+		for (i = 0; i < columns; i++) {
+			GValue       value = { 0, };
+			const gchar *str;
+
+			_tracker_db_result_set_get_value (result_set, i, &value);
+			
+			if (g_value_transform (&value, &transform)) {
+				str = g_value_dup_string (&transform);
+			} else {
+				str = g_strdup ("");
+			}
+
+			list = g_slist_prepend (list, (gchar*) str);
+
+			g_value_unset (&value);
+			g_value_reset (&transform);
+		}
+		
+		list = g_slist_reverse (list);
+		p = tracker_dbus_slist_to_strv (list);
+		g_slist_free (list);
+		g_ptr_array_add (ptr_array, p);
+
+		valid = tracker_db_result_set_iter_next (result_set);
+	}
+
+        return ptr_array;
+}
+

Modified: branches/indexer-split/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-indexer/Makefile.am	(original)
+++ branches/indexer-split/src/tracker-indexer/Makefile.am	Wed May 28 14:44:35 2008
@@ -6,13 +6,16 @@
 	-DLOCALEDIR=\""$(localedir)"\" 					\
 	-DINDEXER_MODULES_DIR=\""$(libdir)"/tracker/indexer-modules\"	\
 	-DG_LOG_DOMAIN=\"Tracker-Indexer\"				\
-	$(GLIB2_CFLAGS)							\
+	-I$(top_srcdir)/src						\
+	$(DBUS_CFLAGS)							\
 	$(GMODULE_CFLAGS)						\
-	-I$(top_srcdir)/src
+	$(GLIB2_CFLAGS)
 
 bin_PROGRAMS = tracker-indexer
 
 tracker_indexer_SOURCES =						\
+	tracker-dbus.c							\
+	tracker-dbus.h							\
 	tracker-ioprio.c						\
 	tracker-ioprio.h						\
 	tracker-indexer.c						\
@@ -24,35 +27,15 @@
 	tracker-metadata.h
 
 tracker_indexer_LDADD =							\
-	$(GLIB2_LIBS)							\
-	$(GMODULE_LIBS)							\
-	$(GTHREAD_LIBS)							\
-	-lz								\
-	-lm								\
 	$(top_builddir)/src/libtracker-db/libtracker-db.la 		\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
 	$(top_builddir)/src/libstemmer/libstemmer-private.la 		\
 	$(top_builddir)/src/xdgmime/libxdgmime.la 			\
-	$(trackerd_win_libs)
-
-# mail_modules_LTLIBRARIES = 						\
-# 	libemail-evolution.la 						\
-# 	libemail-thunderbird.la 					\
-# 	libemail-kmail.la 						\
-# 	libemail-modest.la
-
-# libemail_modest_la_SOURCES = tracker-email-modest.c
-# libemail_modest_la_LDFLAGS = $(module_flags)
-# libemail_modest_la_LIBADD = $(GLIB2_LIBS)
-
-# libemail_evolution_la_SOURCES = tracker-email-evolution.c
-# libemail_evolution_la_LDFLAGS = $(module_flags)
-# libemail_evolution_la_LIBADD = $(GLIB2_LIBS)
-
-# libemail_thunderbird_la_SOURCES = tracker-email-thunderbird.c
-# libemail_thunderbird_la_LDFLAGS = $(module_flags)
-# libemail_thunderbird_la_LIBADD = $(GLIB2_LIBS)
+	$(trackerd_win_libs)						\
+	$(DBUS_LIBS)							\
+	$(GMODULE_LIBS)							\
+	$(GTHREAD_LIBS)							\
+	$(GLIB2_LIBS)							\
+	-lz								\
+	-lm
 
-# libemail_kmail_la_SOURCES = tracker-email-kmail.c
-# libemail_kmail_la_LDFLAGS = $(module_flags)
-# libemail_kmail_la_LIBADD = $(GLIB2_LIBS)

Added: branches/indexer-split/src/tracker-indexer/tracker-dbus.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/tracker-indexer/tracker-dbus.c	Wed May 28 14:44:35 2008
@@ -0,0 +1,206 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include <dbus/dbus-glib-bindings.h>
+
+#include <libtracker-common/tracker-log.h>
+
+#include "tracker-dbus.h"
+#include "tracker-indexer.h"
+
+static DBusGConnection *connection;
+static DBusGProxy      *proxy;
+static GSList          *objects;
+
+static gboolean
+dbus_register_service (DBusGProxy  *proxy,
+		       const gchar *name)
+{
+        GError *error = NULL;
+        guint   result;
+
+        g_message ("Registering DBus service...\n"
+		   "  Name '%s'", 
+		   name);
+
+        if (!org_freedesktop_DBus_request_name (proxy,
+                                                name,
+                                                DBUS_NAME_FLAG_DO_NOT_QUEUE,
+                                                &result, &error)) {
+                g_critical ("Could not aquire name: %s, %s",
+			    name,
+			    error ? error->message : "no error given");
+                g_error_free (error);
+
+                return FALSE;
+		}
+
+        if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+                g_critical ("DBus service name '%s' is already taken, "
+			    "perhaps the daemon is already running?",
+			    name);
+                return FALSE;
+	}
+
+        return TRUE;
+}
+
+#if 0
+static gpointer
+dbus_register_object (DBusGConnection       *connection,
+                      DBusGProxy            *proxy,
+                      GType                  object_type,
+                      const DBusGObjectInfo *info,
+                      const gchar           *path)
+{
+        GObject *object;
+
+        g_message ("Registering DBus object...");
+        g_message ("  Path '%s'", path);
+        g_message ("  Type '%s'", g_type_name (object_type));
+
+        object = g_object_new (object_type, NULL);
+
+        dbus_g_object_type_install_info (object_type, info);
+        dbus_g_connection_register_g_object (connection, path, object);
+
+        return object;
+}
+
+#endif
+
+static gboolean 
+dbus_register_names (void)
+{
+        GError *error = NULL;
+
+	if (connection) {
+		g_critical ("The DBusGConnection is already set, have we already initialized?"); 
+		return FALSE;
+	}
+
+	if (proxy) {
+		g_critical ("The DBusGProxy is already set, have we already initialized?"); 
+		return FALSE;
+	}
+	
+        connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+        if (!connection) {
+                g_critical ("Could not connect to the DBus session bus, %s",
+			    error ? error->message : "no error given.");
+		g_clear_error (&error);
+                return FALSE;
+        }
+
+        /* The definitions below (DBUS_SERVICE_DBUS, etc) are
+         * predefined for us to just use (dbus_g_proxy_...)
+         */
+        proxy = dbus_g_proxy_new_for_name (connection,
+                                           DBUS_SERVICE_DBUS,
+                                           DBUS_PATH_DBUS,
+                                           DBUS_INTERFACE_DBUS);
+
+        /* Register the service name for org.freedesktop.Tracker */
+        if (!dbus_register_service (proxy, TRACKER_INDEXER_SERVICE)) {
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+gboolean
+tracker_dbus_init (void)
+{
+        /* Don't reinitialize */
+        if (objects) {
+                return TRUE;
+        }
+
+	/* Register names and get proxy/connection details */
+	if (!dbus_register_names ()) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+void
+tracker_dbus_shutdown (void)
+{
+        if (objects) {
+		g_slist_foreach (objects, (GFunc) g_object_unref, NULL);
+		g_slist_free (objects);
+		objects = NULL;
+	}
+
+	if (proxy) {
+		g_object_unref (proxy);
+		proxy = NULL;
+	}
+
+	connection = NULL;
+}
+
+gboolean
+tracker_dbus_register_objects (void)
+{
+        GObject *object;
+
+	if (!connection || !proxy) {
+		g_critical ("DBus support must be initialized before registering objects!");
+		return FALSE;
+	}
+
+	object = NULL;
+
+#if 0
+        /* Add org.freedesktop.Tracker.Indexer */
+        if (!(object = dbus_register_object (connection, 
+                                             proxy,
+                                             TRACKER_TYPE_DBUS_DAEMON,
+                                             &dbus_glib_tracker_dbus_daemon_object_info,
+                                             TRACKER_DBUS_DAEMON_PATH))) {
+                return FALSE;
+        }
+
+        objects = g_slist_prepend (objects, object);
+#endif
+
+         /* Reverse list since we added objects at the top each time */
+        objects = g_slist_reverse (objects);
+  
+        return TRUE;
+}
+
+GObject *
+tracker_dbus_get_object (GType type)
+{
+        GSList *l;
+	
+        for (l = objects; l; l = l->next) {
+                if (G_OBJECT_TYPE (l->data) == type) {
+                        return l->data;
+		}
+	}
+
+        return NULL;
+}

Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h	Wed May 28 14:44:35 2008
@@ -22,7 +22,9 @@
 #ifndef __TRACKER_INDEXER_H__
 #define __TRACKER_INDEXER_H__
 
-#include <glib.h>
+#define TRACKER_INDEXER_SERVICE      "org.freedesktop.TrackerIndexer"
+#define TRACKER_INDEXER_PATH         "/org/freedesktop/TrackerIndexer"
+#define TRACKER_INDEXER_INTERFACE    "org.freedesktop.TrackerIndexer"
 
 G_BEGIN_DECLS
 

Modified: branches/indexer-split/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-main.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-main.c	Wed May 28 14:44:35 2008
@@ -32,6 +32,7 @@
 #include <libtracker-common/tracker-config.h>
 #include <libtracker-common/tracker-log.h>
 
+#include "tracker-dbus.h"
 #include "tracker-indexer.h"
 
 #ifdef HAVE_IOPRIO
@@ -235,6 +236,13 @@
                            str ? str : "no error given");
         }
 
+        /* Make sure we initialize DBus, this shows we are started
+         * successfully when called upon from the daemon.
+         */
+        if (!tracker_dbus_init ()) {
+                return EXIT_FAILURE;
+        }
+
         /* Create the indexer and run the main loop */
 	indexer = tracker_indexer_new (reindex);
 	main_loop = g_main_loop_new (NULL, FALSE);

Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am	(original)
+++ branches/indexer-split/src/trackerd/Makefile.am	Wed May 28 14:44:35 2008
@@ -6,15 +6,16 @@
 	-DMAIL_MODULES_DIR=\""$(libdir)"/tracker/mail-modules\"         \
 	-DG_LOG_DOMAIN=\"Tracker\"					\
 	-I$(top_srcdir)/src						\
-	$(GLIB2_CFLAGS)							\
-	$(GMODULE_CFLAGS)						\
-	$(PANGO_CFLAGS)							\
 	$(GMIME_CFLAGS)							\
 	$(FAM_CFLAGS)							\
-	$(DBUS_CFLAGS)							\
 	$(SQLITE3_CFLAGS)						\
 	$(QDBM_CFLAGS)							\
-	$(UNAC_CFLAGS)
+	$(UNAC_CFLAGS)							\
+	$(DBUS_CFLAGS)							\
+	$(PANGO_CFLAGS)							\
+	$(GMODULE_CFLAGS)						\
+	$(GTHREAD_CFLAGS)						\
+	$(GLIB2_CFLAGS)
 
 if HAVE_INOTIFY
 watch_sources =								\
@@ -124,23 +125,23 @@
 endif
 
 trackerd_LDADD =							\
-	$(GLIB2_LIBS)							\
-	$(GMODULE_LIBS)							\
-	$(FAM_LIBS)							\
-	$(DBUS_LIBS)							\
-	$(PANGO_LIBS)							\
+	$(top_builddir)/src/libtracker-db/libtracker-db.la 		\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
+	$(top_builddir)/src/libstemmer/libstemmer-private.la 		\
+	$(top_builddir)/src/xdgmime/libxdgmime.la 			\
 	$(GMIME_LIBS)							\
+	$(FAM_LIBS)							\
 	$(SQLITE3_LIBS)							\
 	$(QDBM_LIBS)							\
 	$(UNAC_LIBS)							\
+	$(DBUS_LIBS)							\
+	$(PANGO_LIBS)							\
+	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
+	$(GLIB2_LIBS)							\
+	$(trackerd_win_libs)						\
 	-lz								\
-	-lm								\
-	$(top_builddir)/src/libtracker-db/libtracker-db.la 		\
-	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
-	$(top_builddir)/src/libstemmer/libstemmer-private.la 		\
-	$(top_builddir)/src/xdgmime/libxdgmime.la 			\
-	$(trackerd_win_libs)
+	-lm
 
 tracker-marshal.h: tracker-marshal.list
 	$(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --header > $@

Modified: branches/indexer-split/src/trackerd/tracker-dbus-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-daemon.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-daemon.c	Wed May 28 14:44:35 2008
@@ -19,14 +19,16 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-dbus.h>
+
+#include <libtracker-db/tracker-db-dbus.h>
 
 #include "tracker-dbus.h"
 #include "tracker-dbus-daemon.h"

Modified: branches/indexer-split/src/trackerd/tracker-dbus-daemon.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-daemon.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-daemon.h	Wed May 28 14:44:35 2008
@@ -22,9 +22,7 @@
 #ifndef __TRACKERD_DBUS_DAEMON_H__
 #define __TRACKERD_DBUS_DAEMON_H__
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <glib-object.h>
 
 #include <libtracker-common/tracker-config.h>
 

Modified: branches/indexer-split/src/trackerd/tracker-dbus-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-files.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-files.c	Wed May 28 14:44:35 2008
@@ -19,17 +19,19 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <config.h>
+#include "config.h"
 
-#include <stdlib.h>
 #include <string.h>
 
+#include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-utils.h>
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-ontology.h>
 #include <libtracker-common/tracker-type-utils.h>
 
+#include <libtracker-db/tracker-db-dbus.h>
+
 #include "tracker-dbus.h"
 #include "tracker-dbus-files.h"
 #include "tracker-db.h"

Modified: branches/indexer-split/src/trackerd/tracker-dbus-files.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-files.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-files.h	Wed May 28 14:44:35 2008
@@ -22,9 +22,7 @@
 #ifndef __TRACKERD_DBUS_FILES_H__
 #define __TRACKERD_DBUS_FILES_H__
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <glib-object.h>
 
 #include "tracker-db-sqlite.h"
 

Modified: branches/indexer-split/src/trackerd/tracker-dbus-keywords.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-keywords.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-keywords.c	Wed May 28 14:44:35 2008
@@ -19,14 +19,14 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
+#include "config.h"
 
+#include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-utils.h>
 
+#include <libtracker-db/tracker-db-dbus.h>
+
 #include "tracker-dbus.h"
 #include "tracker-dbus-keywords.h"
 #include "tracker-db.h"

Modified: branches/indexer-split/src/trackerd/tracker-dbus-keywords.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-keywords.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-keywords.h	Wed May 28 14:44:35 2008
@@ -22,9 +22,7 @@
 #ifndef __TRACKERD_DBUS_KEYWORDS_H__
 #define __TRACKERD_DBUS_KEYWORDS_H__
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <glib-object.h>
 
 #include "tracker-db-sqlite.h"
 

Modified: branches/indexer-split/src/trackerd/tracker-dbus-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-metadata.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-metadata.c	Wed May 28 14:44:35 2008
@@ -19,15 +19,17 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <config.h>
+#include "config.h"
 
-#include <stdlib.h>
 #include <string.h>
 
+#include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-field-data.h>
 #include <libtracker-common/tracker-utils.h>
 
+#include <libtracker-db/tracker-db-dbus.h>
+
 #include "tracker-dbus.h"
 #include "tracker-dbus-metadata.h"
 #include "tracker-db.h"

Modified: branches/indexer-split/src/trackerd/tracker-dbus-metadata.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-metadata.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-metadata.h	Wed May 28 14:44:35 2008
@@ -22,9 +22,7 @@
 #ifndef __TRACKERD_DBUS_METADATA_H__
 #define __TRACKERD_DBUS_METADATA_H__
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <glib-object.h>
 
 #include "tracker-db-sqlite.h"
 #include "tracker-indexer.h"

Modified: branches/indexer-split/src/trackerd/tracker-dbus-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-search.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-search.c	Wed May 28 14:44:35 2008
@@ -19,10 +19,11 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <string.h>
+#include "config.h"
 
-#include <libtracker-common/tracker-log.h>
+#include <string.h>
 
+#include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-config.h>
 #include <libtracker-common/tracker-language.h>
 #include <libtracker-common/tracker-log.h>
@@ -30,6 +31,8 @@
 #include <libtracker-common/tracker-parser.h>
 #include <libtracker-common/tracker-utils.h>
 
+#include <libtracker-db/tracker-db-dbus.h>
+
 #include "tracker-dbus.h"
 #include "tracker-dbus-search.h"
 #include "tracker-rdf-query.h"

Modified: branches/indexer-split/src/trackerd/tracker-dbus-search.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-search.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-search.h	Wed May 28 14:44:35 2008
@@ -22,9 +22,7 @@
 #ifndef __TRACKERD_DBUS_SEARCH_H__
 #define __TRACKERD_DBUS_SEARCH_H__
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <glib-object.h>
 
 #include <libtracker-common/tracker-language.h>
 

Modified: branches/indexer-split/src/trackerd/tracker-dbus-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-xesam.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-xesam.c	Wed May 28 14:44:35 2008
@@ -23,8 +23,9 @@
 
 #include <string.h>
 
-#include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-dbus.h>
+#include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-ontology.h>
 #include <libtracker-common/tracker-utils.h>
 

Modified: branches/indexer-split/src/trackerd/tracker-dbus-xesam.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-xesam.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-xesam.h	Wed May 28 14:44:35 2008
@@ -22,9 +22,9 @@
 #ifndef __TRACKERD_DBUS_XESAM_H__
 #define __TRACKERD_DBUS_XESAM_H__
 
-#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+
 #include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
 
 #include "tracker-db-sqlite.h"
 #include "tracker-indexer.h"
@@ -56,65 +56,65 @@
 
 GType tracker_dbus_xesam_get_type           (void);
 TrackerDBusXesam *
-      tracker_dbus_xesam_new                (DBConnection *db_con); 
-void  tracker_dbus_xesam_new_session        (TrackerDBusXesam    *object,
+      tracker_dbus_xesam_new                (DBConnection          *db_con); 
+void  tracker_dbus_xesam_new_session        (TrackerDBusXesam      *object,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_set_property       (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_set_property       (TrackerDBusXesam      *object,
 					     const gchar           *session_id,
 					     const gchar           *prop,
 					     GValue                *val,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_get_property       (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_get_property       (TrackerDBusXesam      *object,
 					     const gchar           *session_id,
 					     const gchar           *prop,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_close_session      (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_close_session      (TrackerDBusXesam      *object,
 					     const gchar           *session_id,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_new_search         (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_new_search         (TrackerDBusXesam      *object,
 					     const gchar           *session_id,
 					     const gchar           *query_xml,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_start_search       (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_start_search       (TrackerDBusXesam      *object,
 					     const gchar           *search_id,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_get_hit_count      (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_get_hit_count      (TrackerDBusXesam      *object,
 					     const gchar           *search_id,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_get_hits           (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_get_hits           (TrackerDBusXesam      *object,
 					     const gchar           *search_id,
 					     guint                  count,
 					     DBusGMethodInvocation *context);
-void tracker_dbus_xesam_get_range_hits	     (TrackerDBusXesam    *object,
-					      const gchar           *search_id,
-					      guint                  a,
-					      guint                  b,
-					      DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_get_hit_data       (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_get_range_hits     (TrackerDBusXesam      *object,
+					     const gchar           *search_id,
+					     guint                  a,
+					     guint                  b,
+					     DBusGMethodInvocation *context);
+void  tracker_dbus_xesam_get_hit_data       (TrackerDBusXesam      *object,
 					     const gchar           *search_id,
 					     GArray                *hit_ids,
 					     GStrv                  fields,
 					     DBusGMethodInvocation *context);
-void tracker_dbus_xesam_get_range_hit_data  (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_get_range_hit_data (TrackerDBusXesam      *object,
 					     const gchar           *search_id,
 					     guint                  a,
 					     guint                  b,
-					     GStrv                  fields, 
+					     GStrv                  fields,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_close_search       (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_close_search       (TrackerDBusXesam      *object,
 					     const gchar           *search_id,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_get_state          (TrackerDBusXesam    *object,
+void  tracker_dbus_xesam_get_state          (TrackerDBusXesam      *object,
 					     DBusGMethodInvocation *context);
-void  tracker_dbus_xesam_emit_state_changed (TrackerDBusXesam    *self,
+void  tracker_dbus_xesam_emit_state_changed (TrackerDBusXesam      *self,
 					     GStrv                  state_info);
 void  tracker_dbus_xesam_name_owner_changed (DBusGProxy            *proxy,
 					     const char            *name,
 					     const char            *prev_owner,
 					     const char            *new_owner,
-					     TrackerDBusXesam    *self);
-void  tracker_dbus_xesam_set_db_connection  (TrackerDBusXesam *object,
-				             DBConnection      *db_con);
+					     TrackerDBusXesam      *self);
+void  tracker_dbus_xesam_set_db_connection  (TrackerDBusXesam      *object,
+					     DBConnection          *db_con);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c	Wed May 28 14:44:35 2008
@@ -19,8 +19,7 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <string.h>
-#include <stdlib.h>
+#include <dbus/dbus-glib-bindings.h>
 
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-config.h>
@@ -40,15 +39,16 @@
 #include "tracker-dbus-search-glue.h"
 #include "tracker-dbus-xesam.h"
 #include "tracker-dbus-xesam-glue.h"
-
 #include "tracker-utils.h"
 #include "tracker-watch.h"
 
-static GSList *objects;
-
-gboolean
-static dbus_register_service (DBusGProxy  *proxy,
-                              const gchar *name)
+static DBusGConnection *connection;
+static DBusGProxy      *proxy;
+static GSList          *objects;
+
+static gboolean
+dbus_register_service (DBusGProxy  *proxy,
+		       const gchar *name)
 {
         GError *error = NULL;
         guint   result;
@@ -100,105 +100,108 @@
         return object;
 }
 
-static GValue *
-tracker_dbus_g_value_slice_new (GType type)
-{
-	GValue *value;
-
-	value = g_slice_new0 (GValue);
-	g_value_init (value, type);
-
-	return value;
-}
-
-static void
-tracker_dbus_g_value_slice_free (GValue *value)
-{
-	g_value_unset (value);
-	g_slice_free (GValue, value);
-}
-
 static void 
-name_owner_changed_done (gpointer data, GClosure *closure)
+dbus_name_owner_changed (gpointer  data, 
+			 GClosure *closure)
 {
 	g_object_unref (data);
 }
 
-gboolean 
-tracker_dbus_preinit (Tracker          *tracker, 
-		      DBusGConnection **connection_out, 
-		      DBusGProxy      **proxy_out,
-		      DBusGProxy      **xesam_out)
+static gboolean 
+dbus_register_names (TrackerConfig *config)
 {
-        DBusGConnection *connection;
-        DBusGProxy      *proxy, *xesam = NULL;
-        GError          *error = NULL;
+        GError *error = NULL;
 
-        g_return_val_if_fail (tracker != NULL, FALSE);
+	if (connection) {
+		g_critical ("The DBusGConnection is already set, have we already initialized?"); 
+		return FALSE;
+	}
 
+	if (proxy) {
+		g_critical ("The DBusGProxy is already set, have we already initialized?"); 
+		return FALSE;
+	}
+	
         connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
 
         if (!connection) {
                 g_critical ("Could not connect to the DBus session bus, %s",
 			    error ? error->message : "no error given.");
 		g_clear_error (&error);
-
                 return FALSE;
         }
 
         /* The definitions below (DBUS_SERVICE_DBUS, etc) are
-         * predefined for us to just use.
+         * predefined for us to just use (dbus_g_proxy_...)
          */
         proxy = dbus_g_proxy_new_for_name (connection,
                                            DBUS_SERVICE_DBUS,
                                            DBUS_PATH_DBUS,
                                            DBUS_INTERFACE_DBUS);
 
-        /* Set up the main tracker service */
+        /* Register the service name for org.freedesktop.Tracker */
         if (!dbus_register_service (proxy, TRACKER_DBUS_DAEMON_SERVICE)) {
                 return FALSE;
         }
 
-        if (tracker_config_get_enable_xesam (tracker->config)) {
-             /* The definitions below (DBUS_SERVICE_DBUS, etc) are
-             * predefined for us to just use.
-             */
-            xesam = dbus_g_proxy_new_for_name (connection,
-                                           DBUS_SERVICE_DBUS,
-                                           DBUS_PATH_DBUS,
-                                           DBUS_INTERFACE_DBUS);
-
-            /* Set up the main tracker service */
-            if (!dbus_register_service (xesam, TRACKER_DBUS_XESAM_SERVICE)) {
-                    return FALSE;
-            }
+	/* Register the service name for org.freedesktop.xesam if XESAM is enabled */
+        if (tracker_config_get_enable_xesam (config)) {
+		if (!dbus_register_service (proxy, TRACKER_DBUS_XESAM_SERVICE)) {
+			return FALSE;
+		}
         }
 
-        *connection_out = connection;
-        *proxy_out = proxy;
-        *xesam_out = xesam;
-
         return TRUE;
 }
 
 gboolean
-tracker_dbus_init (Tracker         *tracker, 
-		   DBusGConnection *connection, 
-		   DBusGProxy      *proxy,
-		   DBusGProxy      *xesam)
+tracker_dbus_init (TrackerConfig *config)
 {
-        GObject      *object;
-	DBConnection *db_connection;
- 
-        g_return_val_if_fail (tracker != NULL, FALSE);
-        g_return_val_if_fail (connection != NULL, FALSE);
-        g_return_val_if_fail (proxy != NULL, FALSE);
+        g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
 
         /* Don't reinitialize */
         if (objects) {
                 return TRUE;
         }
 
+	/* Register names and get proxy/connection details */
+	if (!dbus_register_names (config)) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+void
+tracker_dbus_shutdown (void)
+{
+        if (objects) {
+		g_slist_foreach (objects, (GFunc) g_object_unref, NULL);
+		g_slist_free (objects);
+		objects = NULL;
+	}
+
+	if (proxy) {
+		g_object_unref (proxy);
+		proxy = NULL;
+	}
+
+	connection = NULL;
+}
+
+gboolean
+tracker_dbus_register_objects (Tracker *tracker)
+{
+        GObject      *object;
+	DBConnection *db_connection;
+
+	g_return_val_if_fail (tracker != NULL, FALSE);
+
+	if (!connection || !proxy) {
+		g_critical ("DBus support must be initialized before registering objects!");
+		return FALSE;
+	}
+
         /* Add org.freedesktop.Tracker */
         if (!(object = dbus_register_object (connection, 
                                              proxy,
@@ -260,24 +263,24 @@
                 return FALSE;
         }
 
-        g_object_set (object, "db-connection", db_connection, NULL);
-        g_object_set (object, "config", tracker->config, NULL);
-        g_object_set (object, "language", tracker->language, NULL);
-        g_object_set (object, "file-index", tracker->file_index, NULL);
-        g_object_set (object, "email-index", tracker->email_index, NULL);
-        objects = g_slist_prepend (objects, object);
+	g_object_set (object, "db-connection", db_connection, NULL);
+	g_object_set (object, "config", tracker->config, NULL);
+	g_object_set (object, "language", tracker->language, NULL);
+	g_object_set (object, "file-index", tracker->file_index, NULL);
+	g_object_set (object, "email-index", tracker->email_index, NULL);
+	objects = g_slist_prepend (objects, object);
 
-        if (xesam) {
+	/* Register the XESAM object if enabled */
+        if (tracker_config_get_enable_xesam (tracker->config)) {
 		/* Add org.freedesktop.xesam.Search */
 		if (!(object = dbus_register_object (connection, 
-						     xesam,
+						     proxy,
 						     TRACKER_TYPE_DBUS_XESAM,
 						     &dbus_glib_tracker_dbus_xesam_object_info,
 						     TRACKER_DBUS_XESAM_PATH))) {
 			return FALSE;
 		}
 		
-		/* g_object_set (object, "db-connection", db_connection, NULL); */
 		db_connection = tracker_db_connect_xesam ();
 		g_object_set (object, "db-connection", db_connection, NULL);
 		
@@ -288,40 +291,17 @@
 		dbus_g_proxy_connect_signal (proxy, "NameOwnerChanged", 
 					     G_CALLBACK (tracker_dbus_xesam_name_owner_changed), 
 					     g_object_ref (object),
-					     name_owner_changed_done);
+					     dbus_name_owner_changed);
 		
 		objects = g_slist_prepend (objects, object);
         }
-
+	
         /* Reverse list since we added objects at the top each time */
         objects = g_slist_reverse (objects);
   
-        /* Clean up */
-        g_object_unref (proxy);
-
         return TRUE;
 }
 
-void
-tracker_dbus_shutdown (void)
-{
-        if (!objects) {
-		return;
-    	}
-
-        g_slist_foreach (objects, (GFunc) g_object_unref, NULL);
-        g_slist_free (objects);
-        objects = NULL;
-}
-
-guint
-tracker_dbus_get_next_request_id (void)
-{
-        static guint request_id = 1;
-	
-        return request_id++;
-}
-	
 GObject *
 tracker_dbus_get_object (GType type)
 {
@@ -330,252 +310,8 @@
         for (l = objects; l; l = l->next) {
                 if (G_OBJECT_TYPE (l->data) == type) {
                         return l->data;
-	}
-	}
-
-        return NULL;
-}
-
-GQuark
-tracker_dbus_error_quark (void)
-{
-	return g_quark_from_static_string (TRACKER_DBUS_ERROR_DOMAIN);
-}
-
-TrackerDBusData *
-tracker_dbus_data_new (const gpointer arg1, 
-                       const gpointer arg2)
-{
-        TrackerDBusData *data;
-
-        data = g_new0 (TrackerDBusData, 1);
-
-        data->id = tracker_dbus_get_next_request_id ();
-
-        data->data1 = arg1;
-        data->data2 = arg2;
-
-        return data;
-}
-
-gchar **
-tracker_dbus_slist_to_strv (GSList *list)
-{
-	GSList  *l;
-	gchar  **strv;
-	gint     i = 0;
-
-	strv = g_new0 (gchar*, g_slist_length (list) + 1);
-				
-        for (l = list; l != NULL; l = l->next) {
-                strv[i++] = g_strdup (l->data);
-	}
-
-        strv[i] = NULL;
-
-	return strv;
-}
-
-gchar **
-tracker_dbus_query_result_to_strv (TrackerDBResultSet *result_set, 
-                                   gint               *count)
-{
-	gchar **strv = NULL;
-        gint    rows = 0;
-
-	if (result_set) {
-		gboolean valid = TRUE;
-		gint     i = 0;
-
-                rows = tracker_db_result_set_get_n_rows (result_set);
-		strv = g_new (gchar*, rows + 1);
-		
-		while (valid) {
-			tracker_db_result_set_get (result_set, 0, &strv[i], -1);
-			valid = tracker_db_result_set_iter_next (result_set);
-			i++;
-		}
-		strv[i] = NULL;
-	}
-
-        if (count) {
-                *count = rows;
-        }
-
-	return strv;
-}
-
-GHashTable *
-tracker_dbus_query_result_to_hash_table (TrackerDBResultSet *result_set)
-{
-        GHashTable *hash_table;
-	gint        field_count;
-	gboolean    valid = FALSE;
-
-	hash_table = g_hash_table_new_full (g_str_hash,
-                                            g_str_equal,
-                                            (GDestroyNotify) g_free,
-                                            (GDestroyNotify) tracker_dbus_g_value_slice_free);       
-
-	if (result_set) {
-		valid = TRUE;
-		field_count = tracker_db_result_set_get_n_columns (result_set);
-        }
-
-	while (valid) {
-		GValue   transform;
-		GValue  *values;
-                gchar  **p;
-                gint     field_count;
-                gint     i = 0;
-		gchar   *key;
-		GSList  *list = NULL;
-
-		g_value_init (&transform, G_TYPE_STRING);
-
-		tracker_db_result_set_get (result_set, 0, &key, -1);
-		values = tracker_dbus_g_value_slice_new (G_TYPE_STRV);
-
-                for (i = 1; i < field_count; i++) {
-			GValue       value;
-			const gchar *str;
-
-			_tracker_db_result_set_get_value (result_set, i, &value);
-
-			if (g_value_transform (&value, &transform)) {
-				str = g_value_dup_string (&transform);
-			} else {
-				str = g_strdup ("");
-			}
-
-			list = g_slist_prepend (list, (gchar*) str);
-		}
-
-		list = g_slist_reverse (list);
-		p = tracker_dbus_slist_to_strv (list);
-		g_slist_free (list);
-		g_value_take_boxed (values, p);
-		g_hash_table_insert (hash_table, key, values);
-
-		valid = tracker_db_result_set_iter_next (result_set);
-        }
-
-        return hash_table;
-}
-
-GPtrArray *
-tracker_dbus_query_result_to_ptr_array (TrackerDBResultSet *result_set)
-{
-        GPtrArray *ptr_array;
-	gboolean   valid = FALSE;
-	gint       columns;
-        gint       i;
-
-	ptr_array = g_ptr_array_new ();
-
-	if (result_set) {
-		valid = TRUE;
-		columns = tracker_db_result_set_get_n_columns (result_set);
-	}
-
-	while (valid) {
-		GSList  *list = NULL;
-		GValue   transform = { 0, };
-		gchar  **p;
-
-		g_value_init (&transform, G_TYPE_STRING);
-
-		/* Append fields to the array */
-		for (i = 0; i < columns; i++) {
-			GValue       value = { 0, };
-			const gchar *str;
-
-			_tracker_db_result_set_get_value (result_set, i, &value);
-			
-			if (g_value_transform (&value, &transform)) {
-				str = g_value_dup_string (&transform);
-			} else {
-				str = g_strdup ("");
-			}
-
-			list = g_slist_prepend (list, (gchar*) str);
-
-			g_value_unset (&value);
-			g_value_reset (&transform);
 		}
-		
-		list = g_slist_reverse (list);
-		p = tracker_dbus_slist_to_strv (list);
-		g_slist_free (list);
-		g_ptr_array_add (ptr_array, p);
-
-		valid = tracker_db_result_set_iter_next (result_set);
 	}
 
-        return ptr_array;
-}
-
-void
-tracker_dbus_request_new (gint          request_id,
-			  const gchar  *format, 
-			  ...)
-{
-	gchar   *str;
-	va_list  args;
-
-	va_start (args, format);
-	str = g_strdup_vprintf (format, args);
-	va_end (args);
-	
-	g_message ("<--- [%d] %s",
-		   request_id,
-		   str);
-
-	g_free (str);
-}
-
-void
-tracker_dbus_request_success (gint request_id)
-{
-	g_message ("---> [%d] Success, no error given", 
-		   request_id);
-}
-
-void
-tracker_dbus_request_failed (gint          request_id,
-			     GError      **error,
-			     const gchar  *format, 
-			     ...)
-{
-	gchar   *str;
-	va_list  args;
-
-	va_start (args, format);
-	str = g_strdup_vprintf (format, args);
-	va_end (args);
-
-	g_set_error (error, TRACKER_DBUS_ERROR, 0, str);
-
-	g_message ("---> [%d] Failed, %s",
-		   request_id,
-		   str);
-	g_free (str);
-}
-
-void
-tracker_dbus_request_comment (gint         request_id,
-			      const gchar *format,
-			      ...)
-{
-	gchar   *str;
-	va_list  args;
-
-	va_start (args, format);
-	str = g_strdup_vprintf (format, args);
-	va_end (args);
-
-	g_message ("---- [%d] %s", 
-		   request_id, 
-		   str);
-	g_free (str);
+        return NULL;
 }

Modified: branches/indexer-split/src/trackerd/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.h	Wed May 28 14:44:35 2008
@@ -22,15 +22,9 @@
 #ifndef __TRACKERD_DBUS_H__
 #define __TRACKERD_DBUS_H__
 
-#ifndef DBUS_API_SUBJECT_TO_CHANGE
-#define DBUS_API_SUBJECT_TO_CHANGE
-#endif 
-
-#include <glib/gi18n.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <libtracker-common/tracker-config.h>
 
 #include <libtracker-db/tracker-db-interface.h>
 
@@ -38,79 +32,10 @@
 
 G_BEGIN_DECLS
 
-#define TRACKER_DBUS_ERROR_DOMAIN "TrackerDBus"
-#define TRACKER_DBUS_ERROR        tracker_dbus_error_quark()
-
-#define tracker_dbus_async_return_if_fail(expr,context)			\
-	G_STMT_START {							\
-		if G_LIKELY(expr) { } else {				\
-			GError *error = NULL;				\
-									\
-			g_set_error (&error,				\
-				     TRACKER_DBUS_ERROR,		\
-				     0,					\
-				     _("Assertion `%s' failed"),	\
-				     #expr);				\
-									\
-			dbus_g_method_return_error (context, error);	\
-			g_clear_error (&error);				\
-									\
-			return;						\
-		};							\
-	} G_STMT_END
-
-#define tracker_dbus_return_val_if_fail(expr,val,error)			\
-	G_STMT_START {							\
-		if G_LIKELY(expr) { } else {				\
-			g_set_error (error,				\
-				     TRACKER_DBUS_ERROR,                \
-				     0,					\
-				     _("Assertion `%s' failed"),	\
-				     #expr);				\
-									\
-			return val;					\
-		};							\
-	} G_STMT_END
-
-typedef struct {
-        guint    id;
-        gpointer data1;
-        gpointer data2;
-} TrackerDBusData;
-
-gboolean         tracker_dbus_preinit                    (Tracker *tracker, 
-							  DBusGConnection **connection_out, 
-							  DBusGProxy **proxy_out,
-							  DBusGProxy **xesam_out);
-gboolean         tracker_dbus_init                       (Tracker *tracker,
-							  DBusGConnection *connection, 
-							  DBusGProxy *proxy,
-							  DBusGProxy *xesam);
-void             tracker_dbus_shutdown                   (void);
-guint            tracker_dbus_get_next_request_id        (void);
-GObject *        tracker_dbus_get_object                 (GType                type);
-GQuark           tracker_dbus_error_quark                (void);
-
-
-/* Utils */
-TrackerDBusData *tracker_dbus_data_new                   (const gpointer       arg1,
-							  const gpointer       arg2);
-gchar **         tracker_dbus_slist_to_strv              (GSList              *list);
-gchar **         tracker_dbus_query_result_to_strv       (TrackerDBResultSet  *result_set,
-							  gint                *count);
-GHashTable *     tracker_dbus_query_result_to_hash_table (TrackerDBResultSet  *result_set);
-GPtrArray *      tracker_dbus_query_result_to_ptr_array  (TrackerDBResultSet  *result_set);
-void             tracker_dbus_request_new                (gint                 request_id,
-							  const gchar         *format,
-							  ...);
-void             tracker_dbus_request_success            (gint                 request_id);
-void             tracker_dbus_request_failed             (gint                 request_id,
-							  GError             **error,
-							  const gchar         *format,
-							  ...);
-void             tracker_dbus_request_comment            (gint                 request_id,
-							  const gchar         *format,
-							  ...);
+gboolean tracker_dbus_init             (TrackerConfig *config);
+void     tracker_dbus_shutdown         (void);
+gboolean tracker_dbus_register_objects (Tracker       *tracker);
+GObject *tracker_dbus_get_object       (GType          type);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-main.c	Wed May 28 14:44:35 2008
@@ -803,9 +803,6 @@
 gint
 main (gint argc, gchar *argv[])
 {
-	DBusGConnection *connection = NULL;
-	DBusGProxy     *proxy = NULL;
-	DBusGProxy     *xesam = NULL;
 	GOptionContext *context = NULL;
 	GError         *error = NULL;
 	GThread        *thread; 
@@ -934,8 +931,9 @@
 	tracker_log_init (log_filename, tracker_config_get_verbosity (tracker->config));
 	g_message ("Starting log");
 	
-	if (!tracker_dbus_preinit (tracker, &connection, &proxy, &xesam))
+	if (!tracker_dbus_init (tracker->config)) {
 		return EXIT_FAILURE;
+	}
 
 	sanity_check_option_values ();
 
@@ -970,12 +968,10 @@
 	 */
 	tracker->is_running = TRUE;
 
-        /* If we are already running, this should return some
-         * indication.
-         */
-        if (!tracker_dbus_init (tracker, connection, proxy, xesam)) {
-                return EXIT_FAILURE;
-        }
+	/* Make Tracker available for introspection */
+	if (!tracker_dbus_register_objects (tracker)) {
+		return EXIT_FAILURE;
+	}
 
 	if (!tracker->readonly) {
 		if (!tracker_start_watching ()) {

Modified: branches/indexer-split/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-live-search.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-live-search.c	Wed May 28 14:44:35 2008
@@ -21,6 +21,8 @@
 
 #include <string.h>
 
+#include <dbus/dbus-glib-bindings.h>
+
 #include "tracker-xesam-live-search.h"
 #include "tracker-dbus-xesam.h"
 #include "tracker-dbus.h"



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