File indexing completed on 2025-01-19 06:44:36
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 #ifndef BLUEZQT_LEADVERTISEMENT_H 0010 #define BLUEZQT_LEADVERTISEMENT_H 0011 0012 #include <QObject> 0013 0014 #include "bluezqt_export.h" 0015 0016 #include <memory> 0017 0018 class QDBusObjectPath; 0019 0020 namespace BluezQt 0021 { 0022 /** 0023 * @class BluezQt::LEAdvertisement leadvertisement.h <BluezQt/LEAdvertisement> 0024 * 0025 * Bluetooth LE advertisement. 0026 * 0027 * This class represents a Bluetooth LE advertisement. 0028 */ 0029 class BLUEZQT_EXPORT LEAdvertisement : public QObject 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 /** 0035 * Creates a new LEAdvertisement object. 0036 * 0037 * @param parent 0038 */ 0039 explicit LEAdvertisement(const QStringList &serviceUuids, QObject *parent = nullptr); 0040 0041 /** 0042 * Destroys a LEAdvertisement object. 0043 */ 0044 ~LEAdvertisement() override; 0045 0046 /** 0047 * List of UUIDs to include in the "Service UUID" field of the Advertising Data. 0048 * 0049 * @return UUIDs of the advertisement 0050 */ 0051 virtual QStringList serviceUuids() const; 0052 0053 /** 0054 * Returns the service data included in the advertisement. 0055 * 0056 * @since 5.75 0057 */ 0058 QHash<QString, QByteArray> serviceData() const; 0059 0060 /** 0061 * Sets the service data to include in the advertisement. 0062 * Keys are the UUIDs of the associated data. 0063 * 0064 * @since 5.75 0065 */ 0066 void setServiceData(const QHash<QString, QByteArray> &data); 0067 0068 /** 0069 * Indicates that the LEAdvertisement was unregistered. 0070 * 0071 * This method gets called when the service daemon removes the Advertisement. 0072 * A client can use it to do cleanup tasks. There is no need to call 0073 * UnregisterAdvertisement because when this method gets called it has 0074 * already been unregistered. 0075 */ 0076 virtual void release(); 0077 0078 protected: 0079 /** 0080 * D-Bus object path of the advertisement. 0081 * 0082 * The path where the advertisement will be registered. 0083 * 0084 * @note You must provide valid object path! 0085 * 0086 * @return object path of advertisement 0087 */ 0088 virtual QDBusObjectPath objectPath() const; 0089 0090 private: 0091 std::unique_ptr<class LEAdvertisementPrivate> const d; 0092 0093 friend class LEAdvertisingManager; 0094 }; 0095 0096 } // namespace BluezQt 0097 0098 #endif // BLUEZQT_LEADVERTISEMENT_H