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->m_greeter->authenticationUser();
94QString Greeter::defaultSessionHint() const
97 return d->m_greeter->defaultSessionHint();
100bool Greeter::promptless() const
103 return d->promptless;
106QString Greeter::selectUser() const
109 if (hasGuestAccount() && d->m_greeter->selectGuestHint()) {
110 return QStringLiteral("*guest");
112 return d->m_greeter->selectUserHint();
116bool Greeter::hasGuestAccount() const
119 return d->m_greeter->hasGuestAccountHint();
122void Greeter::authenticate(const QString &username)
125 d->wasPrompted = false;
127 d->promptless = false;
128 Q_EMIT promptlessChanged();
131 if (username == QStringLiteral("*guest")) {
132 d->m_greeter->authenticateAsGuest();
134 d->m_greeter->authenticate(username);
137 Q_EMIT isAuthenticatedChanged();
138 Q_EMIT authenticationUserChanged();
141void Greeter::respond(const QString &response)
144 d->m_greeter->respond(response);
147bool Greeter::startSessionSync(const QString &session)
150 return d->m_greeter->startSessionSync(session);
153void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type)
156 d->wasPrompted = true;
158 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
160 // Strip prompt of any colons at the end
161 QString trimmedText = text.trimmed();
162 if (trimmedText.endsWith(':') || trimmedText.endsWith(QStringLiteral(":"))) {
166 Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt);
169void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
171 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
174void Greeter::authenticationCompleteFilter()
177 if (!d->wasPrompted) {
178 d->promptless = true;
179 Q_EMIT promptlessChanged();
182 Q_EMIT isAuthenticatedChanged();
183 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