[Slim-Checkins] r9397 - in /branches/6.5/server: Changelog6.html Plugins/MoodLogic/Importer.pm Plugins/MoodLogic/Plugin.pm Plugins/MusicMagic/Importer.pm Plugins/MusicMagic/Plugin.pm Plugins/iTunes/Common.pm Plugins/iTunes/Plugin.pm

dsully at svn.slimdevices.com dsully at svn.slimdevices.com
Sun Sep 3 18:00:25 PDT 2006


Author: dsully
Date: Sun Sep  3 18:00:15 2006
New Revision: 9397

URL: http://svn.slimdevices.com?rev=9397&view=rev
Log:
Bug: 4028
Description: Merge from trunk -r 9395:9396

Modified:
    branches/6.5/server/Changelog6.html
    branches/6.5/server/Plugins/MoodLogic/Importer.pm
    branches/6.5/server/Plugins/MoodLogic/Plugin.pm
    branches/6.5/server/Plugins/MusicMagic/Importer.pm
    branches/6.5/server/Plugins/MusicMagic/Plugin.pm
    branches/6.5/server/Plugins/iTunes/Common.pm
    branches/6.5/server/Plugins/iTunes/Plugin.pm

Modified: branches/6.5/server/Changelog6.html
URL: http://svn.slimdevices.com/branches/6.5/server/Changelog6.html?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Changelog6.html (original)
+++ branches/6.5/server/Changelog6.html Sun Sep  3 18:00:15 2006
@@ -555,6 +555,7 @@
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4021">#4021</a> - build-perl-modules hangs on YAML-Syck-0.64</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4025">#4025</a> - Apple Lossless Files not playing</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4026">#4026</a> - WAV playback only works for 16 bits 44.1kHz</li>
+		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4028">#4028</a> - MusicMagic automatic reimport never runs</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4030">#4030</a> - Add voltage to status command for transporter</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4031">#4031</a> - Crash when enabling Network Health with no players</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4033">#4033</a> - d_scan output in log.txt</li>

Modified: branches/6.5/server/Plugins/MoodLogic/Importer.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/MoodLogic/Importer.pm?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Plugins/MoodLogic/Importer.pm (original)
+++ branches/6.5/server/Plugins/MoodLogic/Importer.pm Sun Sep  3 18:00:15 2006
@@ -146,40 +146,6 @@
 	$initialized = 1;
 
 	return $initialized;
