+ /* If connection is set, we know it worked. */
+ g_debug ("Finding out if Tracker is available via D-Bus...");
+
+ /* We only wait 1 second max, we expect it to be very fast. If we
+ * don't get a response by then, clearly we're replaying a journal
+ * or cleaning up the DB internally. Either way, services is not
+ * available.
+ *
+ * We use the sync call here because we don't expect to be waiting
+ * long enough to block UI painting.
+ */
+ reply = g_dbus_connection_call_sync (connection,
+ DBUS_SERVICE_STATUS,
+ DBUS_PATH_STATUS,
+ DBUS_INTERFACE_STATUS,
+ "Wait",
+ NULL,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ WAIT_TIMEOUT_SECONDS * 1000,
+ NULL,
+ &error);
+
+ if (error)
+ {
+ g_debug ("Tracker is not available, %s", error->message);
+ g_error_free (error);
+ g_object_unref (connection);
+ return NULL;
+ }
+
+ g_variant_unref (reply);
+
+ g_debug ("Tracker is ready");
+
+ return connection;