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"
24AccountsService::AccountsService(QObject* parent)
26 m_service(new AccountsServiceDBusAdaptor(this)),
27 m_user(qgetenv("USER")),
29 m_statsWelcomeScreen(false)
31 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
32 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
33 connect(m_service, SIGNAL(maybeChanged(const QString &)),
34 this, SLOT(maybeChanged(const QString &)));
36 setUser(qgetenv("USER"));
37 updateDemoEdgesForCurrentUser();
40QString AccountsService::user() const
45void AccountsService::setUser(const QString &user)
51 updateBackgroundFile();
52 updateStatsWelcomeScreen();
55bool AccountsService::demoEdges() const
60void AccountsService::setDemoEdges(bool demoEdges)
62 m_demoEdges = demoEdges;
63 m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
66bool AccountsService::demoEdgesForCurrentUser() const
68 return m_demoEdgesForCurrentUser;
71void AccountsService::setDemoEdgesForCurrentUser(bool demoEdgesForCurrentUser)
73 m_demoEdgesForCurrentUser = demoEdgesForCurrentUser;
74 m_service->setUserProperty(qgetenv("USER"), "com.canonical.unity.AccountsService", "demo-edges", demoEdgesForCurrentUser);
77QString AccountsService::backgroundFile() const
79 return m_backgroundFile;
82bool AccountsService::statsWelcomeScreen() const
84 return m_statsWelcomeScreen;
87void AccountsService::updateDemoEdges()
89 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
90 if (m_demoEdges != demoEdges) {
91 m_demoEdges = demoEdges;
92 Q_EMIT demoEdgesChanged();
96void AccountsService::updateDemoEdgesForCurrentUser()
98 auto demoEdgesForCurrentUser = m_service->getUserProperty(qgetenv("USER"), "com.canonical.unity.AccountsService", "demo-edges").toBool();
99 if (m_demoEdgesForCurrentUser != demoEdgesForCurrentUser) {
100 m_demoEdgesForCurrentUser = demoEdgesForCurrentUser;
101 Q_EMIT demoEdgesForCurrentUserChanged();
105void AccountsService::updateBackgroundFile()
107 auto backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
108 if (m_backgroundFile != backgroundFile) {
109 m_backgroundFile = backgroundFile;
110 Q_EMIT backgroundFileChanged();
114void AccountsService::updateStatsWelcomeScreen()
116 bool statsWelcomeScreen = m_service->getUserProperty(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen").toBool();
117 if (m_statsWelcomeScreen != statsWelcomeScreen) {
118 m_statsWelcomeScreen = statsWelcomeScreen;
119 Q_EMIT statsWelcomeScreenChanged();
123void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
125 if (interface == "com.canonical.unity.AccountsService") {
126 if (changed.contains("demo-edges")) {
127 if (qgetenv("USER") == user) {
128 updateDemoEdgesForCurrentUser();
130 if (m_user != user) {
134 } else if (interface == "com.ubuntu.touch.AccountsService.SecurityPrivacy") {
135 if (changed.contains("StatsWelcomeScreen")) {
136 updateStatsWelcomeScreen();
141void AccountsService::maybeChanged(const QString &user)
143 if (m_user == user) {
144 // Standard properties might have changed
145 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