2
Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) version 3, or any
8
later version accepted by the membership of KDE e.V. (or its
9
successor approved by the membership of KDE e.V.), which shall
10
act as a proxy defined in Section 6 of version 3 of the license.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library. If not, see <http://www.gnu.org/licenses/>.
24
#include "dbus/dbus.h"
26
BearerPrivate::BearerPrivate(const QString &path)
27
: bearerIface(MM_DBUS_SERVICE, path, QDBusConnection::systemBus())
31
ModemManager::Bearer::Bearer(const QString &path, QObject *parent)
33
, d_ptr(new Bearer(path))
37
QDBusConnection::systemBus().connect(MM_DBUS_SERVICE, path, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
38
SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
41
ModemManager::Bearer::~Bearer()
45
QString ModemManager::Bearer::interface() const
48
return d->bearerIface.interface();
51
bool ModemManager::Bearer::isConnected() const
54
return d->bearerIface.connected();
57
bool ModemManager::Bearer::isSuspended() const
60
return d->bearerIface.suspended();
63
ModemManager::Bearer::IpConfig ModemManager::Bearer::ip4Config() const
67
const QVariantMap map = d->bearerIface.ip4Config();
68
result.method = (MMBearerIpMethod)map.value("method").toUInt();
70
if (result.method == MM_BEARER_IP_METHOD_STATIC) {
71
result.address = map.value("address").toString();
72
result.prefix = map.value("prefix").toUInt();
73
result.dns1 = map.value("dns1").toString();
74
result.dns2 = map.value("dns2").toString();
75
result.dns3 = map.value("dns3").toString();
76
result.gateway = map.value("gateway").toString();
82
ModemManager::Bearer::IpConfig ModemManager::Bearer::ip6Config() const
86
const QVariantMap map = d->bearerIface.ip6Config();
87
result.method = (MMBearerIpMethod)map.value("method").toUInt();
89
if (result.method == MM_BEARER_IP_METHOD_STATIC) {
90
result.address = map.value("address").toString();
91
result.prefix = map.value("prefix").toUInt();
92
result.dns1 = map.value("dns1").toString();
93
result.dns2 = map.value("dns2").toString();
94
result.dns3 = map.value("dns3").toString();
95
result.gateway = map.value("gateway").toString();
101
uint ModemManager::Bearer::ipTimeout() const
104
return d->bearerIface.ipTimeout();
107
QVariantMap ModemManager::Bearer::properties() const
110
return d->bearerIface.properties();
113
void ModemManager::Bearer::connectBearer()
116
d->bearerIface.Connect();
119
void ModemManager::Bearer::disconnectBearer()
122
d->bearerIface.Disconnect();
125
void ModemManager::Bearer::onPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProps)
127
mmDebug() << interface << properties.keys();
129
if (interface == QString(MM_DBUS_INTERFACE_BEARER)) {
130
QLatin1String interface(MM_BEARER_PROPERTY_INTERFACE);
131
QLatin1String connected(MM_BEARER_PROPERTY_CONNECTED);
132
QLatin1String suspended(MM_BEARER_PROPERTY_SUSPENDED);
133
QLatin1String ip4Config(MM_BEARER_PROPERTY_IP4CONFIG);
134
QLatin1String ip6Config(MM_BEARER_PROPERTY_IP6CONFIG);
136
QVariantMap::const_iterator it = properties.constFind(interface);
137
if (it != properties.constEnd()) {
138
emit interfaceChanged(it->toString());
140
it = properties.constFind(connected);
141
if (it != properties.constEnd()) {
142
emit connectedChanged(it->toBool());
144
it = properties.constFind(suspended);
145
if (it != properties.constEnd()) {
146
emit suspendedChanged(it->toBool());
148
it = properties.constFind(ip4Config);
149
if (it != properties.constEnd()) {
150
emit ip4ConfigChanged();
152
it = properties.constFind(ip6Config);
153
if (it != properties.constEnd()) {
154
emit ip6ConfigChanged();