ModemManagerQt

fakemodem/bearer.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 "bearer.h"
8
9#include <QDBusConnection>
10#include <QDBusMessage>
11
12Bearer::Bearer(QObject *parent)
13 : QObject(parent)
14 , m_connected(false)
15 , m_ipTimeout(0)
16 , m_suspended(false)
17{
18}
19
20Bearer::~Bearer()
21{
22}
23
24bool Bearer::connected() const
25{
26 return m_connected;
27}
28
29QString Bearer::interface() const
30{
31 return m_interface;
32}
33
34QVariantMap Bearer::ip4Config() const
35{
36 return m_ip4Config;
37}
38
39QVariantMap Bearer::ip6Config() const
40{
41 return m_ip6Config;
42}
43
44uint Bearer::ipTimeout() const
45{
46 return m_ipTimeout;
47}
48
49QVariantMap Bearer::properties() const
50{
51 return m_properties;
52}
53
54bool Bearer::suspended() const
55{
56 return m_suspended;
57}
58
59QString Bearer::bearerPath() const
60{
61 return m_bearerPath;
62}
63
64void Bearer::setBearerPath(const QString &path)
65{
66 m_bearerPath = path;
67}
68
69void Bearer::setEnableNotifications(bool enable)
70{
71 m_enabledNotifications = enable;
72}
73
74void Bearer::setConnected(bool connected)
75{
76 m_connected = connected;
77
78 if (m_enabledNotifications) {
79 QVariantMap map;
80 map.insert(QLatin1String("Connected"), m_connected);
81 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
82 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
84 }
85}
86
87void Bearer::setInterface(const QString &interface)
88{
89 m_interface = interface;
90
91 if (m_enabledNotifications) {
92 QVariantMap map;
93 map.insert(QLatin1String("Interface"), m_interface);
94 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
95 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
97 }
98}
99
100void Bearer::setIp4Config(const QVariantMap &config)
101{
102 m_ip4Config = config;
103
104 if (m_enabledNotifications) {
105 QVariantMap map;
106 map.insert(QLatin1String("Ip4Config"), QVariant::fromValue<QVariantMap>(m_ip4Config));
107 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
108 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
110 }
111}
112
113void Bearer::setIp6Config(const QVariantMap &config)
114{
115 m_ip6Config = config;
116
117 if (m_enabledNotifications) {
118 QVariantMap map;
119 map.insert(QLatin1String("Ip6Config"), QVariant::fromValue<QVariantMap>(m_ip6Config));
120 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
121 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
123 }
124}
125
126void Bearer::setIpTimeout(uint timeout)
127{
128 m_ipTimeout = timeout;
129
130 if (m_enabledNotifications) {
131 QVariantMap map;
132 map.insert(QLatin1String("IpTimeout"), m_ipTimeout);
133 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
134 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
136 }
137}
138
139void Bearer::setProperties(const QVariantMap &properties)
140{
141 m_properties = properties;
142
143 if (m_enabledNotifications) {
144 QVariantMap map;
145 map.insert(QLatin1String("Properties"), QVariant::fromValue<QVariantMap>(m_properties));
146 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
147 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
149 }
150}
151
152void Bearer::setSuspended(bool suspended)
153{
154 m_suspended = suspended;
155
156 if (m_enabledNotifications) {
157 QVariantMap map;
158 map.insert(QLatin1String("Suspended"), m_suspended);
159 QDBusMessage message = QDBusMessage::createSignal(m_bearerPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
160 message << QLatin1String("org.kde.fakemodem.Bearer") << map << QStringList();
162 }
163}
164
165void Bearer::Connect()
166{
167 // TODO
168}
169
170void Bearer::Disconnect()
171{
172 // TODO
173}
174
175#include "moc_bearer.cpp"
QString path(const QString &relativePath)
KGuiItem properties()
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 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.