Unity 8
Greeter.h
1 /*
2  * Copyright (C) 2012,2013,2015 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 #ifndef UNITY_GREETER_H
25 #define UNITY_GREETER_H
26 
27 #include <QLightDM/Greeter>
28 #include <QtCore/QObject>
29 
30 class GreeterPrivate;
31 
32 class 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 
43 public:
44  explicit Greeter(QObject* parent=0);
45 
46  bool isActive() const;
47  bool isAuthenticated() const;
48  QString authenticationUser() const;
49  QString defaultSessionHint() const;
50  bool promptless() const;
51  QString selectUser() const;
52 
53 public Q_SLOTS:
54  void authenticate(const QString &username=QString());
55  void respond(const QString &response);
56  bool startSessionSync(const QString &session=QString());
57  void setIsActive(bool isActive);
58 
59 Q_SIGNALS:
60  void showMessage(const QString &text, bool isError);
61  void showPrompt(const QString &text, bool isSecret, bool isDefaultPrompt);
62  void authenticationComplete();
63  void authenticationUserChanged(const QString &user);
64  void isActiveChanged();
65  void isAuthenticatedChanged();
66  void promptlessChanged();
67  void showGreeter();
68  void hideGreeter();
69 
70  // This signal is emitted by external agents like indicators, and the UI
71  // should switch to this user if possible.
72  void requestAuthenticationUser(const QString &user);
73 
74 protected:
75  GreeterPrivate * const d_ptr;
76 
77  Q_DECLARE_PRIVATE(Greeter)
78 
79 private Q_SLOTS:
80  void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
81  void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
82  void authenticationCompleteFilter();
83 };
84 
85 #endif