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_PAIRINGHANDLER_H
|
|
|
|
#define KDECONNECT_PAIRINGHANDLER_H
|
|
|
|
|
2023-06-01 01:25:37 +01:00
|
|
|
#include "device.h"
|
2022-09-10 22:23:52 +01:00
|
|
|
#include "networkpacket.h"
|
2023-06-01 01:25:37 +01:00
|
|
|
#include "pairstate.h"
|
2015-07-05 14:23:53 +01:00
|
|
|
|
2023-06-01 01:25:37 +01:00
|
|
|
#include <QTimer>
|
2015-08-11 04:34:02 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
class KDECONNECTCORE_EXPORT PairingHandler : public QObject
|
2015-07-25 12:45:19 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-11-30 18:36:01 +00:00
|
|
|
public:
|
2023-06-01 01:25:37 +01:00
|
|
|
const static int pairingTimeoutMsec = 30 * 1000; // 30 seconds of timeout
|
|
|
|
|
|
|
|
PairingHandler(Device *parent, PairState initialState);
|
2015-07-05 14:23:53 +01:00
|
|
|
|
2023-06-01 01:25:37 +01:00
|
|
|
void packetReceived(const NetworkPacket &np);
|
2015-07-27 16:28:58 +01:00
|
|
|
|
2023-07-16 15:20:34 +01:00
|
|
|
PairState pairState()
|
|
|
|
{
|
|
|
|
return m_pairState;
|
|
|
|
}
|
2015-07-25 12:45:19 +01:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
2023-06-01 01:25:37 +01:00
|
|
|
bool requestPairing();
|
|
|
|
bool acceptPairing();
|
|
|
|
void cancelPairing();
|
|
|
|
void unpair();
|
2015-07-27 16:28:58 +01:00
|
|
|
|
2015-11-30 18:36:01 +00:00
|
|
|
Q_SIGNALS:
|
2023-06-01 01:25:37 +01:00
|
|
|
void incomingPairRequest();
|
|
|
|
void pairingFailed(const QString &errorMessage);
|
|
|
|
void pairingSuccessful();
|
|
|
|
void unpaired();
|
|
|
|
|
2015-07-27 16:28:58 +01:00
|
|
|
private:
|
2023-06-01 01:25:37 +01:00
|
|
|
void pairingDone();
|
|
|
|
|
|
|
|
QTimer m_pairingTimeout;
|
|
|
|
Device *m_device;
|
|
|
|
PairState m_pairState;
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void pairingTimeout();
|
2015-07-05 14:23:53 +01:00
|
|
|
};
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
#endif // KDECONNECT_PAIRINGHANDLER_H
|