banshee r3563 - in trunk/banshee: . data src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.Query src/Core/Banshee.Services/Banshee.ServiceStack src/Core/Banshee.Services/Banshee.SmartPlaylist src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying



Author: gburt
Date: Thu Mar 27 17:45:27 2008
New Revision: 3563
URL: http://svn.gnome.org/viewvc/banshee?rev=3563&view=rev

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

	* data/mimetypes.txt: List of mimetypes, one per line, combining what we
	already had with Totem's list.

	* data/mimetypes.pl: Perl script that sorts and removes duplicates from
	mimetypes.txt, and prints out a ; separated list suitable for the .desktop
	file.

	* data/banshee-1.desktop.in.in: Use the output from mimetypes.pl, and
	change the name to Banshee Media Player.

	* src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs: Add
	some more file extensions to the whitelist.

	* src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs: Load
	smart playlists here just like we load playlists.

	* src/Core/Banshee.Services/Makefile.am:
	* src/Core/Banshee.Services/Banshee.Services.mdp:
	* src/Core/Banshee.Services/Banshee.Query/SmartPlaylistQueryValue.cs:
	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistCore.cs:
	* src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs: Remove
	SmartPlaylistCore.  The functionality from it that remained is now in
	SmartPlaylistSource, mostly as static methods.

	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs:
	Moved the SmartPlaylistCore code into here.  On the first Reload call, if
	we haven't yet Refresh'd, do it.

	* src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs: Avoid
	activating a source twice by returning if it's already the active souce.

	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs:
	If the source has a Parent, use its UniqueId to determine what columns to
	show, otherwise use the source's UniqueId.

	* src/Core/Banshee.Services/Banshee.Sources/Source.cs: Add UniqueId
	property, and protected abstract TypeUniqueId that doesn't have to be
	unique across different Source subclasses.

	* src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs:
	* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs:
	* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs:
	* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs:
	* src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs:
	Override TypeUniqueId and use UniqueId.


Added:
   trunk/banshee/data/mimetypes.pl
   trunk/banshee/data/mimetypes.txt
Removed:
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistCore.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/data/banshee-1.desktop.in.in
   trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Query/SmartPlaylistQueryValue.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
   trunk/banshee/src/Core/Banshee.Services/Makefile.am
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs

Modified: trunk/banshee/data/banshee-1.desktop.in.in
==============================================================================
--- trunk/banshee/data/banshee-1.desktop.in.in	(original)
+++ trunk/banshee/data/banshee-1.desktop.in.in	Thu Mar 27 17:45:27 2008
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Version=1.0
 Encoding=UTF-8
-_Name=Banshee
+_Name=Banshee Media Player
 _GenericName=Media Player
 Comment=Play and organize your media collection
 Exec=banshee-1 --play-enqueued --enqueue %U
@@ -14,5 +14,4 @@
 X-GNOME-Bugzilla-Product=banshee
 X-GNOME-Bugzilla-Component=General
 X-GNOME-Bugzilla-Version= VERSION@
-MimeType=application/musepack;application/x-musepack;audio/musepack;audio/x-musepack;audio/mp;audio/x-mp;audio/mpc;audio/x-mpc;audio/x-mod;audio/x-it;audio/x-s3m;audio/x-xm;application/ogg;application/x-ogg;audio/ogg;audio/x-ogg;application/x-flac;audio/flac;audio/x-flac;audio/vorbis;audio/x-vorbis;application/x-ape;audio/ape;audio/x-ape;application/x-id3;audio/mp3;audio/mpeg;audio/mpeg3;audio/x-mp3;audio/x-mpeg;audio/x-mpeg-3;audio/x-m4a;x-content/audio-cdda;x-content/audio-dvd;x-content/audio-player;
-
+MimeType=application/musepack;application/ogg;application/ram;application/sdp;application/smil;application/vnd.rn-realmedia;application/x-ape;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-id3;application/x-matroska;application/x-musepack;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/AMR;audio/AMR-WB;audio/ac3;audio/ape;audio/basic;audio/flac;audio/midi;audio/mp;audio/mp3;audio/mp4;audio/mp4a-latm;audio/mpc;audio/mpeg;audio/mpeg3;audio/mpegurl;audio/musepack;audio/ogg;audio/vnd.rn-realaudio;audio/vorbis;audio/x-ape;audio/x-flac;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp;audio/x-mp3;audio/x-mpc;audio/x-mpeg;audio/x-mpeg-3;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-ogg;audio/x-pn-aiff;audio
 /x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-real-audio;audio/x-realaudio;audio/x-s3m;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-tta;audio/x-vorbis;audio/x-wav;audio/x-wavpack;audio/x-xm;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gpp;video/dv;video/fli;video/flv;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-ms-asf;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-msvideo;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;x-content/audio-cdda;x-content/audio-player;

