public AuthProgressForm RestoreSingle(MusicService service) { if (!am.CanRestore(service)) { TaskDialogHelper.ShowMessage(caption: "Cannot restore this service right now.", message: "The service is already being restored in the background. Please try again in a moment.", icon: TaskDialogStandardIcon.Error, buttons: TaskDialogStandardButtons.Ok, owner: parent.Handle); return(null); } var form = new AuthProgressForm(new[] { service }); form.Show(parent); return(form); }
/// <summary> /// Attempts to parse a URL that refers to a media collection. /// </summary> /// <param name="url">The URL to parse.</param> /// <returns>The state of the parser. See the documentation for <see cref="UrlParseState"/> for more info.</returns> public UrlParseState Parse(string url) { Service = null; ParseResult = null; Exception = null; if (String.IsNullOrWhiteSpace(url)) { return(UrlParseState.NullOrEmptyString); } Uri actualUrl; if (!Uri.TryCreate(url, UriKind.Absolute, out actualUrl)) { return(UrlParseState.InvalidUrl); } Service = pluginManager.GetServiceByBaseUri(actualUrl); if (Service == null) { return(UrlParseState.NoServiceFound); } if (am.CanRestore(Service)) { return(UrlParseState.ServiceNotRestored); } if (am.NeedsAuthentication(Service)) { return(UrlParseState.ServiceNotAuthenticated); } try { if ((ParseResult = Service.ParseUrl(actualUrl)) == null || ParseResult?.Type == MediaType.Unknown) { return(UrlParseState.NoMedia); } } catch (Exception ex) { Exception = ex; return(UrlParseState.Exception); } return(UrlParseState.Success); }
private void restoreButton_Click(object sender, EventArgs e) { if (!am.CanRestore(service)) { TaskDialogHelper.ShowMessage(caption: "Cannot restore this service right now.", message: "The service is already being restored in the background. Please try again in a moment.", icon: TaskDialogStandardIcon.Error, buttons: TaskDialogStandardButtons.Ok, owner: Handle); return; } var form = new AuthProgressForm(new[] { service }); form.Closed += (o, args) => { UpdateViews(); servicePlugin.SettingsFile.Save(); }; form.Show(this); }