Unity 8
Greeter.h
1 /*
2  * Copyright (C) 2012,2013 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  * Authors: Michael Terry <michael.terry@canonical.com>
17  */
18 
19 /* This class is a really tiny filter around QLightDM::Greeter. There are some
20  operations that we want to edit a bit for the benefit of Qml. Specifically,
21  we want to chop colons off of any password prompts. But there may be more
22  such edits in the future, and by inserting ourselves here, we have more
23  control. */
24 
25 #ifndef UNITY_GREETER_H
26 #define UNITY_GREETER_H
27 
28 #include <QLightDM/Greeter>
29 #include <QtCore/QObject>
30 
31 class GreeterPrivate;
32 
33 class Greeter : public QObject
34 {
35  Q_OBJECT
36 
37  Q_PROPERTY(bool active READ isActive WRITE setIsActive NOTIFY isActiveChanged)
38  Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
39  Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
40  Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41 
42 public:
43  explicit Greeter(QObject* parent=0);
44 
45  bool isActive() const;
46  bool isAuthenticated() const;
47  QString authenticationUser() const;
48  bool promptless() const;
49 
50 public Q_SLOTS:
51  void authenticate(const QString &username=QString());
52  void respond(const QString &response);
53  bool startSessionSync(const QString &session=QString());
54  void setIsActive(bool isActive);
55 
56 Q_SIGNALS:
57  void showMessage(const QString &text, bool isError);
58  void showPrompt(const QString &text, bool isSecret, bool isDefaultPrompt);
59  void authenticationComplete();
60  void authenticationUserChanged(const QString &user);
61  void isActiveChanged();
62  void isAuthenticatedChanged();
63  void promptlessChanged();
64  void showGreeter();
65  void hideGreeter();
66 
67  // This signal is emitted by external agents like indicators, and the UI
68  // should switch to this user if possible.
69  void requestAuthenticationUser(const QString &user);
70 
71 protected:
72  GreeterPrivate * const d_ptr;
73 
74  Q_DECLARE_PRIVATE(Greeter)
75 
76 private Q_SLOTS:
77  void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
78  void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
79  void authenticationCompleteFilter();
80 };
81 
82 #endif