2012-02-17 14:11:18 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
2012-05-21 18:48:49 +04:00
|
|
|
|
2012-09-18 14:55:58 +04:00
|
|
|
#include "config.h"
|
|
|
|
|
2014-11-10 01:25:57 +03:00
|
|
|
#include "configfile.h"
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "theme.h"
|
2018-05-14 15:37:48 +03:00
|
|
|
#include "version.h"
|
2017-08-16 09:36:52 +03:00
|
|
|
#include "common/utility.h"
|
2017-09-01 19:11:43 +03:00
|
|
|
#include "common/asserts.h"
|
2018-04-26 12:24:30 +03:00
|
|
|
#include "version.h"
|
2013-08-24 16:57:55 +04:00
|
|
|
|
2013-07-30 13:19:22 +04:00
|
|
|
#include "creds/abstractcredentials.h"
|
2020-06-25 17:59:57 +03:00
|
|
|
#include "creds/keychainchunk.h"
|
2013-08-24 16:57:55 +04:00
|
|
|
|
2017-11-29 14:04:01 +03:00
|
|
|
#include "csync_exclude.h"
|
|
|
|
|
2014-04-06 21:34:56 +04:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2013-08-24 16:57:55 +04:00
|
|
|
#include <QWidget>
|
2014-04-06 21:34:56 +04:00
|
|
|
#include <QHeaderView>
|
|
|
|
#endif
|
|
|
|
|
2013-09-05 21:53:29 +04:00
|
|
|
#include <QCoreApplication>
|
2013-10-21 23:42:52 +04:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileInfo>
|
2017-05-09 15:24:11 +03:00
|
|
|
#include <QLoggingCategory>
|
2013-10-21 23:42:52 +04:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QNetworkProxy>
|
2017-12-06 17:29:07 +03:00
|
|
|
#include <QStandardPaths>
|
2019-09-08 19:42:40 +03:00
|
|
|
|
2019-09-08 20:46:08 +03:00
|
|
|
#define QTLEGACY (QT_VERSION < QT_VERSION_CHECK(5,9,0))
|
|
|
|
|
2019-09-08 20:22:40 +03:00
|
|
|
#if !(QTLEGACY)
|
2019-09-08 16:40:49 +03:00
|
|
|
#include <QOperatingSystemVersion>
|
2019-09-08 19:42:40 +03:00
|
|
|
#endif
|
2012-02-17 14:11:18 +04:00
|
|
|
|
2019-09-29 01:42:24 +03:00
|
|
|
#define DEFAULT_REMOTE_POLL_INTERVAL 30000 // default remote poll time in milliseconds
|
2013-07-19 18:27:54 +04:00
|
|
|
#define DEFAULT_MAX_LOG_LINES 20000
|
2012-08-06 15:57:26 +04:00
|
|
|
|
2021-06-03 17:10:26 +03:00
|
|
|
namespace {
|
2021-06-21 14:33:22 +03:00
|
|
|
static constexpr char showMainDialogAsNormalWindowC[] = "showMainDialogAsNormalWindow";
|
2021-06-03 17:10:26 +03:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2012-02-17 14:11:18 +04:00
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
namespace chrono = std::chrono;
|
|
|
|
|
2020-07-01 16:30:44 +03:00
|
|
|
Q_LOGGING_CATEGORY(lcConfigFile, "nextcloud.sync.configfile", QtInfoMsg)
|
2017-05-09 15:24:11 +03:00
|
|
|
|
2015-04-15 15:58:27 +03:00
|
|
|
//static const char caCertsKeyC[] = "CaCertificates"; only used from account.cpp
|
2013-07-19 18:27:54 +04:00
|
|
|
static const char remotePollIntervalC[] = "remotePollInterval";
|
2013-08-08 16:30:45 +04:00
|
|
|
static const char forceSyncIntervalC[] = "forceSyncInterval";
|
2017-09-14 17:43:23 +03:00
|
|
|
static const char fullLocalDiscoveryIntervalC[] = "fullLocalDiscoveryInterval";
|
2016-03-18 18:23:21 +03:00
|
|
|
static const char notificationRefreshIntervalC[] = "notificationRefreshInterval";
|
2013-07-19 18:27:54 +04:00
|
|
|
static const char monoIconsC[] = "monoIcons";
|
2016-01-24 21:45:12 +03:00
|
|
|
static const char promptDeleteC[] = "promptDeleteAllFiles";
|
2014-08-28 18:19:17 +04:00
|
|
|
static const char crashReporterC[] = "crashReporter";
|
2018-02-15 22:21:08 +03:00
|
|
|
static const char optionalServerNotificationsC[] = "optionalServerNotifications";
|
2017-10-19 17:37:51 +03:00
|
|
|
static const char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane";
|
2013-07-19 18:27:54 +04:00
|
|
|
static const char skipUpdateCheckC[] = "skipUpdateCheck";
|
2020-03-09 03:17:02 +03:00
|
|
|
static const char autoUpdateCheckC[] = "autoUpdateCheck";
|
2015-06-15 13:24:18 +03:00
|
|
|
static const char updateCheckIntervalC[] = "updateCheckInterval";
|
2020-02-21 23:28:42 +03:00
|
|
|
static const char updateSegmentC[] = "updateSegment";
|
2018-04-26 12:24:30 +03:00
|
|
|
static const char updateChannelC[] = "updateChannel";
|
2013-07-22 14:28:43 +04:00
|
|
|
static const char geometryC[] = "geometry";
|
2014-05-28 18:28:22 +04:00
|
|
|
static const char timeoutC[] = "timeout";
|
2016-01-15 15:16:52 +03:00
|
|
|
static const char chunkSizeC[] = "chunkSize";
|
2017-03-24 17:01:50 +03:00
|
|
|
static const char minChunkSizeC[] = "minChunkSize";
|
|
|
|
static const char maxChunkSizeC[] = "maxChunkSize";
|
|
|
|
static const char targetChunkUploadDurationC[] = "targetChunkUploadDuration";
|
2018-04-10 14:07:20 +03:00
|
|
|
static const char automaticLogDirC[] = "logToTemporaryLogDir";
|
2020-07-01 17:08:13 +03:00
|
|
|
static const char logDirC[] = "logDir";
|
2020-07-01 16:56:23 +03:00
|
|
|
static const char logDebugC[] = "logDebug";
|
2020-07-01 17:03:45 +03:00
|
|
|
static const char logExpireC[] = "logExpire";
|
2020-07-01 17:10:10 +03:00
|
|
|
static const char logFlushC[] = "logFlush";
|
2018-04-05 14:35:25 +03:00
|
|
|
static const char showExperimentalOptionsC[] = "showExperimentalOptions";
|
2018-05-14 15:37:48 +03:00
|
|
|
static const char clientVersionC[] = "clientVersion";
|
2013-07-19 18:27:54 +04:00
|
|
|
|
|
|
|
static const char proxyHostC[] = "Proxy/host";
|
|
|
|
static const char proxyTypeC[] = "Proxy/type";
|
|
|
|
static const char proxyPortC[] = "Proxy/port";
|
|
|
|
static const char proxyUserC[] = "Proxy/user";
|
|
|
|
static const char proxyPassC[] = "Proxy/pass";
|
|
|
|
static const char proxyNeedsAuthC[] = "Proxy/needsAuth";
|
|
|
|
|
2013-07-24 21:53:05 +04:00
|
|
|
static const char useUploadLimitC[] = "BWLimit/useUploadLimit";
|
|
|
|
static const char useDownloadLimitC[] = "BWLimit/useDownloadLimit";
|
|
|
|
static const char uploadLimitC[] = "BWLimit/uploadLimit";
|
|
|
|
static const char downloadLimitC[] = "BWLimit/downloadLimit";
|
|
|
|
|
2015-07-27 10:54:20 +03:00
|
|
|
static const char newBigFolderSizeLimitC[] = "newBigFolderSizeLimit";
|
|
|
|
static const char useNewBigFolderSizeLimitC[] = "useNewBigFolderSizeLimit";
|
2017-01-24 12:16:10 +03:00
|
|
|
static const char confirmExternalStorageC[] = "confirmExternalStorage";
|
2017-12-25 13:46:38 +03:00
|
|
|
static const char moveToTrashC[] = "moveToTrash";
|
2015-07-07 17:28:48 +03:00
|
|
|
|
2014-11-18 18:44:14 +03:00
|
|
|
const char certPath[] = "http_certificatePath";
|
|
|
|
const char certPasswd[] = "http_certificatePasswd";
|
2017-12-08 12:58:55 +03:00
|
|
|
QString ConfigFile::_confDir = QString();
|
2014-11-10 00:30:29 +03:00
|
|
|
bool ConfigFile::_askedUser = false;
|
2012-04-12 16:06:59 +04:00
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
static chrono::milliseconds millisecondsValue(const QSettings &setting, const char *key,
|
|
|
|
chrono::milliseconds defaultValue)
|
|
|
|
{
|
|
|
|
return chrono::milliseconds(setting.value(QLatin1String(key), qlonglong(defaultValue.count())).toLongLong());
|
2018-07-02 12:03:58 +03:00
|
|
|
}
|
2018-01-24 00:51:25 +03:00
|
|
|
|
2018-11-01 17:02:31 +03:00
|
|
|
bool copy_dir_recursive(QString from_dir, QString to_dir)
|
|
|
|
{
|
|
|
|
QDir dir;
|
|
|
|
dir.setPath(from_dir);
|
|
|
|
|
|
|
|
from_dir += QDir::separator();
|
|
|
|
to_dir += QDir::separator();
|
|
|
|
|
|
|
|
foreach (QString copy_file, dir.entryList(QDir::Files)) {
|
|
|
|
QString from = from_dir + copy_file;
|
|
|
|
QString to = to_dir + copy_file;
|
|
|
|
|
|
|
|
if (QFile::copy(from, to) == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QString copy_dir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
|
|
|
QString from = from_dir + copy_dir;
|
|
|
|
QString to = to_dir + copy_dir;
|
|
|
|
|
|
|
|
if (dir.mkpath(to) == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_dir_recursive(from, to) == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
ConfigFile::ConfigFile()
|
2012-02-17 14:11:18 +04:00
|
|
|
{
|
2014-08-05 02:34:24 +04:00
|
|
|
// QDesktopServices uses the application name to create a config path
|
|
|
|
qApp->setApplicationName(Theme::instance()->appNameGUI());
|
|
|
|
|
2013-07-19 18:27:54 +04:00
|
|
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
2013-07-29 16:28:19 +04:00
|
|
|
|
2013-10-30 19:31:47 +04:00
|
|
|
const QString config = configFile();
|
2013-11-14 18:48:46 +04:00
|
|
|
|
2013-08-08 15:03:49 +04:00
|
|
|
|
2013-10-30 19:31:47 +04:00
|
|
|
QSettings settings(config, QSettings::IniFormat);
|
|
|
|
settings.beginGroup(defaultConnection());
|
2012-02-17 14:11:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-23 16:59:29 +03:00
|
|
|
bool ConfigFile::setConfDir(const QString &value)
|
2013-01-14 03:48:26 +04:00
|
|
|
{
|
2013-08-15 15:01:05 +04:00
|
|
|
QString dirPath = value;
|
2015-03-23 16:59:29 +03:00
|
|
|
if (dirPath.isEmpty())
|
|
|
|
return false;
|
2013-08-15 15:01:05 +04:00
|
|
|
|
|
|
|
QFileInfo fi(dirPath);
|
2016-01-13 12:31:02 +03:00
|
|
|
if (!fi.exists()) {
|
|
|
|
QDir().mkpath(dirPath);
|
|
|
|
fi.setFile(dirPath);
|
2013-08-15 15:01:05 +04:00
|
|
|
}
|
2013-04-03 16:42:13 +04:00
|
|
|
if (fi.exists() && fi.isDir()) {
|
2013-08-15 15:09:20 +04:00
|
|
|
dirPath = fi.absoluteFilePath();
|
2017-03-30 14:46:20 +03:00
|
|
|
qCInfo(lcConfigFile) << "Using custom config dir " << dirPath;
|
2013-08-15 15:09:20 +04:00
|
|
|
_confDir = dirPath;
|
2015-03-23 16:59:29 +03:00
|
|
|
return true;
|
2013-04-03 16:42:13 +04:00
|
|
|
}
|
2015-03-23 16:59:29 +03:00
|
|
|
return false;
|
2013-01-14 03:48:26 +04:00
|
|
|
}
|
|
|
|
|
2018-02-15 22:21:08 +03:00
|
|
|
bool ConfigFile::optionalServerNotifications() const
|
2013-07-05 03:01:23 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2018-03-04 00:44:24 +03:00
|
|
|
return settings.value(QLatin1String(optionalServerNotificationsC), true).toBool();
|
2013-07-05 03:01:23 +04:00
|
|
|
}
|
|
|
|
|
2017-10-19 17:37:51 +03:00
|
|
|
bool ConfigFile::showInExplorerNavigationPane() const
|
|
|
|
{
|
|
|
|
const bool defaultValue =
|
|
|
|
#ifdef Q_OS_WIN
|
2019-09-08 18:33:34 +03:00
|
|
|
#if QTLEGACY
|
|
|
|
(QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS10);
|
2019-09-08 19:42:40 +03:00
|
|
|
#else
|
|
|
|
QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10;
|
2019-09-08 18:33:34 +03:00
|
|
|
#endif
|
2017-10-19 17:37:51 +03:00
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
return settings.value(QLatin1String(showInExplorerNavigationPaneC), defaultValue).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setShowInExplorerNavigationPane(bool show)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(showInExplorerNavigationPaneC), show);
|
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
int ConfigFile::timeout() const
|
2014-05-28 18:28:22 +04:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
return settings.value(QLatin1String(timeoutC), 300).toInt(); // default to 5 min
|
|
|
|
}
|
|
|
|
|
2019-02-13 12:15:33 +03:00
|
|
|
qint64 ConfigFile::chunkSize() const
|
2016-01-15 15:16:52 +03:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2016-02-24 18:02:17 +03:00
|
|
|
return settings.value(QLatin1String(chunkSizeC), 10 * 1000 * 1000).toLongLong(); // default to 10 MB
|
2016-01-15 15:16:52 +03:00
|
|
|
}
|
|
|
|
|
2019-02-13 12:15:33 +03:00
|
|
|
qint64 ConfigFile::maxChunkSize() const
|
2016-12-08 00:35:50 +03:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2021-05-13 22:20:38 +03:00
|
|
|
return settings.value(QLatin1String(maxChunkSizeC), 1000 * 1000 * 1000).toLongLong(); // default to 1000 MB
|
2016-12-08 00:35:50 +03:00
|
|
|
}
|
|
|
|
|
2019-02-13 12:15:33 +03:00
|
|
|
qint64 ConfigFile::minChunkSize() const
|
2016-12-08 00:35:50 +03:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2017-03-24 17:01:50 +03:00
|
|
|
return settings.value(QLatin1String(minChunkSizeC), 1000 * 1000).toLongLong(); // default to 1 MB
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
chrono::milliseconds ConfigFile::targetChunkUploadDuration() const
|
2017-03-24 17:01:50 +03:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2018-01-24 00:51:25 +03:00
|
|
|
return millisecondsValue(settings, targetChunkUploadDurationC, chrono::minutes(1));
|
2016-12-08 00:35:50 +03:00
|
|
|
}
|
|
|
|
|
2018-02-15 22:21:08 +03:00
|
|
|
void ConfigFile::setOptionalServerNotifications(bool show)
|
2013-07-05 03:01:23 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2018-02-15 22:21:08 +03:00
|
|
|
settings.setValue(QLatin1String(optionalServerNotificationsC), show);
|
2013-07-05 03:01:23 +04:00
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::saveGeometry(QWidget *w)
|
2013-07-22 14:28:43 +04:00
|
|
|
{
|
2014-04-06 21:34:56 +04:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2017-02-07 15:52:15 +03:00
|
|
|
ASSERT(!w->objectName().isNull());
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2013-07-22 14:28:43 +04:00
|
|
|
settings.beginGroup(w->objectName());
|
|
|
|
settings.setValue(QLatin1String(geometryC), w->saveGeometry());
|
|
|
|
settings.sync();
|
2014-04-06 21:34:56 +04:00
|
|
|
#endif
|
2013-07-22 14:28:43 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::restoreGeometry(QWidget *w)
|
2013-07-22 14:28:43 +04:00
|
|
|
{
|
2014-04-06 21:34:56 +04:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2013-07-22 14:28:43 +04:00
|
|
|
w->restoreGeometry(getValue(geometryC, w->objectName()).toByteArray());
|
2014-04-06 21:34:56 +04:00
|
|
|
#endif
|
2013-07-22 14:28:43 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::saveGeometryHeader(QHeaderView *header)
|
2013-12-12 18:16:19 +04:00
|
|
|
{
|
2014-04-06 21:34:56 +04:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2013-12-12 18:16:19 +04:00
|
|
|
if (!header)
|
|
|
|
return;
|
2017-02-07 15:52:15 +03:00
|
|
|
ASSERT(!header->objectName().isEmpty());
|
2013-12-12 18:16:19 +04:00
|
|
|
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(header->objectName());
|
|
|
|
settings.setValue(QLatin1String(geometryC), header->saveState());
|
|
|
|
settings.sync();
|
2014-04-06 21:34:56 +04:00
|
|
|
#endif
|
2013-12-12 18:16:19 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::restoreGeometryHeader(QHeaderView *header)
|
2013-12-12 18:16:19 +04:00
|
|
|
{
|
2014-04-06 21:34:56 +04:00
|
|
|
#ifndef TOKEN_AUTH_ONLY
|
2013-12-12 18:16:19 +04:00
|
|
|
if (!header)
|
|
|
|
return;
|
2017-02-07 15:52:15 +03:00
|
|
|
ASSERT(!header->objectName().isNull());
|
2013-12-12 18:16:19 +04:00
|
|
|
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(header->objectName());
|
2015-03-23 20:22:12 +03:00
|
|
|
header->restoreState(settings.value(geometryC).toByteArray());
|
2014-04-06 21:34:56 +04:00
|
|
|
#endif
|
2013-12-12 18:16:19 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QVariant ConfigFile::getPolicySetting(const QString &setting, const QVariant &defaultValue) const
|
2014-02-12 15:17:32 +04:00
|
|
|
{
|
|
|
|
if (Utility::isWindows()) {
|
|
|
|
// check for policies first and return immediately if a value is found.
|
2020-05-26 21:13:51 +03:00
|
|
|
QSettings userPolicy(QString::fromLatin1(R"(HKEY_CURRENT_USER\Software\Policies\%1\%2)")
|
2019-01-09 18:00:33 +03:00
|
|
|
.arg(APPLICATION_VENDOR, Theme::instance()->appNameGUI()),
|
2014-02-12 15:17:32 +04:00
|
|
|
QSettings::NativeFormat);
|
|
|
|
if (userPolicy.contains(setting)) {
|
|
|
|
return userPolicy.value(setting);
|
|
|
|
}
|
|
|
|
|
2020-05-26 21:13:51 +03:00
|
|
|
QSettings machinePolicy(QString::fromLatin1(R"(HKEY_LOCAL_MACHINE\Software\Policies\%1\%2)")
|
2019-01-09 18:00:33 +03:00
|
|
|
.arg(APPLICATION_VENDOR, Theme::instance()->appNameGUI()),
|
2014-02-12 15:17:32 +04:00
|
|
|
QSettings::NativeFormat);
|
|
|
|
if (machinePolicy.contains(setting)) {
|
|
|
|
return machinePolicy.value(setting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return defaultValue;
|
|
|
|
}
|
2013-12-12 18:16:19 +04:00
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::configPath() const
|
2012-03-28 13:26:51 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
if (_confDir.isEmpty()) {
|
2018-11-01 17:02:31 +03:00
|
|
|
if (!Utility::isWindows()) {
|
|
|
|
// On Unix, use the AppConfigLocation for the settings, that's configurable with the XDG_CONFIG_HOME env variable.
|
|
|
|
_confDir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
|
|
|
} else {
|
|
|
|
// On Windows, use AppDataLocation, that's where the roaming data is and where we should store the config file
|
|
|
|
auto newLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
|
|
|
|
|
|
// Check if this is the first time loading the new location
|
|
|
|
if (!QFileInfo(newLocation).isDir()) {
|
|
|
|
// Migrate data to the new locations
|
|
|
|
auto oldLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
|
|
|
|
|
|
|
// Only migrate if the old location exists.
|
|
|
|
if (QFileInfo(oldLocation).isDir()) {
|
|
|
|
QDir().mkpath(newLocation);
|
|
|
|
copy_dir_recursive(oldLocation, newLocation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_confDir = newLocation;
|
|
|
|
}
|
2013-07-29 16:28:19 +04:00
|
|
|
}
|
|
|
|
QString dir = _confDir;
|
2013-04-04 17:19:23 +04:00
|
|
|
|
2012-08-17 19:13:17 +04:00
|
|
|
if (!dir.endsWith(QLatin1Char('/')))
|
|
|
|
dir.append(QLatin1Char('/'));
|
2012-03-28 13:26:51 +04:00
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2014-10-17 17:58:01 +04:00
|
|
|
static const QLatin1String exclFile("sync-exclude.lst");
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::excludeFile(Scope scope) const
|
2012-03-28 14:23:34 +04:00
|
|
|
{
|
2012-09-27 15:16:14 +04:00
|
|
|
// prefer sync-exclude.lst, but if it does not exist, check for
|
2013-07-05 18:54:11 +04:00
|
|
|
// exclude.lst for compatibility reasons in the user writeable
|
2012-09-27 15:16:14 +04:00
|
|
|
// directories.
|
2014-11-18 18:44:14 +03:00
|
|
|
QFileInfo fi;
|
2012-09-27 15:16:14 +04:00
|
|
|
|
2017-02-07 15:52:15 +03:00
|
|
|
switch (scope) {
|
|
|
|
case UserScope:
|
2013-07-05 18:54:11 +04:00
|
|
|
fi.setFile(configPath(), exclFile);
|
|
|
|
|
|
|
|
if (!fi.isReadable()) {
|
|
|
|
fi.setFile(configPath(), QLatin1String("exclude.lst"));
|
|
|
|
}
|
|
|
|
if (!fi.isReadable()) {
|
|
|
|
fi.setFile(configPath(), exclFile);
|
|
|
|
}
|
2014-10-17 17:58:01 +04:00
|
|
|
return fi.absoluteFilePath();
|
2017-02-07 15:52:15 +03:00
|
|
|
case SystemScope:
|
2014-11-10 00:30:29 +03:00
|
|
|
return ConfigFile::excludeFileFromSystem();
|
2012-03-28 14:23:34 +04:00
|
|
|
}
|
2017-02-07 15:52:15 +03:00
|
|
|
|
|
|
|
ASSERT(false);
|
|
|
|
return QString();
|
2014-10-17 17:58:01 +04:00
|
|
|
}
|
2012-08-17 19:00:03 +04:00
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::excludeFileFromSystem()
|
2014-10-17 17:58:01 +04:00
|
|
|
{
|
|
|
|
QFileInfo fi;
|
2013-07-19 18:27:54 +04:00
|
|
|
#ifdef Q_OS_WIN
|
2014-10-17 17:58:01 +04:00
|
|
|
fi.setFile(QCoreApplication::applicationDirPath(), exclFile);
|
2012-05-16 16:55:19 +04:00
|
|
|
#endif
|
2013-07-19 18:27:54 +04:00
|
|
|
#ifdef Q_OS_UNIX
|
2017-02-23 16:54:17 +03:00
|
|
|
fi.setFile(QString(SYSCONFDIR "/" + Theme::instance()->appName()), exclFile);
|
2014-10-17 17:58:01 +04:00
|
|
|
if (!fi.exists()) {
|
|
|
|
// Prefer to return the preferred path! Only use the fallback location
|
|
|
|
// if the other path does not exist and the fallback is valid.
|
|
|
|
QFileInfo nextToBinary(QCoreApplication::applicationDirPath(), exclFile);
|
|
|
|
if (nextToBinary.exists()) {
|
|
|
|
fi = nextToBinary;
|
2017-11-22 21:10:37 +03:00
|
|
|
} else {
|
|
|
|
// For AppImage, the file might reside under a temporary mount path
|
|
|
|
QDir d(QCoreApplication::applicationDirPath()); // supposed to be /tmp/mount.xyz/usr/bin
|
|
|
|
d.cdUp(); // go out of bin
|
|
|
|
d.cdUp(); // go out of usr
|
|
|
|
if (!d.isRoot()) { // it is really a mountpoint
|
|
|
|
if (d.cd("etc") && d.cd(Theme::instance()->appName())) {
|
|
|
|
QFileInfo inMountDir(d, exclFile);
|
|
|
|
if (inMountDir.exists()) {
|
|
|
|
fi = inMountDir;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2014-10-17 17:58:01 +04:00
|
|
|
}
|
|
|
|
}
|
2012-05-16 16:55:19 +04:00
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_MAC
|
2014-10-17 17:58:01 +04:00
|
|
|
// exec path is inside the bundle
|
|
|
|
fi.setFile(QCoreApplication::applicationDirPath(),
|
|
|
|
QLatin1String("../Resources/") + exclFile);
|
2012-04-01 17:09:04 +04:00
|
|
|
#endif
|
2017-05-17 11:55:42 +03:00
|
|
|
|
2013-07-05 18:54:11 +04:00
|
|
|
return fi.absoluteFilePath();
|
2012-03-28 14:23:34 +04:00
|
|
|
}
|
|
|
|
|
2018-05-02 16:40:54 +03:00
|
|
|
QString ConfigFile::backup() const
|
|
|
|
{
|
|
|
|
QString baseFile = configFile();
|
2018-05-14 15:37:48 +03:00
|
|
|
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);
|
2018-05-02 16:40:54 +03:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::configFile() const
|
2012-02-17 14:11:18 +04:00
|
|
|
{
|
2013-10-30 19:31:47 +04:00
|
|
|
return configPath() + Theme::instance()->configFileName();
|
2012-02-17 14:11:18 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
bool ConfigFile::exists()
|
2012-02-17 14:11:18 +04:00
|
|
|
{
|
2012-03-28 14:23:34 +04:00
|
|
|
QFile file(configFile());
|
2012-02-17 14:11:18 +04:00
|
|
|
return file.exists();
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::defaultConnection() const
|
2012-02-18 20:02:10 +04:00
|
|
|
{
|
2012-09-26 18:53:56 +04:00
|
|
|
return Theme::instance()->appName();
|
2012-02-18 20:02:10 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::storeData(const QString &group, const QString &key, const QVariant &value)
|
2012-12-04 20:27:59 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
const QString con(group.isEmpty() ? defaultConnection() : group);
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2012-12-04 20:27:59 +04:00
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
settings.beginGroup(con);
|
|
|
|
settings.setValue(key, value);
|
2012-12-04 20:27:59 +04:00
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QVariant ConfigFile::retrieveData(const QString &group, const QString &key) const
|
2012-12-11 18:07:44 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
const QString con(group.isEmpty() ? defaultConnection() : group);
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2012-12-11 18:07:44 +04:00
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
settings.beginGroup(con);
|
|
|
|
return settings.value(key);
|
|
|
|
}
|
2012-12-11 18:07:44 +04:00
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::removeData(const QString &group, const QString &key)
|
2013-07-29 16:28:19 +04:00
|
|
|
{
|
|
|
|
const QString con(group.isEmpty() ? defaultConnection() : group);
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2012-12-28 16:41:26 +04:00
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
settings.beginGroup(con);
|
|
|
|
settings.remove(key);
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
bool ConfigFile::dataExists(const QString &group, const QString &key) const
|
2013-07-29 16:28:19 +04:00
|
|
|
{
|
|
|
|
const QString con(group.isEmpty() ? defaultConnection() : group);
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
|
|
|
|
settings.beginGroup(con);
|
|
|
|
return settings.contains(key);
|
2012-12-11 18:07:44 +04:00
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
chrono::milliseconds ConfigFile::remotePollInterval(const QString &connection) const
|
2012-05-26 16:37:21 +04:00
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2012-05-26 16:37:21 +04:00
|
|
|
settings.beginGroup(con);
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
auto defaultPollInterval = chrono::milliseconds(DEFAULT_REMOTE_POLL_INTERVAL);
|
|
|
|
auto remoteInterval = millisecondsValue(settings, remotePollIntervalC, defaultPollInterval);
|
|
|
|
if (remoteInterval < chrono::seconds(5)) {
|
2017-03-30 14:46:20 +03:00
|
|
|
qCWarning(lcConfigFile) << "Remote Interval is less than 5 seconds, reverting to" << DEFAULT_REMOTE_POLL_INTERVAL;
|
2018-01-24 00:51:25 +03:00
|
|
|
remoteInterval = defaultPollInterval;
|
2012-05-26 16:37:21 +04:00
|
|
|
}
|
|
|
|
return remoteInterval;
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
void ConfigFile::setRemotePollInterval(chrono::milliseconds interval, const QString &connection)
|
2013-02-10 14:27:21 +04:00
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
if (interval < chrono::seconds(5)) {
|
|
|
|
qCWarning(lcConfigFile) << "Remote Poll interval of " << interval.count() << " is below five seconds.";
|
2013-02-10 14:27:21 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2013-02-10 14:27:21 +04:00
|
|
|
settings.beginGroup(con);
|
2018-01-24 00:51:25 +03:00
|
|
|
settings.setValue(QLatin1String(remotePollIntervalC), qlonglong(interval.count()));
|
2013-02-10 14:27:21 +04:00
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
chrono::milliseconds ConfigFile::forceSyncInterval(const QString &connection) const
|
2013-08-08 16:30:45 +04:00
|
|
|
{
|
2018-01-24 00:51:25 +03:00
|
|
|
auto pollInterval = remotePollInterval(connection);
|
2013-08-08 16:30:45 +04:00
|
|
|
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(con);
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
auto defaultInterval = chrono::hours(2);
|
|
|
|
auto interval = millisecondsValue(settings, forceSyncIntervalC, defaultInterval);
|
2013-08-08 16:30:45 +04:00
|
|
|
if (interval < pollInterval) {
|
2018-01-24 00:51:25 +03:00
|
|
|
qCWarning(lcConfigFile) << "Force sync interval is less than the remote poll inteval, reverting to" << pollInterval.count();
|
2013-08-08 16:30:45 +04:00
|
|
|
interval = pollInterval;
|
|
|
|
}
|
|
|
|
return interval;
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
chrono::milliseconds OCC::ConfigFile::fullLocalDiscoveryInterval() const
|
2017-09-14 17:43:23 +03:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(defaultConnection());
|
2018-01-24 00:51:25 +03:00
|
|
|
return millisecondsValue(settings, fullLocalDiscoveryIntervalC, chrono::hours(1));
|
2017-09-14 17:43:23 +03:00
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
chrono::milliseconds ConfigFile::notificationRefreshInterval(const QString &connection) const
|
2016-03-18 18:23:21 +03:00
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(con);
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
auto defaultInterval = chrono::minutes(5);
|
|
|
|
auto interval = millisecondsValue(settings, notificationRefreshIntervalC, defaultInterval);
|
|
|
|
if (interval < chrono::minutes(1)) {
|
2017-03-30 14:46:20 +03:00
|
|
|
qCWarning(lcConfigFile) << "Notification refresh interval smaller than one minute, setting to one minute";
|
2018-01-24 00:51:25 +03:00
|
|
|
interval = chrono::minutes(1);
|
2016-03-18 18:23:21 +03:00
|
|
|
}
|
|
|
|
return interval;
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
chrono::milliseconds ConfigFile::updateCheckInterval(const QString &connection) const
|
2015-06-15 13:24:18 +03:00
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(con);
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
auto defaultInterval = chrono::hours(10);
|
|
|
|
auto interval = millisecondsValue(settings, updateCheckIntervalC, defaultInterval);
|
2015-06-15 13:24:18 +03:00
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
auto minInterval = chrono::minutes(5);
|
2015-06-15 13:24:18 +03:00
|
|
|
if (interval < minInterval) {
|
2018-01-24 00:51:25 +03:00
|
|
|
qCWarning(lcConfigFile) << "Update check interval less than five minutes, resetting to 5 minutes";
|
2015-06-15 13:24:18 +03:00
|
|
|
interval = minInterval;
|
|
|
|
}
|
|
|
|
return interval;
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
bool ConfigFile::skipUpdateCheck(const QString &connection) const
|
2012-04-02 22:10:29 +04:00
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
|
2014-02-12 15:17:32 +04:00
|
|
|
QVariant fallback = getValue(QLatin1String(skipUpdateCheckC), con, false);
|
|
|
|
fallback = getValue(QLatin1String(skipUpdateCheckC), QString(), fallback);
|
2012-04-02 22:10:29 +04:00
|
|
|
|
2014-02-12 15:17:32 +04:00
|
|
|
QVariant value = getPolicySetting(QLatin1String(skipUpdateCheckC), fallback);
|
|
|
|
return value.toBool();
|
2012-04-02 22:10:29 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setSkipUpdateCheck(bool skip, const QString &connection)
|
2013-02-18 19:17:03 +04:00
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2013-02-18 19:17:03 +04:00
|
|
|
settings.beginGroup(con);
|
|
|
|
|
2013-07-19 18:27:54 +04:00
|
|
|
settings.setValue(QLatin1String(skipUpdateCheckC), QVariant(skip));
|
2013-02-18 19:17:03 +04:00
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2020-03-09 03:17:02 +03:00
|
|
|
bool ConfigFile::autoUpdateCheck(const QString &connection) const
|
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
|
|
|
|
QVariant fallback = getValue(QLatin1String(autoUpdateCheckC), con, true);
|
|
|
|
fallback = getValue(QLatin1String(autoUpdateCheckC), QString(), fallback);
|
|
|
|
|
|
|
|
QVariant value = getPolicySetting(QLatin1String(autoUpdateCheckC), fallback);
|
|
|
|
return value.toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setAutoUpdateCheck(bool autoCheck, const QString &connection)
|
|
|
|
{
|
|
|
|
QString con(connection);
|
|
|
|
if (connection.isEmpty())
|
|
|
|
con = defaultConnection();
|
|
|
|
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.beginGroup(con);
|
|
|
|
|
|
|
|
settings.setValue(QLatin1String(autoUpdateCheckC), QVariant(autoCheck));
|
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2020-02-21 23:28:42 +03:00
|
|
|
int ConfigFile::updateSegment() const
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
int segment = settings.value(QLatin1String(updateSegmentC), -1).toInt();
|
|
|
|
|
|
|
|
// Invalid? (Unset at the very first launch)
|
|
|
|
if(segment < 0 || segment > 99) {
|
|
|
|
// Save valid segment value, normally has to be done only once.
|
2021-09-03 22:37:46 +03:00
|
|
|
segment = Utility::rand() % 99;
|
2020-02-21 23:28:42 +03:00
|
|
|
settings.setValue(QLatin1String(updateSegmentC), segment);
|
|
|
|
}
|
|
|
|
|
|
|
|
return segment;
|
|
|
|
}
|
|
|
|
|
2018-04-26 12:24:30 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setProxyType(int proxyType,
|
2012-07-31 12:17:52 +04:00
|
|
|
const QString &host,
|
2013-05-29 14:56:23 +04:00
|
|
|
int port, bool needsAuth,
|
2012-07-31 12:17:52 +04:00
|
|
|
const QString &user,
|
|
|
|
const QString &pass)
|
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2013-07-19 18:27:54 +04:00
|
|
|
settings.setValue(QLatin1String(proxyTypeC), proxyType);
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2013-05-29 04:14:40 +04:00
|
|
|
if (proxyType == QNetworkProxy::HttpProxy || proxyType == QNetworkProxy::Socks5Proxy) {
|
2013-07-19 18:27:54 +04:00
|
|
|
settings.setValue(QLatin1String(proxyHostC), host);
|
|
|
|
settings.setValue(QLatin1String(proxyPortC), port);
|
|
|
|
settings.setValue(QLatin1String(proxyNeedsAuthC), needsAuth);
|
|
|
|
settings.setValue(QLatin1String(proxyUserC), user);
|
2020-06-25 17:59:57 +03:00
|
|
|
|
|
|
|
if (pass.isEmpty()) {
|
2020-06-27 05:53:37 +03:00
|
|
|
// Security: Don't keep password in config file
|
2020-06-25 17:59:57 +03:00
|
|
|
settings.remove(QLatin1String(proxyPassC));
|
|
|
|
|
2020-06-27 05:53:37 +03:00
|
|
|
// Delete password from keychain
|
2020-06-30 17:00:29 +03:00
|
|
|
auto job = new KeychainChunk::DeleteJob(keychainProxyPasswordKey());
|
2020-06-27 05:53:37 +03:00
|
|
|
job->exec();
|
2020-06-25 17:59:57 +03:00
|
|
|
} else {
|
|
|
|
// Write password to keychain
|
2020-06-30 17:00:29 +03:00
|
|
|
auto job = new KeychainChunk::WriteJob(keychainProxyPasswordKey(), pass.toUtf8());
|
2020-06-27 05:53:37 +03:00
|
|
|
if (job->exec()) {
|
|
|
|
// Security: Don't keep password in config file
|
2020-06-25 17:59:57 +03:00
|
|
|
settings.remove(QLatin1String(proxyPassC));
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 03:41:04 +04:00
|
|
|
}
|
2012-07-31 12:17:52 +04:00
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QVariant ConfigFile::getValue(const QString ¶m, const QString &group,
|
2013-07-24 21:53:05 +04:00
|
|
|
const QVariant &defaultValue) const
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
2014-02-12 15:17:32 +04:00
|
|
|
QVariant systemSetting;
|
|
|
|
if (Utility::isMac()) {
|
2014-02-13 15:52:57 +04:00
|
|
|
QSettings systemSettings(QLatin1String("/Library/Preferences/" APPLICATION_REV_DOMAIN ".plist"), QSettings::NativeFormat);
|
2014-02-12 15:17:32 +04:00
|
|
|
if (!group.isEmpty()) {
|
|
|
|
systemSettings.beginGroup(group);
|
|
|
|
}
|
|
|
|
systemSetting = systemSettings.value(param, defaultValue);
|
|
|
|
} else if (Utility::isUnix()) {
|
|
|
|
QSettings systemSettings(QString(SYSCONFDIR "/%1/%1.conf").arg(Theme::instance()->appName()), QSettings::NativeFormat);
|
|
|
|
if (!group.isEmpty()) {
|
|
|
|
systemSettings.beginGroup(group);
|
|
|
|
}
|
|
|
|
systemSetting = systemSettings.value(param, defaultValue);
|
|
|
|
} else { // Windows
|
2020-05-26 21:13:51 +03:00
|
|
|
QSettings systemSettings(QString::fromLatin1(R"(HKEY_LOCAL_MACHINE\Software\%1\%2)")
|
2019-01-09 18:00:33 +03:00
|
|
|
.arg(APPLICATION_VENDOR, Theme::instance()->appNameGUI()),
|
2017-02-23 16:54:17 +03:00
|
|
|
QSettings::NativeFormat);
|
2014-02-12 15:17:32 +04:00
|
|
|
if (!group.isEmpty()) {
|
|
|
|
systemSettings.beginGroup(group);
|
|
|
|
}
|
|
|
|
systemSetting = systemSettings.value(param, defaultValue);
|
|
|
|
}
|
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2014-02-12 15:17:32 +04:00
|
|
|
if (!group.isEmpty())
|
|
|
|
settings.beginGroup(group);
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2014-02-12 15:17:32 +04:00
|
|
|
return settings.value(param, systemSetting);
|
2013-07-24 21:53:05 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setValue(const QString &key, const QVariant &value)
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2013-07-24 21:53:05 +04:00
|
|
|
|
|
|
|
settings.setValue(key, value);
|
2012-07-31 12:17:52 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
int ConfigFile::proxyType() const
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
2016-03-11 18:21:40 +03:00
|
|
|
if (Theme::instance()->forceSystemNetworkProxy()) {
|
|
|
|
return QNetworkProxy::DefaultProxy;
|
|
|
|
}
|
2013-07-19 18:27:54 +04:00
|
|
|
return getValue(QLatin1String(proxyTypeC)).toInt();
|
2012-07-31 12:17:52 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::proxyHostName() const
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
2013-07-19 18:27:54 +04:00
|
|
|
return getValue(QLatin1String(proxyHostC)).toString();
|
2012-07-31 12:17:52 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
int ConfigFile::proxyPort() const
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
2013-07-19 18:27:54 +04:00
|
|
|
return getValue(QLatin1String(proxyPortC)).toInt();
|
2012-02-17 14:11:18 +04:00
|
|
|
}
|
2012-06-12 14:27:02 +04:00
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
bool ConfigFile::proxyNeedsAuth() const
|
2013-05-29 14:56:23 +04:00
|
|
|
{
|
2013-07-19 18:27:54 +04:00
|
|
|
return getValue(QLatin1String(proxyNeedsAuthC)).toBool();
|
2013-05-29 14:56:23 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::proxyUser() const
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
2013-07-19 18:27:54 +04:00
|
|
|
return getValue(QLatin1String(proxyUserC)).toString();
|
2012-07-31 12:17:52 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
QString ConfigFile::proxyPassword() const
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
2020-06-25 17:59:57 +03:00
|
|
|
QByteArray passEncoded = getValue(proxyPassC).toByteArray();
|
|
|
|
auto pass = QString::fromUtf8(QByteArray::fromBase64(passEncoded));
|
|
|
|
passEncoded.clear();
|
|
|
|
|
|
|
|
const auto key = keychainProxyPasswordKey();
|
|
|
|
|
|
|
|
if (!pass.isEmpty()) {
|
|
|
|
// Security: Migrate password from config file to keychain
|
2020-06-30 17:00:29 +03:00
|
|
|
auto job = new KeychainChunk::WriteJob(key, pass.toUtf8());
|
2020-06-27 05:53:37 +03:00
|
|
|
if (job->exec()) {
|
2020-06-25 17:59:57 +03:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.remove(QLatin1String(proxyPassC));
|
2020-06-27 05:53:37 +03:00
|
|
|
qCInfo(lcConfigFile()) << "Migrated proxy password to keychain";
|
2020-06-25 17:59:57 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Read password from keychain
|
2020-06-30 17:00:29 +03:00
|
|
|
auto job = new KeychainChunk::ReadJob(key);
|
2020-06-27 05:53:37 +03:00
|
|
|
if (job->exec()) {
|
2020-06-25 17:59:57 +03:00
|
|
|
pass = job->textData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConfigFile::keychainProxyPasswordKey() const
|
|
|
|
{
|
|
|
|
return QString::fromLatin1("proxy-password");
|
2012-07-31 12:17:52 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
int ConfigFile::useUploadLimit() const
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
2017-12-08 12:58:55 +03:00
|
|
|
return getValue(useUploadLimitC, QString(), 0).toInt();
|
2013-07-24 21:53:05 +04:00
|
|
|
}
|
|
|
|
|
2015-06-29 18:43:25 +03:00
|
|
|
int ConfigFile::useDownloadLimit() const
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
2017-12-08 12:58:55 +03:00
|
|
|
return getValue(useDownloadLimitC, QString(), 0).toInt();
|
2013-07-24 21:53:05 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setUseUploadLimit(int val)
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
|
|
|
setValue(useUploadLimitC, val);
|
|
|
|
}
|
|
|
|
|
2015-06-29 18:43:25 +03:00
|
|
|
void ConfigFile::setUseDownloadLimit(int val)
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
2015-06-29 18:43:25 +03:00
|
|
|
setValue(useDownloadLimitC, val);
|
2013-07-24 21:53:05 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
int ConfigFile::uploadLimit() const
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
2017-12-08 12:58:55 +03:00
|
|
|
return getValue(uploadLimitC, QString(), 10).toInt();
|
2013-07-24 21:53:05 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
int ConfigFile::downloadLimit() const
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
2017-12-08 12:58:55 +03:00
|
|
|
return getValue(downloadLimitC, QString(), 80).toInt();
|
2013-07-24 21:53:05 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setUploadLimit(int kbytes)
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
|
|
|
setValue(uploadLimitC, kbytes);
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setDownloadLimit(int kbytes)
|
2013-07-24 21:53:05 +04:00
|
|
|
{
|
|
|
|
setValue(downloadLimitC, kbytes);
|
|
|
|
}
|
|
|
|
|
2019-02-13 12:15:33 +03:00
|
|
|
QPair<bool, qint64> ConfigFile::newBigFolderSizeLimit() const
|
2015-07-07 17:28:48 +03:00
|
|
|
{
|
2015-08-05 16:33:38 +03:00
|
|
|
auto defaultValue = Theme::instance()->newBigFolderSizeLimit();
|
2021-02-12 14:23:40 +03:00
|
|
|
const auto fallback = getValue(newBigFolderSizeLimitC, QString(), defaultValue).toLongLong();
|
|
|
|
const auto value = getPolicySetting(QLatin1String(newBigFolderSizeLimitC), fallback).toLongLong();
|
|
|
|
const bool use = value >= 0 && useNewBigFolderSizeLimit();
|
2019-02-13 12:15:33 +03:00
|
|
|
return qMakePair(use, qMax<qint64>(0, value));
|
2015-07-07 17:28:48 +03:00
|
|
|
}
|
|
|
|
|
2019-02-13 12:15:33 +03:00
|
|
|
void ConfigFile::setNewBigFolderSizeLimit(bool isChecked, qint64 mbytes)
|
2015-07-07 17:28:48 +03:00
|
|
|
{
|
2015-07-27 10:54:20 +03:00
|
|
|
setValue(newBigFolderSizeLimitC, mbytes);
|
|
|
|
setValue(useNewBigFolderSizeLimitC, isChecked);
|
2015-07-07 17:28:48 +03:00
|
|
|
}
|
|
|
|
|
2017-01-24 12:16:10 +03:00
|
|
|
bool ConfigFile::confirmExternalStorage() const
|
|
|
|
{
|
2021-02-12 14:23:40 +03:00
|
|
|
const auto fallback = getValue(confirmExternalStorageC, QString(), true);
|
|
|
|
return getPolicySetting(QLatin1String(confirmExternalStorageC), fallback).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigFile::useNewBigFolderSizeLimit() const
|
|
|
|
{
|
|
|
|
const auto fallback = getValue(useNewBigFolderSizeLimitC, QString(), true);
|
|
|
|
return getPolicySetting(QLatin1String(useNewBigFolderSizeLimitC), fallback).toBool();
|
2017-01-24 12:16:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setConfirmExternalStorage(bool isChecked)
|
|
|
|
{
|
|
|
|
setValue(confirmExternalStorageC, isChecked);
|
|
|
|
}
|
|
|
|
|
2017-12-25 13:46:38 +03:00
|
|
|
bool ConfigFile::moveToTrash() const
|
|
|
|
{
|
|
|
|
return getValue(moveToTrashC, QString(), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setMoveToTrash(bool isChecked)
|
|
|
|
{
|
|
|
|
setValue(moveToTrashC, isChecked);
|
|
|
|
}
|
|
|
|
|
2021-06-21 14:33:22 +03:00
|
|
|
bool ConfigFile::showMainDialogAsNormalWindow() const {
|
|
|
|
return getValue(showMainDialogAsNormalWindowC, {}, false).toBool();
|
|
|
|
}
|
|
|
|
|
2016-01-24 21:45:12 +03:00
|
|
|
bool ConfigFile::promptDeleteFiles() const
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2019-04-12 13:11:43 +03:00
|
|
|
return settings.value(QLatin1String(promptDeleteC), false).toBool();
|
2016-01-24 21:45:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setPromptDeleteFiles(bool promptDeleteFiles)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(promptDeleteC), promptDeleteFiles);
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
bool ConfigFile::monoIcons() const
|
2013-07-04 21:59:40 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2021-01-20 17:16:13 +03:00
|
|
|
bool monoDefault = false; // On Mac we want bw by default
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
// OEM themes are not obliged to ship mono icons
|
2021-01-20 17:16:59 +03:00
|
|
|
monoDefault = QByteArrayLiteral("Nextcloud") == QByteArrayLiteral(APPLICATION_NAME);
|
2016-10-14 15:26:31 +03:00
|
|
|
#endif
|
|
|
|
return settings.value(QLatin1String(monoIconsC), monoDefault).toBool();
|
2013-07-04 21:59:40 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 00:30:29 +03:00
|
|
|
void ConfigFile::setMonoIcons(bool useMonoIcons)
|
2013-07-04 21:59:40 +04:00
|
|
|
{
|
2013-07-29 16:28:19 +04:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2013-07-19 18:27:54 +04:00
|
|
|
settings.setValue(QLatin1String(monoIconsC), useMonoIcons);
|
2013-07-04 21:59:40 +04:00
|
|
|
}
|
|
|
|
|
2014-12-02 16:20:13 +03:00
|
|
|
bool ConfigFile::crashReporter() const
|
2014-08-28 18:19:17 +04:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2021-02-12 14:23:40 +03:00
|
|
|
const auto fallback = settings.value(QLatin1String(crashReporterC), true);
|
|
|
|
return getPolicySetting(QLatin1String(crashReporterC), fallback).toBool();
|
2014-08-28 18:19:17 +04:00
|
|
|
}
|
|
|
|
|
2014-12-02 16:20:13 +03:00
|
|
|
void ConfigFile::setCrashReporter(bool enabled)
|
2014-08-28 18:19:17 +04:00
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(crashReporterC), enabled);
|
|
|
|
}
|
|
|
|
|
2018-04-10 14:07:20 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-07-01 17:08:13 +03:00
|
|
|
QString ConfigFile::logDir() const
|
|
|
|
{
|
2020-10-05 18:48:30 +03:00
|
|
|
const auto defaultLogDir = QString(configPath() + QStringLiteral("/logs"));
|
2020-07-01 17:08:13 +03:00
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2020-10-05 18:48:30 +03:00
|
|
|
return settings.value(QLatin1String(logDirC), defaultLogDir).toString();
|
2020-07-01 17:08:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setLogDir(const QString &dir)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(logDirC), dir);
|
|
|
|
}
|
|
|
|
|
2020-07-01 16:56:23 +03:00
|
|
|
bool ConfigFile::logDebug() const
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2020-10-05 18:48:30 +03:00
|
|
|
return settings.value(QLatin1String(logDebugC), true).toBool();
|
2020-07-01 16:56:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setLogDebug(bool enabled)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(logDebugC), enabled);
|
|
|
|
}
|
|
|
|
|
2020-07-01 17:03:45 +03:00
|
|
|
int ConfigFile::logExpire() const
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
2021-03-12 11:23:31 +03:00
|
|
|
return settings.value(QLatin1String(logExpireC), 24).toInt();
|
2020-07-01 17:03:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setLogExpire(int hours)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(logExpireC), hours);
|
|
|
|
}
|
|
|
|
|
2020-07-01 17:10:10 +03:00
|
|
|
bool ConfigFile::logFlush() const
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
return settings.value(QLatin1String(logFlushC), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setLogFlush(bool enabled)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(logFlushC), enabled);
|
|
|
|
}
|
|
|
|
|
2018-04-05 14:35:25 +03:00
|
|
|
bool ConfigFile::showExperimentalOptions() const
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
return settings.value(QLatin1String(showExperimentalOptionsC), false).toBool();
|
|
|
|
}
|
|
|
|
|
2014-11-18 18:44:14 +03:00
|
|
|
QString ConfigFile::certificatePath() const
|
|
|
|
{
|
|
|
|
return retrieveData(QString(), QLatin1String(certPath)).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setCertificatePath(const QString &cPath)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(certPath), cPath);
|
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConfigFile::certificatePasswd() const
|
|
|
|
{
|
|
|
|
return retrieveData(QString(), QLatin1String(certPasswd)).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigFile::setCertificatePasswd(const QString &cPasswd)
|
|
|
|
{
|
|
|
|
QSettings settings(configFile(), QSettings::IniFormat);
|
|
|
|
settings.setValue(QLatin1String(certPasswd), cPasswd);
|
|
|
|
settings.sync();
|
|
|
|
}
|
2017-08-16 09:36:52 +03:00
|
|
|
|
2018-05-14 15:37:48 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-08-16 09:36:52 +03:00
|
|
|
Q_GLOBAL_STATIC(QString, g_configFileName)
|
|
|
|
|
|
|
|
std::unique_ptr<QSettings> ConfigFile::settingsWithGroup(const QString &group, QObject *parent)
|
|
|
|
{
|
|
|
|
if (g_configFileName()->isEmpty()) {
|
|
|
|
// cache file name
|
|
|
|
ConfigFile cfg;
|
|
|
|
*g_configFileName() = cfg.configFile();
|
|
|
|
}
|
|
|
|
std::unique_ptr<QSettings> settings(new QSettings(*g_configFileName(), QSettings::IniFormat, parent));
|
|
|
|
settings->beginGroup(group);
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
2017-11-29 14:04:01 +03:00
|
|
|
void ConfigFile::setupDefaultExcludeFilePaths(ExcludedFiles &excludedFiles)
|
|
|
|
{
|
|
|
|
ConfigFile cfg;
|
|
|
|
QString systemList = cfg.excludeFile(ConfigFile::SystemScope);
|
|
|
|
QString userList = cfg.excludeFile(ConfigFile::UserScope);
|
2018-11-19 17:35:32 +03:00
|
|
|
|
|
|
|
if (!QFile::exists(userList)) {
|
|
|
|
qCInfo(lcConfigFile) << "User defined ignore list does not exist:" << userList;
|
|
|
|
if (!QFile::copy(systemList, userList)) {
|
|
|
|
qCInfo(lcConfigFile) << "Could not copy over default list to:" << userList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!QFile::exists(userList)) {
|
|
|
|
qCInfo(lcConfigFile) << "Adding system ignore list to csync:" << systemList;
|
|
|
|
excludedFiles.addExcludeFilePath(systemList);
|
|
|
|
} else {
|
2017-11-29 14:04:01 +03:00
|
|
|
qCInfo(lcConfigFile) << "Adding user defined ignore list to csync:" << userList;
|
|
|
|
excludedFiles.addExcludeFilePath(userList);
|
|
|
|
}
|
|
|
|
}
|
2012-07-31 12:17:52 +04:00
|
|
|
}
|