1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-07 04:30:43 +02:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Dominik Schmidt
1fbe8e69a8 More -.- 2013-07-16 19:03:34 +02:00
Dominik Schmidt
aceeda13ae Moaaar fixage 2013-07-16 18:55:58 +02:00
Dominik Schmidt
5872da01b2 Remove obsolete includes 2013-07-16 18:44:14 +02:00
Dominik Schmidt
88a1a558fc Revert "Move nam() out of TomahawkUtils.h"
This reverts commit 05b6d7507b.

Conflicts:
	src/libtomahawk/CMakeLists.txt
	src/libtomahawk/GlobalActionManager.cpp
	src/libtomahawk/resolvers/JSResolver.cpp
	src/libtomahawk/resolvers/ScriptResolver.cpp
2013-07-16 18:33:44 +02:00
Dominik Schmidt
154ee5c70a Revert "Completely rip TomahawkSettings out of proxy code"
This reverts commit 36ef3a4420.

Conflicts:
	src/libtomahawk/utils/NetworkAccessManager.cpp
2013-07-16 17:28:39 +02:00
40 changed files with 341 additions and 661 deletions

View File

@@ -24,7 +24,6 @@
#include "utils/Logger.h"
#include "sip/HatchetSip.h"
#include "utils/TomahawkUtils.h"
#include "utils/NetworkAccessManager.cpp"
#include <QtPlugin>
#include <QFile>
@@ -244,7 +243,7 @@ HatchetAccount::loginWithPassword( const QString& username, const QString& passw
QNetworkRequest req( QUrl( c_loginServer + "/auth/credentials") );
req.setHeader( QNetworkRequest::ContentTypeHeader, "application/json; charset=utf-8" );
QNetworkReply* reply = Tomahawk::Utils::nam()->post( req, msgJson );
QNetworkReply* reply = TomahawkUtils::nam()->post( req, msgJson );
NewClosure( reply, SIGNAL( finished() ), this, SLOT( onPasswordLoginFinished( QNetworkReply*, const QString& ) ), reply, username );
}
@@ -265,7 +264,7 @@ HatchetAccount::fetchAccessTokens( const QString& type )
tLog() << "Fetching access tokens";
QNetworkRequest req( QUrl( c_accessTokenServer + "/tokens/" + type + "?authtoken=" + authToken() ) );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
connect( reply, SIGNAL( finished() ), this, SLOT( onFetchAccessTokensFinished() ) );
}

View File

@@ -32,7 +32,6 @@
#include "TomahawkSettings.h"
#include "utils/TomahawkUtilsGui.h"
#include "sip/PeerInfo.h"
#include "utils/NetworkProxyFactory.h"
#include "config.h"
#include "TomahawkVersion.h"
@@ -605,7 +604,7 @@ XmppSipPlugin::configurationChanged()
void
XmppSipPlugin::setupClientHelper()
{
m_client->setProxyFactory( Tomahawk::Utils::proxyFactory( true ) );
m_client->setProxyFactory( TomahawkUtils::proxyFactory( true ) );
Jreen::JID jid = Jreen::JID( m_currentUsername );
m_client->setJID( jid );
m_client->setPassword( m_currentPassword );

View File

@@ -29,7 +29,6 @@
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/TomahawkCache.h"
#include "utils/NetworkAccessManager.h"
#include "Source.h"
#include <qjson/parser.h>
@@ -281,7 +280,7 @@ ChartsPlugin::fetchChartSourcesList( bool fetchOnlySourceList )
TomahawkUtils::urlAddQueryItem( url, "version", TomahawkUtils::appFriendlyVersion() );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "only_source_list", fetchOnlySourceList );
connect( reply, SIGNAL( finished() ), SLOT( chartSourcesList() ) );
@@ -377,7 +376,7 @@ ChartsPlugin::fetchSource(const QString& source)
QUrl url = QUrl( QString( CHART_URL "charts/%1" ).arg( source ) );
TomahawkUtils::urlAddQueryItem( url, "version", TomahawkUtils::appFriendlyVersion() );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "chart_source", source );
tDebug() << Q_FUNC_INFO << "fetching:" << url;
@@ -423,7 +422,7 @@ ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData, con
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "fetching: " << url;
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );

View File

@@ -22,7 +22,6 @@
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/Closure.h"
#include "utils/NetworkAccessManager.h"
#include <qjson/parser.h>
@@ -98,7 +97,7 @@ DiscogsPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requestD
QNetworkRequest req( url );
req.setRawHeader( "User-Agent", "TomahawkPlayer/1.0 +http://tomahawk-player.org" );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
NewClosure( reply, SIGNAL( finished() ), this, SLOT( albumSearchSlot( Tomahawk::InfoSystem::InfoRequestData, QNetworkReply* ) ), requestData, reply );
break;
@@ -137,7 +136,7 @@ DiscogsPlugin::albumSearchSlot( const InfoRequestData &requestData, QNetworkRepl
QNetworkRequest req( url );
req.setRawHeader( "User-Agent", "TomahawkPlayer/1.0 +http://tomahawk-player.org" );
QNetworkReply* reply2 = Tomahawk::Utils::nam()->get( req );
QNetworkReply* reply2 = TomahawkUtils::nam()->get( req );
NewClosure( reply2, SIGNAL( finished() ), this, SLOT( albumInfoSlot( Tomahawk::InfoSystem::InfoRequestData, QNetworkReply* ) ), requestData, reply2 );
}

View File

@@ -18,12 +18,10 @@
*/
#include "EchonestPlugin.h"
#include <echonest/ArtistTypes.h>
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <echonest/ArtistTypes.h>
#include <QNetworkConfiguration>
@@ -52,7 +50,7 @@ EchonestPlugin::~EchonestPlugin()
void
EchonestPlugin::init()
{
Echonest::Config::instance()->setNetworkAccessManager( Tomahawk::Utils::nam() );
Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );
}

View File

@@ -31,7 +31,6 @@
#include "utils/TomahawkUtils.h"
#include "infosystem/InfoSystemWorker.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "Source.h"
#define HYPEM_URL "http://hypem.com/playlist/"
@@ -205,7 +204,7 @@ HypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSys
QUrl url = QUrl( QString( HYPEM_URL "%1/%2" ).arg( criteria["chart_id"].toLower() ).arg(HYPEM_END_URL) );
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
return;

View File

@@ -21,7 +21,6 @@
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <QNetworkReply>
#include <QDomDocument>
@@ -111,7 +110,7 @@ MusicBrainzPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
TomahawkUtils::urlAddQueryItem( url, "limit", "100" );
tDebug() << Q_FUNC_INFO << url.toString();
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( gotReleaseGroupsSlot() ) );
@@ -131,7 +130,7 @@ MusicBrainzPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
TomahawkUtils::urlAddQueryItem( url, "limit", "100" );
tDebug() << Q_FUNC_INFO << url.toString();
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( gotReleasesSlot() ) );
@@ -237,7 +236,7 @@ MusicBrainzPlugin::gotReleasesSlot()
TomahawkUtils::urlAddQueryItem( url, "inc", "recordings" );
tDebug() << Q_FUNC_INFO << url.toString();
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( gotRecordingsSlot() ) );

