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.
|
|
|
|
*/
|
|
|
|
|
2014-11-18 18:44:14 +03:00
|
|
|
#ifndef CONFIGFILE_H
|
|
|
|
#define CONFIGFILE_H
|
2012-02-17 14:11:18 +04:00
|
|
|
|
2014-04-29 17:30:19 +04:00
|
|
|
#include "owncloudlib.h"
|
2017-08-16 09:36:52 +03:00
|
|
|
#include <memory>
|
2013-07-29 16:28:19 +04:00
|
|
|
#include <QSharedPointer>
|
2017-08-16 09:36:52 +03:00
|
|
|
#include <QSettings>
|
2012-05-21 18:48:49 +04:00
|
|
|
#include <QString>
|
2013-07-24 21:53:05 +04:00
|
|
|
#include <QVariant>
|
2018-01-24 00:51:25 +03:00
|
|
|
#include <chrono>
|
2012-05-21 18:48:49 +04:00
|
|
|
|
2013-07-22 14:28:43 +04:00
|
|
|
class QWidget;
|
2013-12-12 18:16:19 +04:00
|
|
|
class QHeaderView;
|
2017-11-29 14:04:01 +03:00
|
|
|
class ExcludedFiles;
|
2012-05-21 18:48:49 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2012-02-17 14:11:18 +04:00
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
class AbstractCredentials;
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The ConfigFile class
|
|
|
|
* @ingroup libsync
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2014-11-10 00:30:29 +03:00
|
|
|
class OWNCLOUDSYNC_EXPORT ConfigFile
|
2012-02-17 14:11:18 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-11-10 00:30:29 +03:00
|
|
|
ConfigFile();
|
2012-02-17 14:11:18 +04:00
|
|
|
|
2013-07-05 18:54:11 +04:00
|
|
|
enum Scope { UserScope,
|
|
|
|
SystemScope };
|
2012-07-25 18:51:29 +04:00
|
|
|
|
2012-03-28 13:26:51 +04:00
|
|
|
QString configPath() const;
|
2012-03-28 14:23:34 +04:00
|
|
|
QString configFile() const;
|
2013-07-05 18:54:11 +04:00
|
|
|
QString excludeFile(Scope scope) const;
|
2014-10-17 17:58:01 +04:00
|
|
|
static QString excludeFileFromSystem(); // doesn't access config dir
|
2012-03-28 14:23:34 +04:00
|
|
|
|
2018-05-02 16:40:54 +03:00
|
|
|
/**
|
|
|
|
* Creates a backup of the file
|
|
|
|
*
|
|
|
|
* Returns the path of the new backup.
|
|
|
|
*/
|
|
|
|
QString backup() const;
|
|
|
|
|
2012-02-17 14:11:18 +04:00
|
|
|
bool exists();
|
2012-02-18 20:02:10 +04:00
|
|
|
|
|
|
|
QString defaultConnection() const;
|
2012-02-17 14:11:18 +04:00
|
|
|
|
2012-08-06 15:57:26 +04:00
|
|
|
// the certs do not depend on a connection.
|
|
|
|
QByteArray caCerts();
|
|
|
|
void setCaCerts(const QByteArray &);
|
|
|
|
|
2017-12-08 12:58:55 +03:00
|
|
|
bool passwordStorageAllowed(const QString &connection = QString());
|
2012-02-18 20:02:10 +04:00
|
|
|
|
2013-01-16 21:03:40 +04:00
|
|
|
/* Server poll interval in milliseconds */
|
2018-01-24 00:51:25 +03:00
|
|
|
std::chrono::milliseconds remotePollInterval(const QString &connection = QString()) const;
|
2015-10-05 06:20:09 +03:00
|
|
|
/* Set poll interval. Value in milliseconds has to be larger than 5000 */
|
2018-01-24 00:51:25 +03:00
|
|
|
void setRemotePollInterval(std::chrono::milliseconds interval, const QString &connection = QString());
|
2012-05-26 16:37:21 +04:00
|
|
|
|
2016-03-18 18:23:21 +03:00
|
|
|
/* Interval to check for new notifications */
|
2018-01-24 00:51:25 +03:00
|
|
|
std::chrono::milliseconds notificationRefreshInterval(const QString &connection = QString()) const;
|
2016-03-18 18:23:21 +03:00
|
|
|
|
2013-08-08 16:30:45 +04:00
|
|
|
/* Force sync interval, in milliseconds */
|
2018-01-24 00:51:25 +03:00
|
|
|
std::chrono::milliseconds forceSyncInterval(const QString &connection = QString()) const;
|
2013-08-08 16:30:45 +04:00
|
|
|
|
2017-09-14 17:43:23 +03:00
|
|
|
/**
|
|
|
|
* Interval in milliseconds within which full local discovery is required
|
|
|
|
*
|
|
|
|
* Use -1 to disable regular full local discoveries.
|
|
|
|
*/
|
2018-01-24 00:51:25 +03:00
|
|
|
std::chrono::milliseconds fullLocalDiscoveryInterval() const;
|
2017-09-14 17:43:23 +03:00
|
|
|
|
2013-07-04 21:59:40 +04:00
|
|
|
bool monoIcons() const;
|
|
|
|
void setMonoIcons(bool);
|
|
|
|
|
2016-01-24 21:45:12 +03:00
|
|
|
bool promptDeleteFiles() const;
|
|
|
|
void setPromptDeleteFiles(bool promptDeleteFiles);
|
|
|
|
|
2014-08-28 18:19:17 +04:00
|
|
|
bool crashReporter() const;
|
|
|
|
void setCrashReporter(bool enabled);
|
|
|
|
|
2018-04-10 14:07:20 +03:00
|
|
|
bool automaticLogDir() const;
|
|
|
|
void setAutomaticLogDir(bool enabled);
|
|
|
|
|
2020-07-01 17:08:13 +03:00
|
|
|
QString logDir() const;
|
|
|
|
void setLogDir(const QString &dir);
|
|
|
|
|
2020-07-01 16:56:23 +03:00
|
|
|
bool logDebug() const;
|
|
|
|
void setLogDebug(bool enabled);
|
|
|
|
|
2020-07-01 17:03:45 +03:00
|
|
|
int logExpire() const;
|
|
|
|
void setLogExpire(int hours);
|
|
|
|
|
2020-07-01 17:10:10 +03:00
|
|
|
bool logFlush() const;
|
|
|
|
void setLogFlush(bool enabled);
|
|
|
|
|
2018-04-05 14:35:25 +03:00
|
|
|
// Whether experimental UI options should be shown
|
|
|
|
bool showExperimentalOptions() const;
|
|
|
|
|
2012-07-31 12:17:52 +04:00
|
|
|
// proxy settings
|
|
|
|
void setProxyType(int proxyType,
|
|
|
|
const QString &host = QString(),
|
2013-05-29 14:56:23 +04:00
|
|
|
int port = 0, bool needsAuth = false,
|
2012-07-31 12:17:52 +04:00
|
|
|
const QString &user = QString(),
|
|
|
|
const QString &pass = QString());
|
|
|
|
|
|
|
|
int proxyType() const;
|
|
|
|
QString proxyHostName() const;
|
|
|
|
int proxyPort() const;
|
2013-05-29 14:56:23 +04:00
|
|
|
bool proxyNeedsAuth() const;
|
2012-07-31 12:17:52 +04:00
|
|
|
QString proxyUser() const;
|
|
|
|
QString proxyPassword() const;
|
2017-05-17 11:55:42 +03:00
|
|
|
|
2013-07-24 21:53:05 +04:00
|
|
|
/** 0: no limit, 1: manual, >0: automatic */
|
|
|
|
int useUploadLimit() const;
|
2015-06-29 18:43:25 +03:00
|
|
|
int useDownloadLimit() const;
|
2013-07-24 21:53:05 +04:00
|
|
|
void setUseUploadLimit(int);
|
2015-06-29 18:43:25 +03:00
|
|
|
void setUseDownloadLimit(int);
|
2013-08-14 15:35:31 +04:00
|
|
|
/** in kbyte/s */
|
2013-07-24 21:53:05 +04:00
|
|
|
int uploadLimit() const;
|
|
|
|
int downloadLimit() const;
|
|
|
|
void setUploadLimit(int kbytes);
|
|
|
|
void setDownloadLimit(int kbytes);
|
2015-07-07 17:28:48 +03:00
|
|
|
/** [checked, size in MB] **/
|
2019-02-13 12:15:33 +03:00
|
|
|
QPair<bool, qint64> newBigFolderSizeLimit() const;
|
|
|
|
void setNewBigFolderSizeLimit(bool isChecked, qint64 mbytes);
|
2021-02-12 14:23:40 +03:00
|
|
|
bool useNewBigFolderSizeLimit() const;
|
2017-01-24 12:16:10 +03:00
|
|
|
bool confirmExternalStorage() const;
|
|
|
|
void setConfirmExternalStorage(bool);
|
2018-01-25 16:35:21 +03:00
|
|
|
|
|
|
|
/** If we should move the files deleted on the server in the trash */
|
2017-12-25 13:46:38 +03:00
|
|
|
bool moveToTrash() const;
|
|
|
|
void setMoveToTrash(bool);
|
2013-07-24 21:53:05 +04:00
|
|
|
|
2015-03-23 16:59:29 +03:00
|
|
|
static bool setConfDir(const QString &value);
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2018-02-15 22:21:08 +03:00
|
|
|
bool optionalServerNotifications() const;
|
|
|
|
void setOptionalServerNotifications(bool show);
|
2013-07-05 03:01:23 +04:00
|
|
|
|
2017-10-19 17:37:51 +03:00
|
|
|
bool showInExplorerNavigationPane() const;
|
|
|
|
void setShowInExplorerNavigationPane(bool show);
|
|
|
|
|
2014-05-28 18:28:22 +04:00
|
|
|
int timeout() const;
|
2019-02-13 12:15:33 +03:00
|
|
|
qint64 chunkSize() const;
|
|
|
|
qint64 maxChunkSize() const;
|
|
|
|
qint64 minChunkSize() const;
|
2018-01-24 00:51:25 +03:00
|
|
|
std::chrono::milliseconds targetChunkUploadDuration() const;
|
2014-05-28 18:28:22 +04:00
|
|
|
|
2013-07-22 14:28:43 +04:00
|
|
|
void saveGeometry(QWidget *w);
|
|
|
|
void restoreGeometry(QWidget *w);
|
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
// how often the check about new versions runs
|
|
|
|
std::chrono::milliseconds updateCheckInterval(const QString &connection = QString()) const;
|
2015-06-15 13:24:18 +03:00
|
|
|
|
2020-03-09 03:17:02 +03:00
|
|
|
// skipUpdateCheck completely disables the updater and hides its UI
|
2014-01-15 14:08:42 +04:00
|
|
|
bool skipUpdateCheck(const QString &connection = QString()) const;
|
|
|
|
void setSkipUpdateCheck(bool, const QString &);
|
|
|
|
|
2020-03-09 03:17:02 +03:00
|
|
|
// autoUpdateCheck allows the user to make the choice in the UI
|
|
|
|
bool autoUpdateCheck(const QString &connection = QString()) const;
|
|
|
|
void setAutoUpdateCheck(bool, const QString &);
|
|
|
|
|
2020-02-21 23:28:42 +03:00
|
|
|
/** Query-parameter 'updatesegment' for the update check, value between 0 and 99.
|
|
|
|
Used to throttle down desktop release rollout in order to keep the update servers alive at peak times.
|
|
|
|
See: https://github.com/nextcloud/client_updater_server/pull/36 */
|
|
|
|
int updateSegment() const;
|
|
|
|
|
2018-04-26 12:24:30 +03:00
|
|
|
QString updateChannel() const;
|
|
|
|
void setUpdateChannel(const QString &channel);
|
|
|
|
|
2013-12-12 18:16:19 +04:00
|
|
|
void saveGeometryHeader(QHeaderView *header);
|
|
|
|
void restoreGeometryHeader(QHeaderView *header);
|
2014-02-12 15:17:32 +04:00
|
|
|
|
2014-11-18 18:44:14 +03:00
|
|
|
QString certificatePath() const;
|
|
|
|
void setCertificatePath(const QString &cPath);
|
|
|
|
QString certificatePasswd() const;
|
|
|
|
void setCertificatePasswd(const QString &cPasswd);
|
|
|
|
|
2018-05-14 15:37:48 +03:00
|
|
|
/** The client version that last used this settings file.
|
|
|
|
Updated by configVersionMigration() at client startup. */
|
|
|
|
QString clientVersionString() const;
|
|
|
|
void setClientVersionString(const QString &version);
|
|
|
|
|
2017-08-16 09:36:52 +03:00
|
|
|
/** Returns a new settings pre-set in a specific group. The Settings will be created
|
|
|
|
with the given parent. If no parent is specified, the caller must destroy the settings */
|
2018-11-12 20:46:39 +03:00
|
|
|
static std::unique_ptr<QSettings> settingsWithGroup(const QString &group, QObject *parent = nullptr);
|
2017-08-16 09:36:52 +03:00
|
|
|
|
2017-11-29 14:04:01 +03:00
|
|
|
/// Add the system and user exclude file path to the ExcludedFiles instance.
|
|
|
|
static void setupDefaultExcludeFilePaths(ExcludedFiles &excludedFiles);
|
|
|
|
|
2012-11-13 14:15:25 +04:00
|
|
|
protected:
|
2014-02-12 15:17:32 +04:00
|
|
|
QVariant getPolicySetting(const QString &policy, const QVariant &defaultValue = QVariant()) const;
|
2013-07-29 16:28:19 +04:00
|
|
|
void storeData(const QString &group, const QString &key, const QVariant &value);
|
|
|
|
QVariant retrieveData(const QString &group, const QString &key) const;
|
|
|
|
void removeData(const QString &group, const QString &key);
|
|
|
|
bool dataExists(const QString &group, const QString &key) const;
|
2012-12-11 18:07:44 +04:00
|
|
|
|
2012-07-31 12:17:52 +04:00
|
|
|
private:
|
2017-12-08 12:58:55 +03:00
|
|
|
QVariant getValue(const QString ¶m, const QString &group = QString(),
|
2013-07-24 21:53:05 +04:00
|
|
|
const QVariant &defaultValue = QVariant()) const;
|
|
|
|
void setValue(const QString &key, const QVariant &value);
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2020-06-25 17:59:57 +03:00
|
|
|
QString keychainProxyPasswordKey() const;
|
|
|
|
|
2012-04-12 16:06:59 +04:00
|
|
|
private:
|
2020-08-12 16:23:11 +03:00
|
|
|
using SharedCreds = QSharedPointer<AbstractCredentials>;
|
2013-07-29 16:28:19 +04:00
|
|
|
|
2012-04-12 16:06:59 +04:00
|
|
|
static bool _askedUser;
|
2012-05-14 18:22:30 +04:00
|
|
|
static QString _oCVersion;
|
2013-01-14 03:48:26 +04:00
|
|
|
static QString _confDir;
|
2012-02-17 14:11:18 +04:00
|
|
|
};
|
|
|
|
}
|
2014-11-18 18:44:14 +03:00
|
|
|
#endif // CONFIGFILE_H
|