[Xfce4-commits] [xfce/tumbler] 03/11: Port the caching service to gbus.

noreply at xfce.org noreply at xfce.org
Mon May 15 13:20:31 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 59984d6e3b6ac3f8108a660afb56c38b060cabbc
Author: Ali Abdallah <aliovx at gmail.com>
Date:   Sat Oct 10 16:41:43 2015 +0200

    Port the caching service to gbus.
---
 tumblerd/Makefile.am                    |  17 +-
 tumblerd/main.c                         |  77 ++++-----
 tumblerd/tumbler-cache-service-dbus.xml |   7 +-
 tumblerd/tumbler-cache-service.c        | 280 ++++++++++++++++++--------------
 tumblerd/tumbler-cache-service.h        |  20 +--
 5 files changed, 208 insertions(+), 193 deletions(-)

diff --git a/tumblerd/Makefile.am b/tumblerd/Makefile.am
index 7ce05ab..0187bcb 100644
--- a/tumblerd/Makefile.am
+++ b/tumblerd/Makefile.am
@@ -24,11 +24,12 @@ tumblerd_PROGRAMS =							\
 	tumblerd
 
 tumblerd_built_sources =						\
-	tumbler-cache-service-dbus-bindings.h				\
 	tumbler-manager-gdbus.c					        \
 	tumbler-manager-gdbus.h                                         \
 	tumbler-service-gdbus.c					        \
-	tumbler-service-gdbus.h
+	tumbler-service-gdbus.h                                         \
+	tumbler-cache-service-gdbus.h                                   \
+	tumbler-cache-service-gdbus.c
 
 
 tumblerd_SOURCES =							\
@@ -82,7 +83,7 @@ tumblerd_LDADD =							\
 	$(DBUS_GLIB_LIBS)						\
 	$(GDK_PIXBUF_LIBS)						\
 	$(GIO_LIBS)							\
