telepathy-gabble: sasl-channel: split changing state and setting errors

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


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

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

sasl-channel: split changing state and setting errors

---

 src/server-sasl-channel.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/server-sasl-channel.c b/src/server-sasl-channel.c
index 0330d99..9af3e8a 100644
--- a/src/server-sasl-channel.c
+++ b/src/server-sasl-channel.c
@@ -434,13 +434,11 @@ gabble_server_sasl_channel_class_init (GabbleServerSaslChannelClass *klass)
 }
 
 static void
-change_current_state (GabbleServerSaslChannel *self,
-    TpSASLStatus status,
+set_errors (
+    GabbleServerSaslChannel *self,
     const gchar *dbus_error,
     const gchar *debug_message)
 {
-  self->priv->sasl_status = status;
-
   g_free (self->priv->sasl_error);
   self->priv->sasl_error = g_strdup (dbus_error);
 
@@ -448,6 +446,13 @@ change_current_state (GabbleServerSaslChannel *self,
   if (debug_message != NULL)
     tp_asv_set_string (self->priv->sasl_error_details, "debug-message",
         debug_message);
+}
+
+static void
+change_current_state (GabbleServerSaslChannel *self,
+    TpSASLStatus status)
+{
+  self->priv->sasl_status = status;
 
   tp_svc_channel_interface_sasl_authentication_emit_sasl_status_changed (
       self, self->priv->sasl_status,
@@ -546,7 +551,7 @@ gabble_server_sasl_channel_start_mechanism_with_data (
               in_Mechanism);
         }
 
-      change_current_state (self, TP_SASL_STATUS_IN_PROGRESS, NULL, NULL);
+      change_current_state (self, TP_SASL_STATUS_IN_PROGRESS);
       dbus_g_method_return (context);
 
       start_data =
@@ -657,8 +662,7 @@ gabble_server_sasl_channel_accept_sasl (
               "and has accepted it");
           g_assert (g_simple_async_result_is_valid (G_ASYNC_RESULT (priv->result),
                 G_OBJECT (self), gabble_server_sasl_channel_challenge_async));
-          change_current_state (self, TP_SASL_STATUS_CLIENT_ACCEPTED, NULL,
-              NULL);
+          change_current_state (self, TP_SASL_STATUS_CLIENT_ACCEPTED);
         }
       break;
 
@@ -669,7 +673,7 @@ gabble_server_sasl_channel_accept_sasl (
       DEBUG ("client has accepted server's success");
       g_assert (g_simple_async_result_is_valid (G_ASYNC_RESULT (priv->result),
             G_OBJECT (self), gabble_server_sasl_channel_success_async));
-      change_current_state (self, TP_SASL_STATUS_SUCCEEDED, NULL, NULL);
+      change_current_state (self, TP_SASL_STATUS_SUCCEEDED);
       break;
 
     case TP_SASL_STATUS_CLIENT_ACCEPTED:
@@ -785,8 +789,9 @@ gabble_server_sasl_channel_abort_sasl (
             complete_operation (self, TRUE);
           }
 
-        change_current_state (self, TP_SASL_STATUS_CLIENT_FAILED,
+        set_errors (self,
             dbus_error, in_Debug_Message);
+        change_current_state (self, TP_SASL_STATUS_CLIENT_FAILED);
         break;
 
       default:
@@ -909,13 +914,11 @@ gabble_server_sasl_channel_success_async (GabbleServerSaslChannel *self,
 
   if (self->priv->sasl_status != TP_SASL_STATUS_CLIENT_ACCEPTED)
     {
-      change_current_state (self, TP_SASL_STATUS_SERVER_SUCCEEDED,
-          NULL, NULL);
+      change_current_state (self, TP_SASL_STATUS_SERVER_SUCCEEDED);
     }
   else
     {
-      change_current_state (self, TP_SASL_STATUS_SUCCEEDED, NULL,
-          NULL);
+      change_current_state (self, TP_SASL_STATUS_SUCCEEDED);
       complete_operation (self, TRUE);
     }
 }
@@ -947,8 +950,9 @@ gabble_server_sasl_channel_fail (GabbleServerSaslChannel *self,
   g_assert (tp_error->domain == TP_ERROR);
 
   DEBUG ("auth failed: %s", tp_error->message);
-  change_current_state (self, TP_SASL_STATUS_SERVER_FAILED,
+  set_errors (self,
       tp_error_get_dbus_name (tp_error->code), tp_error->message);
+  change_current_state (self, TP_SASL_STATUS_SERVER_FAILED);
   self->priv->disconnect_reason = conn_reason;
 }
 



More information about the telepathy-commits mailing list