kdeconnect-kde/core/backends/bluetooth/bluetoothlinkprovider.h

73 lines
2.1 KiB
C
Raw Normal View History

/**
* SPDX-FileCopyrightText: 2016 Saikrishna Arcot <saiarcot895@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef BLUETOOTHLINKPROVIDER_H
#define BLUETOOTHLINKPROVIDER_H
#include <QObject>
2016-11-11 14:55:16 +00:00
#include <QPointer>
#include <QTimer>
2019-02-03 00:44:22 +00:00
#include <QBluetoothAddress>
#include <QBluetoothLocalDevice>
#include <QBluetoothUuid>
#include <QBluetoothServer>
#include <QBluetoothDeviceDiscoveryAgent>
#include <QBluetoothServiceDiscoveryAgent>
#include <QBluetoothSocket>
#include "../linkprovider.h"
class BluetoothDeviceLink;
class ConnectionMultiplexer;
class MultiplexChannel;
2016-11-11 14:55:16 +00:00
class KDECONNECTCORE_EXPORT BluetoothLinkProvider
: public LinkProvider
{
Q_OBJECT
public:
BluetoothLinkProvider();
2016-11-11 14:55:16 +00:00
virtual ~BluetoothLinkProvider();
QString name() override { return QStringLiteral("BluetoothLinkProvider"); }
2016-11-11 14:55:16 +00:00
int priority() override { return PRIORITY_MEDIUM; }
public Q_SLOTS:
2016-11-11 14:55:16 +00:00
virtual void onNetworkChange() override;
virtual void onStart() override;
virtual void onStop() override;
void connectError();
private Q_SLOTS:
void deviceLinkDestroyed(QObject* destroyedDeviceLink);
void socketDisconnected(const QBluetoothAddress &peerAddress, MultiplexChannel *socket);
void serverNewConnection();
void serverDataReceived(const QBluetoothAddress &peerAddress, QSharedPointer<MultiplexChannel> socket);
void clientConnected(QPointer<QBluetoothSocket> socket);
void clientIdentityReceived(const QBluetoothAddress &peerAddress, QSharedPointer<MultiplexChannel> socket);
void serviceDiscovered(const QBluetoothServiceInfo &info);
private:
void addLink(BluetoothDeviceLink* deviceLink, const QString& deviceId);
QList<QBluetoothAddress> getPairedDevices();
QBluetoothUuid mServiceUuid;
2016-11-11 14:55:16 +00:00
QPointer<QBluetoothServer> mBluetoothServer;
QBluetoothServiceInfo mKdeconnectService;
QBluetoothServiceDiscoveryAgent* mServiceDiscoveryAgent;
QTimer* connectTimer;
QMap<QString, DeviceLink*> mLinks;
QMap<QBluetoothAddress, ConnectionMultiplexer*> mSockets;
};
#endif