[Slim-Checkins] r33932 - /7.8/trunk/server/Slim/Control/Queries.pm

[email protected] Wed, 11 Apr 2012 08:38:05 -0000
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: fmueller
Date: Wed Apr 11 01:38:04 2012
New Revision: 33932

URL: http://svn.slimdevices.com/slim?rev=33932&view=rev
Log:
Bug: n/a 
Description: Alarm - Send next alarm (even if further away than 24h), repeat status and weekdays to the player. 

Modified:
    7.8/trunk/server/Slim/Control/Queries.pm

Modified: 7.8/trunk/server/Slim/Control/Queries.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Control/Queries.pm?rev=33932&r1=33931&r2=33932&view=diff
==============================================================================
--- 7.8/trunk/server/Slim/Control/Queries.pm (original)
+++ 7.8/trunk/server/Slim/Control/Queries.pm Wed Apr 11 01:38:04 2012
@@ -3178,6 +3178,29 @@
 		} else {
 			$request->addResult('alarm_state', $alarmComing);
 			$request->addResult('alarm_next', defined $alarmNext ? $alarmNext + 0 : 0);
+		}
+
+		# NEW ALARM CODE
+		# Add alarm version so a player can do the right thing
+		$request->addResult('alarm_version', 2);
+
+		# The alarm_state and alarm_next are only good for an alarm in the next 24 hours
+		#  but we need the next alarm (which could be further away than 24 hours)
+		my $alarmNextAlarm = Slim::Utils::Alarm->getNextAlarm($client);
+
+		if($alarmNextAlarm and $alarmNextAlarm->enabled()) {
+			# Get epoch seconds
+			my $alarmNext2 = $alarmNextAlarm->nextDue();
+			$request->addResult('alarm_next2', $alarmNext2);
+			# Get repeat status
+			my $alarmRepeat = $alarmNextAlarm->repeat();
+			$request->addResult('alarm_repeat', $alarmRepeat);
+			# Get days alarm is active
+			my $alarmDays = "";
+			for my $i (0..6) {
+				$alarmDays .= $alarmNextAlarm->day($i) ? "1" : "0";
+			}
+			$request->addResult('alarm_days', $alarmDays);
 		}
 
 		# send client pref for alarm snooze