Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ void AccountManager::save(bool saveCredentials)
settings->setValue(QLatin1String(versionC), maxAccountsVersion);
for (const auto &acc : std::as_const(_accounts)) {
settings->beginGroup(acc->account()->id());
saveAccountHelper(acc->account().data(), *settings, saveCredentials);
saveAccountHelper(acc->account(), *settings, saveCredentials);
settings->endGroup();
}

settings->sync();
qCInfo(lcAccountManager) << "Saved all account settings, status:" << settings->status();
}

void AccountManager::saveAccount(Account *newAccountData)
void AccountManager::saveAccount(const AccountPtr &newAccountData)
{
qCDebug(lcAccountManager) << "Saving account" << newAccountData->url().toString();
const auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
Expand All @@ -311,7 +311,7 @@ void AccountManager::saveAccountState(AccountState *a)
qCDebug(lcAccountManager) << "Saved account state settings, status:" << settings->status();
}

void AccountManager::saveAccountHelper(Account *account, QSettings &settings, bool saveCredentials)
void AccountManager::saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials)
{
qCDebug(lcAccountManager) << "Saving settings to" << settings.fileName();
settings.setValue(QLatin1String(versionC), maxAccountVersion);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/accountmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AccountManager : public QObject

public slots:
/// Saves account data when adding user, when updating e.g. dav user, not including the credentials
void saveAccount(OCC::Account *newAccountData);
void saveAccount(const OCC::AccountPtr &newAccountData);

/// Saves account state data, not including the account
void saveAccountState(OCC::AccountState *a);
Expand All @@ -118,7 +118,7 @@ public slots:

private:
// saving and loading Account to settings
void saveAccountHelper(Account *account, QSettings &settings, bool saveCredentials = true);
void saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials = true);
AccountPtr loadAccountHelper(QSettings &settings);

bool restoreFromLegacySettings();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ void Application::slotAccountStateAdded(AccountState *accountState)
connect(accountState->account().data(), &Account::serverVersionChanged,
_folderManager.data(), &FolderMan::slotServerVersionChanged);

_gui->slotTrayMessageIfServerUnsupported(accountState->account().data());
_gui->slotTrayMessageIfServerUnsupported(accountState->account());
}

void Application::slotCleanup()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/connectionvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in
if (_account->url() != url) {
qCInfo(lcConnectionValidator()) << "status.php was redirected to" << url.toString();
_account->setUrl(url);
emit _account->wantsAccountSaved(_account.data());
emit _account->wantsAccountSaved(_account);
}

if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/creds/webflowcredentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void WebFlowCredentials::persist() {
}

_account->setCredentialSetting(userC, _user);
emit _account->wantsAccountSaved(_account);
emit _account->wantsAccountSaved(_account->sharedFromThis());

// write cert if there is one
if (!_clientSslCertificate.isNull()) {
Expand Down
12 changes: 6 additions & 6 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ void FolderMan::slotStartScheduledFolderSync()
}
}

bool FolderMan::pushNotificationsFilesReady(Account *account)
bool FolderMan::pushNotificationsFilesReady(const AccountPtr &account)
{
const auto pushNotifications = account->pushNotifications();
const auto pushFilesAvailable = account->capabilities().availablePushNotifications() & PushNotificationType::Files;
Expand Down Expand Up @@ -1017,7 +1017,7 @@ void FolderMan::slotEtagPollTimerTimeout()
// Some folders need not to be checked because they use the push notifications
std::copy_if(folderMapValues.begin(), folderMapValues.end(), std::back_inserter(foldersToRun), [this](Folder *folder) -> bool {
const auto account = folder->accountState()->account();
return !pushNotificationsFilesReady(account.data());
return !pushNotificationsFilesReady(account);
});

qCInfo(lcFolderMan) << "Number of folders that don't use push notifications:" << foldersToRun.size();
Expand Down Expand Up @@ -1059,7 +1059,7 @@ void FolderMan::runEtagJobIfPossible(Folder *folder)
return;
}
// When not using push notifications, make sure polltime is reached
if (!pushNotificationsFilesReady(folder->accountState()->account().data())) {
if (!pushNotificationsFilesReady(folder->accountState()->account())) {
if (folder->msecSinceLastSync() < polltime) {
qCInfo(lcFolderMan) << "Can not run etag job: Polltime not reached";
return;
Expand Down Expand Up @@ -1107,7 +1107,7 @@ void FolderMan::slotForwardFolderSyncStateChange()
}
}

void FolderMan::slotServerVersionChanged(Account *account)
void FolderMan::slotServerVersionChanged(const OCC::AccountPtr &account)
{
// Pause folders if the server version is unsupported
if (account->serverVersionUnsupported()) {
Expand Down Expand Up @@ -2059,7 +2059,7 @@ void FolderMan::slotSetupPushNotifications(const Folder::Map &folderMap)
// See if the account already provides the PushNotifications object and if yes connect to it.
// If we can't connect at this point, the signals will be connected in slotPushNotificationsReady()
// after the PushNotification object emitted the ready signal
slotConnectToPushNotifications(account.data());
slotConnectToPushNotifications(account);
connect(account.data(), &Account::pushNotificationsReady, this, &FolderMan::slotConnectToPushNotifications, Qt::UniqueConnection);
}
}
Expand All @@ -2079,7 +2079,7 @@ void FolderMan::slotProcessFilesPushNotification(Account *account)
}
}

