banshee r3438 - in trunk/banshee: . src src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.Library src/Extensions/Banshee.Lastfm src/Libraries/Hyena/Hyena.Data.Sqlite



Author: gburt
Date: Thu Mar 13 02:16:52 2008
New Revision: 3438
URL: http://svn.gnome.org/viewvc/banshee?rev=3438&view=rev

Log:
2008-03-12  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs:
	* src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs:
	Rename LibraryAlbumInfo to DatabaseAlbumInfo.

	* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
	Change all DateTime.MinValue stamps to NULL.

	* src/Extensions/Banshee.Lastfm/Makefile.am: Alphabetize.

	* src/Libraries/Hyena/Hyena.Data.Sqlite/DatabaseColumn.cs:
	* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs:
	* src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs: Serialize and
	unserialze DateTime.MinValue as NULL.

	* src/nuke-core-tables: Update to new config subdir.


Added:
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
      - copied, changed from r3427, /trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
Removed:
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.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/Extensions/Banshee.Lastfm/Makefile.am
   trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/DatabaseColumn.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
   trunk/banshee/src/nuke-core-tables

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs	Thu Mar 13 02:16:52 2008
@@ -41,8 +41,8 @@
 {
     public class AlbumListDatabaseModel : AlbumListModel, ICacheableDatabaseModel
     {
-        private readonly BansheeModelProvider<LibraryAlbumInfo> provider;
-        private readonly BansheeModelCache<LibraryAlbumInfo> cache;
+        private readonly BansheeModelProvider<DatabaseAlbumInfo> provider;
+        private readonly BansheeModelCache<DatabaseAlbumInfo> cache;
         private readonly TrackListDatabaseModel track_model;
         private readonly ArtistListDatabaseModel artist_model;
         private long count;
@@ -53,8 +53,8 @@
         
         public AlbumListDatabaseModel (BansheeDbConnection connection, string uuid)
         {
-            provider = LibraryAlbumInfo.Provider;
-            cache = new BansheeModelCache <LibraryAlbumInfo> (connection, uuid, this, provider);
+            provider = DatabaseAlbumInfo.Provider;
+            cache = new BansheeModelCache <DatabaseAlbumInfo> (connection, uuid, this, provider);
             cache.HasSelectAllItem = true;
 
             Selection.Changed += HandleSelectionChanged;

Copied: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs (from r3427, /trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs)
==============================================================================
--- /trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs	Thu Mar 13 02:16:52 2008
@@ -1,5 +1,5 @@
 //
-// LibraryAlbumInfo.cs
+// DatabaseAlbumInfo.cs
 //
 // Author:
 //   Aaron Bockover <abockover novell com>
@@ -38,13 +38,13 @@
 
 namespace Banshee.Collection.Database
 {
-    public class LibraryAlbumInfo : AlbumInfo, ICacheableItem
+    public class DatabaseAlbumInfo : AlbumInfo, ICacheableItem
     {
-        private static BansheeModelProvider<LibraryAlbumInfo> provider = new BansheeModelProvider<LibraryAlbumInfo> (
+        private static BansheeModelProvider<DatabaseAlbumInfo> provider = new BansheeModelProvider<DatabaseAlbumInfo> (
             ServiceManager.DbConnection, "CoreAlbums"
         );
 
-        public static BansheeModelProvider<LibraryAlbumInfo> Provider {
+        public static BansheeModelProvider<DatabaseAlbumInfo> Provider {
             get { return provider; }
         }
 
@@ -58,19 +58,19 @@
             ArtistName
         }
 
-        public static LibraryAlbumInfo FindOrCreate (LibraryArtistInfo artist, string title)
+        public static DatabaseAlbumInfo FindOrCreate (LibraryArtistInfo artist, string title)
         {
-            LibraryAlbumInfo album;
+            DatabaseAlbumInfo album;
 
             if (title == null || title.Trim () == String.Empty)
                 title = Catalog.GetString ("Unknown Album");
 
             using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.DbId, title)) {
                 if (reader.Read ()) {
-                    album = new LibraryAlbumInfo (reader);
+                    album = new DatabaseAlbumInfo (reader);
                     album.ArtistName = artist.Name;
                 } else {
-                    album = new LibraryAlbumInfo ();
+                    album = new DatabaseAlbumInfo ();
                     album.Title = title;
                     album.ArtistId = artist.DbId;
                     album.ArtistName = artist.Name;
@@ -80,11 +80,11 @@
             return album;
         }
 
-        public LibraryAlbumInfo () : base (null)
+        public DatabaseAlbumInfo () : base (null)
         {
         }
 
-        protected LibraryAlbumInfo (IDataReader reader) : base (null)
+        protected DatabaseAlbumInfo (IDataReader reader) : base (null)
         {
             LoadFromReader (reader);
         }

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	Thu Mar 13 02:16:52 2008
@@ -394,11 +394,11 @@
             set { 
                 ModelHelper.BuildIdFilter<AlbumInfo> (value, "CoreTracks.AlbumID", album_id_filter_query,
                     delegate (AlbumInfo album) {
-                        if (!(album is LibraryAlbumInfo)) {
+                        if (!(album is DatabaseAlbumInfo)) {
                             return null;
                         }
                         
-                        return ((LibraryAlbumInfo)album).DbId.ToString ();
+                        return ((DatabaseAlbumInfo)album).DbId.ToString ();
                     },
                 
                     delegate (string new_filter) {

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	Thu Mar 13 02:16:52 2008
@@ -476,6 +476,8 @@
                         FROM Tracks
             ");
 
+            Execute ("update coretracks set lastplayedstamp = NULL where lastplayedstamp = -62135575200");
+
             Execute(@"
                 INSERT INTO CorePlaylists (PlaylistID, Name, SortColumn, SortType)
                     SELECT * FROM Playlists

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	Thu Mar 13 02:16:52 2008
@@ -134,7 +134,7 @@
                 }
 
                 LibraryArtistInfo artist = LibraryArtistInfo.FindOrCreate (track.ArtistName);
-                LibraryAlbumInfo album = LibraryAlbumInfo.FindOrCreate (artist, track.AlbumTitle);
+                DatabaseAlbumInfo album = DatabaseAlbumInfo.FindOrCreate (artist, track.AlbumTitle);
 
                 track.DateAdded = DateTime.Now;
                 track.PrimarySource = ServiceManager.SourceManager.Library;

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am	Thu Mar 13 02:16:52 2008
@@ -22,9 +22,9 @@
 	Resources/AudioscrobblerMenu.xml \
 	Resources/GlobalUI.xml \
 	Resources/lastfm.glade \
-	Resources/recommended.png \
 	Resources/neighbour.png \
 	Resources/personal.png \
+	Resources/recommended.png \
 	Resources/tag.png
 
 include $(top_srcdir)/build/build.mk

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/DatabaseColumn.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/DatabaseColumn.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/DatabaseColumn.cs	Thu Mar 13 02:16:52 2008
@@ -93,6 +93,10 @@
                 result = !reader.IsDBNull (column)
                     ? reader.GetInt32 (column)
                     : 0;
+            } else if (type == typeof (int)) {
+                result = !reader.IsDBNull (column)
+                    ? Convert.ToInt64 (reader.GetValue (column))
+                    : Int64.MinValue;
             } else {
                 result = !reader.IsDBNull (column)
                     ? Convert.ToInt64 (reader.GetValue (column))

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs	Thu Mar 13 02:16:52 2008
@@ -150,7 +150,12 @@
                 if (param_values[i] is string) {
                     param_values[i] = String.Format ("'{0}'", (param_values[i] as string).Replace ("'", "''"));
                 } else if (param_values[i] is DateTime) {
-                    param_values[i] = DateTimeUtil.FromDateTime ((DateTime) param_values[i]);
+                    DateTime dt = (DateTime) param_values[i];
+                    if (dt == DateTime.MinValue) {
+                        param_values[i] = "NULL";
+                    } else {
+                        DateTimeUtil.FromDateTime ((DateTime) param_values[i]);
+                    }
                 } else if (param_values[i] == null) {
                     param_values[i] = "NULL";
                 }

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs	Thu Mar 13 02:16:52 2008
@@ -49,7 +49,11 @@
         public static object ToDbFormat (Type type, object value)
         {
             if (type == typeof (DateTime)) {
-                value = DateTimeUtil.FromDateTime ((DateTime)value);
+                if (DateTime.MinValue.Equals (value)) {
+                    value = "NULL";
+                } else { 
+                    value = DateTimeUtil.FromDateTime ((DateTime)value);
+                }
             } else if (type == typeof (TimeSpan)) {
                 value = ((TimeSpan)value).TotalMilliseconds;
             }
@@ -59,7 +63,7 @@
         public static object FromDbFormat (Type type, object value)
         {
             if (type == typeof (DateTime)) {
-                value = DateTimeUtil.ToDateTime ((long)value);
+                value = Int64.MinValue.Equals (value) ? DateTime.MinValue : DateTimeUtil.ToDateTime ((long) value);
             } else if (type == typeof (TimeSpan)) {
                 value = TimeSpan.FromMilliseconds ((long)value);
             }

Modified: trunk/banshee/src/nuke-core-tables
==============================================================================
--- trunk/banshee/src/nuke-core-tables	(original)
+++ trunk/banshee/src/nuke-core-tables	Thu Mar 13 02:16:52 2008
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-DB_FILE="$HOME/.config/banshee/banshee.db"
+DB_FILE="$HOME/.config/banshee-1/banshee.db"
 test ! -z $1 -a -e $1 && DB_FILE=$1
 
 for table in $(sqlite3 $DB_FILE 'select name from sqlite_master;' | egrep '^sqlite_autoindex|^Core'); do



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