[next] telepathy-glib: tp_protocol_new_vardict: allow NULL as @immutable_properties

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Mon Mar 17 07:25:41 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 8cc79a72a17fdcd6c52754433ae3b6f6da2f96f4
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=8cc79a72a17fdcd6c52754433ae3b6f6da2f96f4

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Mon Mar  3 16:02:58 2014 +0100

tp_protocol_new_vardict: allow NULL as @immutable_properties

tp_protocol_new() does this as well.

---

 telepathy-glib/protocol.c |   29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index b0340e0..75b3e3f 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -971,7 +971,8 @@ finally:
  * @dbus: proxy for the D-Bus daemon; may not be %NULL
  * @cm_name: the connection manager name (such as "gabble")
  * @protocol_name: the protocol name (such as "jabber")
- * @immutable_properties: the immutable D-Bus properties for this protocol
+ * @immutable_properties: (allow-none): the immutable D-Bus properties for this
+ * protocol, or %NULL
  * @error: used to indicate the error if %NULL is returned
  *
  * Create a new protocol proxy.
@@ -991,17 +992,27 @@ tp_protocol_new_vardict (TpDBusDaemon *dbus,
     GVariant *immutable_properties,
     GError **error)
 {
-  GHashTable *hash;
   TpProtocol *ret;
 
-  g_return_val_if_fail (g_variant_is_of_type (immutable_properties,
-        G_VARIANT_TYPE_VARDICT), NULL);
+  g_return_val_if_fail (immutable_properties == NULL ||
+      g_variant_is_of_type (immutable_properties, G_VARIANT_TYPE_VARDICT),
+      NULL);
+
+  if (immutable_properties != NULL)
+    {
+      GHashTable *hash;
+
+      g_variant_ref_sink (immutable_properties);
+      hash = tp_asv_from_vardict (immutable_properties);
+      ret = tp_protocol_new (dbus, cm_name, protocol_name, hash, error);
+      g_hash_table_unref (hash);
+      g_variant_unref (immutable_properties);
+    }
+  else
+    {
+      ret = tp_protocol_new (dbus, cm_name, protocol_name, NULL, error);
+    }
 
-  g_variant_ref_sink (immutable_properties);
-  hash = tp_asv_from_vardict (immutable_properties);
-  ret = tp_protocol_new (dbus, cm_name, protocol_name, hash, error);
-  g_hash_table_unref (hash);
-  g_variant_unref (immutable_properties);
   return ret;
 }
 



More information about the telepathy-commits mailing list