[next] telepathy-glib: client-factory: add TpTLSCertificate features
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Mon Mar 17 07:25:42 PDT 2014
Module: telepathy-glib
Branch: next
Commit: 136d7711416c76337256d9c19aabd49184acd13f
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=136d7711416c76337256d9c19aabd49184acd13f
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Thu Mar 13 14:13:54 2014 +0100
client-factory: add TpTLSCertificate features
---
.../telepathy-glib/telepathy-glib-sections.txt | 3 +
telepathy-glib/client-factory.c | 99 ++++++++++++++++++++
telepathy-glib/client-factory.h | 13 +++
tests/dbus/tls-certificate.c | 10 ++
4 files changed, 125 insertions(+)
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index 8ec7e17..f6d1135 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -5791,6 +5791,9 @@ tp_client_factory_add_protocol_features
tp_client_factory_add_protocol_features_varargs
<SUBSECTION>
tp_client_factory_ensure_tls_certificate
+tp_client_factory_add_tls_certificate_features
+tp_client_factory_add_tls_certificate_features_varargs
+tp_client_factory_dup_tls_certificate_features
<SUBSECTION Standard>
TP_IS_CLIENT_FACTORY
TP_IS_CLIENT_FACTORY_CLASS
diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index 4dfa419..da2086d 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -97,6 +97,8 @@
* @dup_protocol_features: implementation of tp_client_factory_dup_protocol_features()
* @create_tls_certificate: create a #TpTLSCertificate;
* see tp_client_factory_ensure_tls_certificate()
+ * @dup_tls_certificate_features: implementation of
+ * tp_client_factory_dup_tls_certificate_features()
*
* The class structure for #TpClientFactory.
*
@@ -148,6 +150,7 @@ struct _TpClientFactoryPrivate
GArray *desired_channel_features;
GArray *desired_contact_features;
GArray *desired_protocol_features;
+ GArray *desired_tls_certificate_features;
};
enum
@@ -345,6 +348,8 @@ tp_client_factory_finalize (GObject *object)
tp_clear_pointer (&self->priv->desired_channel_features, g_array_unref);
tp_clear_pointer (&self->priv->desired_contact_features, g_array_unref);
tp_clear_pointer (&self->priv->desired_protocol_features, g_array_unref);
+ tp_clear_pointer (&self->priv->desired_tls_certificate_features,
+ g_array_unref);
G_OBJECT_CLASS (tp_client_factory_parent_class)->finalize (object);
}
@@ -383,6 +388,11 @@ tp_client_factory_init (TpClientFactory *self)
sizeof (GQuark));
feature = TP_PROTOCOL_FEATURE_CORE;
g_array_append_val (self->priv->desired_protocol_features, feature);
+
+ self->priv->desired_tls_certificate_features = g_array_new (TRUE, FALSE,
+ sizeof (GQuark));
+ feature = TP_TLS_CERTIFICATE_FEATURE_CORE;
+ g_array_append_val (self->priv->desired_tls_certificate_features, feature);
}
static TpProtocol *
@@ -413,6 +423,14 @@ create_tls_certificate_impl (TpClientFactory *self,
return tp_tls_certificate_new (conn_or_chan, object_path, error);
}
+static GArray *
+dup_tls_certificate_features_impl (TpClientFactory *self,
+ TpTLSCertificate *certificate)
+{
+ return _tp_quark_array_copy (
+ (GQuark *) self->priv->desired_tls_certificate_features->data);
+}
+
static void
tp_client_factory_class_init (TpClientFactoryClass *klass)
{
@@ -437,6 +455,7 @@ tp_client_factory_class_init (TpClientFactoryClass *klass)
klass->create_protocol = create_protocol_impl;
klass->dup_protocol_features = dup_protocol_features_impl;
klass->create_tls_certificate = create_tls_certificate_impl;
+ klass->dup_tls_certificate_features = dup_tls_certificate_features_impl;
/**
* TpClientFactory:dbus-daemon:
@@ -1529,3 +1548,83 @@ tp_client_factory_ensure_tls_certificate (TpClientFactory *self,
return cert;
}
+
+/**
+ * tp_client_factory_dup_tls_certificate_features:
+ * @self: a #TpClientFactory object
+ * @certificate: a #TpTLSCertificate
+ *
+ * Return a zero-terminated #GArray containing the #TpTLSCertificate features
+ * that should be prepared on @protocol.
+ *
+ * Returns: (transfer full) (element-type GLib.Quark): a newly allocated
+ * #GArray
+ *
+ * Since: UNRELEASED
+ */
+GArray *
+tp_client_factory_dup_tls_certificate_features (TpClientFactory *self,
+ TpTLSCertificate *certificate)
+{
+ g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL);
+ g_return_val_if_fail (TP_IS_TLS_CERTIFICATE (certificate), NULL);
+
+ return TP_CLIENT_FACTORY_GET_CLASS (self)->dup_tls_certificate_features (
+ self, certificate);
+}
+
+/**
+ * tp_client_factory_add_tls_certificate_features:
+ * @self: a #TpClientFactory object
+ * @features: (transfer none) (array zero-terminated=1) (allow-none): an array
+ * of desired features, ending with 0; %NULL is equivalent to an array
+ * containing only 0
+ *
+ * Add @features to the desired features to be prepared on #TpTLSCertificate
+ * objects. Those features will be added to the features already returned be
+ * tp_client_factory_dup_tls_certificate_features().
+ *
+ * It is not necessary to add %TP_TLS_CERTIFICATE_FEATURE_CORE as it is already
+ * included by default.
+ *
+ * Note that these features will not be added to existing #TpTLSCertificate
+ * objects; the user must call tp_proxy_prepare_async() themself.
+ *
+ * Since: UNRELEASED
+ */
+void
+tp_client_factory_add_tls_certificate_features (TpClientFactory *self,
+ const GQuark *features)
+{
+ g_return_if_fail (TP_IS_CLIENT_FACTORY (self));
+
+ _tp_quark_array_merge (self->priv->desired_tls_certificate_features, features,
+ -1);
+}
+
+/**
+ * tp_client_factory_add_tls_certificate_features_varargs: (skip)
+ * @self: a #TpClientFactory
+ * @feature: the first feature
+ * @...: the second and subsequent features, if any, ending with 0
+ *
+ * The same as tp_client_factory_add_tls_certificate_features(), but with a
+ * more convenient calling convention from C.
+ *
+ * Since: UNRELEASED
+ */
+void
+tp_client_factory_add_tls_certificate_features_varargs (
+ TpClientFactory *self,
+ GQuark feature,
+ ...)
+{
+ va_list var_args;
+
+ g_return_if_fail (TP_IS_CLIENT_FACTORY (self));
+
+ va_start (var_args, feature);
+ _tp_quark_array_merge_valist (self->priv->desired_tls_certificate_features,
+ feature, var_args);
+ va_end (var_args);
+}
diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h
index 3eef940..5001097 100644
--- a/telepathy-glib/client-factory.h
+++ b/telepathy-glib/client-factory.h
@@ -92,6 +92,8 @@ struct _TpClientFactoryClass {
TpProxy *conn_or_chan,
const gchar *object_path,
GError **error);
+ GArray * (*dup_tls_certificate_features) (TpClientFactory *self,
+ TpTLSCertificate *certificate);
/*<private>*/
GCallback padding[20];
@@ -225,6 +227,17 @@ TpTLSCertificate *tp_client_factory_ensure_tls_certificate (
TpProxy *conn_or_chan,
const gchar *object_path,
GError **error);
+_TP_AVAILABLE_IN_UNRELEASED
+GArray *tp_client_factory_dup_tls_certificate_features (TpClientFactory *self,
+ TpTLSCertificate *certificate);
+_TP_AVAILABLE_IN_UNRELEASED
+void tp_client_factory_add_tls_certificate_features (TpClientFactory *self,
+ const GQuark *features);
+_TP_AVAILABLE_IN_UNRELEASED
+void tp_client_factory_add_tls_certificate_features_varargs (
+ TpClientFactory *self,
+ GQuark feature,
+ ...);
G_END_DECLS
diff --git a/tests/dbus/tls-certificate.c b/tests/dbus/tls-certificate.c
index 6e1b542..e1c1bfa 100644
--- a/tests/dbus/tls-certificate.c
+++ b/tests/dbus/tls-certificate.c
@@ -344,6 +344,8 @@ test_factory (Test *test,
{
/* TpTLSCertificate is cached by the factory */
TpTLSCertificate *cert;
+ GArray *features;
+ GQuark f;
cert = tp_client_factory_ensure_tls_certificate (test->factory,
TP_PROXY (test->connection), test->cert_path, &test->error);
@@ -352,6 +354,14 @@ test_factory (Test *test,
g_assert (cert == test->cert);
g_object_unref (cert);
+
+ features = tp_client_factory_dup_tls_certificate_features (test->factory,
+ test->cert);
+ g_assert (features != NULL);
+ g_assert_cmpuint (features->len, ==, 1);
+ f = g_array_index (features, GQuark, 0);
+ g_assert_cmpuint (f, ==, TP_TLS_CERTIFICATE_FEATURE_CORE);
+ g_array_unref (features);
}
int
More information about the telepathy-commits
mailing list