Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Fixed TWK-856: XSPFLoader now follows HTTP redirects (by using our …

…own NetworkReply).
  • Loading branch information...
commit eec48e6ad72ee36b697b4573186dfdf072a9a9ff 1 parent 082f46f
@muesli muesli authored
Showing with 21 additions and 18 deletions.
  1. +21 −18 src/libtomahawk/utils/XspfLoader.cpp
View
39 src/libtomahawk/utils/XspfLoader.cpp
@@ -24,9 +24,6 @@
#include <QDomDocument>
-#include "utils/TomahawkUtils.h"
-#include "utils/Logger.h"
-
#ifndef ENABLE_HEADLESS
#include "jobview/JobStatusView.h"
#include "jobview/JobStatusModel.h"
@@ -38,6 +35,10 @@
#include <XspfUpdater.h>
#include <Pipeline.h>
+#include "utils/NetworkReply.h"
+#include "utils/TomahawkUtils.h"
+#include "utils/Logger.h"
+
using namespace Tomahawk;
@@ -64,7 +65,7 @@ XSPFLoader::XSPFLoader( bool autoCreate, bool autoUpdate, QObject* parent )
, m_autoUpdate( autoUpdate )
, m_autoResolve( true )
, m_autoDelete( true )
- , m_NS("http://xspf.org/ns/0/")
+ , m_NS( "http://xspf.org/ns/0/" )
{
qRegisterMetaType< XSPFErrorCode >("XSPFErrorCode");
}
@@ -99,17 +100,14 @@ XSPFLoader::title() const
void
XSPFLoader::load( const QUrl& url )
{
- QNetworkRequest request( url );
m_url = url;
+ QNetworkRequest request( url );
Q_ASSERT( TomahawkUtils::nam() != 0 );
- QNetworkReply* reply = TomahawkUtils::nam()->get( request );
-
- connect( reply, SIGNAL( finished() ),
- SLOT( networkLoadFinished() ) );
+ NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( request ) );
- connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
- SLOT( networkError( QNetworkReply::NetworkError ) ) );
+ connect( reply, SIGNAL( finished() ), SLOT( networkLoadFinished() ) );
+ connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( networkError( QNetworkReply::NetworkError ) ) );
}
@@ -133,7 +131,7 @@ XSPFLoader::reportError()
{
emit error( FetchError );
#ifndef ENABLE_HEADLESS
- const QString errorMsg = errorToString( FetchError);
+ const QString errorMsg = errorToString( FetchError );
if ( !m_errorTitle.isEmpty() )
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( QString( "%1: %2" ).arg( m_errorTitle ).arg( errorMsg ) ) );
else
@@ -146,12 +144,14 @@ XSPFLoader::reportError()
void
XSPFLoader::networkLoadFinished()
{
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
- if ( reply->error() != QNetworkReply::NoError )
- return;
+ NetworkReply* r = qobject_cast<NetworkReply*>( sender() );
+ if ( r->reply()->error() == QNetworkReply::NoError )
+ {
+ m_body = r->reply()->readAll();
+ gotBody();
+ }
- m_body = reply->readAll();
- gotBody();
+ r->deleteLater();
}
@@ -159,6 +159,9 @@ void
XSPFLoader::networkError( QNetworkReply::NetworkError /* error */ )
{
reportError();
+
+ NetworkReply* r = qobject_cast<NetworkReply*>( sender() );
+ r->deleteLater();
}
@@ -293,7 +296,7 @@ XSPFLoader::gotBody()
else
{
- if( !m_entries.isEmpty() )
+ if ( !m_entries.isEmpty() )
emit tracks( m_entries );
}
Please sign in to comment.
Something went wrong with that request. Please try again.