summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-02-28 22:07:53 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-02-28 22:07:53 +0200
commitf6c279f6f2c6ab2b11d1b48cfe418be2ff3a49ff (patch)
tree94348aa0867a0add612ef4f4026e39e53155a1f5 /src
parentFix crash when inviting users (diff)
downloadnheko-f6c279f6f2c6ab2b11d1b48cfe418be2ff3a49ff.tar.xz
Propagate errors during /login & /versions
Diffstat (limited to 'src')
-rw-r--r--src/LoginPage.cc12
-rw-r--r--src/MatrixClient.cc10
2 files changed, 10 insertions, 12 deletions
diff --git a/src/LoginPage.cc b/src/LoginPage.cc

index 3be9d1a9..6c01670a 100644 --- a/src/LoginPage.cc +++ b/src/LoginPage.cc
@@ -222,20 +222,8 @@ LoginPage::onServerAddressEntered() void LoginPage::versionError(QString error) { - // Matrix homeservers are often kept on a subdomain called 'matrix' - // so let's try that next, unless the address was set explicitly or the domain - // part of the username already points to this subdomain QUrl currentServer = client_->getHomeServer(); QString mxidAddress = matrixid_input_->text().split(":").at(1); - if (currentServer.host() == inferredServerAddress_ && - !currentServer.host().startsWith("matrix")) { - error_label_->setText(""); - currentServer.setHost(QString("matrix.") + currentServer.host()); - serverInput_->setText(currentServer.host()); - client_->setServer(currentServer.host()); - client_->versions(); - return; - } error_label_->setText(error); serverInput_->show(); diff --git a/src/MatrixClient.cc b/src/MatrixClient.cc
index b5c4900b..bcf7a62b 100644 --- a/src/MatrixClient.cc +++ b/src/MatrixClient.cc
@@ -123,6 +123,11 @@ MatrixClient::login(const QString &username, const QString &password) noexcept int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + if (reply->error()) { + emit loginError(reply->errorString()); + return; + } + if (status_code == 403) { emit loginError(tr("Wrong username or password")); return; @@ -428,6 +433,11 @@ MatrixClient::versions() noexcept int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + if (reply->error()) { + emit versionError(reply->errorString()); + return; + } + if (status_code == 404) { emit versionError("Versions endpoint was not found on the server. Possibly " "not a Matrix server");