[tracker/gdbus-porting: 1/33] libtracker-miner: GDBus port of tracker-miner-manager.c



commit 30e2fcacd3e84cf8e98f5aabe450661948a441b6
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Dec 28 14:03:33 2010 +0100

    libtracker-miner: GDBus port of tracker-miner-manager.c

 src/libtracker-miner/tracker-miner-manager.c |  479 ++++++++++++++++----------
 1 files changed, 291 insertions(+), 188 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-manager.c b/src/libtracker-miner/tracker-miner-manager.c
index 568f86e..4fa4f16 100644
--- a/src/libtracker-miner/tracker-miner-manager.c
+++ b/src/libtracker-miner/tracker-miner-manager.c
@@ -19,6 +19,8 @@
 
 #include "config.h"
 
+#include <gio/gio.h>
+
 #include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-type-utils.h>
 
@@ -56,12 +58,16 @@ struct MinerData {
 	gchar *dbus_path;
 	gchar *display_name;
 	gchar *description;
+
+	GDBusConnection *connection;
+	guint progress_signal;
+	guint paused_signal;
+	guint resumed_signal;
+	guint watch_name_signal;
 };
 
 struct TrackerMinerManagerPrivate {
-	DBusGConnection *connection;
-	DBusGProxy *proxy;
-
+	GDBusConnection *connection;
 	GList *miners;
 	GHashTable *miner_proxies;
 };
