private void wc_GpodderImportCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { Debug.WriteLine("Error from gPodder when importing: " + e.Error + ", " + e.Error.ToString()); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Error importing from gPodder. Please try again."; OnExternalServiceImportFinishedWithError(this, args); return; } string xmlResponse = e.Result.ToString(); List <Uri> subscriptions = PodcastFactory.podcastUrlFromGpodderImport(xmlResponse); if (subscriptions == null || subscriptions.Count == 0) { Debug.WriteLine("Got no subscriptions from gPodder.net."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "No subscriptions could be imported."; OnExternalServiceImportFinishedWithError(this, args); return; } MessageBox.Show("A blank screen may appear for a longer period of time. Please wait until the import has completed and do not exit the app."); foreach (Uri subscription in subscriptions) { addSubscriptionFromExterrnalService(subscription.ToString()); } }
void wc_DownloadOPMLCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { App.showErrorToast("Cannot fetch OPML from that location."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Cannot fetch OPML from that location."; OnPodcastChannelAddFinishedWithError(this, args); return; } String opml = e.Result as String; List <Uri> subscriptions = PodcastFactory.podcastUrlFromOPMLImport(opml); if (subscriptions == null || subscriptions.Count < 1) { App.showNotificationToast("No subscriptions to import."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "No podcasts to import."; OnPodcastChannelAddFinishedWithError(this, args); return; } foreach (Uri subscription in subscriptions) { addSubscriptionFromURL(subscription.ToString(), true); } }
async private void wc_DownloadPodcastRSSCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null || e.Cancelled) { try { string foo = e.Result; } catch (WebException ex) { if (needsAuthentication(ex)) { if (MessageBox.Show("Subscribing to this podcast requires authentication. Do you want to give username and password to continue?", "Attention", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { SubscriptionManagerArgs authArgs = new SubscriptionManagerArgs(); authArgs.podcastFeedRSSUri = ex.Response.ResponseUri; OnPodcastChannelRequiresAuthentication(this, authArgs); return; } } } PodcastSubscriptionFailedWithMessage("Could not fetch the podcast feed."); return; } string podcastRss = e.Result; PodcastSubscriptionModel podcastModel = PodcastFactory.podcastModelFromRSS(podcastRss); if (podcastModel == null) { PodcastSubscriptionFailedWithMessage("Podcast feed is invalid."); return; } AddSubscriptionOptions options = e.UserState as AddSubscriptionOptions; string rssUrl = options.rssUrl; bool importingFromExternalService = options.isImportingFromExternalService; bool isPodcastInDB = false; using (var db = new PodcastSqlModel()) { isPodcastInDB = db.isPodcastInDB(rssUrl); } if (isPodcastInDB) { if (!importingFromExternalService) { PodcastSubscriptionFailedWithMessage("You have already subscribed to that podcast."); } if (importingFromExternalService) { m_activeExternalImportsCount--; if (m_activeExternalImportsCount <= 0) { if (OnExternalServiceImportFinished != null) { OnExternalServiceImportFinished(this, null); } } } return; } podcastModel.CachedPodcastRSSFeed = podcastRss; podcastModel.PodcastLogoLocalLocation = localLogoFileName(podcastModel); podcastModel.PodcastRSSUrl = rssUrl; if (String.IsNullOrEmpty(options.username) == false) { podcastModel.Username = options.username; } if (String.IsNullOrEmpty(options.password) == false) { podcastModel.Password = options.password; } using (var db = new PodcastSqlModel()) { db.addSubscription(podcastModel); } await podcastModel.fetchChannelLogo(); SubscriptionManagerArgs addArgs = new SubscriptionManagerArgs(); addArgs.subscription = podcastModel; addArgs.isImportingFromExternalService = importingFromExternalService; OnPodcastChannelAddFinished(this, addArgs); OnPodcastChannelAdded(podcastModel); }