aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-tls-certificate.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2010-08-24 21:20:06 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2010-08-24 21:20:06 +0800
commitdc73f3d3e51958edaf3b0508c4205c387e735547 (patch)
treea5897c07e3704c6115f88545bf567148c8074d2c /libempathy/empathy-tls-certificate.c
parent76d38803e7992e50333c1054c48bb789ff63c699 (diff)
downloadgsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.tar
gsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.tar.gz
gsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.tar.bz2
gsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.tar.lz
gsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.tar.xz
gsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.tar.zst
gsoc2013-empathy-dc73f3d3e51958edaf3b0508c4205c387e735547.zip
Properly handle corner cases of _prepare_async() called twice
- If it's called twice before the first call returned, emit an error. - If it's called twice on an already-prepared object, just successfully return.
Diffstat (limited to 'libempathy/empathy-tls-certificate.c')
-rw-r--r--libempathy/empathy-tls-certificate.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libempathy/empathy-tls-certificate.c b/libempathy/empathy-tls-certificate.c
index 00ff4d547..acb94c79d 100644
--- a/libempathy/empathy-tls-certificate.c
+++ b/libempathy/empathy-tls-certificate.c
@@ -52,6 +52,8 @@ typedef struct {
gchar *cert_type;
GPtrArray *cert_data;
EmpTLSCertificateState state;
+
+ gboolean is_prepared;
} EmpathyTLSCertificatePriv;
G_DEFINE_TYPE (EmpathyTLSCertificate, empathy_tls_certificate,
@@ -106,6 +108,8 @@ tls_certificate_got_all_cb (TpProxy *proxy,
DEBUG ("Got a certificate chain long %u, of type %s",
priv->cert_data->len, priv->cert_type);
+ priv->is_prepared = TRUE;
+
g_simple_async_result_complete (priv->async_prepare_res);
tp_clear_object (&priv->async_prepare_res);
}
@@ -117,6 +121,28 @@ empathy_tls_certificate_prepare_async (EmpathyTLSCertificate *self,
{
EmpathyTLSCertificatePriv *priv = GET_PRIV (self);
+ /* emit an error if we're already preparing the object */
+ if (priv->async_prepare_res != NULL)
+ {
+ g_simple_async_report_error_in_idle (G_OBJECT (self),
+ callback, user_data,
+ G_IO_ERROR, G_IO_ERROR_PENDING,
+ "%s",
+ "Prepare operation already in progress on the TLS certificate.");
+
+ return;
+ }
+
+
+ /* if the object is already prepared, just complete in idle */
+ if (priv->is_prepared)
+ {
+ tp_simple_async_report_success_in_idle (G_OBJECT (self),
+ callback, user_data, empathy_tls_certificate_prepare_async);
+
+ return;
+ }
+
priv->async_prepare_res = g_simple_async_result_new (G_OBJECT (self),
callback, user_data, empathy_tls_certificate_prepare_async);