Browse Source

Merge pull request #5532 from nextcloud/bugfix/stopAfterCreatingConfigFile

Bugfix/stop after creating config file
Matthieu Gallien 2 years ago
parent
commit
04a32cbe36

+ 5 - 0
src/gui/accountsetupcommandlinemanager.cpp

@@ -95,6 +95,11 @@ bool AccountSetupCommandLineManager::isCommandLineParsed() const
     return !_appPassword.isEmpty() && !_userId.isEmpty() && _serverUrl.isValid();
 }
 
+bool AccountSetupCommandLineManager::isVfsEnabled() const
+{
+    return _isVfsEnabled;
+}
+
 void AccountSetupCommandLineManager::setupAccountFromCommandLine()
 {
     if (isCommandLineParsed()) {

+ 2 - 0
src/gui/accountsetupcommandlinemanager.h

@@ -32,6 +32,8 @@ public:
 
     [[nodiscard]] bool isCommandLineParsed() const;
 
+    [[nodiscard]] bool isVfsEnabled() const;
+
 public slots:
     void setupAccountFromCommandLine();
 

+ 13 - 1
src/gui/application.cpp

@@ -332,13 +332,25 @@ Application::Application(int &argc, char **argv)
     ConfigFile cfg;
 
     {
+        auto shouldExit = false;
+
         // these config values will always be empty after the first client run
         if (!_overrideServerUrl.isEmpty()) {
-             cfg.setOverrideServerUrl(_overrideServerUrl);
+            cfg.setOverrideServerUrl(_overrideServerUrl);
+            shouldExit = true;
         }
 
         if (!_overrideLocalDir.isEmpty()) {
             cfg.setOverrideLocalDir(_overrideLocalDir);
+            shouldExit = true;
+        }
+
+        if (AccountSetupCommandLineManager::instance()) {
+            cfg.setVfsEnabled(AccountSetupCommandLineManager::instance()->isVfsEnabled());
+        }
+
+        if (shouldExit) {
+            std::exit(0);
         }
     }
 

+ 2 - 0
src/gui/owncloudsetupwizard.cpp

@@ -73,6 +73,8 @@ void OwncloudSetupWizard::runWizard(QObject *obj, const char *amember, QWidget *
     if (!cfg.overrideServerUrl().isEmpty()) {
         Theme::instance()->setOverrideServerUrl(cfg.overrideServerUrl());
         Theme::instance()->setForceOverrideServerUrl(true);
+        Theme::instance()->setVfsEnabled(cfg.isVfsEnabled());
+
         Theme::instance()->setStartLoginFlowAutomatically(true);
     }
     if (!wiz.isNull()) {

+ 13 - 0
src/libsync/configfile.cpp

@@ -70,6 +70,7 @@ static constexpr char updateSegmentC[] = "updateSegment";
 static constexpr char updateChannelC[] = "updateChannel";
 static constexpr char overrideServerUrlC[] = "overrideServerUrl";
 static constexpr char overrideLocalDirC[] = "overrideLocalDir";
+static constexpr char isVfsEnabledC[] = "isVfsEnabled";
 static constexpr char geometryC[] = "geometry";
 static constexpr char timeoutC[] = "timeout";
 static constexpr char chunkSizeC[] = "chunkSize";
@@ -724,6 +725,18 @@ void ConfigFile::setOverrideLocalDir(const QString &localDir)
     settings.setValue(QLatin1String(overrideLocalDirC), localDir);
 }
 
+bool ConfigFile::isVfsEnabled() const
+{
+    QSettings settings(configFile(), QSettings::IniFormat);
+    return settings.value({isVfsEnabledC}, {}).toBool();
+}
+
+void ConfigFile::setVfsEnabled(bool enabled)
+{
+    QSettings settings(configFile(), QSettings::IniFormat);
+    settings.setValue({isVfsEnabledC}, enabled);
+}
+
 void ConfigFile::setProxyType(int proxyType,
     const QString &host,
     int port, bool needsAuth,

+ 3 - 0
src/libsync/configfile.h

@@ -196,6 +196,9 @@ public:
     [[nodiscard]] QString overrideLocalDir() const;
     void setOverrideLocalDir(const QString &localDir);
 
+    [[nodiscard]] bool isVfsEnabled() const;
+    void setVfsEnabled(bool enabled);
+
     void saveGeometryHeader(QHeaderView *header);
     void restoreGeometryHeader(QHeaderView *header);
 

+ 1 - 1
src/libsync/nextcloudtheme.h

@@ -29,7 +29,7 @@ class NextcloudTheme : public Theme
 public:
     NextcloudTheme();
 
-    QString wizardUrlHint() const override;
+    [[nodiscard]] QString wizardUrlHint() const override;
 };
 }
 #endif // NEXTCLOUD_THEME_H

+ 13 - 0
src/libsync/theme.cpp

@@ -426,6 +426,11 @@ bool Theme::forceOverrideServerUrl() const
     return _forceOverrideServerUrl;
 }
 
+bool Theme::isVfsEnabled() const
+{
+    return _isVfsEnabled;
+}
+
 bool Theme::startLoginFlowAutomatically() const
 {
     return _startLoginFlowAutomatically;
@@ -971,6 +976,14 @@ void Theme::setForceOverrideServerUrl(bool forceOverride)
     }
 }
 
