[tracker/gdbus-porting-rebased: 2/65] 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-rebased: 2/65] libtracker-miner: GDBus porting of tracker-thumbnailer.c
- Date: Wed, 12 Jan 2011 11:15:56 +0000 (UTC)
commit 487177fc12495a670ab6cbf18c44ec8d3920bafd
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 | 166 ++++++++++++++++----------
2 files changed, 123 insertions(+), 80 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-manager.c b/src/libtracker-miner/tracker-miner-manager.c
index f2745af..10530e6 100644
--- a/src/libtracker-miner/tracker-miner-manager.c
+++ b/src/libtracker-miner/tracker-miner-manager.c
@@ -61,7 +61,7 @@ struct MinerData {
guint progress_signal;
guint paused_signal;
guint resumed_signal;
- guint watch_name_signal;
+ guint watch_name_id;
};
struct TrackerMinerManagerPrivate {
@@ -357,13 +357,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);
}
}
@@ -371,19 +371,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..60a1a25 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,41 +202,48 @@ 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, "(^a&s^a&s)", &uri_schemes, &mime_types);
- 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 */
+
+ hash = g_hash_table_new (g_str_hash, g_str_equal);
- i = g_hash_table_size (hash);
- g_message ("Thumbnailer supports %d mime types", i);
+ for (i = 0; mime_types[i] != NULL; i++) {
+ g_hash_table_insert (hash, mime_types[i], NULL);
+ }
- g_hash_table_iter_init (&iter, hash);
- private->supported_mime_types = (GStrv) g_new0 (gchar *, i + 1);
+ i = g_hash_table_size (hash);
+ g_message ("Thumbnailer supports %d mime types", i);
- i = 0;
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- private->supported_mime_types[i] = g_strdup (key);
- i++;
+ g_hash_table_iter_init (&iter, hash);
+ private->supported_mime_types = (GStrv) g_new0 (gchar *, i + 1);
+
+ i = 0;
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ private->supported_mime_types[i] = g_strdup (key);
+ i++;
+ }
+
+ g_hash_table_unref (hash);
+
+ private->service_is_available = TRUE;
}
- g_hash_table_unref (hash);
- private->service_is_available = TRUE;
+ g_variant_unref (v);
}
- g_strfreev (mime_types);
- g_strfreev (uri_schemes);
-
return TRUE;
}
@@ -308,12 +335,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 +367,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 +399,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 ("(^as^as)", 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]