From 3635c185e93a6f7bf6e2f9c11b27966c2ee665ea Mon Sep 17 00:00:00 2001 From: CH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com> Date: Wed, 29 Jul 2020 03:25:47 +0530 Subject: Add Room Verification Messages --- src/timeline/TimelineViewManager.cpp | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/timeline/TimelineViewManager.cpp') diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 02b74d20..c16e09d1 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -17,6 +17,8 @@ #include "emoji/EmojiModel.h" #include "emoji/Provider.h" +#include //only for debugging + Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) Q_DECLARE_METATYPE(std::vector) @@ -185,18 +187,44 @@ TimelineViewManager::TimelineViewManager(QSharedPointer userSettin &ChatPage::decryptSidebarChanged, this, &TimelineViewManager::updateEncryptedDescriptions); + connect( + dynamic_cast(parent), + &ChatPage::recievedRoomDeviceVerificationRequest, + this, + [this](const mtx::events::RoomEvent &message, + TimelineModel *model) { + if (!(this->dvList->exist(QString::fromStdString(message.event_id)))) { + auto flow = + new DeviceVerificationFlow(this, DeviceVerificationFlow::Type::RoomMsg); + if (std::find(message.content.methods.begin(), + message.content.methods.end(), + mtx::events::msg::VerificationMethods::SASv1) != + message.content.methods.end()) { + flow->setModel(model); + flow->setEventId(message.event_id); + emit newDeviceVerificationRequest( + std::move(flow), + QString::fromStdString(message.event_id), + QString::fromStdString(message.sender), + QString::fromStdString(message.content.from_device), + true); + } else { + flow->cancelVerification( + DeviceVerificationFlow::Error::UnknownMethod); + } + } + }); connect( dynamic_cast(parent), &ChatPage::recievedDeviceVerificationRequest, this, [this](const mtx::events::msg::KeyVerificationRequest &msg, std::string sender) { - auto flow = new DeviceVerificationFlow(this); if (!(this->dvList->exist(QString::fromStdString(msg.transaction_id.value())))) { + auto flow = new DeviceVerificationFlow(this); if (std::find(msg.methods.begin(), msg.methods.end(), mtx::events::msg::VerificationMethods::SASv1) != msg.methods.end()) { - // flow->sendVerificationReady(); emit newDeviceVerificationRequest( std::move(flow), QString::fromStdString(msg.transaction_id.value()), @@ -213,9 +241,9 @@ TimelineViewManager::TimelineViewManager(QSharedPointer userSettin &ChatPage::recievedDeviceVerificationStart, this, [this](const mtx::events::msg::KeyVerificationStart &msg, std::string sender) { - auto flow = new DeviceVerificationFlow(this); - flow->canonical_json = nlohmann::json(msg); if (!(this->dvList->exist(QString::fromStdString(msg.transaction_id.value())))) { + auto flow = new DeviceVerificationFlow(this); + flow->canonical_json = nlohmann::json(msg); if ((std::find(msg.key_agreement_protocols.begin(), msg.key_agreement_protocols.end(), "curve25519-hkdf-sha256") != @@ -246,7 +274,6 @@ TimelineViewManager::TimelineViewManager(QSharedPointer userSettin QString::fromStdString(msg.transaction_id.value()), QString::fromStdString(sender), QString::fromStdString(msg.from_device)); - flow->canonical_json = nlohmann::json(msg); } else { flow->cancelVerification( DeviceVerificationFlow::Error::UnknownMethod); -- cgit 1.5.1