mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 10:16:34 +01:00
parent
35ceee25ee
commit
a73ad89f9e
@ -3,6 +3,7 @@ Version 1.5.0
|
||||
* added support for Proxy Auto-Config (PAC)
|
||||
* added option to open another private window from private window
|
||||
* added delete action in edit context menu on page
|
||||
* proxy exceptions now supports wildcards (*, ?)
|
||||
* cancel upload when trying to upload non-readable files
|
||||
* GreaseMonkey: added support for GM_Settings
|
||||
* fixed: size of preferences dialog on low-res screens
|
||||
|
@ -20,6 +20,46 @@
|
||||
#include "settings.h"
|
||||
#include "pac/pacmanager.h"
|
||||
|
||||
WildcardMatcher::WildcardMatcher(const QString &pattern)
|
||||
: m_regExp(0)
|
||||
{
|
||||
setPattern(pattern);
|
||||
}
|
||||
|
||||
WildcardMatcher::~WildcardMatcher()
|
||||
{
|
||||
delete m_regExp;
|
||||
}
|
||||
|
||||
void WildcardMatcher::setPattern(const QString &pattern)
|
||||
{
|
||||
m_pattern = pattern;
|
||||
|
||||
if (m_pattern.contains(QLatin1Char('?')) || m_pattern.contains(QLatin1Char('*'))) {
|
||||
QString regexp = m_pattern;
|
||||
regexp.replace(QLatin1Char('.'), QLatin1String("\\."))
|
||||
.replace(QLatin1Char('*'), QLatin1String(".*"))
|
||||
.replace(QLatin1Char('?'), QLatin1Char('.'));
|
||||
regexp = QString("^.*%1.*$").arg(regexp);
|
||||
|
||||
m_regExp = new QzRegExp(regexp, Qt::CaseInsensitive);
|
||||
}
|
||||
}
|
||||
|
||||
QString WildcardMatcher::pattern() const
|
||||
{
|
||||
return m_pattern;
|
||||
}
|
||||
|
||||
bool WildcardMatcher::match(const QString &str) const
|
||||
{
|
||||
if (!m_regExp) {
|
||||
return str.contains(m_pattern, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
return m_regExp->indexIn(str) > -1;
|
||||
}
|
||||
|
||||
NetworkProxyFactory::NetworkProxyFactory()
|
||||
: QNetworkProxyFactory()
|
||||
, m_pacManager(new PacManager)
|
||||
@ -45,9 +85,16 @@ void NetworkProxyFactory::loadSettings()
|
||||
m_httpsUsername = settings.value("HttpsUsername", QString()).toString();
|
||||
m_httpsPassword = settings.value("HttpsPassword", QString()).toString();
|
||||
|
||||
m_proxyExceptions = settings.value("ProxyExceptions", QStringList() << "localhost" << "127.0.0.1").toStringList();
|
||||
QStringList exceptions = settings.value("ProxyExceptions", QStringList() << "localhost" << "127.0.0.1").toStringList();
|
||||
settings.endGroup();
|
||||
|
||||
qDeleteAll(m_proxyExceptions);
|
||||
m_proxyExceptions.clear();
|
||||
|
||||
foreach (const QString &exception, exceptions) {
|
||||
m_proxyExceptions.append(new WildcardMatcher(exception.trimmed()));
|
||||
}
|
||||
|
||||
m_pacManager->loadSettings();
|
||||
}
|
||||
|
||||
@ -60,20 +107,24 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
|
||||
{
|
||||
QList<QNetworkProxy> proxyList;
|
||||
|
||||
if (m_proxyExceptions.contains(query.url().host(), Qt::CaseInsensitive)) {
|
||||
if (m_proxyPreference == NoProxy) {
|
||||
proxyList.append(QNetworkProxy::NoProxy);
|
||||
return proxyList;
|
||||
}
|
||||
|
||||
const QString &urlHost = query.url().host();
|
||||
foreach (WildcardMatcher* m, m_proxyExceptions) {
|
||||
if (m->match(urlHost)) {
|
||||
proxyList.append(QNetworkProxy::NoProxy);
|
||||
return proxyList;
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_proxyPreference) {
|
||||
case SystemProxy:
|
||||
proxyList.append(systemProxyForQuery(query));
|
||||
break;
|
||||
|
||||
case NoProxy:
|
||||
proxyList.append(QNetworkProxy::NoProxy);
|
||||
break;
|
||||
|
||||
case ProxyAutoConfig:
|
||||
proxyList.append(m_pacManager->queryProxy(query.url()));
|
||||
break;
|
||||
@ -113,3 +164,8 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
|
||||
|
||||
return proxyList;
|
||||
}
|
||||
|
||||
NetworkProxyFactory::~NetworkProxyFactory()
|
||||
{
|
||||
qDeleteAll(m_proxyExceptions);
|
||||
}
|
||||
|
@ -22,15 +22,33 @@
|
||||
#include <QStringList>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
#include "qzregexp.h"
|
||||
|
||||
class PacManager;
|
||||
|
||||
class WildcardMatcher
|
||||
{
|
||||
public:
|
||||
explicit WildcardMatcher(const QString &pattern = QString());
|
||||
~WildcardMatcher();
|
||||
|
||||
void setPattern(const QString &pattern);
|
||||
QString pattern() const;
|
||||
|
||||
bool match(const QString &str) const;
|
||||
|
||||
private:
|
||||
QString m_pattern;
|
||||
QzRegExp* m_regExp;
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT NetworkProxyFactory : public QNetworkProxyFactory
|
||||
{
|
||||
public:
|
||||
enum ProxyPreference { SystemProxy, NoProxy, ProxyAutoConfig, DefinedProxy };
|
||||
|
||||
explicit NetworkProxyFactory();
|
||||
~NetworkProxyFactory();
|
||||
|
||||
void loadSettings();
|
||||
PacManager* pacManager() const;
|
||||
@ -53,7 +71,7 @@ private:
|
||||
QString m_httpsUsername;
|
||||
QString m_httpsPassword;
|
||||
|
||||
QStringList m_proxyExceptions;
|
||||
QList<WildcardMatcher*> m_proxyExceptions;
|
||||
bool m_useDifferentProxyForHttps;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user