private void EmitPodcastEvent(PodcastEventHandler handler, PodcastEventArgs args)
 {
     if (handler != null)
     {
         handler(this, args);
     }
 }
        public bool AddPodcast(PodcastInfo pi, bool update)
        {
            if (pi == null)
            {
                throw new ArgumentNullException("pi");
            }

            bool new_podcast = false;

            if (pi != null)
            {
                lock (PodcastSync)
                {
                    new_podcast = AddPodcastToLibrary(pi);
                }

                if (update && new_podcast)
                {
                    PodcastEventArgs args = new PodcastEventArgs(pi);

                    EmitPodcastAdded(args);
                }
            }

            return(false);
        }
        public bool RemovePodcast(PodcastInfo pi, bool update)
        {
            if (podcasts == null)
            {
                throw new ArgumentNullException("podcasts");
            }

            bool removed = false;

            if (pi != null)
            {
                lock (PodcastSync)
                {
                    removed = RemovePodcastFromLibrary(pi, true);
                }

                if (update && removed)
                {
                    PodcastEventArgs args = new PodcastEventArgs(pi);

                    pi.Feed.UpdateCounts();
                    EmitPodcastRemoved(args);
                }
            }

            return(false);
        }
        public int RemovePodcasts(ICollection podcasts, bool update)
        {
            if (podcasts == null)
            {
                throw new ArgumentNullException("podcasts");
            }

            ArrayList removed_podcasts = new ArrayList();

            lock (PodcastSync)
            {
                foreach (PodcastInfo pi in podcasts)
                {
                    if (pi != null)
                    {
                        try
                        {
                            if (RemovePodcastFromLibrary(pi, false))
                            {
                                removed_podcasts.Add(pi);
                            }
                        } catch {
                            continue;
                        }
                    }
                }

                if (update && (removed_podcasts.Count > 0))
                {
                    PodcastEventArgs args;

                    if (removed_podcasts.Count == 1)
                    {
                        args = new PodcastEventArgs(removed_podcasts[0] as PodcastInfo);
                    }
                    else
                    {
                        args = new PodcastEventArgs(removed_podcasts);
                    }

                    try {
                        UpdateParentFeeds(removed_podcasts);
                        EmitPodcastRemoved(args);
                    } finally {
                        PodcastDBManager.Deactivate(removed_podcasts);
                    }
                }
            }

            return(removed_podcasts.Count);
        }
        public ICollection AddPodcasts(ICollection podcasts, bool update)
        {
            if (podcasts == null)
            {
                throw new ArgumentNullException("podcasts");
            }

            ArrayList newUniquePodcasts = new ArrayList();

            if (podcasts != null)
            {
                lock (PodcastSync)
                {
                    foreach (PodcastInfo pi in podcasts)
                    {
                        if (AddPodcastToLibrary(pi))
                        {
                            newUniquePodcasts.Add(pi);
                        }
                    }
                }

                if (update && (newUniquePodcasts.Count > 0))
                {
                    PodcastEventArgs args;

                    if (newUniquePodcasts.Count == 1)
                    {
                        args = new PodcastEventArgs(newUniquePodcasts[0] as PodcastInfo);
                    }
                    else
                    {
                        args = new PodcastEventArgs(newUniquePodcasts);
                    }

                    EmitPodcastAdded(args);
                }
            }

            return((ICollection)newUniquePodcasts);
        }
        private void EmitPodcastRemoved(PodcastEventArgs args)
        {
            PodcastEventHandler handler = PodcastRemoved;

            EmitPodcastEvent(handler, args);
        }
 private void EmitPodcastRemoved(PodcastEventArgs args)
 {
     PodcastEventHandler handler = PodcastRemoved;
     EmitPodcastEvent (handler, args);
 }
        public int RemovePodcasts(ICollection podcasts, bool update)
        {
            if (podcasts == null)
            {
                throw new ArgumentNullException ("podcasts");
            }

            ArrayList removed_podcasts = new ArrayList ();

            lock (PodcastSync)
            {
                foreach (PodcastInfo pi in podcasts)
                {
                    if (pi != null)
                    {
                        try
                        {
                            if (RemovePodcastFromLibrary (pi, false))
                            {
                                removed_podcasts.Add (pi);
                            }
                        } catch {
                            continue;
                        }
                    }
                }

                if (update && (removed_podcasts.Count > 0))
                {
                    PodcastEventArgs args;

                    if (removed_podcasts.Count == 1) {
                        args = new PodcastEventArgs (removed_podcasts[0] as PodcastInfo);
                    } else {
                        args = new PodcastEventArgs (removed_podcasts);
                    }

                    try {
                        UpdateParentFeeds (removed_podcasts);
                        EmitPodcastRemoved (args);
                    } finally {
                        PodcastDBManager.Deactivate (removed_podcasts);
                    }
                }
            }

            return removed_podcasts.Count;
        }
 private void EmitPodcastEvent(PodcastEventHandler handler, PodcastEventArgs args)
 {
     if (handler != null)
     {
         handler (this, args);
     }
 }
        public bool RemovePodcast(PodcastInfo pi, bool update)
        {
            if (podcasts == null)
            {
                throw new ArgumentNullException ("podcasts");
            }

            bool removed = false;

            if (pi != null)
            {
                lock (PodcastSync)
                {
                    removed = RemovePodcastFromLibrary (pi, true);
                }

                if (update && removed)
                {
                    PodcastEventArgs args = new PodcastEventArgs (pi);

                    pi.Feed.UpdateCounts ();
                    EmitPodcastRemoved (args);
                }
            }

            return false;
        }
        public ICollection AddPodcasts(ICollection podcasts, bool update)
        {
            if (podcasts == null)
            {
                throw new ArgumentNullException ("podcasts");
            }

            ArrayList newUniquePodcasts = new ArrayList ();

            if (podcasts != null)
            {
                lock (PodcastSync)
                {
                    foreach (PodcastInfo pi in podcasts)
                    {
                        if (AddPodcastToLibrary (pi))
                        {
                            newUniquePodcasts.Add (pi);
                        }
                    }
                }

                if (update && (newUniquePodcasts.Count > 0))
                {
                    PodcastEventArgs args;

                    if (newUniquePodcasts.Count == 1)
                    {
                        args = new PodcastEventArgs (newUniquePodcasts[0] as PodcastInfo);
                    }
                    else
                    {
                        args = new PodcastEventArgs (newUniquePodcasts);
                    }

                    EmitPodcastAdded (args);
                }
            }

            return (ICollection) newUniquePodcasts;
        }
        public bool AddPodcast(PodcastInfo pi, bool update)
        {
            if (pi == null)
            {
                throw new ArgumentNullException ("pi");
            }

            bool new_podcast = false;

            if (pi != null)
            {
                lock (PodcastSync)
                {
                    new_podcast = AddPodcastToLibrary (pi);
                }

                if (update && new_podcast)
                {
                    PodcastEventArgs args = new PodcastEventArgs (pi);

                    EmitPodcastAdded (args);
                }
            }

            return false;
        }
        private void PodcastAddedOrRemoved(PodcastEventArgs args, bool added)
        {
            if (args.Podcast != null)
            {
                PodcastInfo pi = args.Podcast;
                if (added)
                {
                    podcast_model.QueueAdd (pi);
                }
                else
                {
                    podcast_model.QueueRemove (pi);
                }
            }
            else if (args.Podcasts != null)
            {
                ICollection podcasts = args.Podcasts;

                if (added)
                {
                    podcast_model.QueueAdd (podcasts);
                }
                else
                {
                    podcast_model.QueueRemove (podcasts);
                }
            }

            Update ();
        }
 private void OnPodcastRemovedHandler(object sender, PodcastEventArgs args)
 {
     PodcastAddedOrRemoved (args, false);
 }