diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52d762b1..ac07562f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -579,7 +579,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare(
MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
- GIT_TAG 9ef7f7503c88b2a27e551324bd39a556b56aa8d6
+ GIT_TAG e93779692fcc00de136234dd48d0af354717b0a1
)
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml
index 7c0d9d5f..db3ecbed 100644
--- a/io.github.NhekoReborn.Nheko.yaml
+++ b/io.github.NhekoReborn.Nheko.yaml
@@ -203,7 +203,7 @@ modules:
buildsystem: cmake-ninja
name: mtxclient
sources:
- - commit: 9ef7f7503c88b2a27e551324bd39a556b56aa8d6
+ - commit: e93779692fcc00de136234dd48d0af354717b0a1
#tag: v0.7.0
type: git
url: https://github.com/Nheko-Reborn/mtxclient.git
diff --git a/resources/qml/pages/LoginPage.qml b/resources/qml/pages/LoginPage.qml
index 87234a22..46036242 100644
--- a/resources/qml/pages/LoginPage.qml
+++ b/resources/qml/pages/LoginPage.qml
@@ -76,10 +76,12 @@ Item {
}
MatrixText {
+ Layout.fillWidth: true
textFormat: Text.PlainText
color: Nheko.theme.error
text: login.mxidError
visible: text
+ wrapMode: TextEdit.Wrap
}
MatrixTextField {
@@ -130,10 +132,12 @@ Item {
}
MatrixText {
+ Layout.fillWidth: true
textFormat: Text.PlainText
color: Nheko.theme.error
text: loginPage.error
visible: text
+ wrapMode: TextEdit.Wrap
}
FlatButton {
diff --git a/resources/qml/pages/RegisterPage.qml b/resources/qml/pages/RegisterPage.qml
index 44836ccb..2b2f56bd 100644
--- a/resources/qml/pages/RegisterPage.qml
+++ b/resources/qml/pages/RegisterPage.qml
@@ -75,10 +75,12 @@ Item {
}
MatrixText {
+ Layout.fillWidth: true
textFormat: Text.PlainText
color: Nheko.theme.error
text: regis.hsError
visible: text
+ wrapMode: TextEdit.Wrap
}
RowLayout {
@@ -122,10 +124,12 @@ Item {
}
MatrixText {
+ Layout.fillWidth: true
textFormat: Text.PlainText
color: Nheko.theme.error
text: regis.usernameError
- visible: text
+ visible: text && regis.supported
+ wrapMode: TextEdit.Wrap
}
@@ -147,10 +151,12 @@ Item {
}
MatrixText {
+ Layout.fillWidth: true
visible: regis.supported
textFormat: Text.PlainText
color: Nheko.theme.error
text: passwordLabel.text != passwordConfirmationLabel.text ? qsTr("Your passwords do not match!") : ""
+ wrapMode: TextEdit.Wrap
}
MatrixTextField {
@@ -177,10 +183,12 @@ Item {
}
MatrixText {
+ Layout.fillWidth: true
textFormat: Text.PlainText
color: Nheko.theme.error
text: registrationPage.error
visible: text
+ wrapMode: TextEdit.Wrap
}
FlatButton {
diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp
index b34e9806..08b7335a 100644
--- a/src/LoginPage.cpp
+++ b/src/LoginPage.cpp
@@ -6,9 +6,12 @@
#include <QDesktopServices>
+#include <set>
+
#include <mtx/identifiers.hpp>
#include <mtx/requests.hpp>
#include <mtx/responses/login.hpp>
+#include <mtx/responses/version.hpp>
#include "Config.h"
#include "Logging.h"
@@ -149,7 +152,8 @@ LoginPage::checkHomeserverVersion()
return;
}
- http::client()->versions([this](const mtx::responses::Versions &, mtx::http::RequestErr err) {
+ http::client()->versions([this](const mtx::responses::Versions &versions,
+ mtx::http::RequestErr err) {
if (err) {
if (err->status_code == 404) {
emit versionErrorCb(tr("The required endpoints were not found. "
@@ -170,6 +174,21 @@ LoginPage::checkHomeserverVersion()
return;
}
+ if (std::find_if(
+ versions.versions.cbegin(), versions.versions.cend(), [](const std::string &v) {
+ static const std::set<std::string_view, std::less<>> supported{
+ "v1.1",
+ "v1.2",
+ "v1.3",
+ };
+ return supported.count(v) != 0;
+ }) == versions.versions.cend()) {
+ emit versionErrorCb(
+ tr("The selected server does not support a version of the Matrix protocol, that this "
+ "client understands (v1.1, v1.2 or v1.3). You can't sign in."));
+ return;
+ }
+
http::client()->get_login([this](mtx::responses::LoginFlows flows,
mtx::http::RequestErr err) {
if (err || flows.flows.empty())
diff --git a/src/RegisterPage.cpp b/src/RegisterPage.cpp
index 5b2ebc78..b647a73c 100644
--- a/src/RegisterPage.cpp
+++ b/src/RegisterPage.cpp
@@ -4,8 +4,11 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
+#include <set>
+
#include <mtx/responses/common.hpp>
#include <mtx/responses/register.hpp>
+#include <mtx/responses/version.hpp>
#include <mtx/responses/well-known.hpp>
#include <mtxclient/http/client.hpp>
@@ -101,47 +104,64 @@ RegisterPage::versionsCheck()
{
// Make a request to /_matrix/client/versions to check the address
// given is a Matrix homeserver.
- http::client()->versions([this](const mtx::responses::Versions &, mtx::http::RequestErr err) {
- if (err) {
- if (err->status_code == 404) {
- setHsError(
- tr("The required endpoints were not found. Possibly not a Matrix server."));
- emit hsErrorChanged();
- return;
- }
-
- if (!err->parse_error.empty()) {
- setHsError(
- tr("Received malformed response. Make sure the homeserver domain is valid."));
- emit hsErrorChanged();
- return;
- }
-
- setHsError(tr("An unknown error occured. Make sure the homeserver domain is valid."));
- emit hsErrorChanged();
- return;
- }
-
- http::client()->registration(
- [this](const mtx::responses::Register &, mtx::http::RequestErr e) {
- nhlog::net()->debug("Registration check: {}", e);
-
- if (!e) {
- setHsError(tr("Server does not support querying registration flows!"));
+ http::client()->versions(
+ [this](const mtx::responses::Versions &versions, mtx::http::RequestErr err) {
+ if (err) {
+ if (err->status_code == 404) {
+ setHsError(
+ tr("The required endpoints were not found. Possibly not a Matrix server."));
emit hsErrorChanged();
return;
}
- if (e->status_code != 401) {
- setHsError(tr("Server does not support registration."));
+
+ if (!err->parse_error.empty()) {
+ setHsError(
+ tr("Received malformed response. Make sure the homeserver domain is valid."));
emit hsErrorChanged();
return;
}
- supported_ = true;
- lookingUpHs_ = false;
- emit lookingUpHsChanged();
- });
- });
+ setHsError(tr("An unknown error occured. Make sure the homeserver domain is valid."));
+ emit hsErrorChanged();
+ return;
+ }
+
+ if (std::find_if(
+ versions.versions.cbegin(), versions.versions.cend(), [](const std::string &v) {
+ static const std::set<std::string_view, std::less<>> supported{
+ "v1.1",
+ "v1.2",
+ "v1.3",
+ };
+ return supported.count(v) != 0;
+ }) == versions.versions.cend()) {
+ emit setHsError(
+ tr("The selected server does not support a version of the Matrix protocol, that "
+ "this client understands (v1.1, v1.2 or v1.3). You can't register."));
+ emit hsErrorChanged();
+ return;
+ }
+
+ http::client()->registration(
+ [this](const mtx::responses::Register &, mtx::http::RequestErr e) {
+ nhlog::net()->debug("Registration check: {}", e);
+
+ if (!e) {
+ setHsError(tr("Server does not support querying registration flows!"));
+ emit hsErrorChanged();
+ return;
+ }
+ if (e->status_code != 401) {
+ setHsError(tr("Server does not support registration."));
+ emit hsErrorChanged();
+ return;
+ }
+
+ supported_ = true;
+ lookingUpHs_ = false;
+ emit lookingUpHsChanged();
+ });
+ });
}
void
diff --git a/src/RegisterPage.h b/src/RegisterPage.h
index 67e2a22e..d7a8602c 100644
--- a/src/RegisterPage.h
+++ b/src/RegisterPage.h
@@ -63,12 +63,12 @@ private:
QString registrationError_, hsError_, usernameError_;
- bool registering_;
- bool supported_;
- bool lookingUpHs_;
- bool lookingUpUsername_;
- bool usernameAvailable_;
- bool usernameUnavailable_;
+ bool registering_ = false;
+ bool supported_ = false;
+ bool lookingUpHs_ = false;
+ bool lookingUpUsername_ = false;
+ bool usernameAvailable_ = false;
+ bool usernameUnavailable_ = false;
QString lastServer;
};
|