Allow server URL to be pre-defined without enforcing it to be used unmodified
authorMichael Schuster <michael@schuster.ms>
Thu, 17 Sep 2020 01:38:35 +0000 (03:38 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Wed, 23 Sep 2020 07:21:35 +0000 (07:21 +0000)
APPLICATION_SERVER_URL can be either empty or be specified. This commit adds the new CMake option APPLICATION_SERVER_URL_ENFORCE to decide whether to enforce the
URL's unmodified use (like before, default: ON) or to allow modification by the user (new).

By default APPLICATION_SERVER_URL_ENFORCE is set to ON, to no break with the previous implementation's expectations.

If APPLICATION_SERVER_URL is empty, APPLICATION_SERVER_URL_ENFORCE will be ignored by the Account Wizard.

The previous behaviour confused me a bit with branded builds. When the URL was (usually) specified but not forced, it was simply discarded, forcing the user to
manually supply it.

Signed-off-by: Michael Schuster <michael@schuster.ms>
NEXTCLOUD.cmake
config.h.in
src/gui/wizard/owncloudsetuppage.cpp
src/libsync/theme.cpp
src/libsync/theme.h

index a497b86749b854e79aa4c622a9c76d3151951f2d..ec5830a4f62b6b7a26955c111d2454d60fb4971b 100644 (file)
@@ -6,7 +6,8 @@ set( APPLICATION_VENDOR     "Nextcloud GmbH" )
 set( APPLICATION_UPDATE_URL "https://updates.nextcloud.org/client/" CACHE STRING "URL for updater" )
 set( APPLICATION_HELP_URL   "" CACHE STRING "URL for the help menu" )
 set( APPLICATION_ICON_NAME  "Nextcloud" )
-set( APPLICATION_SERVER_URL "" CACHE STRING "URL for the server to use. If entered the server can only connect to this instance" )
+set( APPLICATION_SERVER_URL "" CACHE STRING "URL for the server to use. If entered, the UI field will be pre-filled with it" )
+set( APPLICATION_SERVER_URL_ENFORCE ON ) # If set and APPLICATION_SERVER_URL is defined, the server can only connect to the pre-defined URL
 set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" )
 
 set( LINUX_PACKAGE_SHORTNAME "nextcloud" )
index 83ec3853e8862fa375f1bb7fea5aa4d878964202..0581afbd90e25357b6a30487db4362b2dfa4e462 100644 (file)
@@ -21,6 +21,7 @@
 #cmakedefine APPLICATION_HELP_URL "@APPLICATION_HELP_URL@"
 #cmakedefine APPLICATION_ICON_NAME "@APPLICATION_ICON_NAME@"
 #cmakedefine APPLICATION_SERVER_URL "@APPLICATION_SERVER_URL@"
+#cmakedefine APPLICATION_SERVER_URL_ENFORCE "@APPLICATION_SERVER_URL_ENFORCE@"
 #cmakedefine LINUX_APPLICATION_ID "@LINUX_APPLICATION_ID@"
 #cmakedefine APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR "@APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR@"
 #cmakedefine APPLICATION_WIZARD_HEADER_TITLE_COLOR "@APPLICATION_WIZARD_HEADER_TITLE_COLOR@"
index 71f1c19c91d347c7c5c2f933dddfb9957708264e..1bc76fdef311a6281bb0a9f65d5fed6a897ae15c 100644 (file)
@@ -51,7 +51,7 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent)
     if (theme->overrideServerUrl().isEmpty()) {
         _ui.leUrl->setPostfix(theme->wizardUrlPostfix());
         _ui.leUrl->setPlaceholderText(theme->wizardUrlHint());
-    } else {
+    } else if (Theme::instance()->forceOverrideServerUrl()) {
         _ui.leUrl->setEnabled(false);
     }
 
@@ -213,6 +213,10 @@ void OwncloudSetupPage::initializePage()
     // immediately.
     if (Theme::instance()->overrideServerUrl().isEmpty()) {
         _ui.leUrl->setFocus();
+    } else if (!Theme::instance()->forceOverrideServerUrl()) {
+        if (nextButton) {
+            nextButton->setFocus();
+        }
     } else {
         setCommitPage(true);
         // Hack: setCommitPage() changes caption, but after an error this page could still be visible
index f2dcb597b4837e3ae92c5899a2273737f98db253..f792c493d731e2ec6837d18a76cf6e5ba5de8213 100644 (file)
@@ -269,6 +269,15 @@ QString Theme::overrideServerUrl() const
 #endif
 }
 
+bool Theme::forceOverrideServerUrl() const
+{
+#ifdef APPLICATION_SERVER_URL_ENFORCE
+    return true;
+#else
+    return false;
+#endif
+}
+
 QString Theme::forceConfigAuthType() const
 {
     return QString();
index 79014dc485e8dc3a280539b29abd59e75d3610bf..b36dab7ea996a2dc51ff54c3812946d1dbc91623 100644 (file)
@@ -149,10 +149,17 @@ public:
     /**
      * Setting a value here will pre-define the server url.
      *
-     * The respective UI controls will be disabled
+     * The respective UI controls will be disabled only if forceOverrideServerUrl() is true
      */
     virtual QString overrideServerUrl() const;
 
+    /**
+     * Enforce a pre-defined server url.
+     *
+     * When true, the respective UI controls will be disabled
+     */
+    virtual bool forceOverrideServerUrl() 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".