[Pkg-telepathy-commits] [telepathy-glib] 92/111: add tp_protocol_new_vardict()

Simon McVittie smcv at debian.org
Wed Mar 19 18:07:29 UTC 2014


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

smcv pushed a commit to branch debian
in repository telepathy-glib.

commit e8c68230750766d6dc1d5594cc898f2d914c91fb
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Fri Feb 28 17:01:02 2014 +0100

    add tp_protocol_new_vardict()
---
 docs/reference/telepathy-glib-sections.txt |  1 +
 telepathy-glib/protocol.c                  | 39 ++++++++++++++++++++++++++++++
 telepathy-glib/protocol.h                  |  6 +++++
 tests/dbus/protocol-objects.c              | 13 +++++++++-
 4 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index b8eb124..7c0489a 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -6165,6 +6165,7 @@ TP_TYPE_SVC_PROTOCOL_INTERFACE_AVATARS
 TpProtocol
 TpProtocolClass
 tp_protocol_new
+tp_protocol_new_vardict
 tp_protocol_get_name
 tp_protocol_get_cm_name
 tp_protocol_init_known_interfaces
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index 766beda..c238d49 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -1015,6 +1015,45 @@ finally:
 }
 
 /**
+ * tp_protocol_new_vardict:
+ * @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
+ * @error: used to indicate the error if %NULL is returned
+ *
+ * Create a new protocol proxy.
+ *
+ * If @immutable_properties is a floating reference, this function will
+ * take ownership of it, much like g_variant_ref_sink(). See documentation of
+ * that function for details.
+ *
+ * Returns: a new protocol proxy, or %NULL on invalid arguments
+ *
+ * Since: 0.UNRELEASED
+ */
+TpProtocol *
+tp_protocol_new_vardict (TpDBusDaemon *dbus,
+    const gchar *cm_name,
+    const gchar *protocol_name,
+    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_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;
+}
+
+/**
  * tp_protocol_init_known_interfaces:
  *
  * Ensure that the known interfaces for TpProtocol have been set up.
diff --git a/telepathy-glib/protocol.h b/telepathy-glib/protocol.h
index 5d964ea..22cf5ff 100644
--- a/telepathy-glib/protocol.h
+++ b/telepathy-glib/protocol.h
@@ -81,6 +81,12 @@ TpProtocol *tp_protocol_new (TpDBusDaemon *dbus, const gchar *cm_name,
     const gchar *protocol_name, const GHashTable *immutable_properties,
     GError **error);
 
+TpProtocol * tp_protocol_new_vardict (TpDBusDaemon *dbus,
+    const gchar *cm_name,
+    const gchar *protocol_name,
+    GVariant *immutable_properties,
+    GError **error);
+
 const gchar *tp_protocol_get_name (TpProtocol *self);
 
 _TP_AVAILABLE_IN_0_20
diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c
index 5b73a0a..9dcdfd2 100644
--- a/tests/dbus/protocol-objects.c
+++ b/tests/dbus/protocol-objects.c
@@ -11,6 +11,7 @@
 
 #include <telepathy-glib/protocol.h>
 #include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/variant-util-internal.h>
 
 #include "tests/lib/echo-cm.h"
 
@@ -480,9 +481,19 @@ test_protocol_object (Test *test,
   g_assert (vardict != NULL);
   g_assert (g_variant_is_of_type (vardict, G_VARIANT_TYPE_VARDICT));
 
-  g_variant_unref (vardict);
+  g_object_unref (protocol);
+
+  /* Same but using tp_protocol_new_vardict */
+  protocol = tp_protocol_new_vardict (test->dbus, "example_echo_2",
+      "example", vardict, &test->error);
+  g_assert_no_error (test->error);
+  g_assert (TP_IS_PROTOCOL (protocol));
+
+  check_tp_protocol (protocol);
 
   g_object_unref (protocol);
+
+  g_variant_unref (vardict);
   g_hash_table_unref (props);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib.git



More information about the Pkg-telepathy-commits mailing list