[Xfce4-commits] [xfce/xfce4-panel] 01/24: Port the panel dbus service to gdbus

noreply at xfce.org noreply at xfce.org
Tue Jul 4 00:03:32 CEST 2017


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-panel.

commit 6778d620c5f9f1849ba5064903dd5433ce89600f
Author: Ali Abdallah <ali at xfce.org>
Date:   Wed Jun 21 08:48:16 2017 +0200

    Port the panel dbus service to gdbus
---
 configure.ac.in                    |  13 ++
 panel/Makefile.am                  |  22 ++-
 panel/panel-dbus-client.c          | 120 ++++++------
 panel/panel-dbus-service-infos.xml |   5 +-
 panel/panel-dbus-service.c         | 379 +++++++++++++++++++------------------
 5 files changed, 285 insertions(+), 254 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index 18c0df7..1f7feee 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -126,6 +126,18 @@ dnl *******************************
 XDT_CHECK_LIBX11_REQUIRE()
 
 dnl ***********************************
+dnl *** Check for gdbus-codegen ***
+dnl ***********************************
+AC_ARG_VAR([GDBUS_CODEGEN], [D-Bus code and documentation generator from XML D-Bus interface definitions])
+AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], [no])
+if test x"$GDBUS_CODEGEN" = x"no"; then
+  AC_MSG_ERROR([could not find gdbus-codegen in \$PATH. You can run
+  ./configure GDBUS_CODEGEN=/path/to/gdbus-codegen to define
+  a custom location for it.])
+fi
+
+
+dnl ***********************************
 dnl *** Check for required packages ***
 dnl ***********************************
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.9.0])
@@ -137,6 +149,7 @@ XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.16.0])
 XDT_CHECK_PACKAGE([EXO], [exo-2], [0.11.2])
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.24.0])
 XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.24.0])
+PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.24.0])
 XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.24.0])
 XDT_CHECK_PACKAGE([DBUS], [dbus-glib-1], [0.73])
 XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.0.0])
diff --git a/panel/Makefile.am b/panel/Makefile.am
index d9e1a2d..89f93c2 100644
--- a/panel/Makefile.am
+++ b/panel/Makefile.am
@@ -15,8 +15,8 @@ bin_PROGRAMS = \
 	xfce4-panel
 
 xfce4_panel_built_sources = \
-	panel-dbus-service-infos.h \
-	panel-dbus-client-infos.h \
+	panel-gdbus-exported-service.h \
+	panel-gdbus-exported-service.c \
 	panel-marshal.c \
 	panel-marshal.h \
 	panel-plugin-external-wrapper-infos.h \
@@ -29,10 +29,10 @@ xfce4_panel_SOURCES = \
 	panel-application.h \
 	panel-base-window.c \
 	panel-base-window.h \
-	panel-dbus-client.c \
-	panel-dbus-client.h \
 	panel-dbus-service.c \
 	panel-dbus-service.h \
+	panel-dbus-client.c \
+	panel-dbus-client.h \
 	panel-dialogs.c \
 	panel-dialogs.h \
 	panel-item-dialog.c \
@@ -59,6 +59,7 @@ xfce4_panel_SOURCES = \
 xfce4_panel_CFLAGS = \
 	$(GTK_CFLAGS) \
 	$(GMODULE_CFLAGS) \
+	$(GIO_UNIX_CFLAGS) \
 	$(LIBXFCE4UTIL_CFLAGS) \
 	$(LIBXFCE4UI_CFLAGS) \
 	$(LIBWNCK_CFLAGS) \
@@ -77,6 +78,7 @@ xfce4_panel_LDADD = \
 	$(top_builddir)/common/libpanel-common.la \
 	$(GTK_LIBS) \
 	$(GMODULE_LIBS) \
+	$(GIO_UNIX_LIBS) \
 	$(LIBXFCE4UTIL_LIBS) \
 	$(LIBXFCE4UI_LIBS) \
 	$(LIBWNCK_LIBS) \
@@ -99,11 +101,13 @@ panel-marshal.c: panel-marshal.list Makefile
 	$(AM_V_GEN) echo "#include <panel/panel-marshal.h>" > $@ \
 	&& glib-genmarshal --prefix=_panel_marshal --body $< >> $@
 
