mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Don't use lastfm nam anymore, just use our in-built SOCKS support.
This commit is contained in:
@@ -64,6 +64,7 @@ LastFmPlugin::LastFmPlugin()
|
|||||||
lastfm::ws::ApiKey = "7194b85b6d1f424fe1668173a78c0c4a";
|
lastfm::ws::ApiKey = "7194b85b6d1f424fe1668173a78c0c4a";
|
||||||
lastfm::ws::SharedSecret = "ba80f1df6d27ae63e9cb1d33ccf2052f";
|
lastfm::ws::SharedSecret = "ba80f1df6d27ae63e9cb1d33ccf2052f";
|
||||||
lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername();
|
lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername();
|
||||||
|
lastfm::setNetworkAccessManager( TomahawkUtils::nam() );
|
||||||
|
|
||||||
m_pw = TomahawkSettings::instance()->lastFmPassword();
|
m_pw = TomahawkSettings::instance()->lastFmPassword();
|
||||||
|
|
||||||
|
@@ -583,9 +583,6 @@ setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker )
|
|||||||
|
|
||||||
if ( QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() )
|
if ( QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() )
|
||||||
{
|
{
|
||||||
// If setting new values on the main thread, clear the other entries
|
|
||||||
// so that on next access new ones will be created with new proper values
|
|
||||||
NetworkProxyFactory::setApplicationProxyFactory( factory );
|
|
||||||
foreach( QThread* thread, s_threadProxyFactoryHash.keys() )
|
foreach( QThread* thread, s_threadProxyFactoryHash.keys() )
|
||||||
{
|
{
|
||||||
if ( thread != QThread::currentThread() )
|
if ( thread != QThread::currentThread() )
|
||||||
@@ -608,17 +605,19 @@ nam()
|
|||||||
return s_threadNamHash[ QThread::currentThread() ];
|
return s_threadNamHash[ QThread::currentThread() ];
|
||||||
|
|
||||||
if ( !s_threadNamHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) )
|
if ( !s_threadNamHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) )
|
||||||
return 0;
|
{
|
||||||
|
if ( QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() )
|
||||||
|
{
|
||||||
|
setNam( new QNetworkAccessManager(), true );
|
||||||
|
return s_threadNamHash[ QThread::currentThread() ];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a nam for this thread based on the main thread's settings but with its own proxyfactory
|
// Create a nam for this thread based on the main thread's settings but with its own proxyfactory
|
||||||
QNetworkAccessManager *mainNam = s_threadNamHash[ TOMAHAWK_APPLICATION::instance()->thread() ];
|
QNetworkAccessManager *mainNam = s_threadNamHash[ TOMAHAWK_APPLICATION::instance()->thread() ];
|
||||||
QNetworkAccessManager* newNam;
|
QNetworkAccessManager* newNam = new QNetworkAccessManager();
|
||||||
#ifdef LIBLASTFM_FOUND
|
|
||||||
newNam = lastfm::nam();
|
|
||||||
lastfm::setNetworkAccessManager( newNam );
|
|
||||||
#else
|
|
||||||
newNam = new QNetworkAccessManager();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) );
|
newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) );
|
||||||
newNam->setNetworkAccessible( mainNam->networkAccessible() );
|
newNam->setNetworkAccessible( mainNam->networkAccessible() );
|
||||||
@@ -631,10 +630,12 @@ nam()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setNam( QNetworkAccessManager* nam )
|
setNam( QNetworkAccessManager* nam, bool noMutexLocker )
|
||||||
{
|
{
|
||||||
Q_ASSERT( nam );
|
Q_ASSERT( nam );
|
||||||
QMutexLocker locker( &s_namAccessMutex );
|
// Don't lock if being called from nam()()
|
||||||
|
QMutex otherMutex;
|
||||||
|
QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex );
|
||||||
if ( !s_threadNamHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) &&
|
if ( !s_threadNamHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) &&
|
||||||
QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() )
|
QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() )
|
||||||
{
|
{
|
||||||
@@ -644,10 +645,8 @@ setNam( QNetworkAccessManager* nam )
|
|||||||
if ( s->proxyType() != QNetworkProxy::NoProxy && !s->proxyHost().isEmpty() )
|
if ( s->proxyType() != QNetworkProxy::NoProxy && !s->proxyHost().isEmpty() )
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << "Setting proxy to saved values";
|
tDebug( LOGEXTRA ) << "Setting proxy to saved values";
|
||||||
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>( s->proxyType() ), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
QNetworkProxy proxy( s->proxyType(), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
||||||
proxyFactory->setProxy( proxy );
|
proxyFactory->setProxy( proxy );
|
||||||
//TODO: On Windows and Mac because liblastfm sets an application level proxy it may override our factory, so may need to explicitly do
|
|
||||||
//a QNetworkProxy::setApplicationProxy with our own proxy (but then also overriding our own factory :-( )
|
|
||||||
}
|
}
|
||||||
if ( !s->proxyNoProxyHosts().isEmpty() )
|
if ( !s->proxyNoProxyHosts().isEmpty() )
|
||||||
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
|
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
|
||||||
@@ -655,7 +654,6 @@ setNam( QNetworkAccessManager* nam )
|
|||||||
nam->setProxyFactory( proxyFactory );
|
nam->setProxyFactory( proxyFactory );
|
||||||
s_threadNamHash[ QThread::currentThread() ] = nam;
|
s_threadNamHash[ QThread::currentThread() ] = nam;
|
||||||
s_threadProxyFactoryHash[ QThread::currentThread() ] = proxyFactory;
|
s_threadProxyFactoryHash[ QThread::currentThread() ] = proxyFactory;
|
||||||
NetworkProxyFactory::setApplicationProxyFactory( proxyFactory );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT QNetworkAccessManager* nam();
|
DLLEXPORT QNetworkAccessManager* nam();
|
||||||
|
|
||||||
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false );
|
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false );
|
||||||
DLLEXPORT void setNam( QNetworkAccessManager* nam );
|
DLLEXPORT void setNam( QNetworkAccessManager* nam, bool noMutexLocker = false );
|
||||||
|
|
||||||
DLLEXPORT QWidget* tomahawkWindow();
|
DLLEXPORT QWidget* tomahawkWindow();
|
||||||
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
|
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
|
||||||
|
@@ -160,13 +160,8 @@ TomahawkApp::init()
|
|||||||
new ActionCollection( this );
|
new ActionCollection( this );
|
||||||
|
|
||||||
tDebug( LOGINFO ) << "Setting NAM.";
|
tDebug( LOGINFO ) << "Setting NAM.";
|
||||||
#ifndef LIBLASTFM_FOUND
|
// Cause the creation of the nam, but don't need to address it directly, so prevent warning
|
||||||
TomahawkUtils::setNam( new QNetworkAccessManager() );
|
Q_UNUSED( TomahawkUtils::nam() );
|
||||||
#else
|
|
||||||
TomahawkUtils::setNam( lastfm::nam() );
|
|
||||||
//Ensure that liblastfm2 won't delete the nam out from under us, even though they created it
|
|
||||||
lastfm::setNetworkAccessManager( TomahawkUtils::nam() );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
|
m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
|
||||||
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
||||||
|
Reference in New Issue
Block a user