diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp
index d706c3232..be219786f 100644
--- a/src/libtomahawk/utils/tomahawkutils.cpp
+++ b/src/libtomahawk/utils/tomahawkutils.cpp
@@ -301,10 +301,11 @@ extensionToMimetype( const QString& extension )
return s_ext2mime.value( extension, "unknown" );
}
+static QMutex s_noProxyHostsMutex;
+static QStringList s_noProxyHosts;
NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other )
{
- m_noProxyHosts = QStringList( other.m_noProxyHosts );
m_proxy = QNetworkProxy( other.m_proxy );
}
@@ -312,13 +313,17 @@ NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other )
QList< QNetworkProxy >
NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query )
{
+ tDebug() << Q_FUNC_INFO << "query hostname is " << query.peerHostName();
QList< QNetworkProxy > proxies;
QString hostname = query.peerHostName();
- if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || m_noProxyHosts.contains( hostname ) || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy )
+ s_noProxyHostsMutex.lock();
+ if ( s_noProxyHosts.contains( hostname ) )
+ proxies << QNetworkProxy::NoProxy << systemProxyForQuery( query );
+ else if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy )
proxies << systemProxyForQuery( query );
else
proxies << m_proxy << systemProxyForQuery( query );
-
+ s_noProxyHostsMutex.unlock();
return proxies;
}
@@ -335,7 +340,9 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts )
//TODO: wildcard support
}
tDebug() << Q_FUNC_INFO << "New no-proxy hosts:" << newList;
- m_noProxyHosts = newList;
+ s_noProxyHostsMutex.lock();
+ s_noProxyHosts = newList;
+ s_noProxyHostsMutex.unlock();
}
@@ -357,7 +364,6 @@ NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs )
if ( this != &rhs )
{
m_proxy = QNetworkProxy( rhs.m_proxy );
- m_noProxyHosts = QStringList( rhs.m_noProxyHosts );
}
return *this;
@@ -367,7 +373,7 @@ NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs )
bool NetworkProxyFactory::operator==( const NetworkProxyFactory& other ) const
{
tDebug() << Q_FUNC_INFO;
- if ( m_noProxyHosts != other.m_noProxyHosts || m_proxy != other.m_proxy )
+ if ( m_proxy != other.m_proxy )
return false;
return true;
@@ -378,25 +384,29 @@ static QMap< QThread*, NetworkProxyFactory* > s_threadProxyFactoryHash;
static QMutex s_namAccessMutex;
NetworkProxyFactory*
-proxyFactory( bool noMutexLocker )
+proxyFactory( bool makeClone, bool noMutexLocker )
{
// Don't lock if being called from nam()
tDebug() << Q_FUNC_INFO;
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
- if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) )
- return s_threadProxyFactoryHash[ QThread::currentThread() ];
+ if ( !makeClone )
+ {
+ if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) )
+ return s_threadProxyFactoryHash[ QThread::currentThread() ];
- if ( !s_threadProxyFactoryHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) )
- return 0;
+ if ( !s_threadProxyFactoryHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) )
+ return 0;
+ }
// create a new proxy factory for this thread
TomahawkUtils::NetworkProxyFactory *mainProxyFactory = s_threadProxyFactoryHash[ TOMAHAWK_APPLICATION::instance()->thread() ];
TomahawkUtils::NetworkProxyFactory *newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
*newProxyFactory = *mainProxyFactory;
- s_threadProxyFactoryHash[ QThread::currentThread() ] = newProxyFactory;
+ if ( !makeClone )
+ s_threadProxyFactoryHash[ QThread::currentThread() ] = newProxyFactory;
return newProxyFactory;
}
@@ -455,7 +465,7 @@ nam()
newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) );
newNam->setNetworkAccessible( mainNam->networkAccessible() );
- newNam->setProxyFactory( proxyFactory( true ) );
+ newNam->setProxyFactory( proxyFactory( false, true ) );
s_threadNamHash[ QThread::currentThread() ] = newNam;
@@ -485,9 +495,15 @@ setNam( QNetworkAccessManager* nam, bool noMutexLocker )
QNetworkProxy proxy( s->proxyType(), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
proxyFactory->setProxy( proxy );
//FIXME: Jreen is broke without this
- QNetworkProxy::setApplicationProxy( proxy );
- if ( !s->proxyNoProxyHosts().isEmpty() )
+ //QNetworkProxy::setApplicationProxy( proxy );
+ s_noProxyHostsMutex.lock();
+ if ( !s->proxyNoProxyHosts().isEmpty() && s_noProxyHosts.isEmpty() )
+ {
+ s_noProxyHostsMutex.unlock();
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
+ }
+ else
+ s_noProxyHostsMutex.unlock();
}
nam->setProxyFactory( proxyFactory );
diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h
index f3133e112..c244bff63 100644
--- a/src/libtomahawk/utils/tomahawkutils.h
+++ b/src/libtomahawk/utils/tomahawkutils.h
@@ -92,7 +92,7 @@ namespace TomahawkUtils
DLLEXPORT QString extensionToMimetype( const QString& extension );
DLLEXPORT bool newerVersion( const QString& oldVersion, const QString& newVersion );
- DLLEXPORT NetworkProxyFactory* proxyFactory( bool noMutexLocker = false );
+ DLLEXPORT NetworkProxyFactory* proxyFactory( bool makeClone = false, bool noMutexLocker = false );
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false );
DLLEXPORT QNetworkAccessManager* nam();
DLLEXPORT void setNam( QNetworkAccessManager* nam, bool noMutexLocker = false );
diff --git a/src/proxydialog.ui b/src/proxydialog.ui
index 4b30ca1ca..321fcb09c 100644
--- a/src/proxydialog.ui
+++ b/src/proxydialog.ui
@@ -139,7 +139,8 @@
-
- No Proxy Hosts:
+ No Proxy Hosts:
+(Overrides system proxy)
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index 850701b86..57f3a735e 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -22,13 +22,13 @@
#include "utils/tomahawkutilsgui.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#ifdef LIBLASTFM_FOUND
#include
@@ -859,7 +859,6 @@ ProxyDialog::ProxyDialog( QWidget *parent )
ui->userLineEdit->setEnabled( false );
ui->passwordLineEdit->setEnabled( false );
ui->checkBoxUseProxyForDns->setEnabled( false );
- ui->noHostLineEdit->setEnabled( false );
}
connect( ui->typeBox, SIGNAL( currentIndexChanged( int ) ), SLOT( proxyTypeChangedSlot( int ) ) );
@@ -876,7 +875,6 @@ ProxyDialog::proxyTypeChangedSlot( int index )
ui->userLineEdit->setEnabled( false );
ui->passwordLineEdit->setEnabled( false );
ui->checkBoxUseProxyForDns->setEnabled( false );
- ui->noHostLineEdit->setEnabled( false );
}
else
{
@@ -885,7 +883,6 @@ ProxyDialog::proxyTypeChangedSlot( int index )
ui->userLineEdit->setEnabled( true );
ui->passwordLineEdit->setEnabled( true );
ui->checkBoxUseProxyForDns->setEnabled( true );
- ui->noHostLineEdit->setEnabled( true );
}
}
@@ -923,8 +920,8 @@ ProxyDialog::saveSettings()
proxyFactory->setProxy( QNetworkProxy( type, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ) );
if ( !ui->noHostLineEdit->text().isEmpty() )
{
- tDebug() << Q_FUNC_INFO << "hosts line edit is " << ui->noHostLineEdit->text();
- tDebug() << Q_FUNC_INFO << "split hosts line edit is " << ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts );
+ tDebug() << Q_FUNC_INFO << "noproxy line edit is " << ui->noHostLineEdit->text();
+ tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts );
proxyFactory->setNoProxyHosts( ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts ) );
}
}
diff --git a/src/settingsdialog.h b/src/settingsdialog.h
index ef2bdb90e..4c80b127b 100644
--- a/src/settingsdialog.h
+++ b/src/settingsdialog.h
@@ -19,8 +19,8 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
-#include
-#include
+#include
+#include
#include "config.h"
diff --git a/src/sip/jabber/jabber.cpp b/src/sip/jabber/jabber.cpp
index fa3295a4f..0473c9c17 100644
--- a/src/sip/jabber/jabber.cpp
+++ b/src/sip/jabber/jabber.cpp
@@ -102,6 +102,7 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
// general client setup
m_client = new Jreen::Client( jid, m_currentPassword );
+ m_client->setProxyFactory( TomahawkUtils::proxyFactory( true ) );
setupClientHelper();
m_client->registerPayload(new TomahawkSipMessageFactory);
diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp
index 145a55f8a..d15440343 100644
--- a/src/tomahawkapp.cpp
+++ b/src/tomahawkapp.cpp
@@ -28,7 +28,6 @@
#include
#include
#include
-#include
#include "artist.h"
#include "album.h"