File indexing completed on 2024-12-01 12:29:49

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #include "leadvertisementadaptor.h"
0010 #include "leadvertisement.h"
0011 
0012 #include <QDBusMetaType>
0013 #include <QDBusObjectPath>
0014 
0015 namespace BluezQt
0016 {
0017 LEAdvertisementAdaptor::LEAdvertisementAdaptor(LEAdvertisement *parent)
0018     : QDBusAbstractAdaptor(parent)
0019     , m_advertisement(parent)
0020 {
0021     qDBusRegisterMetaType<QHash<QString, QVariant>>();
0022 }
0023 
0024 QString LEAdvertisementAdaptor::type() const
0025 {
0026     return QStringLiteral("peripheral");
0027 }
0028 
0029 QStringList LEAdvertisementAdaptor::serviceUuids() const
0030 {
0031     return m_advertisement->serviceUuids();
0032 }
0033 
0034 QHash<QString, QVariant> LEAdvertisementAdaptor::serviceData() const
0035 {
0036     // bluez wants the value wrapped into a variant...
0037     QHash<QString, QVariant> data;
0038     const auto sd = m_advertisement->serviceData();
0039     data.reserve(sd.size());
0040     for (auto it = sd.begin(); it != sd.end(); ++it) {
0041         data.insert(it.key(), it.value());
0042     }
0043     return data;
0044 }
0045 
0046 void LEAdvertisementAdaptor::Release()
0047 {
0048     m_advertisement->release();
0049 }
0050 
0051 } // namespace BluezQt
0052 
0053 #include "moc_leadvertisementadaptor.cpp"