Codebase list telepathy-glib / e8c6823
add tp_protocol_new_vardict() Guillaume Desmottes 10 years ago
4 changed file(s) with 59 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
61646164 TpProtocol
61656165 TpProtocolClass
61666166 tp_protocol_new
6167 tp_protocol_new_vardict
61676168 tp_protocol_get_name
61686169 tp_protocol_get_cm_name
61696170 tp_protocol_init_known_interfaces
10101010 finally:
10111011 g_free (bus_name);
10121012 g_free (object_path);
1013 return ret;
1014 }
1015
1016 /**
1017 * tp_protocol_new_vardict:
1018 * @dbus: proxy for the D-Bus daemon; may not be %NULL
1019 * @cm_name: the connection manager name (such as "gabble")
1020 * @protocol_name: the protocol name (such as "jabber")
1021 * @immutable_properties: the immutable D-Bus properties for this protocol
1022 * @error: used to indicate the error if %NULL is returned
1023 *
1024 * Create a new protocol proxy.
1025 *
1026 * If @immutable_properties is a floating reference, this function will
1027 * take ownership of it, much like g_variant_ref_sink(). See documentation of
1028 * that function for details.
1029 *
1030 * Returns: a new protocol proxy, or %NULL on invalid arguments
1031 *
1032 * Since: 0.UNRELEASED
1033 */
1034 TpProtocol *
1035 tp_protocol_new_vardict (TpDBusDaemon *dbus,
1036 const gchar *cm_name,
1037 const gchar *protocol_name,
1038 GVariant *immutable_properties,
1039 GError **error)
1040 {
1041 GHashTable *hash;
1042 TpProtocol *ret;
1043
1044 g_return_val_if_fail (g_variant_is_of_type (immutable_properties,
1045 G_VARIANT_TYPE_VARDICT), NULL);
1046
1047 g_variant_ref_sink (immutable_properties);
1048 hash = _tp_asv_from_vardict (immutable_properties);
1049 ret = tp_protocol_new (dbus, cm_name, protocol_name, hash, error);
1050 g_hash_table_unref (hash);
1051 g_variant_unref (immutable_properties);
10131052 return ret;
10141053 }
10151054
8080 const gchar *protocol_name, const GHashTable *immutable_properties,
8181 GError **error);
8282
83 TpProtocol * tp_protocol_new_vardict (TpDBusDaemon *dbus,
84 const gchar *cm_name,
85 const gchar *protocol_name,
86 GVariant *immutable_properties,
87 GError **error);
88
8389 const gchar *tp_protocol_get_name (TpProtocol *self);
8490
8591 _TP_AVAILABLE_IN_0_20
1010
1111 #include <telepathy-glib/protocol.h>
1212 #include <telepathy-glib/telepathy-glib.h>
13 #include <telepathy-glib/variant-util-internal.h>
1314
1415 #include "tests/lib/echo-cm.h"
1516
479480 g_assert (vardict != NULL);
480481 g_assert (g_variant_is_of_type (vardict, G_VARIANT_TYPE_VARDICT));
481482
483 g_object_unref (protocol);
484
485 /* Same but using tp_protocol_new_vardict */
486 protocol = tp_protocol_new_vardict (test->dbus, "example_echo_2",
487 "example", vardict, &test->error);
488 g_assert_no_error (test->error);
489 g_assert (TP_IS_PROTOCOL (protocol));
490
491 check_tp_protocol (protocol);
492
493 g_object_unref (protocol);
494
482495 g_variant_unref (vardict);
483
484 g_object_unref (protocol);
485496 g_hash_table_unref (props);
486497 }
487498