2
* This file is part of system-settings
4
* Copyright (C) 2014 Canonical Ltd.
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 3, as published
8
* by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranties of
12
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
* PURPOSE. See the GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include <QDBusInterface>
21
#include <QDBusPendingCall>
22
#include <QDBusPendingReply>
26
#define HERE_IFACE "com.ubuntu.location.providers.here.AccountsService"
27
#define ENABLED_PROP "LicenseAccepted"
28
#define PATH_PROP "LicenseBasePath"
34
m_hereLicensePath(" ") // use a single space to indicate it is unasssigned
36
m_accounts = new QDBusInterface("org.freedesktop.Accounts",
37
"/org/freedesktop/Accounts/User" + QString::number(geteuid()),
38
"org.freedesktop.DBus.Properties",
39
QDBusConnection::systemBus(),
42
m_accounts->connection().connect(m_accounts->service(),
44
m_accounts->interface(),
47
SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
49
QDBusPendingCall call = m_accounts->asyncCall("Get", HERE_IFACE, PATH_PROP);
50
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
51
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)),
52
this, SLOT(getHereLicensePathFinished(QDBusPendingCallWatcher *)));
55
void System::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalid)
57
if (interface == HERE_IFACE) {
58
if (changed.contains(ENABLED_PROP)) {
59
m_hereEnabled = changed[ENABLED_PROP].toBool();
60
Q_EMIT hereEnabledChanged();
61
} else if (invalid.contains(ENABLED_PROP)) {
62
QDBusPendingCall call = m_accounts->asyncCall("Get", HERE_IFACE, ENABLED_PROP);
63
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
64
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)),
65
this, SLOT(getHereEnabledFinished(QDBusPendingCallWatcher *)));
70
void System::getHereEnabledFinished(QDBusPendingCallWatcher *watcher)
72
QDBusPendingReply<QVariant> reply = *watcher;
73
if (!reply.isError()) {
74
QVariant value = reply.argumentAt<0>();
75
m_hereEnabled = value.toBool();
76
Q_EMIT hereEnabledChanged();
78
watcher->deleteLater();
81
void System::getHereLicensePathFinished(QDBusPendingCallWatcher *watcher)
83
QDBusPendingReply<QVariant> reply = *watcher;
84
if (!reply.isError()) {
85
QVariant value = reply.argumentAt<0>();
86
m_hereLicensePath = value.toString();
88
m_hereLicensePath = "";
91
Q_EMIT hereLicensePathChanged();
93
watcher->deleteLater();
96
bool System::hereEnabled() const
101
void System::setHereEnabled(bool enabled)
103
m_accounts->asyncCall("Set", HERE_IFACE, ENABLED_PROP, QVariant::fromValue(QDBusVariant(enabled)));
106
QString System::hereLicensePath() const
108
return m_hereLicensePath;
111
void System::updateSessionLanguage()
113
QProcess::startDetached("sh -c \"initctl start ubuntu-system-settings-wizard-set-lang; initctl emit --no-wait indicator-services-start; initctl start --no-wait maliit-server\"");