Added: trunk/banshee/data/mimetypes.pl
==============================================================================
--- (empty file)
+++ trunk/banshee/data/mimetypes.pl	Thu Mar 27 17:45:27 2008
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+# This scripts takes the mimetypes.txt list, make sure it's sorted and
+# has no duplicates, and outputs a ; separated list of them.
+
+use strict;
+
+my %mimetypes;
+
+# Read in and store in hash so unique
+open (IN, 'mimetypes.txt');
+foreach my $mimetype (readline(IN)) {
+    chomp($mimetype);
+    $mimetypes{$mimetype} = 1;
+}
+close (IN);
+
+# Write out in sorted order, and print in ; separated list
+open (OUT, '>mimetypes.txt');
+foreach my $mimetype (sort(keys(%mimetypes))) {
+    print OUT "$mimetype\n";
+    if ($mimetype !~ /^#/) {
+        print "$mimetype;";
+    }
+}
+close (OUT);
+
+print "\n";

Added: trunk/banshee/data/mimetypes.txt
==============================================================================
--- (empty file)
+++ trunk/banshee/data/mimetypes.txt	Thu Mar 27 17:45:27 2008
@@ -0,0 +1,121 @@
+# Note: run perl mimetypes.pl to resort this list, remove duplicates, and generate a ; separated list suitable for the .desktop file
+#x-content/audio-dvd
+#x-content/video-blueray
+#x-content/video-dvd
+#x-content/video-hddvd
+#x-content/video-svcd
+#x-content/video-vcd
+application/musepack
+application/ogg
+application/ram
+application/sdp
+application/smil
+application/vnd.rn-realmedia
+application/x-ape
+application/x-extension-m4a
+application/x-extension-mp4
+application/x-flac
+application/x-flash-video
+application/x-id3
+application/x-matroska
+application/x-musepack
+application/x-netshow-channel
+application/x-ogg
+application/x-quicktime-media-link
+application/x-quicktimeplayer
+application/x-shorten
+application/x-smil
+application/xspf+xml
+audio/3gpp
+audio/AMR
+audio/AMR-WB
+audio/ac3
+audio/ape
+audio/basic
+audio/flac
+audio/midi
+audio/mp
+audio/mp3
+audio/mp4
+audio/mp4a-latm
+audio/mpc
+audio/mpeg
+audio/mpeg3
+audio/mpegurl
+audio/musepack
+audio/ogg
+audio/vnd.rn-realaudio
+audio/vorbis
+audio/x-ape
+audio/x-flac
+audio/x-it
+audio/x-m4a
+audio/x-matroska
+audio/x-mod
+audio/x-mp
+audio/x-mp3
+audio/x-mpc
+audio/x-mpeg
+audio/x-mpeg-3
+audio/x-mpegurl
+audio/x-ms-asf
+audio/x-ms-asx
+audio/x-ms-wax
+audio/x-ms-wma
+audio/x-musepack
+audio/x-ogg
+audio/x-pn-aiff
+audio/x-pn-au
+audio/x-pn-realaudio
+audio/x-pn-realaudio-plugin
+audio/x-pn-wav
+audio/x-pn-windows-acm
+audio/x-real-audio
+audio/x-realaudio
+audio/x-s3m
+audio/x-sbc
+audio/x-scpls
+audio/x-speex
+audio/x-tta
+audio/x-vorbis
+audio/x-wav
+audio/x-wavpack
+audio/x-xm
+image/vnd.rn-realpix
+image/x-pict
+misc/ultravox
+text/google-video-pointer
+text/x-google-video-pointer
+video/3gpp
+video/dv
+video/fli
+video/flv
+video/mp4
+video/mp4v-es
+video/mpeg
+video/msvideo
+video/quicktime
+video/vivo
+video/vnd.divx
+video/vnd.rn-realvideo
+video/vnd.vivo
+video/x-anim
+video/x-avi
+video/x-flc
+video/x-fli
+video/x-flic
+video/x-flv
+video/x-m4v
+video/x-matroska
+video/x-mpeg
+video/x-ms-asf
+video/x-ms-wm
+video/x-ms-wmv
+video/x-ms-wmx
+video/x-ms-wvx
+video/x-msvideo
+video/x-nsv
+video/x-ogm+ogg
+video/x-theora+ogg
+x-content/audio-cdda
+x-content/audio-player

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 27 17:45:27 2008
@@ -55,13 +55,14 @@
             "aiff",  "al",   "alaw", "ape",  "asf",  "asx",  "au",   "avi", 
             "cda",   "cdr",  "divx", "dv",   "flac", "flv",  "gvi",  "gvp", 
             "m1v",   "m21",  "m2p",  "m2v",  "m4a",  "m4b",  "m4e",  "m4p",  
