/*public PodcastFeedInfo AddPodcastFeedFromUri (Uri feedUri, SyncPreference syncPref) * { * * }*/ public PodcastFeedInfo AddPodcastFeedFromUri(Uri feedUri) { if (feedUri == null) { throw new ArgumentNullException("feedUri"); } try { PodcastFeedInfo feed = null; string key = feedUri.ToString(); lock (podcast_feed_sync) { if (podcast_feeds_keyed.ContainsKey(key)) { // Should users be notified of this? Console.WriteLine(Catalog.GetString("Already Subscribed")); feed = podcast_feeds_keyed [key] as PodcastFeedInfo; feed.IsSubscribed = true; } else { feed = new PodcastFeedInfo(key); AddPodcastFeed(feed); } } return(feed); } catch { return(null); } }
private bool RemovePodcastFeedFromLibrary(PodcastFeedInfo feed) { if (feed == null) { throw new ArgumentNullException("feed"); } lock (feed.SyncRoot) { if (feed.IsBusy) { return(false); } else { feed.Deactivate(); } } if (feed.PodcastCount > 0) { RemovePodcasts(feed.Podcasts); } feed.Delete(); podcast_feeds.Remove(feed); podcast_feeds_keyed.Remove(feed.Key); return(true); }
// Fix constructors. Need a better way of creating new podcasts. public PodcastInfo(PodcastFeedInfo feed, int id, string title, string link, DateTime pubDate, string description, string author, string local_path, string url, string mime_type, long length, bool downloaded, bool active) : this(id, feed, url) { this.title = title; this.description = description; this.pub_date = pubDate; this.link = link; this.author = author; this.active = active; this.downloaded = downloaded; this.mime_type = mime_type; this.length = length; this.local_path = local_path; this.track = null; if (active && downloaded) { if (local_path != null && local_path != String.Empty) { try { track = (TrackInfo) Globals.Library.TracksFnKeyed[ Banshee.Base.Library.MakeFilenameKey (new SafeUri (local_path)) ]; } catch {} } } }
private static PodcastInfo[] LoadPodcasts(PodcastFeedInfo feed) { ArrayList podcasts = new ArrayList(); IDataReader podcast_reader = Globals.Library.Db.Query( new DbCommand( @"SELECT * FROM Podcasts WHERE PodcastFeedID = :feed_id", "feed_id", feed.ID ) ); while (podcast_reader.Read()) { podcasts.Add( new PodcastInfo( feed, podcast_reader.GetInt32(0), GetStringSafe(podcast_reader, 2), GetStringSafe(podcast_reader, 3), podcast_reader.GetDateTime(4), GetStringSafe(podcast_reader, 5), GetStringSafe(podcast_reader, 6), GetStringSafe(podcast_reader, 7), podcast_reader.GetString(8), podcast_reader.GetString(9), podcast_reader.GetInt64(10), podcast_reader.GetBoolean(11), podcast_reader.GetBoolean(12) ) ); } podcast_reader.Close(); return(podcasts.ToArray(typeof(PodcastInfo)) as PodcastInfo[]); }
// Fix constructors. Need a better way of creating new podcasts. public PodcastInfo(PodcastFeedInfo feed, int id, string title, string link, DateTime pubDate, string description, string author, string local_path, string url, string mime_type, long length, bool downloaded, bool active) : this(id, feed, url) { this.title = title; this.description = description; this.pub_date = pubDate; this.link = link; this.author = author; this.active = active; this.downloaded = downloaded; this.mime_type = mime_type; this.length = length; this.local_path = local_path; this.track = null; if (active && downloaded) { if (local_path != null && local_path != String.Empty) { try { track = (TrackInfo) Globals.Library.TracksFnKeyed[ Banshee.Base.Library.MakeFilenameKey(new SafeUri(local_path)) ]; } catch {} } } }
public static PodcastFeedInfo[] LoadPodcastFeeds() { ArrayList podcastFeeds = new ArrayList(); IDataReader feed_reader = Globals.Library.Db.Query(@" SELECT * FROM PodcastFeeds ORDER BY Title "); while (feed_reader.Read()) { PodcastFeedInfo feed = null; feed = new PodcastFeedInfo( feed_reader.GetInt32(0), feed_reader.GetString(1), feed_reader.GetString(2), GetStringSafe(feed_reader, 3), GetStringSafe(feed_reader, 4), GetStringSafe(feed_reader, 5), feed_reader.GetDateTime(6), feed_reader.GetBoolean(7), (SyncPreference)feed_reader.GetInt32(8) ); podcastFeeds.Add(feed); feed.Add(LoadPodcasts(feed)); } feed_reader.Close(); return(podcastFeeds.ToArray(typeof(PodcastFeedInfo)) as PodcastFeedInfo[]); }
private PodcastInfo(int id, PodcastFeedInfo feed, string url) { treeIter = TreeIter.Zero; this.id = id; this.feed = feed; this.url = new SafeUri(url); }
private void EmitFeedUpdateStatusChanged(PodcastFeedInfo feed, UpdateActivityEventHandler handler) { if (handler != null) { handler(this, new UpdateActivityEventArgs(feed)); } }
private void OnFeedUrlUpdated(object sender, FeedUrlUpdatedEventArgs args) { PodcastFeedInfo feed = sender as PodcastFeedInfo; lock (podcast_feed_sync) { podcast_feeds_keyed.Remove(args.OldUrl); podcast_feeds_keyed.Add(args.NewUrl, feed); } }
public PodcastFeedPropertiesDialog(PodcastFeedInfo feed) : base(feed.Title, InterfaceElements.MainWindow, DialogFlags.DestroyWithParent) { this.feed = feed; Title = feed.Title; IconThemeUtils.SetWindowIcon (this); BuildWindow (); }
public int CompareTo(object o) { PodcastFeedInfo rhs = o as PodcastFeedInfo; if (rhs == null) { return(1); } return(String.Compare(this.Title.ToLower(), rhs.Title.ToLower())); }
public void Update(PodcastFeedInfo feed, bool queue_if_busy) { if (feed == null) { return; } // drrr... PodcastFeedInfo[] wrapper = new PodcastFeedInfo [1]; wrapper.SetValue(feed, 0); DoUpdate(wrapper, queue_if_busy); }
internal static void SubscribeToPodcastFeed(string uri, SyncPreference sync) { PodcastFeedInfo feed = new PodcastFeedInfo(uri, sync); feed.UpdateFinished += InitialFeedUpdateHandler; if (feed != null) { ThreadAssist.Spawn(delegate { FeedFetcher.Update(feed, true); }); } }
public static PodcastFeedParser Create(XmlDocument doc, PodcastFeedInfo feed) { if (doc == null) { throw new ArgumentNullException("doc"); } else if (doc == null) { throw new ArgumentNullException("feed"); } // Only Rss is supported at this time, add logic for others when time is not short. return((PodcastFeedParser) new RssPodcastFeedParser(doc, feed)); }
private static void InitialFeedUpdateHandler(object sender, UpdateActivityEventArgs args) { PodcastFeedInfo feed = sender as PodcastFeedInfo; if (feed != null) { feed.UpdateFinished -= InitialFeedUpdateHandler; feed.UpdateStarted += OnFeedUpdateStatusChanged; feed.UpdateFinished += OnFeedUpdateStatusChanged; Library.AddPodcastFeed(feed); } }
public void UpdateThread() { try { PodcastFeedInfo tmp_feed = null; while (true) { lock (update_sync) { if (currentFeed == totalFeeds) { return; } if (userEvent.IsCancelRequested) { return; } else { tmp_feed = update_queue [currentFeed++] as PodcastFeedInfo; } } try { UpdateUserEvent(String.Format( Catalog.GetString("Updating \"{0}\""), tmp_feed.Title )); if (tmp_feed.IsSubscribed) { tmp_feed.Update(); } } catch { } finally { userEvent.Progress = (double)(currentFeed) / (double)totalFeeds; } } } catch { } finally { EndUpdate(); } }
public static void Delete(PodcastFeedInfo pfi) { if (pfi == null) { throw new ArgumentNullException("pfi"); } Globals.Library.Db.Execute(new DbCommand( @"DELETE FROM PodcastFeeds WHERE PodcastFeedID = :id", "id", pfi.ID )); Globals.Library.Db.Execute(new DbCommand( @"DELETE FROM Podcasts WHERE PodcastFeedID = :id", "id", pfi.ID )); }
public static int Commit(PodcastFeedInfo feed) { int ret = 0; if (feed.ID != 0) { ret = Globals.Library.Db.Execute(new DbCommand( @"UPDATE PodcastFeeds SET Title=:title, FeedUrl=:feed_url, Link=:link, Description=:description, Image=:image, LastUpdated=:last_updated, Subscribed=:subscribed, SyncPreference=:sync_preference WHERE PodcastFeedID=:feed_id", "title", feed.Title, "feed_url", feed.Url.ToString(), "link", feed.Link, "description", feed.Description, "image", feed.Image, "last_updated", feed.LastUpdated.ToString(), "subscribed", Convert.ToInt32(feed.IsSubscribed), "sync_preference", (int)feed.SyncPreference, "feed_id", feed.ID )); } else { ret = Globals.Library.Db.Execute(new DbCommand( @"INSERT INTO PodcastFeeds VALUES (NULL, :title, :feed_url, :link, :description, :image, :last_updated, :subscribed, :sync_preference)", "title", feed.Title, "feed_url", feed.Url.ToString(), "link", feed.Link, "description", feed.Description, "image", feed.Image, "last_updated", feed.LastUpdated.ToString(), "subscribed", Convert.ToInt32(feed.IsSubscribed), "sync_preference", (int)feed.SyncPreference )); } return(ret); }
public static int Commit(PodcastFeedInfo feed) { int ret = 0; if (feed.ID != 0) { ret = Globals.Library.Db.Execute(new DbCommand( @"UPDATE PodcastFeeds SET Title=:title, FeedUrl=:feed_url, Link=:link, Description=:description, Image=:image, LastUpdated=:last_updated, Subscribed=:subscribed, SyncPreference=:sync_preference WHERE PodcastFeedID=:feed_id", "title", feed.Title, "feed_url", feed.Url.ToString(), "link", feed.Link, "description", feed.Description, "image", feed.Image, "last_updated", feed.LastUpdated.ToString(), "subscribed", Convert.ToInt32(feed.IsSubscribed), "sync_preference", (int)feed.SyncPreference, "feed_id", feed.ID )); } else { ret = Globals.Library.Db.Execute(new DbCommand( @"INSERT INTO PodcastFeeds VALUES (NULL, :title, :feed_url, :link, :description, :image, :last_updated, :subscribed, :sync_preference)", "title", feed.Title, "feed_url", feed.Url.ToString(), "link", feed.Link, "description", feed.Description, "image", feed.Image, "last_updated", feed.LastUpdated.ToString(), "subscribed", Convert.ToInt32(feed.IsSubscribed), "sync_preference", (int)feed.SyncPreference )); } return ret; }
private bool AddPodcastFeedToLibrary(PodcastFeedInfo feed, bool sort) { bool ret = false; if (feed == null) { return(ret); } lock (podcast_feed_sync) { if (podcast_feeds_keyed.ContainsKey(feed.Key)) { ret = false; } else { podcast_feeds.Add(feed); podcast_feeds_keyed.Add(feed.Key, feed); if (feed.ID == 0) { feed.Commit(); } feed.TitleUpdated += OnFeedTitleUpdated; feed.UrlUpdated += OnFeedUrlUpdated; if (sort) { podcast_feeds.Sort(); } ret = true; } } return(ret); }
public bool RemovePodcastFeed(PodcastFeedInfo feed, bool update) { if (feed == null) { throw new ArgumentNullException("feeds"); } bool removed = false; lock (PodcastFeedSync) { removed = RemovePodcastFeedFromLibrary(feed); } if (update && removed) { PodcastFeedEventArgs args = new PodcastFeedEventArgs(feed); EmitPodcastFeedRemoved(args); } return(false); }
public bool AddPodcastFeed(PodcastFeedInfo feed, bool update) { if (feed == null) { throw new ArgumentNullException("feed"); } bool new_feed = false; if (feed != null) { lock (PodcastFeedSync) { new_feed = AddPodcastFeedToLibrary(feed, true); } if (update && new_feed) { EmitPodcastFeedAdded(new PodcastFeedEventArgs(feed)); } } return(new_feed); }
public void Update(PodcastFeedInfo feed, bool queue_if_busy) { if (feed == null) { return; } // drrr... PodcastFeedInfo[] wrapper = new PodcastFeedInfo [1]; wrapper.SetValue (feed, 0); DoUpdate (wrapper, queue_if_busy); }
private void EmitFeedUpdateStatusChanged(PodcastFeedInfo feed, UpdateActivityEventHandler handler) { if (handler != null) { handler (this, new UpdateActivityEventArgs (feed)); } }
public void FilterOnFeed(PodcastFeedInfo feed) { selected_feed = feed; Refilter (); }
public PodcastFeedEventArgs(PodcastFeedInfo podcastFeed) : this(podcastFeed, null) { }
public PodcastInfo(PodcastFeedInfo feed, string url) : this(0, feed, url) { active = true; downloaded = false; }
public void Update(PodcastFeedInfo feed) { Update(feed, true); }
private bool AddPodcastFeedToLibrary(PodcastFeedInfo feed, bool sort) { bool ret = false; if (feed == null) { return ret; } lock (podcast_feed_sync) { if (podcast_feeds_keyed.ContainsKey (feed.Key)) { ret = false; } else { podcast_feeds.Add (feed); podcast_feeds_keyed.Add (feed.Key, feed); if (feed.ID == 0) { feed.Commit (); } feed.TitleUpdated += OnFeedTitleUpdated; feed.UrlUpdated += OnFeedUrlUpdated; if (sort) { podcast_feeds.Sort (); } ret = true; } } return ret; }
private bool RemovePodcastFeedFromLibrary(PodcastFeedInfo feed) { if (feed == null) { throw new ArgumentNullException ("feed"); } lock (feed.SyncRoot) { if (feed.IsBusy) { return false; } else { feed.Deactivate (); } } if (feed.PodcastCount > 0) { RemovePodcasts (feed.Podcasts); } feed.Delete (); podcast_feeds.Remove (feed); podcast_feeds_keyed.Remove (feed.Key); return true; }
public static void Delete(PodcastFeedInfo pfi) { if (pfi == null) { throw new ArgumentNullException ("pfi"); } Globals.Library.Db.Execute(new DbCommand( @"DELETE FROM PodcastFeeds WHERE PodcastFeedID = :id", "id", pfi.ID )); Globals.Library.Db.Execute(new DbCommand( @"DELETE FROM Podcasts WHERE PodcastFeedID = :id", "id", pfi.ID )); }
//------------------------------------------------- public bool RemovePodcastFeed(PodcastFeedInfo feed) { return(RemovePodcastFeed(feed, true)); }
public UpdateActivityEventArgs(PodcastFeedInfo podcastFeed) { podcast_feed = podcastFeed; }
public RssPodcastFeedParser(XmlDocument doc, PodcastFeedInfo feed) : base(doc, feed) { }
//------------------------------------------------- public bool RemovePodcastFeed(PodcastFeedInfo feed) { return RemovePodcastFeed (feed, true); }
public bool AddPodcastFeed(PodcastFeedInfo feed, bool update) { if (feed == null) { throw new ArgumentNullException ("feed"); } bool new_feed = false; if (feed != null) { lock (PodcastFeedSync) { new_feed = AddPodcastFeedToLibrary (feed, true); } if (update && new_feed) { EmitPodcastFeedAdded (new PodcastFeedEventArgs (feed)); } } return new_feed; }
/*public PodcastFeedInfo AddPodcastFeedFromUri (Uri feedUri, SyncPreference syncPref) { }*/ public PodcastFeedInfo AddPodcastFeedFromUri(Uri feedUri) { if (feedUri == null) { throw new ArgumentNullException ("feedUri"); } try { PodcastFeedInfo feed = null; string key = feedUri.ToString (); lock (podcast_feed_sync) { if (podcast_feeds_keyed.ContainsKey (key)) { // Should users be notified of this? Console.WriteLine (Catalog.GetString("Already Subscribed")); feed = podcast_feeds_keyed [key] as PodcastFeedInfo; feed.IsSubscribed = true; } else { feed = new PodcastFeedInfo (key); AddPodcastFeed (feed); } } return feed; } catch { return null; } }
public static PodcastFeedInfo[] LoadPodcastFeeds() { ArrayList podcastFeeds = new ArrayList (); IDataReader feed_reader = Globals.Library.Db.Query (@" SELECT * FROM PodcastFeeds ORDER BY Title "); while(feed_reader.Read()) { PodcastFeedInfo feed = null; feed = new PodcastFeedInfo ( feed_reader.GetInt32 (0), feed_reader.GetString (1), feed_reader.GetString (2), GetStringSafe (feed_reader, 3), GetStringSafe (feed_reader, 4), GetStringSafe (feed_reader, 5), feed_reader.GetDateTime (6), feed_reader.GetBoolean (7), (SyncPreference)feed_reader.GetInt32(8) ); podcastFeeds.Add (feed); feed.Add (LoadPodcasts (feed)); } feed_reader.Close (); return podcastFeeds.ToArray (typeof (PodcastFeedInfo)) as PodcastFeedInfo[]; }
protected PodcastFeedParser(XmlDocument doc, PodcastFeedInfo feed) { xml_doc = doc; podcasts = null; this.feed = feed; }
public static PodcastFeedParser Create(XmlDocument doc, PodcastFeedInfo feed) { if (doc == null) { throw new ArgumentNullException ("doc"); } else if (doc == null) { throw new ArgumentNullException ("feed"); } // Only Rss is supported at this time, add logic for others when time is not short. return (PodcastFeedParser) new RssPodcastFeedParser (doc, feed); }
private PodcastFeedEventArgs(PodcastFeedInfo podcastFeed, ICollection podcastFeeds) { podcast_feed = podcastFeed; podcast_feeds = podcastFeeds; }
public bool AddPodcastFeed(PodcastFeedInfo feed) { return(AddPodcastFeed(feed, true)); }
private void OnFeedViewSelectionChanged(object sender, EventArgs args) { PodcastFeedInfo selected_feed = GetSelectedFeed (); if (selected_feed == null || previously_selected == selected_feed) { return; } if (previously_selected != PodcastFeedInfo.All) { if (previously_selected.NewPodcasts > 0) { previously_selected.Select (); } } podcast_view.FilterOnFeed (selected_feed); previously_selected = selected_feed; }
private PodcastInfo(int id, PodcastFeedInfo feed, string url) { treeIter = TreeIter.Zero; this.id = id; this.feed = feed; this.url = new SafeUri (url); }
public bool AddPodcastFeed(PodcastFeedInfo feed) { return AddPodcastFeed (feed, true); }
public bool RemovePodcastFeed(PodcastFeedInfo feed, bool update) { if (feed == null) { throw new ArgumentNullException ("feeds"); } bool removed = false; lock (PodcastFeedSync) { removed = RemovePodcastFeedFromLibrary (feed); } if (update && removed) { PodcastFeedEventArgs args = new PodcastFeedEventArgs (feed); EmitPodcastFeedRemoved (args); } return false; }
public void Update(PodcastFeedInfo feed) { Update (feed, true); }
private static PodcastInfo[] LoadPodcasts(PodcastFeedInfo feed) { ArrayList podcasts = new ArrayList (); IDataReader podcast_reader = Globals.Library.Db.Query ( new DbCommand( @"SELECT * FROM Podcasts WHERE PodcastFeedID = :feed_id", "feed_id", feed.ID ) ); while (podcast_reader.Read()) { podcasts.Add( new PodcastInfo ( feed, podcast_reader.GetInt32 (0), GetStringSafe (podcast_reader, 2), GetStringSafe (podcast_reader, 3), podcast_reader.GetDateTime (4), GetStringSafe (podcast_reader, 5), GetStringSafe (podcast_reader, 6), GetStringSafe (podcast_reader, 7), podcast_reader.GetString (8), podcast_reader.GetString (9), podcast_reader.GetInt64 (10), podcast_reader.GetBoolean (11), podcast_reader.GetBoolean (12) ) ); } podcast_reader.Close (); return podcasts.ToArray (typeof (PodcastInfo)) as PodcastInfo[]; }
internal static void SubscribeToPodcastFeed(string uri, SyncPreference sync) { PodcastFeedInfo feed = new PodcastFeedInfo (uri, sync); feed.UpdateFinished += InitialFeedUpdateHandler; if (feed != null) { ThreadAssist.Spawn ( delegate { FeedFetcher.Update (feed, true); }); } }
// Should use ActionManager at some point private void FeedViewMenuPopup(uint time, PodcastFeedInfo feed) { if(feed_view_popup_menu == null) { feed_view_popup_menu = new Menu (); feed_subscription_menu_item = new CheckMenuItem (Catalog.GetString("Subscribed")); feed_subscription_menu_item.Toggled += OnFeedMenuSubscribeToggled; feed_update_menu_item = new ImageMenuItem (Catalog.GetString ("Update Feed")); feed_update_menu_item.Image = new Gtk.Image (Gtk.Stock.Refresh, IconSize.Menu); feed_update_menu_item.Activated += OnFeedMenuUpdateCurrentActivated; feed_remove_menu_item = new ImageMenuItem (Catalog.GetString ("Delete Feed")); feed_remove_menu_item.Image = new Gtk.Image (Gtk.Stock.Delete, IconSize.Menu); feed_remove_menu_item.Activated += OnFeedMenuRemoveActivated; feed_new_menu_item = new ImageMenuItem (Catalog.GetString ("Subscribe to New Feed")); feed_new_menu_item.Image = new Gtk.Image (Gtk.Stock.New, IconSize.Menu); feed_new_menu_item.Activated += OnFeedMenuNewActivated; feed_visit_link_menu_item = new ImageMenuItem (Catalog.GetString ("Homepage")); feed_visit_link_menu_item.Image = new Gtk.Image (Gtk.Stock.JumpTo, IconSize.Menu); feed_visit_link_menu_item.Activated += OnFeedMenuVisitLinkActivated; feed_properties_menu_item = new ImageMenuItem (Catalog.GetString ("Properties")); feed_properties_menu_item.Image = new Gtk.Image (Gtk.Stock.Properties, IconSize.Menu); feed_properties_menu_item.Activated += OnFeedMenuPropertiesActivated; feed_view_popup_menu.Append (feed_subscription_menu_item); feed_view_popup_menu.Append (new SeparatorMenuItem ()); feed_view_popup_menu.Append (feed_remove_menu_item); feed_view_popup_menu.Append (feed_new_menu_item); feed_view_popup_menu.Append (new SeparatorMenuItem ()); feed_view_popup_menu.Append (feed_visit_link_menu_item); feed_view_popup_menu.Append (feed_update_menu_item); feed_view_popup_menu.Append (new SeparatorMenuItem ()); feed_view_popup_menu.Append (feed_properties_menu_item); feed_view_popup_menu.ShowAll (); } feed_subscription_menu_item.Toggled -= OnFeedMenuSubscribeToggled; feed_subscription_menu_item.Active = feed.IsSubscribed; feed_subscription_menu_item.Toggled += OnFeedMenuSubscribeToggled; if (feed.IsBusy) { // TODO Allow users to delete / unsubscribe from a busy feed. // This will be trivial once the download code is moved into PodcastFeedInfo. feed_subscription_menu_item.Sensitive = false; feed_remove_menu_item.Sensitive = false; } else { feed_remove_menu_item.Sensitive = true; feed_subscription_menu_item.Sensitive = true; } feed_view_popup_menu.Popup (null, null, null, 0, time); return; }