Unity 8
 All Classes Functions Properties
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 authenticated READ isAuthenticated)
38  Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
39  Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
40 
41 public:
42  explicit Greeter(QObject* parent=0);
43 
44  bool isAuthenticated() const;
45  QString authenticationUser() const;
46  bool promptless() const;
47 
48 public Q_SLOTS:
49  void authenticate(const QString &username=QString());
50  void respond(const QString &response);
51  bool startSessionSync(const QString &session=QString());
52 
53 Q_SIGNALS:
54  void showMessage(const QString &text, bool isError);
55  void showPrompt(const QString &text, bool isSecret);
56  void authenticationComplete();
57  void authenticationUserChanged(const QString &user);
58  void promptlessChanged();
59 
60  // This signal is emitted by external agents like indicators, and the UI
61  // should switch to this user if possible.
62  void requestAuthenticationUser(const QString &user);
63 
64 private:
65  GreeterPrivate * const d_ptr;
66 
67  Q_DECLARE_PRIVATE(Greeter)
68 
69 private Q_SLOTS:
70  void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
71  void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
72  void authenticationCompleteFilter();
73 };
74 
75 #endif