"Fossies" - the Fresh Open Source Software Archive

Member "seafile-client-7.0.4/src/settings-mgr.h" (19 Nov 2019, 4866 Bytes) of package /linux/www/seafile-client-7.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "settings-mgr.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef SEAFILE_CLIENT_SETTINGS_MANAGER_H
    2 #define SEAFILE_CLIENT_SETTINGS_MANAGER_H
    3 
    4 #include <QObject>
    5 #include <QRunnable>
    6 #include <QUrl>
    7 #include <QNetworkProxy>
    8 
    9 /**
   10  * Settings Manager handles seafile client user settings & preferences
   11  */
   12 class QTimer;
   13 
   14 class SettingsManager : public QObject {
   15     Q_OBJECT
   16 
   17 public:
   18     enum ProxyType {
   19         NoProxy = 0,
   20         HttpProxy = 1,
   21         SocksProxy = 2,
   22         SystemProxy = 3
   23     };
   24 
   25     struct SeafileProxy {
   26         ProxyType type;
   27 
   28         QString host;
   29         int port;
   30         QString username;
   31         QString password;
   32 
   33         SeafileProxy(ProxyType _type = NoProxy,
   34                      const QString _host = QString(),
   35                      int _port = 0,
   36                      const QString& _username = QString(),
   37                      const QString& _password = QString())
   38             : type(_type),
   39               host(_host),
   40               port(_port),
   41               username(_username),
   42               password(_password)
   43         {
   44         }
   45 
   46         void toQtNetworkProxy(QNetworkProxy *proxy) const;
   47 
   48         bool operator==(const SeafileProxy& rhs) const;
   49         bool operator!=(const SeafileProxy& rhs) const { return !(*this == rhs); };
   50 
   51         static SeafileProxy fromQtNetworkProxy(const QNetworkProxy& proxy);
   52     };
   53 
   54     SettingsManager();
   55 
   56     void loadSettings();
   57     void setAutoSync(bool);
   58 
   59     bool autoSync() { return auto_sync_; }
   60 
   61     bool notify() { return bubbleNotifycation_; }
   62     bool autoStart() { return autoStart_; }
   63     unsigned int maxDownloadRatio() { return maxDownloadRatio_; }
   64     unsigned int maxUploadRatio() { return maxUploadRatio_; }
   65     bool allowInvalidWorktree() { return allow_invalid_worktree_; }
   66     bool syncExtraTempFile() { return sync_extra_temp_file_; }
   67 
   68     void getProxy(QNetworkProxy *proxy) const;
   69     SeafileProxy getProxy() const { return current_proxy_; };
   70 
   71     void setNotify(bool notify);
   72     void setAutoStart(bool autoStart);
   73     void setMaxDownloadRatio(unsigned int ratio);
   74     void setMaxUploadRatio(unsigned int ratio);
   75     void setAllowInvalidWorktree(bool val);
   76     void setSyncExtraTempFile(bool sync);
   77     void setProxy(const SeafileProxy& proxy);
   78 
   79     bool hideMainWindowWhenStarted();
   80     void setHideMainWindowWhenStarted(bool hide);
   81 
   82     bool hideDockIcon();
   83     void setHideDockIcon(bool hide);
   84 
   85     // bool defaultLibraryAlreadySetup();
   86     // void setDefaultLibraryAlreadySetup();
   87 
   88     void setAllowRepoNotFoundOnServer(bool enabled);
   89     bool allowRepoNotFoundOnServer() const { return allow_repo_not_found_on_server_; };
   90 
   91     void setHttpSyncCertVerifyDisabled(bool disabled);
   92     bool httpSyncCertVerifyDisabled() const { return verify_http_sync_cert_disabled_; };
   93 
   94     QString getComputerName();
   95     void setComputerName(const QString& computerName);
   96 
   97     bool isEnableSyncingWithExistingFolder() const;
   98     void setEnableSyncingWithExistingFolder(bool enabled);
   99 
  100 #ifdef HAVE_SHIBBOLETH_SUPPORT
  101     QString getLastShibUrl();
  102     void setLastShibUrl(const QString& url);
  103 #endif // HAVE_SHIBBOLETH_SUPPORT
  104 
  105 #ifdef HAVE_FINDER_SYNC_SUPPORT
  106     bool getFinderSyncExtension() const;
  107     bool getFinderSyncExtensionAvailable() const;
  108     void setFinderSyncExtension(bool enabled);
  109 #endif // HAVE_FINDER_SYNC_SUPPORT
  110 
  111 #ifdef Q_OS_WIN32
  112     void setShellExtensionEnabled(bool enabled);
  113     bool shellExtensionEnabled() const { return shell_ext_enabled_; }
  114 #endif // HAVE_FINDER_SYNC_SUPPORT
  115 
  116 public:
  117 
  118     // Remove all settings from system when uninstall
  119     static void removeAllSettings();
  120     // Write the system proxy information, to be read by seaf-daemon.
  121     void writeSystemProxyInfo(const QUrl& url, const QString& file_path);
  122 
  123 signals:
  124     void autoSyncChanged(bool auto_sync);
  125 
  126 private slots:
  127     void checkSystemProxy();
  128     void onSystemProxyPolled(const QNetworkProxy& proxy);
  129 
  130 private:
  131     Q_DISABLE_COPY(SettingsManager)
  132 
  133     void loadProxySettings();
  134     void writeProxySettingsToDaemon(const SeafileProxy& proxy);
  135     void writeProxyDetailsToDaemon(const SeafileProxy& proxy);
  136 
  137     void applyProxySettings();
  138 
  139     bool auto_sync_;
  140     bool bubbleNotifycation_;
  141     bool autoStart_;
  142     bool allow_invalid_worktree_;
  143     bool allow_repo_not_found_on_server_;
  144     bool sync_extra_temp_file_;
  145     unsigned int maxDownloadRatio_;
  146     unsigned int maxUploadRatio_;
  147     bool verify_http_sync_cert_disabled_;
  148     bool shell_ext_enabled_;
  149 
  150     // proxy settings
  151     SeafileProxy current_proxy_;
  152     QNetworkProxy last_system_proxy_;
  153 
  154     QTimer *check_system_proxy_timer_;
  155 };
  156 
  157 
  158 // Use to periodically reading the current system proxy.
  159 class SystemProxyPoller : public QObject, public QRunnable {
  160     Q_OBJECT
  161 public:
  162     SystemProxyPoller(const QUrl& url);
  163     void run();
  164 
  165 signals:
  166     void systemProxyPolled(const QNetworkProxy& proxy);
  167 
  168 private:
  169     QUrl url_;
  170 };
  171 
  172 #endif // SEAFILE_CLIENT_SETTINGS_MANAGER_H