on e82ae4e help sign in
unity8/plugins/AccountsService/AccountsService.h
161 lines 5.9 kB history raw
1/*
2 * Copyright (C) 2013, 2015 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 enableLauncherWhileLocked
45 READ enableLauncherWhileLocked
46 NOTIFY enableLauncherWhileLockedChanged)
47 Q_PROPERTY (bool enableIndicatorsWhileLocked
48 READ enableIndicatorsWhileLocked
49 NOTIFY enableIndicatorsWhileLockedChanged)
50 Q_PROPERTY (QString backgroundFile
51 READ backgroundFile
52 NOTIFY backgroundFileChanged)
53 Q_PROPERTY (bool statsWelcomeScreen
54 READ statsWelcomeScreen
55 NOTIFY statsWelcomeScreenChanged)
56 Q_PROPERTY (PasswordDisplayHint passwordDisplayHint
57 READ passwordDisplayHint
58 NOTIFY passwordDisplayHintChanged)
59 Q_PROPERTY (uint failedLogins
60 READ failedLogins
61 WRITE setFailedLogins
62 NOTIFY failedLoginsChanged)
63 Q_PROPERTY(bool hereEnabled
64 READ hereEnabled
65 WRITE setHereEnabled
66 NOTIFY hereEnabledChanged)
67 Q_PROPERTY(QString hereLicensePath
68 READ hereLicensePath
69 NOTIFY hereLicensePathChanged)
70 Q_PROPERTY(bool hereLicensePathValid // qml sees a null string as "", so we use proxy setting for that
71 READ hereLicensePathValid
72 NOTIFY hereLicensePathChanged)
73 Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged)
74 Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
75 Q_PROPERTY(QStringList keymaps
76 READ keymaps
77 NOTIFY keymapsChanged)
79public:
80 enum PasswordDisplayHint {
81 Keyboard,
82 Numeric,
83 };
85 explicit AccountsService(QObject *parent = 0, const QString & user = QString());
86 ~AccountsService() = default;
88 QString user() const;
89 void setUser(const QString &user);
90 bool demoEdges() const;
91 void setDemoEdges(bool demoEdges);
92 QStringList demoEdgesCompleted() const;
93 Q_INVOKABLE void markDemoEdgeCompleted(const QString &edge);
94 bool enableLauncherWhileLocked() const;
95 bool enableIndicatorsWhileLocked() const;
96 QString backgroundFile() const;
97 bool statsWelcomeScreen() const;
98 PasswordDisplayHint passwordDisplayHint() const;
99 uint failedLogins() const;
100 void setFailedLogins(uint failedLogins);
101 bool hereEnabled() const;
102 void setHereEnabled(bool enabled);
103 QString hereLicensePath() const;
104 bool hereLicensePathValid() const;
105 QString realName() const;
106 void setRealName(const QString &realName);
107 QString email() const;
108 void setEmail(const QString &email);
109 QStringList keymaps() const;
111Q_SIGNALS:
112 void userChanged();
113 void demoEdgesChanged();
114 void demoEdgesCompletedChanged();
115 void enableLauncherWhileLockedChanged();
116 void enableIndicatorsWhileLockedChanged();
117 void backgroundFileChanged();
118 void statsWelcomeScreenChanged();
119 void passwordDisplayHintChanged();
120 void failedLoginsChanged();
121 void hereEnabledChanged();
122 void hereLicensePathChanged();
123 void realNameChanged();
124 void emailChanged();
125 void keymapsChanged();
127private Q_SLOTS:
128 void onPropertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
129 void onMaybeChanged(const QString &user);
131private:
132 typedef QVariant (*ProxyConverter)(const QVariant &);
134 void refresh(bool async);
135 void registerProperty(const QString &interface, const QString &property, const QString &signal);
136 void registerProxy(const QString &interface, const QString &property, QDBusInterface *iface, const QString &method, ProxyConverter converter = nullptr);
138 void updateAllProperties(const QString &interface, bool async);
139 void updateProperty(const QString &interface, const QString &property);
140 void updateCache(const QString &interface, const QString &property, const QVariant &value);
142 void setProperty(const QString &interface, const QString &property, const QVariant &value);
143 QVariant getProperty(const QString &interface, const QString &property) const;
145 void emitChangedForProperty(const QString &interface, const QString &property);
147 struct PropertyInfo {
148 QVariant value{};
149 QString signal{};
150 QDBusInterface *proxyInterface{};
151 QString proxyMethod{};
152 ProxyConverter proxyConverter{};
153 };
154 typedef QHash< QString, QHash<QString, PropertyInfo> > PropertyHash;
155 PropertyHash m_properties;
156 AccountsServiceDBusAdaptor *m_service;
157 QDBusInterface *m_unityInput;
158 QString m_user;
159};
161#endif