2020-03-13 23:05:18 +03:00
|
|
|
#pragma once
|
|
|
|
|
2020-06-07 14:35:32 +03:00
|
|
|
#include <MatrixClient.h>
|
2020-03-13 23:05:18 +03:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
class DeviceVerificationFlow : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
// Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
|
2020-06-07 14:35:32 +03:00
|
|
|
Q_PROPERTY(QString userId READ getUserId WRITE setUserId)
|
|
|
|
Q_PROPERTY(QString deviceId READ getDeviceId WRITE setDeviceId)
|
|
|
|
Q_PROPERTY(Method method READ getMethod WRITE setMethod)
|
2020-03-13 23:05:18 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum Method
|
|
|
|
{
|
|
|
|
Decimal,
|
|
|
|
Emoji
|
|
|
|
};
|
|
|
|
Q_ENUM(Method)
|
|
|
|
|
|
|
|
DeviceVerificationFlow(QObject *parent = nullptr);
|
2020-06-07 14:35:32 +03:00
|
|
|
QString getUserId();
|
|
|
|
QString getDeviceId();
|
|
|
|
Method getMethod();
|
|
|
|
void setUserId(QString userID);
|
|
|
|
void setDeviceId(QString deviceID);
|
|
|
|
void setMethod(Method method_);
|
2020-03-13 23:05:18 +03:00
|
|
|
|
|
|
|
public slots:
|
2020-06-04 16:44:15 +03:00
|
|
|
//! sends a verification request
|
|
|
|
void sendVerificationRequest();
|
|
|
|
//! accepts a verification
|
2020-03-13 23:05:18 +03:00
|
|
|
void acceptVerificationRequest();
|
2020-06-04 16:44:15 +03:00
|
|
|
//! starts the verification flow
|
|
|
|
void startVerificationRequest();
|
2020-03-13 23:05:18 +03:00
|
|
|
//! cancels a verification flow
|
|
|
|
void cancelVerification();
|
|
|
|
//! Completes the verification flow
|
|
|
|
void acceptDevice();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void verificationRequestAccepted(Method method);
|
|
|
|
void deviceVerified();
|
|
|
|
void timedout();
|
|
|
|
void verificationCanceled();
|
|
|
|
|
|
|
|
private:
|
2020-06-07 14:35:32 +03:00
|
|
|
QString userId;
|
|
|
|
QString deviceId;
|
|
|
|
Method method;
|
2020-06-04 16:44:15 +03:00
|
|
|
|
2020-03-13 23:05:18 +03:00
|
|
|
QTimer *timeout = nullptr;
|
2020-06-04 16:44:15 +03:00
|
|
|
std::string transaction_id;
|
2020-06-07 14:35:32 +03:00
|
|
|
mtx::identifiers::User toClient;
|
2020-03-13 23:05:18 +03:00
|
|
|
};
|