-panel-dbus-service-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
-	$(AM_V_GEN) dbus-binding-tool --prefix=panel_dbus_service --mode=glib-server $< > $@
-
-panel-dbus-client-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
-	$(AM_V_GEN) dbus-binding-tool --mode=glib-client $< > $@
+panel-gdbus-exported-service.h:
+panel-gdbus-exported-service.c: panel-dbus-service-infos.xml Makefile
+	$(AM_V_GEN) $(GDBUS_CODEGEN) \
+	--interface-prefix org.xfce.Panel \
+	--c-namespace XfcePanel   \
+	--generate-c-code panel-gdbus-exported-service \
+	$(srcdir)/panel-dbus-service-infos.xml
 
 panel-plugin-external-wrapper-infos.h: $(srcdir)/panel-plugin-external-wrapper-infos.xml Makefile
 	$(AM_V_GEN) dbus-binding-tool --prefix=panel_plugin_external_wrapper --mode=glib-server $< > $@
diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c
index b32b858..22cefad 100644
--- a/panel/panel-dbus-client.c
+++ b/panel/panel-dbus-client.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008-2010 Nick Schermer <nick at xfce.org>
+ * Copyright (c) 2017      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 published by
@@ -24,7 +25,7 @@
 #include <stdlib.h>
 #endif
 
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
 #include <libxfce4util/libxfce4util.h>
 #include <common/panel-private.h>
 #include <common/panel-dbus.h>
@@ -34,8 +35,7 @@
 #include <panel/panel-dbus-client.h>
 #include <panel/panel-dbus-service.h>
 
-#include <panel/panel-dbus-client-infos.h>
-
+#include <panel/panel-gdbus-exported-service.h>
 
 
 enum
@@ -49,21 +49,15 @@ enum
 
 
 
-static DBusGProxy *
+static XfcePanelExportedService *
 panel_dbus_client_get_proxy (GError **error)
 {
-  DBusGConnection *dbus_connection;
-
-  /* return null if no connection is found */
-  dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
-  if (G_UNLIKELY (dbus_connection == NULL))
-    return NULL;
-
-  return dbus_g_proxy_new_for_name_owner (dbus_connection,
-                                          PANEL_DBUS_NAME,
-                                          PANEL_DBUS_PATH,
-                                          PANEL_DBUS_INTERFACE,
-                                          error);
+  return xfce_panel_exported_service_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                             G_DBUS_PROXY_FLAGS_NONE,
+                                                             PANEL_DBUS_NAME,
+                                                             PANEL_DBUS_PATH,
+                                                             NULL,
+                                                             error);
 }
 
 
