ModemManagerQt

modem3gppussd.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 "modem3gppussd.h"
11#include "mmdebug_p.h"
12#include "modem3gppussd_p.h"
13#ifdef MMQT_STATIC
14#include "dbus/fakedbus.h"
15#else
16#include "dbus/dbus.h"
17#endif
18
19ModemManager::Modem3gppUssdPrivate::Modem3gppUssdPrivate(const QString &path, Modem3gppUssd *q)
20 : InterfacePrivate(path, q)
21#ifdef MMQT_STATIC
22 , ussdIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::sessionBus())
23#else
24 , ussdIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::systemBus())
25#endif
26 , q_ptr(q)
27{
28 if (ussdIface.isValid()) {
29 state = (MMModem3gppUssdSessionState)ussdIface.state();
30 networkNotification = ussdIface.networkNotification();
31 networkRequest = ussdIface.networkRequest();
32 }
33}
34
35ModemManager::Modem3gppUssd::Modem3gppUssd(const QString &path, QObject *parent)
36 : Interface(*new Modem3gppUssdPrivate(path, this), parent)
37{
38 Q_D(Modem3gppUssd);
39
40 qRegisterMetaType<MMModem3gppUssdSessionState>();
41
42#ifdef MMQT_STATIC
44 d->uni,
45 QLatin1String(DBUS_INTERFACE_PROPS),
46 QStringLiteral("PropertiesChanged"),
47 d,
48 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
49#else
51 d->uni,
52 QLatin1String(DBUS_INTERFACE_PROPS),
53 QStringLiteral("PropertiesChanged"),
54 d,
55 SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
56#endif
57}
58
59ModemManager::Modem3gppUssd::~Modem3gppUssd()
60{
61}
62
63void ModemManager::Modem3gppUssdPrivate::onPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProps)
64{
65 Q_Q(Modem3gppUssd);
66 Q_UNUSED(invalidatedProps);
67 qCDebug(MMQT) << interface << properties.keys();
68
69 if (interface == QLatin1String(MMQT_DBUS_INTERFACE_MODEM_MODEM3GPP_USSD)) {
70 QVariantMap::const_iterator it = properties.constFind(QLatin1String(MM_MODEM_MODEM3GPP_USSD_PROPERTY_STATE));
71 if (it != properties.constEnd()) {
72 state = (MMModem3gppUssdSessionState)it->toUInt();
73 Q_EMIT q->stateChanged(state);
74 }
75 it = properties.constFind(QLatin1String(MM_MODEM_MODEM3GPP_USSD_PROPERTY_NETWORKNOTIFICATION));
76 if (it != properties.constEnd()) {
77 networkNotification = it->toString();
78 Q_EMIT q->networkNotificationChanged(networkNotification);
79 }
80 it = properties.constFind(QLatin1String(MM_MODEM_MODEM3GPP_USSD_PROPERTY_NETWORKREQUEST));
81 if (it != properties.constEnd()) {
82 networkRequest = it->toString();
83 Q_EMIT q->networkRequestChanged(networkRequest);
84 }
85 }
86}
87
89{
91 return d->ussdIface.Initiate(command);
92}
93
95{
97 return d->ussdIface.Respond(response);
98}
99
101{
103 d->ussdIface.Cancel();
104}
105
106MMModem3gppUssdSessionState ModemManager::Modem3gppUssd::state() const
107{
108 Q_D(const Modem3gppUssd);
109 return d->state;
110}
111
113{
114 Q_D(const Modem3gppUssd);
115 return d->networkNotification;
116}
117
119{
120 Q_D(const Modem3gppUssd);
121 return d->networkRequest;
122}
123
125{
127 d->ussdIface.setTimeout(timeout);
128}
129
131{
132 Q_D(const Modem3gppUssd);
133 return d->ussdIface.timeout();
134}
135
136#include "moc_modem3gppussd.cpp"
137#include "moc_modem3gppussd_p.cpp"
The Modem3gppUssd class.
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
QDBusPendingReply< QString > initiate(const QString &command)
Sends a USSD command string to the network initiating a USSD session.
MMModem3gppUssdSessionState state() const
QDBusPendingReply< QString > respond(const QString &response)
Respond to a USSD request that is either initiated by the mobile network, or that is awaiting further...
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
QString networkNotification() const
void cancel()
Cancel an ongoing USSD session, either mobile or network initiated.
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.