[tracker/tracker-0.6] Do not make libtracker-module depend on tracker-indexer.



commit 4f2a7e62da1c77781ceafce01fbd724c0b0a6063
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Apr 15 17:21:24 2009 +0200

    Do not make libtracker-module depend on tracker-indexer.
    
    * src/tracker-indexer/tracker-dbus.[ch]: Changed not to depend on
      tracker-indexer. Changed tracker_dbus_register_object() signature so all
      needed info is passed.
    * src/tracker-indexer/tracker-main.c: Pass all necessary info to
      tracker_dbus_register_object() from here. Add a name monitor hook so we stop
      the indexer if trackerd dissapears from DBus.
    * src/tracker-indexer/Makefile.am: Add tracker-dbus.c to libtracker-module, so
      it doesn't have deps on tracker-indexer.
---
 src/tracker-indexer/Makefile.am    |    2 +-
 src/tracker-indexer/tracker-dbus.c |   31 +++++++++----------------------
 src/tracker-indexer/tracker-dbus.h |    4 +++-
 src/tracker-indexer/tracker-main.c |   20 +++++++++++++++++++-
 4 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/src/tracker-indexer/Makefile.am b/src/tracker-indexer/Makefile.am
index 2f72f09..e419744 100644
--- a/src/tracker-indexer/Makefile.am
+++ b/src/tracker-indexer/Makefile.am
@@ -25,6 +25,7 @@ libtracker_moduleincludedir=$(includedir)/tracker-1.0/libtracker-module/
 libtracker_module_LTLIBRARIES = libtracker-module.la
 
 libtracker_module_la_SOURCES =	 					\
+	tracker-dbus.c							\
 	tracker-module-file.c						\
 	tracker-module-iteratable.c					\
 	tracker-module-metadata-utils.c					\
@@ -42,7 +43,6 @@ libtracker_module_la_LIBADD = $(GCOV_LIBS)
 libexec_PROGRAMS = tracker-indexer
 
 tracker_indexer_SOURCES =						\
-	tracker-dbus.c							\
 	tracker-dbus.h							\
 	tracker-indexer.c						\
 	tracker-indexer.h						\
diff --git a/src/tracker-indexer/tracker-dbus.c b/src/tracker-indexer/tracker-dbus.c
index f2392ae..938f8f0 100644
--- a/src/tracker-indexer/tracker-dbus.c
+++ b/src/tracker-indexer/tracker-dbus.c
@@ -26,8 +26,6 @@
 #include <libtracker-common/tracker-log.h>
 
 #include "tracker-dbus.h"
-#include "tracker-indexer.h"
-#include "tracker-indexer-glue.h"
 
 static DBusGConnection *connection;
 static DBusGProxy      *gproxy;
@@ -81,13 +79,6 @@ name_owner_changed_cb (DBusGProxy *proxy,
 {
 	TrackerDBusNameMonitor *name_monitor;
 
-	if (strcmp (name, TRACKER_DAEMON_SERVICE) == 0 && (!new_owner || !*new_owner)) {
-		/* Tracker daemon has dissapeared from
-		 * the bus, shutdown the indexer.
-		 */
-		tracker_indexer_stop (TRACKER_INDEXER (user_data));
-	}
-
 	name_monitor = g_hash_table_lookup (name_monitors, name);
 
 	if (name_monitor) {
@@ -155,7 +146,7 @@ dbus_register_names (void)
 					    DBUS_INTERFACE_DBUS);
 
 	/* Register the service name for org.freedesktop.Tracker */
-	if (!dbus_register_service (gproxy, TRACKER_INDEXER_SERVICE)) {
+	if (!dbus_register_service (gproxy, "org.freedesktop.Tracker.Indexer")) {
 		return FALSE;
 	}
 
@@ -222,24 +213,20 @@ tracker_dbus_shutdown (void)
 }
 
 gboolean
-tracker_dbus_register_object (GObject *object)
+tracker_dbus_register_object (GObject               *object,
+			      const DBusGObjectInfo *info,
+			      const gchar	    *path)
 {
 	if (!connection || !gproxy) {
 		g_critical ("DBus support must be initialized before registering objects!");
 		return FALSE;
 	}
 
-	if (TRACKER_IS_INDEXER (object)) {
-		return dbus_register_object (object,
-					     connection,
-					     gproxy,
-					     &dbus_glib_tracker_indexer_object_info,
-					     TRACKER_INDEXER_PATH);
-	} else {
-		g_warning ("Object not handled by DBus");
-	}
-
-	return FALSE;
+	return dbus_register_object (object,
+				     connection,
+				     gproxy,
+				     info,
+				     path);
 }
 
 void
diff --git a/src/tracker-indexer/tracker-dbus.h b/src/tracker-indexer/tracker-dbus.h
index 0a8fa65..c0ce03e 100644
--- a/src/tracker-indexer/tracker-dbus.h
+++ b/src/tracker-indexer/tracker-dbus.h
@@ -34,7 +34,9 @@ typedef void (* TrackerDBusNameMonitorFunc) (const gchar *name,
 
 gboolean    tracker_dbus_init		   (void);
 void	    tracker_dbus_shutdown	   (void);
-gboolean    tracker_dbus_register_object   (GObject *object);
+gboolean    tracker_dbus_register_object   (GObject               *object,
+					    const DBusGObjectInfo *info,
+					    const gchar	          *path);
 
 void        tracker_dbus_add_name_monitor     (const gchar                *name,
 					       TrackerDBusNameMonitorFunc  func,
diff --git a/src/tracker-indexer/tracker-main.c b/src/tracker-indexer/tracker-main.c
index 5f97228..908fa95 100644
--- a/src/tracker-indexer/tracker-main.c
+++ b/src/tracker-indexer/tracker-main.c
@@ -53,6 +53,7 @@
 #include "tracker-dbus.h"
 #include "tracker-indexer.h"
 #include "tracker-push.h"
+#include "tracker-indexer-glue.h"
 
 #define ABOUT								  \
 	"Tracker " PACKAGE_VERSION "\n"
@@ -268,6 +269,16 @@ indexer_finished_cb (TrackerIndexer *indexer,
 	}
 }
 
+static void
+daemon_availability_changed_cb (const gchar *name,
+                                gboolean     available,
+                                gpointer     user_data)
+{
+        if (!available) {
+                tracker_indexer_stop (TRACKER_INDEXER (user_data));
+        }
+}
+
 gint
 main (gint argc, gchar *argv[])
 {
@@ -380,10 +391,17 @@ main (gint argc, gchar *argv[])
 	indexer = tracker_indexer_new ();
 
 	/* Make Tracker available for introspection */
-	if (!tracker_dbus_register_object (G_OBJECT (indexer))) {
+	if (!tracker_dbus_register_object (G_OBJECT (indexer),
+                                           &dbus_glib_tracker_indexer_object_info,
+                                           TRACKER_INDEXER_PATH)) {
 		return EXIT_FAILURE;
 	}
 
+        /* Listen for changes in trackerd availability */
+        tracker_dbus_add_name_monitor (TRACKER_DAEMON_SERVICE,
+                                       daemon_availability_changed_cb,
+                                       indexer, NULL);
+
 	/* Create the indexer and run the main loop */
 	g_signal_connect (indexer, "finished",
 			  G_CALLBACK (indexer_finished_cb),



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