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>
|
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;
|
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;
|
2013-10-03 19:04:55 +04:00
|
|
|
QString configPathWithAppName() 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
|
|
|
|
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 &);
|
|
|
|
|
2013-02-11 17:20:32 +04:00
|
|
|
bool passwordStorageAllowed(const QString &connection = QString::null);
|
2012-02-18 20:02:10 +04:00
|
|
|
|
2012-06-05 17:11:29 +04:00
|
|
|
// max count of lines in the log window
|
|
|
|
int maxLogLines() const;
|
2013-02-18 19:17:03 +04:00
|
|
|
void setMaxLogLines(int);
|
2012-06-05 17:11:29 +04:00
|
|
|
|
2013-01-16 21:03:40 +04:00
|
|
|
/* Server poll interval in milliseconds */
|
2012-05-26 16:37:21 +04:00
|
|
|
int 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 */
|
2013-01-23 06:35:42 +04:00
|
|
|
void setRemotePollInterval(int 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 */
|
|
|
|
quint64 notificationRefreshInterval(const QString &connection = QString()) const;
|
|
|
|
|
2013-08-08 16:30:45 +04:00
|
|
|
/* Force sync interval, in milliseconds */
|
|
|
|
quint64 forceSyncInterval(const QString &connection = QString()) const;
|
|
|
|
|
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);
|
|
|
|
|
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] **/
|
2015-07-27 10:54:20 +03:00
|
|
|
QPair<bool, quint64> newBigFolderSizeLimit() const;
|
|
|
|
void setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes);
|
2017-01-24 12:16:10 +03:00
|
|
|
bool confirmExternalStorage() const;
|
|
|
|
void setConfirmExternalStorage(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
|
|
|
|
2013-07-05 03:01:23 +04:00
|
|
|
bool optionalDesktopNotifications() const;
|
|
|
|
void setOptionalDesktopNotifications(bool show);
|
|
|
|
|
2014-05-28 18:28:22 +04:00
|
|
|
int timeout() const;
|
2016-01-15 15:16:52 +03:00
|
|
|
quint64 chunkSize() const;
|
2016-12-08 00:35:50 +03:00
|
|
|
quint64 maxChunkSize() const;
|
|
|
|
quint64 minChunkSize() const;
|
2017-03-24 17:01:50 +03:00
|
|
|
quint64 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);
|
|
|
|
|
2015-06-15 13:24:18 +03:00
|
|
|
// how often the check about new versions runs, default two hours
|
2015-07-22 14:42:54 +03:00
|
|
|
int updateCheckInterval(const QString &connection = QString()) const;
|
2015-06-15 13:24:18 +03:00
|
|
|
|
2014-01-15 14:08:42 +04:00
|
|
|
bool skipUpdateCheck(const QString &connection = QString()) const;
|
|
|
|
void setSkipUpdateCheck(bool, const QString &);
|
|
|
|
|
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);
|
|
|
|
|
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 */
|
|
|
|
static std::unique_ptr<QSettings> settingsWithGroup(const QString &group, QObject *parent = 0);
|
|
|
|
|
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:
|
2013-07-24 21:53:05 +04:00
|
|
|
QVariant getValue(const QString ¶m, const QString &group = QString::null,
|
|
|
|
const QVariant &defaultValue = QVariant()) const;
|
|
|
|
void setValue(const QString &key, const QVariant &value);
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2012-04-12 16:06:59 +04:00
|
|
|
private:
|
2013-07-29 16:28:19 +04:00
|
|
|
typedef QSharedPointer<AbstractCredentials> SharedCreds;
|
|
|
|
|
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
|