[rhythmbox] audioscrobbler: fallback to old radio api when appropriate



commit 2dc802c9d160dbaca7c93331516c4670d1a94b9e
Author: Jamie Nicol <jamie thenicols net>
Date:   Fri Jul 23 23:26:48 2010 +0100

    audioscrobbler: fallback to old radio api when appropriate
    
    If tuning radio fails with error code 4 then attempt to tune using the old
    API as that will allow non-subscribers to tune. The user's password must be
    set using rb_audioscrobbler_radio_source_set_old_api_password before this
    will work.

 .../rb-audioscrobbler-radio-source.c               |  377 ++++++++++++++++----
 .../rb-audioscrobbler-radio-source.h               |    3 +
 plugins/audioscrobbler/rb-audioscrobbler-service.c |   26 ++
 plugins/audioscrobbler/rb-audioscrobbler-service.h |    1 +
 4 files changed, 338 insertions(+), 69 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index a726336..679c5c6 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -135,9 +135,7 @@ struct _RBAudioscrobblerRadioSourcePrivate
 	RBEntryView *track_view;
 	RhythmDBQueryModel *track_model;
 
-	gboolean is_fetching_playlist;
-	/* keep pointer to request so it can be cancelled if tuning fails */
-	SoupMessage *fetch_playlist_request;
+	gboolean is_busy;
 
 	RBPlayOrder *play_order;
 
@@ -147,6 +145,13 @@ struct _RBAudioscrobblerRadioSourcePrivate
 	guint emit_coverart_id;
 
 	GtkActionGroup *action_group;
+
+	/* used when streaming radio using old api */
+	char *old_api_password;
+	char *old_api_session_id;
+	char *old_api_base_url;
+	char *old_api_base_path;
+	gboolean old_api_is_banned;
 };
 
 #define RB_AUDIOSCROBBLER_RADIO_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_AUDIOSCROBBLER_RADIO_SOURCE, RBAudioscrobblerRadioSourcePrivate))
@@ -183,6 +188,17 @@ static void xspf_entry_parsed (TotemPlParser *parser,
                                GHashTable *metadata,
                                RBAudioscrobblerRadioSource *source);
 
+/* old api */
+static void old_api_shake_hands (RBAudioscrobblerRadioSource *source);
+static void old_api_handshake_response_cb (SoupSession *session,
+                                           SoupMessage *msg,
+                                           gpointer user_data);
+static void old_api_tune (RBAudioscrobblerRadioSource *source);
+static void old_api_tune_response_cb (SoupSession *session,
+                                      SoupMessage *msg,
+                                      gpointer user_data);
+static void old_api_fetch_playlist (RBAudioscrobblerRadioSource *source);
+
 /* action callbacks */
 static void rename_station_action_cb (GtkAction *action,
                                       RBAudioscrobblerRadioSource *source);
@@ -361,9 +377,6 @@ rb_audioscrobbler_radio_source_init (RBAudioscrobblerRadioSource *source)
 		soup_session_async_new_with_options (SOUP_SESSION_ADD_FEATURE_BY_TYPE,
 		                                     SOUP_TYPE_GNOME_FEATURES_2_26,
 		                                     NULL);
-
-	/* one connection at a time means getPlaylist will only be sent after tune has returned */
-	g_object_set (source->priv->soup_session, "max-conns", 1, NULL);
 }
 
 static void
@@ -478,6 +491,11 @@ rb_audioscrobbler_radio_source_finalize (GObject *object)
 	g_free (source->priv->session_key);
 	g_free (source->priv->station_url);
 
+	g_free (source->priv->old_api_password);
+	g_free (source->priv->old_api_session_id);
+	g_free (source->priv->old_api_base_url);
+	g_free (source->priv->old_api_base_path);
+
 	G_OBJECT_CLASS (rb_audioscrobbler_radio_source_parent_class)->finalize (object);
 }
 