-	$(GIO_UNIX_LIBS)							\
+	$(GIO_UNIX_LIBS)                                                \
 	$(GLIB_LIBS)							\
 	$(GTHREAD_LIBS)							\
 	$(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la
@@ -119,9 +120,6 @@ DISTCLEANFILES =							\
 BUILT_SOURCES =								\
 	$(tumblerd_built_sources)
 
-tumbler-cache-service-dbus-bindings.h: tumbler-cache-service-dbus.xml Makefile
-	$(AM_V_GEN) $(DBUS_BINDING_TOOL) --mode=glib-server --prefix=tumbler_cache_service $< > $@
-
 tumbler-manager-gdbus.h:
 tumbler-manager-gdbus.c: tumbler-manager-dbus.xml Makefile
 	$(AM_V_GEN) $(GDBUS_CODEGEN) \
@@ -138,3 +136,10 @@ tumbler-service-gdbus.c: tumbler-service-dbus.xml Makefile
 	--generate-c-code tumbler-service-gdbus \
 	$(srcdir)/tumbler-service-dbus.xml
 
+tumbler-cache-service-gdbus.h:
+tumbler-cache-service-gdbus.c: tumbler-cache-service-dbus.xml Makefile
+	$(AM_V_GEN) $(GDBUS_CODEGEN) \
+	--interface-prefix org.freedesktop.thumbnails.Cache1 \
+	--c-namespace Tumbler 	\
+	--generate-c-code tumbler-cache-service-gdbus \
+	$(srcdir)/tumbler-cache-service-dbus.xml
\ No newline at end of file
diff --git a/tumblerd/main.c b/tumblerd/main.c
index 54ffe79..0c35161 100644
--- a/tumblerd/main.c
+++ b/tumblerd/main.c
@@ -39,8 +39,6 @@
 #include <glib/gi18n.h>
 #include <glib-object.h>
 
-#include <dbus/dbus-glib.h>
-
 #include <tumbler/tumbler.h>
 
 #include <tumblerd/tumbler-cache-service.h>
@@ -233,8 +231,7 @@ main (int    argc,
 {
   TumblerLifecycleManager *lifecycle_manager;
   TumblerProviderFactory  *provider_factory;
-  GDBusConnection         *gconnection;
-  DBusGConnection         *connection;
+  GDBusConnection         *connection;
   TumblerRegistry         *registry;
   TumblerManager          *manager;
   TumblerService          *service;
@@ -280,22 +277,8 @@ main (int    argc,
     g_thread_init (NULL);
 #endif
 
-  /* initial the D-Bus threading system */
-  dbus_g_thread_init ();
-
-  /* try to connect to the D-Bus session bus */
-  connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
-  /* print an error and exit if the connection could not be established */
-  if (connection == NULL)
-    {
-      g_warning (_("Failed to connect to the D-Bus session bus: %s"), error->message);
-      g_error_free (error);
 
-      return EXIT_FAILURE;
-    }
-
-  gconnection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+  connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
   
   if (error != NULL)
     {
@@ -374,10 +357,10 @@ main (int    argc,
   cache_service = tumbler_cache_service_new (connection, lifecycle_manager);
 
   /* create the thumbnailer manager service */
-  manager = tumbler_manager_new (gconnection, lifecycle_manager, registry);
+  manager = tumbler_manager_new (connection, lifecycle_manager, registry);
 
   /* create the generic thumbnailer service */
-  service = tumbler_service_new (gconnection, lifecycle_manager, registry);
+  service = tumbler_service_new (connection, lifecycle_manager, registry);
 
   /* try to load specialized thumbnailers and exit if that fails */
   if (!tumbler_registry_load (registry, &error))
@@ -391,18 +374,18 @@ main (int    argc,
       goto exit_tumbler;
     }
 
-  /* try to start the service and exit if that fails */
-  if (!tumbler_cache_service_start (cache_service, &error))
-    {
-      g_warning (_("Failed to start the thumbnail cache service: %s"), error->message);
-      g_error_free (error);
-
-      /* service already running, exit gracefully to not break clients */
-      goto exit_tumbler;
-    }
   
+  /* Acquire the cache service dbus name */
+  g_bus_own_name_on_connection (connection,
+				                        "org.freedesktop.thumbnails.Cache1",
+				                        G_BUS_NAME_OWNER_FLAGS_REPLACE,
+				                        NULL, /* We dont need to do anything on name acquired*/
+				                        on_dbus_name_lost,
+				                        main_loop,
+				                        NULL);
+	
   /* Acquire the manager dbus name */
-  g_bus_own_name_on_connection (gconnection,
+  g_bus_own_name_on_connection (connection,
 				                        "org.freedesktop.thumbnails.Manager1",
 				                        G_BUS_NAME_OWNER_FLAGS_REPLACE,
 				                        NULL, /* We dont need to do anything on name acquired*/
@@ -411,7 +394,7 @@ main (int    argc,
 				                        NULL);
 	
   /* Acquire the thumbnailer service dbus name */
-  g_bus_own_name_on_connection (gconnection,
+  g_bus_own_name_on_connection (connection,
 				                        "org.freedesktop.thumbnails.Thumbnailer1",
 				                        G_BUS_NAME_OWNER_FLAGS_REPLACE,
 				                        NULL, /* We dont need to do anything on name acquired*/
@@ -419,19 +402,26 @@ main (int    argc,
 				                        main_loop,
 				                        NULL);
   
-  /* create a new main loop */
-  main_loop = g_main_loop_new (NULL, FALSE);
+  /* check to see if all services are successfully exported on the bus */
+  if (tumbler_manager_is_exported(manager) &&
+      tumbler_service_is_exported(service) &&
+      tumbler_cache_service_is_exported(cache_service))
+    {
 
-  /* 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);
+      /* create a new main loop */
+      main_loop = g_main_loop_new (NULL, FALSE);
 
-  /* start the lifecycle manager */
-  tumbler_lifecycle_manager_start (lifecycle_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);
 
-  /* enter the main loop, thereby making the tumbler service available */
-  g_main_loop_run (main_loop);
+      /* start the lifecycle manager */
+      tumbler_lifecycle_manager_start (lifecycle_manager);
 
+      /* enter the main loop, thereby making the tumbler service available */
+      g_main_loop_run (main_loop);
+    }
+  
   exit_tumbler:
 
   /* shut our services down and release all objects */
@@ -441,11 +431,8 @@ main (int    argc,
   g_object_unref (registry);
   g_object_unref (lifecycle_manager);
 
-  /* disconnect from the D-Bus session bus */
-  dbus_g_connection_unref (connection);
-
   /* free the dbus session bus connection */
-  g_object_unref (gconnection);
+  g_object_unref (connection);
 
   /* we're done, all fine */
   return retval;
diff --git a/tumblerd/tumbler-cache-service-dbus.xml b/tumblerd/tumbler-cache-service-dbus.xml
index 92ffa42..f297f38 100644
--- a/tumblerd/tumbler-cache-service-dbus.xml
+++ b/tumblerd/tumbler-cache-service-dbus.xml
@@ -1,25 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <node name="/org/freedesktop/thumbnails/Cache1">
+    
   <interface name="org.freedesktop.thumbnails.Cache1">
+   	<annotation name="org.gtk.GDBus.C.Name" value="ExportedCacheService" />
     <method name="Move">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="as" name="from_uris" direction="in" />
       <arg type="as" name="to_uris" direction="in" />
     </method>
 
     <method name="Copy">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="as" name="from_uris" direction="in" />
       <arg type="as" name="to_uris" direction="in" />
     </method>
 
     <method name="Delete">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+
       <arg type="as" name="uris" direction="in" />
     </method>
 
     <method name="Cleanup">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="as" name="base_uris" direction="in" />
       <arg type="u" name="since" direction="in" />
     </method>
diff --git a/tumblerd/tumbler-cache-service.c b/tumblerd/tumbler-cache-service.c
index ab00645..b9ac2de 100644
--- a/tumblerd/tumbler-cache-service.c
+++ b/tumblerd/tumbler-cache-service.c
@@ -25,19 +25,18 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib-object.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include <tumbler/tumbler.h>
 
 #include <tumblerd/tumbler-component.h>
 #include <tumblerd/tumbler-cache-service.h>
-#include <tumblerd/tumbler-cache-service-dbus-bindings.h>
+#include <tumblerd/tumbler-cache-service-gdbus.h>
 #include <tumblerd/tumbler-utils.h>
 
-
+#define THUMBNAILER_CACHE_PATH    "/org/freedesktop/thumbnails/Cache1"
+#define THUMBNAILER_CACHE_SERVICE "org.freedesktop.thumbnails.Cache1"
+#define THUMBNAILER_CACHE_IFACE   "org.freedesktop.thumbnails.Cache1"
 
 typedef struct _MoveRequest    MoveRequest;
 typedef struct _CopyRequest    CopyRequest;
@@ -76,6 +75,28 @@ static void tumbler_cache_service_cleanup_thread (gpointer      data,
 
 
 
+static gboolean tumbler_cache_service_cleanup (TumblerExportedCacheService   *skeleton,
+                                               GDBusMethodInvocation         *invocation,
+                                               const gchar *const            *base_uris,
+                                               guint32                       since,
+                                               TumblerCacheService           *service);
+static gboolean tumbler_cache_service_delete  (TumblerExportedCacheService   *skeleton,
+                                               GDBusMethodInvocation         *invocation,
+                                               const gchar *const            *uris,
+                                               TumblerCacheService           *service);
+
+static gboolean tumbler_cache_service_copy    (TumblerExportedCacheService   *skeleton,
+                                               GDBusMethodInvocation         *invocation,
+                                               const gchar *const            *from_uris,
+                                               const gchar *const            *to_uris,
+                                               TumblerCacheService           *service);
+
+static gboolean tumbler_cache_service_move    (TumblerExportedCacheService   *skeleton,
+                                               GDBusMethodInvocation         *invocation,
+                                               const gchar *const            *from_uris,
+                                               const gchar *const            *to_uris,
+                                               TumblerCacheService           *service);
+
 struct _TumblerCacheServiceClass
 {
   TumblerComponentClass __parent__;
@@ -83,45 +104,51 @@ struct _TumblerCacheServiceClass
 
 struct _TumblerCacheService
 {
-  TumblerComponent __parent__;
-
-  DBusGConnection *connection;
+  TumblerComponent            __parent__;
 
-  TumblerCache    *cache;
+  GDBusConnection             *connection;
+  TumblerExportedCacheService *skeleton;
+  gboolean                     dbus_interface_exported;
+ 
+  TumblerCache                *cache;
 
-  GThreadPool     *move_pool;
-  GThreadPool     *copy_pool;
-  GThreadPool     *delete_pool;
-  GThreadPool     *cleanup_pool;
+  GThreadPool                 *move_pool;
+  GThreadPool                 *copy_pool;
+  GThreadPool                 *delete_pool;
+  GThreadPool                 *cleanup_pool;
 
-  TUMBLER_MUTEX    (mutex);
+  TUMBLER_MUTEX               (mutex);
 };
 
 struct _MoveRequest
 {
-  gchar                 **from_uris;
-  gchar                 **to_uris;
-  DBusGMethodInvocation  *context;
+  TumblerExportedCacheService  *skeleton;
+  gchar                       **from_uris;
+  gchar                       **to_uris;
+  GDBusMethodInvocation        *invocation;
 };
 
 struct _CopyRequest
 {
-  gchar                 **from_uris;
-  gchar                 **to_uris;
-  DBusGMethodInvocation  *context;
+  TumblerExportedCacheService  *skeleton;
+  gchar                       **from_uris;
+  gchar                       **to_uris;
+  GDBusMethodInvocation        *invocation;
 };
 
 struct _DeleteRequest
 {
-  gchar                 **uris;
-  DBusGMethodInvocation  *context;
+  TumblerExportedCacheService  *skeleton;
+  gchar                       **uris;
+  GDBusMethodInvocation        *invocation;
 };
 
 struct _CleanupRequest
 {
-  guint32                 since;
-  gchar                 **base_uris;
-  DBusGMethodInvocation  *context;
+  TumblerExportedCacheService  *skeleton;
+  guint32                       since;
+  gchar                       **base_uris;
+  GDBusMethodInvocation        *invocation;  
 };
 
 
@@ -142,9 +169,10 @@ tumbler_cache_service_class_init (TumblerCacheServiceClass *klass)
   gobject_class->set_property = tumbler_cache_service_set_property;
 
   g_object_class_install_property (gobject_class, PROP_CONNECTION,
-                                   g_param_spec_pointer ("connection",
+                                   g_param_spec_object ("connection",
                                                          "connection",
                                                          "connection",
+                                                         G_TYPE_DBUS_CONNECTION,
                                                          G_PARAM_READWRITE |
                                                          G_PARAM_CONSTRUCT_ONLY));
 }
@@ -163,6 +191,7 @@ static void
 tumbler_cache_service_constructed (GObject *object)
 {
   TumblerCacheService *service = TUMBLER_CACHE_SERVICE (object);
+  GError *error = NULL;
 
   /* chain up to parent classes */
   if (G_OBJECT_CLASS (tumbler_cache_service_parent_class)->constructed != NULL)
@@ -178,15 +207,36 @@ tumbler_cache_service_constructed (GObject *object)
                                             service, 1, FALSE, NULL);
   service->cleanup_pool = g_thread_pool_new (tumbler_cache_service_cleanup_thread, 
                                              service, 1, FALSE, NULL);
-
+  
+  service->skeleton = tumbler_exported_cache_service_skeleton_new();
+  
   /* everything's fine, install the cache type D-Bus info */
-  dbus_g_object_type_install_info (G_OBJECT_TYPE (service),
-                                   &dbus_glib_tumbler_cache_service_object_info);
-
-  /* register the cache instance as a handler of the cache interface */
-  dbus_g_connection_register_g_object (service->connection, 
-                                       "/org/freedesktop/thumbnails/Cache1",
-                                       G_OBJECT (service));
+  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON(service->skeleton),
+                                    service->connection,
+                                    THUMBNAILER_CACHE_PATH,
+                                    &error);
+  if (error != NULL)
+    {
+      g_critical ("error exporting thumbnail cache service on session bus: %s", error->message);
+      g_error_free (error);
+      service->dbus_interface_exported = FALSE; 
+    }
+  else
+    {
+      service->dbus_interface_exported = TRUE;
+      
+      g_signal_connect (service->skeleton, "handle-move",
+                        G_CALLBACK(tumbler_cache_service_move), service);
+      
+      g_signal_connect (service->skeleton, "handle-copy",
+                        G_CALLBACK(tumbler_cache_service_copy), service);
+      
+      g_signal_connect (service->skeleton, "handle-delete",
+                        G_CALLBACK(tumbler_cache_service_delete), service);
+      
+      g_signal_connect (service->skeleton, "handle-cleanup",
+                        G_CALLBACK(tumbler_cache_service_cleanup), service);
+    }
 }
 
 
@@ -204,7 +254,18 @@ tumbler_cache_service_finalize (GObject *object)
   if (service->cache != NULL)
     g_object_unref (service->cache);
 
-  dbus_g_connection_unref (service->connection);
+  /* Unexport from dbus */
+  if (service->dbus_interface_exported)
+    g_dbus_interface_skeleton_unexport_from_connection 
+      (
+        G_DBUS_INTERFACE_SKELETON (service->skeleton),
+        service->connection
+      );
+
+  /* release the Skeleton object */
+  g_object_unref (service->skeleton);
+
+  g_object_unref (service->connection);
 
   tumbler_mutex_free (service->mutex);
 
@@ -224,7 +285,7 @@ tumbler_cache_service_get_property (GObject    *object,
   switch (prop_id)
     {
     case PROP_CONNECTION:
-      g_value_set_pointer (value, service->connection);
+      g_value_set_object (value, service->connection);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -245,7 +306,7 @@ tumbler_cache_service_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_CONNECTION:
-      service->connection = dbus_g_connection_ref (g_value_get_pointer (value));
+      service->connection = g_object_ref (g_value_get_object (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -274,7 +335,7 @@ tumbler_cache_service_move_thread (gpointer data,
                           (const gchar *const *)request->to_uris);
     }
 
-  dbus_g_method_return (request->context);
+  tumbler_exported_cache_service_complete_move (request->skeleton, request->invocation);
 
   g_strfreev (request->from_uris);
   g_strfreev (request->to_uris);
@@ -308,7 +369,7 @@ tumbler_cache_service_copy_thread (gpointer data,
                           (const gchar *const *)request->to_uris);
     }
 
-  dbus_g_method_return (request->context);
+  tumbler_exported_cache_service_complete_copy (request->skeleton, request->invocation);
 
   g_strfreev (request->from_uris);
   g_strfreev (request->to_uris);
@@ -338,7 +399,7 @@ tumbler_cache_service_delete_thread (gpointer data,
   if (service->cache != NULL)
     tumbler_cache_delete (service->cache, (const gchar *const *)request->uris);
 
-  dbus_g_method_return (request->context);
+  tumbler_exported_cache_service_complete_delete (request->skeleton, request->invocation);
 
   g_strfreev (request->uris);
   g_slice_free (DeleteRequest, request);
@@ -371,7 +432,7 @@ tumbler_cache_service_cleanup_thread (gpointer data,
                              request->since);
     }
 
-  dbus_g_method_return (request->context);
+  tumbler_exported_cache_service_complete_cleanup (request->skeleton, request->invocation);
 
   g_strfreev (request->base_uris);
   g_slice_free (CleanupRequest, request);
@@ -386,7 +447,7 @@ tumbler_cache_service_cleanup_thread (gpointer data,
 
 
 TumblerCacheService *
-tumbler_cache_service_new (DBusGConnection         *connection,
+tumbler_cache_service_new (GDBusConnection         *connection,
                            TumblerLifecycleManager *lifecycle_manager)
 {
   return g_object_new (TUMBLER_TYPE_CACHE_SERVICE, 
@@ -397,58 +458,20 @@ tumbler_cache_service_new (DBusGConnection         *connection,
 
 
 
-gboolean
-tumbler_cache_service_start (TumblerCacheService *service,
-                             GError             **error)
-{
-  DBusConnection *connection;
-  gint            result;
-
-  g_return_val_if_fail (TUMBLER_IS_CACHE_SERVICE (service), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  tumbler_mutex_lock (service->mutex);
-
-  /* get the native D-Bus connection */
-  connection = dbus_g_connection_get_connection (service->connection);
-
-  /* request ownership for the cache interface */
-  result = dbus_bus_request_name (connection, "org.freedesktop.thumbnails.Cache1", 
-                                  DBUS_NAME_FLAG_DO_NOT_QUEUE, NULL);
-
-  /* check if that failed */
-  if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
-    {
-      if (error != NULL)
-        {
-          g_set_error (error, DBUS_GERROR, DBUS_GERROR_FAILED,
-                       _("Another thumbnail cache service is already running"));
-        }
-
-      tumbler_mutex_unlock (service->mutex);
-
-      return FALSE;
-    }
-  
-  tumbler_mutex_unlock (service->mutex);
-
-  return TRUE;
-}
-
-
 
-void
-tumbler_cache_service_move (TumblerCacheService   *service,
-                            const gchar *const    *from_uris,
-                            const gchar *const    *to_uris,
-                            DBusGMethodInvocation *context)
+gboolean
+tumbler_cache_service_move (TumblerExportedCacheService   *skeleton,
+                            GDBusMethodInvocation         *invocation,
+                            const gchar *const            *from_uris,
+                            const gchar *const            *to_uris,
+                            TumblerCacheService           *service)
 {
   MoveRequest *request;
 
-  dbus_async_return_if_fail (TUMBLER_IS_CACHE_SERVICE (service), context);
-  dbus_async_return_if_fail (from_uris != NULL, context);
-  dbus_async_return_if_fail (to_uris != NULL, context);
-  dbus_async_return_if_fail (g_strv_length ((gchar **)from_uris) == g_strv_length ((gchar **)to_uris), context);
+  g_dbus_async_return_val_if_fail (TUMBLER_IS_CACHE_SERVICE (service), invocation, FALSE);
+  g_dbus_async_return_val_if_fail (from_uris != NULL, invocation, FALSE);
+  g_dbus_async_return_val_if_fail (to_uris != NULL, invocation, FALSE);
+  g_dbus_async_return_val_if_fail (g_strv_length ((gchar **)from_uris) == g_strv_length ((gchar **)to_uris), invocation, FALSE);
 
   /* prevent the lifecycle manager to shut tumbler down before the
    * move request has been processed */
@@ -457,29 +480,32 @@ tumbler_cache_service_move (TumblerCacheService   *service,
   request = g_slice_new0 (MoveRequest);
   request->from_uris = g_strdupv ((gchar **)from_uris);
   request->to_uris = g_strdupv ((gchar **)to_uris);
-  request->context = context;
+  request->invocation = invocation;
 
   g_thread_pool_push (service->move_pool, request, NULL);
 
   /* try to keep tumbler alive */
   tumbler_component_keep_alive (TUMBLER_COMPONENT (service), NULL);
+  
+  return TRUE;
 }
 
 
 
-void
-tumbler_cache_service_copy (TumblerCacheService   *service,
-                            const gchar *const    *from_uris,
-                            const gchar *const    *to_uris,
-                            DBusGMethodInvocation *context)
+gboolean
+tumbler_cache_service_copy (TumblerExportedCacheService   *skeleton,
+                            GDBusMethodInvocation         *invocation,
+                            const gchar *const            *from_uris,
+                            const gchar *const            *to_uris,
+                            TumblerCacheService           *service)
 {
   CopyRequest *request;
-
-  dbus_async_return_if_fail (TUMBLER_IS_CACHE_SERVICE (service), context);
-  dbus_async_return_if_fail (from_uris != NULL, context);
-  dbus_async_return_if_fail (to_uris != NULL, context);
-  dbus_async_return_if_fail (g_strv_length ((gchar **)from_uris) == g_strv_length ((gchar **)to_uris), context);
-
+  
+  g_dbus_async_return_val_if_fail (TUMBLER_IS_CACHE_SERVICE (service), invocation, FALSE);
+  g_dbus_async_return_val_if_fail (from_uris != NULL, invocation, FALSE);
+  g_dbus_async_return_val_if_fail (to_uris != NULL, invocation, FALSE);
+  g_dbus_async_return_val_if_fail (g_strv_length ((gchar **)from_uris) == g_strv_length ((gchar **)to_uris), invocation, FALSE);
+  
   /* prevent the lifecycle manager to shut tumbler down before the
    * copy request has been processed */
   tumbler_component_increment_use_count (TUMBLER_COMPONENT (service));
@@ -487,25 +513,28 @@ tumbler_cache_service_copy (TumblerCacheService   *service,
   request = g_slice_new0 (CopyRequest);
   request->from_uris = g_strdupv ((gchar **)from_uris);
   request->to_uris = g_strdupv ((gchar **)to_uris);
-  request->context = context;
+  request->invocation = invocation;
 
   g_thread_pool_push (service->copy_pool, request, NULL);
 
   /* try to keep tumbler alive */
   tumbler_component_keep_alive (TUMBLER_COMPONENT (service), NULL);
+  
+  return TRUE;
 }
 
 
 
-void
-tumbler_cache_service_delete (TumblerCacheService   *service,
-                              const gchar *const    *uris,
-                              DBusGMethodInvocation *context)
+gboolean
+tumbler_cache_service_delete (TumblerExportedCacheService   *skeleton,
+                              GDBusMethodInvocation         *invocation,
+                              const gchar *const            *uris,
+                              TumblerCacheService           *service)
 {
   DeleteRequest *request;
-
-  dbus_async_return_if_fail (TUMBLER_IS_CACHE_SERVICE (service), context);
-  dbus_async_return_if_fail (uris != NULL, context);
+  
+  g_dbus_async_return_val_if_fail (TUMBLER_IS_CACHE_SERVICE (service), invocation, FALSE);
+  g_dbus_async_return_val_if_fail (uris != NULL, invocation, FALSE);
 
   /* prevent the lifecycle manager to shut tumbler down before the
    * delete request has been processed */
@@ -513,26 +542,29 @@ tumbler_cache_service_delete (TumblerCacheService   *service,
 
   request = g_slice_new0 (DeleteRequest);
   request->uris = g_strdupv ((gchar **)uris);
-  request->context = context;
+  request->invocation = invocation;
 
   g_thread_pool_push (service->delete_pool, request, NULL);
 
   /* try to keep tumbler alive */
   tumbler_component_keep_alive (TUMBLER_COMPONENT (service), NULL);
+  
+  return TRUE;
 }
 
 
 
-void
-tumbler_cache_service_cleanup (TumblerCacheService   *service,
-                               const gchar *const    *base_uris,
-                               guint32                since,
-                               DBusGMethodInvocation *context)
+gboolean
+tumbler_cache_service_cleanup (TumblerExportedCacheService   *skeleton,
+                               GDBusMethodInvocation         *invocation,
+                               const gchar *const            *base_uris,
+                               guint32                       since,
+                               TumblerCacheService           *service)
 {
   CleanupRequest *request;
 
-  dbus_async_return_if_fail (TUMBLER_IS_CACHE_SERVICE (service), context);
-
+  g_dbus_async_return_val_if_fail (TUMBLER_IS_CACHE_SERVICE (service), invocation, FALSE);
+  
   /* prevent the lifecycle manager to shut tumbler down before the
    * cleanup request has been processed */
   tumbler_component_increment_use_count (TUMBLER_COMPONENT (service));
@@ -540,10 +572,18 @@ tumbler_cache_service_cleanup (TumblerCacheService   *service,
   request = g_slice_new0 (CleanupRequest);
   request->base_uris = g_strdupv ((gchar **)base_uris);
   request->since = since;
-  request->context = context;
+  request->invocation = invocation;
 
   g_thread_pool_push (service->cleanup_pool, request, NULL);
 
   /* try to keep tumbler alive */
   tumbler_component_keep_alive (TUMBLER_COMPONENT (service), NULL);
+  
+  return TRUE;
+}
+
+gboolean tumbler_cache_service_is_exported (TumblerCacheService *service)
+{
+  g_return_if_fail (TUMBLER_IS_CACHE_SERVICE(service));
+  return service->dbus_interface_exported;
 }
diff --git a/tumblerd/tumbler-cache-service.h b/tumblerd/tumbler-cache-service.h
index 476781f..92325e0 100644
--- a/tumblerd/tumbler-cache-service.h
+++ b/tumblerd/tumbler-cache-service.h
@@ -41,26 +41,10 @@ typedef struct _TumblerCacheService      TumblerCacheService;
 
 GType                tumbler_cache_service_get_type   (void) G_GNUC_CONST;
 
-TumblerCacheService *tumbler_cache_service_new     (DBusGConnection         *connection,
+TumblerCacheService *tumbler_cache_service_new     (GDBusConnection         *connection,
                                                     TumblerLifecycleManager *lifecycle_manager) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gboolean             tumbler_cache_service_start   (TumblerCacheService     *service,
-                                                    GError                 **error);
-void                 tumbler_cache_service_move    (TumblerCacheService     *service,
-                                                    const gchar *const      *from_uris,
-                                                    const gchar *const      *to_uris,
-                                                    DBusGMethodInvocation   *context);
-void                 tumbler_cache_service_copy    (TumblerCacheService     *service,
-                                                    const gchar *const      *from_uris,
-                                                    const gchar *const      *to_uris,
-                                                    DBusGMethodInvocation   *context);
-void                 tumbler_cache_service_delete  (TumblerCacheService     *service,
-                                                    const gchar *const      *uris,
-                                                    DBusGMethodInvocation   *context);
-void                 tumbler_cache_service_cleanup (TumblerCacheService     *service,
-                                                    const gchar *const      *uri_prefix,
-                                                    guint32                  since,
-                                                    DBusGMethodInvocation   *context);
 
+gboolean             tumbler_cache_service_is_exported   (TumblerCacheService *service);
 
 G_END_DECLS;
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list