BluezQt

leadvertisingmanager.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 "leadvertisingmanager.h"
10 #include "debug.h"
11 #include "leadvertisement.h"
12 #include "leadvertisementadaptor.h"
13 #include "leadvertisingmanager_p.h"
14 #include "pendingcall.h"
15 #include "utils.h"
16 
17 namespace BluezQt
18 {
19 LEAdvertisingManager::LEAdvertisingManager(const QString &path, QObject *parent)
20  : QObject(parent)
21  , d(new LEAdvertisingManagerPrivate())
22 {
23  d->m_path = path;
24  d->m_bluezLEAdvertisingManager = new BluezLEAdvertisingManager(Strings::orgBluez(), path, DBusConnection::orgBluez(), this);
25 }
26 
28 {
29  delete d;
30 }
31 
33 {
34  Q_ASSERT(advertisement);
35 
36  if (!d->m_bluezLEAdvertisingManager) {
37  return new PendingCall(PendingCall::InternalError, QStringLiteral("LEAdvertisingManager not operational!"));
38  }
39 
40  new LEAdvertisementAdaptor(advertisement);
41 
42  if (!DBusConnection::orgBluez().registerObject(advertisement->objectPath().path(), advertisement)) {
43  qCDebug(BLUEZQT) << "Cannot register object" << advertisement->objectPath().path();
44  }
45 
46  return new PendingCall(d->m_bluezLEAdvertisingManager->RegisterAdvertisement(advertisement->objectPath(), QVariantMap()), PendingCall::ReturnVoid, this);
47 }
48 
50 {
51  Q_ASSERT(advertisement);
52 
53  if (!d->m_bluezLEAdvertisingManager) {
54  return new PendingCall(PendingCall::InternalError, QStringLiteral("LEAdvertisingManager not operational!"));
55  }
56 
57  DBusConnection::orgBluez().unregisterObject(advertisement->objectPath().path());
58 
59  return new PendingCall(d->m_bluezLEAdvertisingManager->UnregisterAdvertisement(advertisement->objectPath()), PendingCall::ReturnVoid, this);
60 }
61 
62 } // namespace BluezQt
@ InternalError
Indicates an internal error.
Definition: pendingcall.h:95
QString path() const const
~LEAdvertisingManager() override
Destroys an LEAdvertisingManager object.
PendingCall * unregisterAdvertisement(LEAdvertisement *advertisement)
Unregisters advertisement.
PendingCall * registerAdvertisement(LEAdvertisement *advertisement)
Registers advertisement.
virtual QDBusObjectPath objectPath() const
D-Bus object path of the advertisement.
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.