diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index a90ab9e65..1ef1935c2 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -129,6 +129,14 @@ void AccountManager::save(bool saveCredentials) } } +void AccountManager::wantsAccountSavedSlot(AccountPtr a) +{ + auto settings = Account::settingsWithGroup(QLatin1String(accountsC)); + settings->beginGroup(a->id()); + save(a, *settings, true); + settings->endGroup(); +} + void AccountManager::save(const AccountPtr& acc, QSettings& settings, bool saveCredentials) { settings.setValue(QLatin1String(urlC), acc->_url.toString()); @@ -206,6 +214,9 @@ AccountState *AccountManager::addAccount(const AccountPtr& newAccount) } newAccount->_id = id; + QObject::connect(newAccount.data(), SIGNAL(wantsAccountSaved(AccountPtr)), + this, SLOT(wantsAccountSavedSlot(AccountPtr))); + AccountStatePtr newAccountState(new AccountState(newAccount)); _accounts << newAccountState; emit accountAdded(newAccountState.data()); diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index 033ec2a29..eed8e43e3 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -78,6 +78,9 @@ private: bool isAccountIdAvailable(const QString& id) const; QString generateFreeAccountId() const; +public slots: + void wantsAccountSavedSlot(AccountPtr a); + Q_SIGNALS: void accountAdded(AccountState *account); diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 690925277..1c75a08ab 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -399,6 +399,7 @@ void Account::slotHandleSslErrors(QNetworkReply *reply , QList errors if (_sslErrorHandler->handleErrors(errors, reply->sslConfiguration(), &approvedCerts, sharedFromThis())) { QSslSocket::addDefaultCaCertificates(approvedCerts); addApprovedCerts(approvedCerts); + emit wantsAccountSaved(sharedFromThis()); // all ssl certs are known and accepted. We can ignore the problems right away. // qDebug() << out << "Certs are known and trusted! This is not an actual error."; diff --git a/src/libsync/account.h b/src/libsync/account.h index c64ea3f57..4f98aa839 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -167,6 +167,9 @@ signals: /// Forwards from QNetworkAccessManager::proxyAuthenticationRequired(). void proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*); + // e.g. when the approved SSL certificates changed + void wantsAccountSaved(AccountPtr acc); + protected Q_SLOTS: void slotHandleSslErrors(QNetworkReply*,QList); void slotCredentialsFetched();