[Xfce4-commits] [xfce/xfconf] 08/31: Port xfconf_channel_get_properties to gdbus and Get rid of the last dbus-glib code in libxfconf.

noreply at xfce.org noreply at xfce.org
Thu Jun 1 13:33:01 CEST 2017


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

a   l   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/xfconf.

commit 6312fb9aabffefddfd4815c8fc3c98b2dbfbb398
Author: Ali Abdallah <aliovx at gmail.com>
Date:   Thu Apr 21 12:00:59 2016 +0200

    Port xfconf_channel_get_properties to gdbus and
    Get rid of the last dbus-glib code in libxfconf.
---
 common/xfconf-common-private.h |  2 --
 xfconf/Makefile.am             | 17 ++-------
 xfconf/xfconf-cache.c          |  8 ++---
 xfconf/xfconf-channel.c        | 36 +++++++++++++++----
 xfconf/xfconf-private.h        |  4 ---
 xfconf/xfconf.c                | 80 +-----------------------------------------
 6 files changed, 36 insertions(+), 111 deletions(-)

diff --git a/common/xfconf-common-private.h b/common/xfconf-common-private.h
index 47dcaa6..e5cd892 100644
--- a/common/xfconf-common-private.h
+++ b/common/xfconf-common-private.h
@@ -21,8 +21,6 @@
 #ifndef __XFCONF_COMMON_PRIVATE_H__
 #define __XFCONF_COMMON_PRIVATE_H__
 
-#include <dbus/dbus-glib.h>
-
 #if 0
 #define XFCONF_TYPE_G_VALUE_ARRAY  (dbus_g_type_get_collection("GPtrArray", G_TYPE_VALUE))
 #endif
diff --git a/xfconf/Makefile.am b/xfconf/Makefile.am
index 9edb51e..4fb624e 100644
--- a/xfconf/Makefile.am
+++ b/xfconf/Makefile.am
@@ -29,11 +29,9 @@ libxfconf_0_la_SOURCES = \
 
 libxfconf_0_la_CFLAGS = \
 	$(GLIB_CFLAGS) \
-	$(DBUS_CFLAGS) \
 	$(GIO_CFLAGS) \
         $(GIO_UNIX_CFLAGS) \
 	$(GTHREAD_CFLAGS) \
-	$(DBUS_GLIB_CFLAGS) \
 	$(PLATFORM_CFLAGS)
 
 libxfconf_0_la_LDFLAGS = \
@@ -49,9 +47,7 @@ libxfconf_0_la_LIBADD = \
 	$(GIO_LIBS) \
         $(GIO_UNIX_LIBS) \
 	$(GLIB_LIBS) \
-	$(GTHREAD_LIBS) \
-	$(DBUS_LIBS) \
-	$(DBUS_GLIB_LIBS)
+	$(GTHREAD_LIBS)
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libxfconf-0.pc
@@ -60,7 +56,6 @@ pkgconfig_DATA = libxfconf-0.pc
 if MAINTAINER_MODE
 
 BUILT_SOURCES = \
-	xfconf-dbus-bindings.h \
 	xfconf-gdbus-bindings.c \
 	xfconf-gdbus-bindings.h
 
@@ -72,16 +67,8 @@ xfconf-gdbus-bindings.c: $(top_srcdir)/common/xfconf-dbus.xml Makefile
 	--generate-c-code xfconf-gdbus-bindings \
 	$<
 
-xfconf-dbus-bindings.h: $(top_srcdir)/common/xfconf-dbus.xml Makefile
-	$(AM_V_GEN) dbus-binding-tool --mode=glib-client $< > $(@).tmp \
-	&& sed -e 's/^\([[:space:]]\+GValue[[:space:]]\+[^=]\+\).*;$$/\1 = { 0, };/' <$(@).tmp >$@ \
-	&& rm -f $(@).tmp
-# the above fixes a bug in dbus-binding-tool's output
-# dbus-binding-tool doesn't initialise GValues to { 0, } properly
-
 CLEANFILES = \
-	$(BUILT_SOURCES) \
-	xfconf-dbus-bindings.h.tmp
+	$(BUILT_SOURCES)
 
 endif
 