View File

@@ -21,7 +21,6 @@
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <QNetworkReply>
#include <QDomDocument>
@@ -69,7 +68,7 @@ MusixMatchPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
TomahawkUtils::urlAddQueryItem( url, "q_artist", artist );
TomahawkUtils::urlAddQueryItem( url, "q_track", track );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( trackSearchSlot() ) );
@@ -129,7 +128,7 @@ MusixMatchPlugin::trackSearchSlot()
TomahawkUtils::urlAddQueryItem( url, "apikey", m_apiKey );
TomahawkUtils::urlAddQueryItem( url, "track_id", track_id );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
}

View File

@@ -30,7 +30,6 @@
#include "utils/Logger.h"
#include "utils/TomahawkCache.h"
#include "Source.h"
#include "utils/NetworkAccessManager.h"
#include <qjson/parser.h>
#include <qjson/serializer.h>
@@ -269,7 +268,7 @@ NewReleasesPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
TomahawkUtils::urlAddQueryItem( url, "version", TomahawkUtils::appFriendlyVersion() );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest ( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest ( url ) );
reply->setProperty( "only_source_list", true );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "fetching:" << url;
@@ -402,7 +401,7 @@ NewReleasesPlugin::fetchAllNRSources()
TomahawkUtils::urlAddQueryItem( url, "version", TomahawkUtils::appFriendlyVersion() );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "nr_source", source[ "nr_source" ] );
tDebug() << Q_FUNC_INFO << "fetching:" << url;
@@ -424,7 +423,7 @@ NewReleasesPlugin::fetchNR( InfoRequestData requestData, const QString& source,
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "fetching: " << url;
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect ( reply, SIGNAL( finished() ), SLOT( nrReturned() ) );

View File

@@ -20,7 +20,6 @@
#include "RoviPlugin.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <qjson/parser.h>
@@ -184,7 +183,7 @@ RoviPlugin::makeRequest( QUrl url )
TomahawkUtils::urlAddQueryItem( url, "sig", generateSig() );
qDebug() << "Rovi request url:" << url.toString();
return Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
return TomahawkUtils::nam()->get( QNetworkRequest( url ) );
}

View File

@@ -31,7 +31,6 @@
#include "TomahawkSettings.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "CountryUtils.h"
#include "Source.h"
@@ -148,7 +147,7 @@ SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, To
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/%1/" ).arg( criteria["chart_id"] ) );
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
return;
@@ -165,7 +164,7 @@ SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, To
tDebug() << "SpotifyPlugin: InfoChart fetching possible resources";
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/charts" ) );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
tDebug() << Q_FUNC_INFO << "fetching:" << url;
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
m_chartsFetchJobs++;

View File