@@ -592,7 +610,6 @@ playing_song_changed_cb (RBShellPlayer *player,
 		/* request more if needed */
 		if (entries_after_playing <= 2) {
 			tune (source);
-			fetch_playlist (source);
 		}
 
 		/* emit cover art notification */
@@ -614,6 +631,14 @@ tune (RBAudioscrobblerRadioSource *source)
 	char *msg_url;
 	SoupMessage *msg;
 
+	/* only go through the tune + get playlist process once at a time */
+	if (source->priv->is_busy == TRUE) {
+		return;
+	}
+
+	source->priv->is_busy = TRUE;
+	gtk_widget_hide (source->priv->info_bar);
+
 	sig_arg = g_strdup_printf ("api_key%smethodradio.tunesk%sstation%s%s",
 	                           rb_audioscrobbler_service_get_api_key (source->priv->service),
 	                           source->priv->session_key,
@@ -634,6 +659,7 @@ tune (RBAudioscrobblerRadioSource *source)
 	msg_url = g_strdup_printf ("%s?format=json",
 	                           rb_audioscrobbler_service_get_api_url (source->priv->service));
 
+	rb_debug ("sending tune request: %s", request);
 	msg = soup_message_new ("POST", msg_url);
 	soup_message_set_request (msg,
 	                          "application/x-www-form-urlencoded",
@@ -659,64 +685,78 @@ tune_response_cb (SoupSession *session,
 {
 	RBAudioscrobblerRadioSource *source;
 	JsonParser *parser;
-	JsonObject *root_object;
 
 	source = RB_AUDIOSCROBBLER_RADIO_SOURCE (user_data);
 	parser = json_parser_new ();
-	json_parser_load_from_data (parser, msg->response_body->data, msg->response_body->length, NULL);
-	root_object = json_node_get_object (json_parser_get_root (parser));
 
-	if (json_object_has_member (root_object, "station")) {
-		JsonObject *station_object;
+	if (msg->response_body->data == NULL) {
+		rb_debug ("no response from tune request");
+		gtk_label_set_label (GTK_LABEL (source->priv->info_bar_label), _("Error tuning station: no response"));
+		gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->info_bar), GTK_MESSAGE_WARNING);
+		gtk_widget_show_all (source->priv->info_bar);
+		source->priv->is_busy = FALSE;
+
+	} else if (json_parser_load_from_data (parser, msg->response_body->data, msg->response_body->length, NULL)) {
+		JsonObject *root_object;
+		root_object = json_node_get_object (json_parser_get_root (parser));
 
-		station_object = json_object_get_object_member (root_object, "station");
-		/* TODO: do something fun with this information */
+		if (json_object_has_member (root_object, "station")) {
+			JsonObject *station_object;
 
-	} else if (json_object_has_member (root_object, "error")) {
-		int code;
-		const char *message;
-		char *error_message = NULL;
+			station_object = json_object_get_object_member (root_object, "station");
+			/* TODO: do something fun with this information */
 
-		code = json_object_get_int_member (root_object, "error");
-		message = json_object_get_string_member (root_object, "message");
+			rb_debug ("tune request was successful");
 
-		rb_debug ("radio.tune responded with error: %s", message);
+			/* get the playlist */
+			fetch_playlist (source);
+		} else if (json_object_has_member (root_object, "error")) {
+			int code;
+			const char *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;
-		}
+			code = json_object_get_int_member (root_object, "error");
+			message = json_object_get_string_member (root_object, "message");
 
-		/* show appropriate error message */
-		if (code == 4) {
-			/* Our API key only allows streaming of radio to subscribers.
-			 * TODO: Fall back to using old API
-			 */
-			error_message = g_strdup_printf (_("This station is only available to %s subscribers"),
-			                                 rb_audioscrobbler_service_get_name (source->priv->service));
-		} else if (code == 6) {
-			/* Invalid station url */
-			error_message = g_strdup (_("Invalid station URL"));
-		} else if (code == 12) {
-			/* Subscriber only station */
-			error_message = g_strdup_printf (_("This station is only available to %s subscribers"),
-			                                 rb_audioscrobbler_service_get_name (source->priv->service));
-		} else if (code == 20) {
-			/* Not enough content */
-			error_message = g_strdup (_("Not enough content to play station"));
-		} else {
-			/* Other error */
-			error_message = g_strdup_printf ("Error tuning station: %i - %s", code, message);
-		}
+			rb_debug ("tune request responded with error: %s", message);
 
-		gtk_label_set_label (GTK_LABEL (source->priv->info_bar_label), error_message);
+			if (code == 4) {
+				/* Our API key only allows streaming of radio to subscribers */
+				rb_debug ("attempting to use old API to tune radio");
+				old_api_tune (source);
+			} else {
+				/* show appropriate error message */
+				char *error_message = NULL;
+
+				if (code == 6) {
+					/* Invalid station url */
+					error_message = g_strdup (_("Invalid station URL"));
+				} else if (code == 12) {
+					/* Subscriber only station */
+					error_message = g_strdup_printf (_("This station is only available to %s subscribers"),
+							                 rb_audioscrobbler_service_get_name (source->priv->service));
+				} else if (code == 20) {
+					/* Not enough content */
+					error_message = g_strdup (_("Not enough content to play station"));
+				} else {
+					/* Other error */
+					error_message = g_strdup_printf ("Error tuning station: %i - %s", code, message);
+				}
+
+				gtk_label_set_label (GTK_LABEL (source->priv->info_bar_label), error_message);
+				gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->info_bar), GTK_MESSAGE_WARNING);
+				gtk_widget_show_all (source->priv->info_bar);
+
+				g_free (error_message);
+
+				source->priv->is_busy = FALSE;
+			}
+		}
+	} else {
+		rb_debug ("invalid response from tune request: %s", msg->response_body->data);
+		gtk_label_set_label (GTK_LABEL (source->priv->info_bar_label), _("Error tuning station: invalid response"));
 		gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->info_bar), GTK_MESSAGE_WARNING);
 		gtk_widget_show_all (source->priv->info_bar);