diff --git a/xfconf/xfconf-cache.c b/xfconf/xfconf-cache.c
index ec0c216..3022b34 100644
--- a/xfconf/xfconf-cache.c
+++ b/xfconf/xfconf-cache.c
@@ -1,6 +1,7 @@
 /*
  *  xfconf
  *
+ *  Copyright (c) 2016 Ali Abdallah <ali at xfce.org>
  *  Copyright (c) 2009 Brian Tarricone <brian at tarricone.org>
  *
  *  This library is free software; you can redistribute it and/or
@@ -30,7 +31,6 @@
 #include "xfconf-channel.h"
 #include "xfconf-errors.h"
 #include "xfconf-gdbus-bindings.h"
-#include "xfconf-dbus-bindings.h"
 #include "common/xfconf-gvaluefuncs.h"
 #include "xfconf-private.h"
 #include "common/xfconf-marshal.h"
@@ -954,7 +954,7 @@ xfconf_cache_reset(XfconfCache *cache,
                    GError **error)
 {
     gboolean ret = FALSE;
-    DBusGProxy *proxy = _xfconf_get_dbus_g_proxy();
+    GDBusProxy *proxy = _xfconf_get_gdbus_proxy();
 #if 0
     XfconfCacheOldItem *old_item = NULL;
 #endif
@@ -991,8 +991,8 @@ xfconf_cache_reset(XfconfCache *cache,
      * this point if a reset is going to remove the property or reset
      * it to a default.  so, we have to do this sync.  sad. */
 