@@ -29,7 +29,6 @@
#include "accounts/AccountManager.h"
#include "utils/BinaryInstallerHelper.h"
#include "utils/Closure.h"
#include "utils/NetworkAccessManager.h"
#include <attica/downloaditem.h>
@@ -69,7 +68,7 @@ AtticaManager::AtticaManager( QObject* parent )
// m_manager.addProviderFile( QUrl( "http://bakery.tomahawk-player.org/resolvers/providers.xml" ) );
const QString url = QString( "%1/resolvers/providers.xml?version=%2" ).arg( hostname() ).arg( TomahawkUtils::appFriendlyVersion() );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( url ) ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( url ) ) );
NewClosure( reply, SIGNAL( finished() ), this, SLOT( providerFetched( QNetworkReply* ) ), reply );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( providerError( QNetworkReply::NetworkError ) ) );
@@ -104,7 +103,7 @@ AtticaManager::fetchMissingIcons()
if ( !m_resolverStates.value( resolver.id() ).pixmap && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() )
{
QNetworkReply* fetch = Tomahawk::Utils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
QNetworkReply* fetch = TomahawkUtils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
fetch->setProperty( "resolverId", resolver.id() );
connect( fetch, SIGNAL( finished() ), this, SLOT( resolverIconFetched() ) );
@@ -551,7 +550,7 @@ void AtticaManager::doInstallResolver( const Content& resolver, bool autoCreate,
QUrl url( QString( "%1/resolvers/v1/content/download/%2/1" ).arg( hostname() ).arg( resolver.id() ) );
TomahawkUtils::urlAddQueryItem( url, "tomahawkversion", TomahawkUtils::appFriendlyVersion() );
QNetworkReply* r = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* r = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
NewClosure( r, SIGNAL( finished() ), this, SLOT( resolverDownloadFinished( QNetworkReply* ) ), r );
r->setProperty( "resolverId", resolver.id() );
r->setProperty( "createAccount", autoCreate );
@@ -612,7 +611,7 @@ AtticaManager::resolverDownloadFinished ( QNetworkReply *j )
tLog() << "Found overridden signature in binary download:" << sig;
signature = sig;
}
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
connect( reply, SIGNAL( finished() ), this, SLOT( payloadFetched() ) );
reply->setProperty( "resolverId", j->property( "resolverId" ) );
reply->setProperty( "createAccount", j->property( "createAccount" ) );

View File

@@ -124,8 +124,6 @@ set( libGuiSources
utils/SharedTimeLine.cpp
utils/ResultUrlChecker.cpp
utils/NetworkReply.cpp
utils/NetworkProxyFactory.cpp
utils/NetworkAccessManager.cpp
utils/ShortLinkHelper.cpp
widgets/AnimatedCounterLabel.cpp

View File

@@ -32,7 +32,6 @@
#include "resolvers/ScriptCommand_LookupUrl.h"
#include "utils/JspfLoader.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "utils/RdioParser.h"
#include "utils/ShortenedLinkParser.h"
#include "utils/ShortLinkHelper.h"
@@ -184,7 +183,6 @@ GlobalActionManager::openUrl( const QString& url )
#ifndef ENABLE_HEADLESS
QString
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
{

View File

@@ -19,6 +19,8 @@
#include "LastFmConfig.h"
#include "ui_LastFmConfig.h"
#include <boost/bind.hpp>
#include "LastFmAccount.h"
#include "database/Database.h"
#include "database/DatabaseCommand_LogPlayback.h"
@@ -27,15 +29,12 @@
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/Closure.h"
#include "utils/NetworkAccessManager.h"
#include <lastfm/ws.h>
#include <lastfm/User.h>
#include <lastfm/XmlQuery.h>
#include <lastfm/Track.h>
#include <boost/bind.hpp>
using namespace Tomahawk::Accounts;
@@ -102,7 +101,7 @@ LastFmConfig::testLogin()
query[ "authToken" ] = authToken;
// ensure they have up-to-date settings
lastfm::setNetworkAccessManager( Tomahawk::Utils::nam() );
lastfm::setNetworkAccessManager( TomahawkUtils::nam() );
QNetworkReply* authJob = lastfm::ws::post( query );

View File

@@ -32,7 +32,6 @@
#include "accounts/lastfm/LastFmAccount.h"
#include "Source.h"
#include "TomahawkSettings.h"
#include "utils/NetworkAccessManager.h"
#include <lastfm/ws.h>
#include <lastfm/XmlQuery.h>
@@ -65,7 +64,7 @@ LastFmInfoPlugin::init()
lastfm::ws::ApiKey = "7194b85b6d1f424fe1668173a78c0c4a";
lastfm::ws::SharedSecret = "ba80f1df6d27ae63e9cb1d33ccf2052f";
lastfm::ws::Username = m_account.data()->username();
lastfm::setNetworkAccessManager( Tomahawk::Utils::nam() );
lastfm::setNetworkAccessManager( TomahawkUtils::nam() );
m_pw = m_account.data()->password();
@@ -412,7 +411,7 @@ LastFmInfoPlugin::fetchAlbumInfo( Tomahawk::InfoSystem::InfoRequestData requestD
void
LastFmInfoPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
if ( !Tomahawk::Utils::nam() )
if ( !TomahawkUtils::nam() )
{
tLog() << "Have a null QNAM, uh oh";
emit info( requestData, QVariant() );
@@ -762,7 +761,7 @@ LastFmInfoPlugin::artistInfoReturned()
imgurl = artist.imageUrl( lastfm::AbstractType::LargeImage );
QNetworkRequest req( imgurl );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* newReply = TomahawkUtils::nam()->get( req );
newReply->setProperty( "requestData", reply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
}
@@ -787,7 +786,7 @@ LastFmInfoPlugin::albumInfoReturned()
imgurl = QUrl( lfm["album"]["image size=large"].text() );
QNetworkRequest req( imgurl );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* newReply = TomahawkUtils::nam()->get( req );
newReply->setProperty( "requestData", reply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
}
@@ -834,7 +833,7 @@ LastFmInfoPlugin::coverArtReturned()
{
// Follow HTTP redirect
QNetworkRequest req( redir );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* newReply = TomahawkUtils::nam()->get( req );
newReply->setProperty( "requestData", reply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
}
@@ -878,7 +877,7 @@ LastFmInfoPlugin::artistImagesReturned()
}
else
{
if ( !Tomahawk::Utils::nam() )
if ( !TomahawkUtils::nam() )
{
tLog() << Q_FUNC_INFO << "Uh oh, nam is null";
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
@@ -886,7 +885,7 @@ LastFmInfoPlugin::artistImagesReturned()
}
// Follow HTTP redirect
QNetworkRequest req( redir );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* newReply = TomahawkUtils::nam()->get( req );
newReply->setProperty( "requestData", reply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
}

View File

@@ -21,7 +21,6 @@
#include "SpotifyAccount.h"
#include "utils/Closure.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <qjson/parser.h>
@@ -145,7 +144,7 @@ SpotifyInfoPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
QUrl lookupUrl( "http://ws.spotify.com/search/1/album.json" );
TomahawkUtils::urlAddQueryItem( lookupUrl, "q", QString( "%1 %2" ).arg( artist ).arg( album ) );
QNetworkReply * reply = Tomahawk::Utils::nam()->get( QNetworkRequest( lookupUrl ) );
QNetworkReply * reply = TomahawkUtils::nam()->get( QNetworkRequest( lookupUrl ) );
NewClosure( reply, SIGNAL( finished() ), this, SLOT( albumIdLookupFinished( QNetworkReply*, Tomahawk::InfoSystem::InfoRequestData ) ), reply, requestData );
}
else
@@ -235,7 +234,7 @@ SpotifyInfoPlugin::albumIdLookupFinished( QNetworkReply* reply, const InfoReques
QUrl lookupUrl( QString( "http://spotikea.tomahawk-player.org/browse/%1" ).arg( id ) );
QNetworkReply * reply = Tomahawk::Utils::nam()->get( QNetworkRequest( lookupUrl ) );
QNetworkReply * reply = TomahawkUtils::nam()->get( QNetworkRequest( lookupUrl ) );
NewClosure( reply, SIGNAL( finished() ), this, SLOT( albumContentsLookupFinished( QNetworkReply*, Tomahawk::InfoSystem::InfoRequestData ) ), reply, requestData );
}
else

View File

@@ -33,7 +33,6 @@
#include "utils/Closure.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "AclRegistry.h"
#include "BufferIoDevice.h"
@@ -184,7 +183,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port, Tomahawk::Network
d->externalPort = externalPort;
if ( autoDetectExternalIp )
{
QNetworkReply* reply = Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( "http://toma.hk/?stat=1" ) ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( "http://toma.hk/?stat=1" ) ) );
connect( reply, SIGNAL( finished() ), SLOT( ipDetected() ) );
// Not emitting ready here as we are not done.
}
@@ -1386,7 +1385,7 @@ Servent::httpIODeviceFactory( const Tomahawk::result_ptr& result,
boost::function< void ( QSharedPointer< QIODevice >& ) > callback )
{
QNetworkRequest req( result->url() );
QNetworkReply* reply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
//boost::functions cannot accept temporaries as parameters
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply, &QObject::deleteLater );

View File

@@ -27,7 +27,6 @@
#include "jobview/JobStatusModel.h"
#include "jobview/ErrorStatusMessage.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "utils/TomahawkUtilsGui.h"
#include "Artist.h"
@@ -875,7 +874,7 @@ JSResolver::loadCollections()
{
QNetworkRequest req( iconUrl );
tDebug() << "Creating a QNetworkReply with url:" << req.url().toString();
QNetworkReply* reply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
reply->setProperty( "collectionName", collection->name() );
connect( reply, SIGNAL( finished() ),

View File

@@ -27,7 +27,6 @@
#include "resolvers/ScriptEngine.h"
#include "network/Servent.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "config.h"
#include "JSResolver_p.h"
@@ -447,7 +446,7 @@ JSResolverHelper::returnStreamUrl( const QString& streamUrl, boost::function< vo
QUrl url = QUrl::fromEncoded( streamUrl.toUtf8() );
QNetworkRequest req( url );
tDebug() << "Creating a QNetowrkReply with url:" << req.url().toString();
QNetworkReply* reply = Tomahawk::Utils::nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
//boost::functions cannot accept temporaries as parameters
sp = QSharedPointer< QIODevice >( reply, &QObject::deleteLater );

View File

@@ -20,12 +20,6 @@
#include "ScriptResolver.h"
#include "accounts/AccountConfigWidget.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "utils/NetworkProxyFactory.h"
#include "Artist.h"
#include "Album.h"
#include "Pipeline.h"
@@ -34,6 +28,10 @@
#include "SourceList.h"
#include "Track.h"
#include "utils/Logger.h"
#include "utils/TomahawkUtilsGui.h"
#include "accounts/AccountConfigWidget.h"
#include <QtEndian>
#include <QFileInfo>
#include <QNetworkAccessManager>
@@ -60,7 +58,7 @@ ScriptResolver::ScriptResolver( const QString& exe )
startProcess();
if ( !Tomahawk::Utils::nam() )
if ( !TomahawkUtils::nam() )
return;
// set the name to the binary, if we launch properly we'll get the name the resolver reports
@@ -139,11 +137,7 @@ ScriptResolver::sendConfig()
m_configSent = true;
tDebug() << "Nam is:" << Tomahawk::Utils::nam();
tDebug() << "Nam proxy is:" << Tomahawk::Utils::nam()->proxyFactory();
Tomahawk::Utils::nam()->proxyFactory()->queryProxy();
Tomahawk::Utils::NetworkProxyFactory* factory = dynamic_cast<Tomahawk::Utils::NetworkProxyFactory*>( Tomahawk::Utils::nam()->proxyFactory() );
tDebug() << "Factory is:" << factory;
TomahawkUtils::NetworkProxyFactory* factory = dynamic_cast<TomahawkUtils::NetworkProxyFactory*>( TomahawkUtils::nam()->proxyFactory() );
QNetworkProxy proxy = factory->proxy();
QString proxyType = ( proxy.type() == QNetworkProxy::Socks5Proxy ? "socks5" : "none" );
m.insert( "proxytype", proxyType );

View File

@@ -42,7 +42,6 @@
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
using namespace Tomahawk;
@@ -134,7 +133,7 @@ GroovesharkParser::lookupGroovesharkPlaylist( const QString& linkRaw )
QString hash = QCA::arrayToHex( resultArray.toByteArray() );
QUrl url = QUrl( base_url + hash );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->post( QNetworkRequest( url ), data ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->post( QNetworkRequest( url ), data ) );
connect( reply, SIGNAL( finished() ), SLOT( groovesharkLookupFinished() ) );
#ifndef ENABLE_HEADLESS
@@ -151,7 +150,7 @@ GroovesharkParser::lookupGroovesharkTrack( const QString& track )
{
tLog() << "Parsing Grooveshark Track Page:" << track;
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( track ) ) ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( QUrl( track ) ) ) );
connect( reply, SIGNAL( finished() ), SLOT( trackPageFetchFinished() ) );
#ifndef ENABLE_HEADLESS

View File

@@ -33,7 +33,6 @@
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
// Forward Declarations breaking QSharedPointer
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
@@ -113,7 +112,7 @@ ItunesParser::lookupItunesUri( const QString& link )
url = QUrl( QString( "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsLookup?id=%1&entity=song" ).arg( ( trackId.isEmpty() ? id : trackId ) ) );
}
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( QNetworkRequest( url ) ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) );
connect( reply, SIGNAL( finished() ), SLOT( itunesResponseLookupFinished() ) );
#ifndef ENABLE_HEADLESS

View File

@@ -22,7 +22,6 @@
#include "utils/Logger.h"
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtils.h"
#include "utils/NetworkAccessManager.h"
#include "Playlist.h"
#include "SourceList.h"
@@ -62,8 +61,8 @@ JSPFLoader::load( const QUrl& url )
{
QNetworkRequest request( url );
Q_ASSERT( Tomahawk::Utils::nam() != 0 );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( request ) );
Q_ASSERT( TomahawkUtils::nam() != 0 );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( request ) );
connect( reply, SIGNAL( finished() ), SLOT( networkLoadFinished() ) );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( networkError( QNetworkReply::NetworkError ) ) );

