Unity 8
AccountsService.h
1 /*
2  * Copyright (C) 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 #ifndef UNITY_ACCOUNTSSERVICE_H
20 #define UNITY_ACCOUNTSSERVICE_H
21 
22 #include <QObject>
23 #include <QString>
24 
25 class AccountsServiceDBusAdaptor;
26 
27 class AccountsService: public QObject
28 {
29  Q_OBJECT
30  Q_ENUMS(PasswordDisplayHint)
31  Q_PROPERTY (QString user
32  READ user
33  WRITE setUser
34  NOTIFY userChanged)
35  Q_PROPERTY (bool demoEdges
36  READ demoEdges
37  WRITE setDemoEdges
38  NOTIFY demoEdgesChanged)
39  Q_PROPERTY (bool enableLauncherWhileLocked
40  READ enableLauncherWhileLocked
41  NOTIFY enableLauncherWhileLockedChanged)
42  Q_PROPERTY (bool enableIndicatorsWhileLocked
43  READ enableIndicatorsWhileLocked
44  NOTIFY enableIndicatorsWhileLockedChanged)
45  Q_PROPERTY (QString backgroundFile
46  READ backgroundFile
47  NOTIFY backgroundFileChanged)
48  Q_PROPERTY (bool statsWelcomeScreen
49  READ statsWelcomeScreen
50  NOTIFY statsWelcomeScreenChanged)
51  Q_PROPERTY (PasswordDisplayHint passwordDisplayHint
52  READ passwordDisplayHint
53  NOTIFY passwordDisplayHintChanged)
54  Q_PROPERTY (uint failedLogins
55  READ failedLogins
56  WRITE setFailedLogins
57  NOTIFY failedLoginsChanged)
58  Q_PROPERTY(bool hereEnabled
59  READ hereEnabled
60  WRITE setHereEnabled
61  NOTIFY hereEnabledChanged)
62  Q_PROPERTY(QString hereLicensePath
63  READ hereLicensePath
64  NOTIFY hereLicensePathChanged)
65  Q_PROPERTY(bool hereLicensePathValid // qml sees a null string as "", so we use proxy setting for that
66  READ hereLicensePathValid
67  NOTIFY hereLicensePathChanged)
68 
69 public:
70  enum PasswordDisplayHint {
71  Keyboard,
72  Numeric,
73  };
74 
75  explicit AccountsService(QObject *parent = 0);
76 
77  QString user() const;
78  void setUser(const QString &user);
79  bool demoEdges() const;
80  void setDemoEdges(bool demoEdges);
81  bool enableLauncherWhileLocked() const;
82  bool enableIndicatorsWhileLocked() const;
83  QString backgroundFile() const;
84  bool statsWelcomeScreen() const;
85  PasswordDisplayHint passwordDisplayHint() const;
86  uint failedLogins() const;
87  void setFailedLogins(uint failedLogins);
88  bool hereEnabled() const;
89  void setHereEnabled(bool enabled);
90  QString hereLicensePath() const;
91  bool hereLicensePathValid() const;
92 
93 Q_SIGNALS:
94  void userChanged();
95  void demoEdgesChanged();
96  void enableLauncherWhileLockedChanged();
97  void enableIndicatorsWhileLockedChanged();
98  void backgroundFileChanged();
99  void statsWelcomeScreenChanged();
100  void passwordDisplayHintChanged();
101  void failedLoginsChanged();
102  void hereEnabledChanged();
103  void hereLicensePathChanged();
104 
105 private Q_SLOTS:
106  void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
107  void maybeChanged(const QString &user);
108 
109 private:
110  void updateDemoEdges();
111  void updateEnableLauncherWhileLocked();
112  void updateEnableIndicatorsWhileLocked();
113  void updateBackgroundFile();
114  void updateStatsWelcomeScreen();
115  void updatePasswordDisplayHint();
116  void updateFailedLogins();
117  void updateHereEnabled();
118  void updateHereLicensePath();
119 
120  AccountsServiceDBusAdaptor *m_service;
121  QString m_user;
122  bool m_demoEdges;
123  bool m_enableLauncherWhileLocked;
124  bool m_enableIndicatorsWhileLocked;
125  QString m_backgroundFile;
126  bool m_statsWelcomeScreen;
127  PasswordDisplayHint m_passwordDisplayHint;
128  uint m_failedLogins;
129  bool m_hereEnabled;
130  QString m_hereLicensePath;
131 };
132 
133 #endif