telepathy-gabble: sasl-channel: stash a GError when Close()d

Will Thompson wjt at kemper.freedesktop.org
Thu Dec 6 09:56:44 PST 2012


Module: telepathy-gabble
Branch: master
Commit: 2b05a3888537cda55710c804d79010677456e503
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=2b05a3888537cda55710c804d79010677456e503

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Mon Nov 19 17:56:55 2012 +0000

sasl-channel: stash a GError when Close()d

---

 src/server-sasl-channel.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/server-sasl-channel.c b/src/server-sasl-channel.c
index bfc7aed..48b8fae 100644
--- a/src/server-sasl-channel.c
+++ b/src/server-sasl-channel.c
@@ -992,16 +992,36 @@ gabble_server_sasl_channel_close (TpBaseChannel *channel)
 {
   GabbleServerSaslChannel *self = GABBLE_SERVER_SASL_CHANNEL (channel);
   GabbleServerSaslChannelPrivate *priv = self->priv;
+  GError error = { WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_FAILURE,
+      "Client aborted authentication." };
 
   DEBUG ("called on %p", self);
 
+  switch (priv->sasl_status)
+    {
+    case TP_SASL_STATUS_NOT_STARTED:
+    case TP_SASL_STATUS_IN_PROGRESS:
+    case TP_SASL_STATUS_SERVER_SUCCEEDED:
+      set_errors (self, TP_ERROR_STR_AUTHENTICATION_FAILED, "Close() called",
+          &error);
+      break;
+
+    case TP_SASL_STATUS_CLIENT_ACCEPTED:
+    case TP_SASL_STATUS_SUCCEEDED:
+      /* Hooray! */
+      break;
+
+    case TP_SASL_STATUS_SERVER_FAILED:
+    case TP_SASL_STATUS_CLIENT_FAILED:
+      g_warn_if_fail (priv->sasl_error != NULL);
+      break;
+    }
+
   if (priv->result != NULL)
     {
       DEBUG ("closed channel");
 
-      g_simple_async_result_set_error (priv->result, WOCKY_AUTH_ERROR,
-          WOCKY_AUTH_ERROR_FAILURE,
-          "%s", "Client aborted authentication.");
+      g_simple_async_result_set_from_error (priv->result, &error);
       complete_operation (self, TRUE);
     }
 



More information about the telepathy-commits mailing list