ModemManagerQt

modemvoice.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Aleksander Morgado <aleksander@aleksander.es>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "modemvoice.h"
8#include "modemvoice_p.h"
9
10#ifdef MMQT_STATIC
11#include "dbus/fakedbus.h"
12#else
13#include "dbus/dbus.h"
14#endif
15#include "mmdebug_p.h"
16
17#include <ModemManager/ModemManager.h>
18
19ModemManager::ModemVoicePrivate::ModemVoicePrivate(const QString &path, ModemVoice *q)
20 : InterfacePrivate(path, q)
21#ifdef MMQT_STATIC
22 , modemVoiceIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::sessionBus())
23#else
24 , modemVoiceIface(QLatin1String(MMQT_DBUS_SERVICE), path, QDBusConnection::systemBus())
25#endif
26 , q_ptr(q)
27{
28 if (modemVoiceIface.isValid()) {
29 connect(&modemVoiceIface, &OrgFreedesktopModemManager1ModemVoiceInterface::CallAdded, this, &ModemVoicePrivate::onCallAdded);
30 connect(&modemVoiceIface, &OrgFreedesktopModemManager1ModemVoiceInterface::CallDeleted, this, &ModemVoicePrivate::onCallDeleted);
31 }
32}
33
34ModemManager::ModemVoice::ModemVoice(const QString &path, QObject *parent)
35 : Interface(*new ModemVoicePrivate(path, this), parent)
36{
37 Q_D(ModemVoice);
38
39 // Note: no need to listen for PropertiesChanged signals. Additions and
40 // removals of calls are already notified via CallAdded and CallRemoved
41
42 QList<QDBusObjectPath> calls = d->modemVoiceIface.calls();
43 Q_FOREACH (const QDBusObjectPath &op, calls) {
44 const QString path = op.path();
45 d->callList.insert(path, ModemManager::Call::Ptr());
46 Q_EMIT callAdded(path);
47 }
48}
49
50ModemManager::ModemVoice::~ModemVoice()
51{
52}
53
54ModemManager::Call::Ptr ModemManager::ModemVoicePrivate::findCall(const QString &uni)
55{
57 if (callList.contains(uni)) {
58 if (callList.value(uni)) {
59 call = callList.value(uni);
60 } else {
62 callList[uni] = call;
63 }
64 }
65 return call;
66}
67
68ModemManager::Call::List ModemManager::ModemVoicePrivate::ModemVoicePrivate::calls()
69{
71
73 for (i = callList.constBegin(); i != callList.constEnd(); ++i) {
74 ModemManager::Call::Ptr call = findCall(i.key());
75 if (call) {
76 list.append(call);
77 } else {
78 qCWarning(MMQT) << "warning: null call for" << i.key();
79 }
80 }
81
82 return list;
83}
84
85void ModemManager::ModemVoicePrivate::onCallAdded(const QDBusObjectPath &path)
86{
87 Q_Q(ModemVoice);
88 callList.insert(path.path(), ModemManager::Call::Ptr());
89 Q_EMIT q->callAdded(path.path());
90}
91
92void ModemManager::ModemVoicePrivate::onCallDeleted(const QDBusObjectPath &path)
93{
94 Q_Q(ModemVoice);
95 callList.remove(path.path());
96 Q_EMIT q->callDeleted(path.path());
97}
98
100{
101 Q_D(const ModemVoice);
102 return const_cast<ModemVoicePrivate *>(d)->calls();
103}
104
106{
107 QVariantMap map;
108 map.insert(QStringLiteral("number"), number);
109 return createCall(map);
110}
111
113{
115
116 if (!call.contains(QLatin1String("number"))) {
117 qCDebug(MMQT) << "Unable to create call, missing some property";
119 }
120
121 return d->modemVoiceIface.CreateCall(call);
122}
123
125{
127 return d->modemVoiceIface.DeleteCall(QDBusObjectPath(uni));
128}
129
131{
133 return d->findCall(uni);
134}
135
137{
139 d->modemVoiceIface.setTimeout(timeout);
140}
141
143{
144 Q_D(const ModemVoice);
145 return d->modemVoiceIface.timeout();
146}
147
148#include "moc_modemvoice.cpp"
Provides an interface to manipulate and control a call.
Definition call.h:29
The ModemVoice class.
Definition modemvoice.h:29
ModemManager::Call::Ptr findCall(const QString &uni)
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
QDBusPendingReply< void > deleteCall(const QString &uni)
Delete a call.
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
QDBusPendingReply< QDBusObjectPath > createCall(const QString &number)
Creates a new call object.
ModemManager::Call::List calls() const
Retrieve all calls.
QString path(const QString &relativePath)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QString path() const const
void append(QList< T > &&value)
void deleteLater()
QString & insert(qsizetype position, QChar ch)
Q_D(Todo)
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.