[next] telepathy-glib: add tp_client_factory_ensure_tls_certificate()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Mon Mar 17 07:25:42 PDT 2014


Module: telepathy-glib
Branch: next
Commit: c75761a83e427f6b5d3c50aaa8fc60f5871f117e
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=c75761a83e427f6b5d3c50aaa8fc60f5871f117e

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu Mar 13 12:05:48 2014 +0100

add tp_client_factory_ensure_tls_certificate()

Just a wrapper for now.

---

 .../telepathy-glib/telepathy-glib-sections.txt     |    2 ++
 telepathy-glib/client-factory.c                    |   32 ++++++++++++++++++++
 telepathy-glib/client-factory.h                    |    9 ++++++
 tests/dbus/tls-certificate.c                       |   13 +++++---
 4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index 3181c4a..8ec7e17 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -5789,6 +5789,8 @@ tp_client_factory_ensure_protocol
 tp_client_factory_dup_protocol_features
 tp_client_factory_add_protocol_features
 tp_client_factory_add_protocol_features_varargs
+<SUBSECTION>
+tp_client_factory_ensure_tls_certificate
 <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 612ee8b..8118f76 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -1469,3 +1469,35 @@ tp_client_factory_add_protocol_features_varargs (
       feature, var_args);
   va_end (var_args);
 }
+
+/**
+ * tp_client_factory_ensure_tls_certificate:
+ * @self: a #TpClientFactory
+ * @conn_or_chan: a #TpConnection or #TpChannel parent for this object, whose
+ *  invalidation will also result in invalidation of the returned object
+ * @object_path: the object path of this TLS certificate
+ * @error: Used to raise an error
+ *
+ * Returns a #TpTLSCertificate proxy for the channel or connection
+ * @conn_or_chan.
+ * The returned #TpTLSCertificate is cached; the same #TpTLSCertificate object
+ * will be returned by this function repeatedly, as long as at least one
+ * reference exists.
+ *
+ * Note that the returned #TpTLSCertificate is not guaranteed to be ready; the
+ * caller is responsible for calling tp_proxy_prepare_async() with the desired
+ * features (as given by tp_client_factory_dup_tls_certificate_features()).
+ *
+ * Returns: (transfer full): a reference to a #TpTLSCertificate,
+ * or %NULL on invalid arguments
+ *
+ * Since: UNRELEASED
+ */
+TpTLSCertificate *
+tp_client_factory_ensure_tls_certificate (TpClientFactory *self,
+    TpProxy *conn_or_chan,
+    const gchar *object_path,
+    GError **error)
+{
+  return tp_tls_certificate_new (conn_or_chan, object_path, error);
+}
diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h
index 8051ba1..cd06548 100644
--- a/telepathy-glib/client-factory.h
+++ b/telepathy-glib/client-factory.h
@@ -33,6 +33,7 @@
 #include <telepathy-glib/contact.h>
 #include <telepathy-glib/dbus-daemon.h>
 #include <telepathy-glib/protocol.h>
+#include <telepathy-glib/tls-certificate.h>
 
 G_BEGIN_DECLS
 
@@ -211,6 +212,14 @@ void tp_client_factory_add_protocol_features_varargs (TpClientFactory *self,
     GQuark feature,
     ...);
 
+/* TpTLSCertificate */
+_TP_AVAILABLE_IN_UNRELEASED
+TpTLSCertificate *tp_client_factory_ensure_tls_certificate (
+    TpClientFactory *self,
+    TpProxy *conn_or_chan,
+    const gchar *object_path,
+    GError **error);
+
 G_END_DECLS
 
 #endif
diff --git a/tests/dbus/tls-certificate.c b/tests/dbus/tls-certificate.c
index 9aa2843..5de2e7c 100644
--- a/tests/dbus/tls-certificate.c
+++ b/tests/dbus/tls-certificate.c
@@ -26,6 +26,7 @@ typedef struct {
     TpTestsTLSCertificate *service_cert;
 
     /* Client side objects */
+    TpClientFactory *factory;
     TpConnection *connection;
     TpTLSCertificate *cert;
 
@@ -51,6 +52,8 @@ setup (Test *test,
   tp_tests_create_and_connect_conn (TP_TESTS_TYPE_CONTACTS_CONNECTION,
       "me at test.com", &test->base_connection, &test->connection);
 
+  test->factory = g_object_ref (tp_proxy_get_factory (test->connection));
+
   path = g_strdup_printf ("%s/TlsCertificate",
       tp_proxy_get_object_path (test->connection));
 
@@ -69,8 +72,8 @@ setup (Test *test,
 
   g_ptr_array_unref (chain_data);
 
-  test->cert = tp_tls_certificate_new (TP_PROXY (test->connection), path,
-      &test->error);
+  test->cert = tp_client_factory_ensure_tls_certificate (test->factory,
+      TP_PROXY (test->connection), path, &test->error);
   g_assert_no_error (test->error);
 
   g_free (path);
@@ -93,6 +96,7 @@ teardown (Test *test,
 {
   g_clear_error (&test->error);
 
+  tp_clear_object (&test->factory);
   tp_clear_object (&test->dbus);
   g_main_loop_unref (test->mainloop);
   test->mainloop = NULL;
@@ -286,8 +290,9 @@ test_reject (Test *test,
   /* Test if we cope with an empty rejections list */
   tp_tests_tls_certificate_clear_rejection (test->service_cert);
 
-  cert = tp_tls_certificate_new (TP_PROXY (test->connection),
-      tp_proxy_get_object_path (test->cert), &test->error);
+  cert = tp_client_factory_ensure_tls_certificate (test->factory,
+      TP_PROXY (test->connection), tp_proxy_get_object_path (test->cert),
+      &test->error);
   g_assert_no_error (test->error);
 
   prepare_cert (test, cert);



More information about the telepathy-commits mailing list