aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2022-05-29 14:40:00 +0200
committerTobias Fella <fella@posteo.de>2022-05-29 14:40:00 +0200
commit283f95e429917bd0c7fb5982ceac1602eb2af0b9 (patch)
tree70ddb589bed5a8711b25171031d156112fe6e2d3
parentafcad0615b26421e60b234dc8488b6ea1150d416 (diff)
downloadlibquotient-283f95e429917bd0c7fb5982ceac1602eb2af0b9.tar.gz
libquotient-283f95e429917bd0c7fb5982ceac1602eb2af0b9.zip
Error handling
-rw-r--r--lib/accountregistry.cpp21
-rw-r--r--lib/accountregistry.h9
2 files changed, 12 insertions, 18 deletions
diff --git a/lib/accountregistry.cpp b/lib/accountregistry.cpp
index 91f2e9d7..5322ee80 100644
--- a/lib/accountregistry.cpp
+++ b/lib/accountregistry.cpp
@@ -7,11 +7,6 @@
#include "connection.h"
#include <QtCore/QCoreApplication>
-#if QT_VERSION_MAJOR >= 6
-# include <qt6keychain/keychain.h>
-#else
-# include <qt5keychain/keychain.h>
-#endif
using namespace Quotient;
void AccountRegistry::add(Connection* a)
@@ -75,13 +70,6 @@ QKeychain::ReadPasswordJob* AccountRegistry::loadAccessTokenFromKeychain(const Q
qCDebug(MAIN) << "Reading access token from keychain for" << userId;
auto job = new QKeychain::ReadPasswordJob(qAppName(), this);
job->setKey(userId);
-
- connect(job, &QKeychain::Job::finished, this, [job] {
- if (job->error() == QKeychain::Error::NoError) {
- return;
- }
- //TODO error handling
- });
job->start();
return job;
@@ -100,7 +88,7 @@ void AccountRegistry::invokeLogin()
connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, [accountId, this, accessTokenLoadingJob]() {
AccountSettings account{accountId};
if (accessTokenLoadingJob->error() != QKeychain::Error::NoError) {
- //TODO error handling
+ emit keychainError(accessTokenLoadingJob->error());
return;
}
@@ -111,11 +99,8 @@ void AccountRegistry::invokeLogin()
connection->syncLoop();
});
- connect(connection, &Connection::loginError, this, [](const QString& error, const QString&) {
- //TODO error handling
- });
- connect(connection, &Connection::networkError, this, [](const QString& error, const QString&, int, int) {
- //TODO error handling
+ connect(connection, &Connection::loginError, this, [this, connection](const QString& error, const QString& details) {
+ emit loginError(connection, error, details);
});
connection->assumeIdentity(account.userId(), accessTokenLoadingJob->binaryData(), account.deviceId());
});
diff --git a/lib/accountregistry.h b/lib/accountregistry.h
index ab337303..99827b73 100644
--- a/lib/accountregistry.h
+++ b/lib/accountregistry.h
@@ -9,6 +9,12 @@
#include <QtCore/QAbstractListModel>
+#if QT_VERSION_MAJOR >= 6
+# include <qt6keychain/keychain.h>
+#else
+# include <qt5keychain/keychain.h>
+#endif
+
namespace QKeychain {
class ReadPasswordJob;
}
@@ -69,6 +75,9 @@ public:
Q_SIGNALS:
void accountCountChanged();
void accountsLoadingChanged();
+
+ void keychainError(QKeychain::Error error);
+ void loginError(Connection* connection, QString message, QString details);
private:
QKeychain::ReadPasswordJob* loadAccessTokenFromKeychain(const QString &userId);
QStringList m_accountsLoading;