diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2018-09-14 16:25:59 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2018-09-14 16:25:59 +0300 |
commit | 0290564d5c654d654856f04f1b04bad984f36aee (patch) | |
tree | 3b9a5eda39861d9467bc130a00e7effbc4ef7b6c /src/libsync/configfile.cpp | |
parent | 638f5c8752164ccc0429b1df60b79c3d3293bcd4 (diff) | |
parent | 3a335879fa1f00f094d82855126fec3f6ab59405 (diff) |
Merge remote-tracking branch 'owncloud/master' into delta-sync
Conflicts:
.gitmodules
src/cmd/cmd.cpp
src/gui/generalsettings.ui
src/libsync/propagatedownload.cpp
src/libsync/propagateuploadng.cpp
Diffstat (limited to 'src/libsync/configfile.cpp')
-rw-r--r-- | src/libsync/configfile.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 1c05124c5..939e144fa 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -16,8 +16,10 @@ #include "configfile.h" #include "theme.h" +#include "version.h" #include "common/utility.h" #include "common/asserts.h" +#include "version.h" #include "creds/abstractcredentials.h" @@ -58,12 +60,16 @@ static const char optionalDesktopNoficationsC[] = "optionalDesktopNotifications" static const char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane"; static const char skipUpdateCheckC[] = "skipUpdateCheck"; static const char updateCheckIntervalC[] = "updateCheckInterval"; +static const char updateChannelC[] = "updateChannel"; static const char geometryC[] = "geometry"; static const char timeoutC[] = "timeout"; static const char chunkSizeC[] = "chunkSize"; static const char minChunkSizeC[] = "minChunkSize"; static const char maxChunkSizeC[] = "maxChunkSize"; static const char targetChunkUploadDurationC[] = "targetChunkUploadDuration"; +static const char automaticLogDirC[] = "logToTemporaryLogDir"; +static const char showExperimentalOptionsC[] = "showExperimentalOptions"; +static const char clientVersionC[] = "clientVersion"; static const char proxyHostC[] = "Proxy/host"; static const char proxyTypeC[] = "Proxy/type"; @@ -342,6 +348,28 @@ QString ConfigFile::excludeFileFromSystem() return fi.absoluteFilePath(); } +QString ConfigFile::backup() const +{ + QString baseFile = configFile(); + auto versionString = clientVersionString(); + if (!versionString.isEmpty()) + versionString.prepend('_'); + QString backupFile = + QString("%1.backup_%2%3") + .arg(baseFile) + .arg(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss")) + .arg(versionString); + + // If this exact file already exists it's most likely that a backup was + // already done. (two backup calls directly after each other, potentially + // even with source alterations in between!) + if (!QFile::exists(backupFile)) { + QFile f(baseFile); + f.copy(backupFile); + } + return backupFile; +} + QString ConfigFile::configFile() const { return configPath() + Theme::instance()->configFileName(); @@ -517,6 +545,28 @@ void ConfigFile::setSkipUpdateCheck(bool skip, const QString &connection) settings.sync(); } +QString ConfigFile::updateChannel() const +{ + QString defaultUpdateChannel = QStringLiteral("stable"); + QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); + if (suffix.startsWith("daily") + || suffix.startsWith("nightly") + || suffix.startsWith("alpha") + || suffix.startsWith("rc") + || suffix.startsWith("beta")) { + defaultUpdateChannel = QStringLiteral("beta"); + } + + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString(); +} + +void ConfigFile::setUpdateChannel(const QString &channel) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(updateChannelC), channel); +} + int ConfigFile::maxLogLines() const { QSettings settings(configFile(), QSettings::IniFormat); @@ -761,6 +811,24 @@ void ConfigFile::setCrashReporter(bool enabled) settings.setValue(QLatin1String(crashReporterC), enabled); } +bool ConfigFile::automaticLogDir() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(automaticLogDirC), false).toBool(); +} + +void ConfigFile::setAutomaticLogDir(bool enabled) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(automaticLogDirC), enabled); +} + +bool ConfigFile::showExperimentalOptions() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(showExperimentalOptionsC), false).toBool(); +} + QString ConfigFile::certificatePath() const { return retrieveData(QString(), QLatin1String(certPath)).toString(); @@ -785,6 +853,18 @@ void ConfigFile::setCertificatePasswd(const QString &cPasswd) settings.sync(); } +QString ConfigFile::clientVersionString() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(clientVersionC), QString()).toString(); +} + +void ConfigFile::setClientVersionString(const QString &version) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(clientVersionC), version); +} + Q_GLOBAL_STATIC(QString, g_configFileName) std::unique_ptr<QSettings> ConfigFile::settingsWithGroup(const QString &group, QObject *parent) |