Browse files

* WebResultHintChecker now uses our own NetworkReply.

  • Loading branch information...
1 parent b9191a3 commit 2bc2d8c0f4c252ff95a1bd96b3c73a39ba6fc52f @muesli muesli committed Nov 14, 2012
Showing with 19 additions and 26 deletions.
  1. +16 −22 src/libtomahawk/utils/WebResultHintChecker.cpp
  2. +3 −4 src/libtomahawk/utils/WebResultHintChecker.h
View
38 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 <http://www.gnu.org/licenses/>.
*/
+
#include "WebResultHintChecker.h"
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QUrl>
+
#include "Query.h"
#include "Result.h"
#include "Source.h"
-#include "utils/Closure.h"
-#include "utils/Logger.h"
#include "Pipeline.h"
-
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QUrl>
+#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<NetworkReply*>( 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
View
7 src/libtomahawk/utils/WebResultHintChecker.h
@@ -22,9 +22,8 @@
#include <QObject>
-class QNetworkReply;
-
-namespace Tomahawk {
+namespace Tomahawk
+{
class WebResultHintChecker : public QObject
{
@@ -37,7 +36,7 @@ class WebResultHintChecker : public QObject
static void checkQueries( const QList< query_ptr >& queries );
private slots:
- void headFinished( QNetworkReply* reply );
+ void headFinished();
void check( const QUrl& url );

0 comments on commit 2bc2d8c

Please sign in to comment.