banshee r2966 - in trunk/banshee: . src/Core/Banshee.Core src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Core/Banshee.Collection src/Core/Banshee.Core/Banshee.IO src/Core/Banshee.Core/Banshee.Streaming src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Hyena src/Core/Hyena/Hyena.Data.Query



Author: abock
Date: Sat Jan 12 00:25:14 2008
New Revision: 2966
URL: http://svn.gnome.org/viewvc/banshee?rev=2966&view=rev

Log:
2008-01-11  Aaron Bockover  <abockover novell com>

    * src/Core/Banshee.Core/Banshee.Base/Paths.cs: Added
    MakePathRelativeToLibrary to extract the relative path from a URI for
    storing into the DB

    * src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs: Added FileSize
    and DiscNumber properties

    * src/Core/Banshee.Core/Banshee.IO/Interfaces.cs:
    * src/Core/Banshee.Core/Banshee.IO/SystemIO.cs:
    * src/Core/Banshee.Core/Banshee.IO/Unix.cs:
    * src/Core/Banshee.Core/Banshee.IO/GnomeVfs.cs: Added File.GetSize

    * src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs: Use
    Banshee.IO.IOProxy.File.GetSize to set TrackInfo.FileSize

    * src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs:
    Perform two path checks (relative and absolute) in ContainsUri; support
    FileSize and DiscNumber properties

    * src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
    Added FileSize and DiscNumber columns to CoreTracks

    * src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs:
    Some minor update

    * src/Core/Hyena/Hyena.Data.Query/QueryField.cs: Added term modifier
    support for handling special strings like '50MB' or 'yesterday'

    * src/Core/Hyena/Hyena.Data.Query/QueryTermNode.cs: Fix EmitNumericMatch
    and EmitStringMatch to use the new QueryField.Modifier support; fix
    parsing in EmitNumericMatch to support 64 bit integers which are useful
    for times and file sizes

    * src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs:
    Implemented FileSizeModifier and DateTimeModifier methods to support
    nice file size and date/time string formats like '40MB'; added three
    new fields (FileSize, DateAddedStamp, LastPlayedStamp)

    * src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs:
    * src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs:
    Change references from CoreTracks.RelativeUri to CoreTracks.Uri



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp
   trunk/banshee/src/Core/Banshee.Core/Banshee.IO/GnomeVfs.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Interfaces.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.IO/SystemIO.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Unix.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
   trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryField.cs
   trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryTermNode.cs
   trunk/banshee/src/Core/Hyena/Hyena.mdp
   trunk/banshee/src/Core/Hyena/Makefile.am

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	Sat Jan 12 00:25:14 2008
@@ -101,6 +101,19 @@
             
             return result;
         }
