private void EmitPodcastFeedEvent(PodcastFeedEventHandler handler,
                                   PodcastFeedEventArgs args)
 {
     if (handler != null)
     {
         handler(this, args);
     }
 }
        public int AddPodcastFeeds(ICollection feeds, bool update)
        {
            if (feeds == null)
            {
                throw new ArgumentNullException("feeds");
            }

            ArrayList new_feeds = new ArrayList();

            if (feeds != null)
            {
                lock (podcast_feed_sync)
                {
                    foreach (PodcastFeedInfo feed in feeds)
                    {
                        if (AddPodcastFeedToLibrary(feed, false))
                        {
                            new_feeds.Add(feed);
                        }
                    }

                    if (new_feeds.Count > 0)
                    {
                        podcast_feeds.Sort();
                    }
                }

                if (update && (new_feeds.Count > 0))
                {
                    PodcastFeedEventArgs args;

                    if (new_feeds.Count == 1)
                    {
                        args = new PodcastFeedEventArgs(new_feeds[0] as PodcastFeedInfo);
                    }
                    else
                    {
                        args = new PodcastFeedEventArgs(new_feeds.ToArray(
                                                            typeof(PodcastFeedInfo)) as PodcastFeedInfo[]
                                                        );
                    }

                    EmitPodcastFeedAdded(args);
                }
            }

            return(new_feeds.Count);
        }
        public int RemovePodcastFeeds(ICollection feeds, bool update)
        {
            if (feeds == null)
            {
                throw new ArgumentNullException("feeds");
            }

            ArrayList removed_feeds = new ArrayList();

            lock (PodcastFeedSync)
            {
                foreach (PodcastFeedInfo feed in feeds)
                {
                    if (feed != null)
                    {
                        if (RemovePodcastFeedFromLibrary(feed))
                        {
                            removed_feeds.Add(feed);
                        }
                    }
                }

                if (update && (removed_feeds.Count > 0))
                {
                    PodcastFeedEventArgs args;

                    if (removed_feeds.Count == 1)
                    {
                        args = new PodcastFeedEventArgs(removed_feeds[0] as PodcastFeedInfo);
                    }
                    else
                    {
                        args = new PodcastFeedEventArgs(removed_feeds);
                    }

                    EmitPodcastFeedRemoved(args);
                }
            }

            return(removed_feeds.Count);
        }
        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);
        }
 private void EmitPodcastFeedRemoved(PodcastFeedEventArgs args)
 {
     EmitPodcastFeedEvent(PodcastFeedRemoved, args);
 }
 private void EmitPodcastFeedEvent(PodcastFeedEventHandler handler,
                                    PodcastFeedEventArgs args)
 {
     if (handler != null)
     {
         handler (this, args);
     }
 }
 private void EmitPodcastFeedRemoved(PodcastFeedEventArgs args)
 {
     EmitPodcastFeedEvent (PodcastFeedRemoved, args);
 }
        public int RemovePodcastFeeds(ICollection feeds, bool update)
        {
            if (feeds == null)
            {
                throw new ArgumentNullException ("feeds");
            }

            ArrayList removed_feeds = new ArrayList ();

            lock (PodcastFeedSync)
            {
                foreach (PodcastFeedInfo feed in feeds)
                {
                    if (feed != null)
                    {
                        if (RemovePodcastFeedFromLibrary (feed))
                        {
                            removed_feeds.Add (feed);
                        }
                    }
                }

                if (update && (removed_feeds.Count > 0))
                {
                    PodcastFeedEventArgs args;

                    if (removed_feeds.Count == 1)
                    {
                        args = new PodcastFeedEventArgs (removed_feeds[0] as PodcastFeedInfo);
                    }
                    else
                    {
                        args = new PodcastFeedEventArgs (removed_feeds);
                    }

                    EmitPodcastFeedRemoved (args);
                }
            }

            return removed_feeds.Count;
        }
        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 int AddPodcastFeeds(ICollection feeds, bool update)
        {
            if (feeds == null)
            {
                throw new ArgumentNullException ("feeds");
            }

            ArrayList new_feeds = new ArrayList ();

            if (feeds != null)
            {
                lock (podcast_feed_sync)
                {
                    foreach (PodcastFeedInfo feed in feeds)
                    {
                        if (AddPodcastFeedToLibrary (feed, false))
                        {
                            new_feeds.Add (feed);
                        }
                    }

                    if (new_feeds.Count > 0)
                    {
                        podcast_feeds.Sort ();
                    }
                }

                if (update && (new_feeds.Count > 0))
                {
                    PodcastFeedEventArgs args;

                    if (new_feeds.Count == 1)
                    {
                        args = new PodcastFeedEventArgs (new_feeds[0] as PodcastFeedInfo);
                    }
                    else
                    {
                        args = new PodcastFeedEventArgs (new_feeds.ToArray (
                                                             typeof(PodcastFeedInfo)) as PodcastFeedInfo[]
                                                        );
                    }

                    EmitPodcastFeedAdded (args);
                }
            }

            return new_feeds.Count;
        }
        private void PodcastFeedAddedOrRemoved(PodcastFeedEventArgs args, bool added)
        {
            if (args.Feed != null)
            {
                PodcastFeedInfo feed = args.Feed;

                if (added)
                {
                    podcast_feed_model.QueueAdd (feed);
                }
                else
                {
                    // Only single select is handled at the moment.
                    // This will need to be updated if multiple feed selection becomes available.
                    TreeIter iter = feed.TreeIter;

                    podcast_feed_model.QueueRemove (feed);
                    podcast_feed_model.IterNext (ref iter);

                    if (podcast_feed_model.GetPath (iter) != null)
                    {
                        podcast_feed_view.Selection.SelectIter (iter);
                        podcast_feed_view.ScrollToIter (iter);
                        return;
                    }

                    // Should not select first, should select previous.  Why
                    // is there no 'TreeModel.IterPrev' method?
                    podcast_feed_model.GetIterFirst (out iter);

                    if (podcast_feed_model.GetPath (iter) != null)
                    {
                        podcast_feed_view.Selection.SelectIter (iter);
                        podcast_feed_view.ScrollToIter (iter);
                    }
                }
            }
            else if (args.Feeds != null)
            {
                ICollection feeds = args.Feeds;

                if (added)
                {
                    podcast_feed_model.QueueAdd (feeds);
                }
                else
                {
                    podcast_feed_model.QueueRemove (feeds);
                }
            }

            Update ();
        }
 private void OnPodcastFeedRemovedHandler(object sender, PodcastFeedEventArgs args)
 {
     PodcastFeedAddedOrRemoved (args, false);
 }