diff --git a/NEXTCLOUD.cmake b/NEXTCLOUD.cmake index d34e682af89bb..70725bd337525 100644 --- a/NEXTCLOUD.cmake +++ b/NEXTCLOUD.cmake @@ -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") diff --git a/config.h.in b/config.h.in index e9eff6c929629..1e8cb6e65fbd1 100644 --- a/config.h.in +++ b/config.h.in @@ -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@ diff --git a/src/gui/application.cpp b/src/gui/application.cpp index a7137743f4627..e6dd391426082 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -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) diff --git a/src/gui/networksettings.cpp b/src/gui/networksettings.cpp index 1c3631d4f9ff6..7e00b97ac5f9e 100644 --- a/src/gui/networksettings.cpp +++ b/src/gui/networksettings.cpp @@ -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(&QComboBox::currentIndexChanged), this, + &NetworkSettings::saveProxySettings); + connect(_ui->proxyButtonGroup, static_cast(&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(&QComboBox::currentIndexChanged), this, &NetworkSettings::saveProxySettings); - connect(_ui->proxyButtonGroup, static_cast(&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(&QSpinBox::valueChanged), this, &NetworkSettings::saveBWLimitSettings); connect(_ui->uploadSpinBox, static_cast(&QSpinBox::valueChanged), this, &NetworkSettings::saveBWLimitSettings); - - // Warn about empty proxy host - connect(_ui->hostLineEdit, &QLineEdit::textChanged, this, &NetworkSettings::checkEmptyProxyHost); - checkEmptyProxyHost(); - checkAccountLocalhost(); } NetworkSettings::~NetworkSettings() diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index ff7f58e607ff0..02322bc107877 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -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(); diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 6b9aefb255a76..64786a03ec403 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -254,6 +254,13 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject */ 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".