ModemManagerQt

modemsignal.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Lukas Tinkl <ltinkl@redhat.com>
3 SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "modemsignal.h"
9#include "mmdebug_p.h"
10#include "modemsignal_p.h"
11#ifdef MMQT_STATIC
12#include "dbus/fakedbus.h"
13#else
14#include "dbus/dbus.h"
15#endif
16
17ModemManager::ModemSignalPrivate::ModemSignalPrivate(const QString &path, ModemSignal *q)
18 : InterfacePrivate(path, q)
19#ifdef MMQT_STATIC
20 , modemSignalIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::sessionBus())
21#else
22 , modemSignalIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::systemBus())
23#endif
24 , q_ptr(q)
25{
26 if (modemSignalIface.isValid()) {
27 rate = modemSignalIface.rate();
28 cdma = modemSignalIface.cdma();
29 evdo = modemSignalIface.evdo();
30 gsm = modemSignalIface.gsm();
31 umts = modemSignalIface.umts();
32 lte = modemSignalIface.lte();
33 }
34}
35
36ModemManager::ModemSignal::ModemSignal(const QString &path, QObject *parent)
37 : Interface(*new ModemSignalPrivate(path, this), parent)
38{
39 Q_D(ModemSignal);
40#ifdef MMQT_STATIC
42 d->uni,
43 QLatin1String(DBUS_INTERFACE_PROPS),
44 QStringLiteral("PropertiesChanged"),
45 d,
46 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
47#else
49 d->uni,
50 QLatin1String(DBUS_INTERFACE_PROPS),
51 QStringLiteral("PropertiesChanged"),
52 d,
53 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
54#endif
55}
56
57ModemManager::ModemSignal::~ModemSignal()
58{
59}
60
62{
63 Q_D(const ModemSignal);
64 return d->rate;
65}
66
68{
69 Q_D(const ModemSignal);
70 return d->cdma;
71}
72
74{
75 Q_D(const ModemSignal);
76 return d->evdo;
77}
78
80{
81 Q_D(const ModemSignal);
82 return d->gsm;
83}
84
86{
87 Q_D(const ModemSignal);
88 return d->lte;
89}
90
92{
93 Q_D(const ModemSignal);
94 return d->umts;
95}
96
98{
100 return d->modemSignalIface.Setup(rate);
101}
102
104{
106 d->modemSignalIface.setTimeout(timeout);
107}
108
110{
111 Q_D(const ModemSignal);
112 return d->modemSignalIface.timeout();
113}
114
115void ModemManager::ModemSignalPrivate::onPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProps)
116{
117 Q_Q(ModemSignal);
118 Q_UNUSED(invalidatedProps);
119 qCDebug(MMQT) << interface << properties.keys();
120
121 if (interface == QLatin1String(MMQT_DBUS_INTERFACE_MODEM_SIGNAL)) {
122 QVariantMap::const_iterator it = properties.constFind(QLatin1String(MM_MODEM_SIGNAL_PROPERTY_RATE));
123 if (it != properties.constEnd()) {
124 rate = it->toUInt();
125 Q_EMIT q->rateChanged(rate);
126 }
127 it = properties.constFind(QLatin1String(MM_MODEM_SIGNAL_PROPERTY_CDMA));
128 if (it != properties.constEnd()) {
129 cdma = qdbus_cast<QVariantMap>(*it);
130 Q_EMIT q->cdmaChanged(cdma);
131 }
132 it = properties.constFind(QLatin1String(MM_MODEM_SIGNAL_PROPERTY_EVDO));
133 if (it != properties.constEnd()) {
134 evdo = qdbus_cast<QVariantMap>(*it);
135 Q_EMIT q->cdmaChanged(evdo);
136 }
137 it = properties.constFind(QLatin1String(MM_MODEM_SIGNAL_PROPERTY_GSM));
138 if (it != properties.constEnd()) {
139 gsm = qdbus_cast<QVariantMap>(*it);
140 Q_EMIT q->cdmaChanged(gsm);
141 }
142 it = properties.constFind(QLatin1String(MM_MODEM_SIGNAL_PROPERTY_UMTS));
143 if (it != properties.constEnd()) {
144 umts = qdbus_cast<QVariantMap>(*it);
145 Q_EMIT q->cdmaChanged(umts);
146 }
147 it = properties.constFind(QLatin1String(MM_MODEM_SIGNAL_PROPERTY_LTE));
148 if (it != properties.constEnd()) {
149 lte = qdbus_cast<QVariantMap>(*it);
150 Q_EMIT q->cdmaChanged(lte);
151 }
152 }
153}
154
155#include "moc_modemsignal.cpp"
The ModemSignal class.
Definition modemsignal.h:30
QVariantMap gsm() const
QVariantMap cdma() const
QVariantMap umts() const
QVariantMap lte() const
QDBusPendingReply< void > setup(uint rate)
Setup extended signal quality information retrieval.
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
QVariantMap evdo() const
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
QString path(const QString &relativePath)
KGuiItem properties()
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.