Rewrote the proxy configuration dialog to include missing SOCKS

proxy entry and make it much simpler to use.

BUG:82352
BUG:115704
BUG:139789
BUG:147340
BUG:164460
BUG:189019
BUG:190149
BUG:190901
BUG:205594
BUG:258196
BUG:283226
FIXED-IN:4.8

REVIEW: 102802

GUI:  Proxy configuration dialog rewrite.
This commit is contained in:
Dawit Alemayehu 2011-08-01 01:44:02 -04:00
parent eec9bc4432
commit f90f318f21
14 changed files with 1425 additions and 2306 deletions

View file

@ -11,9 +11,6 @@ set(kcm_kio_PART_SRCS
kcookiespolicyselectiondlg.cpp
smbrodlg.cpp
useragentdlg.cpp
kproxydlgbase.cpp
kmanualproxydlg.cpp
kenvvarproxydlg.cpp
kproxydlg.cpp
useragentinfo.cpp
useragentselectordlg.cpp
@ -27,8 +24,6 @@ kde4_add_ui_files(kcm_kio_PART_SRCS
cache.ui
useragentselectordlg.ui
useragentdlg.ui
manualproxy.ui
envvarproxy.ui
kproxydlg.ui
kcookiespolicies.ui
kcookiesmanagement.ui

View file

@ -1,251 +0,0 @@
<ui version="4.0" >
<class>EnvVarProxyDlgUI</class>
<widget class="QWidget" name="EnvVarProxyDlgUI" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>296</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="lbHttp" >
<property name="whatsThis" >
<string>&lt;qt>
Enter the name of the environment variable, e.g. &lt;b>HTTP_PROXY&lt;/b>, used to store the address of the HTTP proxy server.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt automatic discovery of this variable.&lt;/p&gt;
&lt;/qt></string>
</property>
<property name="text" >
<string>H&amp;TTP:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leHttp</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="leHttp" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" >
<string>&lt;qt>
Enter the name of the environment variable, e.g. &lt;b>HTTP_PROXY&lt;/b>, used to store the address of the HTTP proxy server.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt automatic discovery of this variable.&lt;/p&gt;
&lt;/qt></string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="lbHttps" >
<property name="whatsThis" >
<string>&lt;qt>
Enter the name of the environment variable, e.g. &lt;b>HTTPS_PROXY&lt;/b>, used to store the address of the HTTPS proxy server.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt an automatic discovery of this variable.&lt;/p&gt;
&lt;/qt></string>
</property>
<property name="text" >
<string>HTTP&amp;S:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leHttps</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="leHttps" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" >
<string>&lt;qt>
Enter the name of the environment variable, e.g. &lt;b>HTTPS_PROXY&lt;/b>, used to store the address of the HTTPS proxy server.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt an automatic discovery of this variable.&lt;/p&gt;
&lt;/qt></string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="lbFtp" >
<property name="whatsThis" >
<string>&lt;qt>
Enter the name of the environment variable, e.g. &lt;b>FTP_PROXY&lt;/b>, used to store the address of the FTP proxy server.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt an automatic discovery of this variable.&lt;/p&gt;
&lt;/qt></string>
</property>
<property name="text" >
<string>&amp;FTP:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leFtp</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="leFtp" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" >
<string>&lt;qt>
Enter the name of the environment variable, e.g. &lt;b>FTP_PROXY&lt;/b>, used to store the address of the FTP proxy server.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt an automatic discovery of this variable.&lt;/p&gt;
&lt;/qt></string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="lnNoProxy" >
<property name="whatsThis" >
<string>&lt;qt>
Enter the environment variable, e.g. &lt;b>NO_PROXY&lt;/b>, used to store the addresses of sites for which the proxy server should not be used.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt an automatic discovery of this variable.
&lt;/qt></string>
</property>
<property name="text" >
<string>NO &amp;PROXY:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leNoProxy</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KLineEdit" name="leNoProxy" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" >
<string>&lt;qt>
Enter the environment variable, e.g. &lt;b>NO_PROXY&lt;/b>, used to store the addresses of sites for which the proxy server should not be used.&lt;p>
Alternatively, you can click on the &lt;b>"Auto Detect"&lt;/b> button to attempt an automatic discovery of this variable.
&lt;/qt></string>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QCheckBox" name="cbShowValue" >
<property name="text" >
<string>Show the &amp;value of the environment variables</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1" >
<layout class="QVBoxLayout" >
<item>
<widget class="QPushButton" name="pbVerify" >
<property name="whatsThis" >
<string>&lt;qt>Verify whether or not the environment variable names you supplied are valid. If an environment variable is not found, the associated labels will be &lt;b>highlighted&lt;/b> to indicate that they are invalid.&lt;/qt></string>
</property>
<property name="text" >
<string>&amp;Verify</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbDetect" >
<property name="whatsThis" >
<string>&lt;qt>Attempt automatic discovery of the environment variables used for setting system wide proxy information.&lt;p> This feature works by searching for commonly used variable names such as HTTP_PROXY, FTP_PROXY and NO_PROXY.&lt;/qt></string>
</property>
<property name="text" >
<string>Auto &amp;Detect</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>16</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leHttp</tabstop>
<tabstop>leHttps</tabstop>
<tabstop>leFtp</tabstop>
<tabstop>leNoProxy</tabstop>
<tabstop>pbVerify</tabstop>
<tabstop>pbDetect</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View file

@ -1,310 +0,0 @@
/*
kenvvarproxydlg.cpp - Proxy configuration dialog
Copyright (C) 2001- Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License (GPL) version 2 as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// Local
#include "kenvvarproxydlg.h"
// std
#include <stdlib.h>
// Qt
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QCheckBox>
#include <QtGui/QPushButton>
// KDE
#include <kdebug.h>
#include <klocale.h>
#include <klineedit.h>
#include <kmessagebox.h>
#include <kurl.h>
#define ENV_FTP_PROXY "FTP_PROXY,ftp_proxy,FTPPROXY,ftpproxy,PROXY,proxy"
#define ENV_HTTP_PROXY "HTTP_PROXY,http_proxy,HTTPPROXY,httpproxy,PROXY,proxy"
#define ENV_HTTPS_PROXY "HTTPS_PROXY,https_proxy,HTTPSPROXY,httpsproxy,PROXY,proxy"
#define NO_PROXY "NO_PROXY,no_proxy"
KEnvVarProxyDlg::KEnvVarProxyDlg( QWidget* parent, const char* name )
:KProxyDialogBase( parent, name, true,
i18nc( "@title:window", "Variable Proxy Configuration" ) )
{
mDlg = new EnvVarProxyDlgUI( this );
setMainWidget( mDlg );
mDlg->leHttp->setMinimumWidth( mDlg->leHttp->fontMetrics().maxWidth() * 20 );
init();
}
KEnvVarProxyDlg::~KEnvVarProxyDlg ()
{
}
void KEnvVarProxyDlg::init()
{
m_bHasValidData = false;
connect( mDlg->cbShowValue, SIGNAL(clicked()), SLOT(showValue()) );
connect( mDlg->pbVerify, SIGNAL(clicked()), SLOT(verifyPressed()) );
connect( mDlg->pbDetect, SIGNAL(clicked()), SLOT(autoDetectPressed()) );
}
void KEnvVarProxyDlg::setProxyData( const KProxyData& data )
{
// Setup HTTP Proxy...
KUrl u ( data.proxyList["http"] );
if (!u.isEmpty() && !u.isValid())
{
mEnvVarsMap["http"].name = data.proxyList["http"];
mEnvVarsMap["http"].value = QString::fromLocal8Bit( getenv(data.proxyList["http"].toLocal8Bit()) );
}
// Setup HTTPS Proxy...
u = data.proxyList["https"];
if (!u.isEmpty() && !u.isValid())
{
mEnvVarsMap["https"].name = data.proxyList["https"];
mEnvVarsMap["https"].value = QString::fromLocal8Bit( getenv(data.proxyList["https"].toLocal8Bit()) );
}
// Setup FTP Proxy...
u = data.proxyList["ftp"];
if (!u.isEmpty() && !u.isValid())
{
mEnvVarsMap["ftp"].name = data.proxyList["ftp"];
mEnvVarsMap["ftp"].value = QString::fromLocal8Bit( getenv(data.proxyList["ftp"].toLocal8Bit()) );
}
u = data.noProxyFor.join(",");
if (!u.isEmpty() && !u.isValid())
{
QString noProxy = u.url();
mEnvVarsMap["noProxy"].name = noProxy;
mEnvVarsMap["noProxy"].value = QString::fromLocal8Bit( getenv(noProxy.toLocal8Bit()) );
}
mDlg->cbShowValue->setChecked( data.showEnvVarValue );
showValue();
}
const KProxyData KEnvVarProxyDlg::data() const
{
KProxyData data;
if (m_bHasValidData)
{
data.proxyList["http"] = mEnvVarsMap["http"].name;
data.proxyList["https"] = mEnvVarsMap["https"].name;
data.proxyList["ftp"] = mEnvVarsMap["ftp"].name;
data.noProxyFor = QStringList(mEnvVarsMap["noProxy"].name);
data.type = KProtocolManager::EnvVarProxy;
data.showEnvVarValue = mDlg->cbShowValue->isChecked();
}
return data;
}
void KEnvVarProxyDlg::verifyPressed()
{
if ( !validate() )
{
QString msg = i18n("You must specify at least one valid proxy "
"environment variable.");
QString details = i18n("<qt>Make sure you entered the actual environment "
"variable name rather than its value. For "
"example, if the environment variable is <br /><b>"
"HTTP_PROXY=http://localhost:3128</b><br /> you need "
"to enter <b>HTTP_PROXY</b> here instead of the "
"actual value http://localhost:3128.</qt>");
KMessageBox::detailedSorry( this, msg, details,
i18nc("@title:window", "Invalid Proxy Setup") );
}
else
{
KMessageBox::information( this, i18n("Successfully verified."),
i18nc("@title:window", "Proxy Setup") );
}
}
void KEnvVarProxyDlg::autoDetectPressed()
{
QString env;
QStringList::ConstIterator it;
bool found = false;
setHighLight (mDlg->lbHttp, false);
setHighLight (mDlg->lbHttps, false);
setHighLight (mDlg->lbFtp, false);
// Detect HTTP proxy settings...
QStringList list = QString::fromLatin1(ENV_HTTP_PROXY).split( ',', QString::SkipEmptyParts );
for( it = list.constBegin(); it != list.constEnd(); ++it )
{
env = QString::fromLocal8Bit( getenv( (*it).toLocal8Bit() ) );
if ( !env.isEmpty() )
{
mEnvVarsMap ["http"].name = *it;
mEnvVarsMap ["http"].value = env;
mDlg->leHttp->setText( (mDlg->cbShowValue->isChecked() ? env : *it) );
found = true;
break;
}
}
// Detect HTTPS proxy settings...
list = QString::fromLatin1(ENV_HTTPS_PROXY).split( ',', QString::SkipEmptyParts );
for( it = list.constBegin(); it != list.constEnd(); ++it )
{
env = QString::fromLocal8Bit( getenv( (*it).toLocal8Bit() ) );
if ( !env.isEmpty() )
{
mEnvVarsMap ["https"].name = *it;
mEnvVarsMap ["https"].value = env;
mDlg->leHttps->setText( (mDlg->cbShowValue->isChecked() ? env : *it) );
found = true;
break;
}
}
// Detect FTP proxy settings...
list = QString::fromLatin1(ENV_FTP_PROXY).split( ',', QString::SkipEmptyParts );
for(it = list.constBegin(); it != list.constEnd(); ++it )
{
env = QString::fromLocal8Bit( getenv( (*it).toLocal8Bit() ) );
if ( !env.isEmpty() )
{
mEnvVarsMap ["ftp"].name = *it;
mEnvVarsMap ["ftp"].value = env;
mDlg->leFtp->setText( (mDlg->cbShowValue->isChecked() ? env : *it) );
found = true;
break;
}
}
// Detect the NO_PROXY settings...
list = QString::fromLatin1(NO_PROXY).split (',', QString::SkipEmptyParts );
for(it = list.constBegin(); it != list.constEnd(); ++it )
{
env = QString::fromLocal8Bit( getenv( (*it).toLocal8Bit() ) );
if ( !env.isEmpty() )
{
mEnvVarsMap ["noProxy"].name = *it;
mEnvVarsMap ["noProxy"].value = env;
mDlg->leNoProxy->setText( (mDlg->cbShowValue->isChecked() ? env : *it) );
break;
}
}
if ( !found )
{
QString msg = i18n("Did not detect any environment variables "
"commonly used to set system wide proxy "
"information.");
QString details = i18n("<qt>To learn about the variable names the "
"automatic detection process searches for, "
"press OK, click on the quick help button "
"on the window title bar of the "
"previous dialog and then click on the "
"\"<b>Auto Detect</b>\" button.</qt>");
KMessageBox::detailedSorry( this, msg, details,
i18nc("@title:window", "Automatic Proxy Variable Detection") );
}
}
void KEnvVarProxyDlg::showValue()
{
bool enable = mDlg->cbShowValue->isChecked();
mDlg->leHttp->setReadOnly (enable);
mDlg->leHttps->setReadOnly (enable);
mDlg->leFtp->setReadOnly (enable);
mDlg->leNoProxy->setReadOnly (enable);
if (enable)
{
mDlg->leHttp->setText( mEnvVarsMap["http"].value );
mDlg->leHttps->setText( mEnvVarsMap["https"].value );
mDlg->leFtp->setText( mEnvVarsMap["ftp"].value );
mDlg->leNoProxy->setText( mEnvVarsMap["noProxy"].value );
}
else
{
mDlg->leHttp->setText( mEnvVarsMap["http"].name );
mDlg->leHttps->setText( mEnvVarsMap["https"].name );
mDlg->leFtp->setText( mEnvVarsMap["ftp"].name );
mDlg->leNoProxy->setText( mEnvVarsMap["noProxy"].name );
}
}
bool KEnvVarProxyDlg::validate()
{
int count = 0;
QString value = mEnvVarsMap["http"].value;
if ( !value.isEmpty() )
count++;
value = mEnvVarsMap["https"].value;
if ( !value.isEmpty() )
count++;
value = mEnvVarsMap["ftp"].value;
if ( !value.isEmpty() )
count++;
m_bHasValidData = (count > 0);
return m_bHasValidData;
}
void KEnvVarProxyDlg::accept()
{
if ( !validate() )
{
setHighLight (mDlg->lbHttp, true);
setHighLight (mDlg->lbHttps, true);
setHighLight (mDlg->lbFtp, true);
QString msg = i18n("You must specify at least one valid proxy "
"environment variable.");
QString details = i18n("<qt>Make sure you entered the actual environment "
"variable name rather than its value. For "
"example, if the environment variable is <br /><b>"
"HTTP_PROXY=http://localhost:3128</b><br /> you need "
"to enter <b>HTTP_PROXY</b> here instead of the "
"actual value http://localhost:3128.</qt>");
KMessageBox::detailedError( this, msg, details,
i18nc("@title:window", "Invalid Proxy Setup") );
return;
}
KDialog::accept();
}
#include "kenvvarproxydlg.moc"

View file

@ -1,71 +0,0 @@
/*
kenvvarproxydlg.h - Base dialog box for proxy configuration
Copyright (C) 2001- Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License (GPL) version 2 as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KENVVARPROXYDLG_H
#define KENVVARPROXYDLG_H
#include <QtCore/QMap>
#include "kproxydlgbase.h"
#include "ui_envvarproxy.h"
class EnvVarProxyDlgUI : public QWidget, public Ui::EnvVarProxyDlgUI
{
public:
EnvVarProxyDlgUI( QWidget *parent ) : QWidget( parent ) {
setupUi( this );
}
};
class KEnvVarProxyDlg : public KProxyDialogBase
{
Q_OBJECT
public:
explicit KEnvVarProxyDlg( QWidget* parent = 0, const char* name = 0 );
~KEnvVarProxyDlg();
virtual const KProxyData data() const;
virtual void setProxyData( const KProxyData &data );
protected Q_SLOTS:
virtual void accept();
void showValue();
void verifyPressed();
void autoDetectPressed();
protected:
void init();
bool validate();
private:
EnvVarProxyDlgUI* mDlg;
struct EnvVarPair {
QString name;
QString value;
};
QMap<QString, EnvVarPair> mEnvVarsMap;
};
#endif // KENVVARPROXYDLG_H

View file

@ -1,496 +0,0 @@
/*
kmanualproxydlg.cpp - Proxy configuration dialog
Copyright (C) 2001-2004 Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License (GPL) version 2 as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// Own
#include "kmanualproxydlg.h"
// Qt
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
// KDE
#include <kdebug.h>
#include <kiconloader.h>
#include <kicontheme.h>
#include <kinputdialog.h>
#include <kio/ioslave_defaults.h>
#include <klineedit.h>
#include <klistwidget.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <knuminput.h>
#include <kurifilter.h>
KManualProxyDlg::KManualProxyDlg( QWidget* parent, const char* name )
:KProxyDialogBase( parent, name, true,
i18nc("@title:window", "Manual Proxy Configuration") )
{
mDlg = new ManualProxyDlgUI (this);
setMainWidget(mDlg);
mDlg->pbCopyDown->setIcon( KIcon("go-down") );
QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
sizePolicy.setHeightForWidth( mDlg->pbCopyDown->sizePolicy().hasHeightForWidth() );
mDlg->pbCopyDown->setSizePolicy( sizePolicy );
init();
}
void KManualProxyDlg::init()
{
mDlg->sbHttp->setRange( 0, MAX_PORT_VALUE );
mDlg->sbHttps->setRange( 0, MAX_PORT_VALUE );
mDlg->sbFtp->setRange( 0, MAX_PORT_VALUE );
connect( mDlg->pbNew, SIGNAL(clicked()), SLOT(newPressed()) );
connect( mDlg->pbChange, SIGNAL(clicked()), SLOT(changePressed()) );
connect( mDlg->pbDelete, SIGNAL(clicked()), SLOT(deletePressed()) );
connect( mDlg->pbDeleteAll, SIGNAL(clicked()), SLOT(deleteAllPressed()) );
connect( mDlg->lbExceptions, SIGNAL(itemSelectionChanged()), SLOT(updateButtons()) );
connect( mDlg->lbExceptions, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(changePressed()));
connect( mDlg->cbSameProxy, SIGNAL(toggled(bool)), SLOT(sameProxy(bool)) );
connect( mDlg->pbCopyDown, SIGNAL(clicked()), SLOT(copyDown()) );
connect( mDlg->leHttp, SIGNAL(textChanged(QString)), SLOT(textChanged(QString)) );
connect( mDlg->sbHttp, SIGNAL(valueChanged(int)), SLOT(valueChanged(int)) );
connect( this, SIGNAL(okClicked()), this, SLOT(slotOk()));
}
void KManualProxyDlg::setProxyData( const KProxyData &data )
{
KUrl url;
// Set the HTTP proxy...
if (!isValidURL(data.proxyList["http"], &url))
mDlg->sbHttp->setValue( DEFAULT_PROXY_PORT );
else
{
int port = url.port();
if ( port <= 0 )
port = DEFAULT_PROXY_PORT;
url.setPort( -1 );
mDlg->leHttp->setText( url.url() );
mDlg->sbHttp->setValue( port );
}
bool useSameProxy = (!mDlg->leHttp->text().isEmpty () &&
data.proxyList["http"] == data.proxyList["https"] &&
data.proxyList["http"] == data.proxyList["ftp"]);
mDlg->cbSameProxy->setChecked ( useSameProxy );
if ( useSameProxy )
{
mDlg->leHttps->setText ( mDlg->leHttp->text() );
mDlg->leFtp->setText ( mDlg->leHttp->text() );
mDlg->sbHttps->setValue( mDlg->sbHttp->value() );
mDlg->sbFtp->setValue( mDlg->sbHttp->value() );
sameProxy ( true );
}
else
{
// Set the HTTPS proxy...
if( !isValidURL( data.proxyList["https"], &url ) )
mDlg->sbHttps->setValue( DEFAULT_PROXY_PORT );
else
{
int port = url.port();
if ( port <= 0 )
port = DEFAULT_PROXY_PORT;
url.setPort( -1 );
mDlg->leHttps->setText( url.url() );
mDlg->sbHttps->setValue( port );
}
// Set the FTP proxy...
if( !isValidURL( data.proxyList["ftp"], &url ) )
mDlg->sbFtp->setValue( DEFAULT_PROXY_PORT );
else
{
int port = url.port();
if ( port <= 0 )
port = DEFAULT_PROXY_PORT;
url.setPort( -1 );
mDlg->leFtp->setText( url.url() );
mDlg->sbFtp->setValue( port );
}
}
QStringList::ConstIterator it = data.noProxyFor.begin();
for( ; it != data.noProxyFor.end(); ++it )
{
// "no_proxy" is a keyword used by the environment variable
// based configuration. We ignore it here as it is not applicable...
if ((*it).toLower() != "no_proxy" && !(*it).isEmpty())
{
// Validate the NOPROXYFOR entries and use only hostnames if the entry is
// a valid or legitimate URL. NOTE: needed to catch manual manipulation
// of the proxy config files...
if( isValidURL( *it ) || ((*it).length() >= 3 && (*it).startsWith('.')) )
mDlg->lbExceptions->addItem( *it );
}
}
mDlg->cbReverseProxy->setChecked( data.useReverseProxy );
}
const KProxyData KManualProxyDlg::data() const
{
KProxyData data;
if (!m_bHasValidData)
return data;
data.proxyList["http"] = urlFromInput( mDlg->leHttp, mDlg->sbHttp );
if ( mDlg->cbSameProxy->isChecked () )
{
data.proxyList["https"] = data.proxyList["http"];
data.proxyList["ftp"] = data.proxyList["http"];
}
else
{
data.proxyList["https"] = urlFromInput( mDlg->leHttps, mDlg->sbHttps );
data.proxyList["ftp"] = urlFromInput( mDlg->leFtp, mDlg->sbFtp );
}
if ( mDlg->lbExceptions->count() )
{
for ( int rowIndex = 0 ; rowIndex < mDlg->lbExceptions->count() ; rowIndex++ ) {
data.noProxyFor << mDlg->lbExceptions->item(rowIndex)->text();
}
}
data.type = KProtocolManager::ManualProxy;
data.useReverseProxy = mDlg->cbReverseProxy->isChecked();
return data;
}
void KManualProxyDlg::sameProxy( bool enable )
{
mDlg->leHttps->setEnabled (!enable );
mDlg->leFtp->setEnabled (!enable );
mDlg->sbHttps->setEnabled (!enable );
mDlg->sbFtp->setEnabled (!enable );
mDlg->pbCopyDown->setEnabled( !enable );
if (enable)
{
mOldFtpText = mDlg->leFtp->text();
mOldHttpsText = mDlg->leHttps->text();
mOldFtpPort = mDlg->sbFtp->value();
mOldHttpsPort = mDlg->sbHttps->value();
int port = mDlg->sbHttp->value();
QString text = mDlg->leHttp->text();
mDlg->leFtp->setText (text);
mDlg->leHttps->setText (text);
mDlg->sbFtp->setValue (port);
mDlg->sbHttps->setValue (port);
if (mDlg->lbHttps->font().bold())
setHighLight( mDlg->lbHttps, false );
if (mDlg->lbFtp->font().bold())
setHighLight( mDlg->lbFtp, false );
}
else
{
mDlg->leFtp->setText (mOldFtpText);
mDlg->leHttps->setText (mOldHttpsText);
mDlg->sbFtp->setValue (mOldFtpPort);
mDlg->sbHttps->setValue (mOldHttpsPort);
}
}
bool KManualProxyDlg::validate()
{
KUrl filteredURL;
unsigned short count = 0;
if ( isValidURL( mDlg->leHttp->text(), &filteredURL ) )
{
mDlg->leHttp->setText( filteredURL.url() );
count++;
}
else
setHighLight( mDlg->lbHttp, true );
if ( !mDlg->cbSameProxy->isChecked () )
{
if ( isValidURL( mDlg->leHttps->text(), &filteredURL ) )
{
mDlg->leHttps->setText( filteredURL.url() );
count++;
}
else
setHighLight( mDlg->lbHttps, true );
if ( isValidURL( mDlg->leFtp->text(), &filteredURL ) )
{
mDlg->leFtp->setText( filteredURL.url() );
count++;
}
else
setHighLight( mDlg->lbFtp, true );
}
if ( count == 0 )
{
showErrorMsg( i18nc("@title:window", "Invalid Proxy Setting"),
i18n("One or more of the specified proxy settings are "
"invalid. The incorrect entries are highlighted.") );
}
return (count > 0);
}
void KManualProxyDlg::textChanged(const QString& text)
{
if (!mDlg->cbSameProxy->isChecked())
return;
mDlg->leFtp->setText( text );
mDlg->leHttps->setText( text );
}
void KManualProxyDlg::valueChanged(int value)
{
if (!mDlg->cbSameProxy->isChecked())
return;
mDlg->sbFtp->setValue (value);
mDlg->sbHttps->setValue (value);
}
void KManualProxyDlg::copyDown()
{
int action = -1;
if ( !mDlg->leHttp->text().isEmpty() )
action += 4;
else if ( !mDlg->leHttps->text().isEmpty() )
action += 3;
switch ( action )
{
case 3:
mDlg->leHttps->setText( mDlg->leHttp->text() );
mDlg->sbHttps->setValue( mDlg->sbHttp->value() );
mDlg->leFtp->setText( mDlg->leHttp->text() );
mDlg->sbFtp->setValue( mDlg->sbHttp->value() );
break;
case 2:
mDlg->leFtp->setText( mDlg->leHttps->text() );
mDlg->sbFtp->setValue( mDlg->sbHttps->value() );
break;
case 1:
case 0:
default:
break;
}
}
void KManualProxyDlg::slotOk()
{
if ( m_bHasValidData || validate() )
m_bHasValidData = true;
}
bool KManualProxyDlg::handleDuplicate( const QString& site )
{
for ( int rowIndex = 0 ; rowIndex < mDlg->lbExceptions->count() ; rowIndex++ )
{
QListWidgetItem* item = mDlg->lbExceptions->item(rowIndex);
if ( item->text().lastIndexOf( site ) != -1 &&
item != mDlg->lbExceptions->currentItem() )
{
QString msg = i18n("You entered a duplicate address. "
"Please try again.");
QString details = i18n("<qt><center><b>%1</b></center> "
"is already in the list.</qt>", site);
KMessageBox::detailedError( this, msg, details, i18nc("@title:window", "Duplicate Entry") );
return true;
}
}
return false;
}
void KManualProxyDlg::newPressed()
{
QString result;
if( getException(result, i18nc("@title:window", "New Exception")) && !handleDuplicate(result) )
mDlg->lbExceptions->addItem( result );
}
void KManualProxyDlg::changePressed()
{
QString result;
if( getException( result, i18nc("@title:window", "Change Exception"),
mDlg->lbExceptions->currentItem()->text() ) &&
!handleDuplicate( result ) )
mDlg->lbExceptions->currentItem()->setText(result);
}
void KManualProxyDlg::deletePressed()
{
delete mDlg->lbExceptions->takeItem( mDlg->lbExceptions->currentRow() );
if(mDlg->lbExceptions->currentItem())
mDlg->lbExceptions->currentItem()->setSelected(true);
updateButtons();
}
void KManualProxyDlg::deleteAllPressed()
{
mDlg->lbExceptions->clear();
updateButtons();
}
void KManualProxyDlg::updateButtons()
{
bool hasItems = mDlg->lbExceptions->count() > 0;
bool itemSelected = (hasItems && mDlg->lbExceptions->currentItem()!=0);
mDlg->pbDeleteAll->setEnabled( hasItems );
mDlg->pbDelete->setEnabled( itemSelected );
mDlg->pbChange->setEnabled( itemSelected );
}
QString KManualProxyDlg::urlFromInput(const KLineEdit* edit,
const KIntSpinBox* spin) const
{
if (!edit || edit->text().isEmpty())
return QString();
KUrl u( edit->text() );
if (spin)
u.setPort( spin->value() );
return u.url();
}
bool KManualProxyDlg::isValidURL( const QString& _url, KUrl* result ) const
{
KUrl url (_url);
QStringList filters;
filters << "kshorturifilter" << "localdomainurifilter";
// If the typed URL is malformed, and the filters cannot filter it
// then it must be an invalid entry.
if( !(url.isValid() && KUriFilter::self()->filterUri(url, filters) &&
url.hasHost()) )
return false;
QString host (url.host());
// We only check for a relevant subset of characters that are
// not allowed in <authority> component of a URL.
if ( host.contains ('*') || host.contains (' ') || host.contains ('?') )
return false;
if ( result )
*result = url;
return true;
}
void KManualProxyDlg::showErrorMsg( const QString& caption,
const QString& message )
{
QString cap( caption );
QString msg( message );
if ( cap.isEmpty() )
cap = i18nc("@title:window", "Invalid Entry");
if ( msg.isEmpty() )
msg = i18n("The address you have entered is not valid.");
QString details = i18n("<qt>Make sure none of the addresses or URLs you "
"specified contain invalid or wildcard characters "
"such as spaces, asterisks (*), or question marks(?).<br /><br />"
"<u>Examples of VALID entries:</u><br />"
"<code>http://mycompany.com, 192.168.10.1, "
"mycompany.com, localhost, http://localhost</code><br /><br />"
"<u>Examples of INVALID entries:</u><br />"
"<code>http://my company.com, http:/mycompany,com "
"file:/localhost</code></qt>");
KMessageBox::detailedError( this, msg, details, cap );
}
bool KManualProxyDlg::getException ( QString& result,
const QString& caption,
const QString& value )
{
QString label;
// Specify the appropriate message...
if ( mDlg->cbReverseProxy->isChecked() )
label = i18n("Enter the URL or address that should use the above proxy "
"settings:");
else
label = i18n("Enter the address or URL that should be excluded from "
"using the above proxy settings:");
QString whatsThis = i18n("<qt>Enter a valid address or URL.<br /><br />"
"<b><u>NOTE:</u></b> Wildcard matching such as "
"<code>*.kde.org</code> is not supported. If you want "
"to match any host in the <code>.kde.org</code> domain, "
"e.g. <code>printing.kde.org</code>, then simply enter "
"<code>.kde.org</code>.</qt>");
bool ok;
result = KInputDialog::getText( caption, label, value, &ok, this,
0, QString(), whatsThis );
// If the user pressed cancel, do nothing...
if (!ok)
return false;
// If the typed URL is malformed, and the filters cannot filter it
// then it must be an invalid entry,
if( isValidURL(result) || (result.length() >= 3 && result.startsWith('.')))
return true;
showErrorMsg();
return false;
}
#include "kmanualproxydlg.moc"

View file

@ -1,86 +0,0 @@
/*
kmanualproxydlg.h - Base dialog box for proxy configuration
Copyright (C) 2001-2004 Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License (GPL) version 2 as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KMANUALPROXYDLG_H
#define KMANUALPROXYDLG_H
#include "kproxydlgbase.h"
#include "ui_manualproxy.h"
class KIntSpinBox;
class KLineEdit;
class ManualProxyDlgUI : public QWidget, public Ui::ManualProxyDlgUI
{
public:
ManualProxyDlgUI( QWidget *parent ) : QWidget( parent ) {
setupUi( this );
}
};
class KManualProxyDlg : public KProxyDialogBase
{
Q_OBJECT
public:
explicit KManualProxyDlg( QWidget* parent = 0, const char* name = 0 );
~KManualProxyDlg() {}
virtual void setProxyData( const KProxyData &data );
virtual const KProxyData data() const;
protected:
void init();
bool validate();
protected Q_SLOTS:
virtual void slotOk();
void copyDown();
void sameProxy( bool );
void valueChanged (int value);
void textChanged (const QString&);
void newPressed();
void updateButtons();
void changePressed();
void deletePressed();
void deleteAllPressed();
private:
QString urlFromInput( const KLineEdit* edit, const KIntSpinBox* spin ) const;
bool isValidURL( const QString&, KUrl* = 0 ) const;
bool handleDuplicate( const QString& );
bool getException ( QString&, const QString&,
const QString& value = QString() );
void showErrorMsg( const QString& caption = QString(),
const QString& message = QString() );
private:
ManualProxyDlgUI* mDlg;
int mOldFtpPort;
int mOldHttpsPort;
QString mOldFtpText;
QString mOldHttpsText;
};
#endif // KMANUALPROXYDLG_H

View file

@ -1,7 +1,7 @@
/*
kproxydlg.cpp - Proxy configuration dialog
Copyright (C) 2001- Dawit Alemayehu <adawit@kde.org>
Copyright (C) 2001, 2011 Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
@ -22,57 +22,236 @@
// Own
#include "kproxydlg.h"
// Qt
#include <QtCore/QRegExp>
#include <QtGui/QBoxLayout>
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QRadioButton>
#include <QtGui/QTabWidget>
// Local
#include "ksaveioconfig.h"
// KDE
#include <kpluginfactory.h>
#include <klineedit.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kurifilter.h>
#include <kdebug.h>
// Local
#include "kenvvarproxydlg.h"
#include "kmanualproxydlg.h"
#include "ksaveioconfig.h"
// Qt
#include <QtGui/QLabel>
#include <QtGui/QRadioButton>
#include <QtGui/QLineEdit>
#include <QtGui/QSpinBox>
K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory)
KProxyDialog::KProxyDialog(QWidget *parent, const QVariantList &args)
#define QL1C(x) QLatin1Char(x)
#define QL1S(x) QLatin1String(x)
#define ENV_HTTP_PROXY QL1S("HTTP_PROXY,http_proxy,HTTPPROXY,httpproxy,PROXY,proxy")
#define ENV_HTTPS_PROXY QL1S("HTTPS_PROXY,https_proxy,HTTPSPROXY,httpsproxy,PROXY,proxy")
#define ENV_FTP_PROXY QL1S("FTP_PROXY,ftp_proxy,FTPPROXY,ftpproxy,PROXY,proxy")
#define ENV_SOCKS_PROXY QL1S("SOCKS_PROXY,socks_proxy,SOCKSPROXY,socksproxy,PROXY,proxy")
#define ENV_NO_PROXY QL1S("NO_PROXY,no_proxy")
K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory)
class InputValidator : public QValidator
{
public:
State validate(QString& input, int& pos) const {
const QChar ch = input.at((pos > 0 ? pos - 1 : pos));
if (ch.isSpace())
return Invalid;
return Acceptable;
}
};
static QString manualProxyToText(const QLineEdit* edit, const QSpinBox* spinBox, const QChar& separator)
{
QString value;
value = edit->text();
value += separator;
value += QString::number(spinBox->value());
return value;
}
static void setManualProxyFromText(const QString& value, QLineEdit* edit, QSpinBox* spinBox)
{
if (value.isEmpty())
return;
const QStringList values = value.split(QL1S(" "));
edit->setText(values.at(0));
bool ok = false;
const int num = values.at(1).toInt(&ok);
if (ok) {
spinBox->setValue(num);
}
}
static void showSystemProxyUrl(QLineEdit* edit, QString* value)
{
Q_ASSERT(edit);
Q_ASSERT(value);
*value = edit->text();
edit->setEnabled(false);
const QByteArray envVar(edit->text().toUtf8());
edit->setText(QString::fromUtf8(qgetenv(envVar.constData())));
}
static bool autoDetectSystemProxy(QLineEdit* edit, const QString& envVarStr)
{
const QStringList envVars = envVarStr.split(QL1S(","), QString::SkipEmptyParts);
Q_FOREACH (const QString & envVar, envVars) {
const QByteArray envVarUtf8(envVar.toUtf8());
if (!qgetenv(envVarUtf8.constData()).isEmpty()) {
edit->setText(envVarStr);
return true;
}
}
return false;
}
static void extractProxyUrlFromInput(QString* proxyStr, KProxyDialog::DisplayUrlFlags* flags,
const QLineEdit* edit, const QSpinBox* spinBox,
KProxyDialog::DisplayUrlFlag flag = KProxyDialog::HideNone)
{
Q_ASSERT(edit);
Q_ASSERT(spinBox);
Q_ASSERT(proxyStr);
proxyStr->clear();
if (flags && !edit->text().contains("://")) {
*flags |= flag;
}
KUriFilterData data;
data.setData(edit->text());
if (KUriFilter::self()->filterUri(data, QStringList() << QL1S("kshorturifilter"))) {
KUrl url = data.uri();
const int portNum = (spinBox->value() > 0 ? spinBox->value() : url.port());
url.setPort(-1);
*proxyStr = url.url();
*proxyStr += QL1C(' ');
if (portNum > -1) {
*proxyStr += QString::number(portNum);
}
}
}
static void setProxyInformation(const QString& value,
int proxyType,
QLineEdit* manEdit,
QLineEdit* sysEdit,
QSpinBox* spinBox ,
KProxyDialog::DisplayUrlFlag flag)
{
if (value.isEmpty()) {
return;
}
const bool isSysProxy = (!value.contains(QL1C('.'))
&& !value.contains(QL1C(','))
&& !value.contains(QL1S("://")));
if (proxyType == KProtocolManager::EnvVarProxy || isSysProxy) {
#if defined(Q_OS_LINUX) || defined (Q_OS_UNIX)
sysEdit->setText(value);
#endif
return;
}
if (spinBox) {
KUrl url;
int portNum = -1;
const int index = value.lastIndexOf(QL1C(' '));
if (index > 0) {
bool ok = false;
portNum = value.mid(index+1).toInt(&ok);
if (!ok) {
portNum = -1;
}
url = value.left(index).trimmed();
} else {
url = value.trimmed();
}
if (!url.isValid()) {
return;
}
if (portNum == -1 && url.port() > -1) {
portNum = url.port();
}
url.setPort(-1);
url.setUser(QString());
url.setPass(QString());
url.setPath(QString());
manEdit->setText(((KSaveIOConfig::proxyDisplayUrlFlags() & flag) ? url.host(): url.url()));
if (spinBox && portNum > -1) {
spinBox->setValue(portNum);
}
return;
}
manEdit->setText(value); // Manual proxy exception...
}
KProxyDialog::KProxyDialog(QWidget* parent, const QVariantList& args)
: KCModule(KioConfigFactory::componentData(), parent)
{
Q_UNUSED(args);
mUi.setupUi(this);
Q_UNUSED(args);
mUi.setupUi(this);
// signals and slots connections
connect( mUi.rbNoProxy, SIGNAL(toggled(bool)),
SLOT(slotUseProxyChanged()) );
mUi.systemProxyGroupBox->setVisible(false);
mUi.manualProxyGroupBox->setVisible(false);
mUi.autoDetectButton->setVisible(false);
mUi.proxyConfigScriptGroupBox->setVisible(false);
connect( mUi.rbAutoDiscover, SIGNAL(toggled(bool)),
SLOT(slotChanged()) );
connect( mUi.rbAutoScript, SIGNAL(toggled(bool)),
SLOT(slotChanged()) );
InputValidator* v = new InputValidator;
mUi.proxyScriptUrlRequester->lineEdit()->setValidator(v);
mUi.manualProxyHttpEdit->setValidator(v);
mUi.manualProxyHttpsEdit->setValidator(v);
mUi.manualProxyFtpEdit->setValidator(v);
mUi.manualProxySocksEdit->setValidator(v);
mUi.manualNoProxyEdit->setValidator(v);
connect( mUi.rbPrompt, SIGNAL(toggled(bool)),
SLOT(slotChanged()) );
connect( mUi.rbPresetLogin, SIGNAL(toggled(bool)),
SLOT(slotChanged()) );
#if defined(Q_OS_LINUX) || defined (Q_OS_UNIX)
connect(mUi.systemProxyRadioButton, SIGNAL(toggled(bool)), mUi.systemProxyGroupBox, SLOT(setVisible(bool)));
#else
mUi.autoDetectButton->setVisible(false);
#endif
connect( mUi.cbPersConn, SIGNAL(toggled(bool)),
SLOT(slotChanged()) );
// signals and slots connections
connect(mUi.noProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged()));
connect(mUi.autoDiscoverProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged()));
connect(mUi.autoScriptProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged()));
connect(mUi.manualProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged()));
connect(mUi.noProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged()));
connect(mUi.useReverseProxyCheckBox, SIGNAL(clicked()), SLOT(slotChanged()));
connect(mUi.useSameProxyCheckBox, SIGNAL(clicked()), SLOT(slotChanged()));
connect( mUi.location, SIGNAL(textChanged(QString)),
SLOT(slotChanged()) );
connect(mUi.proxyScriptUrlRequester, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect( mUi.pbEnvSetup, SIGNAL(clicked()), SLOT(setupEnvProxy()) );
connect( mUi.pbManSetup, SIGNAL(clicked()), SLOT(setupManProxy()) );
connect(mUi.manualProxyHttpEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.manualProxyHttpsEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.manualProxyFtpEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.manualProxySocksEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.manualNoProxyEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.systemProxyHttpEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.systemProxyHttpsEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.systemProxyFtpEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.systemProxySocksEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
connect(mUi.systemNoProxyEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged()));
}
KProxyDialog::~KProxyDialog()
@ -81,234 +260,250 @@ KProxyDialog::~KProxyDialog()
void KProxyDialog::load()
{
mDefaultData = false;
mProxyMap[QL1S("HttpProxy")] = KProtocolManager::proxyFor(QL1S("http"));
mProxyMap[QL1S("HttpsProxy")] = KProtocolManager::proxyFor(QL1S("https"));
mProxyMap[QL1S("FtpProxy")] = KProtocolManager::proxyFor(QL1S("ftp"));
mProxyMap[QL1S("SocksProxy")] = KProtocolManager::proxyFor(QL1S("socks"));
mProxyMap[QL1S("ProxyScript")] = KProtocolManager::proxyConfigScript();
mProxyMap[QL1S("NoProxy")] = KProtocolManager::noProxyFor();
KProtocolManager proto;
bool useProxy = proto.useProxy();
mData.type = proto.proxyType();
mData.proxyList["http"] = proto.proxyFor( "http" );
mData.proxyList["https"] = proto.proxyFor( "https" );
mData.proxyList["ftp"] = proto.proxyFor( "ftp" );
mData.proxyList["script"] = proto.proxyConfigScript();
mData.useReverseProxy = proto.useReverseProxy();
mData.noProxyFor = proto.noProxyFor().split( QRegExp("[',''\t'' ']"), QString::SkipEmptyParts);
const int proxyType = KProtocolManager::proxyType();
mUi.gbAuth->setEnabled( useProxy );
mUi.gbOptions->setEnabled( useProxy );
setProxyInformation(mProxyMap.value(QL1S("HttpProxy")), proxyType, mUi.manualProxyHttpEdit, mUi.systemProxyHttpEdit, mUi.manualProxyHttpSpinBox, HideHttpUrlScheme);
setProxyInformation(mProxyMap.value(QL1S("HttpsProxy")), proxyType, mUi.manualProxyHttpsEdit, mUi.systemProxyHttpsEdit, mUi.manualProxyHttpsSpinBox, HideHttpsUrlScheme);
setProxyInformation(mProxyMap.value(QL1S("FtpProxy")), proxyType, mUi.manualProxyFtpEdit, mUi.systemProxyFtpEdit, mUi.manualProxyFtpSpinBox, HideFtpUrlScheme);
setProxyInformation(mProxyMap.value(QL1S("SocksProxy")), proxyType, mUi.manualProxySocksEdit, mUi.systemProxySocksEdit, mUi.manualProxySocksSpinBox, HideSocksUrlScheme);
setProxyInformation(mProxyMap.value(QL1S("NoProxy")), proxyType, mUi.manualNoProxyEdit, mUi.systemNoProxyEdit, 0, HideNone);
mUi.cbPersConn->setChecked( proto.persistentProxyConnection() );
// Check the "Use this proxy server for all protocols" if all the proxy URLs are the same...
const QString httpProxy(mUi.manualProxyHttpEdit->text());
if (!httpProxy.isEmpty()) {
const int httpProxyPort = mUi.manualProxyHttpSpinBox->value();
mUi.useSameProxyCheckBox->setChecked(httpProxy == mUi.manualProxyHttpsEdit->text() &&
httpProxy == mUi.manualProxyFtpEdit->text() &&
httpProxy == mUi.manualProxySocksEdit->text() &&
httpProxyPort == mUi.manualProxyHttpsSpinBox->value() &&
httpProxyPort == mUi.manualProxyFtpSpinBox->value() &&
httpProxyPort == mUi.manualProxySocksSpinBox->value());
}
if ( !mData.proxyList["script"].isEmpty() )
mUi.location->lineEdit()->setText( mData.proxyList["script"] );
// Validate and Set the automatic proxy configuration script url.
KUrl u (mProxyMap.value(QL1S("ProxyScript")));
if (u.isValid() && !u.isEmpty()) {
u.setUser (QString());
u.setPass (QString());
mUi.proxyScriptUrlRequester->setUrl(u);
}
switch ( mData.type )
{
// Set use reverse proxy checkbox...
mUi.useReverseProxyCheckBox->setChecked((!mProxyMap.value(QL1S("NoProxy")).isEmpty()
&& KProtocolManager::useReverseProxy()));
switch (proxyType) {
case KProtocolManager::WPADProxy:
mUi.rbAutoDiscover->setChecked( true );
break;
mUi.autoDiscoverProxyRadioButton->setChecked(true);
break;
case KProtocolManager::PACProxy:
mUi.rbAutoScript->setChecked( true );
break;
mUi.autoScriptProxyRadioButton->setChecked(true);
break;
case KProtocolManager::ManualProxy:
mUi.rbManual->setChecked( true );
break;
mUi.manualProxyRadioButton->setChecked(true);
break;
case KProtocolManager::EnvVarProxy:
mUi.rbEnvVar->setChecked( true );
break;
mUi.systemProxyRadioButton->setChecked(true);
break;
case KProtocolManager::NoProxy:
default:
mUi.rbNoProxy->setChecked( true );
break;
}
switch( proto.proxyAuthMode() )
{
case KProtocolManager::Prompt:
mUi.rbPrompt->setChecked( true );
break;
case KProtocolManager::Automatic:
mUi.rbPresetLogin->setChecked( true );
default:
break;
}
mUi.noProxyRadioButton->setChecked(true);
break;
}
}
void KProxyDialog::save()
{
bool updateProxyScout = false;
KProtocolManager::ProxyType proxyType = KProtocolManager::NoProxy;
DisplayUrlFlags displayUrlFlags = HideNone;
if (mDefaultData)
mData.reset ();
if ( mUi.rbNoProxy->isChecked() )
{
KSaveIOConfig::setProxyType( KProtocolManager::NoProxy );
}
else
{
if ( mUi.rbAutoDiscover->isChecked() )
{
KSaveIOConfig::setProxyType( KProtocolManager::WPADProxy );
updateProxyScout = true;
}
else if ( mUi.rbAutoScript->isChecked() )
{
KUrl u( mUi.location->lineEdit()->text() );
if ( !u.isValid() )
{
showInvalidMessage( i18n("The address of the automatic proxy "
"configuration script is invalid. Please "
"correct this problem before proceeding. "
"Otherwise, your changes will be "
"ignored.") );
return;
}
else
{
KSaveIOConfig::setProxyType( KProtocolManager::PACProxy );
mData.proxyList["script"] = u.url();
updateProxyScout = true;
}
}
else if ( mUi.rbManual->isChecked() )
{
if ( mData.type != KProtocolManager::ManualProxy )
{
// Let's try a bit harder to determine if the previous
// proxy setting was indeed a manual proxy
KUrl u ( mData.proxyList["http"] );
bool validProxy = (u.isValid() && u.port() > 0);
u = mData.proxyList["https"];
validProxy = validProxy || (u.isValid() && u.port() > 0);
u = mData.proxyList["ftp"];
validProxy = validProxy || (u.isValid() && u.port() > 0);
if (!validProxy)
{
showInvalidMessage();
return;
}
mData.type = KProtocolManager::ManualProxy;
}
KSaveIOConfig::setProxyType( KProtocolManager::ManualProxy );
}
else if ( mUi.rbEnvVar->isChecked() )
{
if ( mData.type != KProtocolManager::EnvVarProxy )
{
showInvalidMessage();
return;
}
KSaveIOConfig::setProxyType( KProtocolManager::EnvVarProxy );
if (mUi.manualProxyRadioButton->isChecked()) {
proxyType = KProtocolManager::ManualProxy;
extractProxyUrlFromInput(&mProxyMap[QL1S("HttpProxy")], &displayUrlFlags, mUi.manualProxyHttpEdit, mUi.manualProxyHttpSpinBox, HideHttpUrlScheme);
extractProxyUrlFromInput(&mProxyMap[QL1S("HttpsProxy")], &displayUrlFlags, mUi.manualProxyHttpsEdit, mUi.manualProxyHttpsSpinBox, HideHttpsUrlScheme);
extractProxyUrlFromInput(&mProxyMap[QL1S("FtpProxy")], &displayUrlFlags, mUi.manualProxyFtpEdit, mUi.manualProxyFtpSpinBox, HideFtpUrlScheme);
extractProxyUrlFromInput(&mProxyMap[QL1S("SocksProxy")], &displayUrlFlags, mUi.manualProxySocksEdit, mUi.manualProxySocksSpinBox, HideSocksUrlScheme);
mProxyMap[QL1S("NoProxy")] = mUi.manualNoProxyEdit->text();
} else if (mUi.systemProxyRadioButton->isChecked()) {
proxyType = KProtocolManager::EnvVarProxy;
mProxyMap[QL1S("HttpProxy")] = mUi.systemProxyHttpEdit->text();
mProxyMap[QL1S("HttpsProxy")] = mUi.systemProxyHttpsEdit->text();
mProxyMap[QL1S("FtpProxy")] = mUi.systemProxyFtpEdit->text();
mProxyMap[QL1S("SocksProxy")] = mUi.systemProxySocksEdit->text();
mProxyMap[QL1S("NoProxy")] = mUi.systemNoProxyEdit->text();
} else if (mUi.autoScriptProxyRadioButton->isChecked()) {
proxyType = KProtocolManager::PACProxy;
mProxyMap[QL1S("ProxyScript")] = mUi.proxyScriptUrlRequester->text();
} else if (mUi.autoDiscoverProxyRadioButton->isChecked()) {
proxyType = KProtocolManager::WPADProxy;
}
if ( mUi.rbPrompt->isChecked() )
KSaveIOConfig::setProxyAuthMode( KProtocolManager::Prompt );
else if ( mUi.rbPresetLogin->isChecked() )
KSaveIOConfig::setProxyAuthMode( KProtocolManager::Automatic );
}
KSaveIOConfig::setProxyType(proxyType);
KSaveIOConfig::setProxyDisplayUrlFlags(displayUrlFlags);
KSaveIOConfig::setUseReverseProxy(mUi.useReverseProxyCheckBox->isChecked());
KSaveIOConfig::setPersistentProxyConnection( mUi.cbPersConn->isChecked() );
// Save the common proxy setting...
KSaveIOConfig::setProxyDisplayUrlFlags (displayUrlFlags);
KSaveIOConfig::setProxyFor(QL1S("http"), mProxyMap.value(QL1S("HttpProxy")));
KSaveIOConfig::setProxyFor(QL1S("https"), mProxyMap.value(QL1S("HttpsProxy")));
KSaveIOConfig::setProxyFor(QL1S("ftp"), mProxyMap.value(QL1S("FtpProxy")));
KSaveIOConfig::setProxyFor(QL1S("socks"), mProxyMap.value(QL1S("SocksProxy")));
// Save the common proxy setting...
KSaveIOConfig::setProxyFor( "ftp", mData.proxyList["ftp"] );
KSaveIOConfig::setProxyFor( "http", mData.proxyList["http"] );
KSaveIOConfig::setProxyFor( "https", mData.proxyList["https"] );
KSaveIOConfig::setProxyConfigScript (mProxyMap.value(QL1S("ProxyScript")));
KSaveIOConfig::setNoProxyFor (mProxyMap.value(QL1S("NoProxy")));
KSaveIOConfig::setProxyConfigScript( mData.proxyList["script"] );
KSaveIOConfig::setUseReverseProxy( mData.useReverseProxy );
KSaveIOConfig::setNoProxyFor( mData.noProxyFor.join(",") );
KSaveIOConfig::updateRunningIOSlaves (this);
if (proxyType == KProtocolManager::PACProxy || proxyType == KProtocolManager::WPADProxy) {
KSaveIOConfig::updateProxyScout (this);
}
KSaveIOConfig::updateRunningIOSlaves (this);
if ( updateProxyScout )
KSaveIOConfig::updateProxyScout( this );
emit changed( false );
emit changed (false);
}
void KProxyDialog::defaults()
{
mDefaultData = true;
mUi.rbNoProxy->setChecked( true );
mUi.location->lineEdit()->clear();
mUi.cbPersConn->setChecked( false );
mUi.noProxyRadioButton->setChecked(true);
mUi.proxyScriptUrlRequester->clear();
mUi.manualProxyHttpEdit->clear();
mUi.manualProxyHttpsEdit->clear();
mUi.manualProxyFtpEdit->clear();
mUi.manualProxySocksEdit->clear();
mUi.manualNoProxyEdit->clear();
mUi.manualProxyHttpSpinBox->setValue(0);
mUi.manualProxyHttpsSpinBox->setValue(0);
mUi.manualProxyFtpSpinBox->setValue(0);
mUi.manualProxySocksSpinBox->setValue(0);
mUi.systemProxyHttpEdit->clear();
mUi.systemProxyHttpsEdit->clear();
mUi.systemProxyFtpEdit->clear();
mUi.systemProxySocksEdit->clear();
emit changed (true);
}
void KProxyDialog::setupManProxy()
void KProxyDialog::on_autoDetectButton_clicked()
{
KManualProxyDlg dlgManual( this );
quint8 count = 0;
count += (autoDetectSystemProxy(mUi.systemProxyHttpEdit, ENV_HTTP_PROXY) ? 1 : 0);
count += (autoDetectSystemProxy(mUi.systemProxyHttpsEdit, ENV_HTTPS_PROXY) ? 1 : 0);
count += (autoDetectSystemProxy(mUi.systemProxyFtpEdit, ENV_FTP_PROXY) ? 1 : 0);
count += (autoDetectSystemProxy(mUi.systemProxySocksEdit, ENV_SOCKS_PROXY) ? 1 : 0);
count += (autoDetectSystemProxy(mUi.systemNoProxyEdit, ENV_NO_PROXY) ? 1 : 0);
dlgManual.setProxyData( mData );
if ( dlgManual.exec() == QDialog::Accepted )
{
mData = dlgManual.data();
mUi.rbManual->setChecked(true);
emit changed( true );
}
if (count)
emit changed (true);
}
void KProxyDialog::setupEnvProxy()
void KProxyDialog::on_manualProxyHttpEdit_textChanged(const QString& text)
{
KEnvVarProxyDlg dlgEnv( this );
mUi.useSameProxyCheckBox->setEnabled(!text.isEmpty());
}
dlgEnv.setProxyData( mData );
void KProxyDialog::on_manualNoProxyEdit_textChanged (const QString& text)
{
mUi.useReverseProxyCheckBox->setEnabled(!text.isEmpty());
}
if ( dlgEnv.exec() == QDialog::Accepted )
{
mData = dlgEnv.data();
mUi.rbEnvVar->setChecked(true);
emit changed( true );
}
void KProxyDialog::on_manualProxyHttpEdit_textEdited(const QString& text)
{
if (!mUi.useSameProxyCheckBox->isChecked()) {
return;
}
mUi.manualProxyHttpsEdit->setText(text);
mUi.manualProxyFtpEdit->setText(text);
mUi.manualProxySocksEdit->setText(text);
}
void KProxyDialog::on_manualProxyHttpSpinBox_valueChanged (int value)
{
if (!mUi.useSameProxyCheckBox->isChecked()) {
return;
}
mUi.manualProxyHttpsSpinBox->setValue(value);
mUi.manualProxyFtpSpinBox->setValue(value);
mUi.manualProxySocksSpinBox->setValue(value);
}
void KProxyDialog::on_showEnvValueCheckBox_toggled (bool on)
{
if (on) {
showSystemProxyUrl(mUi.systemProxyHttpEdit, &mProxyMap[QL1S("EnvVarProxyHttp")]);
showSystemProxyUrl(mUi.systemProxyHttpsEdit, &mProxyMap[QL1S("EnvVarProxyHttps")]);
showSystemProxyUrl(mUi.systemProxyFtpEdit, &mProxyMap[QL1S("EnvVarProxyFtp")]);
showSystemProxyUrl(mUi.systemProxySocksEdit, &mProxyMap[QL1S("EnvVarProxySocks")]);
showSystemProxyUrl(mUi.systemNoProxyEdit, &mProxyMap[QL1S("EnvVarNoProxy")]);
return;
}
mUi.systemProxyHttpEdit->setText(mProxyMap.take (QL1S("EnvVarProxyHttp")));
mUi.systemProxyHttpEdit->setEnabled(true);
mUi.systemProxyHttpsEdit->setText(mProxyMap.take (QL1S("EnvVarProxyHttps")));
mUi.systemProxyHttpsEdit->setEnabled(true);
mUi.systemProxyFtpEdit->setText(mProxyMap.take (QL1S("EnvVarProxyFtp")));
mUi.systemProxyFtpEdit->setEnabled(true);
mUi.systemProxySocksEdit->setText(mProxyMap.take (QL1S("EnvVarProxySocks")));
mUi.systemProxySocksEdit->setEnabled(true);
mUi.systemNoProxyEdit->setText(mProxyMap.take (QL1S("EnvVarNoProxy")));
mUi.systemNoProxyEdit->setEnabled(true);
}
void KProxyDialog::on_useSameProxyCheckBox_clicked(bool on)
{
if (on) {
mProxyMap[QL1S("ManProxyHttps")] = manualProxyToText (mUi.manualProxyHttpsEdit, mUi.manualProxyHttpsSpinBox, QL1C (' '));
mProxyMap[QL1S("ManProxyFtp")] = manualProxyToText (mUi.manualProxyFtpEdit, mUi.manualProxyFtpSpinBox, QL1C (' '));
mProxyMap[QL1S("ManProxySocks")] = manualProxyToText (mUi.manualProxySocksEdit, mUi.manualProxySocksSpinBox, QL1C (' '));
const QString& httpProxy = mUi.manualProxyHttpEdit->text();
if (!httpProxy.isEmpty()) {
mUi.manualProxyHttpsEdit->setText(httpProxy);
mUi.manualProxyFtpEdit->setText(httpProxy);
mUi.manualProxySocksEdit->setText(httpProxy);
}
const int httpProxyPort = mUi.manualProxyHttpSpinBox->value();
if (httpProxyPort > 0) {
mUi.manualProxyHttpsSpinBox->setValue(httpProxyPort);
mUi.manualProxyFtpSpinBox->setValue(httpProxyPort);
mUi.manualProxySocksSpinBox->setValue(httpProxyPort);
}
return;
}
setManualProxyFromText(mProxyMap.take (QL1S("ManProxyHttps")), mUi.manualProxyHttpsEdit, mUi.manualProxyHttpsSpinBox);
setManualProxyFromText(mProxyMap.take (QL1S("ManProxyFtp")), mUi.manualProxyFtpEdit, mUi.manualProxyFtpSpinBox);
setManualProxyFromText(mProxyMap.take (QL1S("ManProxySocks")), mUi.manualProxySocksEdit, mUi.manualProxySocksSpinBox);
}
void KProxyDialog::slotChanged()
{
mDefaultData = false;
emit changed( true );
}
void KProxyDialog::slotUseProxyChanged()
{
mDefaultData = false;
bool useProxy = !(mUi.rbNoProxy->isChecked());
mUi.gbAuth->setEnabled(useProxy);
mUi.gbOptions->setEnabled(useProxy);
emit changed( true );
emit changed(true);
}
QString KProxyDialog::quickHelp() const
{
return i18n( "<h1>Proxy</h1>"
"<p>A proxy server is an intermediate program that sits between "
"your machine and the Internet and provides services such as "
"web page caching and/or filtering.</p>"
"<p>Caching proxy servers give you faster access to sites you have "
"already visited by locally storing or caching the content of those "
"pages; filtering proxy servers, on the other hand, provide the "
"ability to block out requests for ads, spam, or anything else you "
"want to block.</p>"
"<p><u>Note:</u> Some proxy servers provide both services.</p>" );
}
void KProxyDialog::showInvalidMessage( const QString& _msg )
{
QString msg;
if( !_msg.isEmpty() )
msg = _msg;
else
msg = i18n( "<qt>The proxy settings you specified are invalid."
"<br /><br />Please click on the <b>Setup...</b> "
"button and correct the problem before proceeding; "
"otherwise your changes will be ignored.</qt>" );
KMessageBox::error( this, msg, i18nc("@title:window", "Invalid Proxy Setup") );
return i18n ("<h1>Proxy</h1>"
"<p>A proxy server is an intermediate program that sits between "
"your machine and the Internet and provides services such as "
"web page caching and/or filtering.</p>"
"<p>Caching proxy servers give you faster access to sites you have "
"already visited by locally storing or caching the content of those "
"pages; filtering proxy servers, on the other hand, provide the "
"ability to block out requests for ads, spam, or anything else you "
"want to block.</p>"
"<p><u>Note:</u> Some proxy servers provide both services.</p>");
}
#include "kproxydlg.moc"

View file

@ -1,7 +1,7 @@
/*
kproxydlg.h - Proxy configuration dialog
Copyright (C) 2001- Dawit Alemayehu <adawit@kde.org>
Copyright (C) 2001, 2011 Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
@ -23,36 +23,48 @@
#define KPROXYDLG_H
#include <kcmodule.h>
#include "kproxydlgbase.h"
#include "ui_kproxydlg.h"
class KProxyDialog : public KCModule
{
Q_OBJECT
Q_OBJECT
public:
KProxyDialog(QWidget *parent, const QVariantList &args);
~KProxyDialog();
enum DisplayUrlFlag {
HideNone = 0x00,
HideHttpUrlScheme = 0x01,
HideHttpsUrlScheme = 0x02,
HideFtpUrlScheme = 0x04,
HideSocksUrlScheme = 0x08
};
Q_DECLARE_FLAGS(DisplayUrlFlags, DisplayUrlFlag)
virtual void load();
virtual void save();
virtual void defaults();
QString quickHelp() const;
KProxyDialog(QWidget* parent, const QVariantList& args);
~KProxyDialog();
virtual void load();
virtual void save();
virtual void defaults();
QString quickHelp() const;
private Q_SLOTS:
void slotChanged();
void slotUseProxyChanged();
void on_autoDetectButton_clicked();
void on_showEnvValueCheckBox_toggled(bool);
void on_useSameProxyCheckBox_clicked(bool);
void setupManProxy();
void setupEnvProxy();
void on_manualProxyHttpEdit_textChanged(const QString&);
void on_manualNoProxyEdit_textChanged(const QString&);
void on_manualProxyHttpEdit_textEdited(const QString&);
void on_manualProxyHttpSpinBox_valueChanged(int);
void slotChanged();
private:
void showInvalidMessage( const QString& _msg = QString() );
private:
Ui::KProxyDialogUI mUi;
KProxyData mData;
bool mDefaultData;
Ui::ProxyDialogUI mUi;
QStringList mNoProxyForList;
QMap<QString, QString> mProxyMap;
};
Q_DECLARE_OPERATORS_FOR_FLAGS (KProxyDialog::DisplayUrlFlags)
#endif // KPROXYDLG_H

File diff suppressed because it is too large Load diff

View file

@ -1,79 +0,0 @@
/*
kproxydlgbase.h - Base dialog box for proxy configuration
Copyright (C) 2001- Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License (GPL) version 2 as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kproxydlgbase.h"
KProxyData::KProxyData()
{
init ();
}
KProxyData::KProxyData(const KProxyData &data)
{
(*this) = data;
}
KProxyData& KProxyData::operator=( const KProxyData &data )
{
useReverseProxy = data.useReverseProxy;
showEnvVarValue = data.showEnvVarValue;
noProxyFor = data.noProxyFor;
proxyList = data.proxyList;
type = data.type;
return (*this);
}
void KProxyData::reset()
{
init();
}
void KProxyData::init()
{
proxyList.clear();
noProxyFor.clear();
useReverseProxy = false;
showEnvVarValue = false;
}
KProxyDialogBase::KProxyDialogBase( QWidget* parent, const char* name,
bool modal, const QString &caption )
: KDialog( parent )
{
setObjectName( name );
setModal( modal );
setCaption( caption );
setButtons( Ok|Cancel );
m_bHasValidData = false;
}
void KProxyDialogBase::setHighLight (QWidget* widget, bool highlight)
{
if (!widget)
return;
QFont f = widget->font();
f.setBold( highlight );
widget->setFont( f );
}

View file

@ -1,69 +0,0 @@
/*
kproxydlgbase.h - Base dialog box for proxy configuration
Copyright (C) 2001- Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License (GPL) version 2 as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KPROXYDLGBASE_H
#define KPROXYDLGBASE_H
#include <QtCore/QMap>
#include <QtCore/QStringList>
#include <kdialog.h>
#include <kprotocolmanager.h>
class KProxyData
{
public:
KProxyData();
KProxyData( const KProxyData &data );
void reset ();
KProxyData& operator=( const KProxyData &data );
bool useReverseProxy;
bool showEnvVarValue;
QStringList noProxyFor;
KProtocolManager::ProxyType type;
QMap<QString, QString> proxyList;
private:
void init();
};
class KProxyDialogBase : public KDialog
{
public:
explicit KProxyDialogBase( QWidget* parent = 0, const char* name = 0,
bool modal = false, const QString &caption = QString());
virtual ~KProxyDialogBase() {}
virtual const KProxyData data() const=0;
virtual void setProxyData (const KProxyData&)=0;
protected:
void setHighLight (QWidget* widget = 0, bool highlight = false);
bool m_bHasValidData;
};
#endif // KPROXYDLGBASE_H

View file

@ -26,9 +26,10 @@
// KDE
#include <kconfig.h>
#include <klocale.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <kio/ioslave_defaults.h>
#include <kconfiggroup.h>
#include <kio/ioslave_defaults.h>
class KSaveIOConfigPrivate
{
@ -42,7 +43,8 @@ public:
K_GLOBAL_STATIC(KSaveIOConfigPrivate, d)
KSaveIOConfigPrivate::KSaveIOConfigPrivate (): config(0), http_config(0)
KSaveIOConfigPrivate::KSaveIOConfigPrivate ()
: config(0), http_config(0)
{
}
@ -68,6 +70,19 @@ static KConfig* http_config()
return d->http_config;
}
int KSaveIOConfig::proxyDisplayUrlFlags()
{
KConfigGroup cfg (config(), QString());
return cfg.readEntry("ProxyUrlDisplayFlags", 0);
}
void KSaveIOConfig::setProxyDisplayUrlFlags (int flags)
{
KConfigGroup cfg (config(), QString());
cfg.writeEntry("ProxyUrlDisplayFlags", flags);
cfg.sync();
}
void KSaveIOConfig::reparseConfiguration ()
{
delete d->config;
@ -78,170 +93,144 @@ void KSaveIOConfig::reparseConfiguration ()
void KSaveIOConfig::setReadTimeout( int _timeout )
{
KConfig* cfg = config();
cfg->group("").writeEntry("ReadTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry("ReadTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg.sync();
}
void KSaveIOConfig::setConnectTimeout( int _timeout )
{
KConfig* cfg = config();
cfg->group("").writeEntry("ConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry("ConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg.sync();
}
void KSaveIOConfig::setProxyConnectTimeout( int _timeout )
{
KConfig* cfg = config();
cfg->group("").writeEntry("ProxyConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry("ProxyConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg.sync();
}
void KSaveIOConfig::setResponseTimeout( int _timeout )
{
KConfig* cfg = config();
cfg->group("").writeEntry("ResponseTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry("ResponseTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
cfg.sync();
}
void KSaveIOConfig::setMarkPartial( bool _mode )
{
KConfig* cfg = config();
cfg->group("").writeEntry( "MarkPartial", _mode );
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry( "MarkPartial", _mode );
cfg.sync();
}
void KSaveIOConfig::setMinimumKeepSize( int _size )
{
KConfig* cfg = config();
cfg->group("").writeEntry( "MinimumKeepSize", _size );
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry( "MinimumKeepSize", _size );
cfg.sync();
}
void KSaveIOConfig::setAutoResume( bool _mode )
{
KConfig* cfg = config();
cfg->group("").writeEntry( "AutoResume", _mode );
cfg->sync();
KConfigGroup cfg (config(), QString());
cfg.writeEntry( "AutoResume", _mode );
cfg.sync();
}
void KSaveIOConfig::setUseCache( bool _mode )
{
KConfig* cfg = http_config();
cfg->group("").writeEntry( "UseCache", _mode );
cfg->sync();
KConfigGroup cfg (http_config(), QString());
cfg.writeEntry( "UseCache", _mode );
cfg.sync();
}
void KSaveIOConfig::setMaxCacheSize( int cache_size )
{
KConfig* cfg = http_config();
cfg->group("").writeEntry( "MaxCacheSize", cache_size );
cfg->sync();
KConfigGroup cfg (http_config(), QString());
cfg.writeEntry( "MaxCacheSize", cache_size );
cfg.sync();
}
void KSaveIOConfig::setCacheControl(KIO::CacheControl policy)
{
KConfig* cfg = http_config();
KConfigGroup cfg (http_config(), QString());
QString tmp = KIO::getCacheControlString(policy);
cfg->group("").writeEntry("cache", tmp);
cfg->sync();
cfg.writeEntry("cache", tmp);
cfg.sync();
}
void KSaveIOConfig::setMaxCacheAge( int cache_age )
{
KConfig* cfg = http_config();
cfg->group("").writeEntry( "MaxCacheAge", cache_age );
cfg->sync();
KConfigGroup cfg (http_config(), QString());
cfg.writeEntry( "MaxCacheAge", cache_age );
cfg.sync();
}
void KSaveIOConfig::setUseReverseProxy( bool mode )
{
KConfig* cfg = config();
cfg->group("Proxy Settings").writeEntry("ReversedException", mode);
cfg->sync();
KConfigGroup cfg (config(), "Proxy Settings");
cfg.writeEntry("ReversedException", mode);
cfg.sync();
}
void KSaveIOConfig::setProxyType(KProtocolManager::ProxyType type)
{
KConfig* cfg = config();
cfg->group("Proxy Settings").writeEntry( "ProxyType", static_cast<int>(type) );
cfg->sync();
}
void KSaveIOConfig::setProxyAuthMode(KProtocolManager::ProxyAuthMode mode)
{
KConfig* cfg = config();
cfg->group("Proxy Settings").writeEntry( "AuthMode", static_cast<int>(mode) );
cfg->sync();
KConfigGroup cfg (config(), "Proxy Settings");
cfg.writeEntry("ProxyType", static_cast<int>(type));
cfg.sync();
}
void KSaveIOConfig::setNoProxyFor( const QString& _noproxy )
{
KConfig* cfg = config();
cfg->group("Proxy Settings").writeEntry( "NoProxyFor", _noproxy );
cfg->sync();
KConfigGroup cfg (config(), "Proxy Settings");
cfg.writeEntry("NoProxyFor", _noproxy);
cfg.sync();
}
void KSaveIOConfig::setProxyFor( const QString& protocol,
const QString& _proxy )
{
KConfig* cfg = config();
cfg->group("Proxy Settings").writeEntry( protocol.toLower() + "Proxy", _proxy );
cfg->sync();
KConfigGroup cfg (config(), "Proxy Settings");
cfg.writeEntry(protocol.toLower() + "Proxy", _proxy);
cfg.sync();
}
void KSaveIOConfig::setProxyConfigScript( const QString& _url )
{
KConfig* cfg = config();
cfg->group("Proxy Settings").writeEntry( "Proxy Config Script", _url );
cfg->sync();
}
void KSaveIOConfig::setPersistentProxyConnection( bool enable )
{
KConfig* cfg = config();
cfg->group("").writeEntry( "PersistentProxyConnection", enable );
cfg->sync();
}
void KSaveIOConfig::setPersistentConnections( bool enable )
{
KConfig* cfg = config();
cfg->group("").writeEntry( "PersistentConnections", enable );
cfg->sync();
KConfigGroup cfg (config(), "Proxy Settings");
cfg.writeEntry("Proxy Config Script", _url);
cfg.sync();
}
void KSaveIOConfig::updateRunningIOSlaves (QWidget *parent)
{
// Inform all running io-slaves about the changes...
// if we cannot update, ioslaves inform the end user...
QDBusMessage message =
QDBusMessage::createSignal("/KIO/Scheduler", "org.kde.KIO.Scheduler", "reparseSlaveConfiguration");
QDBusMessage message = QDBusMessage::createSignal("/KIO/Scheduler", "org.kde.KIO.Scheduler", "reparseSlaveConfiguration");
message << QString();
if (!QDBusConnection::sessionBus().send(message))
{
QString caption = i18nc("@title:window", "Update Failed");
QString message = i18n("You have to restart the running applications "
"for these changes to take effect.");
KMessageBox::information (parent, message, caption);
return;
KMessageBox::information (parent,
i18n("You have to restart the running applications "
"for these changes to take effect."),
i18nc("@title:window", "Update Failed"));
}
}
void KSaveIOConfig::updateProxyScout( QWidget * parent )
{
// Inform the proxyscout kded module about changes
// if we cannot update, ioslaves inform the end user...
QDBusInterface kded("org.kde.kded", "/modules/proxyscout", "org.kde.KPAC.ProxyScout");
QDBusReply<void> reply = kded.call( "reset" );
// Inform the proxyscout kded module about changes if we cannot update,
// ioslaves inform the end user...
QDBusInterface kded("org.kde.kded", "/modules/proxyscout", "org.kde.KPAC.ProxyScout");
QDBusReply<void> reply = kded.call("reset");
if (!reply.isValid())
{
QString caption = i18nc("@title:window", "Update Failed");
QString message = i18n("You have to restart KDE "
"for these changes to take effect.");
KMessageBox::information (parent, message, caption);
return;
KMessageBox::information (parent,
i18n("You have to restart KDE for these changes to take effect."),
i18nc("@title:window", "Update Failed"));
}
}

View file

@ -26,60 +26,56 @@ class QWidget;
namespace KSaveIOConfig
{
/* Reload config file (kioslaverc) */
void reparseConfiguration();
int proxyDisplayUrlFlags();
void setProxyDisplayUrlFlags (int);
/** Timeout Settings */
void setReadTimeout( int );
/* Reload config file (kioslaverc) */
void reparseConfiguration();
void setConnectTimeout( int );
/** Timeout Settings */
void setReadTimeout (int);
void setProxyConnectTimeout( int );
void setConnectTimeout (int);
void setResponseTimeout( int );
void setProxyConnectTimeout (int);
void setResponseTimeout (int);
/** Cache Settings */
void setMaxCacheAge( int );
/** Cache Settings */
void setMaxCacheAge (int);
void setUseCache( bool );
void setUseCache (bool);
void setMaxCacheSize( int );
void setMaxCacheSize (int);
void setCacheControl( KIO::CacheControl );
void setCacheControl (KIO::CacheControl);
/** Proxy Settings */
void setUseReverseProxy( bool );
/** Proxy Settings */
void setUseReverseProxy (bool);
void setProxyType( KProtocolManager::ProxyType );
void setProxyType (KProtocolManager::ProxyType);
void setProxyAuthMode( KProtocolManager::ProxyAuthMode );
void setProxyConfigScript (const QString&);
void setProxyConfigScript( const QString& );
void setProxyFor (const QString&, const QString&);
void setProxyFor( const QString&, const QString& );
void setNoProxyFor( const QString& );
void setNoProxyFor (const QString&);
/** Miscellaneous Settings */
void setMarkPartial( bool );
/** Miscellaneous Settings */
void setMarkPartial (bool);
void setMinimumKeepSize( int );
void setMinimumKeepSize (int);
void setAutoResume( bool );
void setAutoResume (bool);
void setPersistentConnections( bool );
/** Update all running io-slaves */
void updateRunningIOSlaves (QWidget* parent = 0L);
void setPersistentProxyConnection( bool );
/** Update all running io-slaves */
void updateRunningIOSlaves (QWidget * parent = 0L);
/** Update proxy scout */
void updateProxyScout( QWidget * parent = 0L );
/** Update proxy scout */
void updateProxyScout (QWidget* parent = 0L);
}
#endif

View file

@ -1,291 +0,0 @@
<ui version="4.0" >
<class>ManualProxyDlgUI</class>
<widget class="QWidget" name="ManualProxyDlgUI" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>390</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="gbServers" >
<property name="title" >
<string>Ser&amp;vers</string>
</property>
<layout class="QGridLayout" >
<item row="2" column="0" >
<widget class="QLabel" name="lbFtp" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>&amp;FTP:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leFtp</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="lbHttps" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>HTTP&amp;S:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leHttps</cstring>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="lbHttp" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>H&amp;TTP:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<property name="buddy" >
<cstring>leHttp</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="leHttp" >
<property name="whatsThis" >
<string>Enter the address of the HTTP proxy server.</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="leHttps" >
<property name="whatsThis" >
<string>Enter the address of the HTTPS proxy server.</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="leFtp" >
<property name="whatsThis" >
<string>Enter the address of the FTP proxy server.</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="KIntSpinBox" name="sbFtp" >
<property name="whatsThis" >
<string>Enter the port number of the FTP proxy server. Default 8080. Another common value is 3128.</string>
</property>
<property name="maximum" >
<number>65536</number>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="KIntSpinBox" name="sbHttps" >
<property name="whatsThis" >
<string>Enter the port number of the HTTP proxy server. Default is 8080. Another common value is 3128.</string>
</property>
<property name="maximum" >
<number>65536</number>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="KIntSpinBox" name="sbHttp" >
<property name="maximumSize" >
<size>
<width>32767</width>
<height>32767</height>
</size>
</property>
<property name="whatsThis" >
<string>Enter the port number of the HTTP proxy server. Default is 8080. Another common value is 3128.</string>
</property>
<property name="maximum" >
<number>65536</number>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2" >
<widget class="QCheckBox" name="cbSameProxy" >
<property name="text" >
<string>&amp;Use the same proxy server for all protocols</string>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QPushButton" name="pbCopyDown" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbExceptions" >
<property name="title" >
<string>E&amp;xceptions</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="cbReverseProxy" >
<property name="whatsThis" >
<string>&lt;qt>
Reverse the use of the exception list. Checking this box will result in the proxy servers being used only when the requested URL matches one of the addresses listed here.&lt;p>This feature is useful if all you want or need is to use a proxy server for a few specific sites.&lt;p>If you have more complex requirements you might want to use a configuration script.
&lt;/qt></string>
</property>
<property name="text" >
<string>Use proxy only for entries in this list</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item row="3" column="1" >
<widget class="QPushButton" name="pbDeleteAll" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="whatsThis" >
<string>Remove all proxy exception addresses from the list.</string>
</property>
<property name="text" >
<string>D&amp;elete All</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QPushButton" name="pbDelete" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="whatsThis" >
<string>Remove the selected proxy exception address from the list.</string>
</property>
<property name="text" >
<string>De&amp;lete</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="pbNew" >
<property name="whatsThis" >
<string>Add new proxy exception address to the list.</string>
</property>
<property name="text" >
<string>&amp;New...</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="pbChange" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="whatsThis" >
<string>Change the selected proxy exception address.</string>
</property>
<property name="text" >
<string>C&amp;hange...</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>114</height>
</size>
</property>
</spacer>
</item>
<item rowspan="5" row="0" column="0" >
<widget class="KListWidget" name="lbExceptions" />
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KListWidget</class>
<extends>QListWidget</extends>
<header>klistwidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leHttp</tabstop>
<tabstop>sbHttp</tabstop>
<tabstop>leHttps</tabstop>
<tabstop>sbHttps</tabstop>
<tabstop>leFtp</tabstop>
<tabstop>sbFtp</tabstop>
<tabstop>cbSameProxy</tabstop>
<tabstop>pbCopyDown</tabstop>
<tabstop>cbReverseProxy</tabstop>
<tabstop>pbNew</tabstop>
<tabstop>pbChange</tabstop>
<tabstop>pbDelete</tabstop>
<tabstop>pbDeleteAll</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>