mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
move device verification management to its own file
This commit is contained in:
parent
550c80525a
commit
a5030bdd4d
9 changed files with 221 additions and 150 deletions
|
@ -336,6 +336,7 @@ set(SRC_FILES
|
||||||
src/encryption/DeviceVerificationFlow.cpp
|
src/encryption/DeviceVerificationFlow.cpp
|
||||||
src/encryption/Olm.cpp
|
src/encryption/Olm.cpp
|
||||||
src/encryption/SelfVerificationStatus.cpp
|
src/encryption/SelfVerificationStatus.cpp
|
||||||
|
src/encryption/VerificationManager.cpp
|
||||||
|
|
||||||
# Generic notification stuff
|
# Generic notification stuff
|
||||||
src/notifications/Manager.cpp
|
src/notifications/Manager.cpp
|
||||||
|
@ -548,9 +549,10 @@ qt5_wrap_cpp(MOC_HEADERS
|
||||||
src/voip/CallManager.h
|
src/voip/CallManager.h
|
||||||
src/voip/WebRTCSession.h
|
src/voip/WebRTCSession.h
|
||||||
|
|
||||||
src/encryption/SelfVerificationStatus.h
|
|
||||||
src/encryption/DeviceVerificationFlow.h
|
src/encryption/DeviceVerificationFlow.h
|
||||||
src/encryption/Olm.h
|
src/encryption/Olm.h
|
||||||
|
src/encryption/SelfVerificationStatus.h
|
||||||
|
src/encryption/VerificationManager.h
|
||||||
|
|
||||||
src/notifications/Manager.h
|
src/notifications/Manager.h
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,10 @@ Page {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target: VerificationManager
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
function onOpenProfile(profile) {
|
function onOpenProfile(profile) {
|
||||||
var userProfile = userProfileComponent.createObject(timelineRoot, {
|
var userProfile = userProfileComponent.createObject(timelineRoot, {
|
||||||
"profile": profile
|
"profile": profile
|
||||||
|
|
|
@ -12,7 +12,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
property var flow
|
property var flow
|
||||||
|
|
||||||
onClosing: TimelineManager.removeVerificationFlow(flow)
|
onClosing: VerificationManager.removeVerificationFlow(flow)
|
||||||
title: stack.currentItem.title
|
title: stack.currentItem.title
|
||||||
modality: Qt.NonModal
|
modality: Qt.NonModal
|
||||||
palette: Nheko.colors
|
palette: Nheko.colors
|
||||||
|
|
|
@ -141,30 +141,33 @@
|
||||||
<file>qml/SelfVerificationCheck.qml</file>
|
<file>qml/SelfVerificationCheck.qml</file>
|
||||||
<file>qml/TypingIndicator.qml</file>
|
<file>qml/TypingIndicator.qml</file>
|
||||||
<file>qml/NotificationWarning.qml</file>
|
<file>qml/NotificationWarning.qml</file>
|
||||||
<file>qml/emoji/EmojiPicker.qml</file>
|
<file>qml/components/AdaptiveLayout.qml</file>
|
||||||
<file>qml/emoji/StickerPicker.qml</file>
|
<file>qml/components/AdaptiveLayoutElement.qml</file>
|
||||||
<file>qml/delegates/MessageDelegate.qml</file>
|
<file>qml/components/AvatarListTile.qml</file>
|
||||||
|
<file>qml/components/FlatButton.qml</file>
|
||||||
<file>qml/delegates/Encrypted.qml</file>
|
<file>qml/delegates/Encrypted.qml</file>
|
||||||
<file>qml/delegates/FileMessage.qml</file>
|
<file>qml/delegates/FileMessage.qml</file>
|
||||||
<file>qml/delegates/ImageMessage.qml</file>
|
<file>qml/delegates/ImageMessage.qml</file>
|
||||||
|
<file>qml/delegates/MessageDelegate.qml</file>
|
||||||
<file>qml/delegates/NoticeMessage.qml</file>
|
<file>qml/delegates/NoticeMessage.qml</file>
|
||||||
<file>qml/delegates/Pill.qml</file>
|
<file>qml/delegates/Pill.qml</file>
|
||||||
<file>qml/delegates/Placeholder.qml</file>
|
<file>qml/delegates/Placeholder.qml</file>
|
||||||
<file>qml/delegates/PlayableMediaMessage.qml</file>
|
<file>qml/delegates/PlayableMediaMessage.qml</file>
|
||||||
<file>qml/delegates/Reply.qml</file>
|
<file>qml/delegates/Reply.qml</file>
|
||||||
<file>qml/delegates/TextMessage.qml</file>
|
<file>qml/delegates/TextMessage.qml</file>
|
||||||
<file>qml/device-verification/Waiting.qml</file>
|
|
||||||
<file>qml/device-verification/DeviceVerification.qml</file>
|
<file>qml/device-verification/DeviceVerification.qml</file>
|
||||||
<file>qml/device-verification/DigitVerification.qml</file>
|
<file>qml/device-verification/DigitVerification.qml</file>
|
||||||
<file>qml/device-verification/EmojiVerification.qml</file>
|
<file>qml/device-verification/EmojiVerification.qml</file>
|
||||||
<file>qml/device-verification/NewVerificationRequest.qml</file>
|
|
||||||
<file>qml/device-verification/Failed.qml</file>
|
<file>qml/device-verification/Failed.qml</file>
|
||||||
|
<file>qml/device-verification/NewVerificationRequest.qml</file>
|
||||||
<file>qml/device-verification/Success.qml</file>
|
<file>qml/device-verification/Success.qml</file>
|
||||||
<file>qml/dialogs/ImagePackSettingsDialog.qml</file>
|
<file>qml/device-verification/Waiting.qml</file>
|
||||||
<file>qml/dialogs/ImagePackEditorDialog.qml</file>
|
<file>qml/dialogs/ImagePackEditorDialog.qml</file>
|
||||||
|
<file>qml/dialogs/ImagePackSettingsDialog.qml</file>
|
||||||
<file>qml/dialogs/InputDialog.qml</file>
|
<file>qml/dialogs/InputDialog.qml</file>
|
||||||
<file>qml/dialogs/InviteDialog.qml</file>
|
<file>qml/dialogs/InviteDialog.qml</file>
|
||||||
<file>qml/dialogs/JoinRoomDialog.qml</file>
|
<file>qml/dialogs/JoinRoomDialog.qml</file>
|
||||||
|
<file>qml/dialogs/LeaveRoomDialog.qml</file>
|
||||||
<file>qml/dialogs/LogoutDialog.qml</file>
|
<file>qml/dialogs/LogoutDialog.qml</file>
|
||||||
<file>qml/dialogs/RawMessageDialog.qml</file>
|
<file>qml/dialogs/RawMessageDialog.qml</file>
|
||||||
<file>qml/dialogs/ReadReceipts.qml</file>
|
<file>qml/dialogs/ReadReceipts.qml</file>
|
||||||
|
@ -172,6 +175,8 @@
|
||||||
<file>qml/dialogs/RoomMembers.qml</file>
|
<file>qml/dialogs/RoomMembers.qml</file>
|
||||||
<file>qml/dialogs/RoomSettings.qml</file>
|
<file>qml/dialogs/RoomSettings.qml</file>
|
||||||
<file>qml/dialogs/UserProfile.qml</file>
|
<file>qml/dialogs/UserProfile.qml</file>
|
||||||
|
<file>qml/emoji/EmojiPicker.qml</file>
|
||||||
|
<file>qml/emoji/StickerPicker.qml</file>
|
||||||
<file>qml/ui/Ripple.qml</file>
|
<file>qml/ui/Ripple.qml</file>
|
||||||
<file>qml/ui/Spinner.qml</file>
|
<file>qml/ui/Spinner.qml</file>
|
||||||
<file>qml/ui/animations/BlinkAnimation.qml</file>
|
<file>qml/ui/animations/BlinkAnimation.qml</file>
|
||||||
|
@ -183,18 +188,6 @@
|
||||||
<file>qml/voip/PlaceCall.qml</file>
|
<file>qml/voip/PlaceCall.qml</file>
|
||||||
<file>qml/voip/ScreenShare.qml</file>
|
<file>qml/voip/ScreenShare.qml</file>
|
||||||
<file>qml/voip/VideoCall.qml</file>
|
<file>qml/voip/VideoCall.qml</file>
|
||||||
<file>qml/components/AdaptiveLayout.qml</file>
|
|
||||||
<file>qml/components/AdaptiveLayoutElement.qml</file>
|
|
||||||
<file>qml/components/AvatarListTile.qml</file>
|
|
||||||
<file>qml/components/FlatButton.qml</file>
|
|
||||||
<file>qml/dialogs/InviteDialog.qml</file>
|
|
||||||
<file>qml/dialogs/LeaveRoomDialog.qml</file>
|
|
||||||
<file>qml/dialogs/RawMessageDialog.qml</file>
|
|
||||||
<file>qml/dialogs/ReadReceipts.qml</file>
|
|
||||||
<file>qml/dialogs/RoomDirectory.qml</file>
|
|
||||||
<file>qml/dialogs/RoomMembers.qml</file>
|
|
||||||
<file>qml/dialogs/RoomSettings.qml</file>
|
|
||||||
<file>qml/dialogs/UserProfile.qml</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/media">
|
<qresource prefix="/media">
|
||||||
<file>media/ring.ogg</file>
|
<file>media/ring.ogg</file>
|
||||||
|
|
126
src/encryption/VerificationManager.cpp
Normal file
126
src/encryption/VerificationManager.cpp
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include "VerificationManager.h"
|
||||||
|
#include "Cache.h"
|
||||||
|
#include "ChatPage.h"
|
||||||
|
#include "DeviceVerificationFlow.h"
|
||||||
|
#include "timeline/TimelineViewManager.h"
|
||||||
|
|
||||||
|
VerificationManager::VerificationManager(TimelineViewManager *o)
|
||||||
|
: QObject(o)
|
||||||
|
, rooms_(o->rooms())
|
||||||
|
{}
|
||||||
|
|
||||||
|
void
|
||||||
|
VerificationManager::receivedRoomDeviceVerificationRequest(
|
||||||
|
const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &message,
|
||||||
|
TimelineModel *model)
|
||||||
|
{
|
||||||
|
if (this->isInitialSync_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto event_id = QString::fromStdString(message.event_id);
|
||||||
|
if (!this->dvList.contains(event_id)) {
|
||||||
|
if (auto flow = DeviceVerificationFlow::NewInRoomVerification(
|
||||||
|
this, model, message.content, QString::fromStdString(message.sender), event_id)) {
|
||||||
|
dvList[event_id] = flow;
|
||||||
|
emit newDeviceVerificationRequest(flow.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VerificationManager::receivedDeviceVerificationRequest(
|
||||||
|
const mtx::events::msg::KeyVerificationRequest &msg,
|
||||||
|
std::string sender)
|
||||||
|
{
|
||||||
|
if (this->isInitialSync_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!msg.transaction_id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto txnid = QString::fromStdString(msg.transaction_id.value());
|
||||||
|
if (!this->dvList.contains(txnid)) {
|
||||||
|
if (auto flow = DeviceVerificationFlow::NewToDeviceVerification(
|
||||||
|
this, msg, QString::fromStdString(sender), txnid)) {
|
||||||
|
dvList[txnid] = flow;
|
||||||
|
emit newDeviceVerificationRequest(flow.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VerificationManager::receivedDeviceVerificationStart(
|
||||||
|
const mtx::events::msg::KeyVerificationStart &msg,
|
||||||
|
std::string sender)
|
||||||
|
{
|
||||||
|
if (this->isInitialSync_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!msg.transaction_id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto txnid = QString::fromStdString(msg.transaction_id.value());
|
||||||
|
if (!this->dvList.contains(txnid)) {
|
||||||
|
if (auto flow = DeviceVerificationFlow::NewToDeviceVerification(
|
||||||
|
this, msg, QString::fromStdString(sender), txnid)) {
|
||||||
|
dvList[txnid] = flow;
|
||||||
|
emit newDeviceVerificationRequest(flow.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VerificationManager::verifyUser(QString userid)
|
||||||
|
{
|
||||||
|
auto joined_rooms = cache::joinedRooms();
|
||||||
|
auto room_infos = cache::getRoomInfo(joined_rooms);
|
||||||
|
|
||||||
|
for (std::string room_id : joined_rooms) {
|
||||||
|
if ((room_infos[QString::fromStdString(room_id)].member_count == 2) &&
|
||||||
|
cache::isRoomEncrypted(room_id)) {
|
||||||
|
auto room_members = cache::roomMembers(room_id);
|
||||||
|
if (std::find(room_members.begin(), room_members.end(), (userid).toStdString()) !=
|
||||||
|
room_members.end()) {
|
||||||
|
if (auto model = rooms_->getRoomById(QString::fromStdString(room_id))) {
|
||||||
|
auto flow =
|
||||||
|
DeviceVerificationFlow::InitiateUserVerification(this, model.data(), userid);
|
||||||
|
connect(model.data(),
|
||||||
|
&TimelineModel::updateFlowEventId,
|
||||||
|
this,
|
||||||
|
[this, flow](std::string eventId) {
|
||||||
|
dvList[QString::fromStdString(eventId)] = flow;
|
||||||
|
});
|
||||||
|
emit newDeviceVerificationRequest(flow.data());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit ChatPage::instance()->showNotification(
|
||||||
|
tr("No encrypted private chat found with this user. Create an "
|
||||||
|
"encrypted private chat with this user and try again."));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VerificationManager::removeVerificationFlow(DeviceVerificationFlow *flow)
|
||||||
|
{
|
||||||
|
for (auto it = dvList.keyValueBegin(); it != dvList.keyValueEnd(); ++it) {
|
||||||
|
if ((*it).second == flow) {
|
||||||
|
dvList.remove((*it).first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VerificationManager::verifyDevice(QString userid, QString deviceid)
|
||||||
|
{
|
||||||
|
auto flow = DeviceVerificationFlow::InitiateDeviceVerification(this, userid, deviceid);
|
||||||
|
this->dvList[flow->transactionId()] = flow;
|
||||||
|
emit newDeviceVerificationRequest(flow.data());
|
||||||
|
}
|
48
src/encryption/VerificationManager.h
Normal file
48
src/encryption/VerificationManager.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QHash>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include <mtx/events.hpp>
|
||||||
|
#include <mtx/events/encrypted.hpp>
|
||||||
|
|
||||||
|
class DeviceVerificationFlow;
|
||||||
|
class TimelineModel;
|
||||||
|
class TimelineModel;
|
||||||
|
class TimelineViewManager;
|
||||||
|
class RoomlistModel;
|
||||||
|
|
||||||
|
class VerificationManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
VerificationManager(TimelineViewManager *o = nullptr);
|
||||||
|
|
||||||
|
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
|
||||||
|
void verifyUser(QString userid);
|
||||||
|
void verifyDevice(QString userid, QString deviceid);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void newDeviceVerificationRequest(DeviceVerificationFlow *flow);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void receivedRoomDeviceVerificationRequest(
|
||||||
|
const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &message,
|
||||||
|
TimelineModel *model);
|
||||||
|
void receivedDeviceVerificationRequest(const mtx::events::msg::KeyVerificationRequest &msg,
|
||||||
|
std::string sender);
|
||||||
|
void receivedDeviceVerificationStart(const mtx::events::msg::KeyVerificationStart &msg,
|
||||||
|
std::string sender);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHash<QString, QSharedPointer<DeviceVerificationFlow>> dvList;
|
||||||
|
bool isInitialSync_ = false;
|
||||||
|
RoomlistModel *rooms_;
|
||||||
|
};
|
||||||
|
|
|
@ -143,9 +143,10 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
|
||||||
, colorImgProvider(new ColorImageProvider())
|
, colorImgProvider(new ColorImageProvider())
|
||||||
, blurhashProvider(new BlurhashProvider())
|
, blurhashProvider(new BlurhashProvider())
|
||||||
, jdenticonProvider(new JdenticonProvider())
|
, jdenticonProvider(new JdenticonProvider())
|
||||||
, callManager_(callManager)
|
|
||||||
, rooms_(new RoomlistModel(this))
|
, rooms_(new RoomlistModel(this))
|
||||||
, communities_(new CommunitiesModel(this))
|
, communities_(new CommunitiesModel(this))
|
||||||
|
, callManager_(callManager)
|
||||||
|
, verificationManager_(new VerificationManager(this))
|
||||||
{
|
{
|
||||||
qRegisterMetaType<mtx::events::msg::KeyVerificationAccept>();
|
qRegisterMetaType<mtx::events::msg::KeyVerificationAccept>();
|
||||||
qRegisterMetaType<mtx::events::msg::KeyVerificationCancel>();
|
qRegisterMetaType<mtx::events::msg::KeyVerificationCancel>();
|
||||||
|
@ -244,6 +245,7 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
|
||||||
"im.nheko", 1, 0, "Nheko", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
"im.nheko", 1, 0, "Nheko", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||||
return new Nheko();
|
return new Nheko();
|
||||||
});
|
});
|
||||||
|
qmlRegisterSingletonInstance("im.nheko", 1, 0, "VerificationManager", verificationManager_);
|
||||||
qmlRegisterSingletonType<SelfVerificationStatus>(
|
qmlRegisterSingletonType<SelfVerificationStatus>(
|
||||||
"im.nheko", 1, 0, "SelfVerificationStatus", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
"im.nheko", 1, 0, "SelfVerificationStatus", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||||
return new SelfVerificationStatus();
|
return new SelfVerificationStatus();
|
||||||
|
@ -285,63 +287,16 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
|
||||||
connect(parent, &ChatPage::themeChanged, this, &TimelineViewManager::updateColorPalette);
|
connect(parent, &ChatPage::themeChanged, this, &TimelineViewManager::updateColorPalette);
|
||||||
connect(dynamic_cast<ChatPage *>(parent),
|
connect(dynamic_cast<ChatPage *>(parent),
|
||||||
&ChatPage::receivedRoomDeviceVerificationRequest,
|
&ChatPage::receivedRoomDeviceVerificationRequest,
|
||||||
this,
|
verificationManager_,
|
||||||
[this](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &message,
|
&VerificationManager::receivedRoomDeviceVerificationRequest);
|
||||||
TimelineModel *model) {
|
|
||||||
if (this->isInitialSync_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto event_id = QString::fromStdString(message.event_id);
|
|
||||||
if (!this->dvList.contains(event_id)) {
|
|
||||||
if (auto flow = DeviceVerificationFlow::NewInRoomVerification(
|
|
||||||
this,
|
|
||||||
model,
|
|
||||||
message.content,
|
|
||||||
QString::fromStdString(message.sender),
|
|
||||||
event_id)) {
|
|
||||||
dvList[event_id] = flow;
|
|
||||||
emit newDeviceVerificationRequest(flow.data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(dynamic_cast<ChatPage *>(parent),
|
connect(dynamic_cast<ChatPage *>(parent),
|
||||||
&ChatPage::receivedDeviceVerificationRequest,
|
&ChatPage::receivedDeviceVerificationRequest,
|
||||||
this,
|
verificationManager_,
|
||||||
[this](const mtx::events::msg::KeyVerificationRequest &msg, std::string sender) {
|
&VerificationManager::receivedDeviceVerificationRequest);
|
||||||
if (this->isInitialSync_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!msg.transaction_id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto txnid = QString::fromStdString(msg.transaction_id.value());
|
|
||||||
if (!this->dvList.contains(txnid)) {
|
|
||||||
if (auto flow = DeviceVerificationFlow::NewToDeviceVerification(
|
|
||||||
this, msg, QString::fromStdString(sender), txnid)) {
|
|
||||||
dvList[txnid] = flow;
|
|
||||||
emit newDeviceVerificationRequest(flow.data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(dynamic_cast<ChatPage *>(parent),
|
connect(dynamic_cast<ChatPage *>(parent),
|
||||||
&ChatPage::receivedDeviceVerificationStart,
|
&ChatPage::receivedDeviceVerificationStart,
|
||||||
this,
|
verificationManager_,
|
||||||
[this](const mtx::events::msg::KeyVerificationStart &msg, std::string sender) {
|
&VerificationManager::receivedDeviceVerificationStart);
|
||||||
if (this->isInitialSync_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!msg.transaction_id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto txnid = QString::fromStdString(msg.transaction_id.value());
|
|
||||||
if (!this->dvList.contains(txnid)) {
|
|
||||||
if (auto flow = DeviceVerificationFlow::NewToDeviceVerification(
|
|
||||||
this, msg, QString::fromStdString(sender), txnid)) {
|
|
||||||
dvList[txnid] = flow;
|
|
||||||
emit newDeviceVerificationRequest(flow.data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(parent, &ChatPage::loggedOut, this, [this]() {
|
connect(parent, &ChatPage::loggedOut, this, [this]() {
|
||||||
isInitialSync_ = true;
|
isInitialSync_ = true;
|
||||||
emit initialSyncChanged(true);
|
emit initialSyncChanged(true);
|
||||||
|
@ -475,58 +430,6 @@ TimelineViewManager::openImageOverlayInternal(QString eventId, QImage img)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
TimelineViewManager::verifyUser(QString userid)
|
|
||||||
{
|
|
||||||
auto joined_rooms = cache::joinedRooms();
|
|
||||||
auto room_infos = cache::getRoomInfo(joined_rooms);
|
|
||||||
|
|
||||||
for (std::string room_id : joined_rooms) {
|
|
||||||
if ((room_infos[QString::fromStdString(room_id)].member_count == 2) &&
|
|
||||||
cache::isRoomEncrypted(room_id)) {
|
|
||||||
auto room_members = cache::roomMembers(room_id);
|
|
||||||
if (std::find(room_members.begin(), room_members.end(), (userid).toStdString()) !=
|
|
||||||
room_members.end()) {
|
|
||||||
if (auto model = rooms_->getRoomById(QString::fromStdString(room_id))) {
|
|
||||||
auto flow =
|
|
||||||
DeviceVerificationFlow::InitiateUserVerification(this, model.data(), userid);
|
|
||||||
connect(model.data(),
|
|
||||||
&TimelineModel::updateFlowEventId,
|
|
||||||
this,
|
|
||||||
[this, flow](std::string eventId) {
|
|
||||||
dvList[QString::fromStdString(eventId)] = flow;
|
|
||||||
});
|
|
||||||
emit newDeviceVerificationRequest(flow.data());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit ChatPage::instance()->showNotification(
|
|
||||||
tr("No encrypted private chat found with this user. Create an "
|
|
||||||
"encrypted private chat with this user and try again."));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TimelineViewManager::removeVerificationFlow(DeviceVerificationFlow *flow)
|
|
||||||
{
|
|
||||||
for (auto it = dvList.keyValueBegin(); it != dvList.keyValueEnd(); ++it) {
|
|
||||||
if ((*it).second == flow) {
|
|
||||||
dvList.remove((*it).first);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TimelineViewManager::verifyDevice(QString userid, QString deviceid)
|
|
||||||
{
|
|
||||||
auto flow = DeviceVerificationFlow::InitiateDeviceVerification(this, userid, deviceid);
|
|
||||||
this->dvList[flow->transactionId()] = flow;
|
|
||||||
emit newDeviceVerificationRequest(flow.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::updateReadReceipts(const QString &room_id,
|
TimelineViewManager::updateReadReceipts(const QString &room_id,
|
||||||
const std::vector<QString> &event_ids)
|
const std::vector<QString> &event_ids)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <QQuickTextDocument>
|
#include <QQuickTextDocument>
|
||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
#include <QQuickWidget>
|
#include <QQuickWidget>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <mtx/common.hpp>
|
#include <mtx/common.hpp>
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "emoji/EmojiModel.h"
|
#include "emoji/EmojiModel.h"
|
||||||
#include "emoji/Provider.h"
|
#include "emoji/Provider.h"
|
||||||
|
#include "encryption/VerificationManager.h"
|
||||||
#include "timeline/CommunitiesModel.h"
|
#include "timeline/CommunitiesModel.h"
|
||||||
#include "timeline/RoomlistModel.h"
|
#include "timeline/RoomlistModel.h"
|
||||||
#include "voip/CallManager.h"
|
#include "voip/CallManager.h"
|
||||||
|
@ -33,7 +33,6 @@ class BlurhashProvider;
|
||||||
class ColorImageProvider;
|
class ColorImageProvider;
|
||||||
class UserSettings;
|
class UserSettings;
|
||||||
class ChatPage;
|
class ChatPage;
|
||||||
class DeviceVerificationFlow;
|
|
||||||
class ImagePackListModel;
|
class ImagePackListModel;
|
||||||
|
|
||||||
class TimelineViewManager : public QObject
|
class TimelineViewManager : public QObject
|
||||||
|
@ -53,6 +52,7 @@ public:
|
||||||
|
|
||||||
MxcImageProvider *imageProvider() { return imgProvider; }
|
MxcImageProvider *imageProvider() { return imgProvider; }
|
||||||
CallManager *callManager() { return callManager_; }
|
CallManager *callManager() { return callManager_; }
|
||||||
|
VerificationManager *verificationManager() { return verificationManager_; }
|
||||||
|
|
||||||
void clearAll() { rooms_->clear(); }
|
void clearAll() { rooms_->clear(); }
|
||||||
|
|
||||||
|
@ -73,19 +73,14 @@ public:
|
||||||
Q_INVOKABLE void openGlobalUserProfile(QString userId);
|
Q_INVOKABLE void openGlobalUserProfile(QString userId);
|
||||||
|
|
||||||
Q_INVOKABLE void focusMessageInput();
|
Q_INVOKABLE void focusMessageInput();
|
||||||
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
|
|
||||||
|
|
||||||
Q_INVOKABLE void fixImageRendering(QQuickTextDocument *t, QQuickItem *i);
|
Q_INVOKABLE void fixImageRendering(QQuickTextDocument *t, QQuickItem *i);
|
||||||
|
|
||||||
void verifyUser(QString userid);
|
|
||||||
void verifyDevice(QString userid, QString deviceid);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activeTimelineChanged(TimelineModel *timeline);
|
void activeTimelineChanged(TimelineModel *timeline);
|
||||||
void initialSyncChanged(bool isInitialSync);
|
void initialSyncChanged(bool isInitialSync);
|
||||||
void replyingEventChanged(QString replyingEvent);
|
void replyingEventChanged(QString replyingEvent);
|
||||||
void replyClosed();
|
void replyClosed();
|
||||||
void newDeviceVerificationRequest(DeviceVerificationFlow *flow);
|
|
||||||
void inviteUsers(QString roomId, QStringList users);
|
void inviteUsers(QString roomId, QStringList users);
|
||||||
void showRoomList();
|
void showRoomList();
|
||||||
void narrowViewChanged();
|
void narrowViewChanged();
|
||||||
|
@ -142,17 +137,17 @@ private:
|
||||||
BlurhashProvider *blurhashProvider;
|
BlurhashProvider *blurhashProvider;
|
||||||
JdenticonProvider *jdenticonProvider;
|
JdenticonProvider *jdenticonProvider;
|
||||||
|
|
||||||
CallManager *callManager_ = nullptr;
|
|
||||||
|
|
||||||
bool isInitialSync_ = true;
|
bool isInitialSync_ = true;
|
||||||
bool isWindowFocused_ = false;
|
bool isWindowFocused_ = false;
|
||||||
|
|
||||||
RoomlistModel *rooms_ = nullptr;
|
RoomlistModel *rooms_ = nullptr;
|
||||||
CommunitiesModel *communities_ = nullptr;
|
CommunitiesModel *communities_ = nullptr;
|
||||||
|
|
||||||
QHash<QString, QColor> userColors;
|
// don't move this above the rooms_
|
||||||
|
CallManager *callManager_ = nullptr;
|
||||||
|
VerificationManager *verificationManager_ = nullptr;
|
||||||
|
|
||||||
QHash<QString, QSharedPointer<DeviceVerificationFlow>> dvList;
|
QHash<QString, QColor> userColors;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationAccept)
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationAccept)
|
||||||
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationCancel)
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationCancel)
|
||||||
|
|
|
@ -338,9 +338,9 @@ void
|
||||||
UserProfile::verify(QString device)
|
UserProfile::verify(QString device)
|
||||||
{
|
{
|
||||||
if (!device.isEmpty())
|
if (!device.isEmpty())
|
||||||
manager->verifyDevice(userid_, device);
|
manager->verificationManager()->verifyDevice(userid_, device);
|
||||||
else {
|
else {
|
||||||
manager->verifyUser(userid_);
|
manager->verificationManager()->verifyUser(userid_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue