[Xfce4-commits] [xfce/tumbler] 04/11: Porting the specialized thumbnailer to gdbus Getting rid of all dbus-glib api
noreply at xfce.org
noreply at xfce.org
Mon May 15 13:20:32 CEST 2017
This is an automated email from the git hooks/post-receive script.
ali pushed a commit to branch master
in repository xfce/tumbler.
commit acc901b4c430bbde7d0e08c5c4df116182af2e64
Author: Ali Abdallah <aliovx at gmail.com>
Date: Sat Oct 10 18:50:17 2015 +0200
Porting the specialized thumbnailer to gdbus
Getting rid of all dbus-glib api
Tumbler is now dbus-glib free!
---
README | 8 +-
configure.ac | 23 +--
tumblerd/Makefile.am | 4 -
tumblerd/main.c | 11 +-
tumblerd/tumbler-cache-service.h | 2 -
tumblerd/tumbler-manager-dbus.xml | 2 +-
tumblerd/tumbler-manager.c | 77 +++++----
tumblerd/tumbler-manager.h | 6 +-
tumblerd/tumbler-service.h | 2 -
tumblerd/tumbler-specialized-thumbnailer.c | 260 +++++++++++++----------------
tumblerd/tumbler-specialized-thumbnailer.h | 6 +-
tumblerd/tumbler-utils.h | 22 +--
12 files changed, 186 insertions(+), 237 deletions(-)
diff --git a/README b/README
index c338921..85e509a 100644
--- a/README
+++ b/README
@@ -22,11 +22,9 @@ Required packages
Tumbler depends on the following packages:
- * glib-2.0 >= 2.16.0
- * gio-2.0 >= 2.16.0
- * gthread-2.0 >= 2.16.0
- * dbus-1 >= 1.0.0
- * dbus-glib-1 >= 0.72
+ * glib-2.0 >= 2.26.0
+ * gio-2.0 >= 2.26.0
+ * gthread-2.0 >= 2.26.0
Tumbler can optionally use the following packages:
diff --git a/configure.ac b/configure.ac
index e612502..471d532 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,17 +129,6 @@ dnl *************************
GTK_DOC_CHECK(1.9)
dnl ***********************************
-dnl *** Check for dbus-binding-tool ***
-dnl ***********************************
-AC_ARG_VAR([DBUS_BINDING_TOOL], [Tool to generate C bindings from XML D-Bus interface definitions])
-AC_PATH_PROG([DBUS_BINDING_TOOL], [dbus-binding-tool], [no])
-if test x"$DBUS_BINDING_TOOL" = x"no"; then
- AC_MSG_ERROR([could not find dbus-binding-tool in \$PATH. You can run
- ./configure DBUS_BINDING_TOOL=/path/to/dbus-binding-tool to define
- a custom location for it.])
-fi
-
-dnl ***********************************
dnl *** Check for gdbus-codegen ***
dnl ***********************************
AC_ARG_VAR([GDBUS_CODEGEN], [D-Bus code and documentation generator from XML D-Bus interface definitions])
@@ -153,13 +142,11 @@ fi
dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
-PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16.0])
-PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.16.0])
-PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.16.0])
-PKG_CHECK_MODULES([GMODULE], [gmodule-2.0 >= 2.10.0])
-PKG_CHECK_MODULES([GTHREAD], [gthread-2.0 >= 2.16.0])
-PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.0.0])
-PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1 >= 0.72])
+PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.26.0])
+PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26.0])
+PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.26.0])
+PKG_CHECK_MODULES([GMODULE], [gmodule-2.0 >= 2.26.0])
+PKG_CHECK_MODULES([GTHREAD], [gthread-2.0 >= 2.26.0])
dnl *************************
dnl *** Check for plugins ***
diff --git a/tumblerd/Makefile.am b/tumblerd/Makefile.am
index 0187bcb..b1ac6a8 100644
--- a/tumblerd/Makefile.am
+++ b/tumblerd/Makefile.am
@@ -61,8 +61,6 @@ tumblerd_CFLAGS = \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-DG_LOG_DOMAIN=\"tumblerd\" \
-I$(top_srcdir) \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(GIO_CFLAGS) \
$(GIO_UNIX_CFLAGS) \
@@ -79,8 +77,6 @@ tumblerd_DEPENDENCIES = \
$(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la
tumblerd_LDADD = \
- $(DBUS_LIBS) \
- $(DBUS_GLIB_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(GIO_LIBS) \
$(GIO_UNIX_LIBS) \
diff --git a/tumblerd/main.c b/tumblerd/main.c
index 0c35161..1bc64cf 100644
--- a/tumblerd/main.c
+++ b/tumblerd/main.c
@@ -374,6 +374,9 @@ main (int argc,
goto exit_tumbler;
}
+ /* create a new main loop */
+ main_loop = g_main_loop_new (NULL, FALSE);
+
/* Acquire the cache service dbus name */
g_bus_own_name_on_connection (connection,
@@ -407,10 +410,10 @@ main (int argc,
tumbler_service_is_exported(service) &&
tumbler_cache_service_is_exported(cache_service))
{
-
- /* create a new main loop */
- main_loop = g_main_loop_new (NULL, FALSE);
-
+ /* Let the manager initializes the thumbnailer
+ * directory objects, directory monitors */
+ tumbler_manager_load (manager);
+
/* quit the main loop when the lifecycle manager asks us to shut down */
g_signal_connect (lifecycle_manager, "shutdown",
G_CALLBACK (shutdown_tumbler), main_loop);
diff --git a/tumblerd/tumbler-cache-service.h b/tumblerd/tumbler-cache-service.h
index 92325e0..4d04e25 100644
--- a/tumblerd/tumbler-cache-service.h
+++ b/tumblerd/tumbler-cache-service.h
@@ -23,8 +23,6 @@
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
#include <tumblerd/tumbler-lifecycle-manager.h>
G_BEGIN_DECLS;
diff --git a/tumblerd/tumbler-manager-dbus.xml b/tumblerd/tumbler-manager-dbus.xml
index b4c0929..dc492e7 100644
--- a/tumblerd/tumbler-manager-dbus.xml
+++ b/tumblerd/tumbler-manager-dbus.xml
@@ -2,7 +2,7 @@
<node name="/org/freedesktop/thumbnails/Manager1">
<interface name="org.freedesktop.thumbnails.Manager1">
- <annotation name="org.gtk.GDBus.C.Name" value="ExportedManager" />
+ <annotation name="org.gtk.GDBus.C.Name" value="ExportedManager" />
<method name="Register">
<arg type="s" name="uri_scheme" direction="in" />
diff --git a/tumblerd/tumbler-manager.c b/tumblerd/tumbler-manager.c
index 1fae160..570eb98 100644
--- a/tumblerd/tumbler-manager.c
+++ b/tumblerd/tumbler-manager.c
@@ -37,10 +37,6 @@
#include <gio/gio.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <tumblerd/tumbler-component.h>
#include <tumblerd/tumbler-manager.h>
#include <tumblerd/tumbler-manager-gdbus.h>
@@ -74,10 +70,10 @@ static void tumbler_manager_set_property (GObject *obj
const GValue *value,
GParamSpec *pspec);
static gboolean tumbler_manager_register_cb (TumblerExportedManager *skeleton,
- GDBusMethodInvocation *invocation,
- const gchar *const *uri_schemes,
- const gchar *const *mime_types,
- TumblerManager *manager);
+ GDBusMethodInvocation *invocation,
+ const gchar *const *uri_schemes,
+ const gchar *const *mime_types,
+ TumblerManager *manager);
static void tumbler_manager_monitor_unref (GFileMonitor *monitor,
TumblerManager *manager);
static void tumbler_manager_load_thumbnailers (TumblerManager *manager,
@@ -110,10 +106,11 @@ struct _TumblerManagerClass
struct _TumblerManager
{
TumblerComponent __parent__;
- DBusGConnection *legacy_connection;
GDBusConnection *connection;
TumblerExportedManager *skeleton;
+ gboolean dbus_interface_exported;
+
TumblerRegistry *registry;
/* Directory and monitor objects for the thumbnailer dirs in
@@ -164,7 +161,7 @@ static void
tumbler_manager_class_init (TumblerManagerClass *klass)
{
GObjectClass *gobject_class;
-
+
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructed = tumbler_manager_constructed;
gobject_class->finalize = tumbler_manager_finalize;
@@ -173,11 +170,11 @@ tumbler_manager_class_init (TumblerManagerClass *klass)
g_object_class_install_property (gobject_class, PROP_CONNECTION,
g_param_spec_object ("connection",
- "connection",
- "connection",
- G_TYPE_DBUS_CONNECTION,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ "connection",
+ "connection",
+ G_TYPE_DBUS_CONNECTION,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, PROP_REGISTRY,
g_param_spec_object ("registry",
@@ -218,22 +215,25 @@ tumbler_manager_constructed (GObject *object)
manager = TUMBLER_MANAGER (object);
- /* FIXME: dbus-glib legacy, to be removed shortly */
- manager->legacy_connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-
manager->skeleton = tumbler_exported_manager_skeleton_new ();
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON(manager->skeleton),
- manager->connection,
- "/org/freedesktop/thumbnails/Manager1",
- &error);
+ manager->connection,
+ "/org/freedesktop/thumbnails/Manager1",
+ &error);
+
if (error != NULL)
{
g_critical ("error exporting thumbnail manager on session bus: %s", error->message);
g_error_free (error);
-
- exit (1);
- }
+ manager->dbus_interface_exported = FALSE;
+ }
+ else
+ {
+ manager->dbus_interface_exported = TRUE;
+ g_signal_connect(manager->skeleton, "handle-register",
+ G_CALLBACK(tumbler_manager_register_cb), manager);
+ }
}
static void
@@ -259,8 +259,12 @@ tumbler_manager_finalize (GObject *object)
g_object_unref (manager->registry);
/* Unexport from dbus */
- g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (manager->skeleton),
- manager->connection);
+ if (manager->dbus_interface_exported)
+ g_dbus_interface_skeleton_unexport_from_connection
+ (
+ G_DBUS_INTERFACE_SKELETON (manager->skeleton),
+ manager->connection
+ );
/* release the Skeleton object */
g_object_unref (manager->skeleton);
@@ -326,10 +330,10 @@ tumbler_manager_set_property (GObject *object,
static gboolean
tumbler_manager_register_cb (TumblerExportedManager *skeleton,
- GDBusMethodInvocation *invocation,
- const gchar *const *uri_schemes,
- const gchar *const *mime_types,
- TumblerManager *manager)
+ GDBusMethodInvocation *invocation,
+ const gchar *const *uri_schemes,
+ const gchar *const *mime_types,
+ TumblerManager *manager)
{
TumblerThumbnailer *thumbnailer;
const gchar *sender_name;
@@ -342,7 +346,7 @@ tumbler_manager_register_cb (TumblerExportedManager *skeleton,
tumbler_mutex_lock (manager->mutex);
- thumbnailer = tumbler_specialized_thumbnailer_new_foreign (manager->legacy_connection,
+ thumbnailer = tumbler_specialized_thumbnailer_new_foreign (manager->connection,
sender_name, uri_schemes,
mime_types);
@@ -1040,7 +1044,7 @@ tumbler_manager_load_thumbnailer (TumblerManager *manager,
/* create a new specialized thumbnailer object and pass all the required
* information on to it */
info->thumbnailer =
- tumbler_specialized_thumbnailer_new (manager->legacy_connection, name, object_path,
+ tumbler_specialized_thumbnailer_new (manager->connection, name, object_path,
(const gchar *const *)uri_schemes,
(const gchar *const *)mime_types,
file_stat.st_mtime);
@@ -1231,7 +1235,7 @@ tumbler_manager_load_thumbnailers (TumblerManager *manager,
* directory objects, directory monitors, override infos and thumbnailer
* infos.
*/
-static void
+void
tumbler_manager_load (TumblerManager *manager)
{
const gchar *const *data_dirs;
@@ -1892,3 +1896,10 @@ tumbler_manager_new (GDBusConnection *connection,
"lifecycle-manager", lifecycle_manager,
NULL);
}
+
+gboolean tumbler_manager_is_exported (TumblerManager *manager)
+{
+ g_return_if_fail (TUMBLER_IS_MANAGER (manager));
+
+ return manager->dbus_interface_exported;
+}
diff --git a/tumblerd/tumbler-manager.h b/tumblerd/tumbler-manager.h
index 60e308f..d0bd741 100644
--- a/tumblerd/tumbler-manager.h
+++ b/tumblerd/tumbler-manager.h
@@ -1,6 +1,7 @@
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2015 Ali Abdallah <ali at xfce.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -21,8 +22,6 @@
#ifndef __TUMBLER_MANAGER_H__
#define __TUMBLER_MANAGER_H__
-#include <dbus/dbus-glib.h>
-
#include <tumblerd/tumbler-lifecycle-manager.h>
#include <tumblerd/tumbler-registry.h>
@@ -43,6 +42,9 @@ GType tumbler_manager_get_type (void) G_GNUC_CONST;
TumblerManager *tumbler_manager_new (GDBusConnection *connection,
TumblerLifecycleManager *lifecycle_manager,
TumblerRegistry *registry) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+void tumbler_manager_load (TumblerManager *manager);
+
+gboolean tumbler_manager_is_exported (TumblerManager *manager);
G_END_DECLS;
diff --git a/tumblerd/tumbler-service.h b/tumblerd/tumbler-service.h
index d2610cb..63f95dc 100644
--- a/tumblerd/tumbler-service.h
+++ b/tumblerd/tumbler-service.h
@@ -22,8 +22,6 @@
#ifndef __TUMBLER_SERVICE_H__
#define __TUMBLER_SERVICE_H__
-#include <dbus/dbus-glib.h>
-
#include <tumblerd/tumbler-lifecycle-manager.h>
#include <tumblerd/tumbler-registry.h>
diff --git a/tumblerd/tumbler-specialized-thumbnailer.c b/tumblerd/tumbler-specialized-thumbnailer.c
index 955a021..49cd0fd 100644
--- a/tumblerd/tumbler-specialized-thumbnailer.c
+++ b/tumblerd/tumbler-specialized-thumbnailer.c
@@ -66,9 +66,10 @@ static void tumbler_specialized_thumbnailer_set_property (GObject
static void tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer,
GCancellable *cancellable,
TumblerFileInfo *info);
-static void tumbler_specialized_thumbnailer_proxy_destroyed (DBusGProxy *proxy,
- TumblerSpecializedThumbnailer *thumbnailer);
+static void tumbler_specialized_thumbnailer_proxy_name_owner_changed (GDBusProxy *proxy,
+ GParamSpec *spec,
+ TumblerSpecializedThumbnailer *thumbnailer);
struct _TumblerSpecializedThumbnailerClass
@@ -80,8 +81,8 @@ struct _TumblerSpecializedThumbnailer
{
TumblerAbstractThumbnailer __parent__;
- DBusGConnection *connection;
- DBusGProxy *proxy;
+ GDBusConnection *connection;
+ GDBusProxy *proxy;
gboolean foreign;
guint64 modified;
@@ -146,18 +147,19 @@ tumbler_specialized_thumbnailer_class_init (TumblerSpecializedThumbnailerClass *
g_object_class_install_property (gobject_class,
PROP_CONNECTION,
- g_param_spec_pointer ("connection",
- "connection",
- "connection",
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE));
+ g_param_spec_object ("connection",
+ "connection",
+ "connection",
+ G_TYPE_DBUS_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PROXY,
g_param_spec_object ("proxy",
"proxy",
"proxy",
- DBUS_TYPE_G_PROXY,
+ G_TYPE_DBUS_PROXY,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
@@ -177,26 +179,6 @@ tumbler_specialized_thumbnailer_class_init (TumblerSpecializedThumbnailerClass *
0, G_MAXUINT64, 0,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE));
-
- dbus_g_object_register_marshaller (tumbler_marshal_VOID__UINT_STRING,
- G_TYPE_NONE,
- G_TYPE_UINT,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE,
- G_TYPE_UINT,
- G_TYPE_INVALID);
-
- dbus_g_object_register_marshaller (tumbler_marshal_VOID__UINT_STRING_INT_STRING,
- G_TYPE_NONE,
- G_TYPE_UINT,
- G_TYPE_STRING,
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
}
@@ -226,29 +208,20 @@ tumbler_specialized_thumbnailer_constructed (GObject *object)
/* chain up to parent classes */
if (G_OBJECT_CLASS (tumbler_specialized_thumbnailer_parent_class)->constructed != NULL)
(G_OBJECT_CLASS (tumbler_specialized_thumbnailer_parent_class)->constructed) (object);
-
+
thumbnailer->proxy =
- dbus_g_proxy_new_for_name (thumbnailer->connection,
- thumbnailer->name,
- thumbnailer->object_path,
- "org.freedesktop.thumbnails.SpecializedThumbnailer1");
-
- dbus_g_proxy_add_signal (thumbnailer->proxy, "Ready",
- G_TYPE_UINT, G_TYPE_STRING,
- G_TYPE_INVALID);
-
- dbus_g_proxy_add_signal (thumbnailer->proxy, "Error",
- G_TYPE_UINT, G_TYPE_STRING,
- G_TYPE_INT, G_TYPE_STRING,
- G_TYPE_INVALID);
-
- dbus_g_proxy_add_signal (thumbnailer->proxy, "Finished",
- G_TYPE_UINT,
- G_TYPE_INVALID);
-
+ g_dbus_proxy_new_sync (thumbnailer->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ thumbnailer->name,
+ thumbnailer->object_path,
+ "org.freedesktop.thumbnails.SpecializedThumbnailer1",
+ NULL,
+ NULL);
+
if (thumbnailer->foreign) {
- g_signal_connect (thumbnailer->proxy, "destroy",
- G_CALLBACK (tumbler_specialized_thumbnailer_proxy_destroyed),
+ g_signal_connect (thumbnailer->proxy, "notify::g-name-owner",
+ G_CALLBACK (tumbler_specialized_thumbnailer_proxy_name_owner_changed),
thumbnailer);
}
}
@@ -268,8 +241,8 @@ tumbler_specialized_thumbnailer_finalize (GObject *object)
g_object_unref (thumbnailer->proxy);
- dbus_g_connection_unref (thumbnailer->connection);
-
+ g_object_unref (thumbnailer->connection);
+
(*G_OBJECT_CLASS (tumbler_specialized_thumbnailer_parent_class)->finalize) (object);
}
@@ -286,7 +259,7 @@ tumbler_specialized_thumbnailer_get_property (GObject *object,
switch (prop_id)
{
case PROP_CONNECTION:
- g_value_set_pointer (value, dbus_g_connection_ref (thumbnailer->connection));
+ g_value_set_object (value, g_object_ref (thumbnailer->connection));
break;
case PROP_NAME:
g_value_set_string (value, thumbnailer->name);
@@ -322,7 +295,7 @@ tumbler_specialized_thumbnailer_set_property (GObject *object,
switch (prop_id)
{
case PROP_CONNECTION:
- thumbnailer->connection = dbus_g_connection_ref (g_value_get_pointer (value));
+ thumbnailer->connection = g_object_ref (g_value_get_object (value));
break;
case PROP_NAME:
thumbnailer->name = g_value_dup_string (value);
@@ -344,56 +317,65 @@ tumbler_specialized_thumbnailer_set_property (GObject *object,
-static void
-specialized_error (DBusGProxy *proxy,
- guint handle,
- gchar *uri,
- gint error_code,
- gchar *error_msg,
- gpointer user_data)
-{
- SpecializedInfo *info = user_data;
-
- if (info->handle == handle)
- g_signal_emit_by_name (info->thumbnailer, "error", uri, error_code, error_msg);
-}
-
-
-
-static void
-specialized_ready (DBusGProxy *proxy,
- guint handle,
- gchar *uri,
- gpointer user_data)
-{
- SpecializedInfo *info = user_data;
-
- if (info->handle == handle)
- g_signal_emit_by_name (info->thumbnailer, "ready", uri);
-}
-
-
-static void
-specialized_finished (DBusGProxy *proxy,
- guint handle,
- gpointer user_data)
+static void
+thumbnailer_proxy_g_signal_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
{
- SpecializedInfo *info = user_data;
-
- if (info->handle == handle)
+ SpecializedInfo *info = user_data;
+ guint handle;
+
+ if (strcmp (signal_name, "Finished") == 0)
{
- tumbler_mutex_lock (info->mutex);
+ if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(u)")))
+ {
+ g_variant_get (parameters, "(&u)", &handle);
+ if (info->handle == handle)
+ {
+ tumbler_mutex_lock (info->mutex);
#if GLIB_CHECK_VERSION (2, 32, 0)
- g_cond_broadcast (&info->condition);
+ g_cond_broadcast (&info->condition);
#else
- g_cond_broadcast (info->condition);
+ g_cond_broadcast (info->condition);
#endif
- info->had_callback = TRUE;
- tumbler_mutex_unlock (info->mutex);
+ info->had_callback = TRUE;
+ tumbler_mutex_unlock (info->mutex);
+ }
+ }
+ }
+ else if (strcmp (signal_name, "Ready") == 0)
+ {
+ if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(us)")))
+ {
+ const gchar *uri;
+ g_variant_get (parameters, "(us)", &handle, &uri);
+ if (info->handle == handle)
+ {
+ g_signal_emit_by_name (info->thumbnailer, "ready", uri);
+ }
+ }
+ }
+ else if (strcmp (signal_name, "Error") == 0)
+ {
+ if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(usis")))
+ {
+ const gchar *uri, *error_msg;
+ gint error_code;
+
+ g_variant_get (parameters, "(&usis)", &handle, &uri, &error_code, &error_msg);
+ if (info->handle == handle)
+ {
+ g_signal_emit_by_name (info->thumbnailer, "error", uri, error_code, error_msg);
+ }
+ }
}
}
+
+
static void
tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer,
GCancellable *cancellable,
@@ -408,11 +390,13 @@ tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer,
#endif
TumblerThumbnail *thumbnail;
TumblerThumbnailFlavor *flavor;
+ GVariant *result;
const gchar *flavor_name;
const gchar *uri;
GError *error = NULL;
gchar *message;
-
+ int handler_id;
+
g_return_if_fail (TUMBLER_IS_SPECIALIZED_THUMBNAILER (thumbnailer));
uri = tumbler_file_info_get_uri (info);
@@ -433,36 +417,29 @@ tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer,
sinfo.mime_type = tumbler_file_info_get_mime_type (info);
sinfo.thumbnailer = thumbnailer;
- dbus_g_proxy_connect_signal (s->proxy, "Finished",
- G_CALLBACK (specialized_finished),
- &sinfo,
- NULL);
-
- dbus_g_proxy_connect_signal (s->proxy, "Ready",
- G_CALLBACK (specialized_ready),
- &sinfo,
- NULL);
-
- dbus_g_proxy_connect_signal (s->proxy, "Error",
- G_CALLBACK (specialized_error),
- &sinfo,
- NULL);
-
- dbus_g_proxy_call_with_timeout (s->proxy, "Queue",
- 100000000, /* 100 seconds worth of timeout */
- &error,
- G_TYPE_STRING, uri,
- G_TYPE_STRING, sinfo.mime_type,
- G_TYPE_STRING, flavor_name,
- /* TODO: Get this bool from scheduler type */
- G_TYPE_BOOLEAN, FALSE,
- G_TYPE_INVALID,
- G_TYPE_UINT, &sinfo.handle,
- G_TYPE_INVALID);
+ handler_id = g_signal_connect (s->proxy, "g-signal",
+ G_CALLBACK(thumbnailer_proxy_g_signal_cb), &info);
+
+ result = g_dbus_proxy_call_sync (s->proxy,
+ "Queue",
+ g_variant_new("(sssb)",
+ uri,
+ sinfo.mime_type,
+ flavor_name,
+ /* TODO: Get this bool from scheduler type */
+ FALSE),
+ G_DBUS_CALL_FLAGS_NONE,
+ 100000000, /* 100 seconds worth of timeout */
+ NULL,
+ &error);
if (error == NULL)
{
- /* 100 seconds worth of timeout */
+ /*Get the return handle */
+ g_variant_get (result, "(u)", &sinfo.handle);
+ g_variant_unref (result);
+
+ /* 100 seconds worth of timeout */
#if GLIB_CHECK_VERSION (2, 32, 0)
end_time = g_get_monotonic_time () + 100 * G_TIME_SPAN_SECOND;
#else
@@ -497,18 +474,8 @@ tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer,
g_free (message);
g_clear_error (&error);
}
-
- dbus_g_proxy_disconnect_signal (s->proxy, "Finished",
- G_CALLBACK (specialized_finished),
- &sinfo);
-
- dbus_g_proxy_disconnect_signal (s->proxy, "Ready",
- G_CALLBACK (specialized_ready),
- &sinfo);
-
- dbus_g_proxy_disconnect_signal (s->proxy, "Error",
- G_CALLBACK (specialized_error),
- &sinfo);
+
+ g_signal_handler_disconnect (s->proxy, handler_id);
#if GLIB_CHECK_VERSION (2, 32, 0)
g_cond_clear (&sinfo.condition);
@@ -518,19 +485,26 @@ tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer,
}
static void
-tumbler_specialized_thumbnailer_proxy_destroyed (DBusGProxy *proxy,
- TumblerSpecializedThumbnailer *thumbnailer)
+tumbler_specialized_thumbnailer_proxy_name_owner_changed (GDBusProxy *proxy,
+ GParamSpec *spec,
+ TumblerSpecializedThumbnailer *thumbnailer)
{
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
+ gchar *name_owner;
+ g_return_if_fail (G_IS_DBUS_PROXY (proxy));
g_return_if_fail (TUMBLER_IS_SPECIALIZED_THUMBNAILER (thumbnailer));
-
- g_signal_emit_by_name (thumbnailer, "unregister");
+
+ name_owner = g_dbus_proxy_get_name_owner (proxy);
+ if (name_owner == NULL)
+ {
+ g_signal_emit_by_name (thumbnailer, "unregister");
+ }
+ g_free(name_owner);
}
TumblerThumbnailer *
-tumbler_specialized_thumbnailer_new (DBusGConnection *connection,
+tumbler_specialized_thumbnailer_new (GDBusConnection *connection,
const gchar *name,
const gchar *object_path,
const gchar *const *uri_schemes,
@@ -557,7 +531,7 @@ tumbler_specialized_thumbnailer_new (DBusGConnection *connection,
TumblerThumbnailer *
-tumbler_specialized_thumbnailer_new_foreign (DBusGConnection *connection,
+tumbler_specialized_thumbnailer_new_foreign (GDBusConnection *connection,
const gchar *name,
const gchar *const *uri_schemes,
const gchar *const *mime_types)
diff --git a/tumblerd/tumbler-specialized-thumbnailer.h b/tumblerd/tumbler-specialized-thumbnailer.h
index 97c922f..61d2751 100644
--- a/tumblerd/tumbler-specialized-thumbnailer.h
+++ b/tumblerd/tumbler-specialized-thumbnailer.h
@@ -21,8 +21,6 @@
#ifndef __TUMBLER_SPECIALIZED_THUMBNAILER_H__
#define __TUMBLER_SPECIALIZED_THUMBNAILER_H__
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <tumbler/tumbler.h>
G_BEGIN_DECLS
@@ -39,13 +37,13 @@ typedef struct _TumblerSpecializedThumbnailer TumblerSpecializedThumbnailer
GType tumbler_specialized_thumbnailer_get_type (void) G_GNUC_CONST;
-TumblerThumbnailer *tumbler_specialized_thumbnailer_new (DBusGConnection *connection,
+TumblerThumbnailer *tumbler_specialized_thumbnailer_new (GDBusConnection *connection,
const gchar *name,
const gchar *object_path,
const gchar *const *uri_schemes,
const gchar *const *mime_types,
guint64 modified) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-TumblerThumbnailer *tumbler_specialized_thumbnailer_new_foreign (DBusGConnection *connection,
+TumblerThumbnailer *tumbler_specialized_thumbnailer_new_foreign (GDBusConnection *connection,
const gchar *name,
const gchar *const *uri_scheme,
const gchar *const *mime_type) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
diff --git a/tumblerd/tumbler-utils.h b/tumblerd/tumbler-utils.h
index 3049afd..584e845 100644
--- a/tumblerd/tumbler-utils.h
+++ b/tumblerd/tumbler-utils.h
@@ -21,33 +21,17 @@
#ifndef __TUMBLER_UTILS_H__
#define __TUMBLER_UTILS_H__
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
-#define dbus_async_return_if_fail(expr, context) \
- G_STMT_START{ \
- if (G_UNLIKELY (!(expr))) \
- { \
- GError *dbus_async_return_if_fail_error = NULL; \
- \
- g_set_error (&dbus_async_return_if_fail_error, DBUS_GERROR, DBUS_GERROR_FAILED, \
- "Assertion \"%s\" failed", #expr); \
- dbus_g_method_return_error (context, dbus_async_return_if_fail_error); \
- g_clear_error (&dbus_async_return_if_fail_error); \
- \
- return; \
- } \
- }G_STMT_END
-
#define g_dbus_async_return_if_fail(expr, invocation) \
G_STMT_START{ \
if (G_UNLIKELY (!(expr))) \
{ \
GError *dbus_async_return_if_fail_error = NULL; \
\
- g_set_error (&dbus_async_return_if_fail_error, DBUS_GERROR, DBUS_GERROR_FAILED, \
+ g_set_error (&dbus_async_return_if_fail_error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, \
"Assertion \"%s\" failed", #expr); \
g_dbus_method_invocation_return_gerror (invocation, dbus_async_return_if_fail_error);\
g_clear_error (&dbus_async_return_if_fail_error); \
@@ -62,7 +46,7 @@ G_BEGIN_DECLS
{ \
GError *dbus_async_return_if_fail_error = NULL; \
\
- g_set_error (&dbus_async_return_if_fail_error, DBUS_GERROR, DBUS_GERROR_FAILED, \
+ g_set_error (&dbus_async_return_if_fail_error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, \
"Assertion \"%s\" failed", #expr); \
g_dbus_method_invocation_return_gerror (invocation, dbus_async_return_if_fail_error);\
g_clear_error (&dbus_async_return_if_fail_error); \
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list