[empathy] Use TpTpTLSCertificate



commit 00cc78476a3926f64b531be08ff96dc817e63367
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Apr 18 15:25:27 2012 +0200

    Use TpTpTLSCertificate
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674318

 libempathy-gtk/empathy-tls-dialog.c     |   46 ++++++++++++------------
 libempathy-gtk/empathy-tls-dialog.h     |    8 ++---
 libempathy/empathy-server-tls-handler.c |   31 ++++++----------
 libempathy/empathy-server-tls-handler.h |    6 +--
 libempathy/empathy-tls-verifier.c       |   61 +++++++++++++++----------------
 libempathy/empathy-tls-verifier.h       |    8 ++---
 src/empathy-auth-client.c               |   24 +++++++------
 tests/empathy-tls-test.c                |   57 +++++++++++++++--------------
 8 files changed, 114 insertions(+), 127 deletions(-)
---
diff --git a/libempathy-gtk/empathy-tls-dialog.c b/libempathy-gtk/empathy-tls-dialog.c
index 9fb2297..bf36e9a 100644
--- a/libempathy-gtk/empathy-tls-dialog.c
+++ b/libempathy-gtk/empathy-tls-dialog.c
@@ -47,8 +47,8 @@ enum {
 };
 
 typedef struct {
-  EmpathyTLSCertificate *certificate;
-  EmpTLSCertificateRejectReason reason;
+  TpTLSCertificate *certificate;
+  TpTLSCertificateRejectReason reason;
   GHashTable *details;
 
   gboolean remember;
@@ -139,7 +139,7 @@ reason_to_string (EmpathyTLSDialog *self)
 {
   GString *str;
   const gchar *reason_str;
-  EmpTLSCertificateRejectReason reason;
+  TpTLSCertificateRejectReason reason;
   GHashTable *details;
   EmpathyTLSDialogPriv *priv = GET_PRIV (self);
 
@@ -153,37 +153,37 @@ reason_to_string (EmpathyTLSDialog *self)
 
   switch (reason)
     {
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED:
       reason_str = _("The certificate is not signed by a Certification "
           "Authority.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED:
       reason_str = _("The certificate has expired.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED:
       reason_str = _("The certificate hasn't yet been activated.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_FINGERPRINT_MISMATCH:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_FINGERPRINT_MISMATCH:
       reason_str = _("The certificate does not have the expected fingerprint.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH:
       reason_str = _("The hostname verified by the certificate doesn't match "
           "the server name.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED:
       reason_str = _("The certificate is self-signed.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_REVOKED:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED:
       reason_str = _("The certificate has been revoked by the issuing "
           "Certification Authority.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_INSECURE:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_INSECURE:
       reason_str = _("The certificate is cryptographically weak.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_LIMIT_EXCEEDED:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_LIMIT_EXCEEDED:
       reason_str = _("The certificate length exceeds verifiable limits.");
       break;
-    case EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN:
+    case TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN:
     default:
       reason_str = _("The certificate is malformed.");
       break;
@@ -192,7 +192,7 @@ reason_to_string (EmpathyTLSDialog *self)
   g_string_append (str, reason_str);
 
   /* add more information in case of HOSTNAME_MISMATCH */
-  if (reason == EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH)
+  if (reason == TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH)
     {
       const gchar *expected_hostname, *certificate_hostname;
 
@@ -257,7 +257,7 @@ checkbox_toggled_cb (GtkToggleButton *checkbox,
 }
 
 static void
-certificate_invalidated_cb (EmpathyTLSCertificate *certificate,
+certificate_invalidated_cb (TpTLSCertificate *certificate,
     guint domain,
     gint code,
     gchar *message,
@@ -340,16 +340,16 @@ empathy_tls_dialog_class_init (EmpathyTLSDialogClass *klass)
   oclass->finalize = empathy_tls_dialog_finalize;
   oclass->constructed = empathy_tls_dialog_constructed;
 
-  pspec = g_param_spec_object ("certificate", "The EmpathyTLSCertificate",
-      "The EmpathyTLSCertificate to be displayed.",
-      EMPATHY_TYPE_TLS_CERTIFICATE,
+  pspec = g_param_spec_object ("certificate", "The TpTLSCertificate",
+      "The TpTLSCertificate to be displayed.",
+      TP_TYPE_TLS_CERTIFICATE,
       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (oclass, PROP_TLS_CERTIFICATE, pspec);
 
   pspec = g_param_spec_uint ("reason", "The reason",
       "The reason why the certificate is being asked for confirmation.",
-      0, NUM_EMP_TLS_CERTIFICATE_REJECT_REASONS - 1,
-      EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN,
+      0, NUM_TP_TLS_CERTIFICATE_REJECT_REASONS - 1,
+      TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN,
       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (oclass, PROP_REASON, pspec);
 
@@ -367,11 +367,11 @@ empathy_tls_dialog_class_init (EmpathyTLSDialogClass *klass)
 }
 
 GtkWidget *
-empathy_tls_dialog_new (EmpathyTLSCertificate *certificate,
-    EmpTLSCertificateRejectReason reason,
+empathy_tls_dialog_new (TpTLSCertificate *certificate,
+    TpTLSCertificateRejectReason reason,
     GHashTable *details)
 {
-  g_assert (EMPATHY_IS_TLS_CERTIFICATE (certificate));
+  g_assert (TP_IS_TLS_CERTIFICATE (certificate));
 
   return g_object_new (EMPATHY_TYPE_TLS_DIALOG,
       "message-type", GTK_MESSAGE_WARNING,
diff --git a/libempathy-gtk/empathy-tls-dialog.h b/libempathy-gtk/empathy-tls-dialog.h
index fcf72fe..a9c37ad 100644
--- a/libempathy-gtk/empathy-tls-dialog.h
+++ b/libempathy-gtk/empathy-tls-dialog.h
@@ -24,9 +24,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
-#include <libempathy/empathy-tls-certificate.h>
-
-#include <extensions/extensions.h>
+#include <telepathy-glib/telepathy-glib.h>
 
 G_BEGIN_DECLS
 
@@ -60,8 +58,8 @@ GType empathy_tls_dialog_get_type (void);
   (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_TLS_DIALOG, \
   EmpathyTLSDialogClass))
 
-GtkWidget * empathy_tls_dialog_new (EmpathyTLSCertificate *certificate,
-    EmpTLSCertificateRejectReason reason,
+GtkWidget * empathy_tls_dialog_new (TpTLSCertificate *certificate,
+    TpTLSCertificateRejectReason reason,
     GHashTable *details);
 
 G_END_DECLS
diff --git a/libempathy/empathy-server-tls-handler.c b/libempathy/empathy-server-tls-handler.c
index b19e9cf..dd3e7bb 100644
--- a/libempathy/empathy-server-tls-handler.c
+++ b/libempathy/empathy-server-tls-handler.c
@@ -22,12 +22,8 @@
 
 #include "empathy-server-tls-handler.h"
 
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/util.h>
-
 #define DEBUG_FLAG EMPATHY_DEBUG_TLS
 #include "empathy-debug.h"
-#include "empathy-tls-certificate.h"
 #include "empathy-utils.h"
 
 #include "extensions/extensions.h"
@@ -45,7 +41,7 @@ enum {
 typedef struct {
   TpChannel *channel;
 
-  EmpathyTLSCertificate *certificate;
+  TpTLSCertificate *certificate;
   gchar *hostname;
   gchar **reference_identities;
 
@@ -63,14 +59,12 @@ tls_certificate_prepared_cb (GObject *source,
     GAsyncResult *result,
     gpointer user_data)
 {
-  EmpathyTLSCertificate *certificate = EMPATHY_TLS_CERTIFICATE (source);
+  TpTLSCertificate *certificate = TP_TLS_CERTIFICATE (source);
   EmpathyServerTLSHandler *self = user_data;
   GError *error = NULL;
   EmpathyServerTLSHandlerPriv *priv = GET_PRIV (self);
 
-  empathy_tls_certificate_prepare_finish (certificate, result, &error);
-
-  if (error != NULL)
+  if (!tp_proxy_prepare_finish (certificate, result, &error))
     {
       g_simple_async_result_set_from_error (priv->async_init_res, error);
       g_error_free (error);
@@ -106,8 +100,8 @@ tls_handler_init_async (GAsyncInitable *initable,
   const gchar *hostname;
   const gchar * const *identities;
   const gchar *bus_name;
-  TpDBusDaemon *dbus;
   GError *error = NULL;
+  GQuark features[] = { TP_TLS_CERTIFICATE_FEATURE_CORE, 0 };
   /*
    * Used when channel doesn't implement ReferenceIdentities. A GStrv
    * with [0] the hostname, and [1] a NULL terminator.
@@ -155,17 +149,16 @@ tls_handler_init_async (GAsyncInitable *initable,
   cert_object_path = tp_asv_get_object_path (properties,
       EMP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION ".ServerCertificate");
   bus_name = tp_proxy_get_bus_name (TP_PROXY (priv->channel));
-  dbus = tp_proxy_get_dbus_daemon (TP_PROXY (priv->channel));
 
-  DEBUG ("Creating an EmpathyTLSCertificate for path %s, bus name %s",
+  DEBUG ("Creating an TpTLSCertificate for path %s, bus name %s",
       cert_object_path, bus_name);
 
-  priv->certificate = empathy_tls_certificate_new (dbus, bus_name,
+  priv->certificate = tp_tls_certificate_new (TP_PROXY (priv->channel),
       cert_object_path, &error);
 
   if (error != NULL)
     {
-      DEBUG ("Unable to create the EmpathyTLSCertificate: error %s",
+      DEBUG ("Unable to create the TpTLSCertificate: error %s",
           error->message);
 
       g_simple_async_result_set_from_error (priv->async_init_res, error);
@@ -177,7 +170,7 @@ tls_handler_init_async (GAsyncInitable *initable,
       return;
     }
 
-  empathy_tls_certificate_prepare_async (priv->certificate,
+  tp_proxy_prepare_async (priv->certificate, features,
       tls_certificate_prepared_cb, self);
 }
 
@@ -268,9 +261,9 @@ empathy_server_tls_handler_class_init (EmpathyServerTLSHandlerClass *klass)
       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (oclass, PROP_CHANNEL, pspec);
 
-  pspec = g_param_spec_object ("certificate", "The EmpathyTLSCertificate",
-      "The EmpathyTLSCertificate carried by the channel.",
-      EMPATHY_TYPE_TLS_CERTIFICATE,
+  pspec = g_param_spec_object ("certificate", "The TpTLSCertificate",
+      "The TpTLSCertificate carried by the channel.",
+      TP_TYPE_TLS_CERTIFICATE,
       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (oclass, PROP_TLS_CERTIFICATE, pspec);
 
@@ -325,7 +318,7 @@ empathy_server_tls_handler_new_finish (GAsyncResult *result,
     return NULL;
 }
 
-EmpathyTLSCertificate *
+TpTLSCertificate *
 empathy_server_tls_handler_get_certificate (EmpathyServerTLSHandler *self)
 {
   EmpathyServerTLSHandlerPriv *priv = GET_PRIV (self);
diff --git a/libempathy/empathy-server-tls-handler.h b/libempathy/empathy-server-tls-handler.h
index 1fae98b..f4caf35 100644
--- a/libempathy/empathy-server-tls-handler.h
+++ b/libempathy/empathy-server-tls-handler.h
@@ -24,9 +24,7 @@
 #include <glib-object.h>
 #include <gio/gio.h>
 
-#include <telepathy-glib/channel.h>
-
-#include <libempathy/empathy-tls-certificate.h>
+#include <telepathy-glib/telepathy-glib.h>
 
 G_BEGIN_DECLS
 
@@ -65,7 +63,7 @@ void empathy_server_tls_handler_new_async (TpChannel *channel,
 EmpathyServerTLSHandler * empathy_server_tls_handler_new_finish (
     GAsyncResult *result, GError **error);
 
-EmpathyTLSCertificate * empathy_server_tls_handler_get_certificate (
+TpTLSCertificate * empathy_server_tls_handler_get_certificate (
     EmpathyServerTLSHandler *self);
 
 G_END_DECLS
diff --git a/libempathy/empathy-tls-verifier.c b/libempathy/empathy-tls-verifier.c
index dbf083d..a9a4f38 100644
--- a/libempathy/empathy-tls-verifier.c
+++ b/libempathy/empathy-tls-verifier.c
@@ -24,8 +24,6 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
-#include <telepathy-glib/util.h>
-
 #include "empathy-tls-verifier.h"
 
 #include <gcr/gcr.h>
@@ -48,7 +46,7 @@ enum {
 };
 
 typedef struct {
-  EmpathyTLSCertificate *certificate;
+  TpTLSCertificate *certificate;
   gchar *hostname;
   gchar **reference_identities;
 
@@ -61,7 +59,7 @@ typedef struct {
 static gboolean
 verification_output_to_reason (gint res,
     guint verify_output,
-    EmpTLSCertificateRejectReason *reason)
+    TpTLSCertificateRejectReason *reason)
 {
   gboolean retval = TRUE;
 
@@ -75,13 +73,13 @@ verification_output_to_reason (gint res,
       switch (res)
         {
         case GNUTLS_E_INSUFFICIENT_CREDENTIALS:
-          *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
+          *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
           break;
         case GNUTLS_E_CONSTRAINT_ERROR:
-          *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_LIMIT_EXCEEDED;
+          *reason = TP_TLS_CERTIFICATE_REJECT_REASON_LIMIT_EXCEEDED;
           break;
         default:
-          *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
+          *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
           break;
         }
 
@@ -94,17 +92,17 @@ verification_output_to_reason (gint res,
       retval = FALSE;
 
       if (verify_output & GNUTLS_CERT_SIGNER_NOT_FOUND)
-        *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED;
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED;
       else if (verify_output & GNUTLS_CERT_SIGNER_NOT_CA)
-        *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
       else if (verify_output & GNUTLS_CERT_INSECURE_ALGORITHM)
-        *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_INSECURE;
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_INSECURE;
       else if (verify_output & GNUTLS_CERT_NOT_ACTIVATED)
-        *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED;
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED;
       else if (verify_output & GNUTLS_CERT_EXPIRED)
-        *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED;
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED;
       else
-        *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
 
       goto out;
     }
@@ -201,7 +199,7 @@ complete_verification (EmpathyTLSVerifier *self)
 
 static void
 abort_verification (EmpathyTLSVerifier *self,
-    EmpTLSCertificateRejectReason reason)
+    TpTLSCertificateRejectReason reason)
 {
   EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
 
@@ -251,8 +249,8 @@ perform_verification (EmpathyTLSVerifier *self,
         GcrCertificateChain *chain)
 {
   gboolean ret = FALSE;
-  EmpTLSCertificateRejectReason reason =
-    EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
+  TpTLSCertificateRejectReason reason =
+    TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
   gnutls_x509_crt_t *list, *anchors;
   guint n_list, n_anchors;
   guint verify_output;
@@ -282,7 +280,7 @@ perform_verification (EmpathyTLSVerifier *self,
           &anchors, &n_anchors);
   if (list == NULL || n_list == 0) {
       g_warn_if_reached ();
-      abort_verification (self, EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN);
+      abort_verification (self, TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN);
       goto out;
   }
 
@@ -328,7 +326,7 @@ perform_verification (EmpathyTLSVerifier *self,
 
       g_free (certified_hostname);
       abort_verification (self,
-              EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
+              TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
       goto out;
     }
 
@@ -465,9 +463,9 @@ empathy_tls_verifier_class_init (EmpathyTLSVerifierClass *klass)
   oclass->finalize = empathy_tls_verifier_finalize;
   oclass->dispose = empathy_tls_verifier_dispose;
 
-  pspec = g_param_spec_object ("certificate", "The EmpathyTLSCertificate",
-      "The EmpathyTLSCertificate to be verified.",
-      EMPATHY_TYPE_TLS_CERTIFICATE,
+  pspec = g_param_spec_object ("certificate", "The TpTLSCertificate",
+      "The TpTLSCertificate to be verified.",
+      TP_TYPE_TLS_CERTIFICATE,
       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (oclass, PROP_TLS_CERTIFICATE, pspec);
 
@@ -486,10 +484,11 @@ empathy_tls_verifier_class_init (EmpathyTLSVerifierClass *klass)
 }
 
 EmpathyTLSVerifier *
-empathy_tls_verifier_new (EmpathyTLSCertificate *certificate,
-    const gchar *hostname, const gchar **reference_identities)
+empathy_tls_verifier_new (TpTLSCertificate *certificate,
+    const gchar *hostname,
+    const gchar **reference_identities)
 {
-  g_assert (EMPATHY_IS_TLS_CERTIFICATE (certificate));
+  g_assert (TP_IS_TLS_CERTIFICATE (certificate));
   g_assert (hostname != NULL);
   g_assert (reference_identities != NULL);
 
@@ -507,7 +506,7 @@ empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
 {
   GcrCertificateChain *chain;
   GcrCertificate *cert;
-  GPtrArray *cert_data = NULL;
+  GPtrArray *cert_data;
   GArray *data;
   guint idx;
   EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
@@ -516,7 +515,7 @@ empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
 
   g_return_if_fail (priv->verify_result == NULL);
 
-  g_object_get (priv->certificate, "cert-data", &cert_data, NULL);
+  cert_data = tp_tls_certificate_get_cert_data (priv->certificate);
   g_return_if_fail (cert_data);
 
   priv->verify_result = g_simple_async_result_new (G_OBJECT (self),
@@ -535,13 +534,12 @@ empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
           NULL, perform_verification_cb, g_object_ref (self));
 
   g_object_unref (chain);
-  g_boxed_free (TP_ARRAY_TYPE_UCHAR_ARRAY_LIST, cert_data);
 }
 
 gboolean
 empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
     GAsyncResult *res,
-    EmpTLSCertificateRejectReason *reason,
+    TpTLSCertificateRejectReason *reason,
     GHashTable **details,
     GError **error)
 {
@@ -565,7 +563,7 @@ empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
     }
 
   if (reason != NULL)
-    *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
+    *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
 
   return TRUE;
 }
@@ -575,11 +573,11 @@ empathy_tls_verifier_store_exception (EmpathyTLSVerifier *self)
 {
   GArray *data;
   GcrCertificate *cert;
-  GPtrArray *cert_data = NULL;
+  GPtrArray *cert_data;
   GError *error = NULL;
   EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
 
-  g_object_get (priv->certificate, "cert-data", &cert_data, NULL);
+  cert_data = tp_tls_certificate_get_cert_data (priv->certificate);
   g_return_if_fail (cert_data);
 
   if (!cert_data->len)
@@ -600,5 +598,4 @@ empathy_tls_verifier_store_exception (EmpathyTLSVerifier *self)
       DEBUG ("Can't store the pinned certificate: %s", error->message);
 
   g_object_unref (cert);
-  g_boxed_free (TP_ARRAY_TYPE_UCHAR_ARRAY_LIST, cert_data);
 }
diff --git a/libempathy/empathy-tls-verifier.h b/libempathy/empathy-tls-verifier.h
index 4361493..2f66acb 100644
--- a/libempathy/empathy-tls-verifier.h
+++ b/libempathy/empathy-tls-verifier.h
@@ -24,9 +24,7 @@
 #include <glib-object.h>
 #include <gio/gio.h>
 
-#include <libempathy/empathy-tls-certificate.h>
-
-#include <extensions/extensions.h>
+#include <telepathy-glib/telepathy-glib.h>
 
 G_BEGIN_DECLS
 
@@ -61,7 +59,7 @@ GType empathy_tls_verifier_get_type (void);
   EmpathyTLSVerifierClass))
 
 EmpathyTLSVerifier * empathy_tls_verifier_new (
-    EmpathyTLSCertificate *certificate,
+    TpTLSCertificate *certificate,
     const gchar *hostname,
     const gchar **reference_identities);
 
@@ -71,7 +69,7 @@ void empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
 
 gboolean empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
     GAsyncResult *res,
-    EmpTLSCertificateRejectReason *reason,
+    TpTLSCertificateRejectReason *reason,
     GHashTable **details,
     GError **error);
 
diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c
index ee33703..4f7712d 100644
--- a/src/empathy-auth-client.c
+++ b/src/empathy-auth-client.c
@@ -93,8 +93,8 @@ tls_dialog_response_cb (GtkDialog *dialog,
     gint response_id,
     gpointer user_data)
 {
-  EmpathyTLSCertificate *certificate = NULL;
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificate *certificate = NULL;
+  TpTLSCertificateRejectReason reason = 0;
   GHashTable *details = NULL;
   EmpathyTLSDialog *tls_dialog = EMPATHY_TLS_DIALOG (dialog);
   gboolean remember = FALSE;
@@ -113,13 +113,15 @@ tls_dialog_response_cb (GtkDialog *dialog,
 
   if (response_id == GTK_RESPONSE_YES)
     {
-      empathy_tls_certificate_accept_async (certificate, NULL, NULL);
+      tp_tls_certificate_accept_async (certificate, NULL, NULL);
     }
   else
     {
       tp_asv_set_boolean (details, "user-requested", TRUE);
-      empathy_tls_certificate_reject_async (certificate, reason, details,
-          NULL, NULL);
+      tp_tls_certificate_add_rejection (certificate, reason, NULL,
+          g_variant_new_parsed ("{ 'user-requested': <%b> }", TRUE));
+
+      tp_tls_certificate_reject_async (certificate, NULL, NULL);
     }
 
   if (remember)
@@ -138,9 +140,9 @@ tls_dialog_response_cb (GtkDialog *dialog,
 }
 
 static void
-display_interactive_dialog (EmpathyTLSCertificate *certificate,
+display_interactive_dialog (TpTLSCertificate *certificate,
     EmpathyTLSVerifier *verifier,
-    EmpTLSCertificateRejectReason reason,
+    TpTLSCertificateRejectReason reason,
     GHashTable *details)
 {
   GtkWidget *tls_dialog;
@@ -162,9 +164,9 @@ verifier_verify_cb (GObject *source,
     GAsyncResult *result,
     gpointer user_data)
 {
-  EmpTLSCertificateRejectReason reason;
+  TpTLSCertificateRejectReason reason;
   GError *error = NULL;
-  EmpathyTLSCertificate *certificate = NULL;
+  TpTLSCertificate *certificate = NULL;
   GHashTable *details = NULL;
   gchar *hostname = NULL;
 
@@ -185,7 +187,7 @@ verifier_verify_cb (GObject *source,
     }
   else
     {
-      empathy_tls_certificate_accept_async (certificate, NULL, NULL);
+      tp_tls_certificate_accept_async (certificate, NULL, NULL);
     }
 
   g_free (hostname);
@@ -197,7 +199,7 @@ auth_factory_new_tls_handler_cb (EmpathyAuthFactory *factory,
     EmpathyServerTLSHandler *handler,
     gpointer user_data)
 {
-  EmpathyTLSCertificate *certificate = NULL;
+  TpTLSCertificate *certificate = NULL;
   gchar *hostname = NULL;
   gchar **reference_identities = NULL;
   EmpathyTLSVerifier *verifier;
diff --git a/tests/empathy-tls-test.c b/tests/empathy-tls-test.c
index e2ba5b4..c663aad 100644
--- a/tests/empathy-tls-test.c
+++ b/tests/empathy-tls-test.c
@@ -2,7 +2,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <libempathy/empathy-tls-certificate.h>
 #include <libempathy/empathy-tls-verifier.h>
 #include "test-helper.h"
 #include "mock-pkcs11.h"
@@ -11,12 +10,9 @@
 
 #include <gnutls/gnutls.h>
 
-#include <telepathy-glib/dbus-properties-mixin.h>
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/telepathy-glib.h>
 #include <telepathy-glib/svc-tls.h>
 #include <telepathy-glib/svc-generic.h>
-#include <telepathy-glib/telepathy-glib.h>
 
 #define MOCK_TLS_CERTIFICATE_PATH "/mock/certificate"
 
@@ -206,10 +202,10 @@ mock_tls_certificate_iface_init (gpointer g_iface,
 #if 0
 static void
 mock_tls_certificate_assert_rejected (MockTLSCertificate *self,
-        EmpTLSCertificateRejectReason reason)
+        TpTLSCertificateRejectReason reason)
 {
   GValueArray *rejection;
-  EmpTLSCertificateRejectReason rejection_reason;
+  TpTLSCertificateRejectReason rejection_reason;
   gchar *rejection_error;
   GHashTable *rejection_details;
   guint i;
@@ -282,7 +278,7 @@ typedef struct {
   TpDBusDaemon *dbus;
   const gchar *dbus_name;
   MockTLSCertificate *mock;
-  EmpathyTLSCertificate *cert;
+  TpTLSCertificate *cert;
   GAsyncResult *result;
 } Test;
 
@@ -384,17 +380,22 @@ static void
 ensure_certificate_proxy (Test *test)
 {
   GError *error = NULL;
+  GQuark features[] = { TP_TLS_CERTIFICATE_FEATURE_CORE, 0 };
 
   if (test->cert)
     return;
 
   /* Create and prepare a certificate */
-  test->cert = empathy_tls_certificate_new (test->dbus, test->dbus_name,
-          MOCK_TLS_CERTIFICATE_PATH, &error);
-  g_assert_no_error (error);
-  empathy_tls_certificate_prepare_async (test->cert, fetch_callback_result, test);
+  /* We don't use tp_tls_certificate_new() as we don't pass a parent */
+  test->cert = g_object_new (TP_TYPE_TLS_CERTIFICATE,
+      "dbus-daemon", test->dbus,
+      "bus-name", test->dbus_name,
+      "object-path", MOCK_TLS_CERTIFICATE_PATH,
+      NULL);
+
+  tp_proxy_prepare_async (test->cert, features, fetch_callback_result, test);
   g_main_loop_run (test->loop);
-  empathy_tls_certificate_prepare_finish (test->cert, test->result, &error);
+  tp_proxy_prepare_finish (test->cert, test->result, &error);
   g_assert_no_error (error);
 
   /* Clear for any future async stuff */
@@ -414,9 +415,9 @@ test_certificate_mock_basics (Test *test,
 
   ensure_certificate_proxy (test);
 
-  empathy_tls_certificate_accept_async (test->cert, fetch_callback_result, test);
+  tp_tls_certificate_accept_async (test->cert, fetch_callback_result, test);
   g_main_loop_run (test->loop);
-  empathy_tls_certificate_accept_finish (test->cert, test->result, &error);
+  tp_tls_certificate_accept_finish (test->cert, test->result, &error);
   g_assert_no_error (error);
 
   g_assert (test->mock->state == TP_TLS_CERTIFICATE_STATE_ACCEPTED);
@@ -426,7 +427,7 @@ static void
 test_certificate_verify_success_with_pkcs11_lookup (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -467,7 +468,7 @@ static void
 test_certificate_verify_success_with_full_chain (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -506,7 +507,7 @@ static void
 test_certificate_verify_root_not_found (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -531,7 +532,7 @@ test_certificate_verify_root_not_found (Test *test,
 
   /* And it should say we're self-signed (oddly enough) */
   g_assert_error (error, G_IO_ERROR,
-      EMP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
+      TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
 
   g_clear_error (&error);
   g_object_unref (verifier);
@@ -541,7 +542,7 @@ static void
 test_certificate_verify_root_not_anchored (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -566,7 +567,7 @@ test_certificate_verify_root_not_anchored (Test *test,
 
   /* And it should say we're self-signed (oddly enough) */
   g_assert_error (error, G_IO_ERROR,
-      EMP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
+      TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
 
   g_clear_error (&error);
   g_object_unref (verifier);
@@ -576,7 +577,7 @@ static void
 test_certificate_verify_identities_invalid (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -602,7 +603,7 @@ test_certificate_verify_identities_invalid (Test *test,
 
   /* And it should say we're self-signed (oddly enough) */
   g_assert_error (error, G_IO_ERROR,
-      EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
+      TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
 
   g_clear_error (&error);
   g_object_unref (verifier);
@@ -612,7 +613,7 @@ static void
 test_certificate_verify_uses_reference_identities (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -639,7 +640,7 @@ test_certificate_verify_uses_reference_identities (Test *test,
 
   /* And it should say we're self-signed (oddly enough) */
   g_assert_error (error, G_IO_ERROR,
-      EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
+      TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
 
   g_clear_error (&error);
   g_object_unref (verifier);
@@ -649,7 +650,7 @@ static void
 test_certificate_verify_success_with_pinned (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -688,7 +689,7 @@ static void
 test_certificate_verify_pinned_wrong_host (Test *test,
         gconstpointer data G_GNUC_UNUSED)
 {
-  EmpTLSCertificateRejectReason reason = 0;
+  TpTLSCertificateRejectReason reason = 0;
   GError *error = NULL;
   EmpathyTLSVerifier *verifier;
   const gchar *reference_identities[] = {
@@ -713,7 +714,7 @@ test_certificate_verify_pinned_wrong_host (Test *test,
 
   /* And it should say we're self-signed */
   g_assert_error (error, G_IO_ERROR,
-      EMP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
+      TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
 
   g_clear_error (&error);
   g_object_unref (verifier);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]