File indexing completed on 2024-04-28 16:42:52

0001 // SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru>
0002 //
0003 // SPDX-License-Identifier: LicenseRef-KDE-Accepted-GPL
0004 
0005 #include "declarative-call-utils.h"
0006 
0007 DeclarativeCallUtils::DeclarativeCallUtils(QObject *parent)
0008     : org::kde::telephony::CallUtils(QString::fromLatin1(staticInterfaceName()),
0009                                      QStringLiteral("/org/kde/telephony/CallUtils/tel/mm"),
0010                                      QDBusConnection::sessionBus(),
0011                                      parent)
0012 {
0013     if (!isValid()) {
0014         qDebug() << Q_FUNC_INFO << "Could not initiate CallUtils interface";
0015         return;
0016     }
0017 }
0018 
0019 void DeclarativeCallUtils::accept(const QString &deviceUni, const QString &callUni)
0020 {
0021     if (!isValid()) {
0022         qDebug() << Q_FUNC_INFO << "CallUtils is not initiated";
0023         return;
0024     }
0025     org::kde::telephony::CallUtils::accept(deviceUni, callUni);
0026 }
0027 
0028 void DeclarativeCallUtils::dial(const QString &deviceUni, const QString &number)
0029 {
0030     if (!isValid()) {
0031         qDebug() << Q_FUNC_INFO << "CallUtils is not initiated";
0032         return;
0033     }
0034     org::kde::telephony::CallUtils::dial(deviceUni, number);
0035 }
0036 
0037 void DeclarativeCallUtils::hangUp(const QString &deviceUni, const QString &callUni)
0038 {
0039     if (!isValid()) {
0040         qDebug() << Q_FUNC_INFO << "CallUtils is not initiated";
0041         return;
0042     }
0043     org::kde::telephony::CallUtils::hangUp(deviceUni, callUni);
0044 }
0045 
0046 void DeclarativeCallUtils::sendDtmf(const QString &deviceUni, const QString &callUni, const QString &tones)
0047 {
0048     if (!isValid()) {
0049         qDebug() << Q_FUNC_INFO << "CallUtils is not initiated";
0050         return;
0051     }
0052     org::kde::telephony::CallUtils::sendDtmf(deviceUni, callUni, tones);
0053 }
0054 
0055 QString DeclarativeCallUtils::formatNumber(const QString &number)
0056 {
0057     QDBusPendingReply<QString> reply;
0058     if (!isValid()) {
0059         qDebug() << Q_FUNC_INFO << "CallUtils is not initiated";
0060         return reply.value();
0061     }
0062     reply = org::kde::telephony::CallUtils::formatNumber(number);
0063     reply.waitForFinished();
0064     if (reply.isError()) {
0065         qDebug() << Q_FUNC_INFO << reply.error();
0066     }
0067     return reply;
0068 }