11#include "dbus/fakedbus.h"
17Q_LOGGING_CATEGORY(MMQT,
"kf.modemmanagerqt", QtWarningMsg)
21class ModemManager::IpConfig::Private
27 MMBearerIpMethod method{MM_BEARER_IP_METHOD_UNKNOWN};
127 if (
this == &other) {
135ModemManager::BearerPrivate::BearerPrivate(
const QString &path,
Bearer *q)
144 if (bearerIface.isValid()) {
145 bearerInterface = bearerIface.interface();
146 isConnected = bearerIface.connected();
147 isSuspended = bearerIface.suspended();
148 ipv4Config = ipConfigFromMap(bearerIface.ip4Config());
149 ipv6Config = ipConfigFromMap(bearerIface.ip6Config());
150 ipTimeout = bearerIface.ipTimeout();
151 bearerProperties = bearerIface.properties();
155ModemManager::Bearer::Bearer(
const QString &path, QObject *parent)
157 , d_ptr(new BearerPrivate(
path, this))
164 DBUS_INTERFACE_PROPS,
165 QStringLiteral(
"PropertiesChanged"),
167 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
171 DBUS_INTERFACE_PROPS,
172 QStringLiteral(
"PropertiesChanged"),
174 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
178ModemManager::Bearer::~Bearer()
186 return d->bearerInterface;
192 return d->isConnected;
198 return d->isSuspended;
204 return d->ipv4Config;
210 return d->ipv6Config;
222 return d->bearerProperties;
228 return d->bearerIface.Connect();
234 return d->bearerIface.Disconnect();
240 d->bearerIface.setTimeout(
timeout);
246 return d->bearerIface.timeout();
249ModemManager::IpConfig ModemManager::BearerPrivate::ipConfigFromMap(
const QVariantMap &map)
251 ModemManager::IpConfig result;
252 result.
setMethod((MMBearerIpMethod)map.value(QStringLiteral(
"method")).toUInt());
254 if (result.
method() == MM_BEARER_IP_METHOD_STATIC) {
255 result.
setAddress(map.value(QStringLiteral(
"address")).toString());
256 result.
setPrefix(map.value(QStringLiteral(
"prefix")).toUInt());
257 result.
setDns1(map.value(QStringLiteral(
"dns1")).toString());
258 result.
setDns2(map.value(QStringLiteral(
"dns2")).toString());
259 result.
setDns3(map.value(QStringLiteral(
"dns3")).toString());
260 result.
setGateway(map.value(QStringLiteral(
"gateway")).toString());
266void ModemManager::BearerPrivate::onPropertiesChanged(
const QString &interface,
const QVariantMap &properties,
const QStringList &invalidatedProps)
269 Q_UNUSED(invalidatedProps);
270 qCDebug(MMQT) <<
interface << properties.keys();
272 if (interface == QLatin1String(MMQT_DBUS_INTERFACE_BEARER)) {
273 QVariantMap::const_iterator it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_INTERFACE));
275 bearerInterface = it->toString();
276 Q_EMIT q->interfaceChanged(bearerInterface);
278 it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_CONNECTED));
280 isConnected = it->toBool();
281 Q_EMIT q->connectedChanged(isConnected);
283 it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_SUSPENDED));
285 isSuspended = it->toBool();
286 Q_EMIT q->suspendedChanged(isSuspended);
288 it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_IP4CONFIG));
290 ipv4Config = ipConfigFromMap(qdbus_cast<QVariantMap>(*it));
291 Q_EMIT q->ip4ConfigChanged(ipv4Config);
293 it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_IP6CONFIG));
295 ipv6Config = ipConfigFromMap(qdbus_cast<QVariantMap>(*it));
296 Q_EMIT q->ip6ConfigChanged(ipv6Config);
298 it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_IPTIMEOUT));
300 ipTimeout = it->toUInt();
301 Q_EMIT q->ipTimeoutChanged(ipTimeout);
303 it =
properties.constFind(QLatin1String(MM_BEARER_PROPERTY_PROPERTIES));
305 bearerProperties = qdbus_cast<QVariantMap>(*it);
306 Q_EMIT q->propertiesChanged(bearerProperties);
317#include "moc_bearer.cpp"
318#include "moc_bearer_p.cpp"
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
bool isSuspended() const
In some devices, packet data service will be suspended while the device is handling other communicati...
QString interface() const
QDBusPendingReply< void > connectBearer()
Requests activation of a packet data connection with the network using this bearer's properties.
IpConfig ip4Config() const
If the bearer was configured for IPv4 addressing, upon activation this property contains the addressi...
QVariantMap properties() const
QDBusPendingReply< void > disconnectBearer()
Disconnect and deactivate this packet data connection.
IpConfig ip6Config() const
If the bearer was configured for IPv6 addressing, upon activation this property contains the addressi...
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
void setMethod(MMBearerIpMethod method)
Sets the MMBearerIpMethod.
QString dns3() const
Returns the IP address of the third DNS server.
IpConfig()
Constructs an empty IP config object.
void setGateway(const QString &gateway)
Sets the IP address of the default gateway.
QString dns1() const
Returns the IP address of the first DNS server.
QString dns2() const
Returns the IP address of the second DNS server.
void setAddress(const QString &address)
Sets the IP address.
QString gateway() const
Returns the IP address of the default gateway.
void setDns3(const QString &dns3)
Sets the IP address of the third DNS server.
~IpConfig()
Destroys this IpConfig object.
QString address() const
Returns the IP address.
MMBearerIpMethod method() const
Returns the MMBearerIpMethod.
IpConfig & operator=(const IpConfig &other)
Makes a copy of the IpConfig object other.
void setDns2(const QString &dns2)
Sets the IP address of the second DNS server.
void setPrefix(uint prefix)
Sets the numeric CIDR network prefix.
void setDns1(const QString &dns1)
Sets the IP address of the first DNS server.
uint prefix() const
Returns the numeric CIDR network prefix (ie, 24, 32, etc)
QString path(const QString &relativePath)
This namespace allows to query the underlying system to discover the available modem interfaces respo...
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()