2 * Copyright (C) 2013-2016 Canonical, Ltd.
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.
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.
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/>.
19#include "GreeterPrivate.h"
20#include <QCoreApplication>
23static Greeter *singleton = nullptr;
25GreeterPrivate::GreeterPrivate(Greeter* parent)
26 : m_greeter(new QLightDM::Greeter(parent)),
34Greeter::Greeter(QObject* parent)
36 d_ptr(new GreeterPrivate(this))
40 connect(d->m_greeter, &QLightDM::Greeter::showMessage,
41 this, &Greeter::showMessageFilter);
42 connect(d->m_greeter, &QLightDM::Greeter::showPrompt,
43 this, &Greeter::showPromptFilter);
44 connect(d->m_greeter, &QLightDM::Greeter::authenticationComplete,
45 this, &Greeter::authenticationCompleteFilter);
47 // Don't get stuck waiting for PAM as we shut down.
48 connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit,
49 d->m_greeter, &QLightDM::Greeter::cancelAuthentication);
51 d->m_greeter->connectSync();
59Greeter *Greeter::instance()
62 singleton = new Greeter;
67bool Greeter::isActive() const
73void Greeter::setIsActive(bool active)
76 if (d->m_active != active) {
78 Q_EMIT isActiveChanged();
82bool Greeter::isAuthenticated() const
85 return d->m_greeter->isAuthenticated();
88QString Greeter::authenticationUser() const
91 return d->cachedAuthUser;
94void Greeter::checkAuthenticationUser()
97 if (d->cachedAuthUser != d->m_greeter->authenticationUser()) {
98 d->cachedAuthUser = d->m_greeter->authenticationUser();
99 Q_EMIT authenticationUserChanged();
103QString Greeter::defaultSessionHint() const
106 return d->m_greeter->defaultSessionHint();
109bool Greeter::promptless() const
112 return d->promptless;
115QString Greeter::selectUser() const
118 if (hasGuestAccount() && d->m_greeter->selectGuestHint()) {
119 return QStringLiteral("*guest");
121 return d->m_greeter->selectUserHint();
125bool Greeter::hasGuestAccount() const
128 return d->m_greeter->hasGuestAccountHint();
131bool Greeter::showManualLoginHint() const
134 return d->m_greeter->showManualLoginHint();
137bool Greeter::hideUsersHint() const
140 return d->m_greeter->hideUsersHint();
143void Greeter::authenticate(const QString &username)
146 d->wasPrompted = false;
148 d->promptless = false;
149 Q_EMIT promptlessChanged();
152 if (username == QStringLiteral("*guest")) {
153 d->m_greeter->authenticateAsGuest();
154 } else if (username == QStringLiteral("*other")) {
155 d->m_greeter->authenticate(nullptr);
157 d->m_greeter->authenticate(username);
160 Q_EMIT isAuthenticatedChanged();
161 checkAuthenticationUser();
164void Greeter::respond(const QString &response)
167 d->m_greeter->respond(response);
170bool Greeter::startSessionSync(const QString &session)
173 return d->m_greeter->startSessionSync(session);
176void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type)
179 d->wasPrompted = true;
181 checkAuthenticationUser(); // may have changed in liblightdm
183 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
185 // Strip prompt of any colons at the end
186 QString trimmedText = text.trimmed();
187 if (trimmedText.endsWith(':') || trimmedText.endsWith(QStringLiteral(":"))) {
191 if (trimmedText == "login") {
192 // 'login' is provided untranslated by LightDM when asking for a manual
194 trimmedText = gettext("Username");
197 Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt);
200void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
202 checkAuthenticationUser(); // may have changed in liblightdm
203 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
206void Greeter::authenticationCompleteFilter()
209 if (!d->wasPrompted) {
210 d->promptless = true;
211 Q_EMIT promptlessChanged();
214 Q_EMIT isAuthenticatedChanged();
215 Q_EMIT authenticationComplete();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list