+        
+        public static string MakePathRelativeToLibrary (string path)
+        {
+            string library_location = LibraryLocation; // TODO: Use CachedLibraryLocation?
+            
+            if (path.Length < library_location.Length + 1) {
+                return null;
+            }
+            
+            return path.StartsWith (library_location)
+                ? path.Substring (library_location.Length + 1)
+                : null;
+        }
     
         public static string LegacyApplicationData {
             get {
@@ -121,11 +134,7 @@
         }
         
         public static string DefaultLibraryPath {
-            get { 
-                string dir = ReadXdgUserDir ("XDG_MUSIC_DIR", "Music");
-                Directory.CreateDirectory (dir);
-                return dir;
-            }
+            get { return ReadXdgUserDir ("XDG_MUSIC_DIR", "Music"); }
         }
         
         public static string TempDir {

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs	Sat Jan 12 00:25:14 2008
@@ -42,6 +42,7 @@
         private SafeUri uri;
         private SafeUri more_info_uri;
         private string mimetype;
+        private long filesize;
 
         private string artist_name;
         private string album_title;
@@ -50,6 +51,7 @@
 
         private int track_number;
         private int track_count;
+        private int disc_number;
         private int year;
         private int rating;
 
@@ -111,6 +113,11 @@
             set { mimetype = value; }
         }
 
+        public long FileSize {
+            get { return filesize; }
+            set { filesize = value; }
+        }
+
         public virtual string ArtistName {
             get { return artist_name; }
             set { artist_name = value; }
@@ -169,6 +176,11 @@
             set { track_count = value; }
         }
 
+        public virtual int DiscNumber {
+            get { return disc_number; }
+            set { disc_number = value; }
+        }
+
         public virtual int Year {
             get { return year; }
             set { year = value; }

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	Sat Jan 12 00:25:14 2008
@@ -59,6 +59,8 @@
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="False" refto="Hyena" />
+    <ProjectReference type="Gac" localcopy="True" refto="TagLib, Version=0.0.0.0, Culture=neutral" />
+    <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
   </References>
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
     <BuildFilesVar Sync="True" Name="SOURCES" />

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.IO/GnomeVfs.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.IO/GnomeVfs.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.IO/GnomeVfs.cs	Sat Jan 12 00:25:14 2008
@@ -113,6 +113,11 @@
             
             return new VfsStream(uri.AbsoluteUri, System.IO.FileMode.Create);
         }
+        
+        public long GetSize (SafeUri uri)
+        {
+            return 0;
+        }
     }
 
     public class Directory : IDirectory

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Interfaces.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Interfaces.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Interfaces.cs	Sat Jan 12 00:25:14 2008
@@ -50,6 +50,7 @@
         void Move(SafeUri from, SafeUri to);
         System.IO.Stream OpenRead(SafeUri uri);
         System.IO.Stream OpenWrite(SafeUri uri, bool overwrite);
+        long GetSize (SafeUri uri);
     }
     
     public interface IDirectory

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.IO/SystemIO.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.IO/SystemIO.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.IO/SystemIO.cs	Sat Jan 12 00:25:14 2008
@@ -75,6 +75,15 @@
                 ? System.IO.File.Open(uri.LocalPath, FileMode.Create, FileAccess.ReadWrite)
                 : System.IO.File.OpenWrite(uri.LocalPath);
         }
+
+        public long GetSize (SafeUri uri)
+        {
+            try {
+                return new System.IO.FileInfo (uri.LocalPath).Length;
+            } catch {
+                return -1;
+            }
+        }
     }
 
     public class Directory : IDirectory

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Unix.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Unix.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.IO/Unix.cs	Sat Jan 12 00:25:14 2008
@@ -105,6 +105,17 @@
                 ? new UnixFileInfo(uri.LocalPath).Open(FileMode.Create, FileAccess.ReadWrite, FilePermissions.DEFFILEMODE)
                 : new UnixFileInfo(uri.LocalPath).OpenWrite();
         }
+        
+        public long GetSize (SafeUri uri)
+        {
+            try {
+                Mono.Unix.Native.Stat stat;
+                Mono.Unix.Native.Syscall.lstat (uri.LocalPath, out stat);
+                return stat.st_size;
+            } catch {
+                return -1;
+            }
+        }
     }
 
     public class Directory : IDirectory

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs	Sat Jan 12 00:25:14 2008
@@ -55,6 +55,7 @@
         public static void TrackInfoMerge(TrackInfo track, TagLib.File file)
         {
             track.Uri = new SafeUri (file.Name);
+            track.MimeType = file.MimeType;
             track.ArtistName = Choose(file.Tag.JoinedPerformers, track.ArtistName);
             track.AlbumTitle = Choose(file.Tag.Album, track.AlbumTitle);
             track.TrackTitle = Choose(file.Tag.Title, track.TrackTitle);
@@ -62,9 +63,8 @@
             track.TrackNumber = file.Tag.Track == 0 ? track.TrackNumber : (int)file.Tag.Track;
             track.TrackCount = file.Tag.TrackCount == 0 ? track.TrackCount : (int)file.Tag.TrackCount;
             track.Year = (int)file.Tag.Year;
-            track.MimeType = file.MimeType;
-            
             track.Duration = file.Properties.Duration;
+            track.FileSize = Banshee.IO.IOProxy.File.GetSize (track.Uri);
         }
     
         public static void TrackInfoMerge(TrackInfo track, StreamTag tag)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs	Sat Jan 12 00:25:14 2008
