[glib/gdbus-merge] GDBus: Don't take a GError for g_dbus_proxy_get_cached_property_names()



commit 0e2c708bb298c98c136d507427e7b731b5cbd962
Author: David Zeuthen <davidz redhat com>
Date:   Thu May 13 17:10:15 2010 -0400

    GDBus: Don't take a GError for g_dbus_proxy_get_cached_property_names()
    
    We stopped doing this for get_cached_property() so no reason to do it
    here.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 gio/gdbusproxy.c                      |   29 +++++++++--------------------
 gio/gdbusproxy.h                      |    3 +--
 gio/tests/gdbus-example-watch-proxy.c |    2 +-
 3 files changed, 11 insertions(+), 23 deletions(-)
---
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 07b7f8e..4e24d1f 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -445,6 +445,10 @@ static void
 g_dbus_proxy_init (GDBusProxy *proxy)
 {
   proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, G_TYPE_DBUS_PROXY, GDBusProxyPrivate);
+  proxy->priv->properties = g_hash_table_new_full (g_str_hash,
+                                                   g_str_equal,
+                                                   g_free,
+                                                   (GDestroyNotify) g_variant_unref);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -452,18 +456,16 @@ g_dbus_proxy_init (GDBusProxy *proxy)
 /**
  * g_dbus_proxy_get_cached_property_names:
  * @proxy: A #GDBusProxy.
- * @error: Return location for error or %NULL.
  *
  * Gets the names of all cached properties on @proxy.
  *
- * Returns: A %NULL-terminated array of strings or %NULL if @error is set. Free with
- * g_strfreev().
+ * Returns: A %NULL-terminated array of strings or %NULL if @proxy has
+ * no cached properties. Free the returned array with g_strfreev().
  *
  * Since: 2.26
  */
 gchar **
-g_dbus_proxy_get_cached_property_names (GDBusProxy  *proxy,
-                                        GError     **error)
+g_dbus_proxy_get_cached_property_names (GDBusProxy  *proxy)
 {
   gchar **names;
   GPtrArray *p;
@@ -471,18 +473,10 @@ g_dbus_proxy_get_cached_property_names (GDBusProxy  *proxy,
   const gchar *key;
 
   g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), NULL);
-  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   names = NULL;
-
-  if (proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES)
-    {
-      g_set_error (error,
-                   G_IO_ERROR,
-                   G_IO_ERROR_FAILED,
-                   _("Properties are not available (proxy created with G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES)"));
-      goto out;
-    }
+  if (g_hash_table_size (proxy->priv->properties) == 0)
+    goto out;
 
   p = g_ptr_array_new ();
 
@@ -790,11 +784,6 @@ process_get_all_reply (GDBusProxy *proxy,
       goto out;
     }
 
-  proxy->priv->properties = g_hash_table_new_full (g_str_hash,
-                                                   g_str_equal,
-                                                   g_free,
-                                                   (GDestroyNotify) g_variant_unref);
-
   g_variant_iter_init (&iter, g_variant_get_child_value (result, 0));
   while ((item = g_variant_iter_next_value (&iter)) != NULL)
     {
diff --git a/gio/gdbusproxy.h b/gio/gdbusproxy.h
index f860555..4868853 100644
--- a/gio/gdbusproxy.h
+++ b/gio/gdbusproxy.h
@@ -127,8 +127,7 @@ GVariant        *g_dbus_proxy_get_cached_property       (GDBusProxy          *pr
 void             g_dbus_proxy_set_cached_property       (GDBusProxy          *proxy,
                                                          const gchar         *property_name,
                                                          GVariant            *value);
-gchar          **g_dbus_proxy_get_cached_property_names (GDBusProxy          *proxy,
-                                                         GError             **error);
+gchar          **g_dbus_proxy_get_cached_property_names (GDBusProxy          *proxy);
 void             g_dbus_proxy_call                      (GDBusProxy          *proxy,
                                                          const gchar         *method_name,
                                                          GVariant            *parameters,
diff --git a/gio/tests/gdbus-example-watch-proxy.c b/gio/tests/gdbus-example-watch-proxy.c
index 972a66d..4f4195f 100644
--- a/gio/tests/gdbus-example-watch-proxy.c
+++ b/gio/tests/gdbus-example-watch-proxy.c
@@ -26,7 +26,7 @@ print_properties (GDBusProxy *proxy)
 
   g_print ("    properties:\n");
 
-  property_names = g_dbus_proxy_get_cached_property_names (proxy, NULL);
+  property_names = g_dbus_proxy_get_cached_property_names (proxy);
   for (n = 0; property_names != NULL && property_names[n] != NULL; n++)
     {
       const gchar *key = property_names[n];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]