File indexing completed on 2024-06-23 05:28:19

0001 /*
0002 This file is part of LightDM-KDE.
0003 
0004 Copyright 2012 David Edmundson <kde@davidedmundson.co.uk>
0005 
0006 LightDM-KDE is free software: you can redistribute it and/or modify
0007 it under the terms of the GNU General Public License as published by
0008 the Free Software Foundation, either version 3 of the License, or
0009 (at your option) any later version.
0010 
0011 LightDM-KDE is distributed in the hope that it will be useful,
0012 but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 GNU General Public License for more details.
0015 
0016 You should have received a copy of the GNU General Public License
0017 along with LightDM-KDE.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 #include "fakegreeter.h"
0020 
0021 #include <KDebug>
0022 
0023 #include <QApplication>
0024 #include <QTimer>
0025 
0026 FakeGreeter::FakeGreeter(QObject *parent) :
0027     QLightDM::Greeter(parent)
0028 {
0029     m_isAuthenticated = false;
0030 }
0031 
0032 FakeGreeter::~FakeGreeter()
0033 {
0034 
0035 }
0036 
0037 QString FakeGreeter::lastLoggedInUser() const
0038 {
0039     return QString();
0040 }
0041 
0042 QString FakeGreeter::guestLoginName() const
0043 {
0044     return QLatin1String("*guest");
0045 }
0046 
0047 bool FakeGreeter::isAuthenticated() const
0048 {
0049     return m_isAuthenticated;
0050 }
0051 
0052 bool FakeGreeter::connectSync()
0053 {
0054     return true;
0055 }
0056 
0057 void FakeGreeter::authenticate(const QString &username)
0058 {
0059     kDebug() << "authenticating as " << username;
0060     //emit showPrompt in 4 seconds
0061     QTimer::singleShot(4*1000, this, SLOT(onAuthenticationTimerExpired()));
0062 }
0063 
0064 void FakeGreeter::authenticateAsGuest()
0065 {
0066     Q_EMIT authenticationComplete();
0067 }
0068 
0069 void FakeGreeter::respond(const QString &response)
0070 {
0071     Q_UNUSED(response)
0072     m_isAuthenticated = true;
0073     Q_EMIT authenticationComplete();
0074 }
0075 
0076 bool FakeGreeter::startSessionSync(const QString &session)
0077 {
0078     kDebug() << "starting session " << session;
0079     QApplication::instance()->quit();
0080     return true;
0081 }
0082 
0083 void FakeGreeter::onAuthenticationTimerExpired()
0084 {
0085     Q_EMIT showPrompt("Password:", QLightDM::Greeter::PromptTypeQuestion);
0086 }