BluezQt

leadvertisementadaptor.cpp
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <[email protected]>
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...
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
QHash::iterator insert(const Key &key, const T &value)
void reserve(int size)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.