on 2fa460b help sign in
unity8/tests/plugins/AccountsService/PropertiesServer.cpp
82 lines 3.3 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Michael Terry <michael.terry@canonical.com>
18 */
20#include "PropertiesServer.h"
21#include "AccountsService.h"
23// Qt
24#include <QDebug>
25#include <QDBusMessage>
27PropertiesServer::PropertiesServer(QObject *parent)
28 : QObject(parent)
30 Reset();
33QDBusVariant PropertiesServer::Get(const QString &interface, const QString &property)
35 if (m_properties[interface].contains(property)) {
36 return QDBusVariant(m_properties[interface][property]);
37 } else {
38 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
39 return QDBusVariant(QVariant());
40 }
43void PropertiesServer::Set(const QString &interface, const QString &property, const QDBusVariant &variant)
45 QVariant newValue = variant.variant();
47 if (m_properties[interface].contains(property)) {
48 QVariant& oldValue = m_properties[interface][property];
49 if (oldValue != newValue) {
50 oldValue = newValue;
52 // Special case for Background file.
53 if (interface == "org.freedesktop.Accounts.User" && property == "BackgroundFile") {
54 Q_EMIT Changed();
55 } else {
56 QVariantMap propertyChanges;
57 propertyChanges[property] = newValue;
58 Q_EMIT PropertiesChanged(interface, propertyChanges, QStringList());
60 // FIXME: Here to replicate current behaviour
61 // Not sure why accounts-service is triggering Changed when we're
62 // emitting PropertyChanges from org.freedesktop.DBus.Properties as well.
63 Q_EMIT Changed();
64 }
65 }
66 } else {
67 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
68 }
71void PropertiesServer::Reset()
73 m_properties["com.canonical.unity.AccountsService"]["demo-edges"] = false;
74 m_properties["com.canonical.unity.AccountsService.Private"]["FailedLogins"] = 0;
75 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;
76 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;
77 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;
78 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;
79 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false;
80 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = "";
81 m_properties["org.freedesktop.Accounts.User"]["BackgroundFile"] = "";