[banshee] Fix up iPod podcast support (BGO #434237)



commit 4e160e604e248c998c0ce4e6425ccc8adf1a605f
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Apr 29 14:17:16 2009 -0500

    Fix up iPod podcast support (BGO #434237)
    
    Depends on ipod-sharp 0.8.4 (trunk).  Set the description and release date.
    Disable if the iPod doesn't support podcasts. Fix a GUI-thread-blocker
    when syncing.

 build/m4/banshee/dap-ipod.m4                       |    2 +-
 .../Banshee.Collection/IPodcastInfo.cs             |   40 ++++++++++++++++++++
 src/Core/Banshee.Core/Makefile.am                  |    1 +
 .../Banshee.Dap.Ipod/IpodSource.cs                 |   28 +-------------
 .../Banshee.Dap.Ipod/IpodTrackInfo.cs              |   22 ++++++++---
 src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs  |    3 +
 src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs         |    4 ++
 .../Banshee.Podcasting.Data/PodcastTrackInfo.cs    |   10 +----
 8 files changed, 69 insertions(+), 41 deletions(-)
---
diff --git a/build/m4/banshee/dap-ipod.m4 b/build/m4/banshee/dap-ipod.m4
index b09b922..ccf74f1 100644
--- a/build/m4/banshee/dap-ipod.m4
+++ b/build/m4/banshee/dap-ipod.m4
@@ -1,6 +1,6 @@
 AC_DEFUN([BANSHEE_CHECK_DAP_IPOD],
 [
-	IPODSHARP_REQUIRED=0.8.1
+	IPODSHARP_REQUIRED=0.8.4
 
 	AC_ARG_ENABLE(ipod, AC_HELP_STRING([--disable-ipod], [Disable iPod DAP support]), , enable_ipod="yes")
 
diff --git a/src/Core/Banshee.Core/Banshee.Collection/IPodcastInfo.cs b/src/Core/Banshee.Core/Banshee.Collection/IPodcastInfo.cs
new file mode 100644
index 0000000..229273e
--- /dev/null
+++ b/src/Core/Banshee.Core/Banshee.Collection/IPodcastInfo.cs
@@ -0,0 +1,40 @@
+//
+// IPodcastInfo.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2009 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Banshee.Collection
+{
+    public interface IPodcastInfo
+    {
+        string Description { get; }
+        DateTime ReleaseDate { get; }
+        //TimeSpan BookmarkTime { get; set; }
+        //bool RememberPosition { get; set; }
+    }
+}
diff --git a/src/Core/Banshee.Core/Makefile.am b/src/Core/Banshee.Core/Makefile.am
index 219235b..ae6c1b5 100644
--- a/src/Core/Banshee.Core/Makefile.am
+++ b/src/Core/Banshee.Core/Makefile.am
@@ -23,6 +23,7 @@ SOURCES =  \
 	Banshee.Collection/FileTrackInfo.cs \
 	Banshee.Collection/IBasicTrackInfo.cs \
 	Banshee.Collection/ITrackInfo.cs \
+	Banshee.Collection/IPodcastInfo.cs \
 	Banshee.Collection/SampleTrackInfo.cs \
 	Banshee.Collection/TrackAttributes.cs \
 	Banshee.Collection/TrackFilterType.cs \
diff --git a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
index 797c053..ea13d0f 100644
--- a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
+++ b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
@@ -88,7 +88,7 @@ namespace Banshee.Dap.Ipod
 
             // TODO disable this later, but right now it won't disable it in Sync, so might as well
             // leave it enabled
-            //SupportsPodcasts = ipod_device.ModelInfo.HasCapability ("podcast");
+            SupportsPodcasts = ipod_device.ModelInfo.HasCapability ("podcast");
             SupportsVideo = ipod_device.ModelInfo.DeviceClass == "video" ||
                             ipod_device.ModelInfo.DeviceClass == "classic" ||
                             (ipod_device.ModelInfo.DeviceClass == "nano" && ipod_device.ModelInfo.Generation >= 3);
@@ -238,7 +238,6 @@ namespace Banshee.Dap.Ipod
                         SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND ExternalID = ?");
                 foreach (IPod.Playlist playlist in ipod_device.TrackDatabase.Playlists) {
                     if (playlist.IsOnTheGo) { // || playlist.IsPodcast) {
-                        Console.WriteLine ("have playlist {0} with {1} items but ignoring b/c otg or podcast", playlist.Name, playlist.Tracks.Count);
                         continue;
                     }
                     PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
@@ -591,7 +590,7 @@ namespace Banshee.Dap.Ipod
             // Remove playlists on the device
             List<IPod.Playlist> device_playlists = new List<IPod.Playlist> (ipod_device.TrackDatabase.Playlists);
             foreach (IPod.Playlist playlist in device_playlists) {
-                if (!playlist.IsOnTheGo) { // && !playlist.IsPodcast) {
+                if (!playlist.IsOnTheGo) {
                     ipod_device.TrackDatabase.RemovePlaylist (playlist);
                 }
             }
@@ -613,16 +612,6 @@ namespace Banshee.Dap.Ipod
                 }
             }
     
-            // Sync podcast playlist
-            /*IPod.Playlist podcast_playlist = GetPodcastPlaylist ();
-            podcast_playlist.Clear ();
-            foreach (int track_id in ServiceManager.DbConnection.QueryEnumerable<int> (
-                "SELECT CoreTracks.TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND (Attributes & ?) != 0",
-                DbId, (int)Banshee.Collection.TrackMediaAttributes.Podcast))
-            {
-                podcast_playlist.AddTrack (tracks_map[track_id].IpodTrack);
-            }*/
-            
             try {
                 ipod_device.TrackDatabase.SaveStarted += OnIpodDatabaseSaveStarted;
                 ipod_device.TrackDatabase.SaveEnded += OnIpodDatabaseSaveEnded;
@@ -639,19 +628,6 @@ namespace Banshee.Dap.Ipod
             }
         }
 
-        /*private IPod.Playlist GetPodcastPlaylist ()
-        {
-            foreach (IPod.Playlist playlist in ipod_device.TrackDatabase.Playlists) {
-                if (playlist.IsPodcast) {
-                    return playlist;
-                }
-            }
-
-            IPod.Playlist podcast_playlist= ipod_device.TrackDatabase.CreatePlaylist (Catalog.GetString ("Podcasts"));
-            podcast_playlist.IsPodcast = true;
-            return podcast_playlist;
-        }*/
-        
         private UserJob sync_user_job;
         
         private void OnIpodDatabaseSaveStarted (object o, EventArgs args)
diff --git a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
index e04ba5f..5a875a4 100644
--- a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
+++ b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
@@ -48,6 +48,9 @@ namespace Banshee.Dap.Ipod
         internal int IpodId {
             get { return ipod_id; }
         }
+
+        // Used for podcasts only
+        private string description;
         
         public IpodTrackInfo (IPod.Track track) : base ()
         {
@@ -90,6 +93,12 @@ namespace Banshee.Dap.Ipod
                 TrackTitle = track.TrackTitle;
                 Year = track.Year;
                 MediaAttributes = track.MediaAttributes;
+
+                var podcast_info = track.ExternalObject as IPodcastInfo;
+                if (podcast_info != null) {
+                    description = podcast_info.Description;
+                    ReleaseDate = podcast_info.ReleaseDate;
+                }
             }
             
             CanSaveToDatabase = true;
@@ -126,8 +135,9 @@ namespace Banshee.Dap.Ipod
             TrackCount = track.TotalTracks;
             TrackNumber = track.TrackNumber;
             TrackTitle = String.IsNullOrEmpty (track.Title) ? null : track.Title;
-            //ReleaseDate = track.DateReleased;
             Year = track.Year;
+            description = track.Description;
+            ReleaseDate = track.DateReleased;
             
             switch (track.Rating) {
                 case IPod.TrackRating.One:   rating = 1; break;
@@ -204,7 +214,7 @@ namespace Banshee.Dap.Ipod
             track.TotalTracks = TrackCount;
             track.TrackNumber = TrackNumber;
             track.Year = Year;
-            //track.DateReleased = ReleaseDate;
+            track.DateReleased = ReleaseDate;
             
             track.Album = AlbumTitle;
             track.Artist = ArtistName;
@@ -221,10 +231,10 @@ namespace Banshee.Dap.Ipod
             }
 
             if (HasAttribute (TrackMediaAttributes.Podcast)) {
-                //track.Description = ..
-                //track.Category = ..
-                //track.RememberPosition = true;
-                //track.NotPlayedMark = track.PlayCount == 0;
+                track.DateReleased = ReleaseDate;
+                track.Description = description;
+                track.RememberPosition = true;
+                track.NotPlayedMark = track.PlayCount == 0;
             }
 
             if (HasAttribute (TrackMediaAttributes.VideoStream)) {
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
index d379274..19994fe 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
@@ -99,6 +99,9 @@ namespace Banshee.Dap.Gui
         
         private void OnSourceUpdated (object o, EventArgs args)
         {
+            if (source.Sync.Syncing)
+                return;
+
             Banshee.Base.ThreadAssist.ProxyToMain (delegate {
                 try {
                     UpdateUsage ();
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
index 2293e79..a1f4032 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
@@ -222,6 +222,10 @@ namespace Banshee.Dap
                 if (!dap.SupportsVideo) {
                     sources.Remove (ServiceManager.SourceManager.VideoLibrary);
                 }
+
+                if (!dap.SupportsPodcasts) {
+                    sources.RemoveAll (s => s.UniqueId == "PodcastSource-PodcastLibrary");
+                }
                 
                 foreach (Source source in sources) {
                     if (source is LibrarySource) {
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
index ad92b35..c20fabb 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
@@ -56,7 +56,7 @@ namespace Banshee.Podcasting.Data
         None = 7
     }
 
-    public class PodcastTrackInfo
+    public class PodcastTrackInfo : IPodcastInfo
     {
         public static PodcastTrackInfo From (TrackInfo track)
         {
@@ -81,7 +81,6 @@ namespace Banshee.Podcasting.Data
             }
         }
         
-        private int position;
         private DatabaseTrackInfo track;
 
 #region Properties
@@ -121,15 +120,10 @@ namespace Banshee.Podcasting.Data
             get { return !String.IsNullOrEmpty (Enclosure.LocalPath); }
         }
         
-        public int Position {
-            get { return position; }
-            set { position = value; }
-        }
-
         public DateTime ReleaseDate {
             get { return Item.PubDate; }
         }
-        
+
         public FeedEnclosure Enclosure {
             get { return (Item == null) ? null : Item.Enclosure; }
         }



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