auth_check_idle (GSLockPlug *plug)
{
        gboolean     res;
        gboolean     again;
        static guint loop_counter = 0;

        again = TRUE;
        res = do_auth_check (plug);

        if (res) {
                again = FALSE;
                g_idle_add ((GSourceFunc)quit_response_ok, NULL);
        } else {
                loop_counter++;

                if (loop_counter < MAX_FAILURES) {
                        gs_debug ("Authentication failed, retrying (%u)", loop_counter);
                        g_timeout_add (3000, (GSourceFunc)reset_idle_cb, plug);
                } else {
                        gs_debug ("Authentication failed, quitting (max failures)");
                        again = FALSE;
                        /* Don't quit immediately, but rather request that gnome-screensaver
                         * terminates us after it has finished the dialog shake. Time out
                         * after 5 seconds and quit anyway if this doesn't happen though */
                        g_idle_add ((GSourceFunc)response_request_quit, NULL);
                        g_timeout_add (5000, (GSourceFunc)quit_timeout_cb, NULL);
                }
        }

        return again;
}
auth_check_idle (GSLockPlug *plug)
{
        gboolean     res;
        gboolean     again;
        static guint loop_counter = 0;

        again = TRUE;
        res = do_auth_check (plug);

        if (res) {
                again = FALSE;
                g_idle_add ((GSourceFunc)quit_response_ok, NULL);
        } else {
                loop_counter++;

                if (loop_counter < MAX_FAILURES) {
                        gs_debug ("Authentication failed, retrying (%u)", loop_counter);
                        g_timeout_add (3000, (GSourceFunc)reset_idle_cb, plug);
                } else {
                        gs_debug ("Authentication failed, quitting (max failures)");
                        again = FALSE;
                         
                        g_idle_add ((GSourceFunc)response_request_quit, NULL);
                        g_timeout_add (5000, (GSourceFunc)quit_timeout_cb, NULL);
                }
        }

        return again;
}