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); } }
private void PodcastSubscriptionFailedWithMessage(string message) { Debug.WriteLine(message); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = message; OnPodcastChannelAddFinishedWithError(this, args); }
void m_subscriptionsManager_OnPodcastSubscriptionsChanged(object source, SubscriptionManagerArgs e) { if (e.state == PodcastSubscriptionsManager.SubscriptionsState.StartedRefreshing) { UpdatingIndicator.Visibility = Visibility.Visible; } if (e.state == PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing) { UpdatingIndicator.Visibility = Visibility.Collapsed; } }
public void addSubscriptionFromURL(string podcastRss, bool importingFromExternalService = false) { if (String.IsNullOrEmpty(podcastRss)) { #if DEBUG podcastRss = "http://192.168.0.6:8000/feed.rss"; #else Debug.WriteLine("ERROR: Empty URL."); PodcastSubscriptionFailedWithMessage("Empty podcast address."); return; #endif } if (podcastRss.StartsWith("http://") == false) { podcastRss = podcastRss.Insert(0, "http://"); } Uri podcastRssUri; try { podcastRssUri = new Uri(podcastRss); } catch (UriFormatException) { Debug.WriteLine("ERROR: Cannot add podcast from that URL."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Malformed URL"; OnPodcastChannelAddFinishedWithError(this, args); return; } AddSubscriptionOptions options = new AddSubscriptionOptions(); options.rssUrl = podcastRss; options.isImportingFromExternalService = importingFromExternalService; if (importingFromExternalService) { m_activeExternalImportsCount++; } WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadPodcastRSSCompleted); wc.DownloadStringAsync(podcastRssUri, options); if (!importingFromExternalService) { OnPodcastChannelAddStarted(this, null); } Debug.WriteLine("Fetching podcast from URL: " + podcastRss.ToString()); }
void m_subscriptionsManager_OnOPMLExportToSkydriveChanged(object source, SubscriptionManagerArgs e) { if (e.state == PodcastSubscriptionsManager.SubscriptionsState.StartedSkydriveExport) { ProgressText.Text = "Exporting to SkyDrive"; deleteProgressOverlay.Visibility = Visibility.Visible; } if (e.state == PodcastSubscriptionsManager.SubscriptionsState.FinishedSkydriveExport) { deleteProgressOverlay.Visibility = Visibility.Collapsed; } }
void m_subscriptionsManager_OnPodcastSubscriptionsChanged(object source, SubscriptionManagerArgs e) { switch (e.state) { case PodcastSubscriptionsManager.SubscriptionsState.RefreshingSubscription: PodcastSubscriptionModel subscription = e.subscription; subscription.SubscriptionStatus = "Refreshing..."; break; case PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing: this.SubscriptionsList.StopPullToRefreshLoading(true, true); break; } }
private void opmlLiveOperation_UploadCompleted(object sender, LiveOperationCompletedEventArgs args) { SubscriptionManagerArgs managerArgs = new SubscriptionManagerArgs(); managerArgs.state = SubscriptionsState.FinishedSkydriveExport; OnOPMLExportToSkydriveChanged(this, managerArgs); if (args.Error == null) { MessageBox.Show("Exported to SkyDrive succesfully!"); } else { MessageBox.Show("There was an error uploading to SkyDrive. Please try again."); } }
async private void exportToOneDrive(String opmlExportFileName, IsolatedStorageFileStream sourceStream) { try { await OneDriveManager.getInstance().uploadFile("me/SkyDrive", opmlExportFileName, sourceStream); MessageBox.Show("Exported to OneDrive succesfully!"); SubscriptionManagerArgs managerArgs = new SubscriptionManagerArgs(); managerArgs.state = SubscriptionsState.FinishedOneDriveExport; OnOPMLExportToOneDriveChanged(this, managerArgs); } catch (Exception e) { MessageBox.Show("There was an error uploading to OneDrive. Please try again."); } }
public void addSubscriptionFromURLWithCredentials(string podcastRss, NetworkCredential nc) { if (String.IsNullOrEmpty(podcastRss)) { #if DEBUG podcastRss = "http://192.168.0.6:8000/feed.rss"; #else Debug.WriteLine("ERROR: Empty URL."); PodcastSubscriptionFailedWithMessage("Empty podcast address."); return; #endif } if (podcastRss.StartsWith("http://") == false) { podcastRss = podcastRss.Insert(0, "http://"); } Uri podcastRssUri; try { podcastRssUri = new Uri(podcastRss); } catch (UriFormatException) { Debug.WriteLine("ERROR: Cannot add podcast from that URL."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Malformed URL"; OnPodcastChannelAddFinishedWithError(this, args); return; } AddSubscriptionOptions options = new AddSubscriptionOptions(); options.rssUrl = podcastRss; options.username = nc.UserName; options.password = nc.Password; WebClient wc = new WebClient(); wc.Credentials = nc; wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadPodcastRSSCompleted); wc.DownloadStringAsync(podcastRssUri, options); OnPodcastChannelAddStarted(this, null); Debug.WriteLine("Fetching podcast from URL: " + podcastRss.ToString()); }
public void refreshSubscriptions() { SubscriptionManagerArgs stateChangedArgs = new SubscriptionManagerArgs(); if (NetworkInterface.GetIsNetworkAvailable() == false) { Debug.WriteLine("No network available. Won't refresh."); stateChangedArgs.state = PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing; OnPodcastSubscriptionsChanged(this, stateChangedArgs); return; } stateChangedArgs.state = PodcastSubscriptionsManager.SubscriptionsState.StartedRefreshing; OnPodcastSubscriptionsChanged(this, stateChangedArgs); m_subscriptions = App.mainViewModels.PodcastSubscriptions.ToList(); refreshNextSubscription(); }
public void importFromGpodderWithCredentials(NetworkCredential nc) { if (String.IsNullOrEmpty(nc.Password) || String.IsNullOrEmpty(nc.UserName)) { Debug.WriteLine("gPodder username or password empty."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Please give both gPodder username and password."; OnExternalServiceImportFinishedWithError(this, args); return; } OnExternalServiceImportStarted(this, null); Uri gpodderImportUri = new Uri(string.Format("http://gpodder.net/subscriptions/{0}.xml", nc.UserName)); WebClient wc = new WebClient(); wc.Credentials = nc; wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_GpodderImportCompleted); wc.DownloadStringAsync(gpodderImportUri); Debug.WriteLine("Importing from gPodder for user, " + nc.UserName + ", URL: " + gpodderImportUri.ToString()); }
private void subscriptionManager_OnPodcastChannelDeleteFinished(object source, SubscriptionManagerArgs e) { deleteProgressOverlay.Visibility = Visibility.Collapsed; }
private void PodcastSubscriptionsManager_OnPodcastAddedFinished(object source, SubscriptionManagerArgs e) { PodcastSubscriptionModel subscriptionModel = e.addedSubscription; Debug.WriteLine("Podcast added successfully. Name: " + subscriptionModel.PodcastName); subscriptionModel.EpisodesManager.updatePodcastEpisodes(); }
async private void exportToOneDrive(String opmlExportFileName, IsolatedStorageFileStream sourceStream) { try { await OneDriveManager.getInstance().uploadFile("me/SkyDrive", opmlExportFileName, sourceStream); MessageBox.Show("Exported to OneDrive succesfully!"); SubscriptionManagerArgs managerArgs = new SubscriptionManagerArgs(); managerArgs.state = SubscriptionsState.FinishedOneDriveExport; OnOPMLExportToOneDriveChanged(this, managerArgs); } catch (Exception e) { MessageBox.Show("There was an error uploading to OneDrive. Please try again."); } }
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); } }
private void PodcastSubscriptionsManager_OnPodcastAddedFinished(object source, SubscriptionManagerArgs e) { PodcastSubscriptionModel subscriptionModel = e.subscription; Debug.WriteLine("Podcast added successfully. Name: " + subscriptionModel.PodcastName); subscriptionModel.EpisodesManager.updatePodcastEpisodes(); if (e.isImportingFromExternalService) { m_activeExternalImportsCount--; if (m_activeExternalImportsCount <= 0) { if (OnExternalServiceImportFinished != null) { OnExternalServiceImportFinished(this, null); } } } }
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); }
public void refreshSubscriptions() { SubscriptionManagerArgs stateChangedArgs = new SubscriptionManagerArgs(); if (NetworkInterface.GetIsNetworkAvailable() == false) { Debug.WriteLine("No network available. Won't refresh."); stateChangedArgs.state = PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing; OnPodcastSubscriptionsChanged(this, stateChangedArgs); return; } stateChangedArgs.state = PodcastSubscriptionsManager.SubscriptionsState.StartedRefreshing; OnPodcastSubscriptionsChanged(this, stateChangedArgs); m_subscriptions = App.mainViewModels.PodcastSubscriptions.ToList(); refreshNextSubscription(); }
public void addSubscriptionFromURL(string podcastRss, bool importingFromExternalService = false) { if (String.IsNullOrEmpty(podcastRss)) { #if DEBUG podcastRss = "http://192.168.0.6:8000/feed.rss"; #else Debug.WriteLine("ERROR: Empty URL."); PodcastSubscriptionFailedWithMessage("Empty podcast address."); return; #endif } if (podcastRss.StartsWith("http://") == false) { podcastRss = podcastRss.Insert(0, "http://"); } Uri podcastRssUri; try { podcastRssUri = new Uri(podcastRss); } catch (UriFormatException) { Debug.WriteLine("ERROR: Cannot add podcast from that URL."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Malformed URL"; OnPodcastChannelAddFinishedWithError(this, args); return; } AddSubscriptionOptions options = new AddSubscriptionOptions(); options.rssUrl = podcastRss; options.isImportingFromExternalService = importingFromExternalService; if (importingFromExternalService) { m_activeExternalImportsCount++; } WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadPodcastRSSCompleted); wc.DownloadStringAsync(podcastRssUri, options); if (!importingFromExternalService) { OnPodcastChannelAddStarted(this, null); } Debug.WriteLine("Fetching podcast from URL: " + podcastRss.ToString()); }
void m_subscriptionsManager_OnOPMLExportToOneDriveChanged(object source, SubscriptionManagerArgs e) { if (e.state == PodcastSubscriptionsManager.SubscriptionsState.StartedOneDriveExport) { ProgressText.Text = "Exporting to OneDrive"; deleteProgressOverlay.Visibility = Visibility.Visible; } if (e.state == PodcastSubscriptionsManager.SubscriptionsState.FinishedOneDriveExport) { deleteProgressOverlay.Visibility = Visibility.Collapsed; } }
private void opmlLiveOperation_UploadCompleted(object sender, LiveOperationCompletedEventArgs args) { SubscriptionManagerArgs managerArgs = new SubscriptionManagerArgs(); managerArgs.state = SubscriptionsState.FinishedSkydriveExport; OnOPMLExportToSkydriveChanged(this, managerArgs); if (args.Error == null) { MessageBox.Show("Exported to SkyDrive succesfully!"); } else { MessageBox.Show("There was an error uploading to SkyDrive. Please try again."); } }
void m_subscriptionsManager_OnPodcastSubscriptionsChanged(object source, SubscriptionManagerArgs e) { if (e.state == PodcastSubscriptionsManager.SubscriptionsState.StartedRefreshing) { UpdatingIndicator.Visibility = Visibility.Visible; } if (e.state == PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing) { UpdatingIndicator.Visibility = Visibility.Collapsed; } }
private void subscriptionManager_OnPodcastChannelDeleteStarted(object source, SubscriptionManagerArgs e) { ProgressText.Text = "Unsubscribing"; deleteProgressOverlay.Visibility = Visibility.Visible; }
public void addSubscriptionFromURLWithCredentials(string podcastRss, NetworkCredential nc) { if (String.IsNullOrEmpty(podcastRss)) { #if DEBUG podcastRss = "http://192.168.0.6:8000/feed.rss"; #else Debug.WriteLine("ERROR: Empty URL."); PodcastSubscriptionFailedWithMessage("Empty podcast address."); return; #endif } if (podcastRss.StartsWith("http://") == false) { podcastRss = podcastRss.Insert(0, "http://"); } Uri podcastRssUri; try { podcastRssUri = new Uri(podcastRss); } catch (UriFormatException) { Debug.WriteLine("ERROR: Cannot add podcast from that URL."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Malformed URL"; OnPodcastChannelAddFinishedWithError(this, args); return; } AddSubscriptionOptions options = new AddSubscriptionOptions(); options.rssUrl = podcastRss; options.username = nc.UserName; options.password = nc.Password; WebClient wc = new WebClient(); wc.Credentials = nc; wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadPodcastRSSCompleted); wc.DownloadStringAsync(podcastRssUri, options); OnPodcastChannelAddStarted(this, null); Debug.WriteLine("Fetching podcast from URL: " + podcastRss.ToString()); }
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); }
public void importFromGpodderWithCredentials(NetworkCredential nc) { if (String.IsNullOrEmpty(nc.Password) || String.IsNullOrEmpty(nc.UserName)) { Debug.WriteLine("gPodder username or password empty."); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = "Please give both gPodder username and password."; OnExternalServiceImportFinishedWithError(this, args); return; } OnExternalServiceImportStarted(this, null); Uri gpodderImportUri = new Uri(string.Format("http://gpodder.net/subscriptions/{0}.xml", nc.UserName)); WebClient wc = new WebClient(); wc.Credentials = nc; wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_GpodderImportCompleted); wc.DownloadStringAsync(gpodderImportUri); Debug.WriteLine("Importing from gPodder for user, " + nc.UserName + ", URL: " + gpodderImportUri.ToString()); }
private void refreshNextSubscription() { SubscriptionManagerArgs stateChangedArgs = new SubscriptionManagerArgs(); if (m_subscriptions.Count < 1) { if (OnPodcastSubscriptionsChanged == null) { return; } Debug.WriteLine("No more episodes to refresh. Done."); stateChangedArgs.state = PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing; // Update all episodes to the latest list. App.mainViewModels.LatestEpisodesListProperty = new ObservableCollection <PodcastEpisodeModel>(); OnPodcastSubscriptionsChanged(this, stateChangedArgs); return; } PodcastSubscriptionModel subscription = m_subscriptions[0]; m_subscriptions.RemoveAt(0); if (subscription.IsSubscribed == false) { Debug.WriteLine("Not subscribed to {0}, no refresh.", subscription.PodcastName); refreshNextSubscription(); } Uri refreshUri = new Uri(subscription.PodcastRSSUrl, UriKind.Absolute); Debug.WriteLine("Refreshing subscriptions for '{0}', using URL: {1}", subscription.PodcastName, refreshUri); NetworkCredential nc = null; if (String.IsNullOrEmpty(subscription.Username) == false) { nc = new NetworkCredential(); nc.UserName = subscription.Username; Debug.WriteLine("Using username to refresh subscription: {0}", nc.UserName); } if (String.IsNullOrEmpty(subscription.Password) == false) { nc.Password = subscription.Password; Debug.WriteLine("User password to refresh subscription."); } WebClient wc = new WebClient(); if (nc != null) { wc.Credentials = nc; } wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_RefreshPodcastRSSCompleted); wc.DownloadStringAsync(refreshUri, subscription); if (OnPodcastSubscriptionsChanged != null) { stateChangedArgs.state = SubscriptionsState.RefreshingSubscription; stateChangedArgs.subscription = subscription; OnPodcastSubscriptionsChanged(this, stateChangedArgs); } }
private void refreshNextSubscription() { SubscriptionManagerArgs stateChangedArgs = new SubscriptionManagerArgs(); if (m_subscriptions.Count < 1) { if (OnPodcastSubscriptionsChanged == null) { return; } Debug.WriteLine("No more episodes to refresh. Done."); stateChangedArgs.state = PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing; // Update all episodes to the latest list. App.mainViewModels.LatestEpisodesListProperty = new ObservableCollection<PodcastEpisodeModel>(); OnPodcastSubscriptionsChanged(this, stateChangedArgs); return; } PodcastSubscriptionModel subscription = m_subscriptions[0]; m_subscriptions.RemoveAt(0); if (subscription.IsSubscribed == false) { Debug.WriteLine("Not subscribed to {0}, no refresh.", subscription.PodcastName); refreshNextSubscription(); } Uri refreshUri = new Uri(subscription.PodcastRSSUrl, UriKind.Absolute); Debug.WriteLine("Refreshing subscriptions for '{0}', using URL: {1}", subscription.PodcastName, refreshUri); NetworkCredential nc = null; if (String.IsNullOrEmpty(subscription.Username) == false) { nc = new NetworkCredential(); nc.UserName = subscription.Username; Debug.WriteLine("Using username to refresh subscription: {0}", nc.UserName); } if (String.IsNullOrEmpty(subscription.Password) == false) { nc.Password = subscription.Password; Debug.WriteLine("User password to refresh subscription."); } WebClient wc = new WebClient(); if (nc != null) { wc.Credentials = nc; } wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_RefreshPodcastRSSCompleted); wc.DownloadStringAsync(refreshUri, subscription); if (OnPodcastSubscriptionsChanged != null) { stateChangedArgs.state = SubscriptionsState.RefreshingSubscription; stateChangedArgs.subscription = subscription; OnPodcastSubscriptionsChanged(this, stateChangedArgs); } }
private void PodcastSubscriptionsManager_OnPodcastAddedFinished(object source, SubscriptionManagerArgs e) { PodcastSubscriptionModel subscriptionModel = e.subscription; Debug.WriteLine("Podcast added successfully. Name: " + subscriptionModel.PodcastName); subscriptionModel.EpisodesManager.updatePodcastEpisodes(); if (e.isImportingFromExternalService) { m_activeExternalImportsCount--; if (m_activeExternalImportsCount <= 0) { if (OnExternalServiceImportFinished != null) { OnExternalServiceImportFinished(this, null); } } } }
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()); } }
private void subscriptionManager_OnPodcastChannelDeleteStarted(object source, SubscriptionManagerArgs e) { ProgressText.Text = "Unsubscribing"; deleteProgressOverlay.Visibility = Visibility.Visible; }
private void DoOPMLExport() { String dateCreated = DateTime.Now.ToString("r"); String opmlExportFileName = String.Format("PodcatcherSubscriptions_{0}.opml.xml", DateTime.Now.ToString("dd_MM_yyyy")); using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(opmlExportFileName, FileMode.Create, myIsolatedStorage); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.UTF8; using (XmlWriter writer = XmlWriter.Create(isoStream, settings)) { /** OPML root */ writer.WriteStartElement("opml"); writer.WriteAttributeString("version", "2.0"); /** Head */ writer.WriteStartElement("head"); // title writer.WriteStartElement("title"); writer.WriteString("My subscriptions from Podcatcher"); writer.WriteEndElement(); // dateCreated writer.WriteStartElement("dateCreated"); writer.WriteString(dateCreated); writer.WriteEndElement(); /** End Head */ writer.WriteEndElement(); /** Body */ writer.WriteStartElement("body"); // Each outline List<PodcastSubscriptionModel> subscriptions = App.mainViewModels.PodcastSubscriptions.ToList(); foreach (PodcastSubscriptionModel s in subscriptions) { writer.WriteStartElement("outline"); writer.WriteAttributeString("title", s.PodcastName); writer.WriteAttributeString("xmlUrl", s.PodcastRSSUrl); writer.WriteAttributeString("type", "rss"); writer.WriteAttributeString("text", s.PodcastDescription); writer.WriteEndElement(); } /** End Body */ writer.WriteEndElement(); // Finish the document writer.WriteEndDocument(); writer.Flush(); } isoStream.Seek(0, SeekOrigin.Begin); using (var db = new PodcastSqlModel()) { if (db.settings().SelectedExportIndex == (int)SettingsModel.ExportMode.ExportToOneDrive) { SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.state = SubscriptionsState.StartedOneDriveExport; OnOPMLExportToOneDriveChanged(this, args); exportToOneDrive(opmlExportFileName, isoStream); } else if (db.settings().SelectedExportIndex == (int)SettingsModel.ExportMode.ExportViaEmail) { exportViaEmail(isoStream); } } } }
private void subscriptionManager_OnPodcastChannelDeleteFinished(object source, SubscriptionManagerArgs e) { deleteProgressOverlay.Visibility = Visibility.Collapsed; }
private void PodcastSubscriptionFailedWithMessage(string message) { Debug.WriteLine(message); SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.message = message; OnPodcastChannelFinishedWithError(this, args); }
private void DoOPMLExport() { String dateCreated = DateTime.Now.ToString("r"); String opmlExportFileName = String.Format("PodcatcherSubscriptions_{0}.opml.xml", DateTime.Now.ToString("dd_MM_yyyy")); using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(opmlExportFileName, FileMode.Create, myIsolatedStorage); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.UTF8; using (XmlWriter writer = XmlWriter.Create(isoStream, settings)) { /** OPML root */ writer.WriteStartElement("opml"); writer.WriteAttributeString("version", "2.0"); /** Head */ writer.WriteStartElement("head"); // title writer.WriteStartElement("title"); writer.WriteString("My subscriptions from Podcatcher"); writer.WriteEndElement(); // dateCreated writer.WriteStartElement("dateCreated"); writer.WriteString(dateCreated); writer.WriteEndElement(); /** End Head */ writer.WriteEndElement(); /** Body */ writer.WriteStartElement("body"); // Each outline List <PodcastSubscriptionModel> subscriptions = App.mainViewModels.PodcastSubscriptions.ToList(); foreach (PodcastSubscriptionModel s in subscriptions) { writer.WriteStartElement("outline"); writer.WriteAttributeString("title", s.PodcastName); writer.WriteAttributeString("xmlUrl", s.PodcastRSSUrl); writer.WriteAttributeString("type", "rss"); writer.WriteAttributeString("text", s.PodcastDescription); writer.WriteEndElement(); } /** End Body */ writer.WriteEndElement(); // Finish the document writer.WriteEndDocument(); writer.Flush(); } isoStream.Seek(0, SeekOrigin.Begin); using (var db = new PodcastSqlModel()) { if (db.settings().SelectedExportIndex == (int)SettingsModel.ExportMode.ExportToOneDrive) { SubscriptionManagerArgs args = new SubscriptionManagerArgs(); args.state = SubscriptionsState.StartedOneDriveExport; OnOPMLExportToOneDriveChanged(this, args); exportToOneDrive(opmlExportFileName, isoStream); } else if (db.settings().SelectedExportIndex == (int)SettingsModel.ExportMode.ExportViaEmail) { exportViaEmail(isoStream); } } } }
private void wc_DownloadPodcastRSSCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null || e.Cancelled) { PodcastSubscriptionFailedWithMessage("Error retrieving podcast feed."); return; } string podcastRss = e.Result; PodcastSubscriptionModel podcastModel = PodcastFactory.podcastModelFromRSS(podcastRss); if (podcastModel == null) { PodcastSubscriptionFailedWithMessage("Could not parse podcast subscription."); return; } string rssUrl = e.UserState as string; if (m_podcastsSqlModel.isPodcastInDB(rssUrl)) { PodcastSubscriptionFailedWithMessage("You have already subscribed to that podcast."); return; } podcastModel.CachedPodcastRSSFeed = podcastRss; podcastModel.PodcastLogoLocalLocation = localLogoFileName(podcastModel); podcastModel.PodcastRSSUrl = rssUrl; m_podcastsSqlModel.addSubscription(podcastModel); podcastModel.fetchChannelLogo(); SubscriptionManagerArgs addArgs = new SubscriptionManagerArgs(); addArgs.addedSubscription = podcastModel; OnPodcastChannelFinished(this, addArgs); }
void m_subscriptionsManager_OnPodcastSubscriptionsChanged(object source, SubscriptionManagerArgs e) { switch (e.state) { case PodcastSubscriptionsManager.SubscriptionsState.RefreshingSubscription: PodcastSubscriptionModel subscription = e.subscription; subscription.SubscriptionStatus = "Refreshing..."; break; case PodcastSubscriptionsManager.SubscriptionsState.FinishedRefreshing: this.SubscriptionsList.StopPullToRefreshLoading(true, true); break; } }