1 | /* |
2 | SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org> |
3 | SPDX-FileCopyrightText: 2011-2013 Lamarque Souza <lamarque@kde.org> |
4 | SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.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 "modemdevice.h" |
11 | #include "modemdevice_p.h" |
12 | |
13 | #include "manager_p.h" |
14 | |
15 | NetworkManager::ModemDevice::Capabilities convertModemCapabilities(uint theirCaps) |
16 | { |
17 | NetworkManager::ModemDevice::Capabilities ourCaps = (NetworkManager::ModemDevice::Capabilities)theirCaps; |
18 | return ourCaps; |
19 | } |
20 | |
21 | NetworkManager::ModemDevicePrivate::ModemDevicePrivate(const QString &path, ModemDevice *q) |
22 | : DevicePrivate(path, q) |
23 | #ifdef NMQT_STATIC |
24 | , modemIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) |
25 | #else |
26 | , modemIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) |
27 | #endif |
28 | { |
29 | } |
30 | |
31 | NetworkManager::ModemDevice::ModemDevice(const QString &path, QObject *parent) |
32 | : Device(*new ModemDevicePrivate(path, this), parent) |
33 | { |
34 | Q_D(ModemDevice); |
35 | |
36 | QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->modemIface.staticInterfaceName(), path); |
37 | if (!initialProperties.isEmpty()) { |
38 | d->propertiesChanged(properties: initialProperties); |
39 | } |
40 | } |
41 | |
42 | NetworkManager::ModemDevice::ModemDevice(NetworkManager::ModemDevicePrivate &dd, QObject *parent) |
43 | : Device(dd, parent) |
44 | { |
45 | Q_D(ModemDevice); |
46 | |
47 | QDBusConnection::systemBus().connect(service: NetworkManagerPrivate::DBUS_SERVICE, |
48 | path: d->uni, |
49 | interface: NetworkManagerPrivate::FDO_DBUS_PROPERTIES, |
50 | name: QLatin1String("PropertiesChanged" ), |
51 | receiver: d, |
52 | SLOT(dbusPropertiesChanged(QString, QVariantMap, QStringList))); |
53 | } |
54 | |
55 | NetworkManager::ModemDevice::~ModemDevice() |
56 | { |
57 | } |
58 | |
59 | NetworkManager::Device::Type NetworkManager::ModemDevice::type() const |
60 | { |
61 | return NetworkManager::Device::Modem; |
62 | } |
63 | |
64 | NetworkManager::ModemDevice::Capabilities NetworkManager::ModemDevice::currentCapabilities() const |
65 | { |
66 | Q_D(const ModemDevice); |
67 | return d->currentCapabilities; |
68 | } |
69 | |
70 | NetworkManager::ModemDevice::Capabilities NetworkManager::ModemDevice::modemCapabilities() const |
71 | { |
72 | Q_D(const ModemDevice); |
73 | return d->modemCapabilities; |
74 | } |
75 | |
76 | void NetworkManager::ModemDevicePrivate::propertyChanged(const QString &property, const QVariant &value) |
77 | { |
78 | Q_Q(ModemDevice); |
79 | |
80 | if (property == QLatin1String("CurrentCapabilities" )) { |
81 | currentCapabilities = convertModemCapabilities(theirCaps: value.toUInt()); |
82 | Q_EMIT q->currentCapabilitiesChanged(currentCapabilities); |
83 | } else if (property == QLatin1String("ModemCapabilities" )) { |
84 | modemCapabilities = convertModemCapabilities(theirCaps: value.toUInt()); |
85 | } else { |
86 | DevicePrivate::propertyChanged(property, value); |
87 | } |
88 | } |
89 | |
90 | #include "moc_modemdevice.cpp" |
91 | #include "moc_modemdevice_p.cpp" |
92 | |