[tracker/clientapi] Added a way to connect to Tracker without blocking on StartServiceByName
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/clientapi] Added a way to connect to Tracker without blocking on StartServiceByName
- Date: Tue, 12 Jan 2010 15:35:57 +0000 (UTC)
commit 481cc6a1f8004d21fd0c78c85926161db66ea0bf
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Jan 12 16:34:24 2010 +0100
Added a way to connect to Tracker without blocking on StartServiceByName
src/libtracker-client/tracker.c | 40 ++++++++++++++++++++--
src/libtracker-client/tracker.h | 2 +
src/plugins/evolution/tracker-evolution-plugin.c | 6 ++--
3 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index e41ab6a..8607090 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -121,6 +121,7 @@ enum {
PROP_0 = 0,
PROP_TIMEOUT,
PROP_ENABLE_WARNINGS,
+ PROP_FORCE_SERVICE,
};
static guint pending_call_id = 0;
@@ -139,6 +140,7 @@ static gboolean start_service (DBusConnection *connection,
typedef struct {
gint timeout;
gboolean enable_warnings;
+ gboolean force_service;
} TrackerClientPrivate;
G_DEFINE_TYPE(TrackerClient, tracker_client, G_TYPE_OBJECT)
@@ -198,6 +200,14 @@ tracker_client_class_init (TrackerClientClass *klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_FORCE_SERVICE,
+ g_param_spec_boolean ("force-service",
+ "Force service startup",
+ "Force service startup",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
g_type_class_add_private (object_class, sizeof (TrackerClientPrivate));
}
@@ -215,6 +225,9 @@ tracker_client_set_property (GObject *object,
case PROP_ENABLE_WARNINGS:
priv->enable_warnings = g_value_get_boolean (value);
break;
+ case PROP_FORCE_SERVICE:
+ priv->force_service = g_value_get_boolean (value);
+ break;
case PROP_TIMEOUT:
val = g_value_get_int (value);
if (val > 0) {
@@ -239,6 +252,9 @@ tracker_client_get_property (GObject *object,
case PROP_ENABLE_WARNINGS:
g_value_set_boolean (value, priv->enable_warnings);
break;
+ case PROP_FORCE_SERVICE:
+ g_value_set_boolean (value, priv->force_service);
+ break;
case PROP_TIMEOUT:
g_value_set_int (value, priv->timeout);
break;
@@ -263,7 +279,7 @@ tracker_client_init (TrackerClient *client)
return;
}
- if (!start_service (dbus_g_connection_get_connection (connection), TRACKER_SERVICE)) {
+ if (priv->force_service && !start_service (dbus_g_connection_get_connection (connection), TRACKER_SERVICE)) {
/* unable to start tracker-store */
dbus_g_connection_unref (connection);
return;
@@ -470,8 +486,26 @@ tracker_connect (gboolean enable_warnings,
g_type_init ();
- client = g_object_new (TRACKER_TYPE_CLIENT, "timeout", timeout,
- "enable-warnings", enable_warnings, NULL);
+ client = g_object_new (TRACKER_TYPE_CLIENT,
+ "timeout", timeout,
+ "enable-warnings", enable_warnings,
+ "force-service", TRUE, NULL);
+
+ return client;
+}
+
+TrackerClient *
+tracker_connect_no_service_start (gboolean enable_warnings,
+ gint timeout)
+{
+ TrackerClient *client;
+
+ g_type_init ();
+
+ client = g_object_new (TRACKER_TYPE_CLIENT,
+ "timeout", timeout,
+ "enable-warnings", enable_warnings,
+ "force-service", FALSE, NULL);
return client;
}
diff --git a/src/libtracker-client/tracker.h b/src/libtracker-client/tracker.h
index a98eb12..180d13d 100644
--- a/src/libtracker-client/tracker.h
+++ b/src/libtracker-client/tracker.h
@@ -105,6 +105,8 @@ gchar * tracker_sparql_escape (const gchar
TrackerClient *tracker_connect (gboolean enable_warnings,
gint timeout);
+TrackerClient *tracker_connect_no_service_start (gboolean enable_warnings,
+ gint timeout);
void tracker_disconnect (TrackerClient *client);
/* Synchronous API */
diff --git a/src/plugins/evolution/tracker-evolution-plugin.c b/src/plugins/evolution/tracker-evolution-plugin.c
index 99284ec..22237d9 100644
--- a/src/plugins/evolution/tracker-evolution-plugin.c
+++ b/src/plugins/evolution/tracker-evolution-plugin.c
@@ -2146,7 +2146,7 @@ name_owner_changed_cb (DBusGProxy *proxy,
if (tracker_is_empty_string (old_owner) && !tracker_is_empty_string (new_owner)) {
if (!priv->client) {
- priv->client = tracker_connect (FALSE, G_MAXINT);
+ priv->client = tracker_connect_no_service_start (FALSE, G_MAXINT);
}
register_client (user_data);
}
@@ -2338,7 +2338,7 @@ miner_started (TrackerMiner *miner)
g_static_rec_mutex_lock (priv->mutex);
if (!priv->client) {
- priv->client = tracker_connect (FALSE, G_MAXINT);
+ priv->client = tracker_connect_no_service_start (FALSE, G_MAXINT);
}
g_static_rec_mutex_unlock (priv->mutex);
@@ -2440,7 +2440,7 @@ miner_resumed (TrackerMiner *miner)
priv->of_total = 0;
if (!priv->client) {
- priv->client = tracker_connect (FALSE, G_MAXINT);
+ priv->client = tracker_connect_no_service_start (FALSE, G_MAXINT);
}
g_static_rec_mutex_unlock (priv->mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]