@@ -29,6 +29,7 @@
 using System;
 using System.Data;
 
+using Banshee.IO;
 using Banshee.Base;
 using Banshee.Database;
 using Banshee.ServiceStack;
@@ -43,11 +44,14 @@
             AlbumID,
             TagSetID,
             MusicBrainzID,
-            RelativeUri,
+            Uri,
+            UriType,
             MimeType,
+            FileSize,
             Title,
             TrackNumber,
             TrackCount,
+            DiscNumber,
             Duration,
             Year,
             Rating,
@@ -62,6 +66,12 @@
             AlbumTitle
         }
         
+        private enum UriType : int {
+            AbsolutePath,
+            RelativePath,
+            AbsoluteUri
+        }
+        
         private int dbid;
         private int db_index;
 
@@ -83,7 +93,15 @@
         {
             dbid = ReaderGetInt32 (reader, Column.TrackID);
             
-            Uri = new SafeUri (ReaderGetString (reader, Column.RelativeUri));
+            string uri = ReaderGetString (reader, Column.Uri);
+            UriType uri_type = (UriType)ReaderGetInt32 (reader, Column.UriType);
+            
+            if (uri_type == UriType.RelativePath) {
+                uri = System.IO.Path.Combine (Paths.LibraryLocation, uri);
+            }
+            
+            Uri = new SafeUri (uri);
+            FileSize = ReaderGetInt64 (reader, Column.FileSize);
             
             ArtistName = ReaderGetString (reader, Column.Artist);
             ArtistId = ReaderGetInt32 (reader, Column.ArtistID);
@@ -111,26 +129,31 @@
 
         private string ReaderGetString (IDataReader reader, Column column)
         {
-            int column_id = (int) column;
+            int column_id = (int)column;
             return !reader.IsDBNull (column_id) 
                 ? String.Intern (reader.GetString (column_id)) 
                 : null;
         }
-
+        
         private int ReaderGetInt32 (IDataReader reader, Column column)
         {
-            return reader.GetInt32 ((int) column);
+            return reader.GetInt32 ((int)column);
+        }
+
+        private long ReaderGetInt64 (IDataReader reader, Column column)
+        {
+            return reader.GetInt64 ((int)column);
         }
 
         private TimeSpan ReaderGetTimeSpan (IDataReader reader, Column column)
         {
-            long raw = reader.GetInt64 ((int) column);
+            long raw = reader.GetInt64 ((int)column);
             return new TimeSpan (raw * TimeSpan.TicksPerMillisecond);
         }
 
         private DateTime ReaderGetDateTime (IDataReader reader, Column column)
         {
-            long raw = reader.GetInt64 ((int) column);
+            long raw = reader.GetInt64 ((int)column);
             return DateTimeUtil.ToDateTime (raw);
         }
 
@@ -151,11 +174,16 @@
                 AlbumId,
                 -1, // TagSetID
                 null, // MusicBrainzID
-                Uri == null ? null : Uri.AbsoluteUri, // RelativeUri
+                Uri == null ? null : 
+                    (Paths.MakePathRelativeToLibrary (Uri.AbsolutePath) 
+                        ?? Uri.AbsoluteUri),
+                UriType.RelativePath,
                 MimeType,
+                FileSize,
                 TrackTitle,
                 TrackNumber,
                 TrackCount,
+                DiscNumber,
                 Duration.TotalMilliseconds,
                 Year,
                 Rating,
@@ -176,11 +204,16 @@
                 AlbumId,
                 -1, // TagSetID
                 null, // MusicBrainzID
-                Uri == null ? null : Uri.AbsoluteUri, // RelativeUri
+                Uri == null ? null : 
+                    (Paths.MakePathRelativeToLibrary (Uri.AbsolutePath) 
+                        ?? Uri.AbsoluteUri),
+                UriType.RelativePath,
                 MimeType,
+                FileSize,
                 TrackTitle,
                 TrackNumber,
                 TrackCount,
+                DiscNumber,
                 Duration.TotalMilliseconds,
                 Year,
                 Rating,
@@ -215,10 +248,14 @@
             set { album_id = value; }
         }
 
