From: <mic...@us...> - 2012-02-09 16:58:44
|
Revision: 4443 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4443&view=rev Author: michael-t Date: 2012-02-09 16:58:34 +0000 (Thu, 09 Feb 2012) Log Message: ----------- Added Paths: ----------- trunk/plugins/PowerScheduler++/Stable/test/ trunk/plugins/PowerScheduler++/Stable/test/Binaries/ trunk/plugins/PowerScheduler++/Stable/test/Binaries/Common.Utils.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/Core.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/Gentle.Common.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/Gentle.Framework.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/PluginBase.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/SetupControls.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/TVDatabase.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/TVLibrary.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvBusinessLayer.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvControl.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvLibrary.Interfaces.dll trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvService.exe trunk/plugins/PowerScheduler++/Stable/test/Binaries/Utils.dll trunk/plugins/PowerScheduler++/Stable/test/CleanupFiles.bat trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/EPGWakeupConfig.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IEpgHandler.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerController.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerScheduler.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerSettings.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IStandbyHandler.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IWakeupHandler.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerManager.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerScheduler.Interfaces.csproj trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSchedulerEventArgs.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSettings.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Properties/ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Properties/AssemblyInfo.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/RemotePowerControl.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/TimerException.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/WaitableTimer.cs trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/WakeOnLanManager.cs trunk/plugins/PowerScheduler++/Stable/test/CopyFiles.bat trunk/plugins/PowerScheduler++/Stable/test/MPEI/ trunk/plugins/PowerScheduler++/Stable/test/MPEI/PowerScheduler++ 1.2.2.1.mpe1 trunk/plugins/PowerScheduler++/Stable/test/MPEI/PowerScheduler++.xmp2 trunk/plugins/PowerScheduler++/Stable/test/MPEI/PowerScheduler_high.png trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot01.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot02.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot03.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot04.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot05.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot06.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot07.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/Screenshot08.jpg trunk/plugins/PowerScheduler++/Stable/test/MPEI/update.xml trunk/plugins/PowerScheduler++/Stable/test/PowerScheduler++.sln trunk/plugins/PowerScheduler++/Stable/test/RestoreFiles.bat trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/ trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/ trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/ trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/ trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ActiveNetworkHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ActiveSharesHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ActiveStreamsHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ControllerActiveHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/EpgGrabbingHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/GenericStandbyHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/GenericWakeupHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ProcessActiveHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/RebootHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/RemoteClientStandbyHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/RemoteStandbyHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/RemoteWakeupHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/ScheduledRecordingsHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Handlers/XmlTvImportWakeupHandler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerScheduler.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerScheduler.csproj trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerSchedulerFactory.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerSchedulerMasterSetup.Designer.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerSchedulerMasterSetup.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerSchedulerMasterSetup.resx trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerSchedulerPlugin.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Properties/ trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/Properties/AssemblyInfo.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/SelectProcessForm.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/SelectProcessForm.designer.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/SelectProcessForm.resx trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/SelectShareForm.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/SelectShareForm.designer.cs trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/SelectShareForm.resx trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/TheAlgorithm.txt trunk/plugins/PowerScheduler++/Stable/test/TvEngine3/TVLibrary/Plugins/PowerScheduler/WindowsController.cs trunk/plugins/PowerScheduler++/Stable/test/VersionInfo.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/ trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/ trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/Handlers/ trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/Handlers/WakeableStandbyHandler.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/Handlers/WakeableWakeupHandler.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerScheduler.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerScheduler.gif trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerSchedulerClientPlugin.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerSchedulerClientPlugin.csproj trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerSchedulerClientSetup.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerSchedulerClientSetup.designer.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerSchedulerClientSetup.resx trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/PowerScheduler_disabled.gif trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/Properties/ trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/Properties/AssemblyInfo.cs trunk/plugins/PowerScheduler++/Stable/test/mediaportal/PowerSchedulerClientPlugin/UnattendedWindow.cs Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Common.Utils.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Common.Utils.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Core.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Core.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Gentle.Common.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Gentle.Common.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Gentle.Framework.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Gentle.Framework.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/PluginBase.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/PluginBase.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/SetupControls.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/SetupControls.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TVDatabase.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TVDatabase.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TVLibrary.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TVLibrary.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvBusinessLayer.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvBusinessLayer.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvControl.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvControl.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvLibrary.Interfaces.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvLibrary.Interfaces.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvService.exe =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/TvService.exe ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Utils.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/PowerScheduler++/Stable/test/Binaries/Utils.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/PowerScheduler++/Stable/test/CleanupFiles.bat =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/CleanupFiles.bat (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/CleanupFiles.bat 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,75 @@ +@echo off +set PROJECTPATH=%~dp0 +if "%ProgramFiles(x86)%" == "" goto 32bit +set SERVERPATH=%ProgramFiles(x86)%\Team MediaPortal\MediaPortal TV Server +set CLIENTPATH=%ProgramFiles(x86)%\Team MediaPortal\MediaPortal +goto data +:32bit +set SERVERPATH=%ProgramFiles%\Team MediaPortal\MediaPortal TV Server +set CLIENTPATH=%ProgramFiles%\Team MediaPortal\MediaPortal +:data +if "%ProgramData%" == "" goto winXP +set SERVERLOGPATH=%ProgramData%\Team MediaPortal\MediaPortal TV Server\log +goto count +:winXP +set SERVERLOGPATH=%ALLUSERSPROFILE%\Application Data\Team MediaPortal\MediaPortal TV Server\log + +:count +set COUNT=1 + +echo Stopping TV Server +echo --------------------- +:stop +echo trying... +net stop tvservice > nul 2>nul +tasklist | find /i "tvservice" >nul 2>nul +if not %ERRORLEVEL% == 1 ( + ping localhost >nul 2>nul + set /a COUNT=%COUNT%+1 + if %COUNT% GTR 5 goto end + goto stop +) +echo. + +echo MediaPortal TV Server +echo --------------------- +for %%f in (Plugins\PowerScheduler.dll) do ( + echo %%f + if exist "%SERVERPATH%\%%f.org" ( + del "%SERVERPATH%\%%f" + move /Y "%SERVERPATH%\%%f.org" "%SERVERPATH%\%%f" + ) 2>nul +) +echo. +echo MediaPortal Common Library +echo ---------------------------------- +for %%f in (PowerScheduler.Interfaces.dll) do ( + echo %%f + if exist "%SERVERPATH%\%%f.org" ( + del "%SERVERPATH%\%%f" + move /Y "%SERVERPATH%\%%f.org" "%SERVERPATH%\%%f" + ) 2>nul + if exist "%CLIENTPATH%\%%f.org" ( + del "%CLIENTPATH%\%%f" + move /Y "%CLIENTPATH%\%%f.org" "%CLIENTPATH%\%%f" + ) 2>nul +) +echo. +echo MediaPortal Client +echo ------------------ +for %%f in (plugins\process\PowerSchedulerClientPlugin.dll) do ( + echo %%f + if exist "%CLIENTPATH%\%%f.org" ( + del "%CLIENTPATH%\%%f" + move /Y "%CLIENTPATH%\%%f.org" "%CLIENTPATH%\%%f" + ) 2>nul +) +echo. +echo Cleanup +echo ------------------ +move /Y "%SERVERLOGPATH%\tv.log" "%SERVERLOGPATH%\tv_old.log" +net start tvservice +echo. +:end +pause +exit \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/EPGWakeupConfig.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/EPGWakeupConfig.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/EPGWakeupConfig.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,125 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; + +#endregion + +namespace TvEngine.PowerScheduler +{ + + #region Enums + + public enum EPGGrabDays + { + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday, + Sunday + } + + #endregion + + [Serializable] + public class EPGWakeupConfig + { + public DateTime LastRun = DateTime.MinValue; + public List<EPGGrabDays> Days = new List<EPGGrabDays>(); + public int Hour; + public int Minutes; + + public EPGWakeupConfig() {} + + public EPGWakeupConfig(string serializedConfig) + { + EPGWakeupConfig cfg = new EPGWakeupConfig(); + try + { + BinaryFormatter formatter = new BinaryFormatter(); + byte[] buffer = Convert.FromBase64String(serializedConfig); + using (MemoryStream stream = new MemoryStream(buffer, 0, buffer.Length)) + { + cfg = (EPGWakeupConfig)formatter.Deserialize(stream); + } + } + catch (Exception) {} + Hour = cfg.Hour; + Minutes = cfg.Minutes; + Days = cfg.Days; + LastRun = cfg.LastRun; + } + + public string SerializeAsString() + { + BinaryFormatter formatter = new BinaryFormatter(); + string result; + using (MemoryStream stream = new MemoryStream()) + { + formatter.Serialize(stream, this); + stream.Flush(); + stream.Seek(0, SeekOrigin.Begin); + byte[] buffer = new byte[stream.Length]; + int bytesRead = stream.Read(buffer, 0, buffer.Length); + result = Convert.ToBase64String(buffer, 0, bytesRead); + } + return result; + } + + public override bool Equals(object obj) + { + if (obj is EPGWakeupConfig) + { + EPGWakeupConfig cfg = (EPGWakeupConfig)obj; + if (cfg.Hour == Hour && cfg.Minutes == Minutes) + { + foreach (EPGGrabDays day in cfg.Days) + { + if (!Days.Contains(day)) + { + return false; + } + } + foreach (EPGGrabDays day in Days) + { + if (!cfg.Days.Contains(day)) + { + return false; + } + } + return true; + } + } + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IEpgHandler.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IEpgHandler.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IEpgHandler.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,65 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + public delegate void EPGScheduleHandler(); + + /// <summary> + /// Provides access to PowerScheduler's EPG interface for + /// EPG plugins. + /// </summary> + public interface IEpgHandler + { + /// <summary> + /// Allows an external EPG source to prevent standby when it's + /// grabbing EPG + /// </summary> + /// <param name="source">the source preventing standby</param> + /// <param name="allowed">is standby allowed?</param> + void SetStandbyAllowed(object source, bool allowed, int timeout); + + /// <summary> + /// Allows an external EPG source to set a preferred next wakeup time + /// </summary> + /// <param name="source">the source that wants to wakeup the system for EPG grabbing</param> + /// <param name="time">the desired time to wakeup the system</param> + void SetNextEPGWakeupTime(object source, DateTime time); + + /// <summary> + /// Allows an external EPG source to retrieve the next wakeup time + /// for EPG grabbing. This time can be used to start an actual EPG + /// grabbing process. + /// </summary> + /// <returns>next EPG grab wakeup time</returns> + DateTime GetNextEPGWakeupTime(); + + /// <summary> + /// Event which gets fired when the configured EPG wakeup schedule is due. + /// </summary> + event EPGScheduleHandler EPGScheduleDue; + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerController.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerController.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerController.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,108 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + /// <summary> + /// Public interface to PowerScheduler power control + /// Intented to be used by singleseat setups + /// </summary> + public interface IPowerController + { + /// <summary> + /// Requests suspension of the system. Uses default action. + /// </summary> + /// <param name="source">description of who wants to suspend the system</param> + /// <param name="force">force the system to suspend (not recommended)</param> + void SuspendSystem(string source, bool force); + + /// <summary> + /// Requests suspension of the system. + /// </summary> + /// <param name="source"></param> + /// <param name="how">How to suspend, see MediaPortal.Util.RestartOptions</param> + /// <param name="force"></param> + void SuspendSystem(string source, int how, bool force); + + /// <summary> + /// Enables clients on singleseat setups to indicate whether or not the system + /// is allowed to enter standby + /// </summary> + /// <param name="standbyAllowed">is standby allowed?</param> + /// <param name="handlerName">client handlername which prevents standby</param> + void SetStandbyAllowed(bool standbyAllowed, string handlerName); + + /// <summary> + /// Enables clients on singleseat setups to indicate when the next + /// earliest wakeup time is due + /// </summary> + /// <param name="nextWakeupTime">DateTime when to wakeup the system</param> + /// <param name="handlerName">client handlername which is responsible for this wakeup time</param> + void SetNextWakeupTime(DateTime nextWakeupTime, string handlerName); + + /// <summary> + /// Resets the idle timer of the PowerScheduler. When enough time has passed (IdleTimeout), the system + /// is suspended as soon as possible (no handler disallows shutdown). + /// Note that the idle timer is automatically reset to now when the user moves the mouse or touchs the keyboard. + /// </summary> + void UserActivityDetected(DateTime when); + + /// <summary> + /// Register remote handlers. If an empty string or null is passed, no handler is registered for + /// that type. It returns a tag used to unregister the later. The returned tag is always not 0. + /// </summary> + /// <param name="standbyHandlerURI"></param> + /// <param name="wakeupHandlerURI"></param> + int RegisterRemote(String standbyHandlerURI, String wakeupHandlerURI); + + /// <summary> + /// Unregister remote handlers. + /// </summary> + void UnregisterRemote(int tag); + + /// <summary> + /// Indicates whether or not we're connected to the PowerScheduler power control interfaces + /// </summary> + bool IsConnected { get; } + + /// <summary> + /// Get the current state. If refresh is true, the state is the most current state, otherwise the state could be some seconds old. + /// Special case: If shutdown is not allowed because an event is almost due, the handler name is "EVENT-DUE". + /// </summary> + /// <param name="refresh"></param> + /// <param name="disAllowShutdown"></param> + /// <param name="disAllowShutdownHandler"></param> + /// <param name="nextWakeupTime"></param> + /// <param name="nextWakeupHandler"></param> + void GetCurrentState(bool refresh, out bool unattended, out bool disAllowShutdown, + out String disAllowShutdownHandler, out DateTime nextWakeupTime, out String nextWakeupHandler); + + /// <summary> + /// Provides access to PowerScheduler's settings + /// </summary> + IPowerSettings PowerSettings { get; } + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerScheduler.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerScheduler.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerScheduler.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,129 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + /// <summary> + /// EvenHandler delegate for PowerScheduler events + /// </summary> + /// <param name="args"></param> + public delegate void PowerSchedulerEventHandler(PowerSchedulerEventArgs args); + + /// <summary> + /// Interface to PowerScheduler + /// </summary> + public interface IPowerScheduler + { + /// <summary> + /// Register to this event to receive status changes from the PowerScheduler + /// </summary> + event PowerSchedulerEventHandler OnPowerSchedulerEvent; + + /// <summary> + /// Registers an IStandbyHandler implementation + /// </summary> + /// <param name="handler">implementation to register for handling standby requests</param> + void Register(IStandbyHandler handler); + + /// <summary> + /// Registers an IWakeupHandler implementation + /// </summary> + /// <param name="handler">implementation to register for handling system resume time</param> + void Register(IWakeupHandler handler); + + /// <summary> + /// Unregisters an IStandbyHandler implementation + /// </summary> + /// <param name="handler">implementation to unregister for handling standby requests</param> + void Unregister(IStandbyHandler handler); + + /// <summary> + /// Registers an IWakeupHandler implementation + /// </summary> + /// <param name="handler">implementation to register for handling system resume time</param> + void Unregister(IWakeupHandler handler); + + /// <summary> + /// Checks if the given IStandbyHandler is registered + /// </summary> + /// <param name="handler">IStandbyHandler to check</param> + /// <returns>is the given handler registered?</returns> + bool IsRegistered(IStandbyHandler handler); + + /// <summary> + /// Checks if the given IWakeupHandler is registered + /// </summary> + /// <param name="handler">IWakeupHandler to check</param> + /// <returns>is the given handler registered?</returns> + bool IsRegistered(IWakeupHandler handler); + + /// <summary> + /// Requests suspension of the system + /// </summary> + /// <param name="source">description of who wants to suspend the system</param> + /// <param name="force">force the system to suspend (not recommended)</param> + void SuspendSystem(string source, bool force); + + /// <summary> + /// Requests suspension of the system. + /// </summary> + /// <param name="source"></param> + /// <param name="how">How to suspend, see MediaPortal.Util.RestartOptions</param> + /// <param name="force"></param> + void SuspendSystem(string source, int how, bool force); + + /// <summary> + /// Resets the idle timer of the PowerScheduler. When enough time has passed (IdleTimeout), the system + /// is suspended as soon as possible (no handler disallows shutdown). + /// Note that the idle timer is automatically reset to now when the user moves the mouse or touchs the keyboard. + /// </summary> + void UserActivityDetected(DateTime when); + + /// <summary> + /// Get the current state. If refresh is true, the state is the most current state, otherwise the state could be some seconds old. + /// Special case: If shutdown is not allowed because an event is almost due, the handler name is "EVENT-DUE". + /// </summary> + /// <param name="refresh"></param> + /// <param name="disAllowShutdown"></param> + /// <param name="disAllowShutdownHandler"></param> + /// <param name="nextWakeupTime"></param> + /// <param name="nextWakeupHandler"></param> + void GetCurrentState(bool refresh, out bool unattended, out bool disAllowShutdown, + out String disAllowShutdownHandler, out DateTime nextWakeupTime, out String nextWakeupHandler); + + + /// <summary> + /// Checks if a suspend request is in progress + /// </summary> + /// <returns>is the system currently trying to suspend?</returns> + bool IsSuspendInProgress(); + + /// <summary> + /// Provides access to PowerScheduler's settings + /// </summary> + PowerSettings Settings { get; } + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerSettings.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerSettings.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IPowerSettings.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,82 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + /// <summary> + /// Provides access to PowerScheduler's settings + /// </summary> + public interface IPowerSettings + { + /// <summary> + /// Should PowerScheduler actively try to put the system into standby? + /// </summary> + bool ShutdownEnabled { get; } + + /// <summary> + /// Should PowerScheduler check when any plugin wants to wakeup the system? + /// </summary> + bool WakeupEnabled { get; } + + /// <summary> + /// Should the shutdown attemps be forced? + /// </summary> + bool ForceShutdown { get; } + + /// <summary> + /// Should PowerScheduler be verbose when logging? + /// </summary> + bool ExtensiveLogging { get; } + + /// <summary> + /// If ShutdownEnabled, how long (in minutes) to wait before putting the + /// system into standby + /// </summary> + int IdleTimeout { get; } + + /// <summary> + /// if WakeupEnabled, the time (in seconds) to wakeup the system earlier than + /// the actual wakeup time + /// </summary> + int PreWakeupTime { get; } + + /// <summary> + /// If WakeupEnabled, the time (in seconds) the system is not allowed to + /// go to shutdown before the next wakeup time + /// </summary> + int PreNoShutdownTime { get; } + + /// <summary> + /// Controls the granularity of the standby/wakeup checks in seconds + /// </summary> + int CheckInterval { get; } + + /// <summary> + /// How should put the system into standby? suspend/hibernate/stayon + /// suspend uses S3, hibernate uses S4, stayon is for debugging purposes and + /// doesn't put the system into standby at all + /// </summary> + ShutdownMode ShutdownMode { get; } + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IStandbyHandler.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IStandbyHandler.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IStandbyHandler.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,56 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + public interface IStandbyHandler + { + /// <summary> + /// Indicator whether or not to allow suspension/hibernation of the system + /// </summary> + bool DisAllowShutdown { get; } + + /// <summary> + /// Called when the user turns away from the system. + /// </summary> + void UserShutdownNow(); + + /// <summary> + /// Description of the source that allows / disallows shutdown + /// </summary> + string HandlerName { get; } + } + + /// <summary> + /// Extension to the IStandbyHandler interface for away mode + /// </summary> + public interface IStandbyHandlerEx : IStandbyHandler + { + /// <summary> + /// Indicator whether away mode is required by standby handler or not + /// </summary> + bool RequireAwayMode { get; } + } + +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IWakeupHandler.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IWakeupHandler.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/Interfaces/IWakeupHandler.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,46 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + /// <summary> + /// To be implemented by classes who want to control system resume + /// </summary> + public interface IWakeupHandler + { + /// <summary> + /// Should return the earliest time the implementation desires to wake up the system. + /// </summary> + /// <param name="earliestWakeupTime">indicates the earliest valid wake up time that is considered valid by the PowerScheduler</param> + /// <returns>earliest time the implementation wants to wake up the system</returns> + DateTime GetNextWakeupTime(DateTime earliestWakeupTime); + + /// <summary> + /// Description of the source that want to wake up the system at the given time + /// </summary> + string HandlerName { get; } + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerManager.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerManager.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerManager.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,283 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; +using System.Runtime.InteropServices; +using System.Threading; + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + /// <summary> + /// Provides methods for handling system power events + /// </summary> + public class PowerManager + { + #region Variables + + /// <summary> + /// Enable / disable away mode + /// </summary> + private bool _awayMode; + + /// <summary> + /// Thread for calling SetThreadExecutionState() + /// </summary> + private Thread _awayModeThread; + + #endregion + + #region Constructor/Destructor + + /// <summary> + /// Constructor starts the thread for away mode and inits PowerSettings array + /// </summary> + unsafe public PowerManager() + { + if (Environment.OSVersion.Version.Major >= 6) + { + // Start the thread to enable/disable away mode + _awayModeThread = new Thread(AwayModeThread); + _awayModeThread.Name = "ExecutionStateThread"; + _awayModeThread.IsBackground = true; + _awayModeThread.Start(); + } + } + + ~PowerManager() + { + if (_awayModeThread != null) + { + _awayModeThread.Abort(); + _awayModeThread.Join(100); + _awayModeThread = null; + } + } + + #endregion + + #region External power management methods and enumerations + + /// <summary> + /// The thread's execution requirements + /// </summary> + [Flags] + private enum ExecutionState : uint + { + /// <summary> + /// Some error. + /// </summary> + Error = 0, + + /// <summary> + /// System is required, do not hibernate. + /// </summary> + ES_SYSTEM_REQUIRED = 0x00000001, + + /// <summary> + /// Display is required, do not hibernate. + /// </summary> + ES_DISPLAY_REQUIRED = 0x00000002, + + /// <summary> + /// User is active, do not hibernate. + /// </summary> + ES_USER_PRESENT = 0x00000004, + + /// <summary> + /// Enables away mode. + /// </summary> + ES_AWAYMODE_REQUIRED = 0x00000040, + + /// <summary> + /// Use together with the above options to report a + /// state until explicitly changed. + /// </summary> + ES_CONTINUOUS = 0x80000000 + } + + /// <summary> + /// Enables an application to inform the system that it is in use, thereby preventing the system + /// from entering sleep or turning off the display while the application is running. + /// </summary> + /// <param name="esFlags">The thread's execution requirements + /// /// </param> + /// <returns> + /// If the function succeeds, the return value is the previous thread execution state. + /// If the function fails, the return value is NULL. + /// </returns> + [DllImport("kernel32.dll", SetLastError = true, EntryPoint = "SetThreadExecutionState")] + private static extern ExecutionState SetThreadExecutionState(ExecutionState esFlags); + + #endregion + + #region Power management wrapper methods + + /// <summary> + /// Set the PowerManager to allow standby + /// </summary> + /// <returns>bool indicating whether or not standby is allowed</returns> + public bool AllowStandby() + { + return true; + } + + /// <summary> + /// Set the PowerManager to prevent standby + /// </summary> + /// <returns>bool indicating whether or not standby is prevented</returns> + public bool PreventStandby() + { + lock (this) + { + ExecutionState result = SetThreadExecutionState(ExecutionState.ES_SYSTEM_REQUIRED); + //Log.Debug("PowerManager.PreventStandBy: SetThreadExecutionState() returned: {0}", result.ToString()); + if (result == ExecutionState.Error) + { + return false; + } + return true; + } + } + + /// <summary> + /// Sets AwayModeRequired execution state; triggers AwayModeThread to do the real work + /// </summary> + /// <param name="awayModeRequired">Enable/disable away mode</param> + public void SetAwayModeRequired(bool awayModeRequired) + { + if (Environment.OSVersion.Version.Major >= 6) + { + Monitor.Enter(_awayModeThread); + _awayMode = awayModeRequired; + Monitor.Pulse(_awayModeThread); + Monitor.Exit(_awayModeThread); + } + } + + /// <summary> + /// Gets triggered by SetAwayMode and sets the execution state to the desired value + /// /// </summary> + private void AwayModeThread() + { + while (true) + { + Monitor.Enter(_awayModeThread); + Monitor.Wait(_awayModeThread); + if (_awayMode) + SetThreadExecutionState(ExecutionState.ES_AWAYMODE_REQUIRED | ExecutionState.ES_CONTINUOUS); + else + SetThreadExecutionState(ExecutionState.ES_CONTINUOUS); + Monitor.Exit(_awayModeThread); + } + } + + #endregion + + #region External power setting change notification methods and enumerations + + /// <summary> + /// Flags to register for power setting change notification + /// </summary> + private const int DEVICE_NOTIFY_WINDOW_HANDLE = 0x00000000; + private const int DEVICE_NOTIFY_SERVICE_HANDLE = 0x00000001; + + /// <summary> + /// Handle to unregister for power setting change notification + /// </summary> + private IntPtr hAwayMode; + + /// <summary> + /// Constants for power notifications + /// </summary> + public const int WM_POWERBROADCAST = 0x0218; + public const int PBT_APMQUERYSUSPEND = 0x0000; + public const int PBT_APMQUERYSUSPENDFAILED = 0x0002; + public const int PBT_APMSUSPEND = 0x0004; + public const int PBT_APMRESUMECRITICAL = 0x0006; + public const int PBT_APMRESUMESUSPEND = 0x0007; + public const int PBT_APMRESUMEAUTOMATIC = 0x0012; + public const int PBT_POWERSETTINGCHANGE = 0x8013; + public const int BROADCAST_QUERY_DENY = 0x424D5144; + + /// <summary> + /// This structure is sent when the PBT_POWERSETTINGSCHANGE message is sent. + /// It describes the power setting that has changed and contains data about the change + /// </summary> + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct POWERBROADCAST_SETTING + { + public Guid PowerSetting; + public uint DataLength; + public byte Data; + } + + /// <summary> + /// Guid to register for power setting change notification + /// </summary> + public static Guid GUID_SYSTEM_AWAYMODE = new Guid("98a7f580-01f7-48aa-9c0f-44352c29e5C0"); + + /// <summary> + /// + /// </summary> + /// <param name="hRecipient"></param> + /// <param name="PowerSettingGuid"></param> + /// <param name="Flags"></param> + /// <returns></returns> + [DllImport(@"User32", SetLastError = true, EntryPoint = "RegisterPowerSettingNotification", CallingConvention = CallingConvention.StdCall)] + private static extern IntPtr RegisterPowerSettingNotification(IntPtr hRecipient, ref Guid PowerSettingGuid, Int32 Flags); + + /// <summary> + /// + /// </summary> + /// <param name="handle"></param> + /// <returns></returns> + [DllImport(@"User32", SetLastError = true, EntryPoint = "UnregisterPowerSettingNotification", CallingConvention = CallingConvention.StdCall)] + private static extern bool UnregisterPowerSettingNotification(IntPtr handle); + + #endregion + + #region Power setting change notification wrapper methods + + /// <summary> + /// Register for away mode notifications + /// </summary> + /// <param name="hRecipient">Window handle (e.g. GUIGraphicsContext.ActiveForm)</param> + public void RegisterAwayModeNotification(IntPtr hRecipient) + { + if (Environment.OSVersion.Version.Major >= 6) + hAwayMode = RegisterPowerSettingNotification(hRecipient, ref GUID_SYSTEM_AWAYMODE, DEVICE_NOTIFY_WINDOW_HANDLE); + } + + /// <summary> + /// Unregister for away mode notifications + /// </summary> + public void UnregisterAwayModeNotification() + { + if (Environment.OSVersion.Version.Major >= 6) + UnregisterPowerSettingNotification(hAwayMode); + } + + #endregion + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerScheduler.Interfaces.csproj =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerScheduler.Interfaces.csproj (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerScheduler.Interfaces.csproj 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7701AA79-18D4-4A18-BB52-16774FB7943D}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>TvEngine.PowerScheduler.Interfaces</RootNamespace> + <AssemblyName>PowerScheduler.Interfaces</AssemblyName> + <StartupObject> + </StartupObject> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>3.5</OldToolsVersion> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <ItemGroup> + <Compile Include="..\..\VersionInfo.cs"> + <Link>VersionInfo.cs</Link> + </Compile> + <Compile Include="EPGWakeupConfig.cs" /> + <Compile Include="Interfaces\IEpgHandler.cs" /> + <Compile Include="Interfaces\IPowerController.cs" /> + <Compile Include="Interfaces\IPowerScheduler.cs" /> + <Compile Include="Interfaces\IPowerSettings.cs" /> + <Compile Include="Interfaces\IStandbyHandler.cs" /> + <Compile Include="Interfaces\IWakeupHandler.cs" /> + <Compile Include="PowerManager.cs" /> + <Compile Include="PowerSchedulerEventArgs.cs" /> + <Compile Include="PowerSettings.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="RemotePowerControl.cs" /> + <Compile Include="TimerException.cs" /> + <Compile Include="WaitableTimer.cs" /> + <Compile Include="WakeOnLanManager.cs" /> + </ItemGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> +</Project> \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSchedulerEventArgs.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSchedulerEventArgs.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSchedulerEventArgs.cs 2012-02-09 16:58:34 UTC (rev 4443) @@ -0,0 +1,127 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +// Copyright (C) 2005-2011 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +#region Usings + +using System; + +#endregion + +namespace TvEngine.PowerScheduler.Interfaces +{ + + #region Enums + + /// <summary> + /// All possible event types sent by PowerScheduler + /// </summary> + public enum PowerSchedulerEventType + { + /// <summary> + /// Sent when PowerScheduler is started + /// </summary> + Started, + /// <summary> + /// Sent when PowerScheduler is stopped + /// </summary> + Stopped, + /// <summary> + /// Sent when Powerscheduler settings have changed + /// </summary> + SettingsChanged, + /// <summary> + /// Sent when PowerScheduler detects the system state changed from idle to busy + /// </summary> + SystemBusy, + /// <summary> + /// Sent when PowerScheduler detects the system state changed from busy to idle + /// </summary> + SystemIdle, + /// <summary> + /// Sent when PowerScheduler is about to put the system into standby or when + /// powerscheduler detects the system is put into standby + /// </summary> + EnteringStandby, + /// <summary> + /// Sent when PowerScheduler detects the system resumed from standby + /// </summary> + ResumedFromStandby, + /// <summary> + /// Sent when PowerScheduler's check interval is due again + /// (so, sent every PowerSettings.CheckInterval seconds) + /// </summary> + Elapsed + } + + #endregion + + /// <summary> + /// PowerSchedulerEventArgs are sent by PowerScheduler when the status of PowerScheduler changes. + /// To find out the exact event type inspect the EventType property + /// </summary> + public class PowerSchedulerEventArgs : EventArgs + { + #region Variables + + private PowerSchedulerEventType _eventType; + private object _data; + private Type _dataType; + + #endregion + + #region Constructor + + public PowerSchedulerEventArgs(PowerSchedulerEventType eventType) + { + _eventType = eventType; + } + + #endregion + + #region Public methods + + public void SetData<T>(object o) + { + _dataType = typeof (T); + _data = o; + } + + public T GetData<T>() + { + Type dataType = typeof (T); + if (_dataType == dataType) + { + return (T)_data; + } + return default(T); + } + + #endregion + + #region Properties + + public PowerSchedulerEventType EventType + { + get { return _eventType; } + } + + #endregion + } +} \ No newline at end of file Added: trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSettings.cs =================================================================== --- trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSettings.cs (rev 0) +++ trunk/plugins/PowerScheduler++/Stable/test/Common-MP-TVE3/PowerScheduler.Interfaces/PowerSe... [truncated message content] |