ModemManagerQt

modemcdma.cpp
1/*
2 SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org>
3 SPDX-FileCopyrightText: 2010 Lamarque Souza <lamarque@kde.org>
4 SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
5 SPDX-FileCopyrightText: 2013-2015 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 "mmdebug_p.h"
11#include "modemcdma_p.h"
12#ifdef MMQT_STATIC
13#include "dbus/fakedbus.h"
14#else
15#include "dbus/dbus.h"
16#endif
17
18ModemManager::ModemCdmaPrivate::ModemCdmaPrivate(const QString &path, ModemCdma *q)
19 : InterfacePrivate(path, q)
20#ifdef MMQT_STATIC
21 , modemCdmaIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::sessionBus())
22#else
23 , modemCdmaIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::systemBus())
24#endif
25 , q_ptr(q)
26{
27 if (modemCdmaIface.isValid()) {
28 activationState = (MMModemCdmaActivationState)modemCdmaIface.activationState();
29 meid = modemCdmaIface.meid();
30 esn = modemCdmaIface.esn();
31 sid = modemCdmaIface.sid();
32 nid = modemCdmaIface.nid();
33 cdma1xRegistrationState = (MMModemCdmaRegistrationState)modemCdmaIface.cdma1xRegistrationState();
34 evdoRegistrationState = (MMModemCdmaRegistrationState)modemCdmaIface.evdoRegistrationState();
35 }
36}
37
38ModemManager::ModemCdma::ModemCdma(const QString &path, QObject *parent)
39 : Interface(*new ModemCdmaPrivate(path, this), parent)
40{
41 Q_D(ModemCdma);
42
43 qRegisterMetaType<MMModemCdmaActivationState>();
44 qRegisterMetaType<MMCdmaActivationError>();
45 qRegisterMetaType<MMModemCdmaRegistrationState>();
46
47 connect(&d->modemCdmaIface, &OrgFreedesktopModemManager1ModemModemCdmaInterface::ActivationStateChanged, d, &ModemCdmaPrivate::onActivationStateChanged);
48#ifdef MMQT_STATIC
50 d->uni,
51 QLatin1String(DBUS_INTERFACE_PROPS),
52 QStringLiteral("PropertiesChanged"),
53 d,
54 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
55#else
57 d->uni,
58 QLatin1String(DBUS_INTERFACE_PROPS),
59 QStringLiteral("PropertiesChanged"),
60 d,
61 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
62#endif
63}
64
65ModemManager::ModemCdma::~ModemCdma()
66{
67}
68
70{
72 return d->modemCdmaIface.Activate(carrierCode);
73}
74
76{
78 return d->modemCdmaIface.ActivateManual(properties);
79}
80
81MMModemCdmaActivationState ModemManager::ModemCdma::activationState() const
82{
83 Q_D(const ModemCdma);
84 return d->activationState;
85}
86
88{
89 Q_D(const ModemCdma);
90 return d->meid;
91}
92
94{
95 Q_D(const ModemCdma);
96 return d->esn;
97}
98
100{
101 Q_D(const ModemCdma);
102 return d->sid;
103}
104
106{
107 Q_D(const ModemCdma);
108 return d->nid;
109}
110
111MMModemCdmaRegistrationState ModemManager::ModemCdma::cdma1xRegistrationState() const
112{
113 Q_D(const ModemCdma);
114 return d->cdma1xRegistrationState;
115}
116
117MMModemCdmaRegistrationState ModemManager::ModemCdma::evdoRegistrationState() const
118{
119 Q_D(const ModemCdma);
120 return d->evdoRegistrationState;
121}
122
124{
125 Q_D(ModemCdma);
126 d->modemCdmaIface.setTimeout(timeout);
127}
128
130{
131 Q_D(const ModemCdma);
132 return d->modemCdmaIface.timeout();
133}
134
135void ModemManager::ModemCdmaPrivate::onActivationStateChanged(uint activation_state, uint activation_error, const QVariantMap &status_changes)
136{
137 Q_Q(ModemCdma);
138 activationState = (MMModemCdmaActivationState)activation_state;
139 Q_EMIT q->activationStateChanged((MMModemCdmaActivationState)activation_state, (MMCdmaActivationError)activation_error, status_changes);
140}
141
142void ModemManager::ModemCdmaPrivate::onPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProps)
143{
144 Q_Q(ModemCdma);
145 Q_UNUSED(invalidatedProps);
146 qCDebug(MMQT) << interface << properties.keys();
147
148 if (interface == QLatin1String(MMQT_DBUS_INTERFACE_MODEM_MODEMCDMA)) {
149 QVariantMap::const_iterator it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_ACTIVATIONSTATE));
150 if (it != properties.constEnd()) {
151 // Should be handled by activationStateChanged signal
152 }
153 it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_MEID));
154 if (it != properties.constEnd()) {
155 meid = it->toString();
156 Q_EMIT q->meidChanged(meid);
157 }
158 it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_ESN));
159 if (it != properties.constEnd()) {
160 esn = it->toString();
161 Q_EMIT q->esnChanged(esn);
162 }
163 it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_SID));
164 if (it != properties.constEnd()) {
165 sid = it->toUInt();
166 Q_EMIT q->sidChanged(sid);
167 }
168 it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_NID));
169 if (it != properties.constEnd()) {
170 nid = it->toUInt();
171 Q_EMIT q->nidChanged(nid);
172 }
173 it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_CDMA1XREGISTRATIONSTATE));
174 if (it != properties.constEnd()) {
175 cdma1xRegistrationState = (MMModemCdmaRegistrationState)it->toUInt();
176 Q_EMIT q->cdma1xRegistrationStateChanged(cdma1xRegistrationState);
177 }
178 it = properties.constFind(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_EVDOREGISTRATIONSTATE));
179 if (it != properties.constEnd()) {
180 evdoRegistrationState = (MMModemCdmaRegistrationState)it->toUInt();
181 Q_EMIT q->evdoRegistrationStateChanged(evdoRegistrationState);
182 }
183 }
184}
185
186#include "moc_modemcdma.cpp"
The ModemCdma class.
Definition modemcdma.h:33
QString meid() const
Definition modemcdma.cpp:87
MMModemCdmaRegistrationState evdoRegistrationState() const
MMModemCdmaRegistrationState cdma1xRegistrationState() const
MMModemCdmaActivationState activationState() const
Definition modemcdma.cpp:81
QString esn() const
Definition modemcdma.cpp:93
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
QDBusPendingReply< void > activate(const QString &carrierCode)
Provisions the modem for use with a given carrier using the modem's Over-The-Air (OTA) activation fun...
Definition modemcdma.cpp:69
QDBusPendingReply< void > activateManual(const QVariantMap &properties)
Sets the modem provisioning data directly, without contacting the carrier over the air.
Definition modemcdma.cpp:75
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()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
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.