2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
16 * Author: Michael Terry <michael.terry@canonical.com>
19#include "AccountsService.h"
20#include "AccountsServiceDBusAdaptor.h"
25AccountsService::AccountsService(QObject* parent)
27 m_service(new AccountsServiceDBusAdaptor(this)),
30 m_enableLauncherWhileLocked(false),
31 m_enableIndicatorsWhileLocked(false),
32 m_statsWelcomeScreen(false),
33 m_passwordDisplayHint(Keyboard),
36 m_hereLicensePath(" ") // blank space means not set yet
38 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
39 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
40 connect(m_service, SIGNAL(maybeChanged(const QString &)),
41 this, SLOT(maybeChanged(const QString &)));
43 setUser(qgetenv("USER"));
46QString AccountsService::user() const
51void AccountsService::setUser(const QString &user)
53 if (user.isEmpty() || m_user == user)
60 updateEnableLauncherWhileLocked();
61 updateEnableIndicatorsWhileLocked();
62 updateBackgroundFile();
63 updateStatsWelcomeScreen();
64 updatePasswordDisplayHint();
67 updateHereLicensePath();
70bool AccountsService::demoEdges() const
75void AccountsService::setDemoEdges(bool demoEdges)
77 m_demoEdges = demoEdges;
78 m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
81bool AccountsService::enableLauncherWhileLocked() const
83 return m_enableLauncherWhileLocked;
86bool AccountsService::enableIndicatorsWhileLocked() const
88 return m_enableIndicatorsWhileLocked;
91QString AccountsService::backgroundFile() const
93 return m_backgroundFile;
96bool AccountsService::statsWelcomeScreen() const
98 return m_statsWelcomeScreen;
101AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const
103 return m_passwordDisplayHint;
106bool AccountsService::hereEnabled() const
108 return m_hereEnabled;
111void AccountsService::setHereEnabled(bool enabled)
113 m_service->setUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted", enabled);
116QString AccountsService::hereLicensePath() const
118 return m_hereLicensePath;
121void AccountsService::updateDemoEdges()
123 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
124 if (m_demoEdges != demoEdges) {
125 m_demoEdges = demoEdges;
126 Q_EMIT demoEdgesChanged();
130void AccountsService::updateEnableLauncherWhileLocked()
132 auto enableLauncherWhileLocked = m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableLauncherWhileLocked").toBool();
133 if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
134 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
135 Q_EMIT enableLauncherWhileLockedChanged();
139void AccountsService::updateEnableIndicatorsWhileLocked()
141 auto enableIndicatorsWhileLocked = m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableIndicatorsWhileLocked").toBool();
142 if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
143 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
144 Q_EMIT enableIndicatorsWhileLockedChanged();
148void AccountsService::updateBackgroundFile()
150 auto backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
151 if (m_backgroundFile != backgroundFile) {
152 m_backgroundFile = backgroundFile;
153 Q_EMIT backgroundFileChanged();
157void AccountsService::updateStatsWelcomeScreen()
159 bool statsWelcomeScreen = m_service->getUserProperty(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen").toBool();
160 if (m_statsWelcomeScreen != statsWelcomeScreen) {
161 m_statsWelcomeScreen = statsWelcomeScreen;
162 Q_EMIT statsWelcomeScreenChanged();
166void AccountsService::updatePasswordDisplayHint()
168 PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "PasswordDisplayHint").toInt();
169 if (m_passwordDisplayHint != passwordDisplayHint) {
170 m_passwordDisplayHint = passwordDisplayHint;
171 Q_EMIT passwordDisplayHintChanged();
175void AccountsService::updateFailedLogins()
177 uint failedLogins = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins").toUInt();
178 if (m_failedLogins != failedLogins) {
179 m_failedLogins = failedLogins;
180 Q_EMIT failedLoginsChanged();
184void AccountsService::updateHereEnabled()
186 bool hereEnabled = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted").toBool();
187 if (m_hereEnabled != hereEnabled) {
188 m_hereEnabled = hereEnabled;
189 Q_EMIT hereEnabledChanged();
193void AccountsService::updateHereLicensePath()
195 QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
197 if (!hereLicensePath.isEmpty() && !QFile::exists(hereLicensePath))
198 hereLicensePath = "";
200 if (m_hereLicensePath != hereLicensePath) {
201 m_hereLicensePath = hereLicensePath;
202 Q_EMIT hereLicensePathChanged();
206uint AccountsService::failedLogins() const
208 return m_failedLogins;
211void AccountsService::setFailedLogins(uint failedLogins)
213 m_failedLogins = failedLogins;
214 m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins", failedLogins);
217void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
219 if (m_user != user) {
223 if (interface == "com.canonical.unity.AccountsService") {
224 if (changed.contains("demo-edges")) {
227 } else if (interface == "com.canonical.unity.AccountsService.Private") {
228 if (changed.contains("FailedLogins")) {
229 updateFailedLogins();
231 } else if (interface == "com.ubuntu.touch.AccountsService.SecurityPrivacy") {
232 if (changed.contains("StatsWelcomeScreen")) {
233 updateStatsWelcomeScreen();
235 } else if (interface == "com.ubuntu.AccountsService.SecurityPrivacy") {
236 if (changed.contains("PasswordDisplayHint")) {
237 updatePasswordDisplayHint();
239 if (changed.contains("EnableLauncherWhileLocked")) {
240 updateEnableLauncherWhileLocked();
242 if (changed.contains("EnableIndicatorsWhileLocked")) {
243 updateEnableIndicatorsWhileLocked();
245 } else if (interface == "com.ubuntu.location.providers.here.AccountsService") {
246 if (changed.contains("LicenseAccepted")) {
249 if (changed.contains("LicenseBasePath")) {
250 updateHereLicensePath();
255void AccountsService::maybeChanged(const QString &user)
257 if (m_user != user) {
261 // Standard properties might have changed
262 updateBackgroundFile();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list