diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-04-19 12:01:09 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-05-09 12:14:10 +0200 |
commit | f45d621d4de4324689551112f7f56e9e2f205786 (patch) | |
tree | bd1fe6569e5d78154187bf69ddfc1a547e6907d7 | |
parent | 9be7554a63ff6a4f1039cc84d80547561d0225d5 (diff) |
tp_tls_certificate_add_rejection(): takes a GVariant instead of a GHashTable
-rw-r--r-- | telepathy-glib/tls-certificate.c | 35 | ||||
-rw-r--r-- | telepathy-glib/tls-certificate.h | 2 | ||||
-rw-r--r-- | tests/dbus/tls-certificate.c | 5 |
3 files changed, 29 insertions, 13 deletions
diff --git a/telepathy-glib/tls-certificate.c b/telepathy-glib/tls-certificate.c index 7bc8c62da..4d908d399 100644 --- a/telepathy-glib/tls-certificate.c +++ b/telepathy-glib/tls-certificate.c @@ -26,6 +26,7 @@ #include <glib/gstdio.h> #include <telepathy-glib/dbus.h> +#include <telepathy-glib/dbus-internal.h> #include <telepathy-glib/enums.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> @@ -673,26 +674,34 @@ tp_tls_certificate_accept_finish (TpTLSCertificate *self, * @reason: the reason for rejection * @dbus_error: a D-Bus error name such as %TP_ERROR_STR_CERT_REVOKED, or * %NULL to derive one from @reason - * @details: (transfer none) (allow-none) (element-type utf8 GObject.Value): details of the - * rejection, or %NULL + * @details: (transfer none) (allow-none): a variant of type + * %G_VARIANT_TYPE_VARDICT containing the details of the rejection, or %NULL * * Add a pending reason for rejection. The first call to this method is * considered "most important". After calling this method as many times * as are required, call tp_tls_certificate_reject_async() to reject the - * certif + * certificate. + * + * If @details is a floating reference (see g_variant_ref_sink()), + * ownership of @details is taken by this function. This means + * you can pass the result of g_variant_new() or g_variant_new_parsed() + * directly to this function without additional reference-count management. + * * Since: UNRELEASED -ate. */ void tp_tls_certificate_add_rejection (TpTLSCertificate *self, TpTLSCertificateRejectReason reason, const gchar *dbus_error, - GHashTable *details) + GVariant *details) { GValueArray *rejection; + GHashTable *hash; g_return_if_fail (dbus_error == NULL || tp_dbus_check_valid_interface_name (dbus_error, NULL)); + g_return_if_fail (details == NULL || + g_variant_is_of_type (details, G_VARIANT_TYPE_VARDICT)); if (self->priv->pending_rejections == NULL) self->priv->pending_rejections = g_ptr_array_new (); @@ -701,19 +710,27 @@ tp_tls_certificate_add_rejection (TpTLSCertificate *self, dbus_error = reject_reason_get_dbus_error (reason); if (details == NULL) - details = g_hash_table_new (NULL, NULL); + { + hash = g_hash_table_new (NULL, NULL); + } else - g_hash_table_ref (details); + { + hash = _tp_asv_from_vardict (details); + g_variant_ref_sink (details); + } rejection = tp_value_array_build (3, G_TYPE_UINT, reason, G_TYPE_STRING, dbus_error, - TP_HASH_TYPE_STRING_VARIANT_MAP, details, + TP_HASH_TYPE_STRING_VARIANT_MAP, hash, NULL); g_ptr_array_add (self->priv->pending_rejections, rejection); - g_hash_table_unref (details); + g_hash_table_unref (hash); + + if (details != NULL) + g_variant_unref (details); } /** diff --git a/telepathy-glib/tls-certificate.h b/telepathy-glib/tls-certificate.h index 0ad956940..fd77f84b0 100644 --- a/telepathy-glib/tls-certificate.h +++ b/telepathy-glib/tls-certificate.h @@ -96,7 +96,7 @@ gboolean tp_tls_certificate_accept_finish (TpTLSCertificate *self, void tp_tls_certificate_add_rejection (TpTLSCertificate *self, TpTLSCertificateRejectReason reason, const gchar *dbus_error, - GHashTable *details); + GVariant *details); void tp_tls_certificate_reject_async (TpTLSCertificate *self, GAsyncReadyCallback callback, gpointer user_data); diff --git a/tests/dbus/tls-certificate.c b/tests/dbus/tls-certificate.c index 39b85f577..8c0818ae0 100644 --- a/tests/dbus/tls-certificate.c +++ b/tests/dbus/tls-certificate.c @@ -225,14 +225,13 @@ test_reject (Test *test, g_signal_connect (test->cert, "notify::state", G_CALLBACK (notify_cb), test); - details = tp_asv_new ("user-requested", G_TYPE_BOOLEAN, TRUE, NULL); tp_tls_certificate_add_rejection (test->cert, - TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED, NULL, details); + TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED, NULL, + g_variant_new_parsed ("{ 'user-requested': <%b> }", TRUE)); tp_tls_certificate_add_rejection (test->cert, TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN, TP_ERROR_STR_CAPTCHA_NOT_SUPPORTED, NULL); - g_hash_table_unref (details); tp_tls_certificate_reject_async (test->cert, reject_cb, test); |