diff options
author | Ali Abdallah <aliovx@gmail.com> | 2016-04-24 21:29:49 +0200 |
---|---|---|
committer | Ali Abdallah <aliovx@gmail.com> | 2016-04-24 21:29:49 +0200 |
commit | c62a1273806a0c2113ff7d589175c8f977968fe9 (patch) | |
tree | 9dc83b0f2d63272e340e1f5d7ff9651110b080a8 /xfconf | |
parent | a47c2a895d1302b012ff1ec1fe016cd573b96527 (diff) | |
download | xfconf-c62a1273806a0c2113ff7d589175c8f977968fe9.tar.gz |
Use gvalue<->gvariant conversion functions from the common
xfconf-gvaluefuncs.c code.
Change XfconfClient to XfconfExported according to the dbus xml file.
Diffstat (limited to 'xfconf')
-rw-r--r-- | xfconf/xfconf-cache.c | 95 | ||||
-rw-r--r-- | xfconf/xfconf-channel.c | 36 |
2 files changed, 17 insertions, 114 deletions
diff --git a/xfconf/xfconf-cache.c b/xfconf/xfconf-cache.c index c8249c0..65dba64 100644 --- a/xfconf/xfconf-cache.c +++ b/xfconf/xfconf-cache.c @@ -555,7 +555,6 @@ xfconf_cache_set_property_reply_handler(GDBusProxy *proxy, g_hash_table_remove(cache->old_properties, old_item->property); /* don't destroy old_item yet */ g_hash_table_steal(cache->pending_calls, old_item->cancellable); - g_print ("(1)-\n"); item = g_tree_lookup(cache->properties, old_item->property); if(G_UNLIKELY(!item)) { #ifndef NDEBUG @@ -564,7 +563,7 @@ xfconf_cache_set_property_reply_handler(GDBusProxy *proxy, goto out; } - result = xfconf_client_call_set_property_finish ((XfconfClient*)proxy, res, &error); + result = xfconf_exported_call_set_property_finish ((XfconfExported*)proxy, res, &error); if (!result) { GValue empty_val = { 0, }; g_warning("Failed to set property \"%s::%s\": %s", @@ -655,7 +654,7 @@ xfconf_cache_prefetch(XfconfCache *cache, xfconf_cache_mutex_lock(cache); - if(xfconf_client_call_get_all_properties_sync((XfconfClient *)proxy, cache->channel_name, + if(xfconf_exported_call_get_all_properties_sync((XfconfExported *)proxy, cache->channel_name, property_base ? property_base : "/", &props_variant, NULL, &tmp_error)) { @@ -697,7 +696,7 @@ xfconf_cache_lookup_locked(XfconfCache *cache, GValue tmpval = { 0, }; GError *tmp_error = NULL; /* blocking, ugh */ - if(xfconf_client_call_get_property_sync ((XfconfClient *)proxy, cache->channel_name, + if(xfconf_exported_call_get_property_sync ((XfconfExported *)proxy, cache->channel_name, property, &variant, NULL, &tmp_error)) { g_dbus_gvariant_to_gvalue (variant, &tmpval); @@ -749,83 +748,6 @@ xfconf_cache_lookup(XfconfCache *cache, return ret; } -static GVariant *xfconf_cache_basic_value_to_gvariant (const GValue *value) { - - const GVariantType *type = NULL; - - switch (G_VALUE_TYPE(value)){ - case G_TYPE_UINT: - type = G_VARIANT_TYPE_UINT32; - break; - case G_TYPE_INT: - type = G_VARIANT_TYPE_INT32; - break; - case G_TYPE_BOOLEAN: - type = G_VARIANT_TYPE_BOOLEAN; - break; - case G_TYPE_INT64: - type = G_VARIANT_TYPE_INT64; - break; - case G_TYPE_UINT64: - type = G_VARIANT_TYPE_UINT64; - break; - case G_TYPE_DOUBLE: - type = G_VARIANT_TYPE_DOUBLE; - break; - case G_TYPE_STRING: - type = G_VARIANT_TYPE_STRING; - break; - default: - break; - } - - if (G_VALUE_TYPE(value) == XFCONF_TYPE_INT16) - type = G_VARIANT_TYPE_INT16; - else if (G_VALUE_TYPE(value) == XFCONF_TYPE_UINT16) - type = G_VARIANT_TYPE_UINT16; - - if (type) { - return g_dbus_gvalue_to_gvariant (value, type); - } - - g_warning ("Unable to handle gtype '%s' to send over dbus", _xfconf_string_from_gtype(G_VALUE_TYPE(value))); - - return NULL; -} - - -static GVariant * -xfconf_cache_value_to_gvariant (const GValue *value) -{ - GVariant *variant = NULL; - - if (G_VALUE_TYPE(value) == G_TYPE_PTR_ARRAY) { - GPtrArray *arr; - GVariantBuilder builder; - guint i = 0; - - g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); - - arr = (GPtrArray*)g_value_get_boxed (value); - - for (i=0; i < arr->len; ++i) { - GValue *v = g_ptr_array_index (arr, i); - GVariant *var = NULL; - - var = xfconf_cache_basic_value_to_gvariant (v); - if (var) - g_variant_builder_add (&builder, "v", var, NULL); - } - - variant = g_variant_builder_end (&builder); - } - else - variant = xfconf_cache_basic_value_to_gvariant(value); - - return variant; -} - - gboolean xfconf_cache_set(XfconfCache *cache, const gchar *property, @@ -849,11 +771,12 @@ xfconf_cache_set(XfconfCache *cache, if(G_LIKELY(g_dbus_error_is_remote_error (tmp_error))) dbus_error_name = g_dbus_error_get_remote_error (tmp_error); - + if(g_strcmp0(dbus_error_name, "org.xfce.Xfconf.Error.PropertyNotFound") != 0 && g_strcmp0(dbus_error_name, "org.xfce.Xfconf.Error.ChannelNotFound") != 0) { /* this is bad... */ + g_print ("this is bad\n"); g_propagate_error(error, tmp_error); xfconf_cache_mutex_unlock(cache); g_free (dbus_error_name); @@ -897,11 +820,9 @@ xfconf_cache_set(XfconfCache *cache, g_hash_table_insert(cache->old_properties, old_item->property, old_item); } - /* can't use the generated dbus-glib binding here cuz we won't - * get the pending call pointer in the callback */ - variant = g_variant_new_variant (xfconf_cache_value_to_gvariant (value)); + variant = g_variant_new_variant (xfconf_gvalue_to_gvariant (value)); - xfconf_client_call_set_property ((XfconfClient *)proxy, + xfconf_exported_call_set_property ((XfconfExported *)proxy, cache->channel_name, property, variant, @@ -991,7 +912,7 @@ 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_call_reset_property_sync ((XfconfClient*)proxy, cache->channel_name, + ret = xfconf_exported_call_reset_property_sync ((XfconfExported*)proxy, cache->channel_name, property_base, recursive, NULL, error); if(ret) { diff --git a/xfconf/xfconf-channel.c b/xfconf/xfconf-channel.c index e6a4fc8..09404e2 100644 --- a/xfconf/xfconf-channel.c +++ b/xfconf/xfconf-channel.c @@ -669,8 +669,8 @@ xfconf_channel_is_property_locked(XfconfChannel *channel, gchar *real_property = REAL_PROP(channel, property); ERROR_DEFINE; - if (!xfconf_client_call_is_property_locked_sync ((XfconfClient*)proxy, channel->channel_name, - property, &locked, NULL, ERROR)) + if (!xfconf_exported_call_is_property_locked_sync ((XfconfExported*)proxy, channel->channel_name, + property, &locked, NULL, ERROR)) { ERROR_CHECK; locked = FALSE; @@ -748,10 +748,7 @@ xfconf_channel_get_properties(XfconfChannel *channel, { GDBusProxy *proxy = _xfconf_get_gdbus_proxy (); GHashTable *properties = NULL; - GVariant *out_props; GVariant *variant; - gchar *key; - GVariantIter iter; gchar *real_property_base; ERROR_DEFINE; @@ -760,32 +757,17 @@ xfconf_channel_get_properties(XfconfChannel *channel, else real_property_base = REAL_PROP(channel, property_base); - if(!xfconf_client_call_get_all_properties_sync ((XfconfClient*)proxy, channel->channel_name, - real_property_base - ? real_property_base : "/", - &out_props, NULL, ERROR)) + if(!xfconf_exported_call_get_all_properties_sync ((XfconfExported*)proxy, channel->channel_name, + real_property_base + ? real_property_base : "/", + &variant, 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); + properties = xfconf_gvariant_to_hash (variant); + g_variant_unref (variant); if(real_property_base != property_base && real_property_base != channel->property_base) @@ -2339,7 +2321,7 @@ xfconf_list_channels(void) gchar **channels = NULL; ERROR_DEFINE; - if(!xfconf_client_call_list_channels_sync ((XfconfClient*)proxy, + if(!xfconf_exported_call_list_channels_sync ((XfconfExported*)proxy, &channels, NULL, ERROR)) ERROR_CHECK; |