on b7cf5ea help sign in
unity8/tests/mocks/AccountsService/AccountsService.cpp
235 lines 5.5 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#include "AccountsService.h"
19#include <paths.h>
21AccountsService::AccountsService(QObject* parent)
22 : QObject(parent),
23 m_enableFingerprintIdentification(true),
24 m_enableLauncherWhileLocked(true),
25 m_enableIndicatorsWhileLocked(true),
26 m_backgroundFile(qmlDirectory() + "/graphics/phone_background.jpg"),
27 m_statsWelcomeScreen(true),
28 m_failedLogins(0),
29 m_failedFingerprintLogins(0),
30 m_demoEdges(false),
31 m_demoEdgesCompleted(),
32 m_hereEnabled(false),
33 m_hereLicensePath("")
37QString AccountsService::user() const
39 return m_user;
42void AccountsService::setUser(const QString &user)
44 m_user = user;
45 Q_EMIT userChanged();
46 Q_EMIT passwordDisplayHintChanged();
49bool AccountsService::demoEdges() const
51 return m_demoEdges;
54void AccountsService::setDemoEdges(bool demoEdges)
56 m_demoEdges = demoEdges;
57 Q_EMIT demoEdgesChanged();
60QStringList AccountsService::demoEdgesCompleted() const
62 return m_demoEdgesCompleted;
65void AccountsService::markDemoEdgeCompleted(const QString &edge)
67 if (!m_demoEdgesCompleted.contains(edge)) {
68 m_demoEdgesCompleted << edge;
69 Q_EMIT demoEdgesCompletedChanged();
70 }
73void AccountsService::setDemoEdgesCompleted(const QStringList &demoEdgesCompleted)
75 m_demoEdgesCompleted = demoEdgesCompleted;
76 Q_EMIT demoEdgesCompletedChanged();
79bool AccountsService::enableFingerprintIdentification() const
81 return m_enableFingerprintIdentification;
84void AccountsService::setEnableFingerprintIdentification(bool enableFingerprintIdentification)
86 m_enableFingerprintIdentification = enableFingerprintIdentification;
87 Q_EMIT enableFingerprintIdentificationChanged();
90bool AccountsService::enableLauncherWhileLocked() const
92 return m_enableLauncherWhileLocked;
95void AccountsService::setEnableLauncherWhileLocked(bool enableLauncherWhileLocked)
97 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
98 Q_EMIT enableLauncherWhileLockedChanged();
101bool AccountsService::enableIndicatorsWhileLocked() const
103 return m_enableIndicatorsWhileLocked;
106void AccountsService::setEnableIndicatorsWhileLocked(bool enableIndicatorsWhileLocked)
108 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
109 Q_EMIT enableIndicatorsWhileLockedChanged();
112QString AccountsService::backgroundFile() const
114 return m_backgroundFile;
117void AccountsService::setBackgroundFile(const QString &backgroundFile)
119 m_backgroundFile = backgroundFile;
120 backgroundFileChanged();
123bool AccountsService::statsWelcomeScreen() const
125 return m_statsWelcomeScreen;
128void AccountsService::setStatsWelcomeScreen(bool statsWelcomeScreen)
130 m_statsWelcomeScreen = statsWelcomeScreen;
131 statsWelcomeScreenChanged();
134AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const
136 if (m_user == "has-pin")
137 return PasswordDisplayHint::Numeric;
138 else
139 return PasswordDisplayHint::Keyboard;
142uint AccountsService::failedLogins() const
144 return m_failedLogins;
147void AccountsService::setFailedLogins(uint failedLogins)
149 m_failedLogins = failedLogins;
150 failedLoginsChanged();
153uint AccountsService::failedFingerprintLogins() const
155 return m_failedFingerprintLogins;
158void AccountsService::setFailedFingerprintLogins(uint failedFingerprintLogins)
160 m_failedFingerprintLogins = failedFingerprintLogins;
161 failedFingerprintLoginsChanged();
164bool AccountsService::hereEnabled() const
166 return m_hereEnabled;
169void AccountsService::setHereEnabled(bool enabled)
171 m_hereEnabled = enabled;
172 hereEnabledChanged();
175QString AccountsService::hereLicensePath() const
177 return m_hereLicensePath;
180void AccountsService::setHereLicensePath(const QString &path)
182 // Path should always be valid (this code is all synchronous)
183 if (path == " ") {
184 m_hereLicensePath = QString::null;
185 } else if (path.isNull()) { // because qml collapses null and empty
186 m_hereLicensePath = "";
187 } else {
188 m_hereLicensePath = path;
189 }
190 hereLicensePathChanged();
193bool AccountsService::hereLicensePathValid() const
195 return !m_hereLicensePath.isNull();
198QString AccountsService::realName() const
200 return m_realName;
203void AccountsService::setRealName(const QString &realName)
205 m_realName = realName;
206 Q_EMIT realNameChanged();
209QString AccountsService::email() const
211 return m_email;
214void AccountsService::setEmail(const QString &email)
216 m_email = email;
217 Q_EMIT emailChanged();
220QStringList AccountsService::keymaps() const
222 if (!m_kbdMap.isEmpty()) {
223 return m_kbdMap;
224 }
226 return {QStringLiteral("us")};
229void AccountsService::setKeymaps(const QStringList &keymaps)
231 if (keymaps != m_kbdMap) {
232 m_kbdMap = keymaps;
233 Q_EMIT keymapsChanged();
234 }