banshee r4896 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Streaming src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue



Author: gburt
Date: Fri Jan  9 19:22:15 2009
New Revision: 4896
URL: http://svn.gnome.org/viewvc/banshee?rev=4896&view=rev

Log:
2009-01-09  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs:
	If passed a playlist file from /tmp, try to load/play it as a radio
	station (BNC #456120).  Also, clear/delete playlists when Cleared.

	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs: Avoid
	bug where duplicate playlists were created.

	* src/Core/Banshee.Core/Banshee.Base/Paths.cs: Add SystemTempDir property.



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Streaming/RadioTrackInfo.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
   trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs	Fri Jan  9 19:22:15 2009
@@ -165,6 +165,10 @@
         public static string DefaultLibraryPath {
             get { return XdgBaseDirectorySpec.GetUserDirectory ("XDG_MUSIC_DIR", "Music"); }
         }
+
+        public static string SystemTempDir {
+            get { return "/tmp/"; }
+        }
         
         public static string TempDir {
             get {

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	Fri Jan  9 19:22:15 2009
@@ -214,6 +214,7 @@
         
         private PrimarySource source;
         private DatabaseImportManager importer;
+        private bool finished;
         
         public ImportPlaylistWorker (string name, string [] uris, PrimarySource source, DatabaseImportManager importer)
         {
@@ -229,6 +230,7 @@
                 if (importer == null) {
                     importer = new Banshee.Library.LibraryImportManager ();
                 }
+                finished = false;
                 importer.Finished += CreatePlaylist;
                 importer.Enqueue (uris);
             } catch (PlaylistImportCanceledException e) {
@@ -238,6 +240,12 @@
         
         private void CreatePlaylist (object o, EventArgs args)
         {
+            if (finished) {
+                return;
+            }
+
+            finished = true;
+
             try {
                 PlaylistSource playlist = new PlaylistSource (name, source);
                 playlist.Save ();

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Streaming/RadioTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Streaming/RadioTrackInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Streaming/RadioTrackInfo.cs	Fri Jan  9 19:22:15 2009
@@ -29,6 +29,7 @@
 using System;
 using System.Threading;
 using System.Collections.Generic;
+using Mono.Unix;
 
 using Hyena;
 using Media.Playlists.Xspf;
@@ -42,6 +43,55 @@
 {   
     public class RadioTrackInfo : TrackInfo
     {
+    
+#region Static Helper Methods
+
+        public static RadioTrackInfo OpenPlay (string uri)
+        {
+            try {
+                return OpenPlay (new SafeUri (uri));
+            } catch (Exception e) {
+                Hyena.Log.Exception (e);
+                return null;
+            }
+        }
+        
+        public static RadioTrackInfo OpenPlay (SafeUri uri)
+        {
+            RadioTrackInfo track = Open (uri);
+            if (track != null) {
+                track.Play ();
+            }
+            return track;
+        }
+    
+        public static RadioTrackInfo Open (string uri)
+        {
+            return Open (new SafeUri (uri));
+        }
+    
+        public static RadioTrackInfo Open (SafeUri uri)
+        {
+            try {
+                RadioTrackInfo radio_track = new RadioTrackInfo (uri);
+                radio_track.ParsingPlaylistEvent += delegate {
+                    if (radio_track.PlaybackError != StreamPlaybackError.None) {
+                        Log.Error (Catalog.GetString ("Error opening stream"), 
+                            Catalog.GetString ("Could not open stream or playlist"), true);
+                        radio_track = null;
+                    }
+                };
+                
+                return radio_track;
+            } catch {
+                Log.Error (Catalog.GetString ("Error opening stream"), 
+                    Catalog.GetString("Problem parsing playlist"), true);
+                return null;
+            }
+        }
+
+#endregion
+        
         private Track track;
         private SafeUri single_location;
         private List<SafeUri> stream_uris = new List<SafeUri>();

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs	Fri Jan  9 19:22:15 2009
@@ -151,23 +151,8 @@
             string address = dialog.Address;
             dialog.Destroy ();
             
-            if(response != ResponseType.Ok) {
-                return;
-            }
-            
-            try {
-                RadioTrackInfo radio_track = new RadioTrackInfo (new SafeUri (address));
-                radio_track.ParsingPlaylistEvent += delegate {
-                    if (radio_track.PlaybackError != StreamPlaybackError.None) {
-                        Log.Error (Catalog.GetString ("Error opening stream"), 
-                            Catalog.GetString ("Could not open stream or playlist"), true);
-                        radio_track = null;
-                    }
-                };
-                radio_track.Play ();
-            } catch {
-                Log.Error (Catalog.GetString ("Error opening stream"), 
-                    Catalog.GetString("Problem parsing playlist"), true);
+            if (response == ResponseType.Ok) {
+                RadioTrackInfo.OpenPlay (address);
             }
         }
 

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	Fri Jan  9 19:22:15 2009
@@ -141,7 +141,12 @@
             
                 if (PlaylistFileUtil.PathHasPlaylistExtension (path)) {
                     Banshee.Kernel.Scheduler.Schedule (new DelegateJob (delegate {
-                        PlaylistFileUtil.ImportPlaylistToLibrary (path, this, importer);
+                        // If it's in /tmp it probably came from Firefox - just play it
+                        if (path.StartsWith (Paths.SystemTempDir)) {
+                            Banshee.Streaming.RadioTrackInfo.OpenPlay (path);
+                        } else {
+                            PlaylistFileUtil.ImportPlaylistToLibrary (path, this, importer);
+                        }
                     }));
                 } else {
                     importer.Enqueue (path);
@@ -238,6 +243,15 @@
         
         private void OnClearFileSystemQueue (object o, EventArgs args)
         {
+            // Delete any child playlists
+            ClearChildSources ();
+            ServiceManager.DbConnection.Execute (@"
+                DELETE FROM CorePlaylistEntries WHERE PlaylistID IN
+                    (SELECT PlaylistID FROM CorePlaylists WHERE PrimarySourceID = ?);
+                DELETE FROM CorePlaylists WHERE PrimarySourceID = ?;",
+                this.DbId, this.DbId
+            );
+
             RemoveTrackRange ((DatabaseTrackListModel)TrackModel, new Hyena.Collections.RangeCollection.Range (0, Count));
             Reload ();
         }



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