-        private static BansheeDbCommand check_command = new BansheeDbCommand ("SELECT COUNT(*) FROM CoreTracks WHERE RelativeUri = ?", 1);
-        public static bool ContainsPath (string path)
+        private static BansheeDbCommand check_command = new BansheeDbCommand (
+            "SELECT COUNT(*) FROM CoreTracks WHERE Uri = ? OR Uri = ?", 2);
+            
+        public static bool ContainsUri (SafeUri uri)
         {
-            return Convert.ToInt32 (ServiceManager.DbConnection.ExecuteScalar (check_command.ApplyValues (path))) > 0;
+            string relative_path = Paths.MakePathRelativeToLibrary (uri.AbsolutePath) ?? uri.AbsoluteUri;
+            return Convert.ToInt32 (ServiceManager.DbConnection.ExecuteScalar (
+                check_command.ApplyValues (relative_path, uri.AbsoluteUri))) > 0;
         }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs	Sat Jan 12 00:25:14 2008
@@ -36,6 +36,7 @@
 using Hyena.Data;
 using Hyena.Data.Query;
 
+using Banshee.Base;
 using Banshee.Database;
 
 namespace Banshee.Collection.Database
@@ -110,7 +111,7 @@
             sort_query = GetSort (sort_column.SortKey, AscDesc ());
         }
 
-        private const string default_sort = "lower(CoreArtists.Name) ASC, lower(CoreAlbums.Title) ASC, CoreTracks.TrackNumber ASC, CoreTracks.RelativeUri ASC";
+        private const string default_sort = "lower(CoreArtists.Name) ASC, lower(CoreAlbums.Title) ASC, CoreTracks.TrackNumber ASC, CoreTracks.Uri ASC";
         public static string GetSort (string key, string ascDesc)
         {
             string sort_query = null;
@@ -127,7 +128,7 @@
                         lower(CoreArtists.Name) {0}, 
                         lower(CoreAlbums.Title) ASC, 
                         CoreTracks.TrackNumber ASC,
-                        CoreTracks.RelativeUri ASC", ascDesc); 
+                        CoreTracks.Uri ASC", ascDesc); 
                     break;
 
                 case "Album":
@@ -135,7 +136,7 @@
                         lower(CoreAlbums.Title) {0},
                         lower(CoreArtists.Name) ASC,
                         CoreTracks.TrackNumber ASC,
-                        CoreTracks.RelativeUri ASC", ascDesc); 
+                        CoreTracks.Uri ASC", ascDesc); 
                     break;
 
                 case "Title":
@@ -156,7 +157,7 @@
                 case "SkipCount":
                 case "LastPlayedStamp":
                 case "DateAddedStamp":
-                case "RelativeUri":
+                case "Uri":
                     sort_query = String.Format (
                         "CoreTracks.{0} {1}, {2}",
                         key, ascDesc, default_sort
@@ -445,15 +446,65 @@
                 Catalog.GetString ("skips"), Catalog.GetString ("skipcount")
             ),
             new QueryField (
-                Catalog.GetString ("File Path"), "CoreTracks.RelativeUri", QueryFieldType.Text,
+                Catalog.GetString ("File Size"), "CoreTracks.FileSize", QueryFieldType.Numeric, FileSizeModifier,
                 // Translators: These are search fields.  Please, no spaces. Duplicates ok.
-                Catalog.GetString ("path"), Catalog.GetString ("file")
+                Catalog.GetString ("size"), Catalog.GetString ("filesize")
+            ),
+            new QueryField (
+                Catalog.GetString ("File Path"), "CoreTracks.Uri", QueryFieldType.Text,
+                // Translators: These are search fields.  Please, no spaces. Duplicates ok.
+                Catalog.GetString ("path"), Catalog.GetString ("file"), Catalog.GetString ("uri")
             ),
             new QueryField (
                 Catalog.GetString ("Mime Type"), "CoreTracks.MimeType", QueryFieldType.Text,
                 // Translators: These are search fields.  Please, no spaces. Duplicates ok.
                 Catalog.GetString ("type"), Catalog.GetString ("mimetype"), Catalog.GetString ("format")
+            ),
+            new QueryField (
+                Catalog.GetString ("Last Played Date"), "CoreTracks.LastPlayedStamp", QueryFieldType.Numeric, DateTimeModifier,
+                // Translators: These are search fields.  Please, no spaces. Duplicates ok.
+                Catalog.GetString ("lastplayed"), Catalog.GetString ("played")
+            ),
+            new QueryField (
+                Catalog.GetString ("Imported Date"), "CoreTracks.DateAddedStamp", QueryFieldType.Numeric, DateTimeModifier,
+                // Translators: These are search fields.  Please, no spaces. Duplicates ok.
+                Catalog.GetString ("addedon"), Catalog.GetString ("dateadded"), Catalog.GetString ("importedon")
             )
         );
