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, const QString & user = QString());
76  ~AccountsService() = default;
77 
78  QString user() const;
79  void setUser(const QString &user);
80  bool demoEdges() const;
81  void setDemoEdges(bool demoEdges);
82  bool enableLauncherWhileLocked() const;
83  bool enableIndicatorsWhileLocked() const;
84  QString backgroundFile() const;
85  bool statsWelcomeScreen() const;
86  PasswordDisplayHint passwordDisplayHint() const;
87  uint failedLogins() const;
88  void setFailedLogins(uint failedLogins);
89  bool hereEnabled() const;
90  void setHereEnabled(bool enabled);
91  QString hereLicensePath() const;
92  bool hereLicensePathValid() const;
93 
94 Q_SIGNALS:
95  void userChanged();
96  void demoEdgesChanged();
97  void enableLauncherWhileLockedChanged();
98  void enableIndicatorsWhileLockedChanged();
99  void backgroundFileChanged();
100  void statsWelcomeScreenChanged();
101  void passwordDisplayHintChanged();
102  void failedLoginsChanged();
103  void hereEnabledChanged();
104  void hereLicensePathChanged();
105 
106 private Q_SLOTS:
107  void onPropertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
108  void onMaybeChanged(const QString &user);
109 
110 private:
111  void updateDemoEdges(bool async = true);
112  void updateEnableLauncherWhileLocked(bool async = true);
113  void updateEnableIndicatorsWhileLocked(bool async = true);
114  void updateBackgroundFile(bool async = true);
115  void updateStatsWelcomeScreen(bool async = true);
116  void updatePasswordDisplayHint(bool async = true);
117  void updateFailedLogins(bool async = true);
118  void updateHereEnabled(bool async = true);
119  void updateHereLicensePath(bool async = true);
120 
121  AccountsServiceDBusAdaptor *m_service;
122  QString m_user;
123  bool m_demoEdges;
124  bool m_enableLauncherWhileLocked;
125  bool m_enableIndicatorsWhileLocked;
126  QString m_backgroundFile;
127  bool m_statsWelcomeScreen;
128  PasswordDisplayHint m_passwordDisplayHint;
129  uint m_failedLogins;
130  bool m_hereEnabled;
131  QString m_hereLicensePath;
132 };
133 
134 #endif