ModemManagerQt

fakemodem/modem3gpp.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 "modem3gpp.h"
8
9#include <QDBusConnection>
10#include <QDBusMessage>
11
12Modem3gpp::Modem3gpp(QObject *parent)
13 : QDBusAbstractAdaptor(parent)
14 , m_enabledNotifications(false)
15 , m_enabledFacilityLocks(0)
16 , m_registrationState(0)
17 , m_subscriptionState(0)
18{
19}
20
21Modem3gpp::~Modem3gpp()
22{
23}
24
25uint Modem3gpp::enabledFacilityLocks() const
26{
27 return m_enabledFacilityLocks;
28}
29
30QString Modem3gpp::imei() const
31{
32 return m_imei;
33}
34
35QString Modem3gpp::operatorCode() const
36{
37 return m_operatorCode;
38}
39
40QString Modem3gpp::operatorName() const
41{
42 return m_operatorName;
43}
44
45uint Modem3gpp::registrationState() const
46{
47 return m_registrationState;
48}
49
50uint Modem3gpp::subscriptionState() const
51{
52 return m_subscriptionState;
53}
54
55void Modem3gpp::Register(const QString &operator_id)
56{
57 Q_UNUSED(operator_id);
58}
59
60ModemManager::QVariantMapList Modem3gpp::Scan()
61{
63}
64
65void Modem3gpp::setModemPath(const QString &path)
66{
67 m_modemPath = path;
68}
69
70void Modem3gpp::setEnableNotifications(bool enable)
71{
72 m_enabledNotifications = enable;
73}
74
75void Modem3gpp::setEnabledFacilityLocks(uint enabledFacilityLocks)
76{
77 m_enabledFacilityLocks = enabledFacilityLocks;
78
79 if (m_enabledNotifications) {
80 QVariantMap map;
81 map.insert(QLatin1String("EnabledFacilityLocks"), m_enabledFacilityLocks);
82 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
83 message << QLatin1String("org.kde.fakemodem.Modem.Modem3gpp") << map << QStringList();
85 }
86}
87
88void Modem3gpp::setImei(const QString &imei)
89{
90 m_imei = imei;
91
92 if (m_enabledNotifications) {
93 QVariantMap map;
94 map.insert(QLatin1String("Imei"), m_imei);
95 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
96 message << QLatin1String("org.kde.fakemodem.Modem.Modem3gpp") << map << QStringList();
98 }
99}
100
101void Modem3gpp::setOperatorCode(const QString &operatorCode)
102{
103 m_operatorCode = operatorCode;
104
105 if (m_enabledNotifications) {
106 QVariantMap map;
107 map.insert(QLatin1String("OperatorCode"), m_operatorCode);
108 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
109 message << QLatin1String("org.kde.fakemodem.Modem.Modem3gpp") << map << QStringList();
111 }
112}
113
114void Modem3gpp::setOperatorName(const QString &operatorName)
115{
116 m_operatorName = operatorName;
117
118 if (m_enabledNotifications) {
119 QVariantMap map;
120 map.insert(QLatin1String("OperatorName"), m_operatorName);
121 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
122 message << QLatin1String("org.kde.fakemodem.Modem.Modem3gpp") << map << QStringList();
124 }
125}
126
127void Modem3gpp::setRegistrationState(uint registrationState)
128{
129 m_registrationState = registrationState;
130
131 if (m_enabledNotifications) {
132 QVariantMap map;
133 map.insert(QLatin1String("RegistrationState"), m_registrationState);
134 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
135 message << QLatin1String("org.kde.fakemodem.Modem.Modem3gpp") << map << QStringList();
137 }
138}
139
140void Modem3gpp::setSubscriptionState(uint subscriptionState)
141{
142 m_subscriptionState = subscriptionState;
143
144 if (m_enabledNotifications) {
145 QVariantMap map;
146 map.insert(QLatin1String("SubscriptionState"), m_subscriptionState);
147 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
148 message << QLatin1String("org.kde.fakemodem.Modem.Modem3gpp") << map << QStringList();
150 }
151}
152
153QVariantMap Modem3gpp::toMap() const
154{
155 QVariantMap map;
156 map.insert(QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_IMEI), m_imei);
157 map.insert(QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_REGISTRATIONSTATE), m_registrationState);
158 map.insert(QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_OPERATORCODE), m_operatorCode);
159 map.insert(QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_OPERATORNAME), m_operatorName);
160 map.insert(QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_ENABLEDFACILITYLOCKS), m_enabledFacilityLocks);
161#if MM_CHECK_VERSION(1, 2, 0)
162 map.insert(QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_SUBSCRIPTIONSTATE), m_subscriptionState);
163#endif
164 return map;
165}
166
167#include "moc_modem3gpp.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)
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 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.