banshee r3061 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Base 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.Services/Banshee.SmartPlaylist src/Core/Hyena/Hyena.Data.Sqlite



Author: gburt
Date: Sun Jan 27 22:54:29 2008
New Revision: 3061
URL: http://svn.gnome.org/viewvc/banshee?rev=3061&view=rev

Log:
2008-01-27  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Core/Banshee.Base/Log.cs: Make ms always 3 digits.

	* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs:
	* src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs:
	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs:
	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs:
	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs:
	* src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs:  Get
	rid of BansheeDbCommand.  It didn't add anything useful, and in fact had a
	bug that made creating a new playlist not work (and possibly other
	commands as well).

	* src/Core/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs: Add debugging
	message when executing command out of main thread.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
   trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs	Sun Jan 27 22:54:29 2008
@@ -108,7 +108,7 @@
                     case LogEntryType.Debug: Console.ForegroundColor = ConsoleColor.Blue; break;
                 }
                 
-                Console.Write ("[{0} {1:00}:{2:00}:{3:00}.{4:00}]", type, DateTime.Now.Hour,
+                Console.Write ("[{0} {1:00}:{2:00}:{3:00}.{4:000}]", type, DateTime.Now.Hour,
                     DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
                 
                 Console.ResetColor ();

Modified: 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/LibraryAlbumInfo.cs	Sun Jan 27 22:54:29 2008
@@ -48,7 +48,7 @@
             get { return provider; }
         }
 
-        private static BansheeDbCommand select_command = new BansheeDbCommand (
+        private static HyenaSqliteCommand select_command = new HyenaSqliteCommand (
             "SELECT AlbumID, Title FROM CoreAlbums WHERE ArtistID = ? AND Title = ?", 2
         );
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs	Sun Jan 27 22:54:29 2008
@@ -48,7 +48,7 @@
             get { return provider; }
         }
 
-        private static BansheeDbCommand select_command = new BansheeDbCommand (
+        private static HyenaSqliteCommand select_command = new HyenaSqliteCommand (
             "SELECT ArtistID, Name FROM CoreArtists WHERE Name = ?", 1
         );
 

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	Sun Jan 27 22:54:29 2008
@@ -233,7 +233,7 @@
             set { DateAdded = DateTimeUtil.ToDateTime(value); }
         }
 
-        private static BansheeDbCommand check_command = new BansheeDbCommand (
+        private static HyenaSqliteCommand check_command = new HyenaSqliteCommand (
             "SELECT COUNT(*) FROM CoreTracks WHERE Uri = ? OR Uri = ?", 2);
         
         public static bool ContainsUri (SafeUri uri)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs	Sun Jan 27 22:54:29 2008
@@ -155,22 +155,4 @@
             get { return "DbConnection"; }
         }
     }
-    
-    public sealed class BansheeDbCommand : HyenaSqliteCommand
-    {
-        public BansheeDbCommand(string command)
-            : base(command)
-        {
-        }
-
-        public BansheeDbCommand (string command, int num_params)
-            : base(command, num_params)
-        {
-        }
-
-        public BansheeDbCommand (string command, params object [] param_values)
-            : base(command, param_values.Length)
-        {
-        }
-    }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs	Sun Jan 27 22:54:29 2008
@@ -31,6 +31,7 @@
 
 using Mono.Unix;
 using Hyena.Collections;
+using Hyena.Data.Sqlite;
 
 using Banshee.Base;
 using Banshee.Sources;
@@ -46,7 +47,7 @@
         private ErrorSource error_source = new ErrorSource (Catalog.GetString ("Import Errors"));
         private bool error_source_visible = false;
 
-        private BansheeDbCommand remove_range_command = new BansheeDbCommand (@"
+        private HyenaSqliteCommand remove_range_command = new HyenaSqliteCommand (@"
             DELETE FROM CoreTracks WHERE TrackID IN
                 (SELECT ItemID FROM CoreCache
                     WHERE ModelID = ? LIMIT ?, ?);
@@ -58,7 +59,7 @@
                     WHERE ModelID = ? LIMIT ?, ?)", 9
         );
 
