ModemManagerQt

fakemodem/modemoma.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 "modemoma.h"
8
9#include <QDBusConnection>
10#include <QDBusMessage>
11
12ModemOma::ModemOma(QObject *parent)
13 : QDBusAbstractAdaptor(parent)
14 , m_enabledNotifications(false)
15 , m_features(0)
16 , m_sessionState(0)
17 , m_sessionType(0)
18{
19}
20
21ModemOma::~ModemOma()
22{
23}
24
25uint ModemOma::features() const
26{
27 return m_features;
28}
29
30ModemManager::OmaSessionTypes ModemOma::pendingNetworkInitiatedSessions() const
31{
32 return m_sessions;
33}
34
35int ModemOma::sessionState() const
36{
37 return m_sessionState;
38}
39
40uint ModemOma::sessionType() const
41{
42 return m_sessionType;
43}
44
45void ModemOma::AcceptNetworkInitiatedSession(uint session_id, bool accept)
46{
47 Q_UNUSED(session_id);
48 Q_UNUSED(accept);
49}
50
51void ModemOma::CancelSession()
52{
53}
54
55void ModemOma::Setup(uint features)
56{
57 Q_UNUSED(features);
58}
59
60void ModemOma::StartClientInitiatedSession(uint session_type)
61{
62 Q_UNUSED(session_type);
63}
64
65void ModemOma::setModemPath(const QString &path)
66{
67 m_modemPath = path;
68}
69
70void ModemOma::setEnableNotifications(bool enable)
71{
72 m_enabledNotifications = enable;
73}
74
75void ModemOma::setFeatures(uint features)
76{
77 m_features = features;
78
79 if (m_enabledNotifications) {
80 QVariantMap map;
81 map.insert(QLatin1String("Features"), m_features);
82 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
83 message << QLatin1String("org.kde.fakemodem.Modem.Oma") << map << QStringList();
85 }
86}
87
88void ModemOma::setPendingNetworkInitiatedSessions(const ModemManager::OmaSessionTypes &sessions)
89{
90 m_sessions = sessions;
91
92 if (m_enabledNotifications) {
93 QVariantMap map;
94 map.insert(QLatin1String("PendingNetworkInitiatedSessions"), QVariant::fromValue<ModemManager::OmaSessionTypes>(m_sessions));
95 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
96 message << QLatin1String("org.kde.fakemodem.Modem.Oma") << map << QStringList();
98 }
99}
100
101void ModemOma::setSessionState(int state)
102{
103 int previousState = m_sessionState;
104 m_sessionState = state;
105
106 if (m_enabledNotifications) {
107 Q_EMIT SessionStateChanged(previousState, m_sessionState, MM_OMA_SESSION_STATE_UNKNOWN);
108 }
109}
110
111void ModemOma::setSessionType(uint type)
112{
113 m_sessionType = type;
114
115 if (m_enabledNotifications) {
116 QVariantMap map;
117 map.insert(QLatin1String("SessionType"), m_sessionType);
118 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged"));
119 message << QLatin1String("org.kde.fakemodem.Modem.Oma") << map << QStringList();
121 }
122}
123
124QVariantMap ModemOma::toMap() const
125{
126 QVariantMap map;
127 map.insert(QLatin1String(MM_MODEM_OMA_PROPERTY_FEATURES), m_features);
128 map.insert(QLatin1String(MM_MODEM_OMA_PROPERTY_PENDINGNETWORKINITIATEDSESSIONS), QVariant::fromValue<ModemManager::OmaSessionTypes>(m_sessions));
129 map.insert(QLatin1String(MM_MODEM_OMA_PROPERTY_SESSIONTYPE), m_sessionType);
130 map.insert(QLatin1String(MM_MODEM_OMA_PROPERTY_SESSIONSTATE), m_sessionState);
131 return map;
132}
133
134#include "moc_modemoma.cpp"
Type type(const QSqlDatabase &db)
QString path(const QString &relativePath)
std::vector< Feature > features(QStringView coachNumber, QStringView coachClassification)
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)
QVariant fromValue(T &&value)
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.