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();
117void Greeter::authenticate(const QString &username)
120 d->wasPrompted = false;
122 d->promptless = false;
123 Q_EMIT promptlessChanged();
126 if (username == QStringLiteral("*guest")) {
127 d->m_greeter->authenticateAsGuest();
129 d->m_greeter->authenticate(username);
132 Q_EMIT isAuthenticatedChanged();
133 Q_EMIT authenticationUserChanged();
136void Greeter::respond(const QString &response)
139 d->m_greeter->respond(response);
142bool Greeter::startSessionSync(const QString &session)
145 return d->m_greeter->startSessionSync(session);
148void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type)
151 d->wasPrompted = true;
153 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
155 // Strip prompt of any colons at the end
156 QString trimmedText = text.trimmed();
157 if (trimmedText.endsWith(':') || trimmedText.endsWith(QStringLiteral(":"))) {
161 Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt);
164void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
166 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
169void Greeter::authenticationCompleteFilter()
172 if (!d->wasPrompted) {
173 d->promptless = true;
174 Q_EMIT promptlessChanged();
177 Q_EMIT isAuthenticatedChanged();
178 Q_EMIT authenticationComplete();
181QObject *Greeter::mock()
184 return d->m_greeter->property("mock").value<QObject*>();
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