Index: configure.ac =================================================================== RCS file: /cvs/gnome/banshee/configure.ac,v retrieving revision 1.153 diff -u -r1.153 configure.ac --- configure.ac 21 Jun 2006 02:35:20 -0000 1.153 +++ configure.ac 29 Jun 2006 18:22:08 -0000 @@ -139,12 +139,12 @@ AC_SUBST(GTKSHARP_LIBS) dnl dap support -IPODSHARP_REQUIRED=0.5.15 +IPODSHARP_REQUIRED=0.6.0 PKG_CHECK_MODULES(IPODSHARP, - ipod-sharp >= $IPODSHARP_REQUIRED, + ipod-sharp >= $IPODSHARP_REQUIRED ipod-sharp-ui >= $IPODSHARP_REQUIRED, enable_ipodsharp="$enable_ipodsharp", enable_ipodsharp=no) if test "x$enable_ipodsharp" = "xyes"; then - IPODSHARP_ASSEMBLIES="`$PKG_CONFIG --variable=Libraries ipod-sharp`" + IPODSHARP_ASSEMBLIES="`$PKG_CONFIG --variable=Libraries ipod-sharp` `$PKG_CONFIG --variable=Libraries ipod-sharp-ui`" AC_SUBST(IPODSHARP_ASSEMBLIES) AC_SUBST(IPODSHARP_LIBS) fi Index: src/Banshee.Base/TrackInfo.cs =================================================================== RCS file: /cvs/gnome/banshee/src/Banshee.Base/TrackInfo.cs,v retrieving revision 1.13 diff -u -r1.13 TrackInfo.cs --- src/Banshee.Base/TrackInfo.cs 14 May 2006 03:22:46 -0000 1.13 +++ src/Banshee.Base/TrackInfo.cs 29 Jun 2006 18:22:09 -0000 @@ -164,7 +164,7 @@ } } - private string cover_art_file = null; + protected string cover_art_file = null; public string CoverArtFileName { get { if(cover_art_file != null) { Index: src/Banshee.Dap/Ipod/DatabaseRebuilder.cs =================================================================== RCS file: /cvs/gnome/banshee/src/Banshee.Dap/Ipod/DatabaseRebuilder.cs,v retrieving revision 1.3 diff -u -r1.3 DatabaseRebuilder.cs --- src/Banshee.Dap/Ipod/DatabaseRebuilder.cs 13 Feb 2006 22:18:10 -0000 1.3 +++ src/Banshee.Dap/Ipod/DatabaseRebuilder.cs 29 Jun 2006 18:22:10 -0000 @@ -74,7 +74,7 @@ ScanMusicDirectory(directory); } - ProcessSongQueue(); + ProcessTrackQueue(); } private void ScanMusicDirectory(DirectoryInfo directory) @@ -84,18 +84,18 @@ } } - private void ProcessSongQueue() + private void ProcessTrackQueue() { discovery_count = song_queue.Count; - user_event.Message = Catalog.GetString("Processing Songs..."); + user_event.Message = Catalog.GetString("Processing Tracks..."); while(song_queue.Count > 0) { user_event.Progress = (double)(discovery_count - song_queue.Count) / (double)discovery_count; try { - ProcessSong(song_queue.Dequeue() as FileInfo); + ProcessTrack(song_queue.Dequeue() as FileInfo); } catch { } @@ -114,10 +114,10 @@ OnFinished(); } - private void ProcessSong(FileInfo file) + private void ProcessTrack(FileInfo file) { AudioFile af = new AudioFile(file.FullName); - Song song = dap.Device.SongDatabase.CreateSong(); + Track song = dap.Device.TrackDatabase.CreateTrack(); song.FileName = file.FullName; song.Album = af.Album; @@ -139,7 +139,7 @@ user_event.Progress = 0.0; try { - dap.Device.SongDatabase.Save(); + dap.Device.TrackDatabase.Save(); } catch(Exception e) { LogCore.Instance.PushError( Catalog.GetString("Error rebuilding iPod database"), Index: src/Banshee.Dap/Ipod/IpodDap.cs =================================================================== RCS file: /cvs/gnome/banshee/src/Banshee.Dap/Ipod/IpodDap.cs,v retrieving revision 1.14 diff -u -r1.14 IpodDap.cs --- src/Banshee.Dap/Ipod/IpodDap.cs 13 Jun 2006 02:16:32 -0000 1.14 +++ src/Banshee.Dap/Ipod/IpodDap.cs 29 Jun 2006 18:22:10 -0000 @@ -73,7 +73,7 @@ InstallProperty("Model Number", device.ModelNumber); InstallProperty("Serial Number", device.SerialNumber); InstallProperty("Firmware Version", device.FirmwareVersion); - InstallProperty("Database Version", device.SongDatabase.Version.ToString()); + InstallProperty("Database Version", device.TrackDatabase.Version.ToString()); ReloadDatabase(false); @@ -85,10 +85,10 @@ { try { device = new IPod.Device(hal_device["block.device"]); - device.LoadSongDatabase(); + device.LoadTrackDatabase(); database_supported = true; } catch(DatabaseReadException) { - device.LoadSongDatabase(true); + device.LoadTrackDatabase(true); database_supported = false; } catch(Exception e) { return InitializeResult.Invalid; @@ -106,8 +106,10 @@ if(track is IpodDapTrackInfo) new_track = track; - else if(!TrackExistsInList(track, device.SongDatabase.Songs)) - new_track = new IpodDapTrackInfo(track, device.SongDatabase); + else + new_track = new IpodDapTrackInfo(track, device.TrackDatabase); + // FIXME: only add a new track if we don't have it already + if (new_track != null) { tracks.Add(new_track); @@ -123,7 +125,7 @@ try { IpodDapTrackInfo ipod_track = (IpodDapTrackInfo)track; - device.SongDatabase.RemoveSong(ipod_track.Song); + device.TrackDatabase.RemoveTrack(ipod_track.Track); } catch(Exception) { } } @@ -135,13 +137,13 @@ ClearTracks(false); if(refresh) { - device.SongDatabase.Reload(); + device.TrackDatabase.Reload(); } if(database_supported) { - foreach(Song song in device.SongDatabase.Songs) { - IpodDapTrackInfo track = new IpodDapTrackInfo(song); - AddTrack(track); + foreach(Track track in device.TrackDatabase.Tracks) { + IpodDapTrackInfo ti = new IpodDapTrackInfo(track); + AddTrack(ti); } } else { BuildDatabaseUnsupportedWidget(); @@ -166,25 +168,25 @@ 0.0); foreach(IpodDapTrackInfo track in Tracks) { - if(track.Song == null) { + if(track.Track == null) { CommitTrackToDevice(track); } else { - track.Song.Uri = new Uri(track.Uri.AbsoluteUri); + track.Track.Uri = new Uri(track.Uri.AbsoluteUri); } } - device.SongDatabase.SaveProgressChanged += delegate(object o, SaveProgressArgs args) + device.TrackDatabase.SaveProgressChanged += delegate(object o, TrackSaveProgressArgs args) { - double progress = args.CurrentSong == null ? 0.0 : args.TotalProgress; - string message = args.CurrentSong == null + double progress = args.CurrentTrack == null ? 0.0 : args.TotalProgress; + string message = args.CurrentTrack == null ? Catalog.GetString("Flushing to Disk (may take time)") - : args.CurrentSong.Artist + " - " + args.CurrentSong.Title; + : args.CurrentTrack.Artist + " - " + args.CurrentTrack.Title; UpdateSaveProgress(Catalog.GetString("Synchronizing iPod"), message, progress); }; try { - device.SongDatabase.Save(); + device.TrackDatabase.Save(); } catch(Exception e) { Console.Error.WriteLine (e); LogCore.Instance.PushError(Catalog.GetString("Failed to synchronize iPod"), e.Message); @@ -194,57 +196,80 @@ } } - private void CommitTrackToDevice(IpodDapTrackInfo track) + private void CommitTrackToDevice(IpodDapTrackInfo ti) { - Song song = device.SongDatabase.CreateSong(); + Track track = device.TrackDatabase.CreateTrack(); - song.Uri = new Uri(track.Uri.AbsoluteUri); + track.Uri = new Uri(ti.Uri.AbsoluteUri); - if(track.Album != null) { - song.Album = track.Album; + if(ti.Album != null) { + track.Album = ti.Album; } - if(track.Artist != null) { - song.Artist = track.Artist; + if(ti.Artist != null) { + track.Artist = ti.Artist; } - if(track.Title != null) { - song.Title = track.Title; + if(ti.Title != null) { + track.Title = ti.Title; } - if(track.Genre != null) { - song.Genre = track.Genre; + if(ti.Genre != null) { + track.Genre = ti.Genre; } - song.Duration = track.Duration; - song.TrackNumber = (int)track.TrackNumber; - song.TotalTracks = (int)track.TrackCount; - song.Year = (int)track.Year; - song.LastPlayed = track.LastPlayed; + track.Duration = ti.Duration; + track.TrackNumber = (int)ti.TrackNumber; + track.TotalTracks = (int)ti.TrackCount; + track.Year = (int)ti.Year; + track.LastPlayed = ti.LastPlayed; - switch(track.Rating) { - case 1: song.Rating = SongRating.Zero; break; - case 2: song.Rating = SongRating.Two; break; - case 3: song.Rating = SongRating.Three; break; - case 4: song.Rating = SongRating.Four; break; - case 5: song.Rating = SongRating.Five; break; - default: song.Rating = SongRating.Zero; break; + switch(ti.Rating) { + case 1: track.Rating = TrackRating.Zero; break; + case 2: track.Rating = TrackRating.Two; break; + case 3: track.Rating = TrackRating.Three; break; + case 4: track.Rating = TrackRating.Four; break; + case 5: track.Rating = TrackRating.Five; break; + default: track.Rating = TrackRating.Zero; break; } - if(song.Artist == null) { - song.Artist = String.Empty; + if(track.Artist == null) { + track.Artist = String.Empty; } - if(song.Album == null) { - song.Album = String.Empty; + if(track.Album == null) { + track.Album = String.Empty; } - if(song.Title == null) { - song.Title = String.Empty; + if(track.Title == null) { + track.Title = String.Empty; } - if(song.Genre == null) { - song.Genre = String.Empty; + if(track.Genre == null) { + track.Genre = String.Empty; + } + + if (ti.CoverArtFileName != null && File.Exists (ti.CoverArtFileName)) { + try { + Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (ti.CoverArtFileName); + + if (pixbuf != null) { + SetCoverArt (track, ArtworkType.CoverSmall, pixbuf); + SetCoverArt (track, ArtworkType.CoverLarge, pixbuf); + pixbuf.Dispose (); + } + } catch (Exception e) { + Console.Error.WriteLine ("Failed to set cover art: " + e); + } + } + } + + private void SetCoverArt (Track track, ArtworkType type, Gdk.Pixbuf pixbuf) + { + ArtworkFormat format = device.LookupFormat (type); + + if (format != null && !track.HasCoverArt (format)) { + track.SetCoverArt (format, ArtworkHelpers.ToBytes (format, pixbuf)); } } Index: src/Banshee.Dap/Ipod/IpodDapTrackInfo.cs =================================================================== RCS file: /cvs/gnome/banshee/src/Banshee.Dap/Ipod/IpodDapTrackInfo.cs,v retrieving revision 1.4 diff -u -r1.4 IpodDapTrackInfo.cs --- src/Banshee.Dap/Ipod/IpodDapTrackInfo.cs 9 Apr 2006 21:30:26 -0000 1.4 +++ src/Banshee.Dap/Ipod/IpodDapTrackInfo.cs 29 Jun 2006 18:22:10 -0000 @@ -37,21 +37,21 @@ { public sealed class IpodDapTrackInfo : DapTrackInfo { - private Song song; + private Track song; - public IpodDapTrackInfo(Song song) + public IpodDapTrackInfo(Track song) { this.song = song; - LoadFromIpodSong(); + LoadFromIpodTrack(); CanSaveToDatabase = false; } - public IpodDapTrackInfo(TrackInfo track, SongDatabase database) + public IpodDapTrackInfo(TrackInfo track, TrackDatabase database) { if(track is IpodDapTrackInfo) { IpodDapTrackInfo ipod_track = (IpodDapTrackInfo)track; - this.song = ipod_track.Song; - LoadFromIpodSong(); + this.song = ipod_track.Track; + LoadFromIpodTrack(); } else { uri = track.Uri; album = track.Album; @@ -67,12 +67,13 @@ track_count = track.TrackCount; track_number = track.TrackNumber; year = track.Year; + cover_art_file = track.CoverArtFileName; } CanSaveToDatabase = false; } - private void LoadFromIpodSong() + private void LoadFromIpodTrack() { try { uri = new SafeUri(song.Uri.LocalPath); @@ -85,17 +86,17 @@ title = song.Title == String.Empty ? null : song.Title; genre = song.Genre == String.Empty ? null : song.Genre; - track_id = song.Id; + track_id = (int) song.Id; duration = song.Duration; play_count = (uint)song.PlayCount; switch(song.Rating) { - case SongRating.One: rating = 1; break; - case SongRating.Two: rating = 2; break; - case SongRating.Three: rating = 3; break; - case SongRating.Four: rating = 4; break; - case SongRating.Five: rating = 5; break; - case SongRating.Zero: + case TrackRating.One: rating = 1; break; + case TrackRating.Two: rating = 2; break; + case TrackRating.Three: rating = 3; break; + case TrackRating.Four: rating = 4; break; + case TrackRating.Five: rating = 5; break; + case TrackRating.Zero: default: rating = 0; break; @@ -125,7 +126,7 @@ Save(); } - public IPod.Song Song + public IPod.Track Track { get { return song;