banshee r4069 - in trunk/banshee: . data src/Backends/Banshee.Gnome src/Backends/Banshee.Gnome/Banshee.GnomeBackend src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Hardware src/Extensions/Banshee.AudioCd src/Extensions/Banshee.AudioCd/Banshee.AudioCd



Author: abock
Date: Mon Jun  2 20:02:43 2008
New Revision: 4069
URL: http://svn.gnome.org/viewvc/banshee?rev=4069&view=rev

Log:
2008-06-02  Aaron Bockover  <abock gnome org>

    * src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDuplicator.cs:
    Bootstrapper for locating and running an IDiscDuplicator extension

    * src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs:
    Implement disc duplication by calling into AudioCdDiscDuplicator if
    it is supported

    * src/Core/Banshee.Services/Banshee.Hardware/IDiscDuplicator.cs: Interface
    to expose disc duplication support

    * src/Core/Banshee.Services/Banshee.Services.addin.xml: Define a
    DiscDuplicator extension point

    * src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs:
    * src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs: Expose
    Brasero functionality internally

    * src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DiscDuplicator.cs:
    Implement an IDiscDuplicator that first tries to use Brasero and falls
    back to nautilus-cd-burner

    * src/Backends/Banshee.Gnome/Banshee.Gnome.addin.xml: Implement the
    DiscDuplicator extension point

    * data/banshee-1.desktop.in.in: Change the Name field to 'Banshee' to
    eliminate redundancy between Name and GenericNam



Added:
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DiscDuplicator.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDiscDuplicator.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDuplicator.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/data/banshee-1.desktop.in.in
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.addin.xml
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs
   trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
   trunk/banshee/src/Core/Banshee.Services/Makefile.am
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd.mdp
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Makefile.am

Modified: trunk/banshee/data/banshee-1.desktop.in.in
==============================================================================
--- trunk/banshee/data/banshee-1.desktop.in.in	(original)
+++ trunk/banshee/data/banshee-1.desktop.in.in	Mon Jun  2 20:02:43 2008
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Version=1.0
 Encoding=UTF-8
-_Name=Banshee Media Player
+_Name=Banshee
 _GenericName=Media Player
 Comment=Play and organize your media collection
 Exec=banshee-1 --play-enqueued --enqueue %U

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.addin.xml
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.addin.xml	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.addin.xml	Mon Jun  2 20:02:43 2008
@@ -21,4 +21,8 @@
     <ConfigurationClient class="Banshee.GnomeBackend.GConfConfigurationClient"/>
   </Extension>
 
+  <Extension path="/Banshee/Platform/DiscDuplicator">
+    <DiscDuplicator class="Banshee.GnomeBackend.DiscDuplicator"/>
+  </Extension>
+  
 </Addin>

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp	Mon Jun  2 20:02:43 2008
@@ -13,6 +13,7 @@
     <File name="Banshee.Gnome.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
     <File name="Banshee.GnomeBackend/Brasero.cs" subtype="Code" buildaction="Compile" />
     <File name="Resources/GlobalUI.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.GnomeBackend/DiscDuplicator.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs	Mon Jun  2 20:02:43 2008
@@ -97,9 +97,7 @@
             }
             
             try {
-                ProcessStartInfo psi = new ProcessStartInfo (brasero_exec, file_args.ToString ());
-                psi.UseShellExecute = false;
-                Process.Start (psi);
+                Run (file_args.ToString ());
             } catch (Exception e) {
                 Log.Exception ("Problem starting Brasero", e);
                 Log.Error (Catalog.GetString ("Could not write CD"), 
@@ -107,6 +105,13 @@
             }
         }
         
+        internal void Run (string args)
+        {
+            ProcessStartInfo psi = new ProcessStartInfo (brasero_exec, args);
+            psi.UseShellExecute = false;
+            Process.Start (psi);
+        }
+        
         private void UpdateActions ()
         {
             InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();

Added: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DiscDuplicator.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DiscDuplicator.cs	Mon Jun  2 20:02:43 2008
@@ -0,0 +1,78 @@
+//
+// GnomeService.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 Mono.Unix;
+
+using Hyena;
+using Banshee.ServiceStack;
+using Banshee.Hardware;
+
+namespace Banshee.GnomeBackend
+{
+    public class DiscDuplicator : IDiscDuplicator
+    {
+        public void Duplicate (IDiscVolume disc)
+        {
+            if (!RunBrasero (disc.DeviceNode) && !RunNcb (disc.DeviceNode)) {
+                throw new ApplicationException (Catalog.GetString (
+                    "Neither Brasero nor Nautilus CD Burner could be found to duplicate this disc."));
+            }
+        }
+        
+        private bool RunBrasero (string device)
+        {
+            GnomeService gnome = ServiceManager.Get<GnomeService> ();
+            if (gnome == null || gnome.Brasero == null) {
+                return false;
+            }
+            
+            try {
+                gnome.Brasero.Run (String.Format ("-c {0}", device));
+            } catch (Exception e) {
+                Log.Exception (e);
+                return false;
+            }
+            
+            return true;
+        }
+        
+        private bool RunNcb (string device)
+        {    
+            try {
+                System.Diagnostics.Process.Start ("nautilus-cd-burner", 
+                    String.Format ("--source-device={0}", device));
+            } catch (Exception e) {
+                Log.Exception (e);
+                return false;
+            }
+            
+            return false;
+        }
+    }
+}

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs	Mon Jun  2 20:02:43 2008
@@ -36,6 +36,9 @@
     public class GnomeService : IExtensionService, IDisposable 
     {
         private Brasero brasero;
+        internal Brasero Brasero {
+            get { return brasero; }
+        }
         
         public GnomeService ()
         {

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am	Mon Jun  2 20:02:43 2008
@@ -5,6 +5,7 @@
 
 SOURCES =  \
 	Banshee.GnomeBackend/Brasero.cs \
+	Banshee.GnomeBackend/DiscDuplicator.cs \
 	Banshee.GnomeBackend/GConfConfigurationClient.cs \
 	Banshee.GnomeBackend/GnomeService.cs
 

Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDiscDuplicator.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDiscDuplicator.cs	Mon Jun  2 20:02:43 2008
@@ -0,0 +1,37 @@
+//
+// IDiscDuplicator.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;
+
+namespace Banshee.Hardware
+{
+    public interface IDiscDuplicator
+    {
+        void Duplicate (IDiscVolume volume);
+    }
+}

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml	Mon Jun  2 20:02:43 2008
@@ -40,5 +40,9 @@
   <ExtensionPoint path="/Banshee/Platform/HardwareDeviceProvider">
     <ExtensionNode name="HardwareDeviceProvider"/>
   </ExtensionPoint>
+  
+  <ExtensionPoint path="/Banshee/Platform/DiscDuplicator">
+    <ExtensionNode name="DiscDuplicator"/>
+  </ExtensionPoint>
 
 </Addin>

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	Mon Jun  2 20:02:43 2008
@@ -172,6 +172,7 @@
     <File name="Banshee.ServiceStack/DBusConnection.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.ServiceStack/DBusCommandService.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.ServiceStack/IDBusObjectName.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Hardware/IDiscDuplicator.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am	Mon Jun  2 20:02:43 2008
@@ -45,6 +45,7 @@
 	Banshee.Hardware/ICustomDeviceProvider.cs \
 	Banshee.Hardware/IDevice.cs \
 	Banshee.Hardware/IDeviceMediaCapabilities.cs \
+	Banshee.Hardware/IDiscDuplicator.cs \
 	Banshee.Hardware/IDiscVolume.cs \
 	Banshee.Hardware/IDiskDevice.cs \
 	Banshee.Hardware/IHardwareManager.cs \

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd.mdp	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd.mdp	Mon Jun  2 20:02:43 2008
@@ -16,6 +16,7 @@
     <File name="Banshee.AudioCd/AudioCdRipper.cs" subtype="Code" buildaction="Compile" />
     <File name="Resources/ActiveSourceUI.xml" subtype="Code" buildaction="EmbedAsResource" />
     <File name="Resources/GlobalUI.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.AudioCd/AudioCdDuplicator.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />

Added: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDuplicator.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDuplicator.cs	Mon Jun  2 20:02:43 2008
@@ -0,0 +1,66 @@
+//
+// AudioCdDuplicator.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 Mono.Addins;
+
+using Banshee.Hardware;
+
+namespace Banshee.AudioCd
+{
+    public static class AudioCdDuplicator
+    {
+        private static bool duplicator_extension_queried = false;
+        private static TypeExtensionNode duplicator_extension_node = null;
+        
+        public static bool Supported {
+            get { 
+                if (duplicator_extension_queried) {
+                    return duplicator_extension_node != null;
+                }
+                
+                duplicator_extension_queried = true;
+                
+                foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes (
+                    "/Banshee/Platform/DiscDuplicator")) {
+                    duplicator_extension_node = node;
+                    break;
+                }
+                
+                return duplicator_extension_node != null;
+            }
+        }
+        
+        public static void Duplicate (AudioCdDiscModel model)
+        {
+            if (Supported && model != null && model.Volume != null) {
+                ((IDiscDuplicator)duplicator_extension_node.CreateInstance ()).Duplicate (model.Volume);
+            }
+        }
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs	Mon Jun  2 20:02:43 2008
@@ -47,6 +47,7 @@
         private AudioCdDiscModel disc_model;
         private SourceMessage query_message;
         
+        
         public AudioCdSource (AudioCdService service, AudioCdDiscModel discModel) 
             : base (Catalog.GetString ("Audio CD"), discModel.Title, 200)
         {
@@ -219,7 +220,12 @@
 
         internal void DuplicateDisc ()
         {
-            Hyena.Log.Information ("This feature is not implemented yet.", true);
+            try {
+                AudioCdDuplicator.Duplicate (disc_model);
+            } catch (Exception e) {
+                Hyena.Log.Error (Catalog.GetString ("Could not duplicate audio CD"), e.Message, true);
+                Hyena.Log.Exception (e);
+            }
         }
         
         internal void LockAllTracks ()
@@ -413,6 +419,7 @@
             Gtk.Action duplicate_action = uia_service.GlobalActions["DuplicateDiscAction"];
             if (duplicate_action != null) {
                 duplicate_action.IconName = "media-cdrom";
+                duplicate_action.Visible = AudioCdDuplicator.Supported;
             }
         }
         

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Makefile.am	Mon Jun  2 20:02:43 2008
@@ -5,6 +5,7 @@
 
 SOURCES =  \
 	Banshee.AudioCd/AudioCdDiscModel.cs \
+	Banshee.AudioCd/AudioCdDuplicator.cs \
 	Banshee.AudioCd/AudioCdRipper.cs \
 	Banshee.AudioCd/AudioCdService.cs \
 	Banshee.AudioCd/AudioCdSource.cs \



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