banshee r4028 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.MediaEngine src/Core/Banshee.Services/Banshee.Sources src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4028 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.MediaEngine src/Core/Banshee.Services/Banshee.Sources src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue
- Date: Thu, 29 May 2008 22:23:17 +0000 (UTC)
Author: gburt
Date: Thu May 29 22:23:16 2008
New Revision: 4028
URL: http://svn.gnome.org/viewvc/banshee?rev=4028&view=rev
Log:
2008-05-29 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs: Add a bool
IsLocal property. If it's false and you drag tracks to a LibrarySource,
it will ask the owning PrimarySource to copy the file to a given location
by calling its CopyTrackTo method defined here (and implemented in each
non-local subclass).
* src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs:
Reload the FSQ on start to make sure it shows itself if it had saved
items. Also, set IsLocal = true so dragging files between the libraries
and it doesn't do a file copy.
* src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs:
Fix bug with importing to the Library not just from the audio folders.
Implement CopyTrackTo.
* src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs: Add commented
out CopyTrackTo skeleton.
* src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs: Implement
CopyToTrack - the nicest implementation in a way, because we get granular
progress updates.
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs:
Add some NRE defense and debugging for a NRE I saw but don't understand.
* src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs:
Set IsLocal = true, and fix up AddTrack method so that if the file is from
a IsLocal PrimarySource it just 'moves' it (eg changes the
PrimarySourceId) but otherwise it asks the owning PrimarySource to copy
the file to a location in the library folder.
* src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs: Set
the updatd MimeType on the file after transcoding it.
* src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs: Add a BuildFull
convenience overload.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs Thu May 29 22:23:16 2008
@@ -231,6 +231,11 @@
return OnFilter (repl_pattern);
}
+ public static string BuildFull (TrackInfo track)
+ {
+ return BuildFull (track, Path.GetExtension (track.Uri.ToString ()));
+ }
+
public static string BuildFull (ITrackInfo track, string ext)
{
if (ext == null || ext.Length < 1) {
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 Thu May 29 22:23:16 2008
@@ -165,8 +165,12 @@
public void InvalidateCache ()
{
- cache.ClearManagedCache ();
- OnReloaded ();
+ if (cache == null) {
+ Log.ErrorFormat ("Called invalidate cache for {0}'s track model, but cache is null", source);
+ } else {
+ cache.ClearManagedCache ();
+ OnReloaded ();
+ }
}
private string unfiltered_query;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs Thu May 29 22:23:16 2008
@@ -50,6 +50,7 @@
{
Properties.SetString ("GtkActionPath", "/LibraryContextMenu");
Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Library"));
+ IsLocal = true;
AfterInitialized ();
}
@@ -57,6 +58,11 @@
get { return Paths.CachedLibraryLocation; }
}
+ /*public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, UserJob job)
+ {
+ Banshee.IO.File.Copy (track.Uri, uri, false);
+ }*/
+
protected override void DeleteTrack (DatabaseTrackInfo track)
{
try {
@@ -72,26 +78,32 @@
if (track.PrimarySourceId == DbId)
return;
- // Move it if its from another library source
- if (track.PrimarySource is LibrarySource) {
- PrimarySource old_primary = track.PrimarySource;
+ PrimarySource source = track.PrimarySource;
+
+ // If it's from a local primary source, change it's PrimarySource
+ if (source.IsLocal || source is LibrarySource) {
track.PrimarySource = this;
track.Save (false);
- old_primary.NotifyTracksChanged ();
- return;
- }
-
- // Otherwise, copy it
- if (track.PrimarySource is LibrarySource) {
- // queue in importer or something?
+ source.NotifyTracksChanged ();
+ } else {
+ // Figure out where we should put it if were to copy it
+ string path = FileNamePattern.BuildFull (track);
+ SafeUri uri = new SafeUri (path);
+
+ // Make sure it's not already in the library
+ if (DatabaseTrackInfo.ContainsUri (uri, Paths.MakePathRelative (uri.AbsolutePath, BaseDirectory) ?? uri.AbsoluteUri, new int [] {DbId})) {
+ return;
+ }
+
+ // Since it's not, copy it and create a new TrackInfo object
+ track.PrimarySource.CopyTrackTo (track, uri, AddTrackJob);
+
+ // Create a new entry in CoreTracks for the copied file
+ DatabaseTrackInfo new_track = new DatabaseTrackInfo (track);
+ new_track.Uri = uri;
+ new_track.PrimarySource = this;
+ new_track.Save (false);
}
-
- /*try {
- Banshee.IO.Utilities.DeleteFileTrimmingParentDirectories (track.Uri);
- } catch (System.IO.FileNotFoundException) {
- } catch (System.IO.DirectoryNotFoundException) {
- }*/
}
-
}
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs Thu May 29 22:23:16 2008
@@ -216,6 +216,7 @@
}
UserJob.Completed++;
+ args.Track.MimeType = current_context.Config.Profile.MimeTypes[0];
current_context.Handler (args.Track, current_context.OutUri);
ProcessQueue ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs Thu May 29 22:23:16 2008
@@ -127,6 +127,13 @@
}
}
+
+ private bool is_local = false;
+ public bool IsLocal {
+ get { return is_local; }
+ protected set { is_local = value; }
+ }
+
public delegate void TrackEventHandler (Source sender, TrackEventArgs args);
public event TrackEventHandler TracksAdded;
@@ -240,6 +247,11 @@
);
}
+ public virtual void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
+ {
+ throw new Exception (String.Format ("CopyToTrack not implemented for source {0}", Name));
+ }
+
internal void NotifyTracksAdded ()
{
OnTracksAdded ();
@@ -429,8 +441,9 @@
public override bool AcceptsInputFromSource (Source source)
{
- return base.AcceptsInputFromSource (source) && source.Parent != this &&
- (source.Parent is PrimarySource) && !(source.Parent is Banshee.Library.LibrarySource);
+ return base.AcceptsInputFromSource (source) && source.Parent != this
+ && (source.Parent is PrimarySource || source is PrimarySource)
+ && !(source.Parent is Banshee.Library.LibrarySource);
}
public override bool AddSelectedTracks (Source source)
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 Thu May 29 22:23:16 2008
@@ -74,7 +74,7 @@
Initialize ();
}
-
+
public override void Dispose ()
{
CancelSyncThread ();
@@ -328,6 +328,11 @@
Log.Information ("Import to Library is not implemented for iPods yet", true);
}
+ /*public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
+ {
+ throw new Exception ("Copy to Library is not implemented for iPods yet");
+ }*/
+
protected override void DeleteTrack (DatabaseTrackInfo track)
{
lock (sync_mutex) {
Modified: trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs Thu May 29 22:23:16 2008
@@ -117,14 +117,25 @@
DatabaseImportManager importer = new DatabaseImportManager (this);
importer.KeepUserJobHidden = true;
importer.Threaded = false; // We are already threaded
- foreach (string audio_folder in AudioFolders) {
+
+ foreach (string audio_folder in BaseDirectories) {
importer.QueueSource (audio_folder);
}
}
+ public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
+ {
+ if (track.PrimarySourceId == DbId) {
+ Banshee.IO.File.Copy (track.Uri, uri, false);
+ }
+ }
+
public override void Import ()
{
- new LibraryImportManager (true).QueueSource (BaseDirectory);
+ LibraryImportManager importer = new LibraryImportManager (true);
+ foreach (string audio_folder in BaseDirectories) {
+ importer.QueueSource (audio_folder);
+ }
}
public IVolume Volume {
@@ -178,7 +189,7 @@
// According to the HAL spec, the first folder listed in the audio_folders property
// is the folder to write files to.
if (AudioFolders.Length > 0) {
- write_path = System.IO.Path.Combine (write_path, AudioFolders[0]);
+ write_path = Banshee.Base.Paths.Combine (write_path, AudioFolders[0]);
}
}
return write_path;
@@ -191,13 +202,25 @@
protected string [] AudioFolders {
get {
if (audio_folders == null) {
- audio_folders = HasMediaCapabilities ? MediaCapabilities.AudioFolders : new string [] { BaseDirectory };
+ audio_folders = HasMediaCapabilities ? MediaCapabilities.AudioFolders : new string [] {};
}
return audio_folders;
}
set { audio_folders = value; }
}
+ protected IEnumerable<string> BaseDirectories {
+ get {
+ if (AudioFolders.Length == 0) {
+ yield return BaseDirectory;
+ } else {
+ foreach (string audio_folder in AudioFolders) {
+ yield return Paths.Combine (BaseDirectory, audio_folder);
+ }
+ }
+ }
+ }
+
private int folder_depth = -1;
protected int FolderDepth {
get {
Modified: trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs Thu May 29 22:23:16 2008
@@ -177,6 +177,18 @@
//new LibraryImportManager (true).QueueSource (BaseDirectory);
}
+ public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
+ {
+ if (track_map.ContainsKey (track.TrackId)) {
+ track_map[track.TrackId].Download (uri.LocalPath, delegate (ulong current, ulong total, IntPtr data) {
+ job.DetailedProgress = (double) current / total;
+ return 0;
+ });
+ } else {
+ throw new Exception ("Error copying track from MTP device");
+ }
+ }
+
public override bool CanRename {
get { return !(IsAdding || IsDeleting); }
}
Modified: trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs Thu May 29 22:23:16 2008
@@ -58,6 +58,7 @@
{
Properties.SetString ("Icon.Name", "system-file-manager");
Properties.Set<bool> ("AutoAddSource", false);
+ IsLocal = true;
importer = new DatabaseImportManager (this);
importer.KeepUserJobHidden = true;
@@ -90,12 +91,13 @@
UpdateActions ();
ServiceManager.SourceManager.ActiveSourceChanged += delegate { UpdateActions (); };
-
+ TrackModel.Reloaded += OnTrackModelReloaded;
+
+ Reload ();
+
foreach (string path in ApplicationContext.CommandLine.Files) {
Enqueue (path);
}
-
- TrackModel.Reloaded += OnTrackModelReloaded;
}
public void Enqueue (string path)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]