Cmake option to disable proxy

Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
alex-z 2022-01-28 17:35:28 +02:00 committed by Matthieu Gallien (Rebase PR Action)
parent ceb13aa53c
commit 0ea7e8d3a6
6 changed files with 61 additions and 34 deletions

View 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")

View 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@

View 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)

View file

@ -34,6 +34,9 @@ NetworkSettings::NetworkSettings(QWidget *parent)
{
_ui->setupUi(this);
_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"));
@ -48,28 +51,34 @@ NetworkSettings::NetworkSettings(QWidget *parent)
_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->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);
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();
// 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->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);
}
loadBWLimitSettings();
connect(_ui->uploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings);
connect(_ui->noUploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings);
connect(_ui->autoUploadLimitRadioButton, &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()

View 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();

View 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".