on 01c8faa help sign in
206 lines 3.6 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "Greeter.h"
18#include "GreeterPrivate.h"
19#include <QtCore/QCoreApplication>
20#include <QTimer>
22namespace QLightDM
25Greeter::Greeter(QObject *parent)
26 : QObject(parent),
27 d_ptr(new GreeterPrivate(this))
31Greeter::~Greeter()
35QString Greeter::authenticationUser() const
37 Q_D(const Greeter);
38 return d->authenticationUser;
41bool Greeter::hasGuestAccountHint() const
43 return true;
46QString Greeter::getHint(const QString &name) const
48 Q_UNUSED(name)
49 return "";
52QString Greeter::defaultSessionHint() const
54 return QStringLiteral("ubuntu");
57bool Greeter::hideUsersHint() const
59 return false;
62bool Greeter::showManualLoginHint() const
64 return true;
67bool Greeter::showRemoteLoginHint() const
69 return true;
72bool Greeter::lockHint () const
74 return false;
77QString Greeter::selectUserHint() const
79 Q_D(const Greeter);
80 return d->selectUserHint;
83void Greeter::setSelectUserHint(const QString &selectUserHint)
85 Q_D(Greeter);
86 d->selectUserHint = selectUserHint;
89bool Greeter::selectGuestHint() const
91 return false;
94QString Greeter::autologinUserHint() const
96 return "";
99bool Greeter::autologinGuestHint() const
101 return false;
104int Greeter::autologinTimeoutHint() const
106 return 0;
109bool Greeter::inAuthentication() const
111 return false;
114QString Greeter::hostname() const
116 return "hostname1";
119bool Greeter::isAuthenticated() const
121 Q_D(const Greeter);
122 return d->authenticated;
125bool Greeter::connectSync()
127 return true;
130void Greeter::authenticate(const QString &username)
132 Q_D(Greeter);
134 d->authenticated = false;
135 d->authenticationUser = username;
136 d->twoFactorDone = false;
137 QTimer::singleShot(0, this, &Greeter::delayedAuthentication);
140void Greeter::delayedAuthentication()
142 Q_D(Greeter);
143 d->handleAuthenticate();
146void Greeter::authenticateAsGuest()
147{}
149void Greeter::authenticateAutologin()
150{}
152void Greeter::authenticateRemote(const QString &session, const QString &username)
154 Q_UNUSED(session)
155 Q_UNUSED(username)
158void Greeter::cancelAuthentication()
159{}
161void Greeter::setLanguage (const QString &language)
163 Q_UNUSED(language)
166bool Greeter::startSessionSync(const QString &session)
168 Q_UNUSED(session)
169 return true;
172void Greeter::respond(const QString &response)
174 Q_D(Greeter);
176 d->handleRespond(response);
179void Greeter::sendAuthenticationComplete()
181 if (qgetenv("UNITY_TESTING").isEmpty()) {
182 // simulate PAM's delay
183 QTimer::singleShot(1000, this, &Greeter::authenticationComplete);
184 } else {
185 Q_EMIT authenticationComplete();
186 }
189QString Greeter::mockMode() const
191 Q_D(const Greeter);
192 return d->mockMode;
196void Greeter::setMockMode(QString mockMode)
198 Q_D(Greeter);
200 if (d->mockMode != mockMode) {
201 d->mockMode = mockMode;
202 Q_EMIT mockModeChanged(mockMode);
203 }