on f621663 help sign in
unity8/tests/mocks/LightDM/Greeter.cpp
178 lines 3.1 kB history raw
1/*
2 * Copyright (C) 2013 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 *
16 * Author: Michael Terry <michael.terry@canonical.com>
17 */
19#include "Greeter.h"
20#include "GreeterPrivate.h"
21#include <QtCore/QCoreApplication>
22#include <QTimer>
24namespace QLightDM
27Greeter::Greeter(QObject *parent)
28 : QObject(parent),
29 d_ptr(new GreeterPrivate(this))
33Greeter::~Greeter()
37QString Greeter::authenticationUser() const
39 Q_D(const Greeter);
40 return d->authenticationUser;
43bool Greeter::hasGuestAccountHint() const
45 return true;
48QString Greeter::getHint(const QString &name) const
50 Q_UNUSED(name)
51 return "";
54QString Greeter::defaultSessionHint() const
56 return "ubuntu";
59bool Greeter::hideUsersHint() const
61 return false;
64bool Greeter::showManualLoginHint() const
66 return true;
69bool Greeter::showRemoteLoginHint() const
71 return true;
74bool Greeter::lockHint () const
76 return false;
79QString Greeter::selectUserHint() const
81 return "";
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 d->handleAuthenticate();
135void Greeter::authenticateAsGuest()
136{}
138void Greeter::authenticateAutologin()
139{}
141void Greeter::authenticateRemote(const QString &session, const QString &username)
143 Q_UNUSED(session)
144 Q_UNUSED(username)
147void Greeter::cancelAuthentication()
148{}
150void Greeter::setLanguage (const QString &language)
152 Q_UNUSED(language)
155bool Greeter::startSessionSync(const QString &session)
157 Q_UNUSED(session)
158 return true;
161void Greeter::respond(const QString &response)
163 Q_D(Greeter);
165 d->handleRespond(response);
168void Greeter::sendAuthenticationComplete()
170 if (qgetenv("UNITY_TESTING").isEmpty()) {
171 // simulate PAM's delay
172 QTimer::singleShot(1000, this, SIGNAL(authenticationComplete()));
173 } else {
174 Q_EMIT authenticationComplete();
175 }