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"
22static Greeter *singleton = nullptr;
24GreeterPrivate::GreeterPrivate(Greeter* parent)
25 : m_greeter(new QLightDM::Greeter(parent)),
33Greeter::Greeter(QObject* parent)
35 d_ptr(new GreeterPrivate(this))
39 connect(d->m_greeter, &QLightDM::Greeter::showMessage,
40 this, &Greeter::showMessageFilter);
41 connect(d->m_greeter, &QLightDM::Greeter::showPrompt,
42 this, &Greeter::showPromptFilter);
43 connect(d->m_greeter, &QLightDM::Greeter::authenticationComplete,
44 this, &Greeter::authenticationCompleteFilter);
46 d->m_greeter->connectSync();
54Greeter *Greeter::instance()
57 singleton = new Greeter;
62bool Greeter::isActive() const
68void Greeter::setIsActive(bool active)
71 if (d->m_active != active) {
73 Q_EMIT isActiveChanged();
77bool Greeter::isAuthenticated() const
80 return d->m_greeter->isAuthenticated();
83QString Greeter::authenticationUser() const
86 return d->m_greeter->authenticationUser();
89QString Greeter::defaultSessionHint() const
92 return d->m_greeter->defaultSessionHint();
95bool Greeter::promptless() const
101QString Greeter::selectUser() const
104 if (hasGuestAccount() && d->m_greeter->selectGuestHint()) {
105 return QStringLiteral("*guest");
107 return d->m_greeter->selectUserHint();
111bool Greeter::hasGuestAccount() const
114 return d->m_greeter->hasGuestAccountHint();
117bool Greeter::showManualLoginHint() const
120 return d->m_greeter->showManualLoginHint();
123bool Greeter::hideUsersHint() const
126 return d->m_greeter->hideUsersHint();
129void Greeter::authenticate(const QString &username)
132 d->wasPrompted = false;
134 d->promptless = false;
135 Q_EMIT promptlessChanged();
138 if (username == QStringLiteral("*guest")) {
139 d->m_greeter->authenticateAsGuest();
140 } else if (username == QStringLiteral("*other")) {
141 d->m_greeter->authenticate(nullptr);
143 d->m_greeter->authenticate(username);
146 Q_EMIT isAuthenticatedChanged();
147 Q_EMIT authenticationUserChanged();
150void Greeter::respond(const QString &response)
153 d->m_greeter->respond(response);
156bool Greeter::startSessionSync(const QString &session)
159 return d->m_greeter->startSessionSync(session);
162void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type)
165 d->wasPrompted = true;
167 Q_EMIT authenticationUserChanged(); // may have changed in liblightdm
169 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
171 // Strip prompt of any colons at the end
172 QString trimmedText = text.trimmed();
173 if (trimmedText.endsWith(':') || trimmedText.endsWith(QStringLiteral(":"))) {
177 if (trimmedText == "login") {
178 // 'login' is provided untranslated by LightDM when asking for a manual
180 trimmedText = gettext("Username");
183 Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt);
186void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
188 Q_EMIT authenticationUserChanged(); // may have changed in liblightdm
189 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
192void Greeter::authenticationCompleteFilter()
195 if (!d->wasPrompted) {
196 d->promptless = true;
197 Q_EMIT promptlessChanged();
200 Q_EMIT isAuthenticatedChanged();
201 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