banshee r3528 - in trunk/banshee: . src/Core/Banshee.Core src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler



Author: abock
Date: Mon Mar 24 23:13:03 2008
New Revision: 3528
URL: http://svn.gnome.org/viewvc/banshee?rev=3528&view=rev

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

    * src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs: Use XDG_CACHE_HOME
    as the base directory for the album art disk cache

    * src/Core/Banshee.Core/Banshee.Base/Paths.cs: Changed some other paths
    to use XDG_CACHE_HOME, especially for extension caches

    * src/Core/Banshee.Core/Banshee.Base/XdgBaseDirectorySpec.cs: Moved the
    XDG code into its own class from Paths

    * src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs:
    Ensure the artwork cache directory gets created if it doesn't exist

    * src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs:
    Use the new ExtensionCacheRoot path



Added:
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/XdgBaseDirectorySpec.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp
   trunk/banshee/src/Core/Banshee.Core/Makefile.am
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs	Mon Mar 24 23:13:03 2008
@@ -90,8 +90,8 @@
             return Regex.Replace (part, @"[^A-Za-z0-9]*", "").ToLower ();
         }
         
-        private static string root_path =
-            Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "album-art");
+        private static string root_path = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory (
+            "XDG_CACHE_HOME", ".cache"),  "album-art");
             
         public static string RootPath {
             get { return root_path; }

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs	Mon Mar 24 23:13:03 2008
@@ -4,7 +4,7 @@
 // Author:
 //   Aaron Bockover <abockover novell com>
 //
-// Copyright (C) 2005-2007 Novell, Inc.
+// Copyright (C) 2005-2008 Novell, Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -35,56 +35,7 @@
 namespace Banshee.Base
 {
     public class Paths
-    {
-        // TODO: A corlib version of this method will be committed to Mono's Environment.GetFolderPath,
-        // so many many Mono versions in the future we will be able to drop this private copy and
-        // use the pure .NET API - but it's here to stay for now (compat!)
-        private static string ReadXdgUserDir (string key, string fallback)
-        {
-            string home_dir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
-            string config_dir = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
-            
-            string env_path = Environment.GetEnvironmentVariable (key);
-            if (!String.IsNullOrEmpty (env_path)) {
-                return env_path;
-            }
-
-            string user_dirs_path = Path.Combine (config_dir, "user-dirs.dirs");
-
-            if (!File.Exists (user_dirs_path)) {
-                return Path.Combine (home_dir, fallback);
-            }
-
-            try {
-                using (StreamReader reader = new StreamReader (user_dirs_path)) {
-                    string line;
-                    while ((line = reader.ReadLine ()) != null) {
-                        line = line.Trim ();
-                        int delim_index = line.IndexOf ('=');
-                        if (delim_index > 8 && line.Substring (0, delim_index) == key) {
-                            string path = line.Substring (delim_index + 1).Trim ('"');
-                            bool relative = false;
-
-                            if (path.StartsWith ("$HOME/")) {
-                                relative = true;
-                                path = path.Substring (6);
-                            } else if (path.StartsWith ("~")) {
-                                relative = true;
-                                path = path.Substring (1);
-                            } else if (!path.StartsWith ("/")) {
-                                relative = true;
-                            }
-
-                            return relative ? Path.Combine (home_dir, path) : path;
-                        }
-                    }
-                }
-            } catch (FileNotFoundException) {
-            }
-            
-            return Path.Combine (home_dir, fallback);
-        }
-        
+    {        
         public static string Combine (string first, params string [] components)
         {
             if (String.IsNullOrEmpty (first)) {
@@ -135,17 +86,24 @@
             }
         }
         
-        public static string ExtensionsData {
-            get { return Path.Combine (ApplicationData, "extensions"); }
+        private static string application_cache = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory (
+            "XDG_CACHE_HOME", ".cache"), "banshee-1");
+        
+        public static string ApplicationCache {
+            get { return application_cache; }
+        }
+        
+        public static string ExtensionCacheRoot {
+            get { return Path.Combine (ApplicationCache, "extensions"); }
         }
         
         public static string DefaultLibraryPath {
-            get { return ReadXdgUserDir ("XDG_MUSIC_DIR", "Music"); }
+            get { return XdgBaseDirectorySpec.GetUserDirectory ("XDG_MUSIC_DIR", "Music"); }
         }
         
         public static string TempDir {
             get {
-                string dir = Path.Combine (Paths.ApplicationData, "temp");
+                string dir = Path.Combine (ApplicationCache, "temp");
         
                 if (File.Exists (dir)) {
                     File.Delete (dir);

Added: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/XdgBaseDirectorySpec.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/XdgBaseDirectorySpec.cs	Mon Mar 24 23:13:03 2008
@@ -0,0 +1,82 @@
+//
+// XdgBaseDirectorySpec.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2006-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 System.IO;
+
+namespace Banshee.Base
+{
+    public static class XdgBaseDirectorySpec
+    {
+        public static string GetUserDirectory (string key, string fallback)
+        {
+            string home_dir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+            string config_dir = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
+            
+            string env_path = Environment.GetEnvironmentVariable (key);
+            if (!String.IsNullOrEmpty (env_path)) {
+                return env_path;
+            }
+
+            string user_dirs_path = Path.Combine (config_dir, "user-dirs.dirs");
+
+            if (!File.Exists (user_dirs_path)) {
+                return Path.Combine (home_dir, fallback);
+            }
+
+            try {
+                using (StreamReader reader = new StreamReader (user_dirs_path)) {
+                    string line;
+                    while ((line = reader.ReadLine ()) != null) {
+                        line = line.Trim ();
+                        int delim_index = line.IndexOf ('=');
+                        if (delim_index > 8 && line.Substring (0, delim_index) == key) {
+                            string path = line.Substring (delim_index + 1).Trim ('"');
+                            bool relative = false;
+
+                            if (path.StartsWith ("$HOME/")) {
+                                relative = true;
+                                path = path.Substring (6);
+                            } else if (path.StartsWith ("~")) {
+                                relative = true;
+                                path = path.Substring (1);
+                            } else if (!path.StartsWith ("/")) {
+                                relative = true;
+                            }
+
+                            return relative ? Path.Combine (home_dir, path) : path;
+                        }
+                    }
+                }
+            } catch (FileNotFoundException) {
+            }
+            
+            return Path.Combine (home_dir, fallback);
+        }
+    }
+}

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp	Mon Mar 24 23:13:03 2008
@@ -66,6 +66,7 @@
     <File name="Banshee.Configuration/IConfigurationClient.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Core.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
     <File name="Banshee.Collection/TrackMediaAttributes.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Base/XdgBaseDirectorySpec.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="False" refto="Hyena" />

Modified: trunk/banshee/src/Core/Banshee.Core/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Makefile.am	Mon Mar 24 23:13:03 2008
@@ -13,6 +13,7 @@
 	Banshee.Base/Resource.cs \
 	Banshee.Base/SafeUri.cs \
 	Banshee.Base/UriList.cs \
+	Banshee.Base/XdgBaseDirectorySpec.cs \
 	Banshee.Collection/AlbumInfo.cs \
 	Banshee.Collection/ArtistInfo.cs \
 	Banshee.Collection/FileTrackInfo.cs \

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs	Mon Mar 24 23:13:03 2008
@@ -60,12 +60,12 @@
             
             // FIXME: Replace with Directory.Move for release
             
+            Directory.CreateDirectory (CoverArtSpec.RootPath);
+            
             string legacy_artwork_path = Path.Combine (Paths.LegacyApplicationData, "covers");
             int artwork_count = 0;
             
             if (Directory.Exists (legacy_artwork_path)) {
-                Directory.CreateDirectory (CoverArtSpec.RootPath);
-                    
                 foreach (string path in Directory.GetFiles (legacy_artwork_path)) {
                     string dest_path = Path.Combine (CoverArtSpec.RootPath, Path.GetFileName (path));
                         

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs	Mon Mar 24 23:13:03 2008
@@ -135,7 +135,7 @@
 
         public Queue ()
         {
-            string xmlfilepath = Path.Combine (Banshee.Base.Paths.ExtensionsData, "last.fm");
+            string xmlfilepath = Path.Combine (Banshee.Base.Paths.ExtensionCacheRoot, "last.fm");
             xml_path = Path.Combine (xmlfilepath, "audioscrobbler-queue.xml");
             queue = new List<QueuedTrack> ();
             



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