banshee r4033 - in trunk/banshee: . src/Extensions/Banshee.Podcasting/Banshee.Podcasting src/Libraries/Migo/Migo.Syndication



Author: gburt
Date: Fri May 30 03:26:53 2008
New Revision: 4033
URL: http://svn.gnome.org/viewvc/banshee?rev=4033&view=rev

Log:
2008-05-29  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:
	Don't pulse the podcasts source when feeds are changes, just when items
	are added.

	* src/Libraries/Migo/Migo.Syndication/FeedUpdateTask.cs: If the feed
	hasn't been updated since we last checked, pass notify=false to feed.Save.

	* src/Libraries/Migo/Migo.Syndication/Feed.cs: Don't raise FeedsChanged
	when DownloadStatus set, just in Save and Delete.  Add override to Save
	that takes bool notify arg.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
   trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs
   trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedUpdateTask.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	Fri May 30 03:26:53 2008
@@ -289,7 +289,6 @@
         private void OnFeedsChanged (object o, EventArgs args)
         {
             source.Reload ();
-            source.NotifyUser ();
         }
 
         /*private void OnFeedAddedHandler (object sender, FeedEventArgs args)

Modified: trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs	(original)
+++ trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs	Fri May 30 03:26:53 2008
@@ -277,7 +277,7 @@
         private FeedDownloadStatus download_status;
         public FeedDownloadStatus DownloadStatus { 
             get { return download_status; }
-            set { download_status = value; Manager.OnFeedsChanged (); }
+            set { download_status = value; }
         }
         
         [DatabaseColumn("IsSubscribed")]
@@ -544,13 +544,20 @@
 
         public void Save ()
         {
+            Save (true);
+        }
+
+        public void Save (bool notify)
+        {
             Provider.Save (this);
             
             if (LastBuildDate > LastAutoDownload) {
                 CheckForItemsToDownload ();
             }
 
-            Manager.OnFeedsChanged ();
+            if (notify) {
+                Manager.OnFeedsChanged ();
+            }
         }
         
         private void CheckForItemsToDownload ()

Modified: trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedUpdateTask.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedUpdateTask.cs	(original)
+++ trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedUpdateTask.cs	Fri May 30 03:26:53 2008
@@ -140,6 +140,7 @@
 
         private void OnDownloadDataReceived (object sender, Migo.Net.DownloadStringCompletedEventArgs args) 
         {
+            bool notify_on_save = true;
             lock (SyncRoot) {
                 if (cancelled)
                     return;
@@ -147,37 +148,38 @@
                 wc.DownloadStringCompleted -= OnDownloadDataReceived;
                 FeedDownloadError error;
                 
-                if (args.Error == null) {
+                WebException we = args.Error as WebException;
+                if (we == null) {
                      try {
+                        DateTime last_built_at = feed.LastBuildDate;
                         RssParser parser = new RssParser (feed.Url, args.Result);
                         parser.UpdateFeed (feed);
                         feed.SetItems (parser.GetFeedItems (feed));
                         error = FeedDownloadError.None;
+                        notify_on_save = feed.LastBuildDate > last_built_at;
                     } catch (FormatException e) {
                         Log.Exception (e);
                         error = FeedDownloadError.InvalidFeedFormat;
                     }
                 } else {
                     error = FeedDownloadError.DownloadFailed;
-                    WebException we = args.Error as WebException;
-                    if (we != null) {
-                        HttpWebResponse resp = we.Response as HttpWebResponse;
-                        if (resp != null) {
-                            switch (resp.StatusCode) {
-                            case HttpStatusCode.NotFound:
-                            case HttpStatusCode.Gone:
-                                error = FeedDownloadError.DoesNotExist;
-                                break;                                
-                            case HttpStatusCode.NotModified:
-                                error = FeedDownloadError.None;
-                                break;
-                            case HttpStatusCode.Unauthorized:
-                                error = FeedDownloadError.UnsupportedAuth;
-                                break;                                
-                            default:
-                                error = FeedDownloadError.DownloadFailed;
-                                break;
-                            }
+                    HttpWebResponse resp = we.Response as HttpWebResponse;
+                    if (resp != null) {
+                        switch (resp.StatusCode) {
+                        case HttpStatusCode.NotFound:
+                        case HttpStatusCode.Gone:
+                            error = FeedDownloadError.DoesNotExist;
+                            break;                                
+                        case HttpStatusCode.NotModified:
+                            notify_on_save = false;
+                            error = FeedDownloadError.None;
+                            break;
+                        case HttpStatusCode.Unauthorized:
+                            error = FeedDownloadError.UnsupportedAuth;
+                            break;                                
+                        default:
+                            error = FeedDownloadError.DownloadFailed;
+                            break;
                         }
                     }
                 }
@@ -187,7 +189,7 @@
                     feed.LastDownloadTime = DateTime.Now;
                 }
                     
-                feed.Save ();
+                feed.Save (notify_on_save);
                 
                 EmitCompletionEvents (error);
                 completed = true;



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