void FolderMan::slotConnectToPushNotifications(Account *account)
void FolderMan::slotConnectToPushNotifications(const AccountPtr &account)
{
const auto pushNotifications = account->pushNotifications();

Expand Down
6 changes: 3 additions & 3 deletions src/gui/folderman.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private slots:
// FolderMan::folderSyncStateChange(Folder*) signal.
void slotForwardFolderSyncStateChange();

void slotServerVersionChanged(OCC::Account *account);
void slotServerVersionChanged(const OCC::AccountPtr &account);

/**
* A file whose locks were being monitored has become unlocked.
Expand All @@ -337,7 +337,7 @@ private slots:

void slotSetupPushNotifications(const OCC::Folder::Map &);
void slotProcessFilesPushNotification(OCC::Account *account);
void slotConnectToPushNotifications(OCC::Account *account);
void slotConnectToPushNotifications(const OCC::AccountPtr &account);

void slotLeaveShare(const QString &localFile, const QByteArray &folderToken = {});

Expand Down Expand Up @@ -369,7 +369,7 @@ private slots:
void runEtagJobsIfPossible(const QList<Folder *> &folderMap);
void runEtagJobIfPossible(Folder *folder);

bool pushNotificationsFilesReady(Account *account);
bool pushNotificationsFilesReady(const OCC::AccountPtr &account);

[[nodiscard]] bool isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const;

Expand Down
4 changes: 2 additions & 2 deletions src/gui/networksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void NetworkSettings::saveProxySettings()
_account->setProxySettings(proxySetting, proxyType, host, port, needsAuth, user, password);
const auto accountState = AccountManager::instance()->accountFromUserId(_account->userIdAtHostWithPort());
accountState->freshConnectionAttempt();
AccountManager::instance()->saveAccount(_account.data());
AccountManager::instance()->saveAccount(_account);
} else {
ConfigFile().setProxyType(proxyType, host, port, needsAuth, user, password);
ClientProxy proxy;
Expand Down Expand Up @@ -275,7 +275,7 @@ void NetworkSettings::saveBWLimitSettings()
_account->setDownloadLimit(downloadLimit);
_account->setUploadLimitSetting(static_cast<Account::AccountNetworkTransferLimitSetting>(useUploadLimit));
_account->setUploadLimit(uploadLimit);
AccountManager::instance()->saveAccount(_account.data());
AccountManager::instance()->saveAccount(_account);
} else {
ConfigFile cfg;
cfg.setUseDownloadLimit(useDownloadLimit);
Expand Down
6 changes: 3 additions & 3 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void ownCloudGui::slotOpenPath(const QString &path)
showInFileManager(path);
}

void ownCloudGui::slotTrayMessageIfServerUnsupported(Account *account)
void ownCloudGui::slotTrayMessageIfServerUnsupported(const AccountPtr &account)
{
if (account->serverVersionUnsupported()) {
slotShowTrayMessage(
Expand All @@ -276,8 +276,8 @@ void ownCloudGui::slotTrayMessageIfServerUnsupported(Account *account)
}
}

void ownCloudGui::slotNeedToAcceptTermsOfService(OCC::AccountPtr account,
AccountState::State state)
void ownCloudGui::slotNeedToAcceptTermsOfService(const OCC::AccountPtr &account,
const OCC::AccountState::State state)
{
if (state == AccountState::NeedToSignTermsOfService) {
slotShowTrayMessage(
Expand Down
4 changes: 2 additions & 2 deletions src/gui/owncloudgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public slots:
void slotSettingsDialogActivated();
void slotHelp();
void slotOpenPath(const QString &path);
void slotTrayMessageIfServerUnsupported(OCC::Account *account);
void slotNeedToAcceptTermsOfService(OCC::AccountPtr account,
void slotTrayMessageIfServerUnsupported(const OCC::AccountPtr &account);
void slotNeedToAcceptTermsOfService(const OCC::AccountPtr &account,
OCC::AccountState::State state);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/gui/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ AccountState *OwncloudSetupWizard::applyAccountChanges()
auto manager = AccountManager::instance();

auto newState = manager->addAccount(newAccount);
manager->saveAccount(newAccount.data());
manager->saveAccount(newAccount);
return newState;
}

Expand Down
14 changes: 7 additions & 7 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void Account::setDavUser(const QString &newDavUser)

_davUser = newDavUser;

emit wantsAccountSaved(this);
emit wantsAccountSaved(sharedFromThis());
emit prettyNameChanged();
}

Expand Down Expand Up @@ -332,7 +332,7 @@ void Account::trySetupPushNotifications()

connect(_pushNotifications, &PushNotifications::ready, this, [this]() {
_pushNotificationsReconnectTimer.stop();
emit pushNotificationsReady(this);
emit pushNotificationsReady(sharedFromThis());
});

const auto disablePushNotifications = [this]() {
Expand All @@ -341,7 +341,7 @@ void Account::trySetupPushNotifications()
return;
}
if (!_pushNotifications->isReady()) {
emit pushNotificationsDisabled(this);
emit pushNotificationsDisabled(sharedFromThis());
}
if (!_pushNotificationsReconnectTimer.isActive()) {
_pushNotificationsReconnectTimer.start();
Expand Down Expand Up @@ -609,7 +609,7 @@ void Account::slotHandleSslErrors(QNetworkReply *reply, QList<QSslError> errors)
if (!approvedCerts.isEmpty()) {
QSslConfiguration::defaultConfiguration().addCaCertificates(approvedCerts);
addApprovedCerts(approvedCerts);
emit wantsAccountSaved(this);
emit wantsAccountSaved(sharedFromThis());

// all ssl certs are known and accepted. We can ignore the problems right away.
qCInfo(lcAccount) << out << "Certs are known and trusted! This is not an actual error.";
Expand Down Expand Up @@ -737,7 +737,7 @@ bool Account::shouldSkipE2eeMetadataChecksumValidation() const
void Account::resetShouldSkipE2eeMetadataChecksumValidation()
{
_skipE2eeMetadataChecksumValidation = false;
emit wantsAccountSaved(this);
emit wantsAccountSaved(sharedFromThis());
}

int Account::serverVersionInt() const
Expand Down Expand Up @@ -809,7 +809,7 @@ void Account::setServerVersion(const QString &version)

auto oldServerVersion = _serverVersion;
_serverVersion = version;
emit serverVersionChanged(this, oldServerVersion, version);
emit serverVersionChanged(sharedFromThis(), oldServerVersion, version);
}

void Account::writeAppPasswordOnce(QString appPassword){
Expand Down Expand Up @@ -1122,7 +1122,7 @@ void Account::setEncryptionCertificateFingerprint(const QByteArray &fingerprint)
_encryptionCertificateFingerprint = fingerprint;
_e2e.usbTokenInformation()->setSha256Fingerprint(fingerprint);
Q_EMIT encryptionCertificateFingerprintChanged();
Q_EMIT wantsAccountSaved(this);
Q_EMIT wantsAccountSaved(sharedFromThis());
}

void Account::setAskUserForMnemonic(const bool ask)
Expand Down
8 changes: 4 additions & 4 deletions src/libsync/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ public slots:
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *);

// e.g. when the approved SSL certificates changed
void wantsAccountSaved(OCC::Account *acc);
void wantsAccountSaved(const OCC::AccountPtr &acc);

void wantsFoldersSynced();

void serverVersionChanged(OCC::Account *account, const QString &newVersion, const QString &oldVersion);
void serverVersionChanged(const AccountPtr &account, const QString &newVersion, const QString &oldVersion);

void accountChangedAvatar();
void accountChangedDisplayName();
Expand All @@ -460,8 +460,8 @@ public slots:
/// Used in RemoteWipe
void appPasswordRetrieved(QString);

void pushNotificationsReady(OCC::Account *account);
void pushNotificationsDisabled(OCC::Account *account);
void pushNotificationsReady(const OCC::AccountPtr &account);
void pushNotificationsDisabled(const OCC::AccountPtr &account);

void userStatusChanged();

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/creds/httpcredentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void HttpCredentials::persist()
// it's just written if it gets passed into the constructor.
_account->setCredentialSetting(QLatin1String(clientCertBundleC), _clientCertBundle);
}
emit _account->wantsAccountSaved(_account);
emit _account->wantsAccountSaved(_account->sharedFromThis());

// write secrets to the keychain
if (!_clientCertBundle.isEmpty()) {
Expand Down
8 changes: 4 additions & 4 deletions test/testpushnotifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ private slots:

QCOMPARE(connectionLostSpy.count(), 1);

auto accountSent = pushNotificationsDisabledSpy.at(0).at(0).value<OCC::Account *>();
QCOMPARE(accountSent, account.data());
const auto accountSent = pushNotificationsDisabledSpy.at(0).at(0).value<OCC::AccountPtr>();
QCOMPARE(accountSent.data(), account.data());
}

void testAccount_web_socket_authenticationFailed_emitNotificationsDisabled()
Expand All @@ -272,8 +272,8 @@ private slots:

// Now the pushNotificationsDisabled Signal should be emitted
QCOMPARE(pushNotificationsDisabledSpy.count(), 1);
auto accountSent = pushNotificationsDisabledSpy.at(0).at(0).value<OCC::Account *>();
QCOMPARE(accountSent, account.data());
const auto accountSent = pushNotificationsDisabledSpy.at(0).at(0).value<OCC::AccountPtr>();
QCOMPARE(accountSent.data(), account.data());
}

void testPingTimeout_pingTimedOut_reconnect()
Expand Down