on 1faa856 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_ENUMS(PasswordDisplayHint)
33 Q_PROPERTY (QString user
34 READ user
35 WRITE setUser
36 NOTIFY userChanged)
37 Q_PROPERTY (bool demoEdges
38 READ demoEdges
39 WRITE setDemoEdges
40 NOTIFY demoEdgesChanged)
41 Q_PROPERTY (QStringList demoEdgesCompleted
42 READ demoEdgesCompleted
43 NOTIFY demoEdgesCompletedChanged)
44 Q_PROPERTY (bool enableFingerprintIdentification
45 READ enableFingerprintIdentification
46 NOTIFY enableFingerprintIdentificationChanged)
47 Q_PROPERTY (bool enableLauncherWhileLocked
48 READ enableLauncherWhileLocked
49 NOTIFY enableLauncherWhileLockedChanged)
50 Q_PROPERTY (bool enableIndicatorsWhileLocked
51 READ enableIndicatorsWhileLocked
52 NOTIFY enableIndicatorsWhileLockedChanged)
53 Q_PROPERTY (QString backgroundFile
54 READ backgroundFile
55 NOTIFY backgroundFileChanged)
56 Q_PROPERTY (bool statsWelcomeScreen
57 READ statsWelcomeScreen
58 NOTIFY statsWelcomeScreenChanged)
59 Q_PROPERTY (PasswordDisplayHint passwordDisplayHint
60 READ passwordDisplayHint
61 NOTIFY passwordDisplayHintChanged)
62 Q_PROPERTY (uint failedLogins
63 READ failedLogins
64 WRITE setFailedLogins
65 NOTIFY failedLoginsChanged)
66 Q_PROPERTY (uint failedFingerprintLogins
67 READ failedFingerprintLogins
68 WRITE setFailedFingerprintLogins
69 NOTIFY failedFingerprintLoginsChanged)
70 Q_PROPERTY(bool hereEnabled
71 READ hereEnabled
72 WRITE setHereEnabled
73 NOTIFY hereEnabledChanged)
74 Q_PROPERTY(QString hereLicensePath
75 READ hereLicensePath
76 NOTIFY hereLicensePathChanged)
77 Q_PROPERTY(bool hereLicensePathValid // qml sees a null string as "", so we use proxy setting for that
78 READ hereLicensePathValid
79 NOTIFY hereLicensePathChanged)
80 Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged)
81 Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
82 Q_PROPERTY(QStringList keymaps READ keymaps WRITE setKeymaps NOTIFY keymapsChanged)
84public:
85 enum PasswordDisplayHint {
86 Keyboard,
87 Numeric,
88 };
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