View File

@@ -1,382 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "NetworkAccessManager.h"
#include "NetworkProxyFactory.h"
#include "utils/Logger.h"
#include <QMutex>
#include <QStringList>
#include <QThread>
#include <QCoreApplication>
#include <QNetworkConfiguration>
#include <QNetworkAccessManager>
namespace Tomahawk
{
namespace Utils
{
static QMutex s_noProxyHostsMutex;
static QStringList s_noProxyHosts;
NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other )
{
m_proxy = QNetworkProxy( other.m_proxy );
}
QList< QNetworkProxy >
NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query )
{
//tDebug() << Q_FUNC_INFO << "query hostname is" << query.peerHostName() << ", proxy host is" << m_proxy.hostName();
QList< QNetworkProxy > proxies;
QString hostname = query.peerHostName();
s_noProxyHostsMutex.lock();
if ( !hostname.isEmpty() && s_noProxyHosts.contains( hostname ) )
proxies << QNetworkProxy::NoProxy << systemProxyForQuery( query );
else if ( m_proxy.hostName().isEmpty() || proxyType() == QNetworkProxy::NoProxy )
proxies << systemProxyForQuery( query );
else
proxies << m_proxy << systemProxyForQuery( query );
s_noProxyHostsMutex.unlock();
return proxies;
}
void
NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts )
{
QStringList newList;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "No-proxy hosts:" << hosts;
foreach ( const QString& host, hosts )
{
QString munge = host.simplified();
newList << munge;
//TODO: wildcard support
}
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "New no-proxy hosts:" << newList;
s_noProxyHostsMutex.lock();
s_noProxyHosts = newList;
s_noProxyHostsMutex.unlock();
}
void
NetworkProxyFactory::setProxy( const QNetworkProxy& proxy, bool useProxyDns )
{
m_proxyChanged = false;
if ( m_proxy != proxy )
m_proxyChanged = true;
m_proxy = proxy;
QFlags< QNetworkProxy::Capability > proxyCaps;
proxyCaps |= QNetworkProxy::TunnelingCapability;
proxyCaps |= QNetworkProxy::ListeningCapability;
if ( useProxyDns )
proxyCaps |= QNetworkProxy::HostNameLookupCapability;
m_proxy.setCapabilities( proxyCaps );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Proxy using host" << proxy.hostName() << "and port" << proxy.port();
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "setting proxy to use proxy DNS?" << useProxyDns;
}
NetworkProxyFactory&
NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( this != &rhs )
{
m_proxy = QNetworkProxy( rhs.m_proxy );
}
return *this;
}
bool NetworkProxyFactory::operator==( const NetworkProxyFactory& other ) const
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( m_proxy != other.m_proxy )
return false;
return true;
}
static QMap< QThread*, QNetworkAccessManager* > s_threadNamHash;
static QMap< QThread*, NetworkProxyFactory* > s_threadProxyFactoryHash;
static QMutex s_namAccessMutex;
NetworkProxyFactory*
proxyFactory( bool makeClone, bool noMutexLocker )
{
// Don't lock if being called from nam()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
if ( !makeClone )
{
if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) )
return s_threadProxyFactoryHash[ QThread::currentThread() ];
}
// create a new proxy factory for this thread
NetworkProxyFactory *newProxyFactory = new NetworkProxyFactory();
if ( s_threadProxyFactoryHash.contains( QCoreApplication::instance()->thread() ) )
{
NetworkProxyFactory *mainProxyFactory = s_threadProxyFactoryHash[ QCoreApplication::instance()->thread() ];
*newProxyFactory = *mainProxyFactory;
}
if ( !makeClone )
s_threadProxyFactoryHash[ QThread::currentThread() ] = newProxyFactory;
return newProxyFactory;
}
void
setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
Q_ASSERT( factory );
// Don't lock if being called from setNam()
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
if ( !s_threadProxyFactoryHash.contains( QCoreApplication::instance()->thread() ) )
return;
if ( QThread::currentThread() == QCoreApplication::instance()->thread() )
{
foreach ( QThread* thread, s_threadProxyFactoryHash.keys() )
{
if ( thread != QThread::currentThread() )
{
NetworkProxyFactory *currFactory = s_threadProxyFactoryHash[ thread ];
*currFactory = *factory;
}
}
QNetworkProxyFactory::setApplicationProxyFactory( factory );
}
*s_threadProxyFactoryHash[ QThread::currentThread() ] = *factory;
}
QNetworkAccessManager*
nam()
{
QMutexLocker locker( &s_namAccessMutex );
if ( s_threadNamHash.contains( QThread::currentThread() ) )
{
//tDebug() << Q_FUNC_INFO << "Found current thread in nam hash";
return s_threadNamHash[ QThread::currentThread() ];
}
if ( !s_threadNamHash.contains( QCoreApplication::instance()->thread() ) )
{
if ( QThread::currentThread() == QCoreApplication::instance()->thread() )
{
setNam( new QNetworkAccessManager(), true );
return s_threadNamHash[ QThread::currentThread() ];
}
else
return 0;
}
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found gui thread in nam hash";
// Create a nam for this thread based on the main thread's settings but with its own proxyfactory
QNetworkAccessManager *mainNam = s_threadNamHash[ QCoreApplication::instance()->thread() ];
QNetworkAccessManager* newNam = new QNetworkAccessManager();
newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) );
newNam->setNetworkAccessible( mainNam->networkAccessible() );
newNam->setProxyFactory( proxyFactory( false, true ) );
s_threadNamHash[ QThread::currentThread() ] = newNam;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "created new nam for thread" << QThread::currentThread();
//QNetworkProxy proxy = dynamic_cast< NetworkProxyFactory* >( newNam->proxyFactory() )->proxy();
//tDebug() << Q_FUNC_INFO << "reply proxy properties:" << proxy.type() << proxy.hostName() << proxy.port();
return newNam;
}
void
setNam( QNetworkAccessManager* nam, bool noMutexLocker )
{
Q_ASSERT( nam );
// Don't lock if being called from nam()()
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
if ( !s_threadNamHash.contains( QCoreApplication::instance()->thread() ) &&
QThread::currentThread() == QCoreApplication::instance()->thread() )
{
tDebug( LOGVERBOSE ) << "creating initial gui thread (" << QCoreApplication::instance()->thread() << ") nam";
// Should only get here on first initialization of the nam
NetworkProxyFactory* proxyFactory = new NetworkProxyFactory();
if ( proxyType() != QNetworkProxy::NoProxy && !proxyHost().isEmpty() )
{
tDebug( LOGVERBOSE ) << "Setting proxy to saved values";
QNetworkProxy proxy( proxyType(), proxyHost(), proxyPort(), proxyUsername(), proxyPassword() );
proxyFactory->setProxy( proxy, proxyDns() );
//FIXME: Jreen is broke without this
//QNetworkProxy::setApplicationProxy( proxy );
s_noProxyHostsMutex.lock();
if ( !proxyNoProxyHosts().isEmpty() && s_noProxyHosts.isEmpty() )
{
s_noProxyHostsMutex.unlock();
proxyFactory->setNoProxyHosts( proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
}
else
s_noProxyHostsMutex.unlock();
}
QNetworkProxyFactory::setApplicationProxyFactory( proxyFactory );
nam->setProxyFactory( proxyFactory );
s_threadNamHash[ QThread::currentThread() ] = nam;
s_threadProxyFactoryHash[ QThread::currentThread() ] = proxyFactory;
return;
}
s_threadNamHash[ QThread::currentThread() ] = nam;
if ( QThread::currentThread() == QCoreApplication::instance()->thread() )
setProxyFactory( dynamic_cast< NetworkProxyFactory* >( nam->proxyFactory() ), true );
}
static bool s_proxyDns;
static QNetworkProxy::ProxyType s_proxyType;
static QString s_proxyHost;
static int s_proxyPort;
static QString s_proxyUsername;
static QString s_proxyPassword;
static QString s_proxyNoProxyHosts;
QString
proxyHost()
{
return s_proxyHost;
}
void
setProxyHost( const QString& host )
{
s_proxyHost = host;
}
QString
proxyNoProxyHosts()
{
return s_proxyNoProxyHosts;
}
void
setProxyNoProxyHosts( const QString& hosts )
{
s_proxyNoProxyHosts = hosts;
}
qulonglong
proxyPort()
{
return s_proxyPort;
}
void
setProxyPort( const qulonglong port )
{
s_proxyPort = port;
}
QString
proxyUsername()
{
return s_proxyUsername;
}
void
setProxyUsername( const QString& username )
{
s_proxyUsername = username;
}
QString
proxyPassword()
{
return s_proxyPassword;
}
void
setProxyPassword( const QString& password )
{
s_proxyPassword = password;
}
QNetworkProxy::ProxyType
proxyType()
{
return s_proxyType;
}
void
setProxyType( const QNetworkProxy::ProxyType type )
{
s_proxyType = type;
}
bool
proxyDns()
{
return s_proxyDns;
}
void
setProxyDns( bool proxyDns )
{
s_proxyDns = proxyDns;
}
}
}

