ModemManagerQt

modemlocation.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Will Stephenson <wstephenson@kde.org>
3 SPDX-FileCopyrightText: 2010 Lamarque Souza <lamarque@kde.org>
4 SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
5 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8*/
9
10#include "modemlocation.h"
11#include "mmdebug_p.h"
12#include "modemlocation_p.h"
13#ifdef MMQT_STATIC
14#include "dbus/fakedbus.h"
15#else
16#include "dbus/dbus.h"
17#endif
18
19ModemManager::ModemLocationPrivate::ModemLocationPrivate(const QString &path, ModemLocation *q)
20 : InterfacePrivate(path, q)
21#ifdef MMQT_STATIC
22 , modemLocationIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::sessionBus())
23#else
24 , modemLocationIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::systemBus())
25#endif
26 , q_ptr(q)
27{
28 if (modemLocationIface.isValid()) {
29 capabilities = (ModemManager::ModemLocation::LocationSources)modemLocationIface.capabilities();
30 enabledCapabilities = (ModemManager::ModemLocation::LocationSources)modemLocationIface.enabled();
31 signalsLocation = modemLocationIface.signalsLocation();
32 location = modemLocationIface.location();
33 }
34}
35
36ModemManager::ModemLocation::ModemLocation(const QString &path, QObject *parent)
37 : Interface(*new ModemLocationPrivate(path, this), parent)
38{
39 Q_D(ModemLocation);
40
41 qRegisterMetaType<LocationSources>();
42
43#ifdef MMQT_STATIC
45 d->uni,
46 QLatin1String(DBUS_INTERFACE_PROPS),
47 QStringLiteral("PropertiesChanged"),
48 d,
49 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
50#else
52 d->uni,
53 QLatin1String(DBUS_INTERFACE_PROPS),
54 QStringLiteral("PropertiesChanged"),
55 d,
56 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
57#endif
58}
59
60ModemManager::ModemLocation::~ModemLocation()
61{
62}
63
65{
67 return d->modemLocationIface.Setup(sources, signalLocation);
68}
69
75
81
87
89{
90 Q_D(const ModemLocation);
91 return d->enabledCapabilities > MM_MODEM_LOCATION_SOURCE_NONE;
92}
93
95{
96 Q_D(const ModemLocation);
97 return d->signalsLocation;
98}
99
105
107{
109 d->modemLocationIface.setTimeout(timeout);
110}
111
113{
114 Q_D(const ModemLocation);
115 return d->modemLocationIface.timeout();
116}
117
118void ModemManager::ModemLocationPrivate::onPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProps)
119{
120 Q_Q(ModemLocation);
121 Q_UNUSED(invalidatedProps);
122 qCDebug(MMQT) << interface << properties.keys();
123
124 if (interface == QLatin1String(MMQT_DBUS_INTERFACE_MODEM_LOCATION)) {
125 QVariantMap::const_iterator it = properties.constFind(QLatin1String(MM_MODEM_LOCATION_PROPERTY_CAPABILITIES));
126 if (it != properties.constEnd()) {
127 capabilities = (ModemManager::ModemLocation::LocationSources)it->toUInt();
128 Q_EMIT q->capabilitiesChanged(capabilities);
129 }
130 it = properties.constFind(QLatin1String(MM_MODEM_LOCATION_PROPERTY_ENABLED));
131 if (it != properties.constEnd()) {
132 enabledCapabilities = (ModemManager::ModemLocation::LocationSources)it->toUInt();
133 Q_EMIT q->enabledCapabilitiesChanged(enabledCapabilities);
134 }
135 it = properties.constFind(QLatin1String(MM_MODEM_LOCATION_PROPERTY_SIGNALSLOCATION));
136 if (it != properties.constEnd()) {
137 signalsLocation = it->toBool();
138 Q_EMIT q->signalsLocationChanged(signalsLocation);
139 }
140 it = properties.constFind(QLatin1String(MM_MODEM_LOCATION_PROPERTY_LOCATION));
141 if (it != properties.constEnd()) {
142 location = qdbus_cast<ModemManager::LocationInformationMap>(*it);
143 Q_EMIT q->locationChanged(location);
144 }
145 }
146}
147
148#include "moc_modemlocation.cpp"
The ModemLocation class.
LocationSources enabledCapabilities() const
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
LocationSources capabilities() const
LocationInformationMap location() const
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
QDBusPendingReply< void > setup(ModemManager::ModemLocation::LocationSources sources, bool signalLocation)
Configure the location sources to use when gathering location information.
QDBusPendingReply< LocationInformationMap > getLocation()
QVariant location(const QVariant &res)
QString path(const QString &relativePath)
KGuiItem properties()
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:51 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.