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: 4 additions & 2 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015 ownCloud GmbH
Expand Down Expand Up @@ -873,8 +873,10 @@
acc->setSslErrorHandler(new SslDialogErrorHandler);
connect(acc.data(), &Account::proxyAuthenticationRequired,
ProxyAuthHandler::instance(), &ProxyAuthHandler::handleProxyAuthenticationRequired);
connect(acc.data(), &Account::lockFileError,
Systray::instance(), &Systray::showErrorMessageDialog);
if (Systray::instance()) {
connect(acc.data(), &Account::lockFileError,
Systray::instance(), &Systray::showErrorMessageDialog);
}

return acc;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/accountsetupcommandlinemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool AccountSetupCommandLineManager::parseCommandlineOption(const QString &optio

bool AccountSetupCommandLineManager::isCommandLineParsed() const
{
return !_appPassword.isEmpty() && !_userId.isEmpty() && _serverUrl.isValid();
return !_userId.isEmpty() && _serverUrl.isValid();
}

bool AccountSetupCommandLineManager::isVfsEnabled() const
Expand Down
10 changes: 9 additions & 1 deletion src/gui/accountsetupfromcommandlinejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <QJsonObject>
#include <QLoggingCategory>

using namespace Qt::StringLiterals;

namespace OCC
{
Q_LOGGING_CATEGORY(lcAccountSetupCommandLineJob, "nextcloud.gui.accountsetupcommandlinejob", QtInfoMsg)
Expand Down Expand Up @@ -70,8 +72,14 @@

const auto credentials = new WebFlowCredentials(_userId, _appPassword);
_account = AccountManager::createAccount();

_account->setCredentials(credentials);
_account->setCredentialSetting(u"user"_s, _userId);
_account->setUrl(_serverUrl);
auto accountState = AccountManager::instance()->addAccount(_account);

Check warning on line 79 in src/gui/accountsetupfromcommandlinejob.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "accountState" of type "class OCC::AccountState *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9BY6rA7f4k_Nbh2J2t&open=AZ9BY6rA7f4k_Nbh2J2t&pullRequest=10319
setupLocalSyncFolder(accountState);

Q_EMIT _account->wantsAccountSaved(_account);

fetchUserName();
}
Expand Down Expand Up @@ -194,7 +202,7 @@
AccountManager::instance()->deleteAccount(accountState);
printAccountSetupFromCommandLineStatusAndExit(
QStringLiteral("Account %1 setup from command line failed, due to folder creation failure.").arg(_account->displayName()),
false);
true);
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Application::Application(int &argc, char **argv)

// try to migrate legacy accounts and folders from a previous client version
// only copy the settings and check what should be skipped
if (!configVersionMigration()) {
if (!AccountSetupCommandLineManager::instance()->isCommandLineParsed() && !configVersionMigration()) {
qCWarning(lcApplication) << "Config version migration was not possible.";
}

Expand Down Expand Up @@ -412,6 +412,16 @@ Application::Application(int &argc, char **argv)
connect(&_singleApp, &KDSingleApplication::messageReceived, this, &Application::slotParseMessage);
#endif

if (AccountSetupCommandLineManager::instance()->isCommandLineParsed()) {
_folderManager.reset(new FolderMan);
AccountSetupCommandLineManager::instance()->setupAccountFromCommandLine();
_quitInstance = true;
}
AccountSetupCommandLineManager::destroy();
if (_quitInstance) {
return;
}

// create accounts and folders from a legacy desktop client or from the current config file
setupAccountsAndFolders();

Expand Down Expand Up @@ -501,11 +511,6 @@ Application::Application(int &argc, char **argv)
}
#endif

if (AccountSetupCommandLineManager::instance()->isCommandLineParsed()) {
AccountSetupCommandLineManager::instance()->setupAccountFromCommandLine();
}
AccountSetupCommandLineManager::destroy();

#if defined(BUILD_FILE_PROVIDER_MODULE)
Mac::FileProvider::instance();
if (Mac::FileProvider::available()) {
Expand Down
6 changes: 4 additions & 2 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ Systray::Systray()
this, [this]{ showWindow(WindowPosition::Center); });
#endif

connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &Systray::slotSyncFoldersChanged);
slotSyncFoldersChanged(FolderMan::instance()->map());
if (FolderMan::instance()) {
connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &Systray::slotSyncFoldersChanged);
slotSyncFoldersChanged(FolderMan::instance()->map());
}
}

void Systray::create()
Expand Down
Loading