File indexing completed on 2024-04-28 15:17:53

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