summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-03-13 21:05:18 +0100
committerCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-07-30 22:10:27 +0530
commit2088053d26fc124058fafb434d41b7c9516f0da0 (patch)
tree8b7831e522a839f5c7674d87d3e4fec6b9518a03 /src
parentFirst design iteration of device verification dialogs (diff)
downloadnheko-2088053d26fc124058fafb434d41b7c9516f0da0.tar.xz
Add DeviceVerificationFlow dummy and verification test button
Diffstat (limited to 'src')
-rw-r--r--src/DeviceVerificationFlow.cpp36
-rw-r--r--src/DeviceVerificationFlow.h38
-rw-r--r--src/timeline/TimelineViewManager.cpp7
-rw-r--r--src/timeline/TimelineViewManager.h3
4 files changed, 84 insertions, 0 deletions
diff --git a/src/DeviceVerificationFlow.cpp b/src/DeviceVerificationFlow.cpp
new file mode 100644

index 00000000..69d6ab9c --- /dev/null +++ b/src/DeviceVerificationFlow.cpp
@@ -0,0 +1,36 @@ +#include "DeviceVerificationFlow.h" + +#include <QTimer> + +static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes + +DeviceVerificationFlow::DeviceVerificationFlow(QObject *) +{ + timeout = new QTimer(this); + timeout->setSingleShot(true); + connect(timeout, &QTimer::timeout, this, [this]() { + emit timedout(); + this->deleteLater(); + }); + timeout->start(TIMEOUT); +} + +//! accepts a verification and starts the verification flow +void +DeviceVerificationFlow::acceptVerificationRequest() +{ + emit verificationRequestAccepted(rand() % 2 ? Emoji : Decimal); +} +//! cancels a verification flow +void +DeviceVerificationFlow::cancelVerification() +{ + this->deleteLater(); +} +//! Completes the verification flow +void +DeviceVerificationFlow::acceptDevice() +{ + emit deviceVerified(); + this->deleteLater(); +} diff --git a/src/DeviceVerificationFlow.h b/src/DeviceVerificationFlow.h new file mode 100644
index 00000000..038f1e13 --- /dev/null +++ b/src/DeviceVerificationFlow.h
@@ -0,0 +1,38 @@ +#pragma once + +#include <QObject> + +class QTimer; + +class DeviceVerificationFlow : public QObject +{ + Q_OBJECT + // Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") + +public: + enum Method + { + Decimal, + Emoji + }; + Q_ENUM(Method) + + DeviceVerificationFlow(QObject *parent = nullptr); + +public slots: + //! accepts a verification and starts the verification flow + void acceptVerificationRequest(); + //! cancels a verification flow + void cancelVerification(); + //! Completes the verification flow + void acceptDevice(); + +signals: + void verificationRequestAccepted(Method method); + void deviceVerified(); + void timedout(); + void verificationCanceled(); + +private: + QTimer *timeout = nullptr; +}; diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index 975dd5fb..8447619a 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -85,6 +85,7 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin "Can't instantiate enum!"); qmlRegisterType<DelegateChoice>("im.nheko", 1, 0, "DelegateChoice"); qmlRegisterType<DelegateChooser>("im.nheko", 1, 0, "DelegateChooser"); + qmlRegisterType<DeviceVerificationFlow>("im.nheko", 1, 0, "DeviceVerificationFlow"); qRegisterMetaType<mtx::events::collections::TimelineEvents>(); qmlRegisterType<emoji::EmojiModel>("im.nheko.EmojiModel", 1, 0, "EmojiModel"); qmlRegisterType<emoji::EmojiProxyModel>("im.nheko.EmojiModel", 1, 0, "EmojiProxyModel"); @@ -460,3 +461,9 @@ TimelineViewManager::queueVideoMessage(const QString &roomid, model->sendMessage(video); } + +void +TimelineViewManager::startDummyVerification() +{ + emit deviceVerificationRequest(new DeviceVerificationFlow(this)); +} diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 63106916..583a9e4c 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h
@@ -10,6 +10,7 @@ #include <mtx/responses.hpp> #include "Cache.h" +#include "DeviceVerificationFlow.h" #include "Logging.h" #include "TimelineModel.h" #include "Utils.h" @@ -43,6 +44,7 @@ public: Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const; Q_INVOKABLE QColor userColor(QString id, QColor background); + Q_INVOKABLE void startDummyVerification(); Q_INVOKABLE QString userPresence(QString id) const; Q_INVOKABLE QString userStatus(QString id) const; @@ -54,6 +56,7 @@ signals: void initialSyncChanged(bool isInitialSync); void replyingEventChanged(QString replyingEvent); void replyClosed(); + void deviceVerificationRequest(DeviceVerificationFlow *deviceVerificationFlow); public slots: void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);