-        private BansheeDbCommand remove_track_command = new BansheeDbCommand (@"
+        private HyenaSqliteCommand remove_track_command = new HyenaSqliteCommand (@"
             DELETE FROM CoreTracks WHERE TrackID = ?;
             DELETE FROM CorePlaylistEntries WHERE TrackID = ?;
             DELETE FROM CoreSmartPlaylistEntries WHERE TrackID = ?", 3

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	Sun Jan 27 22:54:29 2008
@@ -5,6 +5,8 @@
 
 using Mono.Unix;
 
+using Hyena.Data.Sqlite;
+
 using Banshee.Base;
 using Banshee.Configuration;
 using Banshee.Database;
@@ -172,7 +174,7 @@
             PlaylistSource playlist = new PlaylistSource (name);
             playlist.Save ();
 
-            BansheeDbCommand command = new BansheeDbCommand (
+            HyenaSqliteCommand command = new HyenaSqliteCommand (
                 @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
                     VALUES (?, (SELECT TrackID FROM CoreTracks WHERE Uri = ?))", 2
             );

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs	Sun Jan 27 22:54:29 2008
@@ -35,6 +35,7 @@
 using Mono.Unix;
 
 using Hyena.Data;
+using Hyena.Data.Sqlite;
 using Hyena.Collections;
 
 using Banshee.Base;
@@ -48,9 +49,9 @@
 {
     public class PlaylistSource : AbstractPlaylistSource
     {
-        private static BansheeDbCommand add_tracks_command;
-        private static BansheeDbCommand remove_tracks_command;
-        private static BansheeDbCommand delete_command;
+        private static HyenaSqliteCommand add_tracks_command;
+        private static HyenaSqliteCommand remove_tracks_command;
+        private static HyenaSqliteCommand delete_command;
 
         private static string generic_name = Catalog.GetString ("Playlist");
 
@@ -72,14 +73,14 @@
 
         static PlaylistSource () 
         {
-            add_tracks_command = new BansheeDbCommand (@"
+            add_tracks_command = new HyenaSqliteCommand (@"
                 INSERT INTO CorePlaylistEntries
                     SELECT null, ?, ItemID, 0
                         FROM CoreCache WHERE ModelID = ?
                         LIMIT ?, ?", 4
             );
 
-            remove_tracks_command = new BansheeDbCommand (@"
+            remove_tracks_command = new HyenaSqliteCommand (@"
                 DELETE FROM CorePlaylistEntries WHERE PlaylistID = ? AND
                     TrackID IN (SELECT ItemID FROM CoreCache
                         WHERE ModelID = ? LIMIT ?, ?)", 4
@@ -110,7 +111,7 @@
 
         protected override void Update ()
         {
-            ServiceManager.DbConnection.Execute (new BansheeDbCommand (
+            ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (
                 String.Format (
                     @"UPDATE {0}
                         SET Name = ?,
@@ -124,12 +125,13 @@
 
         protected override void Create ()
         {
-            DbId = ServiceManager.DbConnection.Execute (new BansheeDbCommand (
-                String.Format (@"INSERT INTO {0}
+            Console.WriteLine ("Creating playlist");
+            DbId = ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (
+                @"INSERT INTO CorePlaylists (PlaylistID, Name, SortColumn, SortType)
                     VALUES (NULL, ?, ?, ?)",
-                    SourceTable
-                ), Name, -1, 0 //SortColumn, SortType
+                Name, -1, 1 //SortColumn, SortType
             ));
+            Console.WriteLine ("Done Creating playlist");
         }
 
 #endregion
@@ -157,7 +159,7 @@
         public bool Unmap ()
         {
             if (DbId != null) {
-                ServiceManager.DbConnection.Execute (new BansheeDbCommand (@"
+                ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
                     BEGIN TRANSACTION;
                         DELETE FROM CorePlaylists WHERE PlaylistID = ?;
                         DELETE FROM CorePlaylistEntries WHERE PlaylistID = ?;

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs	Sun Jan 27 22:54:29 2008
@@ -35,6 +35,7 @@
 using Mono.Unix;
 
 using Hyena.Data.Query;
+using Hyena.Data.Sqlite;
  
 using Banshee.Base;
 using Banshee.Sources;
@@ -227,7 +228,7 @@
 
         protected override void Create ()
         {
-            DbId = ServiceManager.DbConnection.Execute (new BansheeDbCommand (@"
+            DbId = ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
                 INSERT INTO CoreSmartPlaylists
                     (Name, Condition, OrderBy, OrderDir, LimitNumber, LimitCriterion)
                     VALUES (?, ?, ?, ?, ?, ?)",
@@ -237,7 +238,7 @@
 
         protected override void Update ()
         {
-            ServiceManager.DbConnection.Execute (new BansheeDbCommand (@"
+            ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
                 UPDATE CoreSmartPlaylists
                     SET Name = ?,
                         Condition = ?,

Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs	(original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs	Sun Jan 27 22:54:29 2008
@@ -30,6 +30,7 @@
 using System.IO;
 using System.Collections.Generic;
 using System.Data;
+using System.Threading;
 using Mono.Data.Sqlite;
 
 namespace Hyena.Data.Sqlite
@@ -38,6 +39,15 @@
     {
         private SqliteConnection connection;
 
+        private static Thread main_thread;
+        static HyenaSqliteConnection () {
+            main_thread = Thread.CurrentThread;
+        }
+
+        private static bool InMainThread {
+            get { return main_thread.Equals (Thread.CurrentThread); }
+        }
+
         public HyenaSqliteConnection () : this (true)
         {
         }
@@ -130,6 +140,10 @@
             if (command.Connection == null)
                 command.Connection = connection;
 
+            if (!InMainThread) {
+                Console.WriteLine ("About to execute command not in main thread: {0}", command.CommandText);
+            }
+
             try {
                 return command.ExecuteReader ();
             } catch (Exception e) {
@@ -152,6 +166,11 @@
         {
             if (command.Connection == null)
                 command.Connection = connection;
+
+            if (!InMainThread) {
+                Console.WriteLine ("About to execute command not in main thread: {0}", command.CommandText);
+            }
+
             try {
                 return command.ExecuteScalar ();
             } catch (Exception e) {
@@ -204,6 +223,11 @@
         {
             if (command.Connection == null)
                 command.Connection = connection;
+
+            if (!InMainThread) {
+                Console.WriteLine ("About to execute command not in main thread: {0}", command.CommandText);
+            }
+
             try {
                 command.ExecuteNonQuery ();
             } catch (Exception e) {



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