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-device-utils.h"
0006 
0007 DeclarativeDeviceUtils::DeclarativeDeviceUtils(QObject *parent)
0008     : QObject(parent)
0009 {
0010 }
0011 
0012 void DeclarativeDeviceUtils::setDeviceUtils(org::kde::telephony::DeviceUtils *deviceUtils)
0013 {
0014     if (!deviceUtils) {
0015         qDebug() << Q_FUNC_INFO << "Could not initiate DeviceUtils interface";
0016         return;
0017     }
0018     _deviceUtils = deviceUtils;
0019     connect(_deviceUtils, &org::kde::telephony::DeviceUtils::deviceUniListChanged, this, &DeclarativeDeviceUtils::deviceUniListChanged);
0020 }
0021 
0022 QStringList DeclarativeDeviceUtils::deviceUniList()
0023 {
0024     QDBusPendingReply<QStringList> reply;
0025     if (!_deviceUtils) {
0026         qDebug() << Q_FUNC_INFO << "DeviceUtils is not initiated";
0027         return reply.value();
0028     }
0029     reply = _deviceUtils->deviceUniList();
0030     reply.waitForFinished();
0031     if (reply.isError()) {
0032         qDebug() << Q_FUNC_INFO << reply.error();
0033     }
0034     return reply.value();
0035 }
0036 
0037 QStringList DeclarativeDeviceUtils::equipmentIdentifiers()
0038 {
0039     QDBusPendingReply<QStringList> reply;
0040     if (!_deviceUtils) {
0041         qDebug() << Q_FUNC_INFO << "DeviceUtils is not initiated";
0042         return reply.value();
0043     }
0044     reply = _deviceUtils->equipmentIdentifiers();
0045     reply.waitForFinished();
0046     if (reply.isError()) {
0047         qDebug() << Q_FUNC_INFO << reply.error();
0048     }
0049     return reply.value();
0050 }
0051 
0052 void DeclarativeDeviceUtils::setDeviceUniList(const QStringList &newDeviceUniList)
0053 {
0054     if (!_deviceUtils) {
0055         qDebug() << Q_FUNC_INFO << "DeviceUtils is not initiated";
0056         return;
0057     }
0058     _deviceUtils->setDeviceUniList(newDeviceUniList);
0059 }