aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/accountregistry.cpp60
-rw-r--r--lib/connection.cpp10
2 files changed, 38 insertions, 32 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());
- });
- }
}
}
diff --git a/lib/connection.cpp b/lib/connection.cpp
index b7f49546..102fb16d 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -387,7 +387,7 @@ public:
const QByteArray& sessionKey) const;
#endif
- void saveAccessTokenToKeychain()
+ void saveAccessTokenToKeychain() const
{
qCDebug(MAIN) << "Saving access token to keychain for" << q->userId();
auto job = new QKeychain::WritePasswordJob(qAppName());
@@ -593,11 +593,9 @@ void Connection::Private::loginToServer(LoginArgTs&&... loginArgs)
data->setDeviceId(loginJob->deviceId());
completeSetup(loginJob->userId());
saveAccessTokenToKeychain();
-#ifndef Quotient_E2EE_ENABLED
- qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
-#else // Quotient_E2EE_ENABLED
+#ifdef Quotient_E2EE_ENABLED
database->clear();
-#endif // Quotient_E2EE_ENABLED
+#endif
});
connect(loginJob, &BaseJob::failure, q, [this, loginJob] {
emit q->loginError(loginJob->errorString(), loginJob->rawDataSample());
@@ -654,9 +652,7 @@ void Connection::Private::completeSetup(const QString& mxId)
olmAccount = std::make_unique<QOlmAccount>(data->userId(), data->deviceId(), q);
connect(olmAccount.get(), &QOlmAccount::needsSave, q, &Connection::saveOlmAccount);
-#ifdef Quotient_E2EE_ENABLED
loadSessions();
-#endif
if (database->accountPickle().isEmpty()) {
// create new account and save unpickle data