-}
-
-sub isMusicLibraryFileChanged {
-	my $file = $mixer->{JetFilePublic};
-
-	my $fileMTime = (stat $file)[9];
-	
-	# Only say "yes" if it has been more than one minute since we last finished scanning
-	# and the file mod time has changed since we last scanned. Note that if we are
-	# just starting, $lastMusicLibraryDate is undef, so both $fileMTime
-	# will be greater than 0 and time()-0 will be greater than 180 :-)
-	if ($file && $fileMTime > Slim::Utils::Prefs::get('lastMoodLogicLibraryDate')) {
-		my $moodlogicscaninterval = Slim::Utils::Prefs::get('moodlogicscaninterval');
-		
-		$::d_moodlogic && msg("MoodLogic: music library has changed!\n");
-		
-		unless ($moodlogicscaninterval) {
-			
-			# only scan if moodlogicscaninterval is non-zero.
-			$::d_moodlogic && msg("MoodLogic: Scan Interval set to 0, rescanning disabled\n");
-
-			return 0;
-		}
-
-		return 1 if (!$lastMusicLibraryFinishTime);
-		
-		if (time() - $lastMusicLibraryFinishTime > $moodlogicscaninterval) {
-			return 1;
-		} else {
-			$::d_moodlogic && msg("MoodLogic: waiting for $moodlogicscaninterval seconds to pass before rescanning\n");
-		}
-	}
-	
-	return 0;
 }
 
 sub startScan {

Modified: branches/6.5/server/Plugins/MoodLogic/Plugin.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/MoodLogic/Plugin.pm?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Plugins/MoodLogic/Plugin.pm (original)
+++ branches/6.5/server/Plugins/MoodLogic/Plugin.pm Sun Sep  3 18:00:15 2006
@@ -52,7 +52,7 @@
 
 	# turn off checker
 	Slim::Utils::Timers::killTimers(0, \&checker);
-	
+
 	# disable protocol handler
 	Slim::Player::ProtocolHandlers->registerHandler('moodlogicplaylist', 0);
 
@@ -93,6 +93,8 @@
 }
 
 sub initPlugin {
+	my $class = shift;
+
 	return 1 if $initialized; 
 	return 0 if Slim::Utils::OSDetect::OS() ne 'win';
 	
@@ -157,8 +159,6 @@
 	#Slim::Utils::Strings::addStrings($strings);
 	Slim::Player::ProtocolHandlers->registerHandler("moodlogicplaylist", "0");
 	
-	my $class = __PACKAGE__;
-
 	# addImporter for Plugins, may include mixer function, setup function, mixerlink reference and use on/off.
 	Slim::Music::Import->addImporter($class, {
 		'mixer'     => \&mixerFunction,
@@ -175,14 +175,19 @@
 
 	$initialized = 1;
 
+	checker($initialized);
+
 	return $initialized;
 }
 
 sub addGroups {
-	my ($groupRef,$prefRef) = &setupUse();
-	Slim::Web::Setup::addGroup('SERVER_SETTINGS','moodlogic',$groupRef,undef,$prefRef);
-	Slim::Web::Setup::addChildren('SERVER_SETTINGS','MOODLOGIC');
-	Slim::Web::Setup::addCategory('MOODLOGIC',&setupCategory);
+	my ($groupRef,$prefRef) = setupUse();
+
+	Slim::Web::Setup::addGroup('SERVER_SETTINGS', 'moodlogic', $groupRef, undef, $prefRef);
+
+	Slim::Web::Setup::addChildren('SERVER_SETTINGS', 'MOODLOGIC');
+
+	Slim::Web::Setup::addCategory('MOODLOGIC', setupCategory());
 }
 
 sub checker {
@@ -190,18 +195,55 @@
 
 	if (!Slim::Utils::Prefs::get('moodlogic')) {
 		return;
-
-	}
-	
-	if (!$firstTime && !Slim::Music::Import->stillScanning && Plugins::MoodLogic::Importer::isMusicLibraryFileChanged()) {
-		startScan();
-	}
-	
+	}
+	
+	if (!$firstTime && !Slim::Music::Import->stillScanning && isMusicLibraryFileChanged()) {
+
+		Slim::Control::Request::executeRequest(undef, ['rescan']);
+	}
+
 	# make sure we aren't doing this more than once...
 	Slim::Utils::Timers::killTimers(0, \&checker);
 
 	# Call ourselves again after 5 seconds
 	Slim::Utils::Timers::setTimer(0, (Time::HiRes::time() + 5.0), \&checker);
+}
+
+sub isMusicLibraryFileChanged {
+	my $file = $mixer->{JetFilePublic};
+
+	my $fileMTime = (stat $file)[9];
+	
+	# Only say "yes" if it has been more than one minute since we last finished scanning
+	# and the file mod time has changed since we last scanned. Note that if we are
+	# just starting, $lastMusicLibraryDate is undef, so both $fileMTime
+	# will be greater than 0 and time()-0 will be greater than 180 :-)
+	if ($file && $fileMTime > Slim::Utils::Prefs::get('lastMoodLogicLibraryDate')) {
+
+		my $moodlogicscaninterval = Slim::Utils::Prefs::get('moodlogicscaninterval');
+
+		$::d_moodlogic && msg("MoodLogic: music library has changed!\n");
+
+		if (!$moodlogicscaninterval) {
+			
+			# only scan if moodlogicscaninterval is non-zero.
+			$::d_moodlogic && msg("MoodLogic: Scan Interval set to 0, rescanning disabled\n");
+
+			return 0;
+		}
+
+		if (!$lastMusicLibraryFinishTime) {
+			return 1;
+		}
+		
+		if (time() - $lastMusicLibraryFinishTime > $moodlogicscaninterval) {
+			return 1;
+		}
+
+		$::d_moodlogic && msg("MoodLogic: waiting for $moodlogicscaninterval seconds to pass before rescanning\n");
+	}
+	
+	return 0;
 }
 
 sub getMoodWheel {

Modified: branches/6.5/server/Plugins/MusicMagic/Importer.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/MusicMagic/Importer.pm?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Plugins/MusicMagic/Importer.pm (original)
+++ branches/6.5/server/Plugins/MusicMagic/Importer.pm Sun Sep  3 18:00:15 2006
@@ -108,58 +108,6 @@
 	}
 
 	return $initialized;
-}
-
-sub isMusicLibraryFileChanged {
-
-	my $fileMTime = get("http://$MMSHost:$MMSport/api/cacheid?contents");
-	my $MMMstatus = get("http://$MMSHost:$MMSport/api/getStatus");
-
-	if ($::d_musicmagic) {
-		msg("MusicMagic: read cacheid of $fileMTime");
-		msg("MusicMagic: got status - $MMMstatus");
-	}
-
-	chomp($fileMTime);
-	chomp($MMMstatus);
-
-	# Only say "yes" if it has been more than one minute since we last finished scanning
-	# and the file mod time has changed since we last scanned. Note that if we are
-	# just starting, $lastMusicLibraryDate is undef, so both $fileMTime
-	# will be greater than 0 and time()-0 will be greater than 180 :-)
-	my $oldTime = Slim::Utils::Prefs::get('MMMlastMusicMagicLibraryDate') || 0;
-	my $lastMusicLibraryFinishTime = Slim::Utils::Prefs::get('MMMlastMusicLibraryFinishTime') || 0;
-
-	if ($fileMTime > $oldTime) {
-
-		my $musicMagicScanInterval = Slim::Utils::Prefs::get('musicmagicscaninterval');
-
-		if ($::d_musicmagic) {
-
-			msg("MusicMagic: music library has changed! Details:\n");
-			msg("\tCacheid - $fileMTime\n");
-			msg("\tLastCacheid - $oldTime\n");
-			msg("\tReload Interval - $musicMagicScanInterval\n");
-			msg("\tLast Scan - $lastMusicLibraryFinishTime\n");
-		}
-		
-		if (!$musicMagicScanInterval) {
-
-			# only scan if musicmagicscaninterval is non-zero.
-			$::d_musicmagic && msg("MusicMagic: Scan Interval set to 0, rescanning disabled\n");
-
-			return 0;
-		}
-
-		if (time - $lastMusicLibraryFinishTime > $musicMagicScanInterval) {
-
-			return 1;
-		}
-
-		$::d_musicmagic && msg("MusicMagic: waiting for $musicMagicScanInterval seconds to pass before rescanning\n");
-	}
-
-	return 0;
 }
 
 sub startScan {

Modified: branches/6.5/server/Plugins/MusicMagic/Plugin.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/MusicMagic/Plugin.pm?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Plugins/MusicMagic/Plugin.pm (original)
+++ branches/6.5/server/Plugins/MusicMagic/Plugin.pm Sun Sep  3 18:00:15 2006
@@ -85,7 +85,7 @@
 sub shutdownPlugin {
 
 	# turn off checker
-	#Slim::Utils::Timers::killTimers(0, \&checker);
+	Slim::Utils::Timers::killTimers(0, \&checker);
 
 	# disable protocol handler?
 	Slim::Player::ProtocolHandlers->registerHandler('musicmaglaylist', 0);
@@ -149,9 +149,7 @@
 		# Note: Check version restrictions if any
 		$initialized = $content;
 
-		#checker($initialized);
-
-		my $class = __PACKAGE__;
+		checker($initialized);
 
 		# addImporter for Plugins, may include mixer function, setup function, mixerlink reference and use on/off.
 		Slim::Music::Import->addImporter($class, {
@@ -166,11 +164,14 @@
 		addGroups();
 
 		if (scalar @{grabMoods()}) {
+
 			Slim::Buttons::Common::addMode('musicmagic_moods', {}, \&setMoodMode);
+
 			Slim::Buttons::Home::addMenuOption('MUSICMAGIC_MOODS', {
 				'useMode'  => 'musicmagic_moods',
 				'mood'     => 'none',
 			});
+
 			Slim::Web::Pages->addPageLinks("browse", {
 				'MUSICMAGIC_MOODS' => "plugins/MusicMagic/musicmagic_moods.html"
 			});
@@ -187,8 +188,8 @@
 
 sub defaultMap {
 	#Slim::Buttons::Common::addMode('musicmagic_mix', \%mixFunctions);
-	Slim::Hardware::IR::addModeDefaultMapping('musicmagic_mix',\%mixMap);
-	return undef;
+
+	Slim::Hardware::IR::addModeDefaultMapping('musicmagic_mix', \%mixMap);
 }
 
 sub playMix {
@@ -200,15 +201,22 @@
 	my $playAddInsert;
 	
 	if ($append == 1) {
+
 		$line1 = $client->string('ADDING_TO_PLAYLIST');
 		$playAddInsert = 'addtracks';
+
 	} elsif ($append == 2) {
+
 		$line1 = $client->string('INSERT_TO_PLAYLIST');
 		$playAddInsert = 'inserttracks';
+
 	} elsif (Slim::Player::Playlist::shuffle($client)) {
+
 		$line1 = $client->string('PLAYING_RANDOMLY_FROM');
 		$playAddInsert = 'playtracks';
+
 	} else {
+
 		$line1 = $client->string('NOW_PLAYING_FROM');
 		$playAddInsert = 'playtracks';
 	}
@@ -225,11 +233,12 @@
 }
 
 sub addGroups {
-	my $category = &setupCategory;
+	my $category = setupCategory();
 
 	Slim::Web::Setup::addCategory('MUSICMAGIC',$category);
 	
-	my ($groupRef,$prefRef) = &setupUse();
+	my ($groupRef, $prefRef) = setupUse();
+
 	Slim::Web::Setup::addGroup('SERVER_SETTINGS', 'musicmagic', $groupRef, undef, $prefRef);
 
 	Slim::Web::Setup::addChildren('SERVER_SETTINGS', 'MUSICMAGIC');
@@ -302,10 +311,9 @@
 		return;
 	}
 
-	my $change = 0;
-
 	if (!$firstTime && !Slim::Music::Import->stillScanning && isMusicLibraryFileChanged()) {
-		startScan();
+
+		Slim::Control::Request::executeRequest(undef, ['rescan']);
 	}
 
 	# make sure we aren't doing this more than once...

Modified: branches/6.5/server/Plugins/iTunes/Common.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/iTunes/Common.pm?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Plugins/iTunes/Common.pm (original)
+++ branches/6.5/server/Plugins/iTunes/Common.pm Sun Sep  3 18:00:15 2006
@@ -255,32 +255,6 @@
 	return 0;
 }
 
-sub checker {
-	my $class = shift;
-	my $firstTime = shift || 0;
-
-	if (!Slim::Utils::Prefs::get('itunes')) {
-
-		return 0;
-	}
-
-	if (!$firstTime && !$class->stillScanning && $class->isMusicLibraryFileChanged) {
-		#startScan();
-	}
-
-	# make sure we aren't doing this more than once...
-	#Slim::Utils::Timers::killTimers(0, \&checker);
-
-	#my $interval = Slim::Utils::Prefs::get('itunesscaninterval') || 3600;
-
-	# the very first time, we do want to scan right away
-	#if ( $firstTime ) {
-	#	$interval = 10;
-	#}
-
-	#Slim::Utils::Timers::setTimer(0, Time::HiRes::time() + $interval, \&checker);
-}
-
 sub normalize_location {
 	my $class    = shift;
 	my $location = shift;

Modified: branches/6.5/server/Plugins/iTunes/Plugin.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/iTunes/Plugin.pm?rev=9397&r1=9396&r2=9397&view=diff
==============================================================================
--- branches/6.5/server/Plugins/iTunes/Plugin.pm (original)
+++ branches/6.5/server/Plugins/iTunes/Plugin.pm Sun Sep  3 18:00:15 2006
@@ -40,12 +40,16 @@
 	Slim::Music::Import->addImporter($class, { 'use' => 1 });
 
 	$class->initialized(1);
+	$class->checker(1);
 
 	return 1;
 }
 
 sub shutdownPlugin {
 	my $class = shift;
+
+	# turn off checker
+	Slim::Utils::Timers::killTimers(0, \&checker);
 
 	# disable protocol handler
 	Slim::Player::ProtocolHandlers->registerHandler('itunesplaylist', 0);
@@ -58,6 +62,33 @@
 
 	# set importer to not use
 	Slim::Music::Import->useImporter($class, 0);
+}
+
+sub checker {
+	my $class     = shift;
+	my $firstTime = shift || 0;
+
+	if (!Slim::Utils::Prefs::get('itunes')) {
+
+		return 0;
+	}
+
+	if (!$firstTime && !Slim::Music::Import->stillScanning && $class->isMusicLibraryFileChanged) {
+
+		Slim::Control::Request::executeRequest(undef, ['rescan']);
+	}
+
+	# make sure we aren't doing this more than once...
+	Slim::Utils::Timers::killTimers(0, \&checker);
+
+	my $interval = Slim::Utils::Prefs::get('itunesscaninterval') || 3600;
+
+	# the very first time, we do want to scan right away
+	if ($firstTime) {
+		$interval = 10;
+	}
+
+	Slim::Utils::Timers::setTimer(0, Time::HiRes::time() + $interval, \&checker);
 }
 
 sub addGroups {



More information about the checkins mailing list