on 34be00a help sign in
201 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;
72QString Greeter::selectUserHint() const
74 Q_D(const Greeter);
75 return d->selectUserHint;
78void Greeter::setSelectUserHint(const QString &selectUserHint)
80 Q_D(Greeter);
81 d->selectUserHint = selectUserHint;
84bool Greeter::selectGuestHint() const
86 return false;
89QString Greeter::autologinUserHint() const
91 return "";
94bool Greeter::autologinGuestHint() const
96 return false;
99int Greeter::autologinTimeoutHint() const
101 return 0;
104bool Greeter::inAuthentication() const
106 return false;
109QString Greeter::hostname() const
111 return "hostname1";
114bool Greeter::isAuthenticated() const
116 Q_D(const Greeter);
117 return d->authenticated;
120bool Greeter::connectSync()
122 return true;
125void Greeter::authenticate(const QString &username)
127 Q_D(Greeter);
129 d->authenticated = false;
130 d->authenticationUser = username;
131 d->twoFactorDone = false;
132 QTimer::singleShot(0, this, &Greeter::delayedAuthentication);
135void Greeter::delayedAuthentication()
137 Q_D(Greeter);
138 d->handleAuthenticate();
141void Greeter::authenticateAsGuest()
142{}
144void Greeter::authenticateAutologin()
145{}
147void Greeter::authenticateRemote(const QString &session, const QString &username)
149 Q_UNUSED(session)
150 Q_UNUSED(username)
153void Greeter::cancelAuthentication()
154{}
156void Greeter::setLanguage (const QString &language)
158 Q_UNUSED(language)
161bool Greeter::startSessionSync(const QString &session)
163 Q_UNUSED(session)
164 return true;
167void Greeter::respond(const QString &response)
169 Q_D(Greeter);
171 d->handleRespond(response);
174void Greeter::sendAuthenticationComplete()
176 if (qgetenv("UNITY_TESTING").isEmpty()) {
177 // simulate PAM's delay
178 QTimer::singleShot(1000, this, &Greeter::authenticationComplete);
179 } else {
180 Q_EMIT authenticationComplete();
181 }
184QString Greeter::mockMode() const
186 Q_D(const Greeter);
187 return d->mockMode;
191void Greeter::setMockMode(QString mockMode)
193 Q_D(Greeter);
195 if (d->mockMode != mockMode) {
196 d->mockMode = mockMode;
197 Q_EMIT mockModeChanged(mockMode);
198 }