From fd1c133e249929e425d771c9ee15c39dc41bc9ce Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 8 Jan 2012 17:46:50 +0000 Subject: [PATCH] Display any SSL or HTTP errors that occur when creating a grooveshark session (cherry picked from commit ff92815ef071abcbddf0bc7c60ffb471716d9465) --- src/internet/groovesharkservice.cpp | 21 +++++++++++++++++++++ src/internet/groovesharkservice.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/internet/groovesharkservice.cpp b/src/internet/groovesharkservice.cpp index 5c9fd3fcd..87b6ca948 100644 --- a/src/internet/groovesharkservice.cpp +++ b/src/internet/groovesharkservice.cpp @@ -366,6 +366,13 @@ void GroovesharkService::SessionCreated() { reply->deleteLater(); + if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) { + emit StreamError("Failed to create Grooveshark session: " + + reply->errorString()); + emit LoginFinished(false); + return; + } + QVariantMap result = ExtractResult(reply); if (!result["success"].toBool()) { qLog(Error) << "Grooveshark returned an error during session creation"; @@ -1377,9 +1384,23 @@ QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name, QLi QNetworkRequest req(url); QNetworkReply *reply = network_->post(req, post_params); + if (use_https) { + connect(reply, SIGNAL(sslErrors(QList)), + SLOT(RequestSslErrors(QList))); + } + return reply; } +void GroovesharkService::RequestSslErrors(const QList& errors) { + QNetworkReply* reply = qobject_cast(sender()); + + foreach (const QSslError& error, errors) { + emit StreamError("SSL error occurred in Grooveshark request for " + + reply->url().toString() + ": " + error.errorString()); + } +} + bool GroovesharkService::WaitForReply(QNetworkReply* reply) { QEventLoop event_loop; QTimer timeout_timer; diff --git a/src/internet/groovesharkservice.h b/src/internet/groovesharkservice.h index 384744d27..8dbb97aa3 100644 --- a/src/internet/groovesharkservice.h +++ b/src/internet/groovesharkservice.h @@ -21,6 +21,8 @@ #include "internetmodel.h" #include "internetservice.h" +#include + class GroovesharkUrlHandler; class NetworkAccessManager; class Playlist; @@ -174,6 +176,8 @@ class GroovesharkService : public InternetService { void StreamMarked(); void SongMarkedAsComplete(); + void RequestSslErrors(const QList& errors); + void Homepage(); // Refresh all Grooveshark's items, and re-fill them void RefreshItems();