Add Room Verification Messages

This commit is contained in:
CH Chethan Reddy 2020-07-29 03:25:47 +05:30
parent 1fcd768f88
commit 3635c185e9
9 changed files with 245 additions and 49 deletions

View file

@ -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>)
@ -185,18 +187,44 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin
&ChatPage::decryptSidebarChanged,
this,
&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);