Cmake option to disable proxy
authoralex-z <blackslayer4@gmail.com>
Fri, 28 Jan 2022 15:35:28 +0000 (17:35 +0200)
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>
Wed, 2 Feb 2022 10:02:34 +0000 (10:02 +0000)
Signed-off-by: alex-z <blackslayer4@gmail.com>
NEXTCLOUD.cmake
config.h.in
src/gui/application.cpp
src/gui/networksettings.cpp
src/libsync/theme.cpp
src/libsync/theme.h

index d34e682af89bbd5cbcad642856d3141718ede266..70725bd337525254ce9aa213affd7ec8989ae5af 100644 (file)
@@ -36,6 +36,8 @@ option( WITH_PROVIDERS "Build with providers list" ON )
 
 option( ENFORCE_VIRTUAL_FILES_SYNC_FOLDER "Enforce use of virtual files sync folder when available" OFF )
 
+option( DO_NOT_USE_PROXY "Do not use system wide proxy, instead always do a direct connection to server" OFF )
+
 ## Theming options
 set(NEXTCLOUD_BACKGROUND_COLOR "#0082c9" CACHE STRING "Default Nextcloud background color")
 set( APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR ${NEXTCLOUD_BACKGROUND_COLOR} CACHE STRING "Hex color of the wizard header background")
index e9eff6c929629eef492b5647eeb3766b60e56c78..1e8cb6e65fbd1423a57ec8348859ed9eed20c9f4 100644 (file)
@@ -33,6 +33,7 @@
 #cmakedefine APPLICATION_FORBID_BAD_SSL "@APPLICATION_FORBID_BAD_SSL@"
 #define APPLICATION_DOTVIRTUALFILE_SUFFIX "." APPLICATION_VIRTUALFILE_SUFFIX
 #cmakedefine01 ENFORCE_VIRTUAL_FILES_SYNC_FOLDER
+#cmakedefine DO_NOT_USE_PROXY "@DO_NOT_USE_PROXY@"
 
 #cmakedefine ZLIB_FOUND @ZLIB_FOUND@
 
index a7137743f4627729ffee4d54c3a26a712ee1f487..e6dd3914260822587435ae184ca24945c1561af4 100644 (file)
@@ -250,6 +250,10 @@ Application::Application(int &argc, char **argv)
         }
     }
 
+    if (_theme->doNotUseProxy()) {
+        ConfigFile().setProxyType(QNetworkProxy::NoProxy);
+    }
+
     parseOptions(arguments());
     //no need to waste time;
     if (_helpOnly || _versionOnly)
