[tracker/direct-wait: 3/3] libtracker-direct: Wait for tracker-store to be ready



commit 2a810804a7577c927beb1f204d5662d68b3c24bf
Author: Jürg Billeter <j bitron ch>
Date:   Mon Aug 23 17:34:36 2010 +0200

    libtracker-direct: Wait for tracker-store to be ready

 src/libtracker-direct/Makefile.am             |    4 +++-
 src/libtracker-direct/tracker-direct.vala     |   16 ++++++++++++++++
 src/libtracker-sparql/tracker-connection.vala |    2 ++
 3 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-direct/Makefile.am b/src/libtracker-direct/Makefile.am
index 87241bc..148a81e 100644
--- a/src/libtracker-direct/Makefile.am
+++ b/src/libtracker-direct/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES =								\
 	-I$(top_srcdir)/src/libtracker-data				\
 	-I$(top_builddir)/src						\
 	$(WARN_CFLAGS)							\
+	$(DBUS_CFLAGS)							\
 	$(GLIB2_CFLAGS)							\
 	$(GCOV_CFLAGS)
 
@@ -36,7 +37,7 @@ vapi_sources =						\
 	$(top_srcdir)/src/libtracker-data/tracker-sparql-query.vapi
 
 libtracker-direct.vala.stamp: $(libtracker_direct_la_VALASOURCES) $(vapi_sources)
-	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 -H tracker-direct.h --vapi tracker-direct.vapi $^
+	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 -H tracker-direct.h --vapi tracker-direct.vapi $^
 	$(AM_V_GEN)touch $@
 
 BUILT_SOURCES = libtracker-direct.vala.stamp
@@ -44,6 +45,7 @@ BUILT_SOURCES = libtracker-direct.vala.stamp
 libtracker_direct_la_LIBADD = 						\
 	$(top_builddir)/src/libtracker-data/libtracker-data.la	\
 	$(GLIB2_LIBS)						\
+	$(DBUS_LIBS) \
 	$(GCOV_LIBS)
 
 MAINTAINERCLEANFILES =					\
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index 1a939aa..137f7d6 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -17,12 +17,28 @@
  * Boston, MA  02110-1301, USA.
  */
 
+[DBus (name = "org.freedesktop.Tracker1.Status")]
+interface Tracker.Direct.Status : GLib.Object {
+	public abstract void wait () throws DBus.Error;
+}
+
 public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
 	// only single connection is currently supported per process
 	static bool initialized;
 
 	public Connection () throws Sparql.Error
 	requires (!initialized) {
+		try {
+			var connection = DBus.Bus.get (DBus.BusType.SESSION);
+
+			var status = (Status) connection.get_object (TRACKER_DBUS_SERVICE,
+			                                             TRACKER_DBUS_OBJECT_STATUS,
+			                                             TRACKER_DBUS_INTERFACE_STATUS);
+			status.wait ();
+		} catch (DBus.Error e) {
+			throw new Sparql.Error.INTERNAL ("Unable to initialize database");
+		}
+
 		if (!Data.Manager.init (DBManagerFlags.READONLY, null, null, false, null, null)) {
 			throw new Sparql.Error.INTERNAL ("Unable to initialize database");
 		}
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 9f740c4..9ccfea8 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -36,6 +36,8 @@ public const string TRACKER_DBUS_INTERFACE_RESOURCES = TRACKER_DBUS_SERVICE + ".
 public const string TRACKER_DBUS_OBJECT_RESOURCES = "/org/freedesktop/Tracker1/Resources";
 public const string TRACKER_DBUS_INTERFACE_STATISTICS = TRACKER_DBUS_SERVICE + ".Statistics";
 public const string TRACKER_DBUS_OBJECT_STATISTICS = "/org/freedesktop/Tracker1/Statistics";
+public const string TRACKER_DBUS_INTERFACE_STATUS = TRACKER_DBUS_SERVICE + ".Status";
+public const string TRACKER_DBUS_OBJECT_STATUS = "/org/freedesktop/Tracker1/Status";
 public const string TRACKER_DBUS_INTERFACE_STEROIDS = TRACKER_DBUS_SERVICE + ".Steroids";
 public const string TRACKER_DBUS_OBJECT_STEROIDS = "/org/freedesktop/Tracker1/Steroids";
 



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