Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Powerdown System after play #249

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+92 −12
Split
@@ -34,7 +34,7 @@
<posx>470</posx>
<posy>0</posy>
<width>340</width>
- <height>720</height>
+ <height>760</height>
<onleft>9000</onleft>
<onright>9000</onright>
<onup>9000</onup>
@@ -63,8 +63,8 @@
<onclick>PreviousMenu</onclick>
<texturefocus>DialogCloseButton-focus.png</texturefocus>
<texturenofocus>DialogCloseButton.png</texturenofocus>
- <onleft>13</onleft>
- <onright>13</onright>
+ <onleft>14</onleft>
+ <onright>14</onright>
<onup>9</onup>
<ondown>2</ondown>
<visible>system.getbool(input.enablemouse)</visible>
@@ -103,6 +103,38 @@
<label>13016</label>
</control>
<control type="button" id="4">
+ <description>Shutdown after playback</description>
+ <width>340</width>
+ <height>40</height>
+ <textcolor>grey2</textcolor>
+ <focusedcolor>white</focusedcolor>
+ <align>center</align>
+ <textwidth>290</textwidth>
+ <texturefocus border="25,5,25,5">ShutdownButtonFocus.png</texturefocus>
+ <texturenofocus border="25,5,25,5">ShutdownButtonNoFocus.png</texturenofocus>
+ <onclick>XBMC.PowerdownAfterPlay(true)</onclick>
+ <pulseonselect>no</pulseonselect>
+ <font>font13</font>
+ <label>13017</label>
+ <visible>System.CanPowerDown + !System.PowerdownAfterPlay + [Player.Paused | Player.Playing]</visible>
+ </control>
+ <control type="button" id="5">
+ <description>Cancel shutdown after playback</description>
+ <width>340</width>
+ <height>40</height>
+ <textcolor>grey2</textcolor>
+ <focusedcolor>white</focusedcolor>
+ <align>center</align>
+ <textwidth>290</textwidth>
+ <texturefocus border="25,5,25,5">ShutdownButtonFocus.png</texturefocus>
+ <texturenofocus border="25,5,25,5">ShutdownButtonNoFocus.png</texturenofocus>
+ <onclick>XBMC.PowerdownAfterPlay(false)</onclick>
+ <pulseonselect>no</pulseonselect>
+ <font>font13</font>
+ <label>13018</label>
+ <visible>System.CanPowerDown + System.PowerdownAfterPlay + [Player.Paused | Player.Playing]</visible>
+ </control>
+ <control type="button" id="6">
<description>Custom Shutdown Timer</description>
<width>340</width>
<height>40</height>
@@ -119,7 +151,7 @@
<visible>!System.HasAlarm(shutdowntimer)</visible>
<visible>System.CanPowerDown</visible>
</control>
- <control type="button" id="5">
+ <control type="button" id="7">
<description>Cancel Shutdown Timer</description>
<width>340</width>
<height>40</height>
@@ -135,7 +167,7 @@
<label>20151</label>
<visible>System.HasAlarm(shutdowntimer)</visible>
</control>
- <control type="button" id="6">
+ <control type="button" id="8">
<description>Suspend button</description>
<width>340</width>
<height>40</height>
@@ -151,7 +183,7 @@
<font>font13</font>
<label>13011</label>
</control>
- <control type="button" id="7">
+ <control type="button" id="9">
<description>Hibernate button</description>
<width>340</width>
<height>40</height>
@@ -167,7 +199,7 @@
<font>font13</font>
<label>13010</label>
</control>
- <control type="button" id="8">
+ <control type="button" id="10">
<description>Reboot button</description>
<width>340</width>
<height>40</height>
@@ -183,7 +215,7 @@
<font>font13</font>
<label>13013</label>
</control>
- <control type="button" id="9">
+ <control type="button" id="11">
<description>Logoff button</description>
<width>340</width>
<height>40</height>
@@ -201,7 +233,7 @@
<visible>System.HasLoginScreen | IntegerGreaterThan(System.ProfileCount,1)</visible>
<visible>System.Loggedon</visible>
</control>
- <control type="togglebutton" id="10">
+ <control type="togglebutton" id="12">
<description>Master mode button</description>
<width>340</width>
<height>40</height>
@@ -222,7 +254,7 @@
<font>font13</font>
<visible>System.HasLocks</visible>
</control>
- <control type="group" id="11">
+ <control type="group" id="13">
<width>340</width>
<height>70</height>
<visible>System.HasAlarm(shutdowntimer)</visible>
@@ -246,7 +278,7 @@
<label>$LOCALIZE[31329] [B]$INFO[System.Alarmpos][/B]</label>
</control>
</control>
- <control type="image" id="12">
+ <control type="image" id="14">
<description>background bottom image</description>
<posx>0</posx>
<width>340</width>
@@ -1008,6 +1008,8 @@
<string id="13014">Minimize</string>
<string id="13015">Power button action</string>
<string id="13016">Power off System</string>
+ <string id="13017">Power off after play</string>
+ <string id="13018">Cancel power off after play</string>
<string id="13020">Is another session active, perhaps over ssh?</string>
<string id="13021">Mounted removable harddrive</string>
View
@@ -377,6 +377,9 @@ CApplication::CApplication(void)
m_bStandalone = false;
m_bEnableLegacyRes = false;
m_bSystemScreenSaverEnable = false;
+
+ m_bPowerdownAfterPlay = false;
+
m_pInertialScrollingHandler = new CInertialScrollingHandler();
#ifdef HAS_DVD_DRIVE
m_Autorun = new CAutorun();
@@ -1963,6 +1966,17 @@ float CApplication::GetDimScreenSaverLevel() const
return 100.0f;
}
+void CApplication::SetPowerdownAfterPlay(bool bOnOff)
+{
+ // toggle on m_bPowerdownAfterPlay only if supported
+ m_bPowerdownAfterPlay = g_powerManager.CanPowerdown() && bOnOff;
+}
+
+bool CApplication::GetPowerdownAfterPlay() const
+{
+ return m_bPowerdownAfterPlay;
+}
+
bool CApplication::WaitFrame(unsigned int timeout)
{
bool done = false;
@@ -4700,6 +4714,19 @@ bool CApplication::OnMessage(CGUIMessage& message)
g_windowManager.PreviousWindow();
}
+ // user wants XBMC to power off system after playing current item(s)
+ if (m_bPowerdownAfterPlay)
+ {
+ // abort power off if playback stopped
+ m_bPowerdownAfterPlay &= (message.GetMessage() != GUI_MSG_PLAYBACK_STOPPED);
+
+ // power off only when player ended playing the (last) item
+ if (m_bPowerdownAfterPlay && (message.GetMessage() == GUI_MSG_PLAYBACK_ENDED) && !IsPlaying())
+ {
+ g_application.getApplicationMessenger().Powerdown();
+ }
+ }
+
if (IsEnableTestMode()) g_application.getApplicationMessenger().Quit();
return true;
}
View
@@ -284,6 +284,10 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool ToggleDPMS(bool manual);
float GetDimScreenSaverLevel() const;
+
+ void SetPowerdownAfterPlay(bool bOnOff);
+ bool GetPowerdownAfterPlay() const;
+
protected:
bool LoadSkin(const CStdString& skinID);
void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);
@@ -311,6 +315,8 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
CStopWatch m_screenSaverTimer;
CStopWatch m_shutdownTimer;
+ bool m_bPowerdownAfterPlay;
+
DPMSSupport* m_dpms;
bool m_dpmsIsActive;
bool m_dpmsIsManual;
View
@@ -218,6 +218,7 @@ const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACT
{ "cansuspend", SYSTEM_CAN_SUSPEND },
{ "canhibernate", SYSTEM_CAN_HIBERNATE },
{ "canreboot", SYSTEM_CAN_REBOOT },
+ { "powerdownafterplay", SYSTEM_POWERDOWN_AFTER_PLAY },
{ "screensaveractive",SYSTEM_SCREENSAVER_ACTIVE },
{ "cputemperature", SYSTEM_CPU_TEMPERATURE }, // labels from here
{ "cpuusage", SYSTEM_CPU_USAGE },
@@ -1908,7 +1909,8 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
bReturn = g_powerManager.CanReboot();
else if (condition == SYSTEM_SCREENSAVER_ACTIVE)
bReturn = g_application.IsInScreenSaver();
-
+ else if (condition == SYSTEM_POWERDOWN_AFTER_PLAY)
+ bReturn = g_application.GetPowerdownAfterPlay();
else if (condition == PLAYER_SHOWINFO)
bReturn = m_playerShowInfo;
else if (condition == PLAYER_SHOWCODEC)
View
@@ -374,6 +374,7 @@ namespace INFO
#define SYSTEM_IDLE_TIME 715
#define SYSTEM_FRIENDLY_NAME 716
#define SYSTEM_SCREENSAVER_ACTIVE 717
+#define SYSTEM_POWERDOWN_AFTER_PLAY 718
#define LIBRARY_HAS_MUSIC 720
#define LIBRARY_HAS_VIDEO 721
@@ -108,6 +108,7 @@ const BUILT_IN commands[] = {
{ "Restart", false, "Restart the xbox (power cycle)" },
{ "ShutDown", false, "Shutdown the xbox" },
{ "Powerdown", false, "Powerdown system" },
+ { "PowerdownAfterPlay", false, "Powerdown system when playback ends" },
{ "Quit", false, "Quit XBMC" },
{ "Hibernate", false, "Hibernates the system" },
{ "Suspend", false, "Suspends the system" },
@@ -275,6 +276,15 @@ int CBuiltins::Execute(const CStdString& execString)
{
g_application.getApplicationMessenger().Minimize();
}
+ else if (execute.Equals("powerdownafterplay"))
+ {
+ bool powerOffAfterPlay = false;
+ if (params.size() > 0)
+ {
+ powerOffAfterPlay = params[0].Equals("true");
+ }
+ g_application.SetPowerdownAfterPlay(powerOffAfterPlay);
+ }
else if (execute.Equals("loadprofile"))
{
int index = g_settings.GetProfileIndex(parameter);