1 | // Copyright (C) 2020 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef REMOTEDEVICEMANAGER_P_H |
5 | #define REMOTEDEVICEMANAGER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <deque> |
19 | |
20 | #include <QList> |
21 | #include <QMutex> |
22 | #include <QObject> |
23 | |
24 | #include <QtBluetooth/qbluetoothaddress.h> |
25 | #include <QtCore/private/qglobal_p.h> |
26 | |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | |
30 | // This API is kept a bit more generic in anticipation of further changes in the future. |
31 | |
32 | class RemoteDeviceManager : public QObject |
33 | { |
34 | Q_OBJECT |
35 | public: |
36 | enum class JobType |
37 | { |
38 | JobDisconnectDevice, |
39 | }; |
40 | |
41 | explicit RemoteDeviceManager(const QBluetoothAddress& localAddress, QObject *parent = nullptr); |
42 | |
43 | bool isJobInProgress() const { return jobInProgress; } |
44 | bool scheduleJob(JobType job, const QList<QBluetoothAddress> &remoteDevices); |
45 | |
46 | signals: |
47 | void finished(); |
48 | |
49 | private slots: |
50 | void runQueue(); |
51 | void prepareNextJob(); |
52 | |
53 | private: |
54 | void disconnectDevice(const QBluetoothAddress& remote); |
55 | |
56 | bool jobInProgress = false; |
57 | QBluetoothAddress localAddress; |
58 | std::deque<std::pair<JobType, QBluetoothAddress>> jobQueue; |
59 | QString adapterPath; |
60 | }; |
61 | |
62 | QT_END_NAMESPACE |
63 | |
64 | #endif // REMOTEDEVICEMANAGER_P_H |
65 | |