[banshee] [Dap.AppleDevice] Update metadata in Manual Sync mode (bgo#589196)
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Dap.AppleDevice] Update metadata in Manual Sync mode (bgo#589196)
- Date: Sun, 19 Sep 2010 13:41:06 +0000 (UTC)
commit 48a23c092d5472126915e146c4364d2106791c20
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Sun Sep 19 15:24:40 2010 +0200
[Dap.AppleDevice] Update metadata in Manual Sync mode (bgo#589196)
This patch basically takes care of implementing the UpdateMetadata()
call exposed virtually by PrimarySource to make the changes belong
to the PerformSync operation, and overrides HasEditableTrackProperties
to true for the SaveTrackMetadaService to be able to hook on the
source to flush changes to files (these changes wouldn't maybe
actually be visible by the AppleDevice but it's still good to flush
them to maintain them in sync with what is in the device's database,
just in case some user copies/imports files from the device).
Thanks goes to Alex Launi <alex launi gmail com> for testing and
fixing the compilation of this patch.
.../Banshee.Dap.AppleDevice/AppleDeviceSource.cs | 50 +++++++++++++++++++-
.../AppleDeviceTrackInfo.cs | 13 ++++-
2 files changed, 59 insertions(+), 4 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
index 815d340..a4bff3d 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
@@ -36,6 +36,7 @@ using System.Threading;
using Banshee.Hardware;
using Banshee.Sources;
using Banshee.I18n;
+using Hyena.Query;
using Hyena;
namespace Banshee.Dap.AppleDevice
@@ -317,6 +318,27 @@ namespace Banshee.Dap.AppleDevice
#region Syncing
+ public override void UpdateMetadata (DatabaseTrackInfo track)
+ {
+ lock (sync_mutex) {
+ AppleDeviceTrackInfo ipod_track;
+ if (!tracks_map.TryGetValue (track.TrackId, out ipod_track)) {
+ return;
+ }
+
+ ipod_track.UpdateInfo (track);
+ tracks_to_update.Enqueue (ipod_track);
+ }
+ }
+
+ protected override void OnTracksChanged (params QueryField[] fields)
+ {
+ if (tracks_to_update.Count > 0 && !Sync.Syncing) {
+ QueueSync ();
+ }
+ base.OnTracksChanged (fields);
+ }
+
protected override void OnTracksAdded ()
{
if (!IsAdding && tracks_to_add.Count > 0 && !Sync.Syncing) {
@@ -334,6 +356,7 @@ namespace Banshee.Dap.AppleDevice
}
private Queue<AppleDeviceTrackInfo> tracks_to_add = new Queue<AppleDeviceTrackInfo> ();
+ private Queue<AppleDeviceTrackInfo> tracks_to_update = new Queue<AppleDeviceTrackInfo> ();
private Queue<AppleDeviceTrackInfo> tracks_to_remove = new Queue<AppleDeviceTrackInfo> ();
private uint sync_timeout_id = 0;
@@ -520,7 +543,19 @@ namespace Banshee.Dap.AppleDevice
OnUserNotifyUpdated ();
}
- // TODO sync updated metadata to changed tracks
+ while (tracks_to_update.Count > 0) {
+ AppleDeviceTrackInfo track = null;
+ lock (sync_mutex) {
+ track = tracks_to_update.Dequeue ();
+ }
+
+ try {
+ track.CommitToIpod (MediaDatabase);
+ } catch (Exception e) {
+ Log.Exception ("Cannot save track to iPod", e);
+ }
+ }
+
message = Catalog.GetString ("Removing track {0} of {1}");
total = tracks_to_remove.Count;
while (tracks_to_remove.Count > 0) {
@@ -592,10 +627,21 @@ namespace Banshee.Dap.AppleDevice
public bool SyncNeeded {
get {
lock (sync_mutex) {
- return tracks_to_add.Count > 0 || tracks_to_remove.Count > 0;
+ return tracks_to_add.Count > 0 ||
+ tracks_to_update.Count > 0 ||
+ tracks_to_remove.Count > 0;
}
}
}
+
+ public override bool HasEditableTrackProperties {
+ get {
+ // we want child sources to be able to edit metadata and the
+ // savetrackmetadataservice to take in account this source
+ return true;
+ }
+ }
+
#endregion
}
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs
index d4c6836..9cd72e9 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs
@@ -53,10 +53,19 @@ namespace Banshee.Dap.AppleDevice
public AppleDeviceTrackInfo (TrackInfo track)
{
+ CanSaveToDatabase = true;
+
if (track is AppleDeviceTrackInfo) {
IpodTrack = ((AppleDeviceTrackInfo)track).IpodTrack;
LoadFromIpodTrack ();
} else {
+ UpdateInfo (track);
+ }
+ }
+
+ public void UpdateInfo (TrackInfo track)
+ {
+ if (!(track is AppleDeviceTrackInfo)) {
IsCompilation = track.IsCompilation ;
AlbumArtist = track.AlbumArtist;
AlbumTitle = track.AlbumTitle;
@@ -92,9 +101,9 @@ namespace Banshee.Dap.AppleDevice
//description = podcast_info.Description;
ReleaseDate = podcast_info.ReleaseDate;
}
+ } else {
+ throw new ArgumentException ("Shouldn't update an AppleDeviceTrackInfo from an AppleDeviceTrackInfo");
}
-
- CanSaveToDatabase = true;
}
private void LoadFromIpodTrack ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]