on beafaa2 help sign in
unity8/plugins/AccountsService/AccountsService.h
172 lines 6.6 kB history raw
1/*
2 * Copyright (C) 2013-2016 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 */
17#ifndef UNITY_ACCOUNTSSERVICE_H
18#define UNITY_ACCOUNTSSERVICE_H
20#include <QHash>
21#include <QObject>
22#include <QString>
23#include <QStringList>
24#include <QVariant>
26class AccountsServiceDBusAdaptor;
27class QDBusInterface;
29class AccountsService: public QObject
31 Q_OBJECT
32 Q_PROPERTY (QString user
33 READ user
34 WRITE setUser
35 NOTIFY userChanged)
36 Q_PROPERTY (bool demoEdges
37 READ demoEdges
38 WRITE setDemoEdges
39 NOTIFY demoEdgesChanged)
40 Q_PROPERTY (QStringList demoEdgesCompleted
41 READ demoEdgesCompleted
42 NOTIFY demoEdgesCompletedChanged)
43 Q_PROPERTY (bool enableFingerprintIdentification
44 READ enableFingerprintIdentification
45 NOTIFY enableFingerprintIdentificationChanged)
46 Q_PROPERTY (bool enableLauncherWhileLocked
47 READ enableLauncherWhileLocked
48 NOTIFY enableLauncherWhileLockedChanged)
49 Q_PROPERTY (bool enableIndicatorsWhileLocked
50 READ enableIndicatorsWhileLocked
51 NOTIFY enableIndicatorsWhileLockedChanged)
52 Q_PROPERTY (QString backgroundFile
53 READ backgroundFile
54 NOTIFY backgroundFileChanged)
55 Q_PROPERTY (bool statsWelcomeScreen
56 READ statsWelcomeScreen
57 NOTIFY statsWelcomeScreenChanged)
58 Q_PROPERTY (PasswordDisplayHint passwordDisplayHint
59 READ passwordDisplayHint
60 NOTIFY passwordDisplayHintChanged)
61 Q_PROPERTY (uint failedLogins
62 READ failedLogins
63 WRITE setFailedLogins
64 NOTIFY failedLoginsChanged)
65 Q_PROPERTY (uint failedFingerprintLogins
66 READ failedFingerprintLogins
67 WRITE setFailedFingerprintLogins
68 NOTIFY failedFingerprintLoginsChanged)
69 Q_PROPERTY(bool hereEnabled
70 READ hereEnabled
71 WRITE setHereEnabled
72 NOTIFY hereEnabledChanged)
73 Q_PROPERTY(QString hereLicensePath
74 READ hereLicensePath
75 NOTIFY hereLicensePathChanged)
76 Q_PROPERTY(bool hereLicensePathValid // qml sees a null string as "", so we use proxy setting for that
77 READ hereLicensePathValid
78 NOTIFY hereLicensePathChanged)
79 Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged)
80 Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
81 Q_PROPERTY(QStringList keymaps READ keymaps WRITE setKeymaps NOTIFY keymapsChanged)
83public:
84 enum PasswordDisplayHint {
85 Keyboard,
86 Numeric,
87 };
88 Q_ENUM(PasswordDisplayHint)
90 explicit AccountsService(QObject *parent = 0, const QString & user = QString());
91 ~AccountsService() = default;
93 QString user() const;
94 void setUser(const QString &user);
95 bool demoEdges() const;
96 void setDemoEdges(bool demoEdges);
97 QStringList demoEdgesCompleted() const;
98 Q_INVOKABLE void markDemoEdgeCompleted(const QString &edge);
99 bool enableFingerprintIdentification() const;
100 bool enableLauncherWhileLocked() const;
101 bool enableIndicatorsWhileLocked() const;
102 QString backgroundFile() const;
103 bool statsWelcomeScreen() const;
104 PasswordDisplayHint passwordDisplayHint() const;
105 uint failedLogins() const;
106 void setFailedLogins(uint failedLogins);
107 uint failedFingerprintLogins() const;
108 void setFailedFingerprintLogins(uint failedFingerprintLogins);
109 bool hereEnabled() const;
110 void setHereEnabled(bool enabled);
111 QString hereLicensePath() const;
112 bool hereLicensePathValid() const;
113 QString realName() const;
114 void setRealName(const QString &realName);
115 QString email() const;
116 void setEmail(const QString &email);
117 QStringList keymaps() const;
118 void setKeymaps(const QStringList &keymaps);
120Q_SIGNALS:
121 void userChanged();
122 void demoEdgesChanged();
123 void demoEdgesCompletedChanged();
124 void enableFingerprintIdentificationChanged();
125 void enableLauncherWhileLockedChanged();
126 void enableIndicatorsWhileLockedChanged();
127 void backgroundFileChanged();
128 void statsWelcomeScreenChanged();
129 void passwordDisplayHintChanged();
130 void failedLoginsChanged();
131 void failedFingerprintLoginsChanged();
132 void hereEnabledChanged();
133 void hereLicensePathChanged();
134 void realNameChanged();
135 void emailChanged();
136 void keymapsChanged();
138private Q_SLOTS:
139 void onPropertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
140 void onMaybeChanged(const QString &user);
142private:
143 typedef QVariant (*ProxyConverter)(const QVariant &);
145 void refresh(bool async);
146 void registerProperty(const QString &interface, const QString &property, const QString &signal);
147 void registerProxy(const QString &interface, const QString &property, QDBusInterface *iface, const QString &method, ProxyConverter converter = nullptr);
149 void updateAllProperties(const QString &interface, bool async);
150 void updateProperty(const QString &interface, const QString &property);
151 void updateCache(const QString &interface, const QString &property, const QVariant &value);
153 void setProperty(const QString &interface, const QString &property, const QVariant &value);
154 QVariant getProperty(const QString &interface, const QString &property) const;
156 void emitChangedForProperty(const QString &interface, const QString &property);
158 struct PropertyInfo {
159 QVariant value{};
160 QString signal{};
161 QDBusInterface *proxyInterface{};
162 QString proxyMethod{};
163 ProxyConverter proxyConverter{};
164 };
165 typedef QHash< QString, QHash<QString, PropertyInfo> > PropertyHash;
166 PropertyHash m_properties;
167 AccountsServiceDBusAdaptor *m_service;
168 QDBusInterface *m_unityInput;
169 QString m_user;
170};
172#endif