-
-		g_free (error_message);
+		source->priv->is_busy = FALSE;
 	}
 }
 
@@ -728,13 +768,6 @@ fetch_playlist (RBAudioscrobblerRadioSource *source)
 	char *request;
 	SoupMessage *msg;
 
-	if (source->priv->is_fetching_playlist == TRUE) {
-		rb_debug ("already fetching playlist");
-		return;
-	}
-
-	source->priv->is_fetching_playlist = TRUE;
-
 	sig_arg = g_strdup_printf ("api_key%smethodradio.getPlaylistrawtruesk%s%s",
 	                           rb_audioscrobbler_service_get_api_key (source->priv->service),
 	                           source->priv->session_key,
@@ -747,6 +780,7 @@ fetch_playlist (RBAudioscrobblerRadioSource *source)
 	                           sig,
 	                           source->priv->session_key);
 
+	rb_debug ("sending playlist request: %s", request);
 	msg = soup_message_new ("POST", rb_audioscrobbler_service_get_api_url (source->priv->service));
 	soup_message_set_request (msg,
 	                          "application/x-www-form-urlencoded",
@@ -758,9 +792,6 @@ fetch_playlist (RBAudioscrobblerRadioSource *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);
@@ -782,15 +813,13 @@ fetch_playlist_response_cb (SoupSession *session,
 
 	source = RB_AUDIOSCROBBLER_RADIO_SOURCE (user_data);
 
-	source->priv->is_fetching_playlist = FALSE;
+	source->priv->is_busy = FALSE;
 
-	if (msg->response_body->length == 0) {
-		rb_debug ("didn't get a response");
+	if (msg->response_body->data == NULL) {
+		rb_debug ("no response from get playlist request");
 		return;
 	}
 
-	rb_debug ("%s", msg->response_body->data);
-
 	/* until totem-pl-parser can parse playlists from in-memory data, we save it to a
 	 * temporary file.
 	 */
@@ -937,6 +966,217 @@ xspf_entry_parsed (TotemPlParser *parser,
 	g_object_unref (db);
 }
 
+void
+rb_audioscrobbler_radio_source_set_old_api_password (RBAudioscrobblerRadioSource *source,
+                                                     const char *password)
+{
+	g_free (source->priv->old_api_password);
+	source->priv->old_api_password = g_strdup (password);
+
+	g_free (source->priv->old_api_session_id);
+	source->priv->old_api_session_id = NULL;
+}
+
+static void
+old_api_shake_hands (RBAudioscrobblerRadioSource *source)
+{
+	if (source->priv->old_api_password != NULL) {
+		char *password_hash;
+		char *msg_url;
+		SoupMessage *msg;
+
+		password_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, source->priv->old_api_password, -1);
+
+		msg_url = g_strdup_printf ("%sradio/handshake.php?username=%s&passwordmd5=%s",
+			                   rb_audioscrobbler_service_get_old_radio_api_url (source->priv->service),
+			                   source->priv->username,
+			                   password_hash);
+
+		rb_debug ("sending old api handshake request: %s", msg_url);
+		msg = soup_message_new ("GET", msg_url);
+		soup_session_queue_message (source->priv->soup_session,
+			                    msg,
+			                    old_api_handshake_response_cb,
+			                    source);
+
+		g_free (password_hash);
+		g_free (msg_url);
+	} else {
+		rb_debug ("cannot shake hands: no old api password is set");
+		source->priv->is_busy = FALSE;
+	}
+}
+
+static void
+old_api_handshake_response_cb (SoupSession *session,
+                               SoupMessage *msg,
+                               gpointer user_data)
+{
+	RBAudioscrobblerRadioSource *source;
+
+	source = RB_AUDIOSCROBBLER_RADIO_SOURCE (user_data);
+
+	if (msg->response_body->data == NULL) {
+		g_free (source->priv->old_api_session_id);
+		source->priv->old_api_session_id = NULL;
+		rb_debug ("handshake failed: no response");
+	} else {
+		char **pieces;
+		int i;
+
+		pieces = g_strsplit (msg->response_body->data, "\n", 0);
+		for (i = 0; pieces[i] != NULL; i++) {
+			gchar **values = g_strsplit (pieces[i], "=", 2);
+
+			if (values[0] == NULL) {
+				rb_debug ("unexpected response content: %s", pieces[i]);
+			} else if (strcmp (values[0], "session") == 0) {
+				if (strcmp (values[1], "FAILED") == 0) {
+					g_free (source->priv->old_api_session_id);
+					source->priv->old_api_session_id = NULL;
+					rb_debug ("handshake failed");
+				} else {
+					g_free (source->priv->old_api_session_id);
+					source->priv->old_api_session_id = g_strdup (values[1]);
+					rb_debug ("session ID: %s", source->priv->old_api_session_id);
+				}
+			} else if (strcmp (values[0], "base_url") == 0) {
+				g_free (source->priv->old_api_base_url);
+				source->priv->old_api_base_url = g_strdup (values[1]);
+				rb_debug ("base url: %s", source->priv->old_api_base_url);
+			} else if (strcmp (values[0], "base_path") == 0) {
+				g_free (source->priv->old_api_base_path);
+				source->priv->old_api_base_path = g_strdup (values[1]);
+				rb_debug ("base path: %s", source->priv->old_api_base_path);
+			} else if (strcmp (values[0], "banned") == 0) {
+				if (strcmp (values[1], "0") != 0) {
+					source->priv->old_api_is_banned = TRUE;
+				} else {
+					source->priv->old_api_is_banned = FALSE;
+				}
+				rb_debug ("banned: %i", source->priv->old_api_is_banned);
+			}
+
+			g_strfreev (values);
+		}
+		g_strfreev (pieces);
+	}
+
+	/* if handshake was successful then tune */
+	if (source->priv->old_api_session_id != NULL) {
+		old_api_tune (source);
+	} else {
+		source->priv->is_busy = FALSE;
+	}
+}
+
+static void
+old_api_tune (RBAudioscrobblerRadioSource *source)
+{
+	/* get a handshake first if we don't have one */
+	if (source->priv->old_api_session_id == NULL) {
+		old_api_shake_hands (source);
+	} else {
+		char *escaped_station_url;
+		char *msg_url;
+		SoupMessage *msg;
+
+		escaped_station_url = g_uri_escape_string (source->priv->station_url, NULL, FALSE);
+
+		msg_url = g_strdup_printf("http://%s%s/adjust.php?session=%s&url=%s";,
+			                  source->priv->old_api_base_url,
+			                  source->priv->old_api_base_path,
+			                  source->priv->old_api_session_id,
+			                  escaped_station_url);
+
+		rb_debug ("sending old api tune request: %s", msg_url);
+		msg = soup_message_new ("GET", msg_url);
+		soup_session_queue_message (source->priv->soup_session,
+			                    msg,
+			                    old_api_tune_response_cb,
+			                    source);
+
+		g_free (escaped_station_url);
+		g_free (msg_url);
+	}
+}
+
+static void
+old_api_tune_response_cb (SoupSession *session,
+                          SoupMessage *msg,
+                          gpointer user_data)
+{
+	RBAudioscrobblerRadioSource *source;
+
+	source = RB_AUDIOSCROBBLER_RADIO_SOURCE (user_data);
+
+	if (msg->response_body->data != NULL) {
+		char **pieces;
+		int i;
+
+		pieces = g_strsplit (msg->response_body->data, "\n", 0);
+		for (i = 0; pieces[i] != NULL; i++) {
+			gchar **values = g_strsplit (pieces[i], "=", 2);
+
+			if (values[0] == NULL) {
+				rb_debug ("unexpected response from old api tune request: %s", pieces[i]);
+			} else if (strcmp (values[0], "response") == 0) {
+				if (strcmp (values[1], "OK") == 0) {
+					rb_debug ("old api tune request was successful");
+					/* no problems tuning, get the playlist */
+					old_api_fetch_playlist (source);
+				}
+			} else if (strcmp (values[0], "error") == 0) {
+				char *error_message;
+				rb_debug ("old api tune request responded with error: %s", pieces[i]);
+
+				error_message = g_strdup_printf (_("Error tuning station: %s"), values[1]);
+				gtk_label_set_label (GTK_LABEL (source->priv->info_bar_label), error_message);
+				gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->info_bar), GTK_MESSAGE_WARNING);
+				gtk_widget_show_all (source->priv->info_bar);
+
+				g_free (error_message);
+
+				source->priv->is_busy = FALSE;
+			}
+			/* TODO: do something with other information given here */
+
+			g_strfreev (values);
+		}
+
+		g_strfreev (pieces);
+	} else {
+		rb_debug ("no response from old api tune request");
+		gtk_label_set_label (GTK_LABEL (source->priv->info_bar_label), _("Error tuning station: no response"));
+		gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->info_bar), GTK_MESSAGE_WARNING);
+		gtk_widget_show_all (source->priv->info_bar);
+		source->priv->is_busy = FALSE;
+	}
+}
+
+static void
+old_api_fetch_playlist (RBAudioscrobblerRadioSource *source)
+{
+	char *msg_url;
+	SoupMessage *msg;
+
+	msg_url = g_strdup_printf("http://%s%s/xspf.php?sk=%s&discovery=%i&desktop=%s";,
+		                  source->priv->old_api_base_url,
+		                  source->priv->old_api_base_path,
+		                  source->priv->old_api_session_id,
+		                  0,
+		                  "1.5");
+
+	rb_debug ("sending old api playlist request: %s", msg_url);
+	msg = soup_message_new ("GET", msg_url);
+	soup_session_queue_message (source->priv->soup_session,
+		                    msg,
+		                    fetch_playlist_response_cb,
+		                    source);
+
+	g_free (msg_url);
+}
+
 static void
 rename_station_action_cb (GtkAction *action, RBAudioscrobblerRadioSource *source)
 {
@@ -1059,7 +1299,6 @@ impl_activate (RBSource *asource)
 	/* if the query model is empty then attempt to add some tracks to it */
 	if (rhythmdb_query_model_get_duration (source->priv->track_model) == 0) {
 		tune (source);
-		fetch_playlist (source);
 	}
 }
 
