banshee r3895 - in trunk/banshee: . src/Backends/Banshee.Hal/Banshee.HalBackend src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage src/Dap/Banshee.Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap.Gui
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3895 - in trunk/banshee: . src/Backends/Banshee.Hal/Banshee.HalBackend src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage src/Dap/Banshee.Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap.Gui
- Date: Tue, 6 May 2008 19:55:50 +0100 (BST)
Author: gburt
Date: Tue May 6 18:55:50 2008
New Revision: 3895
URL: http://svn.gnome.org/viewvc/banshee?rev=3895&view=rev
Log:
2008-05-06 Gabriel Burt <gabriel burt gmail com>
* src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs:
Parse the .is_audio_player file, except not setting the output formats
yet. Install some dap properties.
* src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Add DapProperties property
that the Dap dialog shows.
* src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDialog.cs: Show the
DapProperties.
* src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs: Cache the uuid.
* src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs: Catch property
exception for volume that was suddenly removed.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs
trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDialog.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs (original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs Tue May 6 18:55:50 2008
@@ -51,8 +51,9 @@
this.device = device;
}
+ private string uuid;
public virtual string Uuid {
- get { return String.IsNullOrEmpty (HalDevice["usb.serial"]) ? device.Udi : HalDevice["usb.serial"]; }
+ get { return uuid ?? uuid = String.IsNullOrEmpty (HalDevice["usb.serial"]) ? device.Udi : HalDevice["usb.serial"]; }
}
private string name;
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 Tue May 6 18:55:50 2008
@@ -203,7 +203,12 @@
lock (mounted_volumes) {
if (mounted_volumes.ContainsKey (device)) {
Volume volume = mounted_volumes[device];
- if (!volume.IsMounted) {
+ bool mounted = false;
+ try {
+ mounted = volume.IsMounted;
+ } catch (Exception) {}
+
+ if (!mounted) {
mounted_volumes.Remove (device);
unmounted_volumes[device] = volume;
HardwareManager.OnDeviceRemoved (volume.Uuid);
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 Tue May 6 18:55:50 2008
@@ -63,6 +63,9 @@
if (!HasMediaCapabilities && !HasIsAudioPlayerFile)
throw new InvalidDeviceException ();
+ if (HasIsAudioPlayerFile)
+ ParseIsAudioPlayerFile ();
+
// Ignore iPods, except ones with .is_audio_player files
if (MediaCapabilities != null && MediaCapabilities.IsType ("ipod")) {
if (HasIsAudioPlayerFile) {
@@ -81,10 +84,33 @@
Initialize ();
+ AddDapProperties ();
+
// TODO differentiate between Audio Players and normal Disks, and include the size, eg "2GB Audio Player"?
//GenericName = Catalog.GetString ("Audio Player");
}
+ private void AddDapProperties ()
+ {
+ if (AudioFolders.Length > 0 && !String.IsNullOrEmpty (AudioFolders[0])) {
+ AddDapProperty (String.Format (
+ Catalog.GetPluralString ("Audio Folder", "Audio Folders", AudioFolders.Length), AudioFolders.Length),
+ System.String.Join ("\n", AudioFolders)
+ );
+ }
+
+ if (FolderDepth != -1) {
+ AddDapProperty (Catalog.GetString ("Required Folder Depth"), FolderDepth.ToString ());
+ }
+
+ /*if (AcceptableMimeTypes.Length > 0) {
+ AddDapProperty (String.Format (
+ Catalog.GetPluralString ("Audio Format", "Audio Formats", PlaybackFormats.Length), PlaybackFormats.Length),
+ System.String.Join (", ", PlaybackFormats)
+ );
+ }*/
+ }
+
// WARNING: This will be called from a thread!
protected override void LoadFromDevice ()
{
@@ -108,8 +134,13 @@
get { return mount_point; }
}
+ private bool? has_is_audio_player_file = null;
private bool HasIsAudioPlayerFile {
- get { return File.Exists (new SafeUri (IsAudioPlayerPath)); }
+ get {
+ if (has_is_audio_player_file == null)
+ has_is_audio_player_file = File.Exists (new SafeUri (IsAudioPlayerPath));
+ return has_is_audio_player_file.Value;
+ }
}
protected override IDeviceMediaCapabilities MediaCapabilities {
@@ -144,8 +175,8 @@
write_path = BaseDirectory;
// According to the HAL spec, the first folder listed in the audio_folders property
// is the folder to write files to.
- if (MediaCapabilities != null && MediaCapabilities.AudioFolders.Length > 0) {
- write_path = System.IO.Path.Combine (write_path, MediaCapabilities.AudioFolders[0]);
+ if (AudioFolders.Length > 0) {
+ write_path = System.IO.Path.Combine (write_path, AudioFolders[0]);
}
}
return write_path;
@@ -154,6 +185,28 @@
set { write_path = value; }
}
+ private string [] audio_folders;
+ protected string [] AudioFolders {
+ get {
+ if (audio_folders == null) {
+ audio_folders = HasMediaCapabilities ? MediaCapabilities.AudioFolders : new string [] {};
+ }
+ return audio_folders;
+ }
+ set { audio_folders = value; }
+ }
+
+ private int folder_depth = -1;
+ protected int FolderDepth {
+ get {
+ if (folder_depth == -1) {
+ folder_depth = HasMediaCapabilities ? MediaCapabilities.FolderDepth : 0;
+ }
+ return folder_depth;
+ }
+ set { folder_depth = value; }
+ }
+
protected override void AddTrackToDevice (DatabaseTrackInfo track, SafeUri fromUri)
{
if (track.PrimarySourceId == DbId)
@@ -195,10 +248,6 @@
}
}
- protected int FolderDepth {
- get { return MediaCapabilities == null ? -1 : MediaCapabilities.FolderDepth; }
- }
-
private string GetTrackPath (TrackInfo track, string ext)
{
string file_path = WritePath;
@@ -246,50 +295,49 @@
return file_path;
}
- /*private void ParseIsAudioPlayerFile ()
+ private void ParseIsAudioPlayerFile ()
{
// Allow the HAL values to be overridden by corresponding key=value pairs in .is_audio_player
- if(File.Exists(IsAudioPlayerPath)) {
- StreamReader reader = null;
- try {
- reader = new StreamReader(IsAudioPlayerPath);
-
- string line;
- while((line = reader.ReadLine()) != null) {
- string [] pieces = line.Split('=');
- if(line.StartsWith("#") || pieces == null || pieces.Length != 2)
- continue;
-
- string key = pieces[0], val = pieces[1];
-
- switch(key) {
- case "audio_folders":
- AudioFolders = val.Split(',');
- break;
-
- case "output_formats":
- PlaybackFormats = val.Split(',');
- break;
-
- case "folder_depth":
- FolderDepth = Int32.Parse(val);
- break;
-
- case "input_formats":
- case "playlist_format":
- case "playlist_path":
- default:
- Console.WriteLine("Unsupported key: {0}", key);
- break;
- }
+ System.IO.StreamReader reader = null;
+ try {
+ reader = new System.IO.StreamReader (IsAudioPlayerPath);
+
+ string line;
+ while ((line = reader.ReadLine ()) != null) {
+ string [] pieces = line.Split ('=');
+ if (line.StartsWith ("#") || pieces == null || pieces.Length != 2)
+ continue;
+
+ string key = pieces[0];
+ string val = pieces[1];
+
+ switch (key) {
+ case "audio_folders":
+ AudioFolders = val.Split (',');
+ break;
+
+ case "output_formats":
+ //PlaybackFormats = val.Split (',');
+ break;
+
+ case "folder_depth":
+ FolderDepth = Int32.Parse (val);
+ break;
+
+ case "input_formats":
+ case "playlist_format":
+ case "playlist_path":
+ default:
+ Log.DebugFormat ("Unsupported .is_audio_player key: {0}", key);
+ break;
}
- } catch(Exception e) {
- LogCore.Instance.PushWarning("Error parsing .is_audio_player file", e.ToString(), false);
- } finally {
- if(reader != null)
- reader.Close();
}
+ } catch (Exception e) {
+ Log.Exception ("Error parsing .is_audio_player file", e);
+ } finally {
+ if (reader != null)
+ reader.Close ();
}
- }*/
+ }
}
}
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDialog.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDialog.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDialog.cs Tue May 6 18:55:50 2008
@@ -114,13 +114,13 @@
extTable.ColumnSpacing = 10;
extTable.RowSpacing = 5;
- /*foreach(DapDevice.Property property in device.Properties) {
+ foreach(DapSource.DapProperty property in source.DapProperties) {
extTable.AddLabel(property.Name, property.Value);
}
Expander expander = new Expander(Catalog.GetString("Advanced details"));
expander.Add(extTable);
- box.PackStart(expander, false, false, 0); */
+ box.PackStart(expander, false, false, 0);
BorderWidth = 10;
Resizable = false;
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 Tue May 6 18:55:50 2008
@@ -108,6 +108,9 @@
if (String.IsNullOrEmpty (Name)) {
Name = device.Name;
}
+
+ AddDapProperty (Catalog.GetString ("Product"), device.Product);
+ AddDapProperty (Catalog.GetString ("Vendor"), device.Vendor);
acceptable_mimetypes = MediaCapabilities != null
? MediaCapabilities.PlaybackMimeTypes
@@ -191,6 +194,22 @@
return true;
}
+ public struct DapProperty {
+ public string Name;
+ public string Value;
+ public DapProperty (string k, string v) { Name = k; Value = v; }
+ }
+
+ private List<DapProperty> dap_properties = new List<DapProperty> ();
+ protected void AddDapProperty (string key, string val)
+ {
+ dap_properties.Add (new DapProperty (key, val));
+ }
+
+ public IEnumerable<DapProperty> DapProperties {
+ get { return dap_properties; }
+ }
+
protected override void AddTrackAndIncrementCount (DatabaseTrackInfo track)
{
if (!TrackNeedsTranscoding (track)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]