-            "m4u",   "m4v",  "mp+",  "mid",  "midi", "mjp",  "moov", "mov",  
-            "movie", "mp1",  "mp2",  "mp21", "mp3",  "mp4",  "mpa",  "mpc",  
-            "mpe",   "mpeg", "mpg",  "mpp",  "mpu",  "mpv",  "mpv2", "ogg",  
-            "ogm",   "omf",  "qt",   "ra",   "ram",  "raw",  "rm",   "rmvb", 
-            "rts",   "smil", "swf",  "tivo", "u",    "vfw",  "vob",  "wav",  
-            "wave",  "wax",  "wm",   "wma",  "wmd",  "wmv",  "wmx",  "wv",   
-            "wvc",   "wvx",  "yuv"
+            "m4u",   "m4v",  "mp+",  "mid",  "midi", "mjp",  "mkv",  "moov",
+            "mov",   "movie","mp1",  "mp2",  "mp21", "mp3",  "mp4",  "mpa",
+            "mpc",   "mpe",  "mpeg", "mpg",  "mpp",  "mpu",  "mpv",  "mpv2",
+            "ogg",   "ogm",  "omf",  "qt",   "ra",   "ram",  "raw",  "rm",
+            "rmvb",  "rts",  "smil", "swf",  "tivo", "u",    "vfw",  "vob",
+            "wav",   "wave", "wax",  "wm",   "wma",  "wmd",  "wmv",  "wmx",
+            "wv",    "wvc",  "wvx",  "yuv",
+            "f4v",   "f4a",  "f4b",
         };
 
         static LibraryImportManager ()

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Query/SmartPlaylistQueryValue.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Query/SmartPlaylistQueryValue.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Query/SmartPlaylistQueryValue.cs	Thu Mar 27 17:45:27 2008
@@ -38,7 +38,7 @@
     {
         protected sealed override SmartPlaylistSource Resolve ()
         {
-            return ServiceManager.Get<SmartPlaylistCore>().GetSmartPlaylistFromDbId ((int)IntValue);
+            return SmartPlaylistSource.GetById ((int)IntValue);
         }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs	Thu Mar 27 17:45:27 2008
@@ -75,6 +75,14 @@
                     }
                 }
 
