aboutsummaryrefslogtreecommitdiff
path: root/lib/accountregistry.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-30 15:24:02 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-30 15:24:02 +0200
commit078f5aab2e1eb1dea30828429069836509551b07 (patch)
treec47f13381689fb56d71be91843da281f44f36862 /lib/accountregistry.cpp
parent999ec716d5e2b03aceb562e730edf3939eb2578a (diff)
downloadlibquotient-078f5aab2e1eb1dea30828429069836509551b07.tar.gz
libquotient-078f5aab2e1eb1dea30828429069836509551b07.zip
Cleanup and reformatting
Diffstat (limited to 'lib/accountregistry.cpp')
-rw-r--r--lib/accountregistry.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/lib/accountregistry.cpp b/lib/accountregistry.cpp
index 9b148b51..b40d5ecf 100644
--- a/lib/accountregistry.cpp
+++ b/lib/accountregistry.cpp
@@ -79,35 +79,45 @@ void AccountRegistry::invokeLogin()
{
const auto accounts = SettingsGroup("Accounts").childGroups();
for (const auto& accountId : accounts) {
- AccountSettings account{accountId};
+ AccountSettings account { accountId };
m_accountsLoading += accountId;
emit accountsLoadingChanged();
- if (!account.homeserver().isEmpty()) {
- auto accessTokenLoadingJob = loadAccessTokenFromKeychain(account.userId());
- connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, [accountId, this, accessTokenLoadingJob]() {
- AccountSettings account{accountId};
- if (accessTokenLoadingJob->error() != QKeychain::Error::NoError) {
- emit keychainError(accessTokenLoadingJob->error());
- return;
- }
-
- auto connection = new Connection(account.homeserver());
- connect(connection, &Connection::connected, this, [connection] {
- connection->loadState();
- connection->setLazyLoading(true);
-
- connection->syncLoop();
+ if (account.homeserver().isEmpty())
+ continue;
+
+ auto accessTokenLoadingJob =
+ loadAccessTokenFromKeychain(account.userId());
+ connect(accessTokenLoadingJob, &QKeychain::Job::finished, this,
+ [accountId, this, accessTokenLoadingJob]() {
+ if (accessTokenLoadingJob->error()
+ != QKeychain::Error::NoError) {
+ emit keychainError(accessTokenLoadingJob->error());
+ return;
+ }
+
+ AccountSettings account { accountId };
+ auto connection = new Connection(account.homeserver());
+ connect(connection, &Connection::connected, this,
+ [connection] {
+ connection->loadState();
+ connection->setLazyLoading(true);
+
+ connection->syncLoop();
+ });
+ connect(connection, &Connection::loginError, this,
+ [this, connection](const QString& error,
+ const QString& details) {
+ emit loginError(connection, error, details);
+ });
+ connect(connection, &Connection::resolveError, this,
+ [this, connection](const QString& error) {
+ emit resolveError(connection, error);
+ });
+ connection->assumeIdentity(
+ account.userId(), accessTokenLoadingJob->binaryData(),
+ account.deviceId());
});
- connect(connection, &Connection::loginError, this, [this, connection](const QString& error, const QString& details) {
- emit loginError(connection, error, details);
- });
- connect(connection, &Connection::resolveError, this, [this, connection](QString error) {
- emit resolveError(connection, error);
- });
- connection->assumeIdentity(account.userId(), accessTokenLoadingJob->binaryData(), account.deviceId());
- });
- }
}
}