ModemManagerQt

fakemodem/modemlocation.cpp
1/*
2 SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "modemlocation.h"
8
9#include <QDBusConnection>
10#include <QDBusMessage>
11
12ModemLocation::ModemLocation(QObject *parent)
13 : QDBusAbstractAdaptor(parent)
14 , m_enabledNotifications(false)
15 , m_capabilities(0)
16 , m_enabled(0)
17 , m_signalsLocation(false)
18{
19}
20
21ModemLocation::~ModemLocation()
22{
23}
24
25uint ModemLocation::capabilities() const
26{
27 return m_capabilities;
28}
29
30uint ModemLocation::enabled() const
31{
32 return m_enabled;
33}
34
35ModemManager::LocationInformationMap ModemLocation::location() const
36{
37 return m_location;
38}
39
40bool ModemLocation::signalsLocation() const
41{
42 return m_signalsLocation;
43}
44
45ModemManager::LocationInformationMap ModemLocation::GetLocation()
46{
47 return m_location;
48}
49
50void ModemLocation::Setup(uint sources, bool signal_location)
51{
52 Q_UNUSED(sources);
53 Q_UNUSED(signal_location)
54}
55
56void ModemLocation::setModemPath(const QString &path)
57{
58 m_modemPath = path;
59}
60
61void ModemLocation::setEnableNotifications(bool enable)
62{
63 m_enabledNotifications = enable;
64}
65
66void ModemLocation::setCapabilities(uint capabilities)
67{
68 m_capabilities = capabilities;
69
70 if (m_enabledNotifications) {
71 QVariantMap map;
72 map.insert(QLatin1String("Capabilities"), m_capabilities);
73 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
74 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList();
76 }
77}
78
79void ModemLocation::setEnabled(uint enabled)
80{
81 m_enabled = enabled;
82
83 if (m_enabledNotifications) {
84 QVariantMap map;
85 map.insert(QLatin1String("Enabled"), m_enabled);
86 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
87 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList();
89 }
90}
91
92void ModemLocation::setLocation(const ModemManager::LocationInformationMap &location)
93{
94 m_location = location;
95
96 if (m_enabledNotifications) {
97 QVariantMap map;
99 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
100 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList();
102 }
103}
104
105void ModemLocation::setSignalsLocation(bool signalsLocation)
106{
107 m_signalsLocation = signalsLocation;
108
109 if (m_enabledNotifications) {
110 QVariantMap map;
111 map.insert(QLatin1String("SignalsLocation"), m_signalsLocation);
112 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
113 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList();
115 }
116}
117
118QVariantMap ModemLocation::toMap() const
119{
120 QVariantMap map;
121 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_CAPABILITIES), m_capabilities);
122 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_ENABLED), m_enabled);
123 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_SIGNALSLOCATION), QVariant::fromValue<ModemManager::LocationInformationMap>(m_location));
124 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_LOCATION), m_signalsLocation);
125 return map;
126}
127
128#include "moc_modemlocation.cpp"
Capabilities capabilities()
QVariant location(const QVariant &res)
QString path(const QString &relativePath)
bool send(const QDBusMessage &message) const const
QDBusConnection sessionBus()
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.