+                foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll ()) {
+                    if (pl.PrimarySource != null) {
+                        pl.PrimarySource.AddChildSource (pl);
+                    } else {
+                        Console.WriteLine ("Loading playlist {0} with ps id {1}, ps is null {2}", pl.Name, pl.PrimarySourceId, pl.PrimarySource == null);
+                    }
+                }
+
                 ServiceManager.SourceManager.LoadExtensionSources ();
             }
             

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs	Thu Mar 27 17:45:27 2008
@@ -36,7 +36,6 @@
 using Banshee.Base;
 using Banshee.AudioProfiles;
 using Banshee.Sources;
-using Banshee.SmartPlaylist;
 using Banshee.Database;
 using Banshee.MediaEngine;
 using Banshee.PlaybackController;
@@ -63,7 +62,6 @@
             RegisterService<DBusServiceManager> ();
             RegisterService<BansheeDbConnection> ();
             RegisterService<SourceManager> ();
-            RegisterService<SmartPlaylistCore> ();
             RegisterService<ProfileManager> ();
             RegisterService<PlayerEngineService> ();
             RegisterService<PlaybackControllerService> ();

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	Thu Mar 27 17:45:27 2008
@@ -78,7 +78,6 @@
     <File name="Banshee.Playlist/AbstractPlaylistSource.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Playlist/PlaylistFileUtil.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.SmartPlaylist/Migrator.cs" subtype="Code" buildaction="Compile" />
-    <File name="Banshee.SmartPlaylist/SmartPlaylistCore.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.SmartPlaylist/SmartPlaylistSource.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Sources/IImportable.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Sources/IUnmapableSource.cs" subtype="Code" buildaction="Compile" />
@@ -156,4 +155,4 @@
     <AsmRefVar />
     <ProjectRefVar />
   </MonoDevelop.Autotools.MakefileInfo>
-</Project>
\ No newline at end of file
+</Project>

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	Thu Mar 27 17:45:27 2008
@@ -47,10 +47,22 @@
 using Banshee.Collection;
 using Banshee.Collection.Database;
 
+#pragma warning disable 0169
+
 namespace Banshee.SmartPlaylist
 {
     public class SmartPlaylistSource : AbstractPlaylistSource, IUnmapableSource
     {
+        private static List<SmartPlaylistSource> playlists = new List<SmartPlaylistSource> ();
+        private static uint timeout_id = 0;
+        
+        static SmartPlaylistSource () {
+            Migrator.MigrateAll ();
+
+            ServiceManager.SourceManager.SourceAdded += HandleSourceAdded;
+            ServiceManager.SourceManager.SourceRemoved += HandleSourceRemoved;
+        }
+
         private static string generic_name = Catalog.GetString ("Smart Playlist");
         private static string properties_label = Catalog.GetString ("Edit Smart Playlist");
     
@@ -191,16 +203,8 @@
             DbId = dbid;
 
             InstallProperties ();
-            UpdateDependencies ();
-
-            //Globals.Library.TrackRemoved += OnLibraryTrackRemoved;
 
-            //if (Globals.Library.IsLoaded)
-                //OnLibraryReloaded(Globals.Library, new EventArgs());
-            //else
-                //Globals.Library.Reloaded += OnLibraryReloaded;
-
-            //ListenToPlaylists();
+            UpdateDependencies ();
         }
 
         protected void InstallProperties ()
@@ -298,6 +302,15 @@
             Reload ();
         }
 
+        private bool refreshed = false;
+        public override void Reload ()
+        {
+            if (!refreshed)
+                Refresh ();
+
+            base.Reload ();
+        }
+
         public void Refresh ()
         {
             // Wipe the member list clean and repopulate it 
@@ -310,6 +323,7 @@
                         {1} {2}",
                 DbId, PrependCondition("AND"), OrderAndLimit, PrimarySourceId
             ));
+            refreshed = true;
         }
 
 #endregion
@@ -419,5 +433,106 @@
                 }
             }
         }
