add tp_protocol_new_vardict()
Guillaume Desmottes
10 years ago
6164 | 6164 | TpProtocol |
6165 | 6165 | TpProtocolClass |
6166 | 6166 | tp_protocol_new |
6167 | tp_protocol_new_vardict | |
6167 | 6168 | tp_protocol_get_name |
6168 | 6169 | tp_protocol_get_cm_name |
6169 | 6170 | tp_protocol_init_known_interfaces |
1010 | 1010 | finally: |
1011 | 1011 | g_free (bus_name); |
1012 | 1012 | 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); | |
1013 | 1052 | return ret; |
1014 | 1053 | } |
1015 | 1054 |
80 | 80 | const gchar *protocol_name, const GHashTable *immutable_properties, |
81 | 81 | GError **error); |
82 | 82 | |
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 | ||
83 | 89 | const gchar *tp_protocol_get_name (TpProtocol *self); |
84 | 90 | |
85 | 91 | _TP_AVAILABLE_IN_0_20 |
10 | 10 | |
11 | 11 | #include <telepathy-glib/protocol.h> |
12 | 12 | #include <telepathy-glib/telepathy-glib.h> |
13 | #include <telepathy-glib/variant-util-internal.h> | |
13 | 14 | |
14 | 15 | #include "tests/lib/echo-cm.h" |
15 | 16 | |
479 | 480 | g_assert (vardict != NULL); |
480 | 481 | g_assert (g_variant_is_of_type (vardict, G_VARIANT_TYPE_VARDICT)); |
481 | 482 | |
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 | ||
482 | 495 | g_variant_unref (vardict); |
483 | ||
484 | g_object_unref (protocol); | |
485 | 496 | g_hash_table_unref (props); |
486 | 497 | } |
487 | 498 |