diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-02-28 17:01:02 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-02-28 17:01:02 +0100 |
commit | e8c68230750766d6dc1d5594cc898f2d914c91fb (patch) | |
tree | 84b0802999bf15fbd1088762e745ab207251a5b7 | |
parent | de7f581297e8cc50d5fe9694bbccfb7e131ee009 (diff) | |
download | telepathy-glib-e8c68230750766d6dc1d5594cc898f2d914c91fb.tar.gz |
add tp_protocol_new_vardict()
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 1 | ||||
-rw-r--r-- | telepathy-glib/protocol.c | 39 | ||||
-rw-r--r-- | telepathy-glib/protocol.h | 6 | ||||
-rw-r--r-- | tests/dbus/protocol-objects.c | 13 |
4 files changed, 58 insertions, 1 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index b8eb124b3..7c0489a33 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 766beda4d..c238d49d4 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 5d964ea5f..22cf5ff9a 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 5b73a0abe..9dcdfd27a 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); } |