+
+        private static void HandleSourceAdded (SourceEventArgs args)
+        {
+            SmartPlaylistSource playlist = args.Source as SmartPlaylistSource;
+            if (playlist == null)
+                return;
+
+            StartTimer (playlist);
+            playlists.Add (playlist);
+            SortPlaylists();
+        }
+
+        private static void HandleSourceRemoved (SourceEventArgs args)
+        {
+            SmartPlaylistSource playlist = args.Source as SmartPlaylistSource;
+            if (playlist == null)
+                return;
+
+            playlists.Remove (playlist);
+
+            StopTimer();
+        }
+
+        public static void StartTimer (SmartPlaylistSource playlist)
+        {
+            // Check if the playlist is time-dependent, and if it is,
+            // start the auto-refresh timer.
+            if (timeout_id == 0 && playlist.TimeDependent) {
+                Log.Information (
+                    "Starting Smart Playlist Auto-Refresh",
+                    "Time-dependent smart playlist added, so starting one-minute auto-refresh timer.",
+                    false
+                );
+                timeout_id = GLib.Timeout.Add(1000*60, OnTimerBeep);
+            }
+        }
+
+        public static void StopTimer ()
+        {
+            // If the timer is going and there are no more time-dependent playlists,
+            // stop the timer.
+            if (timeout_id != 0) {
+                foreach (SmartPlaylistSource p in playlists) {
+                    if (p.TimeDependent) {
+                        return;
+                    }
+                }
+
+                // No more time-dependent playlists, so remove the timer
+                Log.Information (
+                    "Stopping timer",
+                    "There are no time-dependent smart playlists, so stopping auto-refresh timer.",
+                    false
+                );
+
+                GLib.Source.Remove (timeout_id);
+                timeout_id = 0;
+            }
+        }
+
+        private static bool OnTimerBeep ()
+        {
+            foreach (SmartPlaylistSource p in playlists) {
+                if (p.TimeDependent) {
+                    p.Reload();
+                }
+            }
+
+            // Keep the timer going
+            return true;
+        }
+
+        public static void SortPlaylists () {
+            playlists.Sort (new DependencyComparer ());
+        }
+
+        public static SmartPlaylistSource GetById (int dbId)
+        {
+            // TODO use a dictionary
+            foreach (SmartPlaylistSource sp in playlists) {
+                if (sp.DbId == dbId) {
+                    return sp;
+                }
+            }
+            return null;
+        }
+    }
+
+    public class DependencyComparer : IComparer<SmartPlaylistSource> {
+        public int Compare(SmartPlaylistSource a, SmartPlaylistSource b)
+        {
+            if (b.DependsOn (a)) {
+                return -1;
+            } else if (a.DependsOn (b)) {
+                return 1;
+            } else {
+                return 0;
+            }
+        }
     }
 }
+
+#pragma warning restore 0169

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	Thu Mar 27 17:45:27 2008
@@ -57,12 +57,17 @@
 
         protected RateLimiter reload_limiter;
         
+        private string type_unique_id;
+        protected override string TypeUniqueId {
+            get { return type_unique_id; }
+        }
+        
         public DatabaseSource (string generic_name, string name, string id, int order) : base (generic_name, name, order)
         {
-            string uuid = String.Format ("{0}-{1}", this.GetType().Name, id);
-            track_model = new TrackListDatabaseModel (ServiceManager.DbConnection, uuid);
-            artist_model = new ArtistListDatabaseModel (track_model, ServiceManager.DbConnection, uuid);
-            album_model = new AlbumListDatabaseModel (track_model, artist_model, ServiceManager.DbConnection, uuid);
+            type_unique_id = id;
+            track_model = new TrackListDatabaseModel (ServiceManager.DbConnection, UniqueId);
+            artist_model = new ArtistListDatabaseModel (track_model, ServiceManager.DbConnection, UniqueId);
+            album_model = new AlbumListDatabaseModel (track_model, artist_model, ServiceManager.DbConnection, UniqueId);
             reload_limiter = new RateLimiter (RateLimitedReload);
         }
 
@@ -130,7 +135,7 @@
 
 #region Public Methods
 
