private void OnStationEditorResponse (object o, ResponseArgs args)
{
StationEditor editor = (StationEditor)o;
bool destroy = true;
try {
if (args.ResponseId == ResponseType.Ok) {
DatabaseTrackInfo track = editor.Track ?? new DatabaseTrackInfo ();
track.PrimarySource = this;
track.IsLive = true;
try {
track.Uri = new SafeUri (editor.StreamUri);
} catch {
destroy = false;
editor.ErrorMessage = Catalog.GetString ("Please provide a valid station URI");
}
if (!String.IsNullOrEmpty (editor.StationCreator)) {
track.ArtistName = editor.StationCreator;
}
track.Comment = editor.Description;
if (!String.IsNullOrEmpty (editor.Genre)) {
track.Genre = editor.Genre;
} else {
destroy = false;
editor.ErrorMessage = Catalog.GetString ("Please provide a station genre");
}
if (!String.IsNullOrEmpty (editor.StationTitle)) {
track.TrackTitle = editor.StationTitle;
track.AlbumTitle = editor.StationTitle;
} else {
destroy = false;
editor.ErrorMessage = Catalog.GetString ("Please provide a station title");
}
track.Rating = editor.Rating;
if (destroy) {
track.Save ();
}
}
} finally {
if (destroy) {
editor.Response -= OnStationEditorResponse;
editor.Destroy ();
}
}
}