@@ -69,7 +75,6 @@ struct TrackerMinerManagerPrivate {
 static void miner_manager_finalize (GObject *object);
 static void initialize_miners_data (TrackerMinerManager *manager);
 
-
 G_DEFINE_TYPE (TrackerMinerManager, tracker_miner_manager, G_TYPE_OBJECT)
 
 enum {
@@ -185,7 +190,7 @@ tracker_miner_manager_class_init (TrackerMinerManagerClass *klass)
 	g_type_class_add_private (object_class, sizeof (TrackerMinerManagerPrivate));
 }
 
-static DBusGProxy *
+static GDBusProxy *
 find_miner_proxy (TrackerMinerManager *manager,
                   const gchar         *name,
                   gboolean             try_suffix)
@@ -213,68 +218,61 @@ find_miner_proxy (TrackerMinerManager *manager,
 }
 
 static void
-name_owner_changed_cb (DBusGProxy  *proxy,
-                       const gchar *name,
-                       const gchar *old_owner,
-                       const gchar *new_owner,
-                       gpointer     user_data)
+miner_appears (GDBusConnection *connection,
+               const gchar     *name,
+               const gchar     *name_owner,
+               gpointer         user_data)
 {
-	TrackerMinerManager *manager = user_data;
-
-	if (find_miner_proxy (manager, name, FALSE) != NULL) {
-		if (new_owner && (!old_owner || !*old_owner)) {
-			g_signal_emit (manager, signals[MINER_ACTIVATED], 0, name);
-		} else if (old_owner && (!new_owner || !*new_owner)) {
-			g_signal_emit (manager, signals[MINER_DEACTIVATED], 0, name);
-		}
-	}
+	g_signal_emit (user_data, signals[MINER_ACTIVATED], 0, name);
 }
 
 static void
-miner_progress_changed (DBusGProxy  *proxy,
-                        const gchar *status,
-                        gdouble      progress,
-                        gpointer     user_data)
+miner_disappears (GDBusConnection *connection,
+                  const gchar     *name,
+                  gpointer         user_data)
 {
-	TrackerMinerManager *manager = user_data;
-	TrackerMinerManagerPrivate *priv;
-	const gchar *name;
-
-	manager = user_data;
-	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
-	name = g_hash_table_lookup (priv->miner_proxies, proxy);
-
-	g_signal_emit (manager, signals[MINER_PROGRESS], 0, name, status, progress);
+	g_signal_emit (user_data, signals[MINER_DEACTIVATED], 0, name);
 }
 
 static void
-miner_paused (DBusGProxy *proxy,
-              gpointer    user_data)
+miner_progress_changed (GDBusConnection *connection,
+                        const gchar     *sender_name,
+                        const gchar     *object_path,
+                        const gchar     *interface_name,
+                        const gchar     *signal_name,
+                        GVariant        *parameters,
+                        gpointer         user_data)
 {
-	TrackerMinerManager *manager = user_data;
-	TrackerMinerManagerPrivate *priv;
-	const gchar *name;
-
-	manager = user_data;
-	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
-	name = g_hash_table_lookup (priv->miner_proxies, proxy);
+	const gchar *status = NULL;
+	gdouble progress = 0;
 
-	g_signal_emit (manager, signals[MINER_PAUSED], 0, name);
+	// todo test this g_variant_get
+	g_variant_get (parameters, "^sd", &status, &progress);
+	g_signal_emit (user_data, signals[MINER_PROGRESS], 0, sender_name, status, progress);
 }
 
 static void
-miner_resumed (DBusGProxy *proxy,
-               gpointer    user_data)
+miner_paused (GDBusConnection *connection,
+              const gchar     *sender_name,
+              const gchar     *object_path,
+              const gchar     *interface_name,
+              const gchar     *signal_name,
+              GVariant        *parameters,
+              gpointer         user_data)
 {
-	TrackerMinerManager *manager = user_data;
-	TrackerMinerManagerPrivate *priv;
-	const gchar *name;
-
-	manager = user_data;
-	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
-	name = g_hash_table_lookup (priv->miner_proxies, proxy);
+	g_signal_emit (user_data, signals[MINER_PAUSED], 0, sender_name);
+}
 
-	g_signal_emit (manager, signals[MINER_RESUMED], 0, name);
+static void
+miner_resumed (GDBusConnection *connection,
+               const gchar     *sender_name,
+               const gchar     *object_path,
+               const gchar     *interface_name,
+               const gchar     *signal_name,
+               GVariant        *parameters,
+               gpointer         user_data)
+{
+	g_signal_emit (user_data, signals[MINER_RESUMED], 0, sender_name);
 }
 
 static void
@@ -286,7 +284,7 @@ tracker_miner_manager_init (TrackerMinerManager *manager)
 
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
 
-	priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+	priv->connection =  g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
 
 	if (!priv->connection) {
 		g_critical ("Could not connect to the D-Bus session bus, %s",
@@ -294,78 +292,103 @@ tracker_miner_manager_init (TrackerMinerManager *manager)
 		g_clear_error (&error);
 	}
 
-	priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
-	                                         DBUS_SERVICE_DBUS,
-	                                         DBUS_PATH_DBUS,
-	                                         DBUS_INTERFACE_DBUS);
-
-	if (!priv->proxy) {
-		g_critical ("Could not get proxy for D-Bus service");
-	}
-
 	priv->miner_proxies = g_hash_table_new_full (NULL, NULL,
 	                                             (GDestroyNotify) g_object_unref,
 	                                             (GDestroyNotify) g_free);
 
-	dbus_g_object_register_marshaller (tracker_marshal_VOID__STRING_DOUBLE,
-	                                   G_TYPE_NONE,
-	                                   G_TYPE_STRING,
-	                                   G_TYPE_DOUBLE,
-	                                   G_TYPE_INVALID);
-
-	dbus_g_proxy_add_signal (priv->proxy,
-	                         "NameOwnerChanged",
-	                         G_TYPE_STRING,
-	                         G_TYPE_STRING,
-	                         G_TYPE_STRING,
-	                         G_TYPE_INVALID);
-
-	dbus_g_proxy_connect_signal (priv->proxy,
-	                             "NameOwnerChanged",
-	                             G_CALLBACK (name_owner_changed_cb),
-	                             manager, NULL);
-
 	initialize_miners_data (manager);
 
 	for (m = priv->miners; m; m = m->next) {
-		DBusGProxy *proxy;
+		GDBusProxy *proxy;
 		MinerData *data;
+		GError *p_error = NULL;
 
 		data = m->data;
+		data->connection = g_object_ref (priv->connection);
+
+		// todo test all these routines
 
-		proxy = dbus_g_proxy_new_for_name (priv->connection,
-		                                   data->dbus_name,
-		                                   data->dbus_path,
-		                                   TRACKER_MINER_DBUS_INTERFACE);
-
-		dbus_g_proxy_add_signal (proxy,
-		                         "Progress",
-		                         G_TYPE_STRING,
-		                         G_TYPE_DOUBLE,
-		                         G_TYPE_INVALID);
-		dbus_g_proxy_add_signal (proxy, "Paused", G_TYPE_INVALID);
-		dbus_g_proxy_add_signal (proxy, "Resumed", G_TYPE_INVALID);
-
-		dbus_g_proxy_connect_signal (proxy,
-		                             "Progress",
-		                             G_CALLBACK (miner_progress_changed),
-		                             manager, NULL);
-		dbus_g_proxy_connect_signal (proxy,
-		                             "Paused",
-		                             G_CALLBACK (miner_paused),
-		                             manager, NULL);
-		dbus_g_proxy_connect_signal (proxy,
-		                             "Resumed",
-		                             G_CALLBACK (miner_resumed),
-		                             manager, NULL);
+		proxy = g_dbus_proxy_new_sync (priv->connection,
+		                               G_DBUS_PROXY_FLAGS_NONE,
+		                               NULL,
+		                               data->dbus_name,
+		                               data->dbus_path,
+		                               TRACKER_MINER_DBUS_INTERFACE,
+		                               NULL,
+		                               &p_error);
+
+
+		if (p_error) {
+			g_critical ("Could not create proxy on the D-Bus session bus, %s",
+			            p_error ? p_error->message : "no error given.");
+			g_clear_error (&p_error);
+			continue;
+		}
+
+		data->progress_signal = g_dbus_connection_signal_subscribe (priv->connection,
+		                                                            data->dbus_name,
+		                                                            TRACKER_MINER_DBUS_INTERFACE,
+		                                                            "Progress",
+		                                                            data->dbus_path,
+		                                                            NULL,
+		                                                            G_DBUS_SIGNAL_FLAGS_NONE,
+		                                                            miner_progress_changed,
+		                                                            manager,
+		                                                            NULL);
+
+		data->paused_signal = g_dbus_connection_signal_subscribe (priv->connection,
+		                                                          data->dbus_name,
+		                                                          TRACKER_MINER_DBUS_INTERFACE,
+		                                                          "Paused",
+		                                                          data->dbus_path,
+		                                                          NULL,
+		                                                          G_DBUS_SIGNAL_FLAGS_NONE,
+		                                                          miner_paused,
+		                                                          manager,
+		                                                          NULL);
+
+
+		data->resumed_signal = g_dbus_connection_signal_subscribe (priv->connection,
+		                                                           data->dbus_name,
+		                                                           TRACKER_MINER_DBUS_INTERFACE,
+		                                                           "Resumed",
+		                                                           data->dbus_path,
+		                                                           NULL,
+		                                                           G_DBUS_SIGNAL_FLAGS_NONE,
+		                                                           miner_resumed,
+		                                                           manager,
+		                                                           NULL);
 
 		g_hash_table_insert (priv->miner_proxies, proxy, g_strdup (data->dbus_name));
+
+		data->watch_name_signal = g_bus_watch_name (G_BUS_TYPE_SESSION,
+		                                            data->dbus_name,
+		                                            G_BUS_NAME_WATCHER_FLAGS_NONE,
+		                                            miner_appears,
+		                                            miner_disappears,
+		                                            manager,
+		                                            NULL);
+
 	}
 }
 
 static void
 miner_data_free (MinerData *data)
 {
+	if (data->watch_name_signal)
+		g_bus_unwatch_name (data->watch_name_signal);
+	if (data->progress_signal)
+		g_dbus_connection_signal_unsubscribe (data->connection,
+		                                      data->progress_signal);
+	if (data->paused_signal)
+		g_dbus_connection_signal_unsubscribe (data->connection,
+		                                      data->paused_signal);
+	if (data->resumed_signal)
+		g_dbus_connection_signal_unsubscribe (data->connection,
+		                                      data->resumed_signal);
+	if (data->connection)
+		g_object_unref (data->connection);
+
 	g_free (data->dbus_path);
 	g_free (data->display_name);
 	g_slice_free (MinerData, data);
@@ -378,16 +401,13 @@ miner_manager_finalize (GObject *object)
 
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (object);
 
-	if (priv->proxy) {
-		g_object_unref (priv->proxy);
-	}
-
 	if (priv->connection) {
-		dbus_g_connection_unref (priv->connection);
+		g_object_unref (priv->connection);
 	}
 
 	g_list_foreach (priv->miners, (GFunc) miner_data_free, NULL);
 	g_list_free (priv->miners);
+	g_hash_table_unref (priv->miner_proxies);
 
 	G_OBJECT_CLASS (tracker_miner_manager_parent_class)->finalize (object);
 }
@@ -421,26 +441,30 @@ tracker_miner_manager_get_running (TrackerMinerManager *manager)
 {
 	TrackerMinerManagerPrivate *priv;
 	GSList *list = NULL;
-	GError *error = NULL;
+//	GError *error = NULL;
 	gchar **p, **result;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), NULL);
 
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
 
-	if (!priv->connection || !priv->proxy) {
-		return NULL;
-	}
+// TODO implement
+
+//	if (!priv->connection || !priv->proxy) {
+//		return NULL;
+//	}
+
+//
+//	if (!dbus_g_proxy_call (priv->proxy, "ListNames", &error,
+//	                        G_TYPE_INVALID,
+//	                        G_TYPE_STRV, &result,
+//	                        G_TYPE_INVALID)) {
+//		g_critical ("Could not get a list of names registered on the session bus, %s",
+//		            error ? error->message : "no error given");
+//		g_clear_error (&error);
+//		return NULL;
+//	}
 
-	if (!dbus_g_proxy_call (priv->proxy, "ListNames", &error,
-	                        G_TYPE_INVALID,
-	                        G_TYPE_STRV, &result,
-	                        G_TYPE_INVALID)) {
-		g_critical ("Could not get a list of names registered on the session bus, %s",
-		            error ? error->message : "no error given");
-		g_clear_error (&error);
-		return NULL;
-	}
 
 	if (result) {
 		for (p = result; *p; p++) {
@@ -540,7 +564,7 @@ initialize_miners_data (TrackerMinerManager *manager)
 	GMainLoop *main_loop;
 	GFile *file;
 	TrackerCrawler *crawler;
-        const gchar    *miners_dir;
+	const gchar    *miners_dir;
 	crawler = tracker_crawler_new ();
 	main_loop = g_main_loop_new (NULL, FALSE);
 
@@ -552,12 +576,12 @@ initialize_miners_data (TrackerMinerManager *manager)
 	                  main_loop);
 
 	/* Go through service files */
-        miners_dir = g_getenv ("TRACKER_MINERS_DIR");
-        if (G_LIKELY (miners_dir == NULL)) {
-                miners_dir = TRACKER_MINERS_DIR ;
-        } else {
-                g_message ("Crawling miners in '%s' (set in env)", miners_dir);
-        }
+	miners_dir = g_getenv ("TRACKER_MINERS_DIR");
+	if (G_LIKELY (miners_dir == NULL)) {
+		miners_dir = TRACKER_MINERS_DIR ;
+	} else {
+		g_message ("Crawling miners in '%s' (set in env)", miners_dir);
+	}
 
 	file = g_file_new_for_path (miners_dir);
 	tracker_crawler_start (crawler, file, TRUE);
@@ -618,9 +642,10 @@ tracker_miner_manager_pause (TrackerMinerManager *manager,
                              const gchar         *reason,
                              guint32             *cookie)
 {
-	DBusGProxy *proxy;
+	GDBusProxy *proxy;
 	const gchar *app_name;
 	GError *error = NULL;
+	GVariant *v;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (miner != NULL, FALSE);
@@ -644,7 +669,18 @@ tracker_miner_manager_pause (TrackerMinerManager *manager,
 		app_name = "TrackerMinerManager client";
 	}
 
-	org_freedesktop_Tracker1_Miner_pause (proxy, app_name, reason, cookie, &error);
+	// todo test this call
+	v = g_dbus_proxy_call_sync (proxy,
+	                            "Pause",
+	                            g_variant_new ("ssi", app_name, reason, (gint) cookie),
+	                            G_DBUS_CALL_FLAGS_NONE,
+	                            -1,
+	                            NULL,
+	                            &error);
+
+	if (v) {
+		g_variant_unref (v);
+	}
 
 	if (error) {
 		g_critical ("Could not pause miner '%s': %s", miner, error->message);
@@ -672,8 +708,9 @@ tracker_miner_manager_resume (TrackerMinerManager *manager,
                               const gchar         *miner,
                               guint32              cookie)
 {
-	DBusGProxy *proxy;
+	GDBusProxy *proxy;
 	GError *error = NULL;
+	GVariant *v;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (miner != NULL, FALSE);
@@ -684,7 +721,18 @@ tracker_miner_manager_resume (TrackerMinerManager *manager,
 		return FALSE;
 	}
 
-	org_freedesktop_Tracker1_Miner_resume (proxy, cookie, &error);
+	// todo test this call
+	v = g_dbus_proxy_call_sync (proxy,
+	                            "Resume",
+	                            g_variant_new ("i", (gint) cookie),
+	                            G_DBUS_CALL_FLAGS_NONE,
+	                            -1,
+	                            NULL,
+	                            &error);
+
+	if (v) {
+		g_variant_unref (v);
+	}
 
 	if (error) {
 		g_critical ("Could not resume miner '%s': %s", miner, error->message);
@@ -709,24 +757,25 @@ tracker_miner_manager_is_active (TrackerMinerManager *manager,
                                  const gchar         *miner)
 {
 	TrackerMinerManagerPrivate *priv;
-	GError *error = NULL;
-	gboolean active;
+//	GError *error = NULL;
+	gboolean active = FALSE;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (miner != NULL, FALSE);
 
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
 
-	if (!dbus_g_proxy_call (priv->proxy, "NameHasOwner", &error,
-	                        G_TYPE_STRING, miner,
-	                        G_TYPE_INVALID,
-	                        G_TYPE_BOOLEAN, &active,
-	                        G_TYPE_INVALID)) {
-		g_critical ("Could not check whether miner '%s' is currently active: %s",
-		            miner, error ? error->message : "no error given");
-		g_error_free (error);
-		return FALSE;
-	}
+// TODO
+//	if (!dbus_g_proxy_call (priv->proxy, "NameHasOwner", &error,
+//	                        G_TYPE_STRING, miner,
+//	                        G_TYPE_INVALID,
+//	                        G_TYPE_BOOLEAN, &active,
+//	                        G_TYPE_INVALID)) {
+//		g_critical ("Could not check whether miner '%s' is currently active: %s",
+//		            miner, error ? error->message : "no error given");
+//		g_error_free (error);
+//		return FALSE;
+//	}
 
 	return active;
 }
@@ -749,10 +798,10 @@ tracker_miner_manager_get_status (TrackerMinerManager  *manager,
                                   gchar               **status,
                                   gdouble              *progress)
 {
-	DBusGProxy *proxy;
+	GDBusProxy *proxy;
 	GError *error = NULL;
 	gdouble p;
-	gchar *st;
+	GVariant *v;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (miner != NULL, FALSE);
@@ -764,7 +813,18 @@ tracker_miner_manager_get_status (TrackerMinerManager  *manager,
 		return FALSE;
 	}
 
-	org_freedesktop_Tracker1_Miner_get_progress (proxy, &p, &error);
+	v = g_dbus_proxy_call_sync (proxy,
+	                            "GetProgress",
+	                            NULL,
+	                            G_DBUS_CALL_FLAGS_NONE,
+	                            -1,
+	                            NULL,
+	                            &error);
+
+	if (v) {
+		p = g_variant_get_double (v);
+		g_variant_unref (v);
+	}
 
 	if (error) {
 		/* We handle this error as a special case, some
@@ -780,20 +840,32 @@ tracker_miner_manager_get_status (TrackerMinerManager  *manager,
 		return FALSE;
 	}
 
-	org_freedesktop_Tracker1_Miner_get_status (proxy, &st, &error);
+	// todo test this call
+	v = g_dbus_proxy_call_sync (proxy,
+	                            "GetStatus",
+	                            NULL,
+	                            G_DBUS_CALL_FLAGS_NONE,
+	                            -1,
+	                            NULL,
+	                            &error);
 
 	if (error) {
 		g_critical ("Could not get miner status for '%s': %s", miner,
 		            error->message);
 		g_error_free (error);
-
+		if (v) {
+			g_variant_unref (v);
+		}
 		return FALSE;
 	}
 
-	if (status) {
-		*status = st;
-	} else {
-		g_free (st);
+	if (v && status) {
+		gsize len;
+		*status = g_variant_dup_string (v, &len);
+	}
+
+	if (v) {
+		g_variant_unref (v);
 	}
 
 	if (progress) {
@@ -824,10 +896,11 @@ tracker_miner_manager_is_paused (TrackerMinerManager *manager,
                                  GStrv               *applications,
                                  GStrv               *reasons)
 {
-	DBusGProxy *proxy;
+	GDBusProxy *proxy;
 	GStrv apps, r;
 	GError *error = NULL;
 	gboolean paused;
+	GVariant *v;
 
 	if (applications) {
 		*applications = NULL;
@@ -847,16 +920,33 @@ tracker_miner_manager_is_paused (TrackerMinerManager *manager,
 		return FALSE;
 	}
 
-	org_freedesktop_Tracker1_Miner_get_pause_details (proxy, &apps, &r, &error);
+	// todo test this call
+	v = g_dbus_proxy_call_sync (proxy,
+	                            "GetPauseDetails",
+	                            NULL,
+	                            G_DBUS_CALL_FLAGS_NONE,
+	                            -1,
+	                            NULL,
+	                            &error);
 
 	if (error) {
 		g_critical ("Could not get pause details for miner '%s': %s", miner,
 		            error->message);
 		g_error_free (error);
 
+		if (v) {
+			g_variant_unref (v);
+		}
+
 		return TRUE;
 	}
 
+	if (v) {
+		// todo test this format string
+		g_variant_get (v, "^as^as", &apps, &r);
+		g_variant_unref (v);
+	}
+
 	paused = (g_strv_length (apps) > 0);
 
 	if (applications) {
@@ -957,9 +1047,9 @@ tracker_miner_manager_ignore_next_update (TrackerMinerManager *manager,
                                           const gchar         *miner,
                                           const gchar        **urls)
 {
-	DBusGProxy *proxy;
-	const gchar *app_name;
+	GDBusProxy *proxy;
 	GError *error = NULL;
+	GVariant *v;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (miner != NULL, FALSE);
@@ -971,19 +1061,18 @@ tracker_miner_manager_ignore_next_update (TrackerMinerManager *manager,
 		return FALSE;
 	}
 
-	/* Find a reasonable app name */
-	app_name = g_get_application_name ();
+	v = g_dbus_proxy_call_sync (proxy,
+	                            "IgnoreNextUpdate",
+	                            g_variant_new ("as", urls),
+	                            G_DBUS_CALL_FLAGS_NONE,
+	                            -1,
+	                            NULL,
+	                            &error);
 
-	if (!app_name) {
-		app_name = g_get_prgname ();
+	if (v) {
+		g_variant_unref (v);
 	}
 
-	if (!app_name) {
-		app_name = "TrackerMinerManager client";
-	}
-
-	org_freedesktop_Tracker1_Miner_ignore_next_update (proxy, urls, &error);
-
 	if (error) {
 		g_warning ("Could not ignore next update for miner '%s': %s", miner, error->message);
 		g_error_free (error);
@@ -1030,9 +1119,9 @@ tracker_miner_manager_reindex_by_mimetype (TrackerMinerManager  *manager,
                                            const GStrv           mimetypes,
                                            GError              **error)
 {
-	static DBusGProxy *proxy = NULL;
 	TrackerMinerManagerPrivate *priv;
 	GError *internal_error = NULL;
+	GVariant *v;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (mimetypes != NULL, FALSE);
@@ -1048,17 +1137,22 @@ tracker_miner_manager_reindex_by_mimetype (TrackerMinerManager  *manager,
 
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
 
-	if (G_UNLIKELY (!proxy)) {
-		proxy = dbus_g_proxy_new_for_name (priv->connection,
-		                                   "org.freedesktop.Tracker1.Miner.Files.Index",
-		                                   "/org/freedesktop/Tracker1/Miner/Files/Index",
-		                                   "org.freedesktop.Tracker1.Miner.Files.Index");
+	v = g_dbus_connection_call_sync (priv->connection,
+	                                 "org.freedesktop.Tracker1.Miner.Files.Index",
+	                                 "/org/freedesktop/Tracker1/Miner/Files/Index",
+	                                 "org.freedesktop.Tracker1.Miner.Files.Index",
+	                                 "ReindexMimeTypes",
+	                                 g_variant_new ("as", mimetypes),
+	                                 NULL,
+	                                 G_DBUS_CALL_FLAGS_NONE,
+	                                 -1,
+	                                 NULL,
+	                                 &internal_error);
+
+	if (v) {
+		g_variant_unref (v);
 	}
 
-	org_freedesktop_Tracker1_Miner_Files_Index_reindex_mime_types (proxy,
-	                                                               (const gchar **) mimetypes,
-	                                                               &internal_error);
-
 	if (internal_error) {
 		g_propagate_error (error, internal_error);
 		return FALSE;
@@ -1084,10 +1178,10 @@ tracker_miner_manager_index_file (TrackerMinerManager  *manager,
                                   GFile                *file,
                                   GError              **error)
 {
-	static DBusGProxy *proxy = NULL;
 	TrackerMinerManagerPrivate *priv;
 	GError *internal_error = NULL;
 	gchar *uri;
+	GVariant *v;
 
 	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
 	g_return_val_if_fail (G_IS_FILE (file), FALSE);
@@ -1111,15 +1205,24 @@ tracker_miner_manager_index_file (TrackerMinerManager  *manager,
 
 	priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager);
 
-	if (G_UNLIKELY (!proxy)) {
-		proxy = dbus_g_proxy_new_for_name (priv->connection,
-		                                   "org.freedesktop.Tracker1.Miner.Files.Index",
-		                                   "/org/freedesktop/Tracker1/Miner/Files/Index",
-		                                   "org.freedesktop.Tracker1.Miner.Files.Index");
+	uri = g_file_get_uri (file);
+
+	v = g_dbus_connection_call_sync (priv->connection,
+	                                 "org.freedesktop.Tracker1.Miner.Files.Index",
+	                                 "/org/freedesktop/Tracker1/Miner/Files/Index",
+	                                 "org.freedesktop.Tracker1.Miner.Files.Index",
+	                                 "IndexFile",
+	                                 g_variant_new ("s", uri),
+	                                 NULL,
+	                                 G_DBUS_CALL_FLAGS_NONE,
+	                                 -1,
+	                                 NULL,
+	                                 &internal_error);
+
+	if (v) {
+		g_variant_unref (v);
 	}
 
-	uri = g_file_get_uri (file);
-	org_freedesktop_Tracker1_Miner_Files_Index_index_file (proxy, uri, &internal_error);
 	g_free (uri);
 
 	if (internal_error) {



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