View File

@@ -1,63 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOMAHAWK_UTILS_NETWORKACCESSMANAGER_H
#define TOMAHAWK_UTILS_NETWORKACCESSMANAGER_H
#include <QNetworkProxy>
#include "DllMacro.h"
class QNetworkAccessManager;
namespace Tomahawk
{
namespace Utils
{
DLLEXPORT QNetworkAccessManager* nam();
DLLEXPORT void setNam( QNetworkAccessManager* nam, bool noMutexLocker = false );
// Proxy settings
DLLEXPORT bool proxyDns();
DLLEXPORT void setProxyDns( bool proxyDns );
DLLEXPORT QNetworkProxy::ProxyType proxyType();
DLLEXPORT void setProxyType( QNetworkProxy::ProxyType proxyType );
DLLEXPORT QString proxyHost();
DLLEXPORT void setProxyHost( const QString& proxyHost );
DLLEXPORT qulonglong proxyPort();
DLLEXPORT void setProxyPort( qulonglong proxyPort );
DLLEXPORT QString proxyUsername();
DLLEXPORT void setProxyUsername( const QString& proxyUsername );
DLLEXPORT QString proxyPassword();
DLLEXPORT void setProxyPassword( const QString& proxyPassword );
DLLEXPORT QString proxyNoProxyHosts();
DLLEXPORT void setProxyNoProxyHosts( const QString& proxyNoProxyHosts );
}
}
#endif // TOMAHAWK_UTILS_NETWORKACCESSMANAGER_H

