[banshee] Better Rockbox support



commit 743bf394375b10a00275aaacda8ffd5be7ab467b
Author: Jack Deslippe <jdeslip gmail com>
Date:   Wed Jul 29 17:04:44 2009 -0700

    Better Rockbox support
    
    If a .rockbox/config.cfg file is found on the device, then load custom
    settings that should work well with the firmware.
    
    Signed-off-by: Gabriel Burt <gabriel burt gmail com>

 .../Banshee.Dap.MassStorage/MassStorageDevice.cs   |   91 ++++++++++++--------
 1 files changed, 55 insertions(+), 36 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
index 1f2e473..2ee2a1a 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
@@ -30,6 +30,8 @@ using System;
 using System.IO;
 using System.Collections.Generic;
 
+using Mono.Unix;
+
 using Hyena;
 
 using Banshee.Base;
@@ -68,50 +70,67 @@ namespace Banshee.Dap.MassStorage
         public virtual bool LoadDeviceConfiguration ()
         {
             string path = IsAudioPlayerPath;
+            string path_rockbox = System.IO.Path.Combine (source.Volume.MountPoint, ".rockbox/config.cfg");
             StreamReader reader = null;
             
-            if (!File.Exists (path)) {
+            if (!File.Exists (path) && !File.Exists (path_rockbox) ) {
                 return false;
             }
             
-            try {
-                foreach (KeyValuePair<string, string []> item in new KeyValueParser (reader = new StreamReader (path))) {
-                    try {
-                        switch (item.Key) {
-                            case "name": name = item.Value[0]; break;
-                            
-                            case "cover_art_file_type": cover_art_file_type = item.Value[0].ToLower (); break;
-                            case "cover_art_file_name": cover_art_file_name = item.Value[0]; break;
-                            case "cover_art_size": Int32.TryParse (item.Value[0], out cover_art_size); break;
-                            
-                            case "folder_depth": 
-                                if (!Int32.TryParse (item.Value[0], out folder_depth)) {
-                                    folder_depth = -1;
-                                }
-                            Hyena.Log.DebugFormat ("MassStorageDevice.LoadDeviceConfiguration {0}", folder_depth);
-                                break;
-                            case "audio_folders": audio_folders = item.Value; break;
-                            
-                            case "output_formats": playback_mime_types = item.Value; break;
-                            
-                            case "playlist_format": playlist_formats = item.Value; break;
-                            case "playlist_path": playlist_path = item.Value[0]; break;
-                            
-                            default:
-                                throw new ApplicationException ("unsupported key");    
+            if (File.Exists (path_rockbox) ) {
+                Hyena.Log.DebugFormat ("Found RockBox Device");
+                name = Catalog.GetString ("Rockbox Device");
+                audio_folders = new string [] {"Music/","Videos/"};
+                //video_folders = new string [] {"Videos/"};
+                folder_depth = 2;
+                playback_mime_types = new string [] {"application/ogg","audio/x-ms-wma","audio/mpeg","audio/mp4","audio/x-wav"};
+                playlist_formats = new string [] {"audio/x-mpegurl"};
+                playlist_path = "Playlists/";
+                cover_art_file_name = "cover.jpg";
+                cover_art_file_type = "jpeg";
+                cover_art_size = 320;
+            }
+
+            if (File.Exists (path)) {
+                try {
+                    foreach (KeyValuePair<string, string []> item in new KeyValueParser (reader = new StreamReader (path))) {
+                        try {
+                            switch (item.Key) {
+                                case "name": name = item.Value[0]; break;
+
+                                case "cover_art_file_type": cover_art_file_type = item.Value[0].ToLower (); break;
+                                case "cover_art_file_name": cover_art_file_name = item.Value[0]; break;
+                                case "cover_art_size": Int32.TryParse (item.Value[0], out cover_art_size); break;
+
+                                case "folder_depth": 
+                                    if (!Int32.TryParse (item.Value[0], out folder_depth)) {
+                                        folder_depth = -1;
+                                    }
+                                    Hyena.Log.DebugFormat ("MassStorageDevice.LoadDeviceConfiguration {0}", folder_depth);
+                                    break;
+                                case "audio_folders": audio_folders = item.Value; break;
+
+                                case "output_formats": playback_mime_types = item.Value; break;
+
+                                case "playlist_format": playlist_formats = item.Value; break;
+                                case "playlist_path": playlist_path = item.Value[0]; break;
+
+                                default:
+                                    throw new ApplicationException ("unsupported key");    
+                            }
+                        } catch (Exception e) {
+                            Log.Exception ("Invalid .is_audio_player item " + item.Key, e);
                         }
-                    } catch (Exception e) {
-                        Log.Exception ("Invalid .is_audio_player item " + item.Key, e);
                     }
-                }
-            } catch (Exception e) {
-                Log.Exception ("Error parsing " + path, e);
-            } finally {
-                if (reader != null) {
-                    reader.Dispose ();
+                } catch (Exception e) {
+                    Log.Exception ("Error parsing " + path, e);
+                } finally {
+                    if (reader != null) {
+                        reader.Dispose ();
+                    }
                 }
             }
-            
+
             has_is_audio_player_file = true;
             
             return true;
@@ -131,7 +150,7 @@ namespace Banshee.Dap.MassStorage
         private string IsAudioPlayerPath {
             get { return System.IO.Path.Combine (source.Volume.MountPoint, ".is_audio_player"); }
         }
-        
+
         private string name;
         public virtual string Name {
             get { return name ?? source.Volume.Name; }



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