banshee r3470 - in trunk/banshee: . src/Core/Banshee.Core src/Core/Banshee.Core/Banshee.Collection 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/Libraries/Hyena/Hyena.Data.Sqlite
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3470 - in trunk/banshee: . src/Core/Banshee.Core src/Core/Banshee.Core/Banshee.Collection 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/Libraries/Hyena/Hyena.Data.Sqlite
- Date: Mon, 17 Mar 2008 02:59:55 +0000 (GMT)
Author: abock
Date: Mon Mar 17 02:59:54 2008
New Revision: 3470
URL: http://svn.gnome.org/viewvc/banshee?rev=3470&view=rev
Log:
2008-03-16 Aaron Bockover <abock gnome org>
* src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs:
Defined a starting set of general flags that can be used to describe
the track, including VideoStream, AudioStream, Podcast, AudioBook, etc.
* src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs: Added a
MediaAttributes property
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs:
Override MediaAttributes and bind it to the Attributes column
* src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs: Detect and merge
some MediaAttributes into the track (i.e. if taglib says the file
has audio and/or video streams, apply those as attributes)
* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
Added the first schema changes using the migrator now that we have actually
made a release, we don't want to break users' database; add a column called
Attributes to CoreTracks
* src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs:
NotifyTracksAdded a little more frequently than we do right now
* src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs: Special case
Enum types so that we can convert integer values in the database to
the enum values they represent if a bound property's type is an enum
Added:
trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs
Modified:
trunk/banshee/ChangeLog
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.Streaming/StreamTagger.cs
trunk/banshee/src/Core/Banshee.Core/Makefile.am
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
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 Mon Mar 17 02:59:54 2008
@@ -273,6 +273,12 @@
set { can_play = value; }
}
+ private TrackMediaAttributes media_attributes;
+ public virtual TrackMediaAttributes MediaAttributes {
+ get { return media_attributes; }
+ set { media_attributes = value; }
+ }
+
// Generates a{sv} of self according to http://wiki.xmms2.xmms.se/index.php/Media_Player_Interfaces#.22Metadata.22
public IDictionary<string, object> GenerateExportable ()
{
Added: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackMediaAttributes.cs Mon Mar 17 02:59:54 2008
@@ -0,0 +1,47 @@
+//
+// TrackMediaAttributes.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 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;
+
+namespace Banshee.Collection
+{
+ [Flags]
+ public enum TrackMediaAttributes
+ {
+ None = (0 << 0),
+ AudioStream = (1 << 0),
+ VideoStream = (1 << 1),
+ Music = (1 << 2),
+ AudioBook = (1 << 3),
+ Podcast = (1 << 4),
+ TvShow = (1 << 5),
+ Movie = (1 << 6),
+
+ Default = AudioStream | Music
+ }
+}
\ No newline at end of file
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 17 02:59:54 2008
@@ -65,12 +65,13 @@
<File name="Banshee.Configuration/ConfigurationClient.cs" subtype="Code" buildaction="Compile" />
<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" />
</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" />
<ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.3.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+ <ProjectReference type="Gac" localcopy="True" refto="taglib-sharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=db62eba44689b5b0" />
</References>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
<BuildFilesVar Sync="True" Name="SOURCES" />
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 Mon Mar 17 02:59:54 2008
@@ -40,9 +40,9 @@
TagLib.File file = Banshee.IO.DemuxVfs.OpenFile (uri.IsLocalPath ? uri.LocalPath : uri.AbsoluteUri,
null, TagLib.ReadStyle.Average);
- if ((file.Properties.MediaTypes & TagLib.MediaTypes.Audio) != 0 &&
- file.Properties.MediaTypes != TagLib.MediaTypes.Audio) {
- throw new TagLib.UnsupportedFormatException ("File contains more than just audio");
+ if ((file.Properties.MediaTypes & TagLib.MediaTypes.Audio) == 0 &&
+ (file.Properties.MediaTypes & TagLib.MediaTypes.Video) == 0) {
+ throw new TagLib.UnsupportedFormatException ("File does not contain video or audio");
}
return file;
@@ -76,6 +76,27 @@
: (priority <= 0 ? fallback : priority);
}
+ private static void FindTrackMediaAttributes (TrackInfo track, TagLib.File file)
+ {
+ track.MediaAttributes = TrackMediaAttributes.None;
+
+ if ((file.Properties.MediaTypes & TagLib.MediaTypes.Audio) != 0) {
+ track.MediaAttributes |= TrackMediaAttributes.AudioStream;
+ }
+
+ if ((file.Properties.MediaTypes & TagLib.MediaTypes.Video) != 0) {
+ track.MediaAttributes |= TrackMediaAttributes.VideoStream;
+ }
+
+ // TODO: Actually figure out, if possible at the tag/file level, if
+ // the file is actual music, podcast, audiobook, movie, tv show, etc.
+ // For now just assume that if it's only audio, it's music, since that's
+ // what we've just historically assumed on any media type
+ if ((track.MediaAttributes & TrackMediaAttributes.VideoStream) == 0) {
+ track.MediaAttributes |= TrackMediaAttributes.Music;
+ }
+ }
+
public static void TrackInfoMerge (TrackInfo track, TagLib.File file)
{
TrackInfoMerge (track, file, false);
@@ -88,6 +109,8 @@
track.MimeType = file.MimeType;
track.FileSize = Banshee.IO.File.GetSize (track.Uri);
track.Duration = file.Properties.Duration;
+
+ FindTrackMediaAttributes (track, file);
track.ArtistName = Choose (file.Tag.JoinedPerformers, track.ArtistName, preferTrackInfo);
track.AlbumTitle = Choose (file.Tag.Album, track.AlbumTitle, preferTrackInfo);
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 17 02:59:54 2008
@@ -22,6 +22,7 @@
Banshee.Collection/TrackAttributes.cs \
Banshee.Collection/TrackFilterType.cs \
Banshee.Collection/TrackInfo.cs \
+ Banshee.Collection/TrackMediaAttributes.cs \
Banshee.Collection/UnknownTrackInfo.cs \
Banshee.Configuration.Schema/ImportSchema.cs \
Banshee.Configuration.Schema/LibrarySchema.cs \
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs Mon Mar 17 02:59:54 2008
@@ -222,6 +222,12 @@
set { base.FileSize = value; }
}
+ [DatabaseColumn ("Attributes")]
+ public override TrackMediaAttributes MediaAttributes {
+ get { return base.MediaAttributes; }
+ set { base.MediaAttributes = value; }
+ }
+
[DatabaseColumn ("Title")]
public override string TrackTitle {
get { return base.TrackTitle; }
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 Mon Mar 17 02:59:54 2008
@@ -4,7 +4,7 @@
// Author:
// 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
@@ -38,6 +38,7 @@
using Banshee.ServiceStack;
using Banshee.Sources;
+using Banshee.Collection;
using Banshee.Collection.Database;
using Banshee.Streaming;
@@ -60,7 +61,7 @@
// NOTE: Whenever there is a change in ANY of the database schema,
// this version MUST be incremented and a migration method
// MUST be supplied to match the new version number
- protected const int CURRENT_VERSION = 1;
+ protected const int CURRENT_VERSION = 2;
protected class DatabaseVersionAttribute : Attribute
{
@@ -123,48 +124,55 @@
}
}
- public void Migrate()
+ public void Migrate ()
{
try {
- Execute("BEGIN");
- InnerMigrate();
- Execute("COMMIT");
- } catch(Exception e) {
- Console.WriteLine("Rolling back transaction");
- Console.WriteLine(e);
- Execute("ROLLBACK");
+ Execute ("BEGIN");
+ InnerMigrate ();
+ Execute ("COMMIT");
+ } catch (Exception e) {
+ Console.WriteLine ("Rolling back transaction");
+ Console.WriteLine (e);
+ Execute ("ROLLBACK");
}
OnFinished ();
}
- private void InnerMigrate()
+ private void InnerMigrate ()
{
- MethodInfo [] methods = GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic);
+ MethodInfo [] methods = GetType ().GetMethods (BindingFlags.Instance | BindingFlags.NonPublic);
bool terminate = false;
bool ran_migration_step = false;
- for(int i = DatabaseVersion + 1; i <= CURRENT_VERSION; i++) {
- foreach(MethodInfo method in methods) {
- foreach(Attribute attr in method.GetCustomAttributes(false)) {
- if(attr is DatabaseVersionAttribute && ((DatabaseVersionAttribute)attr).Version == i) {
- if (!ran_migration_step) {
- ran_migration_step = true;
- OnStarted ();
- }
-
- if(!(bool)method.Invoke(this, null)) {
- terminate = true;
- }
- break;
+ for (int i = DatabaseVersion + 1; i <= CURRENT_VERSION; i++) {
+ foreach (MethodInfo method in methods) {
+ foreach (DatabaseVersionAttribute attr in method.GetCustomAttributes (
+ typeof (DatabaseVersionAttribute), false)) {
+ if (attr.Version != i) {
+ continue;
}
+
+ if (!ran_migration_step) {
+ ran_migration_step = true;
+ OnStarted ();
+ }
+
+ if (!(bool)method.Invoke (this, null)) {
+ terminate = true;
+ }
+
+ break;
}
}
- if(terminate) {
+ if (terminate) {
break;
}
}
+
+ Execute (String.Format ("UPDATE CoreConfiguration SET Value = '{0}' WHERE Key = 'DatabaseVersion'",
+ CURRENT_VERSION));
}
protected bool TableExists(string tableName)
@@ -228,7 +236,15 @@
InitializeFreshDatabase ();
return false;
}
- }
+ }
+
+ [DatabaseVersion (2)]
+ private bool Migrate_2 ()
+ {
+ Execute (String.Format ("ALTER TABLE CoreTracks ADD COLUMN Attributes INTEGER DEFAULT {0}",
+ (int)TrackMediaAttributes.Default));
+ return true;
+ }
#pragma warning restore 0169
@@ -271,7 +287,7 @@
// TODO add these:
// Others to consider:
// AlbumArtist (TPE2) (in CoreAlbums?)
- Execute(@"
+ Execute(String.Format (@"
CREATE TABLE CoreTracks (
PrimarySourceID INTEGER NOT NULL,
TrackID INTEGER PRIMARY KEY,
@@ -285,6 +301,7 @@
UriType INTEGER,
MimeType TEXT,
FileSize INTEGER,
+ Attributes INTEGER DEFAULT {0},
Title TEXT,
TrackNumber INTEGER,
@@ -305,7 +322,7 @@
DateAddedStamp INTEGER,
DateUpdatedStamp INTEGER
)
- ");
+ ", (int)TrackMediaAttributes.Default));
Execute("CREATE INDEX CoreTracksPrimarySourceIndex ON CoreTracks(PrimarySourceID)");
Execute("CREATE INDEX CoreTracksAggregatesIndex ON CoreTracks(FileSize, Duration)");
Execute("CREATE INDEX CoreTracksArtistIndex ON CoreTracks(ArtistID)");
@@ -440,7 +457,7 @@
ORDER BY AlbumTitle
");
- Execute(@"
+ Execute (String.Format (@"
INSERT INTO CoreTracks
SELECT
1,
@@ -454,11 +471,12 @@
AND a.ArtistID = b.ArtistID
AND b.Name = Artist),
0,
- null,
+ 0,
Uri,
0,
MimeType,
0,
+ {0},
Title,
TrackNumber,
TrackCount,
@@ -474,7 +492,7 @@
DateAddedStamp,
DateAddedStamp
FROM Tracks
- ");
+ ", (int)TrackMediaAttributes.Default));
Execute ("update coretracks set lastplayedstamp = NULL where lastplayedstamp = -62135575200");
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 Mon Mar 17 02:59:54 2008
@@ -148,7 +148,7 @@
throw;
}
- if (++count % 500 == 0) {
+ if (++count % 250 == 0) {
ServiceManager.SourceManager.Library.NotifyTracksAdded ();
}
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 Mon Mar 17 02:59:54 2008
@@ -39,7 +39,7 @@
if (type == typeof (string)) {
return "TEXT";
} else if (type == typeof (int) || type == typeof (long)
- || type == typeof (DateTime) || type == typeof (TimeSpan)) {
+ || type == typeof (DateTime) || type == typeof (TimeSpan) || type.IsEnum) {
return "INTEGER";
} else {
throw new Exception (String.Format (
@@ -57,7 +57,10 @@
return TimeSpan.MinValue.Equals ((TimeSpan)value)
? (object)null
: ((TimeSpan)value).TotalMilliseconds;
+ } else if (type.IsEnum) {
+ return Convert.ChangeType (value, Enum.GetUnderlyingType (type));
}
+
return value;
}
@@ -77,15 +80,15 @@
} else {
return null;
}
+ } else if (type.IsEnum) {
+ return Enum.ToObject (type, value);
} else {
return Convert.ChangeType (value, type);
}
}
- public static string BuildColumnSchema (string type,
- string name,
- string default_value,
- DatabaseColumnConstraints constraints)
+ public static string BuildColumnSchema (string type, string name, string default_value,
+ DatabaseColumnConstraints constraints)
{
StringBuilder builder = new StringBuilder ();
builder.Append (name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]