[gdm/multi-stack: 22/45] Pull verification functions out into their own subroutines



commit 919c58b2816701ef7ed0b8be4aefb7d162f81003
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 2 13:53:34 2009 -0500

    Pull verification functions out into their own subroutines
    
    This makes the function smaller and easier to read

 gui/simple-greeter/gdm-greeter-login-window.c |  132 +++++++++++++++++--------
 1 files changed, 92 insertions(+), 40 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index ffcd950..0c06607 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -1170,6 +1170,17 @@ begin_task_verification (GdmTaskList           *task_list,
         return FALSE;
 }
 
+static void
+begin_verification (GdmGreeterLoginWindow *login_window)
+{
+        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
+                                    (GdmTaskListForeachFunc)
+                                    begin_task_verification,
+                                    login_window);
+
+        switch_mode (login_window, MODE_AUTHENTICATION);
+}
+
 static gboolean
 begin_task_verification_for_selected_user (GdmTaskList           *task_list,
                                            GdmTask               *task,
@@ -1195,6 +1206,15 @@ begin_task_verification_for_selected_user (GdmTaskList           *task_list,
 }
 
 static void
+begin_verification_for_selected_user (GdmGreeterLoginWindow *login_window)
+{
+        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
+                                    (GdmTaskListForeachFunc)
+                                    begin_task_verification_for_selected_user,
+                                    login_window);
+}
+
+static void
 on_user_chosen (GdmGreeterLoginWindow *login_window,
                 const char            *user_name)
 {
@@ -1203,12 +1223,75 @@ on_user_chosen (GdmGreeterLoginWindow *login_window,
         g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
                        0, user_name);
 
+        begin_verification_for_selected_user (login_window);
+
+        switch_mode (login_window, MODE_AUTHENTICATION);
+}
+
+static void
+begin_auto_login (GdmGreeterLoginWindow *login_window)
+{
+        g_signal_emit (login_window, signals[BEGIN_AUTO_LOGIN], 0,
+                       login_window->priv->timed_login_username);
+
+        login_window->priv->timed_login_enabled = TRUE;
+        restart_timed_login_timeout (login_window);
+
+        /* just wait for the user to select language and stuff */
+        set_log_in_button_mode (login_window, LOGIN_BUTTON_TIMED_LOGIN);
+        set_message (login_window, _("Select language and click Log In"));
+
+        switch_mode (login_window, MODE_AUTHENTICATION);
+}
+
+static gboolean
+reset_task_if_not_given (GdmTaskList *task_list,
+                         GdmTask     *task,
+                         GdmTask     *given_task)
+{
+        if (task == given_task) {
+                return FALSE;
+        }
+
+        gdm_conversation_reset (GDM_CONVERSATION (task));
+        return FALSE;
+}
+
+static void
+reset_every_task_but_given_task (GdmGreeterLoginWindow *login_window,
+                                 GdmTask               *task)
+{
         gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
                                     (GdmTaskListForeachFunc)
-                                    begin_task_verification_for_selected_user,
-                                    login_window);
+                                    reset_task_if_not_given,
+                                    task);
+}
+
+static void
+begin_single_service_verification (GdmGreeterLoginWindow *login_window,
+                                   const char            *service_name)
+{
+        GdmTask *task;
+
+        task = find_task_with_service_name (login_window, service_name);
+
+        if (task == NULL) {
+                g_debug ("GdmGreeterLoginWindow: %s has no task associated with it", service_name);
+                return;
+        }
+
+        g_debug ("GdmGreeterLoginWindow: Beginning %s auth conversation", service_name);
+
+        /* FIXME: we should probably give the plugin more say for
+         * what happens here.
+         */
+        g_signal_emit (login_window, signals[BEGIN_VERIFICATION], 0, service_name);
 
         switch_mode (login_window, MODE_AUTHENTICATION);
+        gdm_task_list_set_active_task (GDM_TASK_LIST (login_window->priv->conversation_list), task);
+
+        reset_every_task_but_given_task (login_window, task);
+        g_object_unref (task);
 }
 
 static void
@@ -1230,54 +1313,23 @@ on_user_chooser_activated (GdmUserChooserWidget  *user_chooser,
         item_id = gdm_chooser_widget_get_active_item (GDM_CHOOSER_WIDGET (user_chooser));
         g_debug ("GdmGreeterLoginWindow: item chosen '%s'", item_id);
 
+        g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
+                       0, item_id);
+
         if (strcmp (item_id, GDM_USER_CHOOSER_USER_OTHER) == 0) {
                 g_debug ("GdmGreeterLoginWindow: Starting all auth conversations");
                 g_free (item_id);
 
-                gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                            (GdmTaskListForeachFunc)
-                                            begin_task_verification,
-                                            login_window);
-
-                switch_mode (login_window, MODE_AUTHENTICATION);
+                begin_verification (login_window);
         } else if (strcmp (item_id, GDM_USER_CHOOSER_USER_AUTO) == 0) {
                 g_debug ("GdmGreeterLoginWindow: Starting auto login");
-                g_signal_emit (login_window, signals[BEGIN_AUTO_LOGIN], 0,
-                               login_window->priv->timed_login_username);
-
-                login_window->priv->timed_login_enabled = TRUE;
-                restart_timed_login_timeout (login_window);
-
-                /* just wait for the user to select language and stuff */
-                set_log_in_button_mode (login_window, LOGIN_BUTTON_TIMED_LOGIN);
-                set_message (login_window, _("Select language and click Log In"));
                 g_free (item_id);
 
-                switch_mode (login_window, MODE_AUTHENTICATION);
+                begin_auto_login (login_window);
         } else {
-                GdmTask *task;
-
-                task = gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                                   (GdmTaskListForeachFunc)
-                                                   task_has_service_name,
-                                                   (gpointer) item_id);
-
-                if (task == NULL) {
-                        g_debug ("GdmGreeterLoginWindow: %s has no task associated with it", item_id);
-                        g_free (item_id);
-                        return;
-                }
-                g_debug ("GdmGreeterLoginWindow: Beginning auth conversation for item %s", item_id);
-                /* FIXME: we should probably give the plugin more say for
-                 * what happens here.
-                 */
-                g_signal_emit (login_window, signals[BEGIN_VERIFICATION], 0, item_id);
+                g_debug ("GdmGreeterLoginWindow: Starting single auth conversation");
+                begin_single_service_verification (login_window, item_id);
                 g_free (item_id);
-
-                switch_mode (login_window, MODE_AUTHENTICATION);
-                gdm_task_list_set_active_task (GDM_TASK_LIST (login_window->priv->conversation_list), task);
-
-                g_object_unref (task);
         }
 }
 



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