errorOccured
Have controller link to neochatconnection for errorOccured rather than call directly to remove dependency on controller. For all the same reasons as network/neochat!1926
This commit is contained in:
@@ -224,7 +224,7 @@ void Controller::invokeLogin()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(connection, &NeoChatConnection::networkError, this, [this](const QString &error, const QString &, int, int) {
|
connect(connection, &NeoChatConnection::networkError, this, [this](const QString &error, const QString &, int, int) {
|
||||||
Q_EMIT errorOccured(i18n("Network Error: %1", error), {});
|
Q_EMIT errorOccured(i18n("Network Error: %1", error));
|
||||||
});
|
});
|
||||||
#if Quotient_VERSION_MINOR > 8
|
#if Quotient_VERSION_MINOR > 8
|
||||||
connection->assumeIdentity(account.userId(), account.deviceId(), accessToken);
|
connection->assumeIdentity(account.userId(), account.deviceId(), accessToken);
|
||||||
@@ -250,17 +250,17 @@ QKeychain::ReadPasswordJob *Controller::loadAccessTokenFromKeyChain(const QStrin
|
|||||||
|
|
||||||
switch (job->error()) {
|
switch (job->error()) {
|
||||||
case QKeychain::EntryNotFound:
|
case QKeychain::EntryNotFound:
|
||||||
Q_EMIT errorOccured(i18n("Access token wasn't found"), i18n("Maybe it was deleted?"));
|
Q_EMIT errorOccured(i18n("Access token wasn't found: Maybe it was deleted?"));
|
||||||
break;
|
break;
|
||||||
case QKeychain::AccessDeniedByUser:
|
case QKeychain::AccessDeniedByUser:
|
||||||
case QKeychain::AccessDenied:
|
case QKeychain::AccessDenied:
|
||||||
Q_EMIT errorOccured(i18n("Access to keychain was denied."), i18n("Please allow NeoChat to read the access token"));
|
Q_EMIT errorOccured(i18n("Access to keychain was denied: Please allow NeoChat to read the access token"));
|
||||||
break;
|
break;
|
||||||
case QKeychain::NoBackendAvailable:
|
case QKeychain::NoBackendAvailable:
|
||||||
Q_EMIT errorOccured(i18n("No keychain available."), i18n("Please install a keychain, e.g. KWallet or GNOME keyring on Linux"));
|
Q_EMIT errorOccured(i18n("No keychain available: Please install a keychain, e.g. KWallet or GNOME keyring on Linux"));
|
||||||
break;
|
break;
|
||||||
case QKeychain::OtherError:
|
case QKeychain::OtherError:
|
||||||
Q_EMIT errorOccured(i18n("Unable to read access token"), job->errorString());
|
Q_EMIT errorOccured(i18n("Unable to read access token: %1", job->errorString()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -325,11 +325,17 @@ void Controller::setActiveConnection(NeoChatConnection *connection)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_connection != nullptr) {
|
||||||
|
m_connection->disconnect(this);
|
||||||
|
}
|
||||||
|
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
|
|
||||||
if (m_connection != nullptr) {
|
if (m_connection != nullptr) {
|
||||||
m_connection->refreshBadgeNotificationCount();
|
m_connection->refreshBadgeNotificationCount();
|
||||||
updateBadgeNotificationCount(m_connection, m_connection->badgeNotificationCount());
|
updateBadgeNotificationCount(m_connection, m_connection->badgeNotificationCount());
|
||||||
|
|
||||||
|
connect(m_connection, &NeoChatConnection::errorOccured, this, &Controller::errorOccured);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT activeConnectionChanged(m_connection);
|
Q_EMIT activeConnectionChanged(m_connection);
|
||||||
|
|||||||
@@ -129,7 +129,10 @@ private Q_SLOTS:
|
|||||||
void updateBadgeNotificationCount(NeoChatConnection *connection, int count);
|
void updateBadgeNotificationCount(NeoChatConnection *connection, int count);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void errorOccured(const QString &error, const QString &detail);
|
/**
|
||||||
|
* @brief Request a error message be shown to the user.
|
||||||
|
*/
|
||||||
|
void errorOccured(const QString &error);
|
||||||
void connectionAdded(NeoChatConnection *connection);
|
void connectionAdded(NeoChatConnection *connection);
|
||||||
void connectionDropped(NeoChatConnection *connection);
|
void connectionDropped(NeoChatConnection *connection);
|
||||||
void activeConnectionChanged(NeoChatConnection *connection);
|
void activeConnectionChanged(NeoChatConnection *connection);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void LoginHelper::init()
|
|||||||
m_connection = nullptr;
|
m_connection = nullptr;
|
||||||
});
|
});
|
||||||
connect(m_connection, &Connection::networkError, this, [this](QString error, const QString &, int, int) {
|
connect(m_connection, &Connection::networkError, this, [this](QString error, const QString &, int, int) {
|
||||||
Q_EMIT Controller::instance().errorOccured(i18n("Network Error"), std::move(error));
|
Q_EMIT m_connection->errorOccured(i18n("Network Error: %1", std::move(error)));
|
||||||
m_isLoggingIn = false;
|
m_isLoggingIn = false;
|
||||||
Q_EMIT isLoggingInChanged();
|
Q_EMIT isLoggingInChanged();
|
||||||
});
|
});
|
||||||
@@ -93,14 +93,14 @@ void LoginHelper::init()
|
|||||||
if (error == QStringLiteral("Invalid username or password")) {
|
if (error == QStringLiteral("Invalid username or password")) {
|
||||||
setInvalidPassword(true);
|
setInvalidPassword(true);
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT errorOccured(i18n("Login Failed: %1", error));
|
Q_EMIT loginErrorOccured(i18n("Login Failed: %1", error));
|
||||||
}
|
}
|
||||||
m_isLoggingIn = false;
|
m_isLoggingIn = false;
|
||||||
Q_EMIT isLoggingInChanged();
|
Q_EMIT isLoggingInChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_connection, &Connection::resolveError, this, [](QString error) {
|
connect(m_connection, &Connection::resolveError, this, [this](QString error) {
|
||||||
Q_EMIT Controller::instance().errorOccured(i18n("Network Error"), std::move(error));
|
Q_EMIT m_connection->errorOccured(i18n("Network Error: %1", std::move(error)));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ Q_SIGNALS:
|
|||||||
void loginFlowsChanged();
|
void loginFlowsChanged();
|
||||||
void ssoUrlChanged();
|
void ssoUrlChanged();
|
||||||
void connected();
|
void connected();
|
||||||
void errorOccured(const QString &message);
|
void loginErrorOccured(const QString &message);
|
||||||
void testingChanged();
|
void testingChanged();
|
||||||
void isLoggingInChanged();
|
void isLoggingInChanged();
|
||||||
void isLoggedInChanged();
|
void isLoggedInChanged();
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ Kirigami.Page {
|
|||||||
Connections {
|
Connections {
|
||||||
target: LoginHelper
|
target: LoginHelper
|
||||||
|
|
||||||
function onErrorOccured(message) {
|
function onLoginErrorOccured(message) {
|
||||||
headerMessage.text = message;
|
headerMessage.text = message;
|
||||||
headerMessage.visible = message.length > 0;
|
headerMessage.visible = message.length > 0;
|
||||||
headerMessage.type = Kirigami.MessageType.Error;
|
headerMessage.type = Kirigami.MessageType.Error;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "controller.h"
|
|
||||||
#include "jobs/neochatchangepasswordjob.h"
|
#include "jobs/neochatchangepasswordjob.h"
|
||||||
#include "jobs/neochatdeactivateaccountjob.h"
|
#include "jobs/neochatdeactivateaccountjob.h"
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
@@ -345,8 +344,8 @@ void NeoChatConnection::createRoom(const QString &name, const QString &topic, co
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(job, &CreateRoomJob::failure, this, [job] {
|
connect(job, &CreateRoomJob::failure, this, [this, job] {
|
||||||
Q_EMIT Controller::instance().errorOccured(i18n("Room creation failed: %1", job->errorString()), {});
|
Q_EMIT errorOccured(i18n("Room creation failed: %1", job->errorString()));
|
||||||
});
|
});
|
||||||
connect(
|
connect(
|
||||||
this,
|
this,
|
||||||
@@ -382,8 +381,8 @@ void NeoChatConnection::createSpace(const QString &name, const QString &topic, c
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(job, &CreateRoomJob::failure, this, [job] {
|
connect(job, &CreateRoomJob::failure, this, [this, job] {
|
||||||
Q_EMIT Controller::instance().errorOccured(i18n("Space creation failed: %1", job->errorString()), {});
|
Q_EMIT errorOccured(i18n("Space creation failed: %1", job->errorString()));
|
||||||
});
|
});
|
||||||
connect(
|
connect(
|
||||||
this,
|
this,
|
||||||
|
|||||||
@@ -212,6 +212,11 @@ Q_SIGNALS:
|
|||||||
void badgeNotificationCountChanged(NeoChatConnection *connection, int count);
|
void badgeNotificationCountChanged(NeoChatConnection *connection, int count);
|
||||||
void canCheckMutualRoomsChanged();
|
void canCheckMutualRoomsChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Request a error message be shown to the user.
|
||||||
|
*/
|
||||||
|
void errorOccured(const QString &error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isOnline = true;
|
bool m_isOnline = true;
|
||||||
void setIsOnline(bool isOnline);
|
void setIsOnline(bool isOnline);
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ Kirigami.ApplicationWindow {
|
|||||||
Connections {
|
Connections {
|
||||||
target: Controller
|
target: Controller
|
||||||
|
|
||||||
function onErrorOccured(error, detail) {
|
function onErrorOccured(error) {
|
||||||
showPassiveNotification(detail.length > 0 ? i18n("%1: %2", error, detail) : error, "short");
|
showPassiveNotification(error, "short");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user