ModemManagerQt

fakemodem/modemcdma.cpp
1/*
2 SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "modemcdma.h"
8
9#include <QDBusConnection>
10#include <QDBusMessage>
11
12ModemCdma::ModemCdma(QObject *parent)
13 : QDBusAbstractAdaptor(parent)
14 , m_enabledNotifications(false)
15 , m_activationState(0)
16 , m_cdma1xRegistrationState(0)
17 , m_evdoRegistrationState(0)
18 , m_nid(0)
19 , m_sid(0)
20{
21}
22
23ModemCdma::~ModemCdma()
24{
25}
26
27uint ModemCdma::activationState() const
28{
29 return m_activationState;
30}
31
32uint ModemCdma::cdma1xRegistrationState() const
33{
34 return m_cdma1xRegistrationState;
35}
36
37QString ModemCdma::esn() const
38{
39 return m_esn;
40}
41
42uint ModemCdma::evdoRegistrationState() const
43{
44 return m_evdoRegistrationState;
45}
46
47QString ModemCdma::meid() const
48{
49 return m_meid;
50}
51
52uint ModemCdma::nid() const
53{
54 return m_nid;
55}
56
57uint ModemCdma::sid() const
58{
59 return m_sid;
60}
61
62void ModemCdma::Activate(const QString &carrier_code)
63{
64 Q_UNUSED(carrier_code);
65}
66
67void ModemCdma::ActivateManual(const QVariantMap &properties)
68{
69 Q_UNUSED(properties);
70}
71
72void ModemCdma::setModemPath(const QString &path)
73{
74 m_modemPath = path;
75}
76
77void ModemCdma::setEnableNotifications(bool enable)
78{
79 m_enabledNotifications = enable;
80}
81
82void ModemCdma::setActivationState(uint state)
83{
84 m_activationState = state;
85
86 if (m_enabledNotifications) {
87 Q_EMIT ActivationStateChanged(state, MM_CDMA_ACTIVATION_ERROR_NONE, QVariantMap());
88 }
89}
90
91void ModemCdma::setCdma1xRegistrationState(uint state)
92{
93 m_cdma1xRegistrationState = state;
94
95 if (m_enabledNotifications) {
96 QVariantMap map;
97 map.insert(QLatin1String("Cdma1xRegistrationState"), m_cdma1xRegistrationState);
98 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
99 message << QLatin1String("org.kde.fakemodem.Modem.ModemCdma") << map << QStringList();
101 }
102}
103
104void ModemCdma::setEsn(const QString &esn)
105{
106 m_esn = esn;
107
108 if (m_enabledNotifications) {
109 QVariantMap map;
110 map.insert(QLatin1String("Esn"), m_esn);
111 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
112 message << QLatin1String("org.kde.fakemodem.Modem.ModemCdma") << map << QStringList();
114 }
115}
116
117void ModemCdma::setEvdoRegistrationState(uint state)
118{
119 m_evdoRegistrationState = state;
120
121 if (m_enabledNotifications) {
122 QVariantMap map;
123 map.insert(QLatin1String("EvdoRegistrationState"), m_evdoRegistrationState);
124 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
125 message << QLatin1String("org.kde.fakemodem.Modem.ModemCdma") << map << QStringList();
127 }
128}
129
130void ModemCdma::setMeid(const QString &meid)
131{
132 m_meid = meid;
133
134 if (m_enabledNotifications) {
135 QVariantMap map;
136 map.insert(QLatin1String("Meid"), m_meid);
137 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
138 message << QLatin1String("org.kde.fakemodem.Modem.ModemCdma") << map << QStringList();
140 }
141}
142
143void ModemCdma::setNid(uint nid)
144{
145 m_nid = nid;
146
147 if (m_enabledNotifications) {
148 QVariantMap map;
149 map.insert(QLatin1String("Nid"), m_nid);
150 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
151 message << QLatin1String("org.kde.fakemodem.Modem.ModemCdma") << map << QStringList();
153 }
154}
155
156void ModemCdma::setSid(uint sid)
157{
158 m_sid = sid;
159
160 if (m_enabledNotifications) {
161 QVariantMap map;
162 map.insert(QLatin1String("Sid"), m_sid);
163 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
164 message << QLatin1String("org.kde.fakemodem.Modem.ModemCdma") << map << QStringList();
166 }
167}
168
169QVariantMap ModemCdma::toMap() const
170{
171 QVariantMap map;
172 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_ACTIVATIONSTATE), m_activationState);
173 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_MEID), m_meid);
174 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_ESN), m_esn);
175 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_SID), m_sid);
176 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_NID), m_nid);
177 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_CDMA1XREGISTRATIONSTATE), m_cdma1xRegistrationState);
178 map.insert(QLatin1String(MM_MODEM_MODEMCDMA_PROPERTY_EVDOREGISTRATIONSTATE), m_evdoRegistrationState);
179 return map;
180}
181
182#include "moc_modemcdma.cpp"
QString path(const QString &relativePath)
bool send(const QDBusMessage &message) const const
QDBusConnection sessionBus()
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
Q_EMITQ_EMIT
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:51 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.