configfile.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (C) by Klaas Freitag <freitag@owncloud.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. #ifndef CONFIGFILE_H
  15. #define CONFIGFILE_H
  16. #include "owncloudlib.h"
  17. #include <QSharedPointer>
  18. #include <QString>
  19. #include <QVariant>
  20. class QWidget;
  21. class QHeaderView;
  22. namespace OCC {
  23. class AbstractCredentials;
  24. /**
  25. * @brief The ConfigFile class
  26. * @ingroup libsync
  27. */
  28. class OWNCLOUDSYNC_EXPORT ConfigFile
  29. {
  30. public:
  31. ConfigFile();
  32. enum Scope { UserScope, SystemScope };
  33. QString configPath() const;
  34. QString configPathWithAppName() const;
  35. QString configFile() const;
  36. QString excludeFile(Scope scope) const;
  37. static QString excludeFileFromSystem(); // doesn't access config dir
  38. bool exists();
  39. QString defaultConnection() const;
  40. // the certs do not depend on a connection.
  41. QByteArray caCerts();
  42. void setCaCerts( const QByteArray& );
  43. bool passwordStorageAllowed(const QString &connection = QString::null );
  44. // max count of lines in the log window
  45. int maxLogLines() const;
  46. void setMaxLogLines(int);
  47. /* Server poll interval in milliseconds */
  48. int remotePollInterval( const QString& connection = QString() ) const;
  49. /* Set poll interval. Value in milliseconds has to be larger than 5000 */
  50. void setRemotePollInterval(int interval, const QString& connection = QString() );
  51. /* Interval to check for new notifications */
  52. quint64 notificationRefreshInterval(const QString& connection = QString()) const;
  53. /* Force sync interval, in milliseconds */
  54. quint64 forceSyncInterval(const QString &connection = QString()) const;
  55. bool monoIcons() const;
  56. void setMonoIcons(bool);
  57. bool promptDeleteFiles() const;
  58. void setPromptDeleteFiles(bool promptDeleteFiles);
  59. bool crashReporter() const;
  60. void setCrashReporter(bool enabled);
  61. // proxy settings
  62. void setProxyType(int proxyType,
  63. const QString& host = QString(),
  64. int port = 0, bool needsAuth = false,
  65. const QString& user = QString(),
  66. const QString& pass = QString());
  67. int proxyType() const;
  68. QString proxyHostName() const;
  69. int proxyPort() const;
  70. bool proxyNeedsAuth() const;
  71. QString proxyUser() const;
  72. QString proxyPassword() const;
  73. /** 0: no limit, 1: manual, >0: automatic */
  74. int useUploadLimit() const;
  75. int useDownloadLimit() const;
  76. void setUseUploadLimit(int);
  77. void setUseDownloadLimit(int);
  78. /** in kbyte/s */
  79. int uploadLimit() const;
  80. int downloadLimit() const;
  81. void setUploadLimit(int kbytes);
  82. void setDownloadLimit(int kbytes);
  83. /** [checked, size in MB] **/
  84. QPair<bool, quint64> newBigFolderSizeLimit() const;
  85. void setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes);
  86. bool confirmExternalStorage() const;
  87. void setConfirmExternalStorage(bool);
  88. static bool setConfDir(const QString &value);
  89. bool optionalDesktopNotifications() const;
  90. void setOptionalDesktopNotifications(bool show);
  91. int timeout() const;
  92. quint64 chunkSize() const;
  93. quint64 maxChunkSize() const;
  94. quint64 minChunkSize() const;
  95. quint64 targetChunkUploadDuration() const;
  96. void saveGeometry(QWidget *w);
  97. void restoreGeometry(QWidget *w);
  98. // how often the check about new versions runs, default two hours
  99. int updateCheckInterval( const QString& connection = QString() ) const;
  100. bool skipUpdateCheck( const QString& connection = QString() ) const;
  101. void setSkipUpdateCheck( bool, const QString& );
  102. void saveGeometryHeader(QHeaderView *header);
  103. void restoreGeometryHeader(QHeaderView *header);
  104. QString certificatePath() const;
  105. void setCertificatePath(const QString& cPath);
  106. QString certificatePasswd() const;
  107. void setCertificatePasswd(const QString& cPasswd);
  108. protected:
  109. QVariant getPolicySetting(const QString& policy, const QVariant& defaultValue = QVariant()) const;
  110. void storeData(const QString& group, const QString& key, const QVariant& value);
  111. QVariant retrieveData(const QString& group, const QString& key) const;
  112. void removeData(const QString& group, const QString& key);
  113. bool dataExists(const QString& group, const QString& key) const;
  114. private:
  115. QVariant getValue(const QString& param, const QString& group = QString::null,
  116. const QVariant& defaultValue = QVariant()) const;
  117. void setValue(const QString& key, const QVariant &value);
  118. private:
  119. typedef QSharedPointer< AbstractCredentials > SharedCreds;
  120. static bool _askedUser;
  121. static QString _oCVersion;
  122. static QString _confDir;
  123. };
  124. }
  125. #endif // CONFIGFILE_H