File indexing completed on 2024-12-01 12:29:51

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #ifndef BLUEZQT_RFKILL_H
0010 #define BLUEZQT_RFKILL_H
0011 
0012 #include <QHash>
0013 #include <QObject>
0014 
0015 #include "bluezqt_export.h"
0016 
0017 #include <memory>
0018 
0019 namespace BluezQt
0020 {
0021 struct RfkillPrivate;
0022 
0023 class BLUEZQT_EXPORT Rfkill : public QObject
0024 {
0025     Q_OBJECT
0026     Q_PROPERTY(State state READ state NOTIFY stateChanged)
0027 
0028 public:
0029     enum State {
0030         Unblocked = 0,
0031         SoftBlocked = 1,
0032         HardBlocked = 2,
0033         Unknown = 3,
0034     };
0035     Q_ENUM(State)
0036 
0037     explicit Rfkill(QObject *parent = nullptr);
0038     ~Rfkill() override;
0039 
0040     State state() const;
0041     bool block();
0042     bool unblock();
0043 
0044 Q_SIGNALS:
0045     void stateChanged(State state);
0046 
0047 private Q_SLOTS:
0048     BLUEZQT_NO_EXPORT void devReadyRead();
0049 
0050 private:
0051     BLUEZQT_NO_EXPORT void init();
0052     BLUEZQT_NO_EXPORT bool openForWriting();
0053     BLUEZQT_NO_EXPORT void updateRfkillDevices();
0054     BLUEZQT_NO_EXPORT bool setSoftBlock(quint8 soft);
0055 
0056     std::unique_ptr<RfkillPrivate> d;
0057 };
0058 
0059 } // namespace BluezQt
0060 
0061 #endif // BLUEZQT_RFKILL_H