-    ret = xfconf_client_reset_property(proxy, cache->channel_name,
-                                       property_base, recursive, error);
+    ret = xfconf_client_call_reset_property_sync ((XfconfClient*)proxy, cache->channel_name,
+                                                  property_base, recursive, NULL, error);
 
     if(ret) {
         /* here we just evict the entry from the cache if we have one.
diff --git a/xfconf/xfconf-channel.c b/xfconf/xfconf-channel.c
index 6cda4f6..c861b75 100644
--- a/xfconf/xfconf-channel.c
+++ b/xfconf/xfconf-channel.c
@@ -1,6 +1,7 @@
 /*
  *  xfconf
  *
+ *  Copyright (c) 2016 Ali Abdallah <ali at xfce.org>
  *  Copyright (c) 2007-2008 Brian Tarricone <bjt23 at cornell.edu>
  *
  *  This library is free software; you can redistribute it and/or
@@ -28,7 +29,6 @@
 
 #include "xfconf-channel.h"
 #include "xfconf-cache.h"
-#include "xfconf-dbus-bindings.h"
 #include "xfconf-gdbus-bindings.h"
 #include "common/xfconf-gvaluefuncs.h"
 #include "xfconf-private.h"
@@ -746,8 +746,12 @@ GHashTable *
 xfconf_channel_get_properties(XfconfChannel *channel,
                               const gchar *property_base)
 {
-    DBusGProxy *proxy = _xfconf_get_dbus_g_proxy();
+    GDBusProxy *proxy = _xfconf_get_gdbus_proxy ();
     GHashTable *properties = NULL;
+    GVariant *out_props;
+    GVariant *variant;
+    gchar *key;
+    GVariantIter iter;
     gchar *real_property_base;
     ERROR_DEFINE;
 
@@ -756,15 +760,33 @@ xfconf_channel_get_properties(XfconfChannel *channel,
     else
         real_property_base = REAL_PROP(channel, property_base);
 
-    if(!xfconf_client_get_all_properties(proxy, channel->channel_name,
-                                         real_property_base
-                                         ? real_property_base : "/",
-                                         &properties, ERROR))
+    if(!xfconf_client_call_get_all_properties_sync ((XfconfClient*)proxy, channel->channel_name,
+                                                    real_property_base
+                                                    ? real_property_base : "/",
+                                                    &out_props, NULL, ERROR))
     {
         ERROR_CHECK;
         properties = NULL;
     }
-
+    
+    g_variant_iter_init (&iter, out_props);
+    properties = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                       (GDestroyNotify)g_free,(GDestroyNotify)g_value_unset);
+    
+    while (g_variant_iter_next (&iter, "{&sv}", &key, &variant)) {
+        GValue *value;
+        
+        value = g_new0(GValue, 1);
+        g_dbus_gvariant_to_gvalue(variant, value);
+        g_hash_table_insert (properties, 
+                             g_strdup(key),
+                             value);
+        
+        g_variant_unref (variant);
+        g_free(key);
+    }
+    g_variant_unref (out_props);
+        
     if(real_property_base != property_base
        && real_property_base != channel->property_base)
     {
diff --git a/xfconf/xfconf-private.h b/xfconf/xfconf-private.h
index b611dff..6dcaffa 100644
--- a/xfconf/xfconf-private.h
+++ b/xfconf/xfconf-private.h
@@ -21,7 +21,6 @@
 #ifndef __XFCONF_PRIVATE_H__
 #define __XFCONF_PRIVATE_H__
 
-#include <dbus/dbus-glib.h>
 #include <gio/gio.h>
 
 #ifdef XFCONF_ENABLE_CHECKS
@@ -50,9 +49,6 @@ typedef struct
     GType *member_types;
 } XfconfNamedStruct;
 
-DBusGConnection *_xfconf_get_dbus_g_connection(void);
-DBusGProxy *_xfconf_get_dbus_g_proxy(void);
-
 
 GDBusConnection *_xfconf_get_gdbus_connection(void);
 GDBusProxy *_xfconf_get_gdbus_proxy(void);
diff --git a/xfconf/xfconf.c b/xfconf/xfconf.c
index 99b4dd9..c125571 100644
--- a/xfconf/xfconf.c
+++ b/xfconf/xfconf.c
@@ -30,16 +30,12 @@
 #include <gio/gio.h>
 #include <glib-object.h>
 
-#include <dbus/dbus-glib.h>
-
 #include "xfconf.h"
 #include "common/xfconf-marshal.h"
 #include "xfconf-private.h"
 #include "common/xfconf-alias.h"
 
 static guint xfconf_refcnt = 0;
-static DBusGConnection *dbus_conn = NULL;
-static DBusGProxy *dbus_proxy = NULL;
 
 static GDBusConnection *gdbus = NULL;
 static GDBusProxy *gproxy = NULL;
@@ -48,29 +44,6 @@ static GHashTable *named_structs = NULL;
 
 /* private api */
 
-DBusGConnection *
-_xfconf_get_dbus_g_connection(void)
-{
-    if(!xfconf_refcnt) {
-        g_critical("xfconf_init() must be called before attempting to use libxfconf!");
-        return NULL;
-    }
-
-    return dbus_conn;
-}
-
-DBusGProxy *
-_xfconf_get_dbus_g_proxy(void)
-{
-    if(!xfconf_refcnt) {
-        g_critical("xfconf_init() must be called before attempting to use libxfconf!");
-        return NULL;
-    }
-
-    return dbus_proxy;
-}
-
-
 GDBusConnection *
 _xfconf_get_gdbus_connection(void)
 {
@@ -107,34 +80,6 @@ _xfconf_named_struct_free(XfconfNamedStruct *ns)
     g_slice_free(XfconfNamedStruct, ns);
 }
 
-
-
-static void
-xfconf_static_dbus_init(void)
-{
-    static gboolean static_dbus_inited = FALSE;
-
-    if(!static_dbus_inited) {
-        dbus_g_error_domain_register(XFCONF_ERROR, "org.xfce.Xfconf.Error",
-                                     XFCONF_TYPE_ERROR);
-
-        dbus_g_object_register_marshaller(_xfconf_marshal_VOID__STRING_STRING_BOXED,
-                                          G_TYPE_NONE,
-                                          G_TYPE_STRING,
-                                          G_TYPE_STRING,
-                                          G_TYPE_VALUE,
-                                          G_TYPE_INVALID);
-        dbus_g_object_register_marshaller(_xfconf_marshal_VOID__STRING_STRING,
-                                          G_TYPE_NONE,
-                                          G_TYPE_STRING,
-                                          G_TYPE_STRING,
-                                          G_TYPE_INVALID);
-
-        static_dbus_inited = TRUE;
-    }
-}
-
-
 /* public api */
 
 /**
@@ -159,13 +104,8 @@ xfconf_init(GError **error)
     g_type_init();
 #endif
 
-    xfconf_static_dbus_init();
-
-    dbus_conn = dbus_g_bus_get(DBUS_BUS_SESSION, error);
-    if(!dbus_conn)
-        return FALSE;
-    
     gdbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+
     if (!gdbus)
         return FALSE;
 
@@ -177,18 +117,6 @@ xfconf_init(GError **error)
                                    "org.xfce.Xfconf",
                                    NULL,
                                    NULL);
-    
-    dbus_proxy = dbus_g_proxy_new_for_name(dbus_conn,
-                                           "org.xfce.Xfconf",
-                                           "/org/xfce/Xfconf",
-                                           "org.xfce.Xfconf");
-
-    dbus_g_proxy_add_signal(dbus_proxy, "PropertyChanged",
-                            G_TYPE_STRING, G_TYPE_STRING, G_TYPE_VALUE,
-                            G_TYPE_INVALID);
-    dbus_g_proxy_add_signal(dbus_proxy, "PropertyRemoved",
-                            G_TYPE_STRING, G_TYPE_STRING,
-                            G_TYPE_INVALID);
 
     ++xfconf_refcnt;
     return TRUE;
@@ -221,12 +149,6 @@ xfconf_shutdown(void)
         named_structs = NULL;
     }
 
-    g_object_unref(G_OBJECT(dbus_proxy));
-    dbus_proxy = NULL;
-
-    dbus_g_connection_unref(dbus_conn);
-    dbus_conn = NULL;
-
     --xfconf_refcnt;
 }
 

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


More information about the Xfce4-commits mailing list