View File

@@ -1,24 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "NetworkProxyFactory.h"
//MAJORHACK: all implementation in NetworkAccessManager.cpp even for NetworkProxyFactory.h because they share private s_* vars :C

View File

@@ -1,67 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOMAHAWK_UTILS_NETWORKPROXYFACTORY_H
#define TOMAHAWK_UTILS_NETWORKPROXYFACTORY_H
#include <QNetworkProxyFactory>
#include <QStringList>
#include "DllMacro.h"
namespace Tomahawk
{
namespace Utils
{
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
{
public:
NetworkProxyFactory()
: m_proxy( QNetworkProxy::NoProxy )
, m_proxyChanged( false )
{}
NetworkProxyFactory( const NetworkProxyFactory &other );
virtual ~NetworkProxyFactory() {}
virtual QList< QNetworkProxy > queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );
virtual void setNoProxyHosts( const QStringList &hosts );
virtual QStringList noProxyHosts() const { return m_noProxyHosts; }
virtual void setProxy( const QNetworkProxy &proxy, bool useProxyDns );
virtual QNetworkProxy proxy() { return m_proxy; }
virtual NetworkProxyFactory& operator=( const NetworkProxyFactory &rhs );
virtual bool operator==( const NetworkProxyFactory &other ) const;
bool changed() const { return m_proxyChanged; }
private:
QStringList m_noProxyHosts;
QNetworkProxy m_proxy;
bool m_proxyChanged;
};
DLLEXPORT void setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker = false );
DLLEXPORT NetworkProxyFactory* proxyFactory( bool makeClone = false, bool noMutexLocker = false );
}
}
#endif // TOMAHAWK_UTILS_NETWORKPROXYFACTORY_H

View File

@@ -20,7 +20,6 @@
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <QNetworkAccessManager>
@@ -63,7 +62,7 @@ NetworkReply::load( const QUrl& url )
m_url = url;
QNetworkRequest request( url );
Q_ASSERT( Tomahawk::Utils::nam() != 0 );
Q_ASSERT( TomahawkUtils::nam() != 0 );
QNetworkAccessManager::Operation op = m_reply->operation();
m_reply->deleteLater();
@@ -71,11 +70,11 @@ NetworkReply::load( const QUrl& url )
switch ( op )
{
case QNetworkAccessManager::HeadOperation:
m_reply = Tomahawk::Utils::nam()->head( request );
m_reply = TomahawkUtils::nam()->head( request );
break;
default:
m_reply = Tomahawk::Utils::nam()->get( request );
m_reply = TomahawkUtils::nam()->get( request );
}
connect( m_reply, SIGNAL( finished() ), SLOT( networkLoadFinished() ) );

View File

@@ -31,7 +31,6 @@
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include <qjson/parser.h>
@@ -131,7 +130,7 @@ RdioParser::fetchObjectsFromUrl( const QString& url, DropJob::DropType type )
QNetworkRequest request = generateRequest( "getObjectFromUrl", cleanedUrl, params, &data );
request.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/x-www-form-urlencoded" ) );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->post( request, data ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->post( request, data ) );
connect( reply, SIGNAL( finished() ), SLOT( rdioReturned() ) );
#ifndef ENABLE_HEADLESS

View File

@@ -27,7 +27,6 @@
#include "Result.h"
#include "Source.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
using namespace Tomahawk;
@@ -56,7 +55,7 @@ ResultUrlChecker::check()
if ( url.isEmpty() || !url.toString().startsWith( "http" ) )
continue;
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->head( QNetworkRequest( url ) ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->head( QNetworkRequest( url ) ) );
m_replies.insert( reply, result );
connect( reply, SIGNAL( finished() ), SLOT( headFinished() ) );
}

View File

@@ -22,7 +22,6 @@
#include "ShortLinkHelper_p.h"
#include "utils/Closure.h"
#include "utils/NetworkAccessManager.h"
#include "utils/TomahawkUtils.h"
#include "Playlist.h"
#include "Source.h"
@@ -91,7 +90,7 @@ ShortLinkHelper::shortLink( const Tomahawk::playlist_ptr& pl )
const QUrl url( QString( "%1/p/").arg( hostname() ) );
QNetworkRequest req( url );
req.setHeader( QNetworkRequest::ContentTypeHeader, QString( "multipart/form-data; boundary=%1" ).arg( QString::fromLatin1( boundary ) ) );
d->reply = Tomahawk::Utils::nam()->post( req, data );
d->reply = TomahawkUtils::nam()->post( req, data );
NewClosure( d->reply, SIGNAL( finished() ),
this, SLOT( shortLinkRequestFinished( Tomahawk::playlist_ptr ) ), pl );
@@ -114,7 +113,7 @@ ShortLinkHelper::shortenLink( const QUrl& url, const QVariant& callbackObj )
QNetworkRequest request;
request.setUrl( url );
d->reply = Tomahawk::Utils::nam()->get( request );
d->reply = TomahawkUtils::nam()->get( request );
if ( callbackObj.isValid() )
d->reply->setProperty( "callbackobj", callbackObj );
connect( d->reply, SIGNAL( finished() ), SLOT( shortenLinkRequestFinished() ) );

View File

@@ -32,7 +32,6 @@
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
using namespace Tomahawk;
@@ -79,7 +78,7 @@ ShortenedLinkParser::lookupUrl( const QString& url )
if ( cleaned.contains( "/#/s/" ) )
cleaned.replace( "/#", "" );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( cleaned ) ) ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( QUrl( cleaned ) ) ) );
connect( reply, SIGNAL( finished() ), SLOT( lookupFinished() ) );
m_queries.insert( reply );

View File

@@ -34,7 +34,6 @@
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
using namespace Tomahawk;
@@ -176,7 +175,7 @@ SpotifyParser::lookupSpotifyBrowse( const QString& link )
url = QUrl( QString( SPOTIFY_PLAYLIST_API_URL "/browse/%1/%2" ).arg( m_browseUri )
.arg ( m_limit ) );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( QNetworkRequest( url ) ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) );
connect( reply, SIGNAL( finished() ), SLOT( spotifyBrowseFinished() ) );
#ifndef ENABLE_HEADLESS
@@ -205,7 +204,7 @@ SpotifyParser::lookupTrack( const QString& link )
QUrl url = QUrl( QString( "http://ws.spotify.com/lookup/1/.json?uri=%1" ).arg( uri ) );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( QNetworkRequest( url ) ) );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) );
connect( reply, SIGNAL( finished() ), SLOT( spotifyTrackLookupFinished() ) );
#ifndef ENABLE_HEADLESS

