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 | |
15 | namespace BluezQt |
16 | { |
17 | LEAdvertisementAdaptor::LEAdvertisementAdaptor(LEAdvertisement *parent) |
18 | : QDBusAbstractAdaptor(parent) |
19 | , m_advertisement(parent) |
20 | { |
21 | qDBusRegisterMetaType<QHash<QString, QVariant>>(); |
22 | } |
23 | |
24 | QString LEAdvertisementAdaptor::type() const |
25 | { |
26 | return QStringLiteral("peripheral" ); |
27 | } |
28 | |
29 | QStringList LEAdvertisementAdaptor::serviceUuids() const |
30 | { |
31 | return m_advertisement->serviceUuids(); |
32 | } |
33 | |
34 | QHash<QString, QVariant> LEAdvertisementAdaptor::serviceData() const |
35 | { |
36 | // bluez wants the value wrapped into a variant... |
37 | QHash<QString, QVariant> data; |
38 | const auto sd = m_advertisement->serviceData(); |
39 | data.reserve(sd.size()); |
40 | for (auto it = sd.begin(); it != sd.end(); ++it) { |
41 | data.insert(it.key(), it.value()); |
42 | } |
43 | return data; |
44 | } |
45 | |
46 | void LEAdvertisementAdaptor::Release() |
47 | { |
48 | m_advertisement->release(); |
49 | } |
50 | |
51 | } // namespace BluezQt |
52 | |
53 | #include "moc_leadvertisementadaptor.cpp" |
54 | |