@@ -1077,7 +1316,7 @@ impl_get_status (RBSource *asource, char **text, char **progress_text, float *pr
 	RBAudioscrobblerRadioSource *source = RB_AUDIOSCROBBLER_RADIO_SOURCE (asource);
 
 	/* pulse progressbar if we're busy, otherwise see what the streaming source part of us has to say */
-	if (source->priv->is_fetching_playlist) {
+	if (source->priv->is_busy) {
 		/* We could be calling either radio.tune or radio.getPlaylist methods.
 		 * "Tuning station" seems like a user friendly message to display for both cases.
 		 */
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h
index c1af4e4..5468c0b 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h
@@ -83,6 +83,9 @@ RBSource *rb_audioscrobbler_radio_source_new (RBAudioscrobblerProfileSource *par
                                               const char *station_name,
                                               const char *station_url);
 
+void rb_audioscrobbler_radio_source_set_old_api_password (RBAudioscrobblerRadioSource *source,
+                                                          const char *password);
+
 G_END_DECLS
 
 #endif /* __RB_AUDIOSCROBBLER_RADIO_SOURCE_H */
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-service.c b/plugins/audioscrobbler/rb-audioscrobbler-service.c
index 7484570..c5bfe24 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-service.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-service.c
@@ -33,6 +33,7 @@
 #define LASTFM_AUTH_URL "http://www.last.fm/api/auth/";
 #define LASTFM_SCROBBLER_URL "http://post.audioscrobbler.com/";
 #define LASTFM_API_URL "http://ws.audioscrobbler.com/2.0/";
+#define LASTFM_OLD_RADIO_API_URL "http://ws.audioscrobbler.com/";
 /* this API key belongs to Jamie Nicol <jamie thenicols net>
    generated May 2010 for use in the audioscrobbler plugin */
 #define LASTFM_API_KEY "0337ff3c59299b6a31d75164041860b6"
@@ -50,6 +51,7 @@ struct _RBAudioscrobblerServicePrivate {
 	char *auth_url;
 	char *scrobbler_url;
 	char *api_url;
+	char *old_radio_api_url;
 	char *api_key;
 	char *api_secret;
 };
@@ -75,6 +77,7 @@ enum
 	PROP_AUTH_URL,
 	PROP_SCROBBLER_URL,
 	PROP_API_URL,
+	PROP_OLD_RADIO_API_URL,
 	PROP_API_KEY,
 	PROP_API_SECRET,
 };
@@ -90,6 +93,7 @@ rb_audioscrobbler_service_new_lastfm (void)
 	                     "auth-url", LASTFM_AUTH_URL,
 	                     "scrobbler-url", LASTFM_SCROBBLER_URL,
 	                     "api-url", LASTFM_API_URL,
+	                     "old-radio-api-url", LASTFM_OLD_RADIO_API_URL,
 	                     "api-key", LASTFM_API_KEY,
 	                     "api-secret", LASTFM_API_SECRET,
 	                     NULL);
@@ -151,6 +155,14 @@ rb_audioscrobbler_service_class_init (RBAudioscrobblerServiceClass *klass)
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
 	g_object_class_install_property (object_class,
+	                                 PROP_OLD_RADIO_API_URL,
+	                                 g_param_spec_string ("old-radio-api-url",
+	                                                      "Old Radio API URL",
+	                                                      "URL that radio requests using the old API should be sent to",
+	                                                      NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+	g_object_class_install_property (object_class,
 	                                 PROP_API_KEY,
 	                                 g_param_spec_string ("api-key",
 	                                                      "API Key",
@@ -184,6 +196,7 @@ rb_audioscrobbler_service_finalize (GObject *object)
 	g_free (service->priv->auth_url);
 	g_free (service->priv->scrobbler_url);
 	g_free (service->priv->api_url);
+	g_free (service->priv->old_radio_api_url);
 	g_free (service->priv->api_key);
 	g_free (service->priv->api_secret);
 
@@ -211,6 +224,9 @@ rb_audioscrobbler_service_get_property (GObject *object,
 	case PROP_API_URL:
 		g_value_set_string (value, rb_audioscrobbler_service_get_api_url (service));
 		break;
+	case PROP_OLD_RADIO_API_URL:
+		g_value_set_string (value, rb_audioscrobbler_service_get_old_radio_api_url (service));
+		break;
 	case PROP_API_KEY:
 		g_value_set_string (value, rb_audioscrobbler_service_get_api_key (service));
 		break;
@@ -248,6 +264,10 @@ rb_audioscrobbler_service_set_property (GObject *object,
 		g_free (service->priv->api_url);
 		service->priv->api_url = g_value_dup_string (value);
 		break;
+	case PROP_OLD_RADIO_API_URL:
+		g_free (service->priv->old_radio_api_url);
+		service->priv->old_radio_api_url = g_value_dup_string (value);
+		break;
 	case PROP_API_KEY:
 		g_free (service->priv->api_key);
 		service->priv->api_key = g_value_dup_string (value);
@@ -287,6 +307,12 @@ rb_audioscrobbler_service_get_api_url (RBAudioscrobblerService *service)
 }
 
 const char *
+rb_audioscrobbler_service_get_old_radio_api_url (RBAudioscrobblerService *service)
+{
+	return service->priv->old_radio_api_url;
+}
+
+const char *
 rb_audioscrobbler_service_get_api_key (RBAudioscrobblerService *service)
 {
 	return service->priv->api_key;
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-service.h b/plugins/audioscrobbler/rb-audioscrobbler-service.h
index 0b3df5c..b8d1ed3 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-service.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-service.h
@@ -61,6 +61,7 @@ const char *rb_audioscrobbler_service_get_name (RBAudioscrobblerService *service
 const char *rb_audioscrobbler_service_get_auth_url (RBAudioscrobblerService *service);
 const char *rb_audioscrobbler_service_get_scrobbler_url (RBAudioscrobblerService *service);
 const char *rb_audioscrobbler_service_get_api_url (RBAudioscrobblerService *service);
+const char *rb_audioscrobbler_service_get_old_radio_api_url (RBAudioscrobblerService *service);
 const char *rb_audioscrobbler_service_get_api_key (RBAudioscrobblerService *service);
 const char *rb_audioscrobbler_service_get_api_secret (RBAudioscrobblerService *service);
 



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