View File

@@ -428,6 +428,243 @@ levenshtein( const QString& source, const QString& target )
}
static QMutex s_noProxyHostsMutex;
static QStringList s_noProxyHosts;
NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other )
{
m_proxy = QNetworkProxy( other.m_proxy );
}
QList< QNetworkProxy >
NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query )
{
//tDebug() << Q_FUNC_INFO << "query hostname is" << query.peerHostName() << ", proxy host is" << m_proxy.hostName();
QList< QNetworkProxy > proxies;
QString hostname = query.peerHostName();
s_noProxyHostsMutex.lock();
if ( !hostname.isEmpty() && s_noProxyHosts.contains( hostname ) )
proxies << QNetworkProxy::NoProxy << systemProxyForQuery( query );
else if ( m_proxy.hostName().isEmpty() || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy )
proxies << systemProxyForQuery( query );
else
proxies << m_proxy << systemProxyForQuery( query );
s_noProxyHostsMutex.unlock();
return proxies;
}
void
NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts )
{
QStringList newList;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "No-proxy hosts:" << hosts;
foreach ( const QString& host, hosts )
{
QString munge = host.simplified();
newList << munge;
//TODO: wildcard support
}
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "New no-proxy hosts:" << newList;
s_noProxyHostsMutex.lock();
s_noProxyHosts = newList;
s_noProxyHostsMutex.unlock();
}
void
NetworkProxyFactory::setProxy( const QNetworkProxy& proxy )
{
m_proxyChanged = false;
if ( m_proxy != proxy )
m_proxyChanged = true;
m_proxy = proxy;
QFlags< QNetworkProxy::Capability > proxyCaps;
proxyCaps |= QNetworkProxy::TunnelingCapability;
proxyCaps |= QNetworkProxy::ListeningCapability;
if ( TomahawkSettings::instance()->proxyDns() )
proxyCaps |= QNetworkProxy::HostNameLookupCapability;
m_proxy.setCapabilities( proxyCaps );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Proxy using host" << proxy.hostName() << "and port" << proxy.port();
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "setting proxy to use proxy DNS?" << (TomahawkSettings::instance()->proxyDns() ? "true" : "false");
}
NetworkProxyFactory&
NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( this != &rhs )
{
m_proxy = QNetworkProxy( rhs.m_proxy );
}
return *this;
}
bool NetworkProxyFactory::operator==( const NetworkProxyFactory& other ) const
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( m_proxy != other.m_proxy )
return false;
return true;
}
static QMap< QThread*, QNetworkAccessManager* > s_threadNamHash;
static QMap< QThread*, NetworkProxyFactory* > s_threadProxyFactoryHash;
static QMutex s_namAccessMutex;
NetworkProxyFactory*
proxyFactory( bool makeClone, bool noMutexLocker )
{
// Don't lock if being called from nam()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
if ( !makeClone )
{
if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) )
return s_threadProxyFactoryHash[ QThread::currentThread() ];
}
// create a new proxy factory for this thread
TomahawkUtils::NetworkProxyFactory *newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
if ( s_threadProxyFactoryHash.contains( QCoreApplication::instance()->thread() ) )
{
TomahawkUtils::NetworkProxyFactory *mainProxyFactory = s_threadProxyFactoryHash[ QCoreApplication::instance()->thread() ];
*newProxyFactory = *mainProxyFactory;
}
if ( !makeClone )
s_threadProxyFactoryHash[ QThread::currentThread() ] = newProxyFactory;
return newProxyFactory;
}
void
setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
Q_ASSERT( factory );
// Don't lock if being called from setNam()
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
if ( !s_threadProxyFactoryHash.contains( QCoreApplication::instance()->thread() ) )
return;
if ( QThread::currentThread() == QCoreApplication::instance()->thread() )
{
foreach ( QThread* thread, s_threadProxyFactoryHash.keys() )
{
if ( thread != QThread::currentThread() )
{
TomahawkUtils::NetworkProxyFactory *currFactory = s_threadProxyFactoryHash[ thread ];
*currFactory = *factory;
}
}
QNetworkProxyFactory::setApplicationProxyFactory( factory );
}
*s_threadProxyFactoryHash[ QThread::currentThread() ] = *factory;
}
QNetworkAccessManager*
nam()
{
QMutexLocker locker( &s_namAccessMutex );
if ( s_threadNamHash.contains( QThread::currentThread() ) )
{
//tDebug() << Q_FUNC_INFO << "Found current thread in nam hash";
return s_threadNamHash[ QThread::currentThread() ];
}
if ( !s_threadNamHash.contains( QCoreApplication::instance()->thread() ) )
{
if ( QThread::currentThread() == QCoreApplication::instance()->thread() )
{
setNam( new QNetworkAccessManager(), true );
return s_threadNamHash[ QThread::currentThread() ];
}
else
return 0;
}
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found gui thread in nam hash";
// Create a nam for this thread based on the main thread's settings but with its own proxyfactory
QNetworkAccessManager *mainNam = s_threadNamHash[ QCoreApplication::instance()->thread() ];
QNetworkAccessManager* newNam = new QNetworkAccessManager();
newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) );
newNam->setNetworkAccessible( mainNam->networkAccessible() );
newNam->setProxyFactory( proxyFactory( false, true ) );
s_threadNamHash[ QThread::currentThread() ] = newNam;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "created new nam for thread" << QThread::currentThread();
//QNetworkProxy proxy = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( newNam->proxyFactory() )->proxy();
//tDebug() << Q_FUNC_INFO << "reply proxy properties:" << proxy.type() << proxy.hostName() << proxy.port();
return newNam;
}
void
setNam( QNetworkAccessManager* nam, bool noMutexLocker )
{
Q_ASSERT( nam );
// Don't lock if being called from nam()()
QMutex otherMutex;
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
if ( !s_threadNamHash.contains( QCoreApplication::instance()->thread() ) &&
QThread::currentThread() == QCoreApplication::instance()->thread() )
{
tDebug( LOGVERBOSE ) << "creating initial gui thread (" << QCoreApplication::instance()->thread() << ") nam";
// Should only get here on first initialization of the nam
TomahawkSettings *s = TomahawkSettings::instance();
TomahawkUtils::NetworkProxyFactory* proxyFactory = new TomahawkUtils::NetworkProxyFactory();
if ( s->proxyType() != QNetworkProxy::NoProxy && !s->proxyHost().isEmpty() )
{
tDebug( LOGVERBOSE ) << "Setting proxy to saved values";
QNetworkProxy proxy( s->proxyType(), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
proxyFactory->setProxy( proxy );
//FIXME: Jreen is broke without this
//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();
}
QNetworkProxyFactory::setApplicationProxyFactory( proxyFactory );
nam->setProxyFactory( proxyFactory );
s_threadNamHash[ QThread::currentThread() ] = nam;
s_threadProxyFactoryHash[ QThread::currentThread() ] = proxyFactory;
return;
}
s_threadNamHash[ QThread::currentThread() ] = nam;
if ( QThread::currentThread() == QCoreApplication::instance()->thread() )
setProxyFactory( dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( nam->proxyFactory() ), true );
}
bool
newerVersion( const QString& oldVersion, const QString& newVersion )
{

View File

@@ -139,6 +139,33 @@ namespace TomahawkUtils
};
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
{
public:
NetworkProxyFactory()
: m_proxy( QNetworkProxy::NoProxy )
, m_proxyChanged( false )
{}
NetworkProxyFactory( const NetworkProxyFactory &other );
virtual ~NetworkProxyFactory() {}
virtual QList< QNetworkProxy > queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );
virtual void setNoProxyHosts( const QStringList &hosts );
virtual QStringList noProxyHosts() const { return m_noProxyHosts; }
virtual void setProxy( const QNetworkProxy &proxy );
virtual QNetworkProxy proxy() { return m_proxy; }
virtual NetworkProxyFactory& operator=( const NetworkProxyFactory &rhs );
virtual bool operator==( const NetworkProxyFactory &other ) const;
bool changed() const { return m_proxyChanged; }
private:
QStringList m_noProxyHosts;
QNetworkProxy m_proxy;
bool m_proxyChanged;
};
DLLEXPORT bool headless();
DLLEXPORT void setHeadless( bool headless );
@@ -160,6 +187,10 @@ namespace TomahawkUtils
DLLEXPORT bool newerVersion( const QString& oldVersion, const QString& newVersion );
DLLEXPORT int levenshtein( const QString& source, const QString& target );
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 );
DLLEXPORT quint64 infosystemRequestId();
DLLEXPORT QString md5( const QByteArray& data );

