2022-09-06 11:36:55 +08:00
|
|
|
// SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2020-05-14 13:09:26 +08:00
|
|
|
|
|
|
|
#ifndef ADAPTERSMANAGER_H
|
|
|
|
#define ADAPTERSMANAGER_H
|
|
|
|
|
|
|
|
#include <com_deepin_daemon_bluetooth.h>
|
|
|
|
using DBusBluetooth = com::deepin::daemon::Bluetooth;
|
|
|
|
|
2020-04-01 16:18:12 +08:00
|
|
|
class Adapter;
|
|
|
|
class Device;
|
2020-05-14 13:09:26 +08:00
|
|
|
class AdaptersManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit AdaptersManager(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
void setAdapterPowered(const Adapter *adapter, const bool &powered);
|
2021-01-08 14:33:08 +08:00
|
|
|
void connectDevice(const Device *device, Adapter *adapter);
|
2020-05-14 13:09:26 +08:00
|
|
|
int adaptersCount();
|
2020-06-10 15:49:55 +08:00
|
|
|
void adapterRefresh(const Adapter *adapter);
|
2020-05-14 13:09:26 +08:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void adapterIncreased(Adapter *adapter);
|
|
|
|
void adapterDecreased(Adapter *adapter);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onAdapterPropertiesChanged(const QString &json);
|
|
|
|
void onDevicePropertiesChanged(const QString &json);
|
|
|
|
|
2021-01-08 14:33:08 +08:00
|
|
|
void onAddAdapter(const QString &json);
|
|
|
|
void onRemoveAdapter(const QString &json);
|
2020-05-14 13:09:26 +08:00
|
|
|
|
2021-01-08 14:33:08 +08:00
|
|
|
void onAddDevice(const QString &json);
|
|
|
|
void onRemoveDevice(const QString &json);
|
2020-05-14 13:09:26 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void adapterAdd(Adapter *adapter, const QJsonObject &adpterObj);
|
|
|
|
void inflateAdapter(Adapter *adapter, const QJsonObject &adapterObj);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DBusBluetooth *m_bluetoothInter;
|
|
|
|
QMap<QString, const Adapter *> m_adapters;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ADAPTERSMANAGER_H
|