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>
28using StringMap = QMap<QString,QString>;
29using StringMapList = QList<StringMap>;
30Q_DECLARE_METATYPE(StringMapList)
32PropertiesServer::PropertiesServer(QObject *parent)
35 qDBusRegisterMetaType<QList<QVariantMap>>();
36 qDBusRegisterMetaType<StringMap>();
37 qDBusRegisterMetaType<StringMapList>();
41QDBusVariant PropertiesServer::Get(const QString &interface, const QString &property) const
43 if (m_properties.contains(interface) && m_properties[interface].contains(property)) {
44 return QDBusVariant(m_properties[interface][property]);
46 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
47 return QDBusVariant(QVariant());
51QVariantMap PropertiesServer::GetAll(const QString &interface) const
53 if (m_properties.contains(interface)) {
54 return m_properties[interface];
56 sendErrorReply(QDBusError::InvalidArgs, "Bad interface");
61void PropertiesServer::Set(const QString &interface, const QString &property, const QDBusVariant &variant)
63 QVariant newValue = variant.variant();
65 if (m_properties[interface].contains(property)) {
66 QVariant& oldValue = m_properties[interface][property];
67 if (oldValue != newValue) {
68 // complex types have an extra layer of wrapping via QDBusArgument
69 if (interface == QStringLiteral("com.canonical.unity.AccountsService") &&
70 property == QStringLiteral("LauncherItems")) {
71 newValue = QVariant::fromValue(qdbus_cast<QList<QVariantMap>>(newValue.value<QDBusArgument>()));
72 } else if (interface == "org.freedesktop.Accounts.User" && property == "InputSources") {
73 newValue = QVariant::fromValue(qdbus_cast<StringMapList>(newValue.value<QDBusArgument>()));
78 // Special case for user properties.
79 if (interface == "org.freedesktop.Accounts.User") {
82 QVariantMap propertyChanges;
83 propertyChanges[property] = newValue;
84 Q_EMIT PropertiesChanged(interface, propertyChanges, QStringList());
86 // FIXME: Here to replicate current behaviour
87 // Not sure why accounts-service is triggering Changed when we're
88 // emitting PropertyChanges from org.freedesktop.DBus.Properties as well.
93 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
97void PropertiesServer::Reset()
99 m_properties["com.canonical.unity.AccountsService"]["demo-edges"] = false;
100 m_properties["com.canonical.unity.AccountsService"]["DemoEdgesCompleted"] = QStringList();
101 m_properties["com.canonical.unity.AccountsService"]["LauncherItems"] = QVariant::fromValue(QList<QVariantMap>());
102 m_properties["com.canonical.unity.AccountsService.Private"]["FailedLogins"] = 0;
103 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;
104 m_properties["com.ubuntu.AccountsService.Input"]["MousePrimaryButton"] = "right";
105 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;
106 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;
107 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;
108 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false;
109 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = "";
110 m_properties["org.freedesktop.Accounts.User"]["BackgroundFile"] = "";
111 m_properties["org.freedesktop.Accounts.User"]["RealName"] = "";
112 m_properties["org.freedesktop.Accounts.User"]["InputSources"] = QVariant::fromValue(StringMapList());
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