summary refs log tree commit diff
path: root/src/timeline/TimelineViewManager.cpp
diff options
context:
space:
mode:
authorCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-07-29 03:25:47 +0530
committerCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-07-30 22:10:27 +0530
commit3635c185e93a6f7bf6e2f9c11b27966c2ee665ea (patch)
tree036e5fa56355cccded5c06d61e28d5a958a59c03 /src/timeline/TimelineViewManager.cpp
parentAdding Room Key Verification Stuff (diff)
downloadnheko-3635c185e93a6f7bf6e2f9c11b27966c2ee665ea.tar.xz
Add Room Verification Messages
Diffstat (limited to 'src/timeline/TimelineViewManager.cpp')
-rw-r--r--src/timeline/TimelineViewManager.cpp37
1 files changed, 32 insertions, 5 deletions
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 <iostream> //only for debugging + Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) Q_DECLARE_METATYPE(std::vector<DeviceInfo>) @@ -187,16 +189,42 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin &TimelineViewManager::updateEncryptedDescriptions); connect( dynamic_cast<ChatPage *>(parent), + &ChatPage::recievedRoomDeviceVerificationRequest, + this, + [this](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &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<ChatPage *>(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<UserSettings> 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<UserSettings> 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);