+void Theme::setVfsEnabled(bool enabled)
+{
+    if (_isVfsEnabled != enabled) {
+        _isVfsEnabled = enabled;
+        emit vfsEnabledChanged();
+    }
+}
+
 void Theme::setStartLoginFlowAutomatically(bool startLoginFlowAuto)
 {
     if (_startLoginFlowAutomatically != startLoginFlowAuto) {

+ 80 - 71
src/libsync/theme.h

@@ -57,6 +57,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
     Q_PROPERTY(QString conflictHelpUrl READ conflictHelpUrl CONSTANT)
     Q_PROPERTY(QString overrideServerUrl READ overrideServerUrl WRITE setOverrideServerUrl NOTIFY overrideServerUrlChanged)
     Q_PROPERTY(bool forceOverrideServerUrl READ forceOverrideServerUrl WRITE setForceOverrideServerUrl NOTIFY forceOverrideServerUrlChanged)
+    Q_PROPERTY(bool isVfsEnabled READ isVfsEnabled WRITE setVfsEnabled NOTIFY vfsEnabledChanged)
     Q_PROPERTY(bool startLoginFlowAutomatically READ startLoginFlowAutomatically WRITE setStartLoginFlowAutomatically NOTIFY startLoginFlowAutomaticallyChanged)
 #ifndef TOKEN_AUTH_ONLY
     Q_PROPERTY(QColor wizardHeaderTitleColor READ wizardHeaderTitleColor CONSTANT)
@@ -89,7 +90,7 @@ public:
      *
      * @return true if branded, false otherwise
      */
-    virtual bool isBranded() const;
+    [[nodiscard]] bool isBranded() const;
 
     /**
      * @brief appNameGUI - Human readable application name.
@@ -102,7 +103,7 @@ public:
      *
      * @return QString with human readable app name.
      */
-    virtual QString appNameGUI() const;
+    [[nodiscard]] QString appNameGUI() const;
 
     /**
      * @brief appName - Application name (short)
@@ -120,61 +121,61 @@ public:
      *
      * @return QString with app name.
      */
-    virtual QString appName() const;
+    [[nodiscard]] QString appName() const;
 
     /**
      * @brief Returns full path to an online state icon
      * @return QUrl full path to an icon
      */
-    QUrl stateOnlineImageSource() const;
+    [[nodiscard]] QUrl stateOnlineImageSource() const;
 
     /**
      * @brief Returns full path to an offline state icon
      * @return QUrl full path to an icon
      */
-    QUrl stateOfflineImageSource() const;
+    [[nodiscard]] QUrl stateOfflineImageSource() const;
     
     /**
      * @brief Returns full path to an online user status icon
      * @return QUrl full path to an icon
      */
-    QUrl statusOnlineImageSource() const;
+    [[nodiscard]] QUrl statusOnlineImageSource() const;
     
     /**
      * @brief Returns full path to an do not disturb user status icon
      * @return QUrl full path to an icon
      */
-    QUrl statusDoNotDisturbImageSource() const;
+    [[nodiscard]] QUrl statusDoNotDisturbImageSource() const;
     
     /**
      * @brief Returns full path to an away user status icon
      * @return QUrl full path to an icon
      */
-    QUrl statusAwayImageSource() const;
+    [[nodiscard]] QUrl statusAwayImageSource() const;
     
     /**
      * @brief Returns full path to an invisible user status icon
      * @return QUrl full path to an icon
      */
-    QUrl statusInvisibleImageSource() const;
+    [[nodiscard]] QUrl statusInvisibleImageSource() const;
 
-    QUrl syncStatusOk() const;
+    [[nodiscard]] QUrl syncStatusOk() const;
 
-    QUrl syncStatusError() const;
+    [[nodiscard]] QUrl syncStatusError() const;
 
-    QUrl syncStatusRunning() const;
+    [[nodiscard]] QUrl syncStatusRunning() const;
 
-    QUrl syncStatusPause() const;
+    [[nodiscard]] QUrl syncStatusPause() const;
 
-    QUrl syncStatusWarning() const;
+    [[nodiscard]] QUrl syncStatusWarning() const;
 
-    QUrl folderOffline() const;
+    [[nodiscard]] QUrl folderOffline() const;
 
     /**
      * @brief configFileName
      * @return the name of the config file.
      */
-    virtual QString configFileName() const;
+    [[nodiscard]] QString configFileName() const;
 
 #ifndef TOKEN_AUTH_ONLY
     static QString hidpiFileName(const QString &fileName, QPaintDevice *dev = nullptr);
@@ -186,25 +187,25 @@ public:
     /**
       * get an sync state icon
       */
-    virtual QIcon syncStateIcon(SyncResult::Status, bool sysTray = false) const;
+    [[nodiscard]] QIcon syncStateIcon(SyncResult::Status, bool sysTray = false) const;
 
-    virtual QIcon folderDisabledIcon() const;
-    virtual QIcon folderOfflineIcon(bool sysTray = false) const;
-    virtual QIcon applicationIcon() const;
+    [[nodiscard]] QIcon folderDisabledIcon() const;
+    [[nodiscard]] QIcon folderOfflineIcon(bool sysTray = false) const;
+    [[nodiscard]] QIcon applicationIcon() const;
 #endif
 
-    virtual QString statusHeaderText(SyncResult::Status) const;
-    virtual QString version() const;
+    [[nodiscard]] QString statusHeaderText(SyncResult::Status) const;
+    [[nodiscard]] QString version() const;
 
     /**
      * Characteristics: bool if more than one sync folder is allowed
      */
-    virtual bool singleSyncFolder() const;
+    [[nodiscard]] bool singleSyncFolder() const;
 
     /**
      * When true, client works with multiple accounts.
      */
-    virtual bool multiAccount() const;
+    [[nodiscard]] bool multiAccount() const;
 
     /**
     * URL to documentation.
@@ -216,7 +217,7 @@ public:
     *
     * Defaults to Nextclouds client documentation website.
     */
-    virtual QString helpUrl() const;
+    [[nodiscard]] QString helpUrl() const;
 
     /**
      * The url to use for showing help on conflicts.
@@ -227,74 +228,79 @@ public:
      * documentation website. If helpUrl() is empty, this function will also return the
      * empty string.
      */
-    virtual QString conflictHelpUrl() const;
+    [[nodiscard]] QString conflictHelpUrl() const;
 
     /**
      * Setting a value here will pre-define the server url.
      *
      * The respective UI controls will be disabled only if forceOverrideServerUrl() is true
      */
-    virtual QString overrideServerUrl() const;
+    [[nodiscard]] QString overrideServerUrl() const;
 
     /**
      * Enforce a pre-defined server url.
      *
      * When true, the respective UI controls will be disabled
      */
-    virtual bool forceOverrideServerUrl() const;
+    [[nodiscard]] bool forceOverrideServerUrl() const;
+
+    /**
+     * Enforce use of virtual files whenever possible.
+     */
+    [[nodiscard]] bool isVfsEnabled() const;
 
     /**
      * Automatically start login flow
      *
      * When true, the browser will get opened automatically
      */
-    virtual bool startLoginFlowAutomatically() const;
+    [[nodiscard]] bool startLoginFlowAutomatically() const;
     
     /**
      * Enable OCSP stapling for SSL handshakes
      *
      * When true, peer will be requested for Online Certificate Status Protocol response
      */
-    virtual bool enableStaplingOCSP() const;
+    [[nodiscard]] bool enableStaplingOCSP() const;
 
     /**
      * Enforce SSL validity
      *
      * When true, trusting the untrusted certificate is not allowed
      */
-    virtual bool forbidBadSSL() const;
+    [[nodiscard]] bool forbidBadSSL() const;
 
     /**
      * Forbid use of proxy
      *
      * When true, the app always connects to the server directly
      */
-    virtual bool doNotUseProxy() const;
+    [[nodiscard]] bool doNotUseProxy() const;
 
     /**
      * This is only usefull when previous version had a different overrideServerUrl
      * with a different auth type in that case You should then specify "http" or "shibboleth".
      * Normaly this should be left empty.
      */
-    virtual QString forceConfigAuthType() const;
+    [[nodiscard]] QString forceConfigAuthType() const;
 
     /**
      * The default folder name without path on the server at setup time.
      */
-    virtual QString defaultServerFolder() const;
+    [[nodiscard]] QString defaultServerFolder() const;
 
     /**
      * The default folder name without path on the client side at setup time.
      */
-    virtual QString defaultClientFolder() const;
+    [[nodiscard]] QString defaultClientFolder() const;
 
     /**
      * Override to encforce a particular locale, i.e. "de" or "pt_BR"
      */
-    virtual QString enforcedLocale() const { return QString(); }
+    [[nodiscard]] QString enforcedLocale() const { return QString(); }
 
     /** colored, white or black */
-    QString systrayIconFlavor(bool mono) const;
+    [[nodiscard]] QString systrayIconFlavor(bool mono) const;
 
 #ifndef TOKEN_AUTH_ONLY
     /**
@@ -302,18 +308,18 @@ public:
      * The default implementation will try to look up
      * :/client/theme/<type>.png
      */
-    virtual QVariant customMedia(CustomMediaType type);
+    [[nodiscard]] QVariant customMedia(CustomMediaType type);
 
     /** @return color for the setup wizard */
-    virtual QColor wizardHeaderTitleColor() const;
+    [[nodiscard]] QColor wizardHeaderTitleColor() const;
 
     /** @return color for the setup wizard. */
-    virtual QColor wizardHeaderBackgroundColor() const;
+    [[nodiscard]] QColor wizardHeaderBackgroundColor() const;
 
-    virtual QPixmap wizardApplicationLogo() const;
+    [[nodiscard]] QPixmap wizardApplicationLogo() const;
 
     /** @return logo for the setup wizard. */
-    virtual QPixmap wizardHeaderLogo() const;
+    [[nodiscard]] QPixmap wizardHeaderLogo() const;
 
     /**
      * The default implementation creates a
@@ -322,23 +328,23 @@ public:
      *
      * @return banner for the setup wizard.
      */
-    virtual QPixmap wizardHeaderBanner() const;
+    [[nodiscard]] QPixmap wizardHeaderBanner() const;
 #endif
 
     /**
      * The SHA sum of the released git commit
      */
-    QString gitSHA1() const;
+    [[nodiscard]] QString gitSHA1() const;
 
     /**
      * About dialog contents
      */
-    virtual QString about() const;
+    [[nodiscard]] QString about() const;
 
     /**
      * Legal notice dialog version detail contents
      */
-    virtual QString aboutDetails() const;
+    [[nodiscard]] QString aboutDetails() const;
 
     /**
      * Define if the systray icons should be using mono design
@@ -348,56 +354,56 @@ public:
     /**
      * Retrieve wether to use mono icons for systray
      */
-    bool systrayUseMonoIcons() const;
+    [[nodiscard]] bool systrayUseMonoIcons() const;
 
     /**
      * Check if mono icons are available
      */
-    bool monoIconsAvailable() const;
+    [[nodiscard]] bool monoIconsAvailable() const;
 
     /**
      * @brief Where to check for new Updates.
      */
-    virtual QString updateCheckUrl() const;
+    [[nodiscard]] QString updateCheckUrl() const;
 
     /**
      * When true, the setup wizard will show the selective sync dialog by default and default
      * to nothing selected
      */
-    virtual bool wizardSelectiveSyncDefaultNothing() const;
+    [[nodiscard]] bool wizardSelectiveSyncDefaultNothing() const;
 
     /**
      * Default option for the newBigFolderSizeLimit.
      * Size in MB of the maximum size of folder before we ask the confirmation.
      * Set -1 to never ask confirmation.  0 to ask confirmation for every folder.
      **/
-    virtual qint64 newBigFolderSizeLimit() const;
+    [[nodiscard]] qint64 newBigFolderSizeLimit() const;
 
     /**
      * Hide the checkbox that says "Ask for confirmation before synchronizing folders larger than X MB"
      * in the account wizard
      */
-    virtual bool wizardHideFolderSizeLimitCheckbox() const;
+    [[nodiscard]] bool wizardHideFolderSizeLimitCheckbox() const;
     /**
      * Hide the checkbox that says "Ask for confirmation before synchronizing external storages"
      * in the account wizard
      */
-    virtual bool wizardHideExternalStorageConfirmationCheckbox() const;
+    [[nodiscard]] bool wizardHideExternalStorageConfirmationCheckbox() const;
 
     /**
      * @brief Sharing options
      *
      * Allow link sharing and or user/group sharing
      */
-    virtual bool linkSharing() const;
-    virtual bool userGroupSharing() const;
+    [[nodiscard]] bool linkSharing() const;
+    [[nodiscard]] bool userGroupSharing() const;
 
     /**
      * If this returns true, the user cannot configure the proxy in the network settings.
      * The proxy settings will be disabled in the configuration dialog.
      * Default returns false.
      */
-    virtual bool forceSystemNetworkProxy() const;
+    [[nodiscard]] bool forceSystemNetworkProxy() const;
 
     /**
      * @brief How to handle the userID
@@ -414,7 +420,7 @@ public:
      *
      *  @return UserIDType::UserIDUserName, unless reimplemented
      */
-    virtual UserIDType userIDType() const;
+    [[nodiscard]] UserIDType userIDType() const;
 
     /**
      * @brief Allows to customize the type of user ID (e.g. user name, email)
@@ -424,7 +430,7 @@ public:
      *
      * @return An empty string, unless reimplemented
      */
-    virtual QString customUserID() const;
+    [[nodiscard]] QString customUserID() const;
 
     /**
      * @brief Demo string to be displayed when no text has been
@@ -432,7 +438,7 @@ public:
      *
      * @return An empty string, unless reimplemented
      */
-    virtual QString userIDHint() const;
+    [[nodiscard]] QString userIDHint() const;
 
     /**
      * @brief Postfix that will be enforced in a URL. e.g.
@@ -440,14 +446,14 @@ public:
      *
      * @return An empty string, unless reimplemented
      */
-    virtual QString wizardUrlPostfix() const;
+    [[nodiscard]] QString wizardUrlPostfix() const;
 
     /**
      * @brief String that will be shown as long as no text has been entered by the user.
      *
      * @return An empty string, unless reimplemented
      */
-    virtual QString wizardUrlHint() const;
+    [[nodiscard]] virtual QString wizardUrlHint() const;
 
     /**
      * @brief the server folder that should be queried for the quota information
@@ -458,14 +464,14 @@ public:
      *
      * Defaults: "/"
      */
-    virtual QString quotaBaseFolder() const;
+    [[nodiscard]] QString quotaBaseFolder() const;
 
     /**
      * The OAuth client_id, secret pair.
      * Note that client that change these value cannot connect to un-branded owncloud servers.
      */
-    virtual QString oauthClientId() const;
-    virtual QString oauthClientSecret() const;
+    [[nodiscard]] QString oauthClientId() const;
+    [[nodiscard]] QString oauthClientSecret() const;
 
     /**
      * @brief What should be output for the --version command line switch.
@@ -473,7 +479,7 @@ public:
      * By default, it's a combination of appName(), version(), the GIT SHA1 and some
      * important dependency versions.
      */
-    virtual QString versionSwitchOutput() const;
+    [[nodiscard]] QString versionSwitchOutput() const;
 	
 	/**
     * @brief Request suitable QIcon resource depending on the background colour of the parent widget.
@@ -481,7 +487,7 @@ public:
     * This should be replaced (TODO) by a real theming implementation for the client UI 
     * (actually 2019/09/13 only systray theming).
     */
-	virtual QIcon uiThemeIcon(const QString &iconName, bool uiHasDarkBg) const;
+    [[nodiscard]] QIcon uiThemeIcon(const QString &iconName, bool uiHasDarkBg) const;
 
     Q_INVOKABLE static double getColorDarkness(const QColor &color);
 
@@ -581,9 +587,9 @@ public:
      * By default, the options are not shown unless experimental options are
      * manually enabled in the configuration file.
      */
-    virtual bool showVirtualFilesOption() const;
+    [[nodiscard]] bool showVirtualFilesOption() const;
 
-    virtual bool enforceVirtualFilesSyncFolder() const;
+    [[nodiscard]] bool enforceVirtualFilesSyncFolder() const;
 
     static QColor defaultColor();
 
@@ -593,9 +599,10 @@ public:
     bool darkMode();
 
 public slots:
-    virtual void setOverrideServerUrl(const QString &overrideServerUrl);
-    virtual void setForceOverrideServerUrl(bool forceOverride);
-    virtual void setStartLoginFlowAutomatically(bool startLoginFlowAuto);
+    void setOverrideServerUrl(const QString &overrideServerUrl);
+    void setForceOverrideServerUrl(bool forceOverride);
+    void setVfsEnabled(bool enabled);
+    void setStartLoginFlowAutomatically(bool startLoginFlowAuto);
 
 protected:
 #ifndef TOKEN_AUTH_ONLY
@@ -617,6 +624,7 @@ signals:
     void darkModeChanged();
     void overrideServerUrlChanged();
     void forceOverrideServerUrlChanged();
+    void vfsEnabledChanged();
     void startLoginFlowAutomaticallyChanged();
 
 private:
@@ -634,6 +642,7 @@ private:
 
     QString _overrideServerUrl;
     bool _forceOverrideServerUrl = false;
+    bool _isVfsEnabled = false;
     bool _startLoginFlowAutomatically = false;
 
 #ifndef TOKEN_AUTH_ONLY