BluezQt

leadvertisementadaptor.cpp
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "leadvertisementadaptor.h"
10#include "leadvertisement.h"
11
12#include <QDBusMetaType>
13#include <QDBusObjectPath>
14
15namespace BluezQt
16{
17LEAdvertisementAdaptor::LEAdvertisementAdaptor(LEAdvertisement *parent)
18 : QDBusAbstractAdaptor(parent)
19 , m_advertisement(parent)
20{
21 qDBusRegisterMetaType<QHash<QString, QVariant>>();
22 qDBusRegisterMetaType<QHash<quint16, QDBusVariant>>();
23}
24
25QString LEAdvertisementAdaptor::type() const
26{
27 return QStringLiteral("peripheral");
28}
29
30QStringList LEAdvertisementAdaptor::serviceUuids() const
31{
32 return m_advertisement->serviceUuids();
33}
34
35QHash<QString, QVariant> LEAdvertisementAdaptor::serviceData() const
36{
37 // bluez wants the value wrapped into a variant...
39 const auto sd = m_advertisement->serviceData();
40 data.reserve(sd.size());
41 for (auto it = sd.begin(); it != sd.end(); ++it) {
42 data.insert(it.key(), it.value());
43 }
44 return data;
45}
46
47QHash<quint16, QDBusVariant> LEAdvertisementAdaptor::manufacturerData() const
48{
50
51 const auto &md = m_advertisement->manufacturerData();
52 data.reserve(md.size());
53
54 for (auto it = md.cbegin(); it != md.cend(); ++it) {
55 data.insert(it.key(), QDBusVariant(QVariant::fromValue(it.value())));
56 }
57
58 return data;
59}
60
61void LEAdvertisementAdaptor::Release()
62{
63 m_advertisement->release();
64}
65
66} // namespace BluezQt
67
68#include "moc_leadvertisementadaptor.cpp"
iterator insert(const Key &key, const T &value)
void reserve(qsizetype size)
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:00:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.