| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "leadvertisingmanagerinterface.h" |
| 8 |
|
| 9 |
#include <QDBusConnection> |
| 10 |
#include <QDBusMessage> |
| 11 |
#include <QDBusPendingCall> |
| 12 |
|
| 13 |
LEAdvertisingManagerInterface::LEAdvertisingManagerInterface(const QDBusObjectPath &path, QObject *parent) |
| 14 |
: QDBusAbstractAdaptor(parent) |
| 15 |
{ |
| 16 |
setName(QStringLiteral("org.bluez.LEAdvertisingManager1")); |
| 17 |
setPath(path); |
| 18 |
} |
| 19 |
|
| 20 |
void LEAdvertisingManagerInterface::runAction(const QString &actionName, const QVariantMap & /*properties*/) |
| 21 |
{ |
| 22 |
if (actionName == QLatin1String("release")) { |
| 23 |
runReleaseAction(); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
void LEAdvertisingManagerInterface::RegisterAdvertisement(const QDBusObjectPath &path, const QVariantMap & /*options*/, const QDBusMessage &msg) |
| 28 |
{ |
| 29 |
m_advertisement = path; |
| 30 |
m_service = msg.service(); |
| 31 |
} |
| 32 |
|
| 33 |
void LEAdvertisingManagerInterface::UnregisterAdvertisement(const QDBusObjectPath &path, const QDBusMessage &msg) |
| 34 |
{ |
| 35 |
if (m_advertisement == path && m_service == msg.service()) { |
| 36 |
m_advertisement = QDBusObjectPath(); |
| 37 |
m_service.clear(); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
void LEAdvertisingManagerInterface::runReleaseAction() |
| 42 |
{ |
| 43 |
QDBusMessage call = |
| 44 |
QDBusMessage::createMethodCall(m_service, m_advertisement.path(), QStringLiteral("org.bluez.LEAdvertisement1"), QStringLiteral("Release")); |
| 45 |
QDBusConnection::sessionBus().asyncCall(call); |
| 46 |
} |
| 47 |
|
| 48 |
#include "moc_leadvertisingmanagerinterface.cpp" |