@@ -73,18 +67,20 @@ panel_dbus_client_display_preferences_dialog (guint         active,
                                               const gchar  *socket_id,
                                               GError      **error)
 {
-  gboolean    result;
-  DBusGProxy *dbus_proxy;
+  XfcePanelExportedService *dbus_proxy;
+  gboolean                  result;
 
   panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
   dbus_proxy = panel_dbus_client_get_proxy (error);
-  if (G_LIKELY (dbus_proxy == NULL))
+  if (G_UNLIKELY (dbus_proxy == NULL))
     return FALSE;
 
-  result = _panel_dbus_client_display_preferences_dialog (dbus_proxy,
-                                                          active, socket_id,
-                                                          error);
+  result = xfce_panel_exported_service_call_display_preferences_dialog_sync (dbus_proxy,
+                                                                             active,
+                                                                             socket_id,
+                                                                             NULL,
+                                                                             error);
 
   g_object_unref (G_OBJECT (dbus_proxy));
 
@@ -97,8 +93,9 @@ gboolean
 panel_dbus_client_display_items_dialog (guint    active,
                                         GError **error)
 {
-  gboolean    result;
-  DBusGProxy *dbus_proxy;
+  XfcePanelExportedService *dbus_proxy;
+  gboolean                  result;
+
 
   panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -106,8 +103,10 @@ panel_dbus_client_display_items_dialog (guint    active,
   if (G_UNLIKELY (dbus_proxy == NULL))
     return FALSE;
 
-  result = _panel_dbus_client_display_items_dialog (dbus_proxy, active,
-                                                    error);
+  result = xfce_panel_exported_service_call_display_items_dialog_sync (dbus_proxy,
+                                                                       active,
+                                                                       NULL,
+                                                                       error);
 
   g_object_unref (G_OBJECT (dbus_proxy));
 
@@ -119,8 +118,8 @@ panel_dbus_client_display_items_dialog (guint    active,
 gboolean
 panel_dbus_client_save (GError **error)
 {
-  DBusGProxy *dbus_proxy;
-  gboolean    result;
+  XfcePanelExportedService *dbus_proxy;
+  gboolean                  result;
 
   panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -128,7 +127,7 @@ panel_dbus_client_save (GError **error)
   if (G_UNLIKELY (dbus_proxy == NULL))
     return FALSE;
 
-  result = _panel_dbus_client_save (dbus_proxy, error);
+  result = xfce_panel_exported_service_call_save_sync (dbus_proxy, NULL, error);
 
   g_object_unref (G_OBJECT (dbus_proxy));
 
@@ -142,8 +141,9 @@ panel_dbus_client_add_new_item (const gchar  *plugin_name,
                                 gchar       **arguments,
                                 GError      **error)
 {
-  DBusGProxy *dbus_proxy;
-  gboolean    result;
+
+  XfcePanelExportedService *dbus_proxy;
+  gboolean                  result;
 
   panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -151,9 +151,10 @@ panel_dbus_client_add_new_item (const gchar  *plugin_name,
   if (G_UNLIKELY (dbus_proxy == NULL))
     return FALSE;
 
-  result = _panel_dbus_client_add_new_item (dbus_proxy, plugin_name,
-                                            (const gchar **) arguments,
-                                            error);
+  result = xfce_panel_exported_service_call_add_new_item_sync (dbus_proxy, plugin_name,
+                                                               (const gchar **) arguments,
+                                                               NULL,
+                                                               error);
 
   g_object_unref (G_OBJECT (dbus_proxy));
 
@@ -186,12 +187,12 @@ panel_dbus_client_plugin_event (const gchar  *plugin_event,
                                 gboolean     *return_succeed,
                                 GError      **error)
 {
-  DBusGProxy  *dbus_proxy;
-  gboolean     result = FALSE;
-  gchar      **tokens;
-  GType        type;
-  GValue       value = { 0, };
-  guint        n_tokens;
+  XfcePanelExportedService  *dbus_proxy;
+  gchar                    **tokens;
+  GType                      type;
+  guint                      n_tokens;
+  gboolean                   result = FALSE;
+  GVariant                  *variant = NULL;
 
   panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -214,26 +215,23 @@ panel_dbus_client_plugin_event (const gchar  *plugin_event,
   else if (n_tokens == 2)
     {
       /* set noop value, recognized by the dbus service as %NULL value */
-      g_value_init (&value, G_TYPE_UCHAR);
-      g_value_set_uchar (&value, '\0');
+      variant = g_variant_new_byte ('\0');
     }
   else if (n_tokens == N_TOKENS)
     {
       type = panel_dbus_client_gtype_from_string (tokens[TYPE]);
       if (G_LIKELY (type != G_TYPE_NONE))
         {
-          g_value_init (&value, type);
-
           if (type == G_TYPE_BOOLEAN)
-            g_value_set_boolean (&value, strcmp (tokens[VALUE], "true") == 0);
+            variant = g_variant_new_boolean (strcmp (tokens[VALUE], "true") == 0);
           else if (type == G_TYPE_DOUBLE)
-            g_value_set_double (&value, g_ascii_strtod (tokens[VALUE], NULL));
+            variant = g_variant_new_double (g_ascii_strtod (tokens[VALUE], NULL));
           else if (type == G_TYPE_INT)
-            g_value_set_int (&value, strtol (tokens[VALUE], NULL, 0));
+            variant = g_variant_new_int64 (g_ascii_strtoll (tokens[VALUE], NULL, 0));
           else if (type == G_TYPE_STRING)
-            g_value_set_static_string (&value, tokens[VALUE]);
+            variant = g_variant_new_string (tokens[VALUE]);
           else if (type == G_TYPE_UINT)
-            g_value_set_uint (&value, strtol (tokens[VALUE], NULL, 0));
+            variant = g_variant_new_uint64 (g_ascii_strtoll (tokens[VALUE], NULL, 0));
           else
             panel_assert_not_reached ();
         }
@@ -253,15 +251,15 @@ panel_dbus_client_plugin_event (const gchar  *plugin_event,
     }
 
   /* send value over dbus */
-  panel_return_val_if_fail (G_IS_VALUE (&value), FALSE);
-  result = _panel_dbus_client_plugin_event (dbus_proxy,
-                                            tokens[PLUGIN_NAME],
-                                            tokens[NAME],
-                                            &value,
-                                            return_succeed,
-                                            error);
-  g_value_unset (&value);
-
+  panel_return_val_if_fail (variant != NULL, FALSE);
+  result = xfce_panel_exported_service_call_plugin_event_sync (dbus_proxy,
+                                                               tokens[PLUGIN_NAME],
+                                                               tokens[NAME],
+                                                               variant,
+                                                               return_succeed,
+                                                               NULL,
+                                                               error);
+  g_variant_unref (variant);
 out:
   g_strfreev (tokens);
   g_object_unref (G_OBJECT (dbus_proxy));
@@ -275,8 +273,8 @@ gboolean
 panel_dbus_client_terminate (gboolean   restart,
                              GError   **error)
 {
-  DBusGProxy *dbus_proxy;
-  gboolean    result;
+  XfcePanelExportedService *dbus_proxy;
+  gboolean                  result;
 
   panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -284,7 +282,7 @@ panel_dbus_client_terminate (gboolean   restart,
   if (G_UNLIKELY (dbus_proxy == NULL))
     return FALSE;
 
-  result = _panel_dbus_client_terminate (dbus_proxy, restart, error);
+  result = xfce_panel_exported_service_call_terminate_sync (dbus_proxy, restart, NULL, error);
 
   g_object_unref (G_OBJECT (dbus_proxy));
 
diff --git a/panel/panel-dbus-service-infos.xml b/panel/panel-dbus-service-infos.xml
index d1a6316..a0eaa6d 100644
--- a/panel/panel-dbus-service-infos.xml
+++ b/panel/panel-dbus-service-infos.xml
@@ -6,10 +6,7 @@
     with the panel.
   -->
   <interface name="org.xfce.Panel">
-    <annotation name="org.freedesktop.DBus.GLib.CSymbol"
-                value="panel_dbus_service"/>
-    <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol"
-                value="_panel_dbus_client"/>
+    <annotation name="org.gtk.GDBus.C.Name" value="ExportedService" />
 
     <!--
       DisplayPreferencesDialog (active : UINT, socket-id : STRING) : VOID
diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index 03c575d..aafceaa 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -24,9 +24,7 @@
 #include <string.h>
 #endif
 
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 #include <common/panel-private.h>
 #include <common/panel-dbus.h>
 #include <libxfce4util/libxfce4util.h>
@@ -39,57 +37,63 @@
 #include <panel/panel-item-dialog.h>
 #include <panel/panel-module-factory.h>
 
+#include <panel/panel-gdbus-exported-service.h>
+
+static void      panel_dbus_service_finalize                   (GObject                 *object);
+static void      panel_dbus_service_plugin_event_result        (XfcePanelPluginProvider *prev_provider,
+                                                                guint                    handle,
+                                                                gboolean                 result,
+                                                                PanelDBusService        *service);
+
+static gboolean  panel_dbus_service_display_preferences_dialog (XfcePanelExportedService *skeleton,
+                                                                GDBusMethodInvocation    *invocation,
+                                                                guint                     active,
+                                                                const gchar              *socket_id,
+                                                                PanelDBusService         *service);
+static gboolean  panel_dbus_service_display_items_dialog       (XfcePanelExportedService *skeleton,
+                                                                GDBusMethodInvocation    *invocation,
+                                                                guint                     active,
+                                                                PanelDBusService         *service);
+static gboolean  panel_dbus_service_save                       (XfcePanelExportedService *skeleton,
+                                                                GDBusMethodInvocation    *invocation,
+                                                                PanelDBusService         *service);
+static gboolean  panel_dbus_service_add_new_item               (XfcePanelExportedService *skeleton,
+                                                                GDBusMethodInvocation    *invocation,
+                                                                const gchar              *plugin_name,
+                                                                gchar                   **arguments,
+                                                                PanelDBusService         *service);
+static void      panel_dbus_service_plugin_event_free          (gpointer                  data);
+static gboolean  panel_dbus_service_plugin_event               (XfcePanelExportedService *skeleton,
+                                                                GDBusMethodInvocation    *invocation,
+                                                                const gchar              *plugin_name,
+                                                                const gchar              *name,
+                                                                GVariant                 *variant,
+                                                                PanelDBusService         *service);
+static gboolean  panel_dbus_service_terminate                  (XfcePanelExportedService *skeleton,
+                                                                GDBusMethodInvocation    *invocation,
+                                                                gboolean                  restart,
+                                                                PanelDBusService         *service);
 
 
-static void      panel_dbus_service_finalize                   (GObject            *object);
-static gboolean  panel_dbus_service_display_preferences_dialog (PanelDBusService   *service,
-                                                                guint               active,
-                                                                const gchar        *socket_id,
-                                                                GError            **error);
-static gboolean  panel_dbus_service_display_items_dialog       (PanelDBusService   *service,
-                                                                guint               active,
-                                                                GError            **error);
-static gboolean  panel_dbus_service_save                       (PanelDBusService   *service,
-                                                                GError            **error);
-static gboolean  panel_dbus_service_add_new_item               (PanelDBusService   *service,
-                                                                const gchar        *plugin_name,
-                                                                gchar             **arguments,
-                                                                GError            **error);
-static void      panel_dbus_service_plugin_event_free          (gpointer            data);
-static gboolean  panel_dbus_service_plugin_event               (PanelDBusService  *service,
-                                                                const gchar       *plugin_name,
-                                                                const gchar       *name,
-                                                                const GValue      *value,
-                                                                gboolean          *OUT_succeed,
-                                                                GError           **error);
-static gboolean  panel_dbus_service_terminate                  (PanelDBusService   *service,
-                                                                gboolean            restart,
-                                                                GError            **error);
-
-
-
-/* include the dbus glue generated by dbus-binding-tool */
-#include <panel/panel-dbus-service-infos.h>
-
 
 
 struct _PanelDBusServiceClass
 {
-  GObjectClass __parent__;
+  XfcePanelExportedServiceSkeletonClass __parent__;
 };
 
 struct _PanelDBusService
 {
-  GObject __parent__;
+  XfcePanelExportedServiceSkeleton __parent__;
 
   /* the dbus connection */
-  DBusGConnection *connection;
+  GDBusConnection *connection;
 
   /* queue for remote-events */
   GHashTable      *remote_events;
 
   /* whether the service is owner of the name */
-  guint            is_owner : 1;
+  guint            is_exported : 1;
 };
 
 typedef struct
@@ -120,8 +124,6 @@ panel_dbus_service_class_init (PanelDBusServiceClass *klass)
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = panel_dbus_service_finalize;
 
-  dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
-      &dbus_glib_panel_dbus_service_object_info);
 }
 
 
@@ -130,27 +132,39 @@ static void
 panel_dbus_service_init (PanelDBusService *service)
 {
   GError         *error = NULL;
-  DBusConnection *connection;
-  gint            result;
 
-  service->is_owner = FALSE;
+  service->is_exported = FALSE;
   service->remote_events = NULL;
 
-  service->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  service->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
   if (G_LIKELY (service->connection != NULL))
     {
-      /* TODO handle error */
-      connection = dbus_g_connection_get_connection (service->connection);
-      result = dbus_bus_request_name (connection, PANEL_DBUS_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE, NULL);
-      if (result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+      service->is_exported =
+      g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(service),
+                                       service->connection,
+                                       "/org/xfce/Panel",
+                                       &error);
+
+      if (error)
         {
-          /* yes we own the name */
-          service->is_owner = TRUE;
+          g_critical ("Failed to export panel D-BUS interface: %s", error->message);
+          g_error_free (error);
+        }
 
-          /* register this object */
-          dbus_g_connection_register_g_object (service->connection,
-                                               PANEL_DBUS_PATH,
-                                               G_OBJECT (service));
+      if (G_LIKELY (service->is_exported))
+        {
+          g_signal_connect (service, "handle_add_new_item",
+                            G_CALLBACK(panel_dbus_service_add_new_item), service);
+          g_signal_connect (service, "handle_display_items_dialog",
+                            G_CALLBACK(panel_dbus_service_display_items_dialog), service);
+          g_signal_connect (service, "handle_display_preferences_dialog",
+                            G_CALLBACK(panel_dbus_service_display_preferences_dialog), service);
+          g_signal_connect (service, "handle_plugin_event",
+                            G_CALLBACK(panel_dbus_service_plugin_event), service);
+          g_signal_connect (service, "handle_save",
+                            G_CALLBACK(panel_dbus_service_save), service);
+          g_signal_connect (service, "handle_terminate",
+                            G_CALLBACK(panel_dbus_service_terminate), service);
         }
     }
   else
@@ -166,17 +180,6 @@ static void
 panel_dbus_service_finalize (GObject *object)
 {
   PanelDBusService *service = PANEL_DBUS_SERVICE (object);
-  DBusConnection   *connection;
-
-  if (G_LIKELY (service->connection != NULL))
-    {
-      /* release the org.xfce.Panel name */
-      connection = dbus_g_connection_get_connection (service->connection);
-      dbus_bus_release_name (connection, PANEL_DBUS_NAME, NULL);
-      dbus_g_connection_flush (service->connection);
-
-      dbus_g_connection_unref (service->connection);
-    }
 
   if (service->remote_events != NULL)
     {
@@ -190,16 +193,18 @@ panel_dbus_service_finalize (GObject *object)
 
 
 static gboolean
-panel_dbus_service_display_preferences_dialog (PanelDBusService  *service,
-                                               guint              active,
-                                               const gchar       *socket_id,
-                                               GError           **error)
+panel_dbus_service_display_preferences_dialog (XfcePanelExportedService *skeleton,
+                                               GDBusMethodInvocation    *invocation,
+                                               guint                     active,
+                                               const gchar              *socket_id,
+                                               PanelDBusService         *service)
 {
   panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  /* show the preferences dialog */
-  panel_preferences_dialog_show_from_id (active, socket_id);
+  /* show the items dialog */
+  panel_item_dialog_show_from_id (active);
+
+  xfce_panel_exported_service_complete_display_preferences_dialog(skeleton, invocation);
 
   return TRUE;
 }
@@ -207,50 +212,55 @@ panel_dbus_service_display_preferences_dialog (PanelDBusService  *service,
 
 
 static gboolean
-panel_dbus_service_display_items_dialog (PanelDBusService  *service,
-                                         guint              active,
-                                         GError           **error)
+panel_dbus_service_display_items_dialog (XfcePanelExportedService *skeleton,
+                                         GDBusMethodInvocation    *invocation,
+                                         guint                     active,
+                                         PanelDBusService         *service)
 {
   panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
   /* show the items dialog */
   panel_item_dialog_show_from_id (active);
 
+  xfce_panel_exported_service_complete_display_items_dialog (skeleton, invocation);
+
   return TRUE;
 }
 
 
 
 static gboolean
-panel_dbus_service_save (PanelDBusService  *service,
-                         GError           **error)
+panel_dbus_service_save (XfcePanelExportedService *skeleton,
+                         GDBusMethodInvocation    *invocation,
+                         PanelDBusService         *service)
 {
   PanelApplication *application;
 
   panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
   /* save the configuration */
   application = panel_application_get ();
   panel_application_save (application, SAVE_EVERYTHING);
   g_object_unref (G_OBJECT (application));
 
+  xfce_panel_exported_service_complete_save (skeleton,
+                                             invocation);
+
   return TRUE;
 }
 
 
 
 static gboolean
-panel_dbus_service_add_new_item (PanelDBusService  *service,
-                                 const gchar       *plugin_name,
-                                 gchar            **arguments,
-                                 GError           **error)
+panel_dbus_service_add_new_item (XfcePanelExportedService *skeleton,
+                                 GDBusMethodInvocation    *invocation,
+                                 const gchar              *plugin_name,
+                                 gchar                   **arguments,
+                                 PanelDBusService         *service)
 {
   PanelApplication *application;
 
   panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
   panel_return_val_if_fail (plugin_name != NULL, FALSE);
 
   application = panel_application_get ();
@@ -263,120 +273,49 @@ panel_dbus_service_add_new_item (PanelDBusService  *service,
 
   g_object_unref (G_OBJECT (application));
 
-  return TRUE;
-}
-
-
+  xfce_panel_exported_service_complete_add_new_item (skeleton,
+                                                     invocation);
 
-static void
-panel_dbus_service_plugin_event_free (gpointer data)
-{
-  PluginEvent *event = data;
-
-  g_value_unset (&event->value);
-  g_free (event->name);
-  g_slist_free (event->plugins);
-  g_slice_free (PluginEvent, event);
-}
-
-
-
-static void
-panel_dbus_service_plugin_event_result (XfcePanelPluginProvider *prev_provider,
-                                        guint                    handle,
-                                        gboolean                 result,
-                                        PanelDBusService        *service)
-{
-  PluginEvent             *event;
-  GSList                  *li, *lnext;
-  XfcePanelPluginProvider *provider;
-  guint                    new_handle;
-  gboolean                 new_result;
-
-  g_signal_handlers_disconnect_by_func (G_OBJECT (prev_provider),
-      G_CALLBACK (panel_dbus_service_plugin_event_result), service);
-
-  event = g_hash_table_lookup (service->remote_events, &handle);
-  if (G_LIKELY (event != NULL))
-    {
-      panel_assert (event->handle == handle);
-      if (!result)
-        {
-          for (li = event->plugins, new_handle = 0; li != NULL; li = lnext, new_handle = 0)
-            {
-              lnext = li->next;
-              provider = li->data;
-              event->plugins = g_slist_delete_link (event->plugins, li);
-              new_handle = 0;
-
-              /* maybe the plugin has been destroyed */
-              if (!XFCE_PANEL_PLUGIN_PROVIDER (provider))
-                continue;
-
-              new_result = xfce_panel_plugin_provider_remote_event (provider, event->name,
-                                                                    &event->value, &new_handle);
-
-              if (new_handle > 0 && lnext != NULL)
-                {
-                  /* steal the old value */
-                  g_hash_table_steal (service->remote_events, &handle);
-
-                  /* update handle and insert again */
-                  event->handle = new_handle;
-                  g_hash_table_insert (service->remote_events, &event->handle, event);
-                  g_signal_connect (G_OBJECT (provider), "remote-event-result",
-                      G_CALLBACK (panel_dbus_service_plugin_event_result), service);
-
-                  /* leave and wait for reply */
-                  return;
-                }
-              else if (new_result)
-                {
-                  /* we're done, remove from hash table below */
-                  break;
-                }
-            }
-        }
+  return TRUE;
 
-      /* handle can be removed */
-      g_hash_table_remove (service->remote_events, &handle);
-    }
 }
 
 
 
 static gboolean
-panel_dbus_service_plugin_event (PanelDBusService  *service,
-                                 const gchar       *plugin_name,
-                                 const gchar       *name,
-                                 const GValue      *value,
-                                 gboolean          *OUT_succeed,
-                                 GError           **error)
+panel_dbus_service_plugin_event (XfcePanelExportedService *skeleton,
+                                 GDBusMethodInvocation    *invocation,
+                                 const gchar              *plugin_name,
+                                 const gchar              *name,
+                                 GVariant                 *variant,
+                                 PanelDBusService         *service)
 {
   GSList             *plugins, *li, *lnext;
   PanelModuleFactory *factory;
   PluginEvent        *event;
   guint               handle;
   gboolean            result;
+  GValue              value = { 0, };
   gboolean            plugin_replied = FALSE;
 
   panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
   panel_return_val_if_fail (plugin_name != NULL, FALSE);
   panel_return_val_if_fail (name != NULL, FALSE);
-  panel_return_val_if_fail (G_IS_VALUE (value), FALSE);
 
   /* send the event to all matching plugins, break if one of the
    * plugins returns TRUE in this remote-event handler */
   factory = panel_module_factory_get ();
   plugins = panel_module_factory_get_plugins (factory, plugin_name);
 
+  g_dbus_gvariant_to_gvalue (variant, &value);
+
   for (li = plugins, handle = 0; li != NULL; li = lnext, handle = 0)
     {
       lnext = li->next;
 
       panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (li->data), FALSE);
-      result = xfce_panel_plugin_provider_remote_event (li->data, name, value, &handle);
+
+      result = xfce_panel_plugin_provider_remote_event (li->data, name, &value, &handle);
 
       if (handle > 0 && lnext != NULL)
         {
@@ -384,8 +323,8 @@ panel_dbus_service_plugin_event (PanelDBusService  *service,
           event->handle = handle;
           event->name = g_strdup (name);
           event->plugins = g_slist_copy (lnext);
-          g_value_init (&event->value, G_VALUE_TYPE (value));
-          g_value_copy (value, &event->value);
+          g_value_init (&event->value, G_VALUE_TYPE (&value));
+          g_value_copy (&value, &event->value);
 
           /* create hash table if needed */
           if (service->remote_events == NULL)
@@ -416,26 +355,106 @@ panel_dbus_service_plugin_event (PanelDBusService  *service,
   g_slist_free (plugins);
   g_object_unref (G_OBJECT (factory));
 
-  /* return status for the panel */
-  if (OUT_succeed)
-    *OUT_succeed = plugin_replied;
+  xfce_panel_exported_service_complete_plugin_event (skeleton, invocation, plugin_replied);
 
   return TRUE;
+
 }
 
 
 
 static gboolean
-panel_dbus_service_terminate (PanelDBusService  *service,
-                              gboolean           restart,
-                              GError           **error)
+panel_dbus_service_terminate (XfcePanelExportedService *skeleton,
+                              GDBusMethodInvocation    *invocation,
+                              gboolean                  restart,
+                              PanelDBusService         *service)
 {
-  panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+  return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
 
   panel_dbus_service_exit_panel (restart);
 
+  xfce_panel_exported_service_complete_terminate (skeleton,
+                                                  invocation);
+
   return TRUE;
+
+}
+
+
+
+static void
+panel_dbus_service_plugin_event_free (gpointer data)
+{
+  PluginEvent *event = data;
+
+  g_value_unset (&event->value);
+  g_free (event->name);
+  g_slist_free (event->plugins);
+  g_slice_free (PluginEvent, event);
+}
+
+
+
+static void
+panel_dbus_service_plugin_event_result (XfcePanelPluginProvider *prev_provider,
+                                        guint                    handle,
+                                        gboolean                 result,
+                                        PanelDBusService        *service)
+{
+  PluginEvent             *event;
+  GSList                  *li, *lnext;
+  XfcePanelPluginProvider *provider;
+  guint                    new_handle;
+  gboolean                 new_result;
+
+  g_signal_handlers_disconnect_by_func (G_OBJECT (prev_provider),
+      G_CALLBACK (panel_dbus_service_plugin_event_result), service);
+
+  event = g_hash_table_lookup (service->remote_events, &handle);
+  if (G_LIKELY (event != NULL))
+    {
+      panel_assert (event->handle == handle);
+      if (!result)
+        {
+          for (li = event->plugins, new_handle = 0; li != NULL; li = lnext, new_handle = 0)
+            {
+              lnext = li->next;
+              provider = li->data;
+              event->plugins = g_slist_delete_link (event->plugins, li);
+              new_handle = 0;
+
+              /* maybe the plugin has been destroyed */
+              if (!XFCE_PANEL_PLUGIN_PROVIDER (provider))
+                continue;
+
+              new_result = xfce_panel_plugin_provider_remote_event (provider, event->name,
+                                                                    &event->value, &new_handle);
+
+              if (new_handle > 0 && lnext != NULL)
+                {
+                  /* steal the old value */
+                  g_hash_table_steal (service->remote_events, &handle);
+
+                  /* update handle and insert again */
+                  event->handle = new_handle;
+                  g_hash_table_insert (service->remote_events, &event->handle, event);
+                  g_signal_connect (G_OBJECT (provider), "remote-event-result",
+                      G_CALLBACK (panel_dbus_service_plugin_event_result), service);
+
+                  /* leave and wait for reply */
+                  return;
+                }
+              else if (new_result)
+                {
+                  /* we're done, remove from hash table below */
+                  break;
+                }
+            }
+        }
+
+      /* handle can be removed */
+      g_hash_table_remove (service->remote_events, &handle);
+    }
 }
 
 
@@ -461,10 +480,10 @@ panel_dbus_service_get (void)
 
 
 gboolean
-panel_dbus_service_is_owner (PanelDBusService *service)
+panel_dbus_service_is_exported (PanelDBusService *service)
 {
   panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
-  return service->is_owner;
+  return service->is_exported;
 }
 
 

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


More information about the Xfce4-commits mailing list