[rhythmbox] audioscrobbler: cancel playlist request if radio tuning is unsuccessful



commit 9ebdc2ea4d40001dcf54a00bf69b524826a9cd48
Author: Jamie Nicol <jamie thenicols net>
Date:   Tue Jul 13 15:01:21 2010 +0100

    audioscrobbler: cancel playlist request if radio tuning is unsuccessful

 .../rb-audioscrobbler-radio-source.c               |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index c8f8184..601ef8e 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -134,6 +134,8 @@ struct _RBAudioscrobblerRadioSourcePrivate
 	RhythmDBQueryModel *track_model;
 
 	gboolean is_fetching_playlist;
+	/* keep pointer to request so it can be cancelled if tuning fails */
+	SoupMessage *fetch_playlist_request;
 
 	RBPlayOrder *play_order;
 
@@ -568,8 +570,6 @@ rb_audioscrobbler_radio_source_tune (RBAudioscrobblerRadioSource *source)
 	                            rb_audioscrobbler_radio_source_tune_response_cb,
 	                            source);
 
-	rb_audioscrobbler_radio_source_fetch_playlist (source);
-
 	g_free (sig_arg);
 	g_free (sig);
 	g_free (request);
@@ -636,6 +636,14 @@ rb_audioscrobbler_radio_source_tune_response_cb (SoupSession *session,
 
 			g_free (info_message);
 		}
+
+		/* if a playlist request is queued then cancel it */
+		if (source->priv->fetch_playlist_request != NULL) {
+			soup_session_cancel_message (source->priv->soup_session,
+			                             source->priv->fetch_playlist_request,
+			                             SOUP_STATUS_CANCELLED);
+			source->priv->fetch_playlist_request = NULL;
+		}
 	}
 }
 
@@ -677,6 +685,9 @@ rb_audioscrobbler_radio_source_fetch_playlist (RBAudioscrobblerRadioSource *sour
 	                            rb_audioscrobbler_radio_source_fetch_playlist_response_cb,
 	                            source);
 
+	/* keep pointer to message so it can be cancelled if need be */
+	source->priv->fetch_playlist_request = msg;
+
 	g_free (sig_arg);
 	g_free (sig);
 	g_free (request);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]