banshee r3581 - in trunk/banshee: . src/Backends/Banshee.Hal/Banshee.HalBackend src/Core/Banshee.Services/Banshee.Hardware src/Extensions/Banshee.AudioCd src/Extensions/Banshee.AudioCd/Banshee.AudioCd



Author: abock
Date: Sat Mar 29 00:28:30 2008
New Revision: 3581
URL: http://svn.gnome.org/viewvc/banshee?rev=3581&view=rev

Log:
2008-03-28  Aaron Bockover  <abock gnome org>

    * src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs:
    * src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs: Actually return
    a real device node

    * src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs: Added a DeviceNode
    property since volumes have 'em as well

    * src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDiscModel.cs:
    Read the audio CD tracks from the disc and push to the model

    * src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs:
    Load the model

    * src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdTrackInfo.cs:
    TrackInfo object specific to the audio cd



Added:
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdTrackInfo.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs
   trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd.mdp
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDiscModel.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Makefile.am

Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs	Sat Mar 29 00:28:30 2008
@@ -58,7 +58,7 @@
         }
         
         public string DeviceNode {
-            get { return HalDevice.Udi; }
+            get { return HalDevice["block.device"]; }
         }
         
         public IEnumerable<IVolume> Volumes {

Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs	Sat Mar 29 00:28:30 2008
@@ -59,6 +59,10 @@
                 : new string[0];
         }
 
+        public string DeviceNode {
+            get { return HalDevice["block.device"]; }
+        }
+
         public string MountPoint {
             get { return HalDevice["volume.mount_point"]; }
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs	Sat Mar 29 00:28:30 2008
@@ -32,6 +32,7 @@
 {
     public interface IVolume : IDevice
     {
+        string DeviceNode { get; }
         string MountPoint { get; }
         bool IsMounted { get; }
         bool IsMountedReadOnly { get; }

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	Sat Mar 29 00:28:30 2008
@@ -12,6 +12,7 @@
     <File name="Banshee.AudioCd/AudioCdService.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.AudioCd/AudioCdSource.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.AudioCd/AudioCdDiscModel.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.AudioCd/AudioCdTrackInfo.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDiscModel.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDiscModel.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdDiscModel.cs	Sat Mar 29 00:28:30 2008
@@ -27,6 +27,7 @@
 //
 
 using System;
+using Mono.Unix;
 
 using MusicBrainz;
 using Banshee.Hardware;
@@ -41,20 +42,35 @@
         public AudioCdDiscModel (IDiscVolume volume)
         {
             this.volume = volume;
-            ReadDisc ();
+            disc_title = Catalog.GetString ("Audio CD");
         }
         
-        private void ReadDisc ()
+        public void LoadModelFromDisc ()
         {
+            LocalDisc mb_disc = LocalDisc.GetFromDevice (volume.DeviceNode);
+            if (mb_disc == null) {
+                throw new ApplicationException ("Could not read contents of the disc. Platform may not be supported.");
+            }
             
+            for (int i = 0, n = mb_disc.TrackDurations.Length; i < n; i++) {
+                AudioCdTrackInfo track = new AudioCdTrackInfo (volume.DeviceNode, i);
+                track.TrackNumber = i + 1;
+                track.TrackCount = n;
+                track.Duration = TimeSpan.FromSeconds (mb_disc.TrackDurations[i]);
+                track.ArtistName = Catalog.GetString ("Unknown Artist");
+                track.AlbumTitle = Catalog.GetString ("Unknown Album");
+                track.TrackTitle = String.Format(Catalog.GetString ("Track {0}"), track.TrackNumber);
+                Add (track);
+            }
         }
         
         public IDiscVolume Volume {
             get { return volume; }
         }
         
+        private string disc_title;
         public string Title {
-            get { return "New CD"; }
+            get { return disc_title; }
         }
         
         public int TrackCount {

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	Sat Mar 29 00:28:30 2008
@@ -46,6 +46,8 @@
             this.service = service;
             this.disc_model = discModel;
             
+            disc_model.LoadModelFromDisc ();
+            
             Properties.SetStringList ("Icon.Name", "media-cdrom", "gnome-dev-cdrom-audio", "source-cd-audio");
             Properties.SetString ("UnmapSourceActionLabel", Catalog.GetString ("Eject Disc"));
         }

Added: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdTrackInfo.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdTrackInfo.cs	Sat Mar 29 00:28:30 2008
@@ -0,0 +1,49 @@
+//
+// AudioCdTrackInfo.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 Banshee.Base;
+using Banshee.Collection;
+
+namespace Banshee.AudioCd
+{
+    public class AudioCdTrackInfo : TrackInfo
+    {
+        public AudioCdTrackInfo (string deviceNode, int index)
+        {
+            index_on_disc = index;            
+            Uri = new SafeUri ("cdda://" + index_on_disc + "#" + deviceNode); 
+        }
+        
+        private int index_on_disc;
+        public int IndexOnDisc {
+            get { return index_on_disc; }
+        }
+    }
+}

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	Sat Mar 29 00:28:30 2008
@@ -6,7 +6,8 @@
 SOURCES =  \
 	Banshee.AudioCd/AudioCdDiscModel.cs \
 	Banshee.AudioCd/AudioCdService.cs \
-	Banshee.AudioCd/AudioCdSource.cs
+	Banshee.AudioCd/AudioCdSource.cs \
+	Banshee.AudioCd/AudioCdTrackInfo.cs
 
 RESOURCES = Banshee.AudioCd.addin.xml
 



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