Skip to content

Commit

Permalink
Merge pull request #5385 from nextcloud/bugfix/issue-5383
Browse files Browse the repository at this point in the history
Only accept folder setup page if overrideLocalDir is set
  • Loading branch information
mgallien authored Feb 2, 2023
2 parents e5eac81 + e533c60 commit 69275bb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
46 changes: 34 additions & 12 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,18 @@ Application::Application(int &argc, char **argv)

parseOptions(arguments());
//no need to waste time;
if (_helpOnly || _versionOnly)
if (_helpOnly || _versionOnly) {
return;
}

if (_quitInstance) {
QTimer::singleShot(0, qApp, &QApplication::quit);
return;
}

if (isRunning())
if (isRunning()) {
return;
}

#if defined(WITH_CRASHREPORTER)
if (ConfigFile().crashReporter()) {
Expand All @@ -337,6 +339,19 @@ Application::Application(int &argc, char **argv)
}

ConfigFile cfg;

{
// these config values will always be empty after the first client run
if (!_overrideServerUrl.isEmpty()) {
cfg.setOverrideServerUrl(_overrideServerUrl);
}

if (!_overrideLocalDir.isEmpty()) {
cfg.setOverrideLocalDir(_overrideLocalDir);
}
}


// The timeout is initialized with an environment variable, if not, override with the value from the config
if (!AbstractNetworkJob::httpTimeout)
AbstractNetworkJob::httpTimeout = cfg.timeout();
Expand All @@ -345,10 +360,12 @@ Application::Application(int &argc, char **argv)
if (Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() == Vfs::Off) {
qCWarning(lcApplication) << "Theme wants to show vfs mode, but no vfs plugins are available";
}
if (isVfsPluginAvailable(Vfs::WindowsCfApi))
if (isVfsPluginAvailable(Vfs::WindowsCfApi)) {
qCInfo(lcApplication) << "VFS windows plugin is available";
if (isVfsPluginAvailable(Vfs::WithSuffix))
}
if (isVfsPluginAvailable(Vfs::WithSuffix)) {
qCInfo(lcApplication) << "VFS suffix plugin is available";
}

_folderManager.reset(new FolderMan);
#ifdef Q_OS_WIN
Expand Down Expand Up @@ -639,8 +656,9 @@ void Application::parseOptions(const QStringList &options)
{
QStringListIterator it(options);
// skip file name;
if (it.hasNext())
if (it.hasNext()) {
it.next();
}

bool shouldExit = false;

Expand Down Expand Up @@ -711,16 +729,16 @@ void Application::parseOptions(const QStringList &options)
&& QUrl::fromUserInput(overrideUrl).isValid();
if (!isUrlValid) {
showHint("Invalid URL passed to --overrideserverurl");
} else {
ConfigFile().setOverrideServerUrl(overrideUrl);
shouldExit = true;
} else {
_overrideServerUrl = overrideUrl;
}
} else {
showHint("Invalid URL passed to --overrideserverurl");
}
} else if (option == QStringLiteral("--overridelocaldir")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
ConfigFile().setOverrideLocalDir(it.next());
_overrideLocalDir = it.next();
} else {
showHint("Invalid URL passed to --overridelocaldir");
}
Expand Down Expand Up @@ -833,11 +851,13 @@ QString substLang(const QString &lang)
// transifex translation conventions.

// Simplified Chinese
if (lang == QLatin1String("zh_Hans"))
if (lang == QLatin1String("zh_Hans")) {
return QLatin1String("zh_CN");
}
// Traditional Chinese
if (lang == QLatin1String("zh_Hant"))
if (lang == QLatin1String("zh_Hant")) {
return QLatin1String("zh_TW");
}
return lang;
}

Expand All @@ -853,8 +873,9 @@ void Application::setupTranslations()
#endif

QString enforcedLocale = Theme::instance()->enforcedLocale();
if (!enforcedLocale.isEmpty())
if (!enforcedLocale.isEmpty()) {
uiLanguages.prepend(enforcedLocale);
}

auto *translator = new QTranslator(this);
auto *qtTranslator = new QTranslator(this);
Expand Down Expand Up @@ -895,8 +916,9 @@ void Application::setupTranslations()
installTranslator(qtkeychainTranslator);
break;
}
if (property("ui_lang").isNull())
if (property("ui_lang").isNull()) {
setProperty("ui_lang", "C");
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ protected slots:
QNetworkConfigurationManager _networkConfigurationManager;
QTimer _checkConnectionTimer;

QString _overrideServerUrl;
QString _overrideLocalDir;

#if defined(WITH_CRASHREPORTER)
QScopedPointer<CrashReporter::Handler> _crashHandler;
#endif
Expand Down
8 changes: 5 additions & 3 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,14 @@ void OwncloudAdvancedSetupPage::initializePage()
}
if (Theme::instance()->forceOverrideServerUrl()) {
QTimer::singleShot(0, this, [this]() {
connect(_ocWizard, &QDialog::accepted, []() {
ConfigFile cfg;
ConfigFile cfg;
connect(_ocWizard, &QDialog::accepted, [&]() {
cfg.setOverrideServerUrl({});
cfg.setOverrideLocalDir({});
});
_ocWizard->accept();
if (!cfg.overrideLocalDir().isEmpty()) {
_ocWizard->accept();
}
});
}
}
Expand Down

0 comments on commit 69275bb

Please sign in to comment.