index 1c3631d4f9ff6e11bc60c8fd8d1e96e4202e353b..7e00b97ac5f9ef34dd9e825442025720f22f7d65 100644 (file)
@@ -34,41 +34,50 @@ NetworkSettings::NetworkSettings(QWidget *parent)
 {
     _ui->setupUi(this);
 
-    _ui->hostLineEdit->setPlaceholderText(tr("Hostname of proxy server"));
-    _ui->userLineEdit->setPlaceholderText(tr("Username for proxy server"));
-    _ui->passwordLineEdit->setPlaceholderText(tr("Password for proxy server"));
-
-    _ui->typeComboBox->addItem(tr("HTTP(S) proxy"), QNetworkProxy::HttpProxy);
-    _ui->typeComboBox->addItem(tr("SOCKS5 proxy"), QNetworkProxy::Socks5Proxy);
-
-    _ui->authRequiredcheckBox->setEnabled(true);
-
-    // Explicitly set up the enabled status of the proxy auth widgets to ensure
-    // toggling the parent enables/disables the children
-    _ui->userLineEdit->setEnabled(true);
-    _ui->passwordLineEdit->setEnabled(true);
-    _ui->authWidgets->setEnabled(_ui->authRequiredcheckBox->isChecked());
-    connect(_ui->authRequiredcheckBox, &QAbstractButton::toggled,
-        _ui->authWidgets, &QWidget::setEnabled);
-
-    connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled,
-        _ui->manualSettings, &QWidget::setEnabled);
-    connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled,
-        _ui->typeComboBox, &QWidget::setEnabled);
-    connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled,
-        this, &NetworkSettings::checkAccountLocalhost);
-
-    loadProxySettings();
-    loadBWLimitSettings();
+    _ui->proxyGroupBox->setVisible(!Theme::instance()->doNotUseProxy());
+
+    if (!Theme::instance()->doNotUseProxy()) {
+        _ui->hostLineEdit->setPlaceholderText(tr("Hostname of proxy server"));
+        _ui->userLineEdit->setPlaceholderText(tr("Username for proxy server"));
+        _ui->passwordLineEdit->setPlaceholderText(tr("Password for proxy server"));
+
+        _ui->typeComboBox->addItem(tr("HTTP(S) proxy"), QNetworkProxy::HttpProxy);
+        _ui->typeComboBox->addItem(tr("SOCKS5 proxy"), QNetworkProxy::Socks5Proxy);
+
+        _ui->authRequiredcheckBox->setEnabled(true);
+
+        // Explicitly set up the enabled status of the proxy auth widgets to ensure
+        // toggling the parent enables/disables the children
+        _ui->userLineEdit->setEnabled(true);
+        _ui->passwordLineEdit->setEnabled(true);
+        _ui->authWidgets->setEnabled(_ui->authRequiredcheckBox->isChecked());
+        connect(_ui->authRequiredcheckBox, &QAbstractButton::toggled, _ui->authWidgets, &QWidget::setEnabled);
+
+        connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled, _ui->manualSettings, &QWidget::setEnabled);
+        connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled, _ui->typeComboBox, &QWidget::setEnabled);
+        connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled, this, &NetworkSettings::checkAccountLocalhost);
+
+        loadProxySettings();
+
+        connect(_ui->typeComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
+            &NetworkSettings::saveProxySettings);
+        connect(_ui->proxyButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
+            &NetworkSettings::saveProxySettings);
+        connect(_ui->hostLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings);
+        connect(_ui->userLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings);
+        connect(_ui->passwordLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings);
+        connect(_ui->portSpinBox, &QAbstractSpinBox::editingFinished, this, &NetworkSettings::saveProxySettings);
+        connect(_ui->authRequiredcheckBox, &QAbstractButton::toggled, this, &NetworkSettings::saveProxySettings);
+
+        // Warn about empty proxy host
+        connect(_ui->hostLineEdit, &QLineEdit::textChanged, this, &NetworkSettings::checkEmptyProxyHost);
+        checkEmptyProxyHost();
+        checkAccountLocalhost();
+    } else {
+        _ui->noProxyRadioButton->setChecked(false);
+    }
 
-    // proxy
-    connect(_ui->typeComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &NetworkSettings::saveProxySettings);
-    connect(_ui->proxyButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &NetworkSettings::saveProxySettings);
-    connect(_ui->hostLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings);
-    connect(_ui->userLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings);
-    connect(_ui->passwordLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings);
-    connect(_ui->portSpinBox, &QAbstractSpinBox::editingFinished, this, &NetworkSettings::saveProxySettings);
-    connect(_ui->authRequiredcheckBox, &QAbstractButton::toggled, this, &NetworkSettings::saveProxySettings);
+    loadBWLimitSettings();
 
     connect(_ui->uploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings);
     connect(_ui->noUploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings);
@@ -78,11 +87,6 @@ NetworkSettings::NetworkSettings(QWidget *parent)
     connect(_ui->autoDownloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings);
     connect(_ui->downloadSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &NetworkSettings::saveBWLimitSettings);
     connect(_ui->uploadSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &NetworkSettings::saveBWLimitSettings);
-
-    // Warn about empty proxy host
-    connect(_ui->hostLineEdit, &QLineEdit::textChanged, this, &NetworkSettings::checkEmptyProxyHost);
-    checkEmptyProxyHost();
-    checkAccountLocalhost();
 }
 
 NetworkSettings::~NetworkSettings()
index ff7f58e607ff056026a8488bf8ae0c0c5af0e5a7..02322bc1078770d8d8dc91527252e48cab575370 100644 (file)
@@ -417,6 +417,15 @@ bool Theme::forbidBadSSL() const
 #endif
 }
 
+bool Theme::doNotUseProxy() const
+{
+#ifdef DO_NOT_USE_PROXY
+    return true;
+#else
+    return false;
+#endif
+}
+
 QString Theme::forceConfigAuthType() const
 {
     return QString();
index 6b9aefb255a7618d748f5cd3f8a89292499efed8..64786a03ec403194a33932327a6941e0e61566b2 100644 (file)
@@ -254,6 +254,13 @@ public:
      */
     virtual bool forbidBadSSL() const;
 
+    /**
+     * Forbid use of proxy
+     *
+     * When true, the app always connects to the server directly
+     */
+    virtual 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".