diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2010-07-23 01:28:23 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2010-08-13 22:22:22 +0800 |
commit | 3564f1760938f7312b3cd16f1c8c8227c44ab4ad (patch) | |
tree | 18ba9521fefe88ba1c2c3c8fcc28d0ea37a6b049 | |
parent | 7a8b4058baa7f61cf93aa41076047a6f08d0eecb (diff) | |
download | gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.tar gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.tar.gz gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.tar.bz2 gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.tar.lz gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.tar.xz gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.tar.zst gsoc2013-empathy-3564f1760938f7312b3cd16f1c8c8227c44ab4ad.zip |
Add the proxy properties and methods.
Mirror them on the GObject itself, for Empathy to use and consume them.
-rw-r--r-- | libempathy/empathy-tls-certificate.c | 96 | ||||
-rw-r--r-- | libempathy/empathy-tls-certificate.h | 6 |
2 files changed, 102 insertions, 0 deletions
diff --git a/libempathy/empathy-tls-certificate.c b/libempathy/empathy-tls-certificate.c index bc5dff0f3..84103fc29 100644 --- a/libempathy/empathy-tls-certificate.c +++ b/libempathy/empathy-tls-certificate.c @@ -35,6 +35,12 @@ static void async_initable_iface_init (GAsyncInitableIface *iface); enum { PROP_OBJECT_PATH = 1, PROP_BUS_NAME, + + /* proxy properties */ + PROP_CERT_TYPE, + PROP_CERT_DATA, + PROP_STATE, + PROP_REJECT_REASON, LAST_PROPERTY, }; @@ -204,6 +210,18 @@ empathy_tls_certificate_get_property (GObject *object, case PROP_BUS_NAME: g_value_set_string (value, priv->bus_name); break; + case PROP_CERT_TYPE: + g_value_set_string (value, priv->cert_type); + break; + case PROP_CERT_DATA: + g_value_set_boxed (value, priv->cert_data); + break; + case PROP_STATE: + g_value_set_uint (value, priv->state); + break; + case PROP_REJECT_REASON: + g_value_set_uint (value, priv->reject_reason); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -262,6 +280,57 @@ empathy_tls_certificate_class_init (EmpathyTLSCertificateClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (oclass, PROP_BUS_NAME, pspec); + + pspec = g_param_spec_string ("cert-type", "Certificate type", + "The type of this certificate.", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_CERT_TYPE, pspec); + + pspec = g_param_spec_boxed ("cert-data", "Certificate chain data", + "The raw PEM-encoded certificate chain data.", + array_of_ay_get_type (), + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_CERT_DATA, pspec); + + pspec = g_param_spec_uint ("state", "State", + "The state of this certificate.", + EMP_TLS_CERTIFICATE_STATE_NONE, NUM_EMP_TLS_CERTIFICATE_STATES -1, + EMP_TLS_CERTIFICATE_STATE_NONE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_STATE, pspec); + + pspec = g_param_spec_uint ("reject-reason", "Reject reason", + "The reason why this certificate was rejected.", + EMP_TLS_CERTIFICATE_REJECT_REASON_NONE, + NUM_EMP_TLS_CERTIFICATE_REJECT_REASONS -1, + EMP_TLS_CERTIFICATE_REJECT_REASON_NONE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_REJECT_REASON, pspec); +} + +static void +cert_proxy_accept_cb (TpProxy *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + DEBUG ("Callback for accept(), error %p", error); + + if (error != NULL) + DEBUG ("Error was %s", error->message); +} + +static void +cert_proxy_reject_cb (TpProxy *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + DEBUG ("Callback for reject(), error %p", error); + + if (error != NULL) + DEBUG ("Error was %s", error->message); } void @@ -295,3 +364,30 @@ empathy_tls_certificate_new_finish (GAsyncResult *res, else return NULL; } + +void +empathy_tls_certificate_accept (EmpathyTLSCertificate *self) +{ + EmpathyTLSCertificatePriv *priv = GET_PRIV (self); + + g_assert (EMPATHY_IS_TLS_CERTIFICATE (self)); + + DEBUG ("Accepting TLS certificate"); + + emp_cli_authentication_tls_certificate_call_accept (priv->proxy, + -1, cert_proxy_accept_cb, NULL, NULL, G_OBJECT (self)); +} + +void +empathy_tls_certificate_reject (EmpathyTLSCertificate *self, + EmpTLSCertificateRejectReason reason) +{ + EmpathyTLSCertificatePriv *priv = GET_PRIV (self); + + g_assert (EMPATHY_IS_TLS_CERTIFICATE (self)); + + DEBUG ("Rejecting TLS certificate with reason %u", reason); + + emp_cli_authentication_tls_certificate_call_reject (priv->proxy, + -1, reason, cert_proxy_reject_cb, NULL, NULL, G_OBJECT (self)); +} diff --git a/libempathy/empathy-tls-certificate.h b/libempathy/empathy-tls-certificate.h index de856be1e..473134044 100644 --- a/libempathy/empathy-tls-certificate.h +++ b/libempathy/empathy-tls-certificate.h @@ -24,6 +24,8 @@ #include <glib-object.h> #include <gio/gio.h> +#include <extensions/extensions.h> + G_BEGIN_DECLS typedef struct _EmpathyTLSCertificate EmpathyTLSCertificate; @@ -64,6 +66,10 @@ void empathy_tls_certificate_new_async (const gchar *bus_name, EmpathyTLSCertificate * empathy_tls_certificate_new_finish (GAsyncResult * res, GError **error); +void empathy_tls_certificate_accept (EmpathyTLSCertificate *self); +void empathy_tls_certificate_reject (EmpathyTLSCertificate *self, + EmpTLSCertificateRejectReason reason); + G_END_DECLS #endif /* #ifndef __EMPATHY_TLS_CERTIFICATE_H__*/ |