banshee r4597 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.PlayQueue src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue



Author: abock
Date: Tue Sep 23 20:53:02 2008
New Revision: 4597
URL: http://svn.gnome.org/viewvc/banshee?rev=4597&view=rev

Log:
2008-09-23  Aaron Bockover  <abock gnome org>

    * src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
    Implement IPlayQueue

    * src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/IPlayQueue.cs:
    Basic interface for adding files that are already in the library to the
    play queue

    * src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs: Implement
    IDBusExportable and automatically register and unregister sources on the
    bus that implement IDBusExportable as well



Added:
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/IPlayQueue.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs	Tue Sep 23 20:53:02 2008
@@ -49,7 +49,7 @@
         public int Position;
     }
     
-    public class SourceManager : /*ISourceManager,*/ IInitializeService, IRequiredService, IDisposable
+    public class SourceManager : /*ISourceManager,*/ IInitializeService, IRequiredService, IDBusExportable, IDisposable
     {
         private List<Source> sources = new List<Source>();
         private Dictionary<string, Source> extension_sources = new Dictionary<string, Source> ();
@@ -165,8 +165,11 @@
             } else if (source is VideoLibrarySource) {
                 video_library = source as VideoLibrarySource;
             }
-
-            // ServiceManager.DBusServiceManager.RegisterObject(source);
+            
+            IDBusExportable exportable = source as IDBusExportable;
+            if (exportable != null) {
+                ServiceManager.DBusServiceManager.RegisterObject (exportable);
+            }
             
             List<Source> children = new List<Source> (source.Children);
             foreach(Source child_source in children) {
@@ -202,6 +205,11 @@
             foreach(Source child_source in source.Children) {
                 RemoveSource (child_source, recursivelyDispose);
             }
+            
+            IDBusExportable exportable = source as IDBusExportable;
+            if (exportable != null) {
+                ServiceManager.DBusServiceManager.UnregisterObject (exportable);
+            }
 
             if (recursivelyDispose) {
                 IDisposable disposable = source as IDisposable;
@@ -348,11 +356,11 @@
         
         /*string [] ISourceManager.Sources {
             get { return DBusServiceManager.MakeObjectPathArray<Source>(sources); }
-        }
+        }*/
         
         IDBusExportable IDBusExportable.Parent {
             get { return null; }
-        }*/
+        }
         
         string Banshee.ServiceStack.IService.ServiceName {
             get { return "SourceManager"; }

Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj	(original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj	Tue Sep 23 20:53:02 2008
@@ -40,6 +40,7 @@
   <ItemGroup>
     <Compile Include="Banshee.PlayQueue\PlayQueueSource.cs" />
     <Compile Include="Banshee.PlayQueue\PlayQueueActions.cs" />
+    <Compile Include="Banshee.PlayQueue\IPlayQueue.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Resources\ActiveSourceUI.xml">

Added: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/IPlayQueue.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/IPlayQueue.cs	Tue Sep 23 20:53:02 2008
@@ -0,0 +1,39 @@
+//
+// IPlayQueue.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using NDesk.DBus;
+
+namespace Banshee.PlayQueue
+{
+    [Interface ("org.bansheeproject.Banshee.PlayQueue")]
+    public interface IPlayQueue
+    {
+        void EnqueueUri (string uri);
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	Tue Sep 23 20:53:02 2008
@@ -46,7 +46,7 @@
 
 namespace Banshee.PlayQueue
 {
-    public class PlayQueueSource : PlaylistSource, IBasicPlaybackController, IDisposable
+    public class PlayQueueSource : PlaylistSource, IBasicPlaybackController, IPlayQueue, IDBusExportable, IDisposable
     {
         private static string special_playlist_name = "Play Queue";//typeof (PlayQueueSource).ToString ();
 
@@ -102,6 +102,30 @@
             SetAsPlaybackSourceUnlessPlaying ();
         }
         
+#region IPlayQueue, IDBusExportable
+
+        public void EnqueueUri (string uri)
+        {
+            int track_id = LibrarySource.GetTrackIdForUri (uri);
+            if (track_id > 0) {
+                HyenaSqliteCommand insert_command = new HyenaSqliteCommand (String.Format (
+                    @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES ({0}, ?)", DbId));
+                ServiceManager.DbConnection.Execute (insert_command, track_id);
+                Reload ();
+                NotifyUser ();
+            }
+        }
+        
+        IDBusExportable IDBusExportable.Parent {
+            get { return ServiceManager.SourceManager; }
+        }
+        
+        string IService.ServiceName {
+            get { return "PlayQueue"; }
+        }
+
+#endregion
+        
         private void SetAsPlaybackSourceUnlessPlaying ()
         {
             if (Count > 0) {

Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am	Tue Sep 23 20:53:02 2008
@@ -4,6 +4,7 @@
 INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
 SOURCES =  \
+	Banshee.PlayQueue/IPlayQueue.cs \
 	Banshee.PlayQueue/PlayQueueActions.cs \
 	Banshee.PlayQueue/PlayQueueSource.cs 
 



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