diff --git a/src/DeviceVerificationFlow.cpp b/src/DeviceVerificationFlow.cpp
index 9b260892..2c6e9c1e 100644
--- a/src/DeviceVerificationFlow.cpp
+++ b/src/DeviceVerificationFlow.cpp
@@ -13,7 +13,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *)
{
timeout = new QTimer(this);
timeout->setSingleShot(true);
- this->sas = olm::client()->sas_init();
+ this->sas = olm::client()->sas_init();
+ this->isMacVerified = false;
connect(timeout, &QTimer::timeout, this, [this]() {
emit timedout();
this->deleteLater();
@@ -134,45 +135,47 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *)
}
}
});
- connect(ChatPage::instance(),
- &ChatPage::recievedDeviceVerificationMac,
- this,
- [this](const mtx::events::collections::DeviceEvents &message) {
- auto msg =
- std::get<mtx::events::DeviceEvent<msgs::KeyVerificationMac>>(message);
- if (msg.content.transaction_id == this->transaction_id) {
- std::string info =
- "MATRIX_KEY_VERIFICATION_MAC" + this->toClient.to_string() +
- this->deviceId.toStdString() +
- http::client()->user_id().to_string() +
- http::client()->device_id() + this->transaction_id;
+ connect(
+ ChatPage::instance(),
+ &ChatPage::recievedDeviceVerificationMac,
+ this,
+ [this](const mtx::events::collections::DeviceEvents &message) {
+ auto msg = std::get<mtx::events::DeviceEvent<msgs::KeyVerificationMac>>(message);
+ if (msg.content.transaction_id == this->transaction_id) {
+ std::string info =
+ "MATRIX_KEY_VERIFICATION_MAC" + this->toClient.to_string() +
+ this->deviceId.toStdString() + http::client()->user_id().to_string() +
+ http::client()->device_id() + this->transaction_id;
- std::vector<std::string> key_list;
- std::string key_string;
- for (auto mac : msg.content.mac) {
- if (mac.second ==
- this->sas->calculate_mac(this->device_keys[mac.first],
- info + mac.first)) {
- key_string += mac.first;
- } else {
- this->cancelVerification();
- return;
- }
- }
- if (msg.content.keys ==
- this->sas->calculate_mac(key_string, info + "KEY_IDS")) {
- // uncomment this in future to be compatible with the
- // MSC2366 this->sendVerificationDone(); and remoeve the
- // below line
- if (this->isMacVerified == true)
- emit this->deviceVerified();
- else
- this->isMacVerified = true;
- } else {
- this->cancelVerification();
- }
- }
- });
+ std::vector<std::string> key_list;
+ std::string key_string;
+ for (auto mac : msg.content.mac) {
+ key_string += mac.first + ",";
+ if (device_keys[mac.first] != "") {
+ if (mac.second ==
+ this->sas->calculate_mac(this->device_keys[mac.first],
+ info + mac.first)) {
+ } else {
+ this->cancelVerification();
+ return;
+ }
+ }
+ }
+ key_string = key_string.substr(0, key_string.length() - 1);
+ if (msg.content.keys ==
+ this->sas->calculate_mac(key_string, info + "KEY_IDS")) {
+ // uncomment this in future to be compatible with the
+ // MSC2366 this->sendVerificationDone(); and remove the
+ // below line
+ if (this->isMacVerified == true)
+ emit this->deviceVerified();
+ else
+ this->isMacVerified = true;
+ } else {
+ this->cancelVerification();
+ }
+ }
+ });
connect(ChatPage::instance(),
&ChatPage::recievedDeviceVerificationReady,
this,
diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp
index 588d6969..6aa4deff 100644
--- a/src/ui/UserProfile.cpp
+++ b/src/ui/UserProfile.cpp
@@ -1,4 +1,5 @@
#include "UserProfile.h"
+#include "ChatPage.h"
#include "Logging.h"
#include "Utils.h"
#include "mtx/responses/crypto.hpp"
@@ -86,3 +87,30 @@ UserProfile::updateDeviceList()
{
fetchDeviceList(this->userId);
}
+
+void
+UserProfile::banUser()
+{
+ ChatPage::instance()->banUser(this->userId, "");
+}
+
+// void ignoreUser(){
+
+// }
+
+void
+UserProfile::kickUser()
+{
+ ChatPage::instance()->kickUser(this->userId, "");
+}
+
+void
+UserProfile::startChat()
+{
+ mtx::requests::CreateRoom req;
+ req.preset = mtx::requests::Preset::PrivateChat;
+ req.visibility = mtx::requests::Visibility::Private;
+ if (utils::localUser() != this->userId)
+ req.invite = {this->userId.toStdString()};
+ emit ChatPage::instance()->createRoom(req);
+}
diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h
index c37e23ae..ad92d182 100644
--- a/src/ui/UserProfile.h
+++ b/src/ui/UserProfile.h
@@ -5,7 +5,6 @@
#include <QVector>
#include "MatrixClient.h"
-
class DeviceInfo
{
public:
@@ -36,6 +35,10 @@ public:
Q_INVOKABLE void fetchDeviceList(const QString &userID);
Q_INVOKABLE void updateDeviceList();
+ Q_INVOKABLE void banUser();
+ // Q_INVOKABLE void ignoreUser();
+ Q_INVOKABLE void kickUser();
+ Q_INVOKABLE void startChat();
signals:
void userIdChanged();
|