banshee r4637 - in trunk/banshee: . src/Extensions/Banshee.Podcasting/Banshee.Podcasting



Author: gburt
Date: Wed Oct  1 00:31:25 2008
New Revision: 4637
URL: http://svn.gnome.org/viewvc/banshee?rev=4637&view=rev

Log:
2008-09-30  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:
	Every 10 minutes refresh any podcasts that haven't been updated in over an
	hour (BGO #508418).


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs	Wed Oct  1 00:31:25 2008
@@ -55,7 +55,8 @@
     public partial class PodcastService : IExtensionService, IDisposable, IDelayedInitializeService
     {  
         private readonly string tmp_download_path;
-        private string tmp_enclosure_path; 
+        private string tmp_enclosure_path;
+        private uint refresh_timeout_id = 0;
             
         private bool disposed;
         
@@ -226,16 +227,11 @@
 
             ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.StateChange);
             ServiceManager.Get<DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
-            
-            Banshee.Kernel.Scheduler.Schedule (new Banshee.Kernel.DelegateJob (delegate {
-                DateTime now = DateTime.Now;
-                foreach (Feed feed in Feed.Provider.FetchAll ()) {
-                    if ((now - feed.LastDownloadTime).TotalHours > 1) {
-                        feed.Update ();
-                        RefreshArtworkFor (feed);
-                    }
-                }
-            }));
+
+            RefreshFeeds ();
+
+            // Every 10 minutes try to refresh again
+            refresh_timeout_id = Application.RunTimeout (1000 * 60 * 10, RefreshFeeds);
         }
         
         bool disposing;
@@ -248,6 +244,9 @@
                     disposing = true;               
                 }
             }
+
+            Application.IdleTimeoutRemove (refresh_timeout_id);
+            refresh_timeout_id = 0;
             
             ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
             ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
@@ -274,6 +273,21 @@
                 disposed = true;
             }
         }
+
+        private bool RefreshFeeds ()
+        {
+            Hyena.Log.Debug ("Refreshing any podcasts that haven't been updated in over an hour");
+            Banshee.Kernel.Scheduler.Schedule (new Banshee.Kernel.DelegateJob (delegate {
+                DateTime now = DateTime.Now;
+                foreach (Feed feed in Feed.Provider.FetchAll ()) {
+                    if ((now - feed.LastDownloadTime).TotalHours > 1) {
+                        feed.Update ();
+                        RefreshArtworkFor (feed);
+                    }
+                }
+            }));
+            return true;
+        }
         
         private void OnCommandLineArgument (string uri, object value, bool isFile)
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]