View File

@@ -30,7 +30,6 @@
#include "utils/NetworkReply.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#include "utils/NetworkAccessManager.h"
#include "Pipeline.h"
#include "Playlist.h"
@@ -103,8 +102,8 @@ XSPFLoader::load( const QUrl& url )
m_url = url;
QNetworkRequest request( url );
Q_ASSERT( Tomahawk::Utils::nam() != 0 );
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( request ) );
Q_ASSERT( TomahawkUtils::nam() != 0 );
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( request ) );
connect( reply, SIGNAL( finished() ), SLOT( networkLoadFinished() ) );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( networkError( QNetworkReply::NetworkError ) ) );

View File

@@ -54,8 +54,6 @@
#include "jobview/JobStatusView.h"
#include "jobview/JobStatusModel.h"
#include "jobview/ErrorStatusMessage.h"
#include "utils/NetworkAccessManager.h"
#include "utils/NetworkProxyFactory.h"
#include <QDesktopServices>
#include <QFileDialog>
@@ -292,16 +290,16 @@ SettingsDialog::saveSettings()
m_collectionWidgetUi->dirTree->cleanup();
Tomahawk::Utils::NetworkProxyFactory* proxyFactory = Tomahawk::Utils::proxyFactory();
TomahawkUtils::NetworkProxyFactory* proxyFactory = TomahawkUtils::proxyFactory();
if ( !m_advancedWidgetUi->enableProxyCheckBox->isChecked() )
{
tDebug() << Q_FUNC_INFO << "Got NoProxy selected";
proxyFactory->setProxy( QNetworkProxy::NoProxy, s->proxyDns() );
proxyFactory->setProxy( QNetworkProxy::NoProxy );
}
else
{
tDebug() << Q_FUNC_INFO << "Got Socks5Proxy selected";
proxyFactory->setProxy( QNetworkProxy( QNetworkProxy::Socks5Proxy, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ), s->proxyDns() );
proxyFactory->setProxy( QNetworkProxy( QNetworkProxy::Socks5Proxy, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ) );
if ( !s->proxyNoProxyHosts().isEmpty() )
{
tDebug() << Q_FUNC_INFO << "noproxy hosts:" << s->proxyNoProxyHosts();

View File

@@ -50,7 +50,6 @@
#include "EchonestCatalogSynchronizer.h"
#include "database/DatabaseImpl.h"
#include "network/Msg.h"
#include "utils/NetworkAccessManager.h"
#include "accounts/lastfm/LastFmAccount.h"
#include "accounts/spotify/SpotifyAccount.h"
@@ -198,18 +197,8 @@ TomahawkApp::init()
new ACLRegistryImpl( this );
tDebug( LOGINFO ) << "Setting NAM.";
TomahawkSettings *s = TomahawkSettings::instance();
Tomahawk::Utils::setProxyDns( s->proxyDns() );
Tomahawk::Utils::setProxyType( s->proxyType() );
Tomahawk::Utils::setProxyHost( s->proxyHost() );
Tomahawk::Utils::setProxyPort( s->proxyPort() );
Tomahawk::Utils::setProxyUsername( s->proxyUsername() );
Tomahawk::Utils::setProxyPassword( s->proxyPassword() );
Tomahawk::Utils::setProxyNoProxyHosts( s->proxyNoProxyHosts() );
// Cause the creation of the nam, but don't need to address it directly, so prevent warning
Q_UNUSED( Tomahawk::Utils::nam() );
Q_UNUSED( TomahawkUtils::nam() );
m_audioEngine = QPointer<AudioEngine>( new AudioEngine );
@@ -628,7 +617,7 @@ TomahawkApp::onInfoSystemReady()
TomahawkSettings* s = TomahawkSettings::instance();
Echonest::Config::instance()->setNetworkAccessManager( Tomahawk::Utils::nam() );
Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );
#ifndef ENABLE_HEADLESS
EchonestGenerator::setupCatalogs();
@@ -698,7 +687,7 @@ TomahawkApp::onInfoSystemReady()
GlobalActionManager::instance();
// check if our spotify playlist api server is up and running, and enable spotify playlist drops if so
QNetworkReply* r = Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( SPOTIFY_PLAYLIST_API_URL "/pong" ) ) );
QNetworkReply* r = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( SPOTIFY_PLAYLIST_API_URL "/pong" ) ) );
connect( r, SIGNAL( finished() ), this, SLOT( spotifyApiCheckFinished() ) );
#endif

View File

@@ -443,8 +443,8 @@ TomahawkWindow::setupUpdateCheck()
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin" );
qtsparkle::Updater* updater = new qtsparkle::Updater( updaterUrl, this );
Q_ASSERT( Tomahawk::Utils::nam() != 0 );
updater->SetNetworkAccessManager( Tomahawk::Utils::nam() );
Q_ASSERT( TomahawkUtils::nam() != 0 );
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
connect( ActionCollection::instance()->getAction( "checkForUpdates" ), SIGNAL( triggered() ),