-        public void Reload ()
+        public virtual void Reload ()
         {
             reload_limiter.Execute ();
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs	Thu Mar 27 17:45:27 2008
@@ -43,6 +43,12 @@
         
         public event EventHandler Cleared;
         public event EventHandler Reloaded;
+        
+        private static Random rand = new Random ();
+        private string tuid = rand.Next ().ToString ();
+        protected override string TypeUniqueId {
+            get { return tuid; }
+        }
 
         public ErrorSource (string name) : base (name, name, 0)
         {

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	Thu Mar 27 17:45:27 2008
@@ -350,6 +350,13 @@
         public Source Parent {
             get { return parent; }
         }
+        
+        private string unique_id;
+        public string UniqueId {
+            get { return unique_id ?? unique_id = String.Format ("{0}-{1}", this.GetType ().Name, TypeUniqueId); }
+        }
+        
+        protected abstract string TypeUniqueId { get; }
 
         public virtual bool CanRename {
             get { return true; }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs	Thu Mar 27 17:45:27 2008
@@ -249,6 +249,10 @@
         
         public void SetActiveSource(Source source, bool notify)
         {
+            if(active_source == source) {
+                return;
+            }
+            
             if(active_source != null) {
                 active_source.Deactivate();
             }

Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am	Thu Mar 27 17:45:27 2008
@@ -106,7 +106,6 @@
 	Banshee.ServiceStack/UserJobEventHandler.cs \
 	Banshee.ServiceStack/UserJobManager.cs \
 	Banshee.SmartPlaylist/Migrator.cs \
-	Banshee.SmartPlaylist/SmartPlaylistCore.cs \
 	Banshee.SmartPlaylist/SmartPlaylistSource.cs \
 	Banshee.Sources/DatabaseSource.cs \
 	Banshee.Sources/ErrorSource.cs \

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs	Thu Mar 27 17:45:27 2008
@@ -44,7 +44,7 @@
         private Source source;
         public Source Source {
             get { return source; }
-            set { 
+            set {
                 if (source == value) {
                     return;
                 }
@@ -57,9 +57,8 @@
                 source_id = null;
                 
                 if (source != null) {
-                    // FIXME: Build a real source ID based on the source's primary source
-                    source_id = "default";
-                    source_id = source_id.ToLower ().Replace ('.', '_');
+                    // If we have a parent, use their UniqueId so all children of a parent persist the same columns
+                    source_id = (source.Parent == null ? source.UniqueId : source.Parent.UniqueId).Replace ('.', '_');
                     Load ();
                 }
             }

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs	Thu Mar 27 17:45:27 2008
@@ -68,6 +68,10 @@
         public LastfmActions Actions {
             get { return actions; }
         }
+        
+        protected override string TypeUniqueId {
+            get { return lastfm; }
+        }
 
         public LastfmSource () : base (lastfm, lastfm, 150)
         {

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs	Thu Mar 27 17:45:27 2008
@@ -93,6 +93,10 @@
 
         private int dbid;
         
+        protected override string TypeUniqueId {
+            get { return Convert.ToString (dbid); }
+        }
+        
         // For StationSources that already exist in the db
         protected StationSource (LastfmSource lastfm, int dbId, string name, string type, string arg, int playCount) : base (generic_name, name, 150)
         {

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs	Thu Mar 27 17:45:27 2008
@@ -42,6 +42,10 @@
     public class NowPlayingSource : Source, IDisposable
     {
         private TrackInfo transitioned_track;
+
+        protected override string TypeUniqueId {
+            get { return "now-playing"; }
+        }
         
         public NowPlayingSource () : base ("now-playing", Catalog.GetString ("Now Playing"), 0)
         {
@@ -61,7 +65,7 @@
         }
         
         private void OnPlaybackControllerTrackStarted (object o, EventArgs args)
-        { 
+        {
             TrackInfo current_track = ServiceManager.PlaybackController.CurrentTrack;
             if (current_track != null && transitioned_track != current_track && 
                 (current_track.MediaAttributes & TrackMediaAttributes.VideoStream) != 0) {



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