[banshee] Move `Paths` to Hyena (bgo#605891)



commit 2d1dada540c07344948c725d63f70a378012fc23
Author: Ruben Vermeersch <ruben savanne be>
Date:   Mon Apr 12 10:41:24 2010 +1000

    Move `Paths` to Hyena (bgo#605891)
    
    This patch moves Paths into Hyena, which allows it to be used by other
    applications.
    
    This patch consists of a number of things:
    
     * The legacy application data path is moved to a new LegacyPaths class.
     * The rest of Paths is moved into Hyena.
     * All other fixes are related to getting it building with the moved
       class.
    
    One special thing to note is the new ApplicationName member in Paths.
    As I didn't want anything banshee-specific in Paths, I had to
    introduce this new member. This needs to be initialized at application
    startup.
    
    Signed-off-by: Alexander Kojevnikov <alexander kojevnikov com>

 src/Clients/Beroe/Beroe/IndexerClient.cs           |    2 +
 src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs |    4 +-
 src/Core/Banshee.Core/Banshee.Base/LegacyPaths.cs  |   46 +++++++++++++++++++
 .../XmlConfigurationClient.cs                      |    2 +
 src/Core/Banshee.Core/Banshee.Core.csproj          |    1 -
 src/Core/Banshee.Core/Makefile.am                  |    2 +-
 .../Banshee.Database/BansheeDbFormatMigrator.cs    |    4 +-
 .../Banshee.Library/Tests/FileNamePatternTests.cs  |    1 +
 .../Banshee.MediaEngine/TranscoderService.cs       |    1 +
 .../Banshee.MediaProfiles/MediaProfileManager.cs   |    2 +-
 .../Banshee.ServiceStack/Application.cs            |    2 +-
 .../Banshee.Collection.Gui/ArtworkManager.cs       |    2 +-
 .../Banshee.Gui/BansheeIconFactory.cs              |    2 +-
 .../Banshee.Gui/GtkBaseClient.cs                   |    7 +++-
 .../Banshee.Library.Gui/PhotoFolderImportSource.cs |    2 +
 .../Banshee.Dap.MassStorage/MassStorageSource.cs   |    8 ++--
 .../Banshee.InternetRadio/XspfMigrator.cs          |    2 +-
 .../Banshee.Lastfm.Audioscrobbler/Queue.cs         |    2 +-
 .../Banshee.Lastfm.Radio/LastfmSource.cs           |    2 +-
 .../AmarokPlayerImportSource.cs                    |    1 +
 .../RhythmboxPlayerImportSource.cs                 |    8 ++--
 .../Banshee.YouTube.Data/DataFetch.cs              |    2 +-
 src/Libraries/Hyena/Hyena.csproj                   |    1 +
 .../Hyena/Hyena}/Paths.cs                          |   48 +++++++++++---------
 src/Libraries/Hyena/Makefile.am                    |    1 +
 25 files changed, 110 insertions(+), 45 deletions(-)
---
diff --git a/src/Clients/Beroe/Beroe/IndexerClient.cs b/src/Clients/Beroe/Beroe/IndexerClient.cs
index f4c0430..538ff87 100644
--- a/src/Clients/Beroe/Beroe/IndexerClient.cs
+++ b/src/Clients/Beroe/Beroe/IndexerClient.cs
@@ -73,6 +73,8 @@ namespace Beroe
 
         private static void Startup ()
         {
+            Paths.ApplicationName = "banshee-1";
+
             ThreadAssist.InitializeMainThread ();
 
             ServiceManager.Initialize ();
diff --git a/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs b/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
index 77fb38b..2a3fbfe 100644
--- a/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
@@ -26,6 +26,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using Hyena;
+
 using System;
 using System.IO;
 using System.Collections.Generic;
@@ -34,8 +36,6 @@ using System.Text.RegularExpressions;
 
 using Mono.Unix;
 
-using Hyena;
-
 namespace Banshee.Base
 {
     public static class CoverArtSpec
diff --git a/src/Core/Banshee.Core/Banshee.Base/LegacyPaths.cs b/src/Core/Banshee.Core/Banshee.Base/LegacyPaths.cs
new file mode 100644
index 0000000..d80a2d4
--- /dev/null
+++ b/src/Core/Banshee.Core/Banshee.Base/LegacyPaths.cs
@@ -0,0 +1,46 @@
+//
+// LegacyPaths.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//   Ruben Vermeersch <ruben savanne be>
+//
+// 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
+// "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 Hyena;
+
+using System;
+using System.IO;
+
+namespace Banshee.Base
+{
+    public class LegacyPaths
+    {
+        private static string application_data = Path.Combine (Environment.GetFolderPath (
+            Environment.SpecialFolder.ApplicationData), Paths.ApplicationName);
+
+        public static string ApplicationData {
+            get { return application_data; }
+        }
+    }
+}
diff --git a/src/Core/Banshee.Core/Banshee.Configuration/XmlConfigurationClient.cs b/src/Core/Banshee.Core/Banshee.Configuration/XmlConfigurationClient.cs
index 1305899..0f0e5d1 100644
--- a/src/Core/Banshee.Core/Banshee.Configuration/XmlConfigurationClient.cs
+++ b/src/Core/Banshee.Core/Banshee.Configuration/XmlConfigurationClient.cs
@@ -32,6 +32,8 @@ using System.Timers;
 using System.Xml;
 using System.Xml.Serialization;
 
+using Hyena;
+
 using Banshee.Base;
 
 namespace Banshee.Configuration
diff --git a/src/Core/Banshee.Core/Banshee.Core.csproj b/src/Core/Banshee.Core/Banshee.Core.csproj
index 8f0dca5..bc6e3fa 100644
--- a/src/Core/Banshee.Core/Banshee.Core.csproj
+++ b/src/Core/Banshee.Core/Banshee.Core.csproj
@@ -96,7 +96,6 @@
     <Compile Include="Banshee.Configuration\SchemaEntry.cs" />
     <Compile Include="Banshee.Base\FileNamePattern.cs" />
     <Compile Include="Banshee.Base\PathPattern.cs" />
-    <Compile Include="Banshee.Base\Paths.cs" />
     <Compile Include="Banshee.Base\SafeUri.cs" />
     <Compile Include="Banshee.Collection\AlbumInfo.cs" />
     <Compile Include="Banshee.Collection\ArtistInfo.cs" />
diff --git a/src/Core/Banshee.Core/Makefile.am b/src/Core/Banshee.Core/Makefile.am
index e519743..9884a0c 100644
--- a/src/Core/Banshee.Core/Makefile.am
+++ b/src/Core/Banshee.Core/Makefile.am
@@ -4,10 +4,10 @@ LINK = $(REF_BANSHEE_CORE)
 SOURCES =  \
 	Banshee.Base/CoverArtSpec.cs \
 	Banshee.Base/FileNamePattern.cs \
+	Banshee.Base/LegacyPaths.cs \
 	Banshee.Base/Localization.cs \
 	Banshee.Base/NamingUtil.cs \
 	Banshee.Base/PathPattern.cs \
-	Banshee.Base/Paths.cs \
 	Banshee.Base/PlatformHacks.cs \
 	Banshee.Base/ProductInformation.cs \
 	Banshee.Base/Resource.cs \
diff --git a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
index c8123b0..96b61e5 100644
--- a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
+++ b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
@@ -738,7 +738,7 @@ namespace Banshee.Database
                         WHERE UriType = 1
                           AND PrimarySourceID != ?", library_path, podcast_src_id);
 
-                    string podcast_path = Banshee.Base.Paths.Combine (library_path, "Podcasts");
+                    string podcast_path = Paths.Combine (library_path, "Podcasts");
                     connection.Execute (@"
                         UPDATE CoreTracks SET Uri = BANSHEE_MIGRATE_PARTIAL(?, Uri)
                         WHERE UriType = 1
@@ -1439,7 +1439,7 @@ namespace Banshee.Database
         {
             string library_path = (string)args[0];
             string filename_fragment = (string)args[1];
-            string full_path = Banshee.Base.Paths.Combine (library_path, filename_fragment);
+            string full_path = Paths.Combine (library_path, filename_fragment);
             return Banshee.Base.SafeUri.FilenameToUri (full_path);
         }
     }
diff --git a/src/Core/Banshee.Services/Banshee.Library/Tests/FileNamePatternTests.cs b/src/Core/Banshee.Services/Banshee.Library/Tests/FileNamePatternTests.cs
index 34e9376..35988e8 100644
--- a/src/Core/Banshee.Services/Banshee.Library/Tests/FileNamePatternTests.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/Tests/FileNamePatternTests.cs
@@ -31,6 +31,7 @@
 using System;
 using NUnit.Framework;
 
+using Hyena;
 using Banshee.Base;
 using Banshee.Collection;
 
diff --git a/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs b/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs
index 0a4100b..a26a932 100644
--- a/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs
+++ b/src/Core/Banshee.Services/Banshee.MediaEngine/TranscoderService.cs
@@ -33,6 +33,7 @@ using System.Collections.Generic;
 using Mono.Unix;
 using Mono.Addins;
 
+using Hyena;
 using Hyena.Jobs;
 
 using Banshee.Base;
diff --git a/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs b/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs
index 59c6556..d0ecb3d 100644
--- a/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs
+++ b/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs
@@ -88,7 +88,7 @@ namespace Banshee.MediaProfiles
             profiles = new List<Profile> ();
             preset_variables = new Dictionary<string, PipelineVariable> ();
 
-            string path = Banshee.Base.Paths.GetInstalledDataDirectory ("audio-profiles");
+            string path = Hyena.Paths.GetInstalledDataDirectory ("audio-profiles");
             if(File.Exists(path)) {
                 LoadFromFile(path);
             } else if(Directory.Exists(path)) {
diff --git a/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs b/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
index 3d481fb..25a4b8e 100644
--- a/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
+++ b/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
@@ -99,7 +99,7 @@ namespace Banshee.ServiceStack
 #endif
 
             Catalog.Init (Application.InternalName, System.IO.Path.Combine (
-                Banshee.Base.Paths.InstalledApplicationDataRoot, "locale"));
+                Hyena.Paths.InstalledApplicationDataRoot, "locale"));
 
             if (!DBusConnection.ConnectTried) {
                 DBusConnection.Connect ();
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
index 1e351ef..c4af06a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
@@ -282,7 +282,7 @@ namespace Banshee.Collection.Gui
             var legacy_root_path = CoverArtSpec.LegacyRootPath;
 
             if (version < 1) {
-                string legacy_artwork_path = Paths.Combine (Paths.LegacyApplicationData, "covers");
+                string legacy_artwork_path = Paths.Combine (LegacyPaths.ApplicationData, "covers");
 
                 if (!Directory.Exists (legacy_root_path)) {
                     Directory.Create (legacy_root_path);
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeIconFactory.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeIconFactory.cs
index d80e635..df1903f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeIconFactory.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeIconFactory.cs
@@ -45,7 +45,7 @@ namespace Banshee.Gui
         {
             theme = IconTheme.Default;
 
-            string icon_theme_path = Banshee.Base.Paths.GetInstalledDataDirectory ("icons");
+            string icon_theme_path = Hyena.Paths.GetInstalledDataDirectory ("icons");
             if (Directory.Exists (icon_theme_path)) {
                 Hyena.Log.DebugFormat ("Adding icon theme search path: {0}", icon_theme_path);
                 Theme.AppendSearchPath (icon_theme_path);
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
index 0e3f988..02acde0 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
@@ -43,9 +43,14 @@ namespace Banshee.Gui
 {
     public abstract class GtkBaseClient : Client
     {
+        static GtkBaseClient () {
+            Paths.ApplicationName = Application.InternalName;
+            user_gtkrc = Path.Combine (Paths.ApplicationData, "gtkrc");
+        }
+
         private static Type client_type;
 
-        private static string user_gtkrc = Path.Combine (Paths.ApplicationData, "gtkrc");
+        private static string user_gtkrc;
 
         public static void Startup<T> (string [] args) where T : GtkBaseClient
         {
diff --git a/src/Core/Banshee.ThickClient/Banshee.Library.Gui/PhotoFolderImportSource.cs b/src/Core/Banshee.ThickClient/Banshee.Library.Gui/PhotoFolderImportSource.cs
index 06a6b45..fd87e21 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Library.Gui/PhotoFolderImportSource.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Library.Gui/PhotoFolderImportSource.cs
@@ -30,6 +30,8 @@ using System;
 using Mono.Unix;
 using Gtk;
 
+using Hyena;
+
 using Banshee.Base;
 
 namespace Banshee.Library.Gui
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
index 40942a8..c8de72e 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
@@ -372,7 +372,7 @@ namespace Banshee.Dap.MassStorage
                     // According to the HAL spec, the first folder listed in the audio_folders property
                     // is the folder to write files to.
                     if (AudioFolders.Length > 0) {
-                        write_path = Banshee.Base.Paths.Combine (write_path, AudioFolders[0]);
+                        write_path = Hyena.Paths.Combine (write_path, AudioFolders[0]);
                     }
                 }
                 return write_path;
@@ -388,10 +388,10 @@ namespace Banshee.Dap.MassStorage
                     write_path_video = BaseDirectory;
                     // Some Devices May Have a Separate Video Directory
                     if (VideoFolders.Length > 0) {
-                        write_path_video = Banshee.Base.Paths.Combine (write_path_video, VideoFolders[0]);
+                        write_path_video = Hyena.Paths.Combine (write_path_video, VideoFolders[0]);
                     } else if (AudioFolders.Length > 0) {
-                        write_path_video = Banshee.Base.Paths.Combine (write_path_video, AudioFolders[0]);
-                        write_path_video = Banshee.Base.Paths.Combine (write_path_video, "Videos");
+                        write_path_video = Hyena.Paths.Combine (write_path_video, AudioFolders[0]);
+                        write_path_video = Hyena.Paths.Combine (write_path_video, "Videos");
                     }
                 }
                 return write_path_video;
diff --git a/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/XspfMigrator.cs b/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/XspfMigrator.cs
index 6db686f..345ff92 100644
--- a/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/XspfMigrator.cs
+++ b/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/XspfMigrator.cs
@@ -57,7 +57,7 @@ namespace Banshee.InternetRadio
 
             DatabaseConfigurationClient.Client.Set<bool> ("InternetRadio.LegacyXspfMigrated", true);
 
-            string xspf_path = Paths.Combine (Paths.LegacyApplicationData, "plugins", "stations");
+            string xspf_path = Paths.Combine (LegacyPaths.ApplicationData, "plugins", "stations");
 
             try {
                 foreach (string file in Directory.GetFiles (Paths.Combine (xspf_path, "user"), "*.xspf")) {
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs
index 462c602..a1db32a 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/Queue.cs
@@ -140,7 +140,7 @@ namespace Banshee.Lastfm.Audioscrobbler
 
         public Queue ()
         {
-            string xmlfilepath = Path.Combine (Banshee.Base.Paths.ExtensionCacheRoot, "last.fm");
+            string xmlfilepath = Path.Combine (Hyena.Paths.ExtensionCacheRoot, "last.fm");
             xml_path = Path.Combine (xmlfilepath, "audioscrobbler-queue.xml");
             queue = new List<QueuedTrack> ();
 
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
index 1e636b4..1ef4fbf 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
@@ -105,7 +105,7 @@ namespace Banshee.Lastfm.Radio
 
             // Initialize DataCore's UserAgent and CachePath
             DataCore.UserAgent = Banshee.Web.Browser.UserAgent;
-            DataCore.CachePath = System.IO.Path.Combine (Banshee.Base.Paths.ExtensionCacheRoot, "lastfm");
+            DataCore.CachePath = System.IO.Path.Combine (Hyena.Paths.ExtensionCacheRoot, "lastfm");
 
             // FIXME this is temporary until we split the GUI part from the non-GUI part
             Properties.Set<ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents<LastfmSourceContents> ());
diff --git a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/AmarokPlayerImportSource.cs b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/AmarokPlayerImportSource.cs
index 417fa20..84c6bda 100644
--- a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/AmarokPlayerImportSource.cs
+++ b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/AmarokPlayerImportSource.cs
@@ -33,6 +33,7 @@ using System.IO;
 
 using Mono.Unix;
 
+using Hyena;
 using Hyena.Data.Sqlite;
 
 using Banshee.Base;
diff --git a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs
index 6c5ee94..0e7a17f 100644
--- a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs
+++ b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs
@@ -47,11 +47,11 @@ namespace Banshee.PlayerMigration
 {
     public sealed class RhythmboxPlayerImportSource : ThreadPoolImportSource
     {
-        private static readonly SafeUri rhythmbox_db_uri = new SafeUri (Banshee.Base.Paths.Combine (
+        private static readonly SafeUri rhythmbox_db_uri = new SafeUri (Hyena.Paths.Combine (
             Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".local", "share", "rhythmbox", "rhythmdb.xml"
         ));
 
-        private static readonly SafeUri rhythmbox_db_uri_old = new SafeUri (Banshee.Base.Paths.Combine (
+        private static readonly SafeUri rhythmbox_db_uri_old = new SafeUri (Hyena.Paths.Combine (
             Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".gnome2", "rhythmbox", "rhythmdb.xml"
         ));
 
@@ -88,7 +88,7 @@ namespace Banshee.PlayerMigration
             processed = 0;
 
             // Import Rhythmbox playlists if playlist file is available
-            SafeUri rhythmbox_playlists_uri = new SafeUri (Banshee.Base.Paths.Combine (
+            SafeUri rhythmbox_playlists_uri = new SafeUri (Hyena.Paths.Combine (
                 Environment.GetFolderPath (Environment.SpecialFolder.Personal),
                 ".local", "share", "rhythmbox", "playlists.xml"
             ));
@@ -97,7 +97,7 @@ namespace Banshee.PlayerMigration
 
             // Look at the old location too
             if (!playlists_available) {
-                rhythmbox_playlists_uri = new SafeUri (Banshee.Base.Paths.Combine (
+                rhythmbox_playlists_uri = new SafeUri (Hyena.Paths.Combine (
                     Environment.GetFolderPath (Environment.SpecialFolder.Personal),
                     ".gnome2", "rhythmbox", "playlists.xml"
                 ));
diff --git a/src/Extensions/Banshee.YouTube/Banshee.YouTube.Data/DataFetch.cs b/src/Extensions/Banshee.YouTube/Banshee.YouTube.Data/DataFetch.cs
index bad4de1..8f4a065 100644
--- a/src/Extensions/Banshee.YouTube/Banshee.YouTube.Data/DataFetch.cs
+++ b/src/Extensions/Banshee.YouTube/Banshee.YouTube.Data/DataFetch.cs
@@ -43,7 +43,7 @@ namespace Banshee.YouTube.Data
     {
         private const int CACHE_VERSION = 2;
         public static string UserAgent = Banshee.Web.Browser.UserAgent;
-        public static string CachePath = Path.Combine (Banshee.Base.Paths.ExtensionCacheRoot, "youtube");
+        public static string CachePath = Path.Combine (Paths.ExtensionCacheRoot, "youtube");
         public static TimeSpan NormalCacheTime = TimeSpan.FromHours (2);
 
         private static bool initialized = false;
diff --git a/src/Libraries/Hyena/Hyena.csproj b/src/Libraries/Hyena/Hyena.csproj
index 15d44c9..e558ed1 100644
--- a/src/Libraries/Hyena/Hyena.csproj
+++ b/src/Libraries/Hyena/Hyena.csproj
@@ -87,6 +87,7 @@
     <Compile Include="Hyena.Query\QueryValue.cs" />
     <Compile Include="Hyena.Query\StringQueryValue.cs" />
     <Compile Include="Hyena\Timer.cs" />
+    <Compile Include="Hyena\Paths.cs" />
     <Compile Include="Hyena\DateTimeUtil.cs" />
     <Compile Include="Hyena.SExpEngine\ArithmeticFunctionSet.cs" />
     <Compile Include="Hyena.SExpEngine\CastFunctionSet.cs" />
diff --git a/src/Core/Banshee.Core/Banshee.Base/Paths.cs b/src/Libraries/Hyena/Hyena/Paths.cs
similarity index 85%
rename from src/Core/Banshee.Core/Banshee.Base/Paths.cs
rename to src/Libraries/Hyena/Hyena/Paths.cs
index 1eddc17..ef4831f 100644
--- a/src/Core/Banshee.Core/Banshee.Base/Paths.cs
+++ b/src/Libraries/Hyena/Hyena/Paths.cs
@@ -3,6 +3,7 @@
 //
 // Author:
 //   Aaron Bockover <abockover novell com>
+//   Ruben Vermeersch <ruben savanne be>
 //
 // Copyright (C) 2005-2008 Novell, Inc.
 //
@@ -30,11 +31,7 @@ using System;
 using System.IO;
 using Mono.Unix;
 
-using Hyena;
-
-using Banshee.Configuration.Schema;
-
-namespace Banshee.Base
+namespace Hyena
 {
     public class Paths
     {
@@ -133,33 +130,40 @@ namespace Banshee.Base
                 : null;
         }
 
-        private static string legacy_application_data = Path.Combine (Environment.GetFolderPath (
-            Environment.SpecialFolder.ApplicationData), "banshee");
+        public static string ApplicationData {
+            get; private set;
+        }
 
-        public static string LegacyApplicationData {
-            get { return legacy_application_data; }
+        public static string ApplicationCache {
+            get; private set;
         }
 
-        private static string application_data = Path.Combine (Environment.GetFolderPath (
-            Environment.SpecialFolder.ApplicationData), "banshee-1");
+        private static string application_name = null;
 
-        public static string ApplicationData {
+        public static string ApplicationName {
             get {
-                if (!Directory.Exists (application_data)) {
-                    Directory.CreateDirectory (application_data);
+                if (application_name == null) {
+                    throw new ApplicationException ("Paths.ApplicationName must be set first");
                 }
-
-                return application_data;
+                return application_name;
             }
+            set { application_name = value; InitializePaths (); }
         }
 
-        private static string application_cache = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory (
-            "XDG_CACHE_HOME", ".cache"), "banshee-1");
+        // This can only happen after ApplicationName is set.
+        private static void InitializePaths ()
+        {
+            ApplicationCache = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory (
+                "XDG_CACHE_HOME", ".cache"), ApplicationName);
 
-        public static string ApplicationCache {
-            get { return application_cache; }
+            ApplicationData = Path.Combine (Environment.GetFolderPath (
+                Environment.SpecialFolder.ApplicationData), ApplicationName);
+            if (!Directory.Exists (ApplicationData)) {
+                Directory.CreateDirectory (ApplicationData);
+            }
         }
 
+
         public static string ExtensionCacheRoot {
             get { return Path.Combine (ApplicationCache, "extensions"); }
         }
@@ -188,7 +192,7 @@ namespace Banshee.Base
                     installed_application_prefix = Path.GetDirectoryName (
                         System.Reflection.Assembly.GetExecutingAssembly ().Location);
 
-                    if (Directory.Exists (Paths.Combine (installed_application_prefix, "share", "banshee-1"))) {
+                    if (Directory.Exists (Paths.Combine (installed_application_prefix, "share", ApplicationName))) {
                         return installed_application_prefix;
                     }
 
@@ -208,7 +212,7 @@ namespace Banshee.Base
         }
 
         public static string InstalledApplicationData {
-            get { return Path.Combine (InstalledApplicationDataRoot, "banshee-1"); }
+            get { return Path.Combine (InstalledApplicationDataRoot, ApplicationName); }
         }
 
         public static string GetInstalledDataDirectory (string path)
diff --git a/src/Libraries/Hyena/Makefile.am b/src/Libraries/Hyena/Makefile.am
index 4d15587..6ad4bb3 100644
--- a/src/Libraries/Hyena/Makefile.am
+++ b/src/Libraries/Hyena/Makefile.am
@@ -126,6 +126,7 @@ SOURCES =  \
 	Hyena/EventArgs.cs \
 	Hyena/IUndoAction.cs \
 	Hyena/Log.cs \
+	Hyena/Paths.cs \
 	Hyena/PlatformDetection.cs \
 	Hyena/StringUtil.cs \
 	Hyena/Tests/CryptoUtilTests.cs \



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