[tracker/gdbus-porting: 3/33] libtracker-miner: GDBus porting of tracker-thumbnailer.c
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gdbus-porting: 3/33] libtracker-miner: GDBus porting of tracker-thumbnailer.c
- Date: Fri, 31 Dec 2010 09:44:38 +0000 (UTC)
commit 6441e21f77dc28f6406b0c65c32a3648bbe3bcbe
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Dec 28 16:24:55 2010 +0100
libtracker-miner: GDBus porting of tracker-thumbnailer.c
src/libtracker-miner/tracker-miner-manager.c | 37 ++++--
src/libtracker-miner/tracker-thumbnailer.c | 167 +++++++++++++++----------
2 files changed, 123 insertions(+), 81 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-manager.c b/src/libtracker-miner/tracker-miner-manager.c
index 05dc14d..ff31614 100644
--- a/src/libtracker-miner/tracker-miner-manager.c
+++ b/src/libtracker-miner/tracker-miner-manager.c
@@ -63,7 +63,7 @@ struct MinerData {
guint progress_signal;
guint paused_signal;
guint resumed_signal;
- guint watch_name_signal;
+ guint watch_name_id;
};
struct TrackerMinerManagerPrivate {
@@ -361,13 +361,13 @@ tracker_miner_manager_init (TrackerMinerManager *manager)
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);
+ data->watch_name_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ data->dbus_name,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ miner_appears,
+ miner_disappears,
+ manager,
+ NULL);
}
}
@@ -375,19 +375,28 @@ tracker_miner_manager_init (TrackerMinerManager *manager)
static void
miner_data_free (MinerData *data)
{
- if (data->watch_name_signal)
- g_bus_unwatch_name (data->watch_name_signal);
- if (data->progress_signal)
+ if (data->watch_name_id != 0) {
+ g_bus_unwatch_name (data->watch_name_id);
+ }
+
+ if (data->progress_signal) {
g_dbus_connection_signal_unsubscribe (data->connection,
data->progress_signal);
- if (data->paused_signal)
+ }
+
+ if (data->paused_signal) {
g_dbus_connection_signal_unsubscribe (data->connection,
data->paused_signal);
- if (data->resumed_signal)
+ }
+
+ if (data->resumed_signal) {
g_dbus_connection_signal_unsubscribe (data->connection,
data->resumed_signal);
- if (data->connection)
+ }
+
+ if (data->connection) {
g_object_unref (data->connection);
+ }
g_free (data->dbus_path);
g_free (data->display_name);
diff --git a/src/libtracker-miner/tracker-thumbnailer.c b/src/libtracker-miner/tracker-thumbnailer.c
index 10519b2..857238b 100644
--- a/src/libtracker-miner/tracker-thumbnailer.c
+++ b/src/libtracker-miner/tracker-thumbnailer.c
@@ -48,8 +48,9 @@
#define THUMBMAN_INTERFACE "org.freedesktop.thumbnails.Thumbnailer1"
typedef struct {
- DBusGProxy *cache_proxy;
- DBusGProxy *manager_proxy;
+ GDBusProxy *cache_proxy;
+ GDBusProxy *manager_proxy;
+ GDBusConnection *connection;
GStrv supported_mime_types;
@@ -78,6 +79,10 @@ private_free (gpointer data)
g_object_unref (private->manager_proxy);
}
+ if (private->connection) {
+ g_object_unref (private->connection);
+ }
+
g_strfreev (private->supported_mime_types);
g_slist_foreach (private->removes, (GFunc) g_free, NULL);
@@ -118,10 +123,8 @@ gboolean
tracker_thumbnailer_init (void)
{
TrackerThumbnailerPrivate *private;
- DBusGConnection *connection;
- GStrv mime_types = NULL;
- GStrv uri_schemes = NULL;
GError *error = NULL;
+ GVariant *v;
private = g_new0 (TrackerThumbnailerPrivate, 1);
@@ -134,9 +137,9 @@ tracker_thumbnailer_init (void)
g_message ("Thumbnailer connections being set up...");
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ private->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
- if (!connection) {
+ if (!private->connection) {
g_critical ("Could not connect to the D-Bus session bus, %s",
error ? error->message : "no error given.");
g_clear_error (&error);
@@ -146,24 +149,41 @@ tracker_thumbnailer_init (void)
return FALSE;
}
- private->cache_proxy =
- dbus_g_proxy_new_for_name (connection,
- THUMBCACHE_SERVICE,
- THUMBCACHE_PATH,
- THUMBCACHE_INTERFACE);
-
- private->manager_proxy =
- dbus_g_proxy_new_for_name (connection,
- THUMBMAN_SERVICE,
- THUMBMAN_PATH,
- THUMBMAN_INTERFACE);
-
- dbus_g_proxy_call (private->manager_proxy,
- "GetSupported", &error,
- G_TYPE_INVALID,
- G_TYPE_STRV, &uri_schemes,
- G_TYPE_STRV, &mime_types,
- G_TYPE_INVALID);
+ private->cache_proxy = g_dbus_proxy_new_sync (private->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ THUMBCACHE_SERVICE,
+ THUMBCACHE_PATH,
+ THUMBCACHE_INTERFACE,
+ NULL,
+ &error);
+
+ if (error) {
+ goto error_handler;
+ }
+
+ private->manager_proxy = g_dbus_proxy_new_sync (private->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ THUMBMAN_SERVICE,
+ THUMBMAN_PATH,
+ THUMBMAN_INTERFACE,
+ NULL,
+ &error);
+
+ if (error) {
+ goto error_handler;
+ }
+
+ v = g_dbus_proxy_call_sync (private->manager_proxy,
+ "GetSupported",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+error_handler:
if (error) {
g_message ("Thumbnailer service did not return supported mime types, %s",
@@ -182,40 +202,46 @@ tracker_thumbnailer_init (void)
}
return FALSE;
- } else if (mime_types) {
- GHashTable *hash;
- GHashTableIter iter;
- gpointer key, value;
- guint i;
+ } else if (v) {
+ GStrv mime_types = NULL;
+ GStrv uri_schemes = NULL;
- /* The table that you receive may contain duplicate mime-types, because
- * they are grouped against the uri_schemes table */
+ g_variant_get (v, "asas", &mime_types, &uri_schemes);
- hash = g_hash_table_new (g_str_hash, g_str_equal);
+ if (mime_types) {
+ GHashTable *hash;
+ GHashTableIter iter;
+ gpointer key, value;
+ guint i;
- for (i = 0; mime_types[i] != NULL; i++) {
- g_hash_table_insert (hash, mime_types[i], NULL);
- }
+ /* The table that you receive may contain duplicate mime-types, because
+ * they are grouped against the uri_schemes table */
- i = g_hash_table_size (hash);
- g_message ("Thumbnailer supports %d mime types", i);
+ hash = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_iter_init (&iter, hash);
- private->supported_mime_types = (GStrv) g_new0 (gchar *, i + 1);
+ for (i = 0; mime_types[i] != NULL; i++) {
+ g_hash_table_insert (hash, mime_types[i], NULL);
+ }
- i = 0;
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- private->supported_mime_types[i] = g_strdup (key);
- i++;
- }
+ i = g_hash_table_size (hash);
+ g_message ("Thumbnailer supports %d mime types", i);
- g_hash_table_unref (hash);
+ g_hash_table_iter_init (&iter, hash);
+ private->supported_mime_types = (GStrv) g_new0 (gchar *, i + 1);
- private->service_is_available = TRUE;
- }
+ i = 0;
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ private->supported_mime_types[i] = g_strdup (key);
+ i++;
+ }
- g_strfreev (mime_types);
- g_strfreev (uri_schemes);
+ g_hash_table_unref (hash);
+
+ private->service_is_available = TRUE;
+ }
+
+ g_variant_unref (v);
+ }
return TRUE;
}
@@ -308,12 +334,14 @@ tracker_thumbnailer_cleanup (const gchar *uri_prefix)
uri_prefix,
private->request_id);
- dbus_g_proxy_call_no_reply (private->cache_proxy,
- "Cleanup",
- G_TYPE_STRING, uri_prefix,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ g_dbus_proxy_call (private->cache_proxy,
+ "Cleanup",
+ g_variant_new ("s", uri_prefix),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
return TRUE;
}
@@ -338,11 +366,14 @@ tracker_thumbnailer_send (void)
uri_strv = tracker_dbus_slist_to_strv (private->removes);
- dbus_g_proxy_call_no_reply (private->cache_proxy,
- "Delete",
- G_TYPE_STRV, uri_strv,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ g_dbus_proxy_call (private->cache_proxy,
+ "Delete",
+ g_variant_new ("as", uri_strv),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
g_message ("Thumbnailer removes queue sent with %d items to thumbnailer daemon, request ID:%d...",
list_len,
@@ -367,12 +398,14 @@ tracker_thumbnailer_send (void)
from_strv = tracker_dbus_slist_to_strv (private->moves_from);
to_strv = tracker_dbus_slist_to_strv (private->moves_to);
- dbus_g_proxy_call_no_reply (private->cache_proxy,
- "Move",
- G_TYPE_STRV, from_strv,
- G_TYPE_STRV, to_strv,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ g_dbus_proxy_call (private->cache_proxy,
+ "Move",
+ g_variant_new ("asas", from_strv, to_strv),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
g_message ("Thumbnailer moves queue sent with %d items to thumbnailer daemon, request ID:%d...",
list_len,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]