mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-24 03:58:49 +03:00
Require matrix v1.1 or greater
This commit is contained in:
parent
6e97f3da06
commit
5772447874
7 changed files with 98 additions and 47 deletions
|
@ -579,7 +579,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
MatrixClient
|
MatrixClient
|
||||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
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_EXAMPLES OFF CACHE INTERNAL "")
|
||||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
|
@ -203,7 +203,7 @@ modules:
|
||||||
buildsystem: cmake-ninja
|
buildsystem: cmake-ninja
|
||||||
name: mtxclient
|
name: mtxclient
|
||||||
sources:
|
sources:
|
||||||
- commit: 9ef7f7503c88b2a27e551324bd39a556b56aa8d6
|
- commit: e93779692fcc00de136234dd48d0af354717b0a1
|
||||||
#tag: v0.7.0
|
#tag: v0.7.0
|
||||||
type: git
|
type: git
|
||||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
|
|
|
@ -76,10 +76,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
color: Nheko.theme.error
|
color: Nheko.theme.error
|
||||||
text: login.mxidError
|
text: login.mxidError
|
||||||
visible: text
|
visible: text
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixTextField {
|
MatrixTextField {
|
||||||
|
@ -130,10 +132,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
color: Nheko.theme.error
|
color: Nheko.theme.error
|
||||||
text: loginPage.error
|
text: loginPage.error
|
||||||
visible: text
|
visible: text
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatButton {
|
FlatButton {
|
||||||
|
|
|
@ -75,10 +75,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
color: Nheko.theme.error
|
color: Nheko.theme.error
|
||||||
text: regis.hsError
|
text: regis.hsError
|
||||||
visible: text
|
visible: text
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -122,10 +124,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
color: Nheko.theme.error
|
color: Nheko.theme.error
|
||||||
text: regis.usernameError
|
text: regis.usernameError
|
||||||
visible: text
|
visible: text && regis.supported
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,10 +151,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
|
Layout.fillWidth: true
|
||||||
visible: regis.supported
|
visible: regis.supported
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
color: Nheko.theme.error
|
color: Nheko.theme.error
|
||||||
text: passwordLabel.text != passwordConfirmationLabel.text ? qsTr("Your passwords do not match!") : ""
|
text: passwordLabel.text != passwordConfirmationLabel.text ? qsTr("Your passwords do not match!") : ""
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixTextField {
|
MatrixTextField {
|
||||||
|
@ -177,10 +183,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
color: Nheko.theme.error
|
color: Nheko.theme.error
|
||||||
text: registrationPage.error
|
text: registrationPage.error
|
||||||
visible: text
|
visible: text
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatButton {
|
FlatButton {
|
||||||
|
|
|
@ -6,9 +6,12 @@
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <mtx/identifiers.hpp>
|
#include <mtx/identifiers.hpp>
|
||||||
#include <mtx/requests.hpp>
|
#include <mtx/requests.hpp>
|
||||||
#include <mtx/responses/login.hpp>
|
#include <mtx/responses/login.hpp>
|
||||||
|
#include <mtx/responses/version.hpp>
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
@ -149,7 +152,8 @@ LoginPage::checkHomeserverVersion()
|
||||||
return;
|
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) {
|
||||||
if (err->status_code == 404) {
|
if (err->status_code == 404) {
|
||||||
emit versionErrorCb(tr("The required endpoints were not found. "
|
emit versionErrorCb(tr("The required endpoints were not found. "
|
||||||
|
@ -170,6 +174,21 @@ LoginPage::checkHomeserverVersion()
|
||||||
return;
|
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,
|
http::client()->get_login([this](mtx::responses::LoginFlows flows,
|
||||||
mtx::http::RequestErr err) {
|
mtx::http::RequestErr err) {
|
||||||
if (err || flows.flows.empty())
|
if (err || flows.flows.empty())
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
#include <mtx/responses/register.hpp>
|
#include <mtx/responses/register.hpp>
|
||||||
|
#include <mtx/responses/version.hpp>
|
||||||
#include <mtx/responses/well-known.hpp>
|
#include <mtx/responses/well-known.hpp>
|
||||||
#include <mtxclient/http/client.hpp>
|
#include <mtxclient/http/client.hpp>
|
||||||
|
|
||||||
|
@ -101,7 +104,8 @@ RegisterPage::versionsCheck()
|
||||||
{
|
{
|
||||||
// Make a request to /_matrix/client/versions to check the address
|
// Make a request to /_matrix/client/versions to check the address
|
||||||
// given is a Matrix homeserver.
|
// given is a Matrix homeserver.
|
||||||
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) {
|
||||||
if (err->status_code == 404) {
|
if (err->status_code == 404) {
|
||||||
setHsError(
|
setHsError(
|
||||||
|
@ -122,6 +126,22 @@ RegisterPage::versionsCheck()
|
||||||
return;
|
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(
|
http::client()->registration(
|
||||||
[this](const mtx::responses::Register &, mtx::http::RequestErr e) {
|
[this](const mtx::responses::Register &, mtx::http::RequestErr e) {
|
||||||
nhlog::net()->debug("Registration check: {}", e);
|
nhlog::net()->debug("Registration check: {}", e);
|
||||||
|
|
|
@ -63,12 +63,12 @@ private:
|
||||||
|
|
||||||
QString registrationError_, hsError_, usernameError_;
|
QString registrationError_, hsError_, usernameError_;
|
||||||
|
|
||||||
bool registering_;
|
bool registering_ = false;
|
||||||
bool supported_;
|
bool supported_ = false;
|
||||||
bool lookingUpHs_;
|
bool lookingUpHs_ = false;
|
||||||
bool lookingUpUsername_;
|
bool lookingUpUsername_ = false;
|
||||||
bool usernameAvailable_;
|
bool usernameAvailable_ = false;
|
||||||
bool usernameUnavailable_;
|
bool usernameUnavailable_ = false;
|
||||||
|
|
||||||
QString lastServer;
|
QString lastServer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue