2015-07-05 14:23:53 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2015 Vineet Garg <grg.vineet@gmail.com>
|
2015-07-05 14:23:53 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2015-07-05 14:23:53 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KDECONNECT_LANPAIRINGHANDLER_H
|
|
|
|
#define KDECONNECT_LANPAIRINGHANDLER_H
|
|
|
|
|
2016-07-05 13:13:48 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2015-07-27 16:28:58 +01:00
|
|
|
#include "device.h"
|
2016-07-05 13:27:53 +01:00
|
|
|
#include "backends/devicelink.h"
|
|
|
|
#include "backends/pairinghandler.h"
|
2015-07-05 14:23:53 +01:00
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
// This class is used pairing related stuff. It has direct access to links and can directly send packets
|
2015-07-05 14:23:53 +01:00
|
|
|
class LanPairingHandler
|
|
|
|
: public PairingHandler
|
|
|
|
{
|
2016-11-26 15:05:56 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2015-07-05 14:23:53 +01:00
|
|
|
public:
|
2015-12-01 18:45:14 +00:00
|
|
|
|
|
|
|
enum InternalPairStatus {
|
|
|
|
NotPaired,
|
|
|
|
Requested,
|
|
|
|
RequestedByPeer,
|
|
|
|
Paired,
|
|
|
|
};
|
|
|
|
|
2015-12-17 13:54:24 +00:00
|
|
|
LanPairingHandler(DeviceLink* deviceLink);
|
2016-06-20 08:05:02 +01:00
|
|
|
~LanPairingHandler() override { }
|
2015-07-05 14:23:53 +01:00
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
void packetReceived(const NetworkPacket& np) override;
|
2016-06-20 08:05:02 +01:00
|
|
|
bool requestPairing() override;
|
|
|
|
bool acceptPairing() override;
|
|
|
|
void rejectPairing() override;
|
|
|
|
void unpair() override;
|
2015-07-05 14:23:53 +01:00
|
|
|
|
2015-12-01 18:45:14 +00:00
|
|
|
bool isPairRequested() const { return m_status == Requested; }
|
|
|
|
bool isPaired() const { return m_status == Paired; }
|
|
|
|
|
2015-11-30 18:36:01 +00:00
|
|
|
private Q_SLOTS:
|
2015-12-01 18:45:14 +00:00
|
|
|
void pairingTimeout();
|
2015-07-27 16:28:58 +01:00
|
|
|
|
2015-11-30 18:36:01 +00:00
|
|
|
protected:
|
2015-12-01 18:45:14 +00:00
|
|
|
void setInternalPairStatus(InternalPairStatus status);
|
|
|
|
|
2015-11-30 18:36:01 +00:00
|
|
|
QTimer m_pairingTimeout;
|
2015-07-05 14:23:53 +01:00
|
|
|
|
2015-12-01 18:45:14 +00:00
|
|
|
InternalPairStatus m_status;
|
2015-07-05 14:23:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //KDECONNECT_LANPAIRINGHANDLER_H
|