2 * Copyright 2013 Canonical Ltd.
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.
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.
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/>
17 * Authored by: Michael Terry <michael.terry@canonical.com>
20#include "PropertiesServer.h"
21#include "AccountsService.h"
25#include <QDBusMessage>
26#include <QDBusMetaType>
28PropertiesServer::PropertiesServer(QObject *parent)
31 qDBusRegisterMetaType<QList<QVariantMap>>();
35QDBusVariant PropertiesServer::Get(const QString &interface, const QString &property) const
37 if (m_properties.contains(interface) && m_properties[interface].contains(property)) {
38 return QDBusVariant(m_properties[interface][property]);
40 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
41 return QDBusVariant(QVariant());
45QVariantMap PropertiesServer::GetAll(const QString &interface) const
47 if (m_properties.contains(interface)) {
48 return m_properties[interface];
50 sendErrorReply(QDBusError::InvalidArgs, "Bad interface");
55void PropertiesServer::Set(const QString &interface, const QString &property, const QDBusVariant &variant)
57 QVariant newValue = variant.variant();
59 if (m_properties[interface].contains(property)) {
60 QVariant& oldValue = m_properties[interface][property];
61 if (oldValue != newValue) {
62 // complex types have an extra layer of wrapping via QDBusArgument
63 if (interface == QStringLiteral("com.canonical.unity.AccountsService") &&
64 property == QStringLiteral("LauncherItems")) {
65 newValue = QVariant::fromValue(qdbus_cast<QList<QVariantMap>>(newValue.value<QDBusArgument>()));
70 // Special case for user properties.
71 if (interface == "org.freedesktop.Accounts.User") {
74 QVariantMap propertyChanges;
75 propertyChanges[property] = newValue;
76 Q_EMIT PropertiesChanged(interface, propertyChanges, QStringList());
78 // FIXME: Here to replicate current behaviour
79 // Not sure why accounts-service is triggering Changed when we're
80 // emitting PropertyChanges from org.freedesktop.DBus.Properties as well.
85 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
89void PropertiesServer::Reset()
91 m_properties["com.canonical.unity.AccountsService"]["demo-edges"] = false;
92 m_properties["com.canonical.unity.AccountsService"]["LauncherItems"] = QVariant::fromValue(QList<QVariantMap>());
93 m_properties["com.canonical.unity.AccountsService.Private"]["FailedLogins"] = 0;
94 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;
95 m_properties["com.ubuntu.AccountsService.Input"]["MousePrimaryButton"] = "right";
96 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;
97 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;
98 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;
99 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false;
100 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = "";
101 m_properties["org.freedesktop.Accounts.User"]["BackgroundFile"] = "";
102 m_properties["org.freedesktop.Accounts.User"]["RealName"] = "";
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