+        
+        private static string FileSizeModifier (string input)
+        {
+            long value = 0;
+            
+            if (input.Length < 2) {
+                return input;
+            } else if (input[input.Length - 1] == 'b' || input[input.Length - 1] == 'B') {
+                input = input.Substring (0, input.Length - 1);
+            }
+            
+            if (!Int64.TryParse (input.Substring (0, input.Length - 1), out value)) {
+                return input;
+            }
+            
+            switch (input[input.Length - 1]) {
+                case 'k': case 'K': value *= 1024; break;
+                case 'm': case 'M': value *= 1048576; break;
+                case 'g': case 'G': value *= 1073741824; break;
+                case 't': case 'T': value *= 1099511627776; break;
+                default: break;
+            }
+            
+            return Convert.ToString (value);
+        }
+        
+        private static string DateTimeModifier (string input)
+        {
+            // TODO: Add support for relative strings like "yesterday", "3 weeks ago", "5 days ago"
+            try {
+                return DateTimeUtil.ToTimeT (DateTime.Parse (input)).ToString ();
+            } catch {
+                return "0";
+            }
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	Sat Jan 12 00:25:14 2008
@@ -235,8 +235,6 @@
             ", CURRENT_VERSION));
             
             // TODO add these:
-            // DiscNumber (Grouping)
-            // FileSize
             // Comment
             // Composer
             // Copyright
@@ -256,12 +254,15 @@
                     
                     MusicBrainzID       TEXT,
 
-                    RelativeUri         TEXT,
+                    Uri                 TEXT,
+                    UriType             INTEGER,
                     MimeType            TEXT,
+                    FileSize            INTEGER,
                     
                     Title               TEXT,
                     TrackNumber         INTEGER,
                     TrackCount          INTEGER,
+                    DiscNumber          INTEGER,
                     Duration            INTEGER,
                     Year                INTEGER,
 
@@ -396,10 +397,13 @@
                         0,
                         null,
                         Uri,
+                        0,
                         MimeType,
+                        0,
                         Title,
                         TrackNumber,
                         TrackCount,
+                        0,
                         Duration * 1000,
                         Year,
                         Rating,
@@ -424,6 +428,9 @@
                 INSERT INTO CoreSmartPlaylists (SmartPlaylistID, Name, Condition, OrderBy, LimitNumber, LimitCriterion)
                     SELECT * FROM SmartPlaylists
             ");
+            
+            // TODO: Kick off some kind of scanner to find the file size of all the files
+            //       since that information was never in the old Banshee
         }
         
 #endregion

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs	Sat Jan 12 00:25:14 2008
@@ -95,8 +95,7 @@
             try {
                 SafeUri uri = new SafeUri (path);
 
-                if (LibraryTrackInfo.ContainsPath (uri.AbsoluteUri)) {
-                    //LogError (path, Catalog.GetString ("Track already in Library"));
+                if (LibraryTrackInfo.ContainsUri (uri)) {
                     IncrementProcessedCount (null);
                     return;
                 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	Sat Jan 12 00:25:14 2008
@@ -174,7 +174,7 @@
 
             BansheeDbCommand command = new BansheeDbCommand (
                 @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
-                    VALUES (?, (SELECT TrackID FROM CoreTracks WHERE RelativeUri = ?))", 2
+                    VALUES (?, (SELECT TrackID FROM CoreTracks WHERE Uri = ?))", 2
             );
 
             foreach (string uri in uris) {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs	Sat Jan 12 00:25:14 2008
@@ -60,7 +60,7 @@
                 //new SortableColumn("Rating", new RatingColumnCell(null, true), 0.15, "Rating"),
                 new SortableColumn("Last Played", new ColumnCellDateTime("LastPlayed", true), 0.15, "LastPlayedStamp"),
                 new SortableColumn("Added", new ColumnCellDateTime("DateAdded", true), 0.15, "DateAddedStamp"),
-                new SortableColumn("Location", new ColumnCellText("Uri", true), 0.15, "RelativeUri")
+                new SortableColumn("Location", new ColumnCellText("Uri", true), 0.15, "Uri")
             );
             
             ColumnController = DefaultColumnController;

Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryField.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryField.cs	(original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryField.cs	Sat Jan 12 00:25:14 2008
@@ -1,10 +1,11 @@
 //
 // QueryField.cs
 //
-// Author:
+// Authors:
 //   Gabriel Burt <gburt novell com>
+//   Aaron Bockover <abockover novell com>
 //
-// Copyright (C) 2007 Novell, Inc.
+// Copyright (C) 2007-2008 Novell, Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -37,25 +38,41 @@
         Text,
         Numeric
     }
-
+    
     public class QueryField
     {
+        public delegate string ModifierHandler (string input);
+
         public string Name;
         public string [] Aliases;
         public string Column;
         public bool Default;
         public QueryFieldType QueryFieldType;
+        public ModifierHandler Modifier;
 
-        public QueryField (string name, string column, QueryFieldType type, params string [] aliases) : this (name, column, type, false, aliases)
+        public QueryField (string name, string column, QueryFieldType type, params string [] aliases) 
+            : this (name, column, type, false, null, aliases)
         {
         }
-
+        
+        public QueryField (string name, string column, QueryFieldType type, ModifierHandler modifier, params string [] aliases) 
+            : this (name, column, type, false, modifier, aliases)
+        {
+        }
+        
         public QueryField (string name, string column, QueryFieldType type, bool isDefault, params string [] aliases)
+            : this (name, column, type, isDefault, null, aliases)
+        {
+        }
+        
+        public QueryField (string name, string column, QueryFieldType type, bool isDefault, 
+            ModifierHandler modifier, params string [] aliases)
         {
             Name = name;
             Column = column;
             QueryFieldType = type;
             Default = isDefault;
+            Modifier = modifier;
             Aliases = aliases;
         }
 

Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryTermNode.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryTermNode.cs	(original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Query/QueryTermNode.cs	Sat Jan 12 00:25:14 2008
@@ -181,56 +181,61 @@
         private bool EmitTermMatch (StringBuilder sb, QueryField field, bool emit_or)
         {
             if (field.QueryFieldType == QueryFieldType.Text)
-                return EmitStringMatch(sb, field.Column, emit_or);
+                return EmitStringMatch(sb, field, emit_or);
             else
-                return EmitNumericMatch(sb, field.Column, emit_or);
+                return EmitNumericMatch(sb, field, emit_or);
         }
 
-        private bool EmitStringMatch(StringBuilder sb, string field, bool emit_or)
+        private bool EmitStringMatch(StringBuilder sb, QueryField field, bool emit_or)
         {
-            string safe_value = Value.Replace("'", "''");
+            string safe_value = (field.Modifier == null ? Value : field.Modifier (Value)).Replace("'", "''");
             
             if (emit_or)
                 sb.Append (" OR ");
 
             switch (Operator.UserOperator) {
-                case "=": // Treat as starts with
-                case "==":
-                    sb.AppendFormat("{0} LIKE '{1}%'", field, safe_value);
+                case "=": // Starts with
+                    sb.AppendFormat("{0} LIKE '{1}%'", field.Column, safe_value);
+                    break;
+                    
+                case "==": // Equal to
+                    sb.AppendFormat("{0} LIKE '{1}'", field.Column, safe_value);
                     break;
 
                 case ":": // Contains
                 default:
-                    sb.AppendFormat("{0} LIKE '%{1}%'", field, safe_value);
+                    sb.AppendFormat("{0} LIKE '%{1}%'", field.Column, safe_value);
                     break;
             }
 
             return true;
         }
 
-        private bool EmitNumericMatch(StringBuilder sb, string field, bool emit_or)
+        private bool EmitNumericMatch(StringBuilder sb, QueryField field, bool emit_or)
         {
-            try {
-                // TODO could add a handler to the Field class so we could preprocess
-                // date queries (and turn them into numbers), etc..
-                int num = Convert.ToInt32 (Value);
-                if (emit_or)
-                    sb.Append (" OR ");
-
-                switch (Operator.UserOperator) {
-                    case ":":
-                    case "=":
-                    case "==":
-                        sb.AppendFormat("{0} = {1}", field, num);
-                        break;
-
-                    default:
-                        sb.AppendFormat("{0} {2} {1}", field, num, Operator.UserOperator);
-                        break;
-                }
-                return true;
-            } catch {}
-            return false;
+            long num = 0;
+            
+            if (!Int64.TryParse (field.Modifier == null ? Value : field.Modifier (Value), out num)) {
+                return false;
+            }
+            
+            if (emit_or) {
+                sb.Append (" OR ");
+            }
+            
+            switch (Operator.UserOperator) {
+                case ":":
+                case "=":
+                case "==":
+                    sb.AppendFormat("{0} = {1}", field.Column, num);
+                    break;
+
+                default:
+                    sb.AppendFormat("{0} {2} {1}", field.Column, num, Operator.UserOperator);
+                    break;
+            }
+            
+            return true;
         }
         
         public string Value {

Modified: trunk/banshee/src/Core/Hyena/Hyena.mdp
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.mdp	(original)
+++ trunk/banshee/src/Core/Hyena/Hyena.mdp	Sat Jan 12 00:25:14 2008
@@ -39,6 +39,7 @@
     <File name="Hyena.Collections/SelectionProxy.cs" subtype="Code" buildaction="Compile" />
     <File name="Hyena.Data.Query/QueryField.cs" subtype="Code" buildaction="Compile" />
     <File name="Hyena.Data.Query/UserQueryParser.cs" subtype="Code" buildaction="Compile" />
+    <File name="Hyena.Data.Query/XmlQueryParser.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Modified: trunk/banshee/src/Core/Hyena/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Hyena/Makefile.am	(original)
+++ trunk/banshee/src/Core/Hyena/Makefile.am	Sat Jan 12 00:25:14 2008
@@ -18,8 +18,8 @@
 	Hyena.Data.Query/QueryParser.cs \
 	Hyena.Data.Query/QueryTermNode.cs \
 	Hyena.Data.Query/QueryToken.cs \
-	Hyena.Data.Query/XmlQueryParser.cs \
 	Hyena.Data.Query/UserQueryParser.cs \
+	Hyena.Data.Query/XmlQueryParser.cs \
 	Hyena.Data/CacheableModelAdapter.cs \
 	Hyena.Data/ColumnDescription.cs \
 	Hyena.Data/ICacheableModel.cs \



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