banshee r4473 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.SmartPlaylist src/Core/Banshee.Services/Banshee.Sources src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap/Banshee.Dap src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4473 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.SmartPlaylist src/Core/Banshee.Services/Banshee.Sources src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap/Banshee.Dap src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data
- Date: Fri, 5 Sep 2008 15:32:09 +0000 (UTC)
Author: gburt
Date: Fri Sep 5 15:32:09 2008
New Revision: 4473
URL: http://svn.gnome.org/viewvc/banshee?rev=4473&view=rev
Log:
2008-09-05 Gabriel Burt <gabriel burt gmail com>
* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs:
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs:
Make UpdateUnfilteredAggregates public so we can get an accurate count
without doing a full reload.
* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Support
getting an accurate count before having reloaded the track model via a new
UpdateCounts method.
* src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs: Handle loading
playlists when the device is plugged in, and syncing them. Podcast
playlists are still TODO - will require changes to ipod-sharp.
* src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs: Do a better,
more complete job of syncing metadata between TrackInfos and IPod.Track.
* src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs: Call SyncPlaylists on the
dap source when syncing. Not a great API, but needed atm at least to tell
the iPod support it needs to save the playlists even if (possibly) zero
tracks were added/removed.
* src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Remove playlists too when
removing smart playlists. Remove warning about playlists.
* src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs: Handle syncing all
playlists from a library to the device.
* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs:
* src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs: Fix bug
where we listened for TracksChanged etc events on our PrimarySource even
before we were saved/had an id (BGO #550921).
* src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs: Add
comments.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs Fri Sep 5 15:32:09 2008
@@ -34,14 +34,14 @@
public enum TrackMediaAttributes
{
None = (0 << 0),
- AudioStream = (1 << 0),
- VideoStream = (1 << 1),
- Music = (1 << 2),
- AudioBook = (1 << 3),
- Podcast = (1 << 4),
- TvShow = (1 << 5),
- Movie = (1 << 6),
+ AudioStream = (1 << 0), // 1
+ VideoStream = (1 << 1), // 2
+ Music = (1 << 2), // 4
+ AudioBook = (1 << 3), // 8
+ Podcast = (1 << 4), // 16
+ TvShow = (1 << 5), // 32
+ Movie = (1 << 6), // 64
- Default = AudioStream | Music
+ Default = AudioStream | Music // 5
}
}
\ No newline at end of file
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs Fri Sep 5 15:32:09 2008
@@ -199,7 +199,7 @@
}
}
- protected virtual void UpdateUnfilteredAggregates ()
+ public virtual void UpdateUnfilteredAggregates ()
{
HyenaSqliteCommand count_command = new HyenaSqliteCommand (String.Format (
"SELECT COUNT(*), SUM(CoreTracks.FileSize) {0}", UnfilteredQuery
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs Fri Sep 5 15:32:09 2008
@@ -150,6 +150,15 @@
#region AbstractPlaylist overrides
+ protected override void AfterInitialized ()
+ {
+ base.AfterInitialized ();
+ if (PrimarySource != null) {
+ PrimarySource.TracksChanged += HandleTracksChanged;
+ PrimarySource.TracksDeleted += HandleTracksDeleted;
+ }
+ }
+
protected override void Update ()
{
ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (
@@ -211,7 +220,7 @@
));
}
- Remove ();
+ ThreadAssist.ProxyToMain (Remove);
return true;
}
@@ -363,17 +372,6 @@
);
}
}
-
- public override void SetParentSource (Source parent)
- {
- base.SetParentSource (parent);
-
- PrimarySource primary = parent as PrimarySource;
- if (primary != null) {
- primary.TracksChanged += HandleTracksChanged;
- primary.TracksDeleted += HandleTracksDeleted;
- }
- }
private static int GetPlaylistId (string name)
{
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs Fri Sep 5 15:32:09 2008
@@ -275,6 +275,17 @@
#region AbstractPlaylist overrides
+ protected override void AfterInitialized ()
+ {
+ base.AfterInitialized ();
+
+ if (PrimarySource != null) {
+ PrimarySource.TracksAdded += HandleTracksAdded;
+ PrimarySource.TracksChanged += HandleTracksChanged;
+ PrimarySource.TracksDeleted += HandleTracksDeleted;
+ }
+ }
+
protected override void Create ()
{
DbId = ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
@@ -410,7 +421,7 @@
));
}
- Remove ();
+ ThreadAssist.ProxyToMain (Remove);
return true;
}
@@ -466,13 +477,6 @@
public override void SetParentSource (Source parent)
{
base.SetParentSource (parent);
-
- PrimarySource primary = parent as PrimarySource;
- if (primary != null) {
- primary.TracksAdded += HandleTracksAdded;
- primary.TracksChanged += HandleTracksChanged;
- primary.TracksDeleted += HandleTracksDeleted;
- }
}
#endregion
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs Fri Sep 5 15:32:09 2008
@@ -79,6 +79,13 @@
{
}
+ public void UpdateCounts ()
+ {
+ DatabaseTrackModel.UpdateUnfilteredAggregates ();
+ ever_counted = true;
+ OnUpdated ();
+ }
+
public abstract void Save ();
protected override void Initialize ()
@@ -133,6 +140,12 @@
reload_limiter = new RateLimiter (RateLimitedReload);
}
+ protected virtual void AfterInitialized ()
+ {
+ DatabaseTrackModel.Initialize (TrackCache);
+ OnSetupComplete ();
+ }
+
protected virtual void InitializeTrackModel ()
{
}
@@ -189,7 +202,7 @@
#region Public Properties
public override int Count {
- get { return ever_reloaded ? DatabaseTrackModel.UnfilteredCount : SavedCount; }
+ get { return ever_counted ? DatabaseTrackModel.UnfilteredCount : SavedCount; }
}
public override int FilteredCount {
@@ -347,7 +360,7 @@
public virtual void Reload ()
{
- ever_reloaded = true;
+ ever_counted = ever_reloaded = true;
reload_limiter.Execute ();
}
@@ -551,13 +564,7 @@
}
}
- protected virtual void AfterInitialized ()
- {
- DatabaseTrackModel.Initialize (TrackCache);
- OnSetupComplete ();
- }
-
- private bool ever_reloaded = false;
+ private bool ever_reloaded = false, ever_counted = false;
public override void Activate ()
{
if (!ever_reloaded)
Modified: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs Fri Sep 5 15:32:09 2008
@@ -37,10 +37,12 @@
using Hyena;
using Banshee.Base;
using Banshee.ServiceStack;
+using Banshee.Sources;
using Banshee.Dap;
using Banshee.Hardware;
using Banshee.Collection.Database;
using Banshee.Library;
+using Banshee.Playlist;
using Banshee.Dap.Gui;
@@ -101,7 +103,7 @@
public override void Dispose ()
{
- ThreadAssist.ProxyToMain (delegate { DestroyUnsupportedView (); });
+ ThreadAssist.ProxyToMain (DestroyUnsupportedView);
CancelSyncThread ();
base.Dispose ();
}
@@ -208,6 +210,24 @@
Log.Exception (e);
}
}
+
+ string insert_sql = @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
+ 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.DbId);
+ pl_src.Save ();
+ // We use the IPod.Track.Id here b/c we just shoved it into ExternalID above when we loaded
+ // the tracks, however when we sync, the Track.Id values may/will change.
+ foreach (IPod.Track track in playlist.Tracks) {
+ ServiceManager.DbConnection.Execute (insert_sql, pl_src.DbId, this.DbId, track.Id);
+ }
+ pl_src.UpdateCounts ();
+ AddChildSource (pl_src);
+ }
}
/*else {
@@ -413,6 +433,11 @@
}
}
+ public override void SyncPlaylists ()
+ {
+ QueueSync ();
+ }
+
private void QueueSync ()
{
lock (sync_timeout_mutex) {
@@ -489,10 +514,13 @@
try {
track.CommitToIpod (ipod_device);
+ tracks_map[track.TrackId] = track;
} catch (Exception e) {
Log.Exception ("Cannot save track to iPod", e);
}
}
+
+ // TODO sync updated metadata to changed tracks
while (tracks_to_remove.Count > 0) {
IpodTrackInfo track = null;
@@ -511,7 +539,40 @@
} catch (Exception e) {
Log.Exception ("Cannot remove track from iPod", e);
}
- }
+ }
+
+ // 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) {
+ ipod_device.TrackDatabase.RemovePlaylist (playlist);
+ }
+ }
+ device_playlists.Clear ();
+
+ // Add playlists from Banshee to the device
+ foreach (Source child in Children) {
+ PlaylistSource from = child as PlaylistSource;
+ if (from != null && from.Count > 0) {
+ IPod.Playlist playlist = ipod_device.TrackDatabase.CreatePlaylist (from.Name);
+ foreach (int track_id in ServiceManager.DbConnection.QueryEnumerable<int> (String.Format (
+ "SELECT CoreTracks.TrackID FROM CoreTracks{0} WHERE {1}",
+ from.DatabaseTrackModel.JoinFragment, from.DatabaseTrackModel.Condition)))
+ {
+ playlist.AddTrack (tracks_map[track_id].IpodTrack);
+ }
+ }
+ }
+
+ // 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;
@@ -526,6 +587,19 @@
ipod_device.TrackDatabase.SaveProgressChanged -= OnIpodDatabaseSaveProgressChanged;
}
}
+
+ /*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;
Modified: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs Fri Sep 5 15:32:09 2008
@@ -62,20 +62,32 @@
this.track = ((IpodTrackInfo)track).IpodTrack;
LoadFromIpodTrack ();
} else {
- Uri = track.Uri;
+ AlbumArtist = track.AlbumArtist;
AlbumTitle = track.AlbumTitle;
ArtistName = track.ArtistName;
- TrackTitle = track.TrackTitle;
- Genre = track.Genre;
+ BitRate = track.BitRate;
+ Bpm = track.Bpm;
+ Comment = track.Comment;
+ Composer = track.Composer;
+ Conductor = track.Conductor;
+ Copyright = track.Copyright;
+ DateAdded = track.DateAdded;
+ DiscCount = track.DiscCount;
+ DiscNumber = track.DiscNumber;
Duration = track.Duration;
- rating = track.Rating;
- PlayCount = track.PlayCount;
+ FileSize = track.FileSize;
+ Genre = track.Genre;
+ Grouping = track.Grouping;
+ IsCompilation = track.IsCompilation ;
LastPlayed = track.LastPlayed;
- DateAdded = track.DateAdded;
+ LastSkipped = track.LastSkipped;
+ PlayCount = track.PlayCount;
+ ReleaseDate = track.ReleaseDate;
+ SkipCount = track.SkipCount;
TrackCount = track.TrackCount;
TrackNumber = track.TrackNumber;
+ TrackTitle = track.TrackTitle;
Year = track.Year;
- FileSize = track.FileSize;
MediaAttributes = track.MediaAttributes;
}
@@ -90,21 +102,31 @@
Uri = null;
}
+ ExternalId = track.Id;
ipod_id = (int)track.Id;
+ AlbumArtist = track.AlbumArtist;
+ AlbumTitle = String.IsNullOrEmpty (track.Album) ? null : track.Album;
+ ArtistName = String.IsNullOrEmpty (track.Artist) ? null : track.Artist;
+ BitRate = track.BitRate;
+ Bpm = (int)track.BPM;
+ Comment = track.Comment;
+ Composer = track.Composer;
+ DateAdded = track.DateAdded;
+ DiscCount = track.TotalDiscs;
+ DiscNumber = track.DiscNumber;
Duration = track.Duration;
- PlayCount = track.PlayCount;
+ FileSize = track.Size;
+ Genre = String.IsNullOrEmpty (track.Genre) ? null : track.Genre;
+ Grouping = track.Grouping;
+ IsCompilation = track.IsCompilation;
LastPlayed = track.LastPlayed;
- DateAdded = track.DateAdded;
+ PlayCount = track.PlayCount;
TrackCount = track.TotalTracks;
TrackNumber = track.TrackNumber;
- Year = track.Year;
- FileSize = track.Size;
-
- AlbumTitle = String.IsNullOrEmpty (track.Album) ? null : track.Album;
- ArtistName = String.IsNullOrEmpty (track.Artist) ? null : track.Artist;
TrackTitle = String.IsNullOrEmpty (track.Title) ? null : track.Title;
- Genre = String.IsNullOrEmpty (track.Genre) ? null : track.Genre;
+ //ReleaseDate = track.DateReleased;
+ Year = track.Year;
switch (track.Rating) {
case IPod.TrackRating.One: rating = 1; break;
@@ -154,7 +176,8 @@
public void CommitToIpod (IPod.Device device)
{
- IPod.Track track = device.TrackDatabase.CreateTrack ();
+ track = track ?? device.TrackDatabase.CreateTrack ();
+ ExternalId = track.Id;
try {
track.Uri = new Uri (Uri.AbsoluteUri);
@@ -163,29 +186,29 @@
device.TrackDatabase.RemoveTrack (track);
}
+ track.AlbumArtist = AlbumArtist;
+ track.BitRate = BitRate;
+ track.BPM = (short)Bpm;
+ track.Comment = Comment;
+ track.Composer = Composer;
+ track.DateAdded = DateAdded;
+ track.TotalDiscs = DiscCount;
+ track.DiscNumber = DiscNumber;
track.Duration = Duration;
- track.PlayCount = PlayCount;
+ track.Size = (int)FileSize;
+ track.Grouping = Grouping;
+ track.IsCompilation = IsCompilation;
track.LastPlayed = LastPlayed;
- track.DateAdded = DateAdded;
+ track.PlayCount = PlayCount;
track.TotalTracks = TrackCount;
track.TrackNumber = TrackNumber;
track.Year = Year;
+ //track.DateReleased = ReleaseDate;
- if (!String.IsNullOrEmpty (AlbumTitle)) {
- track.Album = AlbumTitle;
- }
-
- if (!String.IsNullOrEmpty (ArtistName)) {
- track.Artist = ArtistName;
- }
-
- if (!String.IsNullOrEmpty (TrackTitle)) {
- track.Title = TrackTitle;
- }
-
- if (!String.IsNullOrEmpty (Genre)) {
- track.Genre = Genre;
- }
+ track.Album = AlbumTitle;
+ track.Artist = ArtistName;
+ track.Title = TrackTitle;
+ track.Genre = Genre;
switch (Rating) {
case 1: track.Rating = IPod.TrackRating.Zero; break;
@@ -195,25 +218,32 @@
case 5: track.Rating = IPod.TrackRating.Five; break;
default: track.Rating = IPod.TrackRating.Zero; break;
}
+
+ if (HasAttribute (TrackMediaAttributes.Podcast)) {
+ //track.Description = ..
+ //track.Category = ..
+ //track.RememberPosition = true;
+ //track.NotPlayedMark = track.PlayCount == 0;
+ }
- if ((MediaAttributes & TrackMediaAttributes.VideoStream) != 0) {
- if ((MediaAttributes & TrackMediaAttributes.Music) != 0) {
- track.Type = IPod.MediaType.MusicVideo;
- } else if ((MediaAttributes & TrackMediaAttributes.Podcast) != 0) {
+ if (HasAttribute (TrackMediaAttributes.VideoStream)) {
+ if (HasAttribute (TrackMediaAttributes.Podcast)) {
track.Type = IPod.MediaType.VideoPodcast;
- } else if ((MediaAttributes & TrackMediaAttributes.Movie) != 0) {
+ } else if (HasAttribute (TrackMediaAttributes.Music)) {
+ track.Type = IPod.MediaType.MusicVideo;
+ } else if (HasAttribute (TrackMediaAttributes.Movie)) {
track.Type = IPod.MediaType.Movie;
- } else if ((MediaAttributes & TrackMediaAttributes.TvShow) != 0) {
+ } else if (HasAttribute (TrackMediaAttributes.TvShow)) {
track.Type = IPod.MediaType.TVShow;
} else {
track.Type = IPod.MediaType.Video;
}
} else {
- if ((MediaAttributes & TrackMediaAttributes.Podcast) != 0) {
+ if (HasAttribute (TrackMediaAttributes.Podcast)) {
track.Type = IPod.MediaType.Podcast;
- } else if ((MediaAttributes & TrackMediaAttributes.AudioBook) != 0) {
+ } else if (HasAttribute (TrackMediaAttributes.AudioBook)) {
track.Type = IPod.MediaType.Audiobook;
- } else if ((MediaAttributes & TrackMediaAttributes.Music) != 0) {
+ } else if (HasAttribute (TrackMediaAttributes.Music)) {
track.Type = IPod.MediaType.Audio;
} else {
track.Type = IPod.MediaType.Audio;
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs Fri Sep 5 15:32:09 2008
@@ -75,26 +75,19 @@
#endregion
- private string [] SyncPlaylistIds {
+ public string [] SyncPlaylistIds {
get { return playlist_ids.Get (); }
}
- List<AbstractPlaylistSource> sync_playlists;
- private IList<AbstractPlaylistSource> SyncPlaylists {
- get {
- if (sync_playlists == null) {
- sync_playlists = new List<AbstractPlaylistSource> ();
- foreach (string id in SyncPlaylistIds) {
- foreach (Source src in library.Children) {
- if (src.UniqueId == id) {
- sync_playlists.Add (src as AbstractPlaylistSource);
- break;
- }
- }
- }
+ private IList<AbstractPlaylistSource> GetSyncPlaylists ()
+ {
+ List<AbstractPlaylistSource> playlists = new List<AbstractPlaylistSource> ();
+ foreach (Source child in library.Children) {
+ if (child is AbstractPlaylistSource) {
+ playlists.Add (child as AbstractPlaylistSource);
}
- return sync_playlists;
}
+ return playlists;
}
internal string SmartPlaylistId {
@@ -175,7 +168,7 @@
{
if (SyncEntireLibrary) {
sync_src.ConditionTree = null;
- } else if (SyncPlaylistIds.Length > 0) {
+ }/* else if (SyncPlaylistIds.Length > 0) {
QueryListNode playlists_node = new QueryListNode (Keyword.Or);
foreach (AbstractPlaylistSource src in SyncPlaylists) {
if (src is PlaylistSource) {
@@ -185,7 +178,7 @@
}
}
sync_src.ConditionTree = playlists_node;
- }
+ }*/
sync_src.RefreshAndReload ();
to_add.RefreshAndReload ();
to_remove.RefreshAndReload ();
@@ -211,41 +204,32 @@
sync.Dap.AddAllTracks (to_add);
}
- CalculateSync ();
- sync.OnUpdated ();
- }
- //sync.Dap.AddAllTracks (to_add);
+ if (library.SupportsPlaylists) {
+ sync.Dap.RemovePlaylists ();
- // Sync Playlists
- /*
- // Remove all playlists
- foreach (Source child in sync.Dap.Children) {
- if (child is AbstractPlaylistSource && !(child is MediaGroupSource)) {
- (child as IUnmapableSource).Unmap ();
+ // Then create the playlists, taking snapshots of smart playlists and saving them
+ // as normal playlists
+ IList<AbstractPlaylistSource> playlists = GetSyncPlaylists ();
+ foreach (AbstractPlaylistSource from in playlists) {
+ PlaylistSource to = new PlaylistSource (from.Name, sync.Dap.DbId);
+ to.Save ();
+
+ ServiceManager.DbConnection.Execute (
+ String.Format (
+ @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
+ SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND MetadataHash IN (
+ SELECT MetadataHash FROM CoreTracks{0} WHERE {1})",
+ from.DatabaseTrackModel.JoinFragment, from.DatabaseTrackModel.Condition),
+ to.DbId, sync.Dap.DbId
+ );
+ to.DatabaseTrackModel.UpdateUnfilteredAggregates ();
+ sync.Dap.AddChildSource (to);
+ }
}
- }
-
- if (!SyncEntireLibrary && SyncPlaylistIds.Length == 0) {
- return;
- }
- foreach (AbstractPlaylistSource src in SyncPlaylists) {
- SyncPlaylist (src);
- }*/
+ CalculateSync ();
+ sync.OnUpdated ();
+ }
}
-
- /*private void SyncPlaylist (AbstractPlaylistSource from)
- {
- PlaylistSource to = new PlaylistSource (from.Name, sync.Dap.DbId);
- to.Save ();
-
- ServiceManager.DbConnection.Execute (
- @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
- SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND MetadataHash IN (
- SELECT t.MetadataHash FROM CoreTracks t, CorePlaylistEntries e
- WHERE t.TrackID = e.TrackID AND e.PlaylistID = ?)",
- to.DbId, sync.Dap.DbId, from.DbId
- );
- }*/
}
}
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs Fri Sep 5 15:32:09 2008
@@ -39,6 +39,7 @@
using Banshee.ServiceStack;
using Banshee.Sources;
using Banshee.Collection;
+using Banshee.Playlist;
using Banshee.Collection.Database;
using Banshee.Hardware;
using Banshee.MediaEngine;
@@ -94,7 +95,7 @@
public override void Dispose ()
{
- PurgeBuiltinSmartPlaylists ();
+ PurgeTemporaryPlaylists ();
PurgeTracks ();
if (dap_info_bar != null) {
@@ -109,7 +110,7 @@
dap_properties_display = null;*/
}
- private void PurgeBuiltinSmartPlaylists ()
+ private void PurgeTemporaryPlaylists ()
{
ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
BEGIN TRANSACTION;
@@ -119,6 +120,15 @@
COMMIT TRANSACTION",
DbId, DbId
));
+
+ ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
+ BEGIN TRANSACTION;
+ DELETE FROM CorePlaylistEntries WHERE PlaylistID IN
+ (SELECT PlaylistID FROM CorePlaylists WHERE PrimarySourceID = ?);
+ DELETE FROM CorePlaylists WHERE PrimarySourceID = ?;
+ COMMIT TRANSACTION",
+ DbId, DbId
+ ));
}
internal void RaiseUpdated ()
@@ -126,11 +136,15 @@
OnUpdated ();
}
+ public virtual void SyncPlaylists ()
+ {
+ }
+
#region Source
protected override void Initialize ()
{
- PurgeBuiltinSmartPlaylists ();
+ PurgeTemporaryPlaylists ();
base.Initialize ();
@@ -192,14 +206,14 @@
}
}
- public override void AddChildSource (Source child)
+ /*public override void AddChildSource (Source child)
{
if (child is Banshee.Playlist.AbstractPlaylistSource && !(child is MediaGroupSource)) {
Log.Information ("Note: playlists added to digital audio players within Banshee are not yet saved to the device.", true);
}
base.AddChildSource (child);
- }
+ }*/
// Force to zero so that count doesn't show up
public override int Count {
@@ -253,6 +267,17 @@
}
}
+ public void RemovePlaylists ()
+ {
+ // First remove any playlists on the device
+ List<Source> children = new List<Source> (sync.Dap.Children);
+ foreach (Source child in children) {
+ if (child is AbstractPlaylistSource && !(child is MediaGroupSource)) {
+ (child as IUnmapableSource).Unmap ();
+ }
+ }
+ }
+
protected virtual void LoadFromDevice ()
{
}
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs Fri Sep 5 15:32:09 2008
@@ -257,6 +257,7 @@
foreach (DapLibrarySync library_sync in library_syncs) {
library_sync.Sync ();
}
+ dap.SyncPlaylists ();
}
}
}
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs Fri Sep 5 15:32:09 2008
@@ -74,7 +74,7 @@
: GetSort (SortColumn.SortKey, SortColumn.SortType == Hyena.Data.SortType.Ascending);
}
- protected override void UpdateUnfilteredAggregates ()
+ public override void UpdateUnfilteredAggregates ()
{
HyenaSqliteCommand count_command = new HyenaSqliteCommand (String.Format (
"SELECT COUNT(*) {0} AND PodcastItems.IsRead = 0", UnfilteredQuery
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]