banshee r3824 - in trunk/banshee: . src/Dap/Banshee.Dap src/Dap/Banshee.Dap.Ipod 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/Dap/Banshee.Dap/Banshee.Dap src/Libraries/Hyena/Hyena



Author: abock
Date: Thu Apr 24 22:33:08 2008
New Revision: 3824
URL: http://svn.gnome.org/viewvc/banshee?rev=3824&view=rev

Log:
2008-04-24  Aaron Bockover  <abock gnome org>

    * src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs:
    * src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs:
    * src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs:
    Updated to the new DapSource API

    * src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs: Uses the new enforced
    IDevice ctor that DapSources must have to create the device, if
    InvalidDeviceException is thrown, the source is discarded

    * src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Lots of refactoring and
    cleaning; get rid of Resovle and Initialize (IDevice) and rolled all
    that into the ctor; better error messages, more result checking, easier
    to read code

    * src/Dap/Banshee.Dap/Banshee.Dap/InvalidDeviceException.cs: New exception
    that DapSource implementors must throw in the ctor if they can't support
    the device being passed to them

    * src/Libraries/Hyena/Hyena/Log.cs: Log exceptions through Log.Warning
    and added an override to provide a message with the exception



Added:
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/InvalidDeviceException.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp
   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/Dap/Banshee.Dap/Banshee.Dap.mdp
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Makefile.am
   trunk/banshee/src/Libraries/Hyena/Hyena/Log.cs

Modified: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp	Thu Apr 24 22:33:08 2008
@@ -9,7 +9,6 @@
   </Configurations>
   <Contents>
     <File name="Banshee.Dap.Ipod.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
-    <File name="Banshee.Dap.Ipod" subtype="Directory" buildaction="Compile" />
     <File name="Banshee.Dap.Ipod/IpodSource.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Dap.Ipod/PodSleuthDevice.cs" subtype="Code" buildaction="Compile" />

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 Apr 24 22:33:08 2008
@@ -53,21 +53,20 @@
             get { return database_supported; }
         }
         
-#region Device Initialization        
+#region Device Initialization
         
-        protected override bool Initialize (IDevice device)
+        public IpodSource (IDevice device) : base (device)
         {
             ipod_device = device as PodSleuthDevice;
             if (ipod_device == null) {
-                return false;
+                throw new InvalidDeviceException ();
             }
         
             if (!LoadIpod ()) {
-                return false;
+                throw new InvalidDeviceException ();
             }
             
             Initialize ();
-            return true;
         }
         
         private bool LoadIpod ()

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 Apr 24 22:33:08 2008
@@ -34,6 +34,7 @@
 using Hyena.Collections;
 
 using Banshee.IO;
+using Banshee.Dap;
 using Banshee.Base;
 using Banshee.ServiceStack;
 using Banshee.Library;
@@ -48,21 +49,17 @@
     {
         protected IVolume volume;
 
-        public MassStorageSource () : base ()
-        {
-        }
-
-        protected override bool Initialize (IDevice device)
+        public MassStorageSource (IDevice device) : base (device)
         {
             this.volume = device as IVolume;
             if (volume == null)
-                return false;
+                throw new InvalidDeviceException ();
 
             // TODO set up a ui for selecting volumes we want mounted/shown within Banshee
             // (so people don't have to touch .is_audio_player, and so we can give them a harddrive icon
             // instead of pretending they are DAPs).
-            if (!IsMediaDevice)
-                return false;
+            if (!HasMediaCapabilities)
+                throw new InvalidDeviceException ();
 
             Name = volume.Name;
             mount_point = volume.MountPoint;
@@ -77,8 +74,6 @@
             importer.KeepUserJobHidden = true;
             importer.ImportFinished += delegate  { HideStatus (); };
             importer.QueueSource (BaseDirectory);
-
-            return true;
         }
 
         public override void Import ()
@@ -95,8 +90,8 @@
             get { return mount_point; }
         }
 
-        protected override bool IsMediaDevice {
-            get { return base.IsMediaDevice || File.Exists (new SafeUri (IsAudioPlayerPath)); }
+        protected override bool HasMediaCapabilities {
+            get { return base.HasMediaCapabilities || File.Exists (new SafeUri (IsAudioPlayerPath)); }
         }
 
         protected string IsAudioPlayerPath {

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 Apr 24 22:33:08 2008
@@ -36,6 +36,7 @@
 using Mtp;
 
 using Banshee.Base;
+using Banshee.Dap;
 using Banshee.ServiceStack;
 using Banshee.Library;
 using Banshee.Sources;
@@ -54,14 +55,10 @@
         //private bool supports_jpegs = false;
         private Dictionary<int, Track> track_map;
 
-        public MtpSource () : base ()
-        {
-        }
-
-        protected override bool Initialize (IDevice device)
+        public MtpSource (IDevice device) : base (device)
         {
             if (MediaCapabilities == null || !MediaCapabilities.IsType ("mtp")) {
-                return false;
+                throw new InvalidDeviceException ();
             }
 
             // libmtp only allows us to have one MTP device active
@@ -71,7 +68,7 @@
                     Catalog.GetString ("Banshee's MTP audio player support can only handle one device at a time."),
                     true
                 );
-				return false;
+                throw new InvalidDeviceException ();
             }
 
 			List<MtpDevice> devices = null;
@@ -83,12 +80,11 @@
                     Catalog.GetString ("Error Initializing MTP Device Support"),
                     Catalog.GetString ("There was an error intializing MTP device support.  See http://www.banshee-project.org/Guide/DAPs/MTP for more information.")
                 );
-				return false;
+                throw new InvalidDeviceException ();
 			} catch (Exception e) {
                 Log.Exception (e);
-                Log.Debug (e.ToString ());
 				//ShowGeneralExceptionDialog (e);
-				return false;
+                throw new InvalidDeviceException ();
 			}
 
             if (devices == null || devices.Count == 0) {
@@ -115,7 +111,7 @@
             }
 
             if (mtp_device == null) {
-                return false;
+                throw new InvalidDeviceException ();
             }
 
             Name = mtp_device.Name;
@@ -155,8 +151,6 @@
                 OnTracksAdded ();
                 HideStatus ();
             });
-
-            return true;
         }
 
         public override void Import ()

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp	Thu Apr 24 22:33:08 2008
@@ -13,12 +13,14 @@
     <File name="Banshee.Dap/DapService.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Dap.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
     <File name="Banshee.Dap.Gui/DapPropertiesDialog.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Dap/InvalidDeviceException.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
     <ProjectReference type="Project" localcopy="True" refto="Hyena" />
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+    <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
   </References>
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
     <BuildFilesVar Sync="True" Name="SOURCES" />

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs	Thu Apr 24 22:33:08 2008
@@ -47,7 +47,7 @@
     public class DapService : IExtensionService, IDisposable
     {
         private Dictionary<string, DapSource> sources;
-        private List<TypeExtensionNode> supported_dap_types = new List<TypeExtensionNode>();
+        private List<TypeExtensionNode> supported_dap_types = new List<TypeExtensionNode> ();
         
         public DapService ()
         {
@@ -98,28 +98,47 @@
             }
         }
         
+        private DapSource FindDeviceSource (IDevice device)
+        {
+            foreach (TypeExtensionNode node in supported_dap_types) {
+                try {
+                    return (DapSource)Activator.CreateInstance (node.Type, new object [] { device });
+                } catch (System.Reflection.TargetInvocationException e) {
+                    if (!(e.InnerException is InvalidDeviceException)) {
+                        Log.Exception (e);
+                    }
+                } catch (InvalidCastException e) {
+                    Log.Exception ("Extension is not a DapSource as required", e);
+                }
+            }
+            
+            return null;
+        }
+        
         private void MapDevice (IDevice device)
         {
             lock (this) {
-                if (sources.ContainsKey (device.Uuid))
+                if (sources.ContainsKey (device.Uuid)) {
                     return;
-
-                if (device is ICdromDevice || device is IDiscVolume)
+                }
+                
+                if (device is ICdromDevice || device is IDiscVolume) {
                     return;
-
-                if (device is IVolume && (device as IVolume).ShouldIgnore)
+                }
+                
+                if (device is IVolume && (device as IVolume).ShouldIgnore) {
                     return;
-
-                if (device.MediaCapabilities == null && !(device is IBlockDevice) && !(device is IVolume))
+                }
+                
+                if (device.MediaCapabilities == null && !(device is IBlockDevice) && !(device is IVolume)) {
                     return;
-
-                DapSource source = FindDeviceType (device);
+                }
+                
+                DapSource source = FindDeviceSource (device);
                 if (source != null) {
-                    Log.DebugFormat ("Found DAP support for device {0}", source.Name);
+                    Log.DebugFormat ("Found DAP support ({0}) for device {1}", source.GetType ().FullName, source.Name);
                     sources.Add (device.Uuid, source);
                     ServiceManager.SourceManager.AddSource (source);
-                } else {
-                    //Log.DebugFormat ("Did not find DAP support for device {0}", device.Uuid);
                 }
             }
         }
@@ -129,7 +148,6 @@
             lock (this) {
                 if (sources.ContainsKey (uuid)) {
                     Log.DebugFormat ("Unmapping DAP source ({0})", uuid);
-
                     DapSource source = sources[uuid];
                     source.Dispose ();
                     sources.Remove (uuid);
@@ -161,21 +179,6 @@
                 UnmapDevice (args.DeviceUuid);
             }
         }
-
-        private DapSource FindDeviceType (IDevice device)
-        {
-            foreach (TypeExtensionNode node in supported_dap_types) {
-                try {
-                    DapSource src = (DapSource) node.CreateInstance ();
-                    if (src.Resolve (device)) {
-                        return src;
-                    }
-                } catch (Exception e) {
-                    Log.Exception (e);
-                }
-            }
-            return null;
-        }
         
         string IService.ServiceName {
             get { return "DapService"; }

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	Thu Apr 24 22:33:08 2008
@@ -45,55 +45,69 @@
 {
     public abstract class DapSource : RemovableSource
     {
-        protected IDevice device;
-        protected string [] acceptable_mimetypes;
-
+        private IDevice device;
+        
         internal IDevice Device {
             get { return device; }
         }
 
-        protected DapSource () : base ()
+        protected DapSource (IDevice device)
         {
+            this.device = device;
+            type_unique_id = device.Uuid;
         }
 
+#region Source
+
         protected override void Initialize ()
         {
             base.Initialize ();
-
-            if (!String.IsNullOrEmpty (device.Vendor) && !String.IsNullOrEmpty (device.Product)) {
-                string device_icon_name = (device.Vendor.Trim () + "-" + device.Product.Trim ()).Replace (' ', '-').ToLower ();
-                Properties.SetStringList ("Icon.Name", device_icon_name, FallbackIcon);
-            } else {
-                Properties.SetStringList ("Icon.Name", FallbackIcon);
-            }
-
+            
+            Properties.SetStringList ("Icon.Name", GetIconNames ());
             Properties.Set<string> ("SourcePropertiesActionLabel", Catalog.GetString ("Device Properties"));
-            Properties.Set<OpenPropertiesDelegate> ("SourceProperties.GuiHandler", delegate { new DapPropertiesDialog (this).RunDialog (); });
-
-            GenericName = IsMediaDevice ? Catalog.GetString ("Audio Player") : Catalog.GetString ("Media Device");
-            if (String.IsNullOrEmpty (Name))
+            Properties.Set<OpenPropertiesDelegate> ("SourceProperties.GuiHandler", delegate { 
+                new DapPropertiesDialog (this).RunDialog (); 
+            });
+
+            if (String.IsNullOrEmpty (GenericName)) {
+                GenericName = HasMediaCapabilities 
+                    ? Catalog.GetString ("Media Player") 
+                    : Catalog.GetString ("Storage Device");
+            }
+            
+            if (String.IsNullOrEmpty (Name)) {
                 Name = device.Name;
-
-            acceptable_mimetypes = (MediaCapabilities != null) ? MediaCapabilities.PlaybackMimeTypes : new string [] {"taglib/mp3"};
+            }
+            
+            acceptable_mimetypes = MediaCapabilities != null 
+                ? MediaCapabilities.PlaybackMimeTypes 
+                : new string [] { "taglib/mp3" };
         }
-
-        bool initialized = false;
-
-        public bool Resolve (IDevice device)
+        
+        public override void AddChildSource (Source child)
         {
-            this.device = device;
-            type_unique_id = device.Uuid;
-            bool ret = Initialize (device);
-            initialized = true;
-            return ret;
+            if (child is Banshee.Playlist.AbstractPlaylistSource) {
+                Log.Information ("Note: playlists added to digital audio players within Banshee are not yet saved to the device.", true);
+            }
+            
+            base.AddChildSource (child);
         }
+        
+        public override bool HasProperties {
+            get { return true; }
+        }
+        
+#endregion
+        
+#region Track Management/Syncing       
 
-        protected abstract bool Initialize (IDevice device);
+        protected abstract void AddTrackToDevice (DatabaseTrackInfo track, SafeUri fromUri);  
 
         protected bool TrackNeedsTranscoding (TrackInfo track)
         {
             foreach (string mimetype in AcceptableMimeTypes) {
-                if (ServiceManager.MediaProfileManager.GetExtensionForMimeType (track.MimeType) == ServiceManager.MediaProfileManager.GetExtensionForMimeType (mimetype)) {
+                if (ServiceManager.MediaProfileManager.GetExtensionForMimeType (track.MimeType) == 
+                    ServiceManager.MediaProfileManager.GetExtensionForMimeType (mimetype)) {
                     return false;
                 }
             }
@@ -101,66 +115,106 @@
             return true;
         }
 
-        private ProfileConfiguration preferred_config;
-        private ProfileConfiguration PreferredConfiguration {
-            get {
-                if (preferred_config == null) {
-                    preferred_config = ServiceManager.MediaProfileManager.GetActiveProfileConfiguration (UniqueId, acceptable_mimetypes);
-                }
-                return preferred_config;
-            }
-        }
-
         protected override void AddTrackAndIncrementCount (DatabaseTrackInfo track)
         {
-            if (TrackNeedsTranscoding (track)) {
-                if (PreferredConfiguration == null) {
-                    throw new Exception (Catalog.GetString ("Format not supported by device, and no converter found"));
-                }
-
-                ServiceManager.Get <TranscoderService> ().Enqueue (track, PreferredConfiguration, delegate (TrackInfo ti, SafeUri outUri) {
-                    AddTrackJob.Status = String.Format ("{0} - {1}", track.ArtistName, track.TrackTitle);
-                    try {
-                        AddTrackToDevice (track, outUri);
-                    } catch (Exception e) {
-                        Log.Exception (e);
-                    }
-                    IncrementAddedTracks ();
-                }, delegate { IncrementAddedTracks (); });
-            } else {
+            if (!TrackNeedsTranscoding (track)) {
                 AddTrackToDevice (track, track.Uri);
                 IncrementAddedTracks ();
+                return;
             }
+            
+            if (PreferredConfiguration == null) {
+                string format = System.IO.Path.GetExtension (track.Uri.LocalPath);
+                format = String.IsNullOrEmpty (format) ? Catalog.GetString ("Unknown") : format.Substring (1);
+                throw new ApplicationException (String.Format (Catalog.GetString (
+                    "The {0} format is not supported by the device, and no converter was found to convert it."), format));
+            }
+
+            TranscoderService transcoder = ServiceManager.Get<TranscoderService> ();
+            if (transcoder == null) {
+                throw new ApplicationException (Catalog.GetString (
+                    "File format conversion is not supported for this device."));
+            }
+            
+            transcoder.Enqueue (track, PreferredConfiguration, OnTrackTranscoded, OnTrackTranscodeCancelled);
         }
+        
+        private void OnTrackTranscoded (TrackInfo track, SafeUri outputUri)
+        {
+            AddTrackJob.Status = String.Format ("{0} - {1}", track.ArtistName, track.TrackTitle);
+            
+            try {
+                AddTrackToDevice ((DatabaseTrackInfo)track, outputUri);
+            } catch (Exception e) {
+                Log.Exception (e);
+            }
+            
+            IncrementAddedTracks ();
+        }
+        
+        private void OnTrackTranscodeCancelled ()
+        {
+            IncrementAddedTracks (); 
+        }
+        
+#endregion
 
-        protected abstract void AddTrackToDevice (DatabaseTrackInfo track, SafeUri fromUri);
+#region Device Properties
 
-        protected virtual bool IsMediaDevice {
-            get { return device.MediaCapabilities != null; }
+        protected virtual string [] GetIconNames ()
+        {
+            string vendor = device.Vendor;
+            string product = device.Product;
+            
+            vendor = vendor != null ? vendor.Trim () : null;
+            product = product != null ? product.Trim () : null;
+
+            if (!String.IsNullOrEmpty (vendor) && !String.IsNullOrEmpty (product)) {
+                return new string [] { 
+                    String.Format ("{0}-{1}", vendor, product).Replace (' ', '-').ToLower (), 
+                    FallbackIcon
+                };
+            } else {
+                return new string [] { FallbackIcon };
+            }
+        }
+        
+        private string FallbackIcon {
+            get { return HasMediaCapabilities ? "multimedia-player" : "harddrive"; }
         }
 
-        protected virtual string FallbackIcon {
-            get { return IsMediaDevice ? "multimedia-player" : "harddrive"; }
+        protected virtual bool HasMediaCapabilities {
+            get { return device.MediaCapabilities != null; }
         }
 
         protected IDeviceMediaCapabilities MediaCapabilities {
             get { return device.MediaCapabilities; }
         }
+        
+        private ProfileConfiguration preferred_config;
+        private ProfileConfiguration PreferredConfiguration {
+            get {
+                if (preferred_config != null) {
+                    return preferred_config;
+                }
+            
+                MediaProfileManager manager = ServiceManager.MediaProfileManager;
+                if (manager == null) {
+                    return null;
+                }
+        
+                preferred_config = manager.GetActiveProfileConfiguration (UniqueId, acceptable_mimetypes);
+                return preferred_config;
+            }
+        }
 
+        private string [] acceptable_mimetypes;
         public string [] AcceptableMimeTypes {
             get { return acceptable_mimetypes; }
+            protected set { acceptable_mimetypes = value; }
         }
-
-        public override bool HasProperties {
-            get { return true; }
-        }
-
-        public override void AddChildSource (Source child)
-        {
-            if (initialized && child is Banshee.Playlist.AbstractPlaylistSource) {
-                Log.Information ("Note: playlists added to digital audio players within Banshee are not yet saved to the device.", true);
-            }
-            base.AddChildSource (child);
-        }
+        
+#endregion
+        
     }
 }

Added: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/InvalidDeviceException.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/InvalidDeviceException.cs	Thu Apr 24 22:33:08 2008
@@ -0,0 +1,36 @@
+//
+// InvalidDeviceException.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.Dap
+{
+    public class InvalidDeviceException : ApplicationException
+    {
+    }
+}

Modified: trunk/banshee/src/Dap/Banshee.Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Makefile.am	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Makefile.am	Thu Apr 24 22:33:08 2008
@@ -7,6 +7,7 @@
 	Banshee.Dap.Gui/DapPropertiesDialog.cs \
 	Banshee.Dap/DapService.cs \
 	Banshee.Dap/DapSource.cs \
+	Banshee.Dap/InvalidDeviceException.cs \
 	Banshee.Dap/RemovableSource.cs
 
 RESOURCES = Banshee.Dap.addin.xml

Modified: trunk/banshee/src/Libraries/Hyena/Hyena/Log.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena/Log.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena/Log.cs	Thu Apr 24 22:33:08 2008
@@ -361,8 +361,13 @@
         
         public static void Exception (Exception e)
         {
+            Exception (null, e);
+        }
+        
+        public static void Exception (string message, Exception e)
+        {
             // FIXME: We should save these to an actual log file
-            Console.WriteLine (e);
+            Log.Warning (message ?? "Caught an exception", e.ToString (), false);
         }
         
         #endregion



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