diff --git a/src/libtomahawk/utils/WebResultHintChecker.cpp b/src/libtomahawk/utils/WebResultHintChecker.cpp index 444337184..ddea82547 100644 --- a/src/libtomahawk/utils/WebResultHintChecker.cpp +++ b/src/libtomahawk/utils/WebResultHintChecker.cpp @@ -15,22 +15,23 @@ * You should have received a copy of the GNU General Public License * along with Tomahawk. If not, see . */ + #include "WebResultHintChecker.h" +#include +#include +#include + #include "Query.h" #include "Result.h" #include "Source.h" -#include "utils/Closure.h" -#include "utils/Logger.h" #include "Pipeline.h" - -#include -#include -#include -#include +#include "utils/NetworkReply.h" +#include "utils/Logger.h" using namespace Tomahawk; + WebResultHintChecker::WebResultHintChecker( const query_ptr& q ) : QObject( 0 ) , m_query( q ) @@ -45,9 +46,9 @@ WebResultHintChecker::WebResultHintChecker( const query_ptr& q ) check( QUrl::fromUserInput( m_url ) ); } + WebResultHintChecker::~WebResultHintChecker() { - } @@ -62,7 +63,7 @@ WebResultHintChecker::checkQuery( const query_ptr& query ) void WebResultHintChecker::checkQueries( const QList< query_ptr >& queries ) { - foreach ( const query_ptr& query, queries ) + foreach ( const query_ptr& query, queries ) checkQuery( query ); } @@ -89,8 +90,8 @@ WebResultHintChecker::check( const QUrl &url ) return; } - QNetworkReply* reply = TomahawkUtils::nam()->head( QNetworkRequest( url ) ); - NewClosure( reply, SIGNAL( finished() ), this, SLOT( headFinished( QNetworkReply* ) ), reply ); + NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->head( QNetworkRequest( url ) ) ); + connect( reply, SIGNAL( finished() ), SLOT( headFinished() ) ); } @@ -118,19 +119,12 @@ WebResultHintChecker::removeHint() void -WebResultHintChecker::headFinished( QNetworkReply* reply ) +WebResultHintChecker::headFinished() { - reply->deleteLater(); + NetworkReply* r = qobject_cast( sender() ); + r->deleteLater(); - const QUrl redir = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl(); - if ( redir.isValid() ) - { - const QUrl url = reply->url().resolved( redir ); - check( url ); - - return; - } - else if ( reply->error() != QNetworkReply::NoError ) + if ( r->reply()->error() != QNetworkReply::NoError ) { // Error getting headers for the http resulthint, remove it from the result // as it's definitely not playable diff --git a/src/libtomahawk/utils/WebResultHintChecker.h b/src/libtomahawk/utils/WebResultHintChecker.h index cdfeee8d7..58dc79c95 100644 --- a/src/libtomahawk/utils/WebResultHintChecker.h +++ b/src/libtomahawk/utils/WebResultHintChecker.h @@ -22,9 +22,8 @@ #include -class QNetworkReply; - -namespace Tomahawk { +namespace Tomahawk +{ class WebResultHintChecker : public QObject { @@ -37,7 +36,7 @@ public: static void checkQueries( const QList< query_ptr >& queries ); private slots: - void headFinished( QNetworkReply* reply ); + void headFinished(); void check( const QUrl& url );