Lomiri
Loading...
Searching...
No Matches
Greeter.h
1/*
2 * Copyright (C) 2012-2016 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 */
17
18/* This class is a really tiny filter around QLightDM::Greeter. There are some
19 operations that we want to edit a bit for the benefit of Qml. Specifically,
20 we want to chop colons off of any password prompts. But there may be more
21 such edits in the future, and by inserting ourselves here, we have more
22 control. */
23
24#pragma once
25
26#include <QLightDM/Greeter>
27#include <QtCore/QObject>
28
29class GreeterPrivate;
30class PromptsModel;
31
32class Greeter : public QObject
33{
34 Q_OBJECT
35
36 Q_PROPERTY(bool active READ isActive WRITE setIsActive NOTIFY isActiveChanged)
37 Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
38 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
39 Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT)
40 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41 Q_PROPERTY(QString selectUser READ selectUser CONSTANT)
42
43public:
44 static Greeter *instance();
45 virtual ~Greeter();
46
47 bool isActive() const;
48 bool isAuthenticated() const;
49 QString authenticationUser() const;
50 QString defaultSessionHint() const;
51 bool promptless() const;
52 QString selectUser() const;
53 bool hasGuestAccount() const;
54 bool showManualLoginHint() const;
55 bool hideUsersHint() const;
56
57 PromptsModel *promptsModel();
58
59public Q_SLOTS:
60 void authenticate(const QString &username=QString());
61 void respond(const QString &response);
62 bool startSessionSync(const QString &session=QString());
63 void setIsActive(bool isActive);
64
65Q_SIGNALS:
66 void authenticationUserChanged();
67 void isActiveChanged();
68 void isAuthenticatedChanged();
69 void promptlessChanged();
70 void showGreeter();
71 void hideGreeter();
72 void loginError(bool automatic);
73 void loginSuccess(bool automatic);
74 void authenticationStarted(); // useful for testing
75
76 // This signal is emitted by external agents like indicators, and the UI
77 // should switch to this user if possible.
78 void requestAuthenticationUser(const QString &user);
79
80protected:
81 explicit Greeter(QObject* parent=0);
82
83 GreeterPrivate * const d_ptr;
84
85 Q_DECLARE_PRIVATE(Greeter)
86
87private Q_SLOTS:
88 void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
89 void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
90 void authenticationCompleteFilter();
91 void checkAuthenticationUser();
92};