Author: dchapyshev Date: Thu Jan 15 09:32:30 2009 New Revision: 38769
URL: http://svn.reactos.org/svn/reactos?rev=38769&view=rev Log: - Add power.c file for power management functions - Move GetSystemPowerStatus, SetSystemPowerState, GetDevicePowerState, RequestDeviceWakeup, RequestWakeupLatency, CancelDeviceWakeupRequest, IsSystemResumeAutomatic, and SetMessageWaitingIndicator to power.c - Implement GetSystemPowerStatus
Added: trunk/reactos/dll/win32/kernel32/misc/power.c (with props) Modified: trunk/reactos/dll/win32/kernel32/kernel32.rbuild trunk/reactos/dll/win32/kernel32/misc/stubs.c
Modified: trunk/reactos/dll/win32/kernel32/kernel32.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel32... ============================================================================== --- trunk/reactos/dll/win32/kernel32/kernel32.rbuild [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/kernel32.rbuild [iso-8859-1] Thu Jan 15 09:32:30 2009 @@ -80,6 +80,7 @@ <file>muldiv.c</file> <file>nls.c</file> <file>perfcnt.c</file> + <file>power.c</file> <file>recovery.c</file> <file>res.c</file> <file>sortkey.c</file>
Added: trunk/reactos/dll/win32/kernel32/misc/power.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/pow... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/power.c (added) +++ trunk/reactos/dll/win32/kernel32/misc/power.c [iso-8859-1] Thu Jan 15 09:32:30 2009 @@ -1,0 +1,158 @@ +/* + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: dll/win32/kernel32/misc/power.c + * PURPOSE: Power Management Functions + * PROGRAMMER: Dmitry Chapyshev dmitry@reactos.org + * + * UPDATE HISTORY: + * 01/15/2009 Created + */ + +#include <k32.h> + +#define NDEBUG +#include <debug.h> + +#define STUB \ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); \ + DPRINT1("%s() is UNIMPLEMENTED!\n", __FUNCTION__) + +/* PUBLIC FUNCTIONS ***********************************************************/ + +/* + * @implemented + */ +BOOL +WINAPI +GetSystemPowerStatus(LPSYSTEM_POWER_STATUS PowerStatus) +{ + NTSTATUS Status; + SYSTEM_BATTERY_STATE SysBatState; + + Status = NtPowerInformation(SystemBatteryState, + NULL, + 0, + &SysBatState, + sizeof(SYSTEM_BATTERY_STATE)); + + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return FALSE; + } + + RtlZeroMemory(PowerStatus, sizeof(LPSYSTEM_POWER_STATUS)); + + PowerStatus->BatteryLifeTime = BATTERY_LIFE_UNKNOWN; + PowerStatus->BatteryFullLifeTime = BATTERY_LIFE_UNKNOWN; + + PowerStatus->BatteryLifePercent = BATTERY_PERCENTAGE_UNKNOWN; + if (SysBatState.MaxCapacity) + { + if (SysBatState.MaxCapacity >= SysBatState.RemainingCapacity) + PowerStatus->BatteryLifePercent = (SysBatState.RemainingCapacity / SysBatState.MaxCapacity) * 100; + else + PowerStatus->BatteryLifePercent = 100; /* 100% */ + + if (PowerStatus->BatteryLifePercent <= 32) + PowerStatus->BatteryFlag |= BATTERY_FLAG_LOW; + + if (PowerStatus->BatteryLifePercent >= 67) + PowerStatus->BatteryFlag |= BATTERY_FLAG_HIGH; + } + + if (!SysBatState.BatteryPresent) + PowerStatus->BatteryFlag |= BATTERY_FLAG_NO_BATTERY; + + if (SysBatState.Charging) + PowerStatus->BatteryFlag |= BATTERY_FLAG_CHARGING; + + if (!SysBatState.AcOnLine && SysBatState.BatteryPresent) + PowerStatus->ACLineStatus = AC_LINE_OFFLINE; + else + PowerStatus->ACLineStatus = AC_LINE_ONLINE; + + if (SysBatState.EstimatedTime) + PowerStatus->BatteryLifeTime = SysBatState.EstimatedTime; + + return TRUE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +SetSystemPowerState(BOOL fSuspend, BOOL fForce) +{ + STUB; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GetDevicePowerState(HANDLE hDevice, BOOL *pfOn) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +RequestDeviceWakeup(HANDLE hDevice) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +RequestWakeupLatency(LATENCY_TIME latency) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +CancelDeviceWakeupRequest(HANDLE hDevice) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +IsSystemResumeAutomatic(VOID) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +SetMessageWaitingIndicator(HANDLE hMsgIndicator, + ULONG ulMsgCount) +{ + STUB; + return 0; +}
Propchange: trunk/reactos/dll/win32/kernel32/misc/power.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/dll/win32/kernel32/misc/stubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/stu... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/stubs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/stubs.c [iso-8859-1] Thu Jan 15 09:32:30 2009 @@ -150,26 +150,6 @@ { STUB; return 0; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -GetSystemPowerStatus ( - LPSYSTEM_POWER_STATUS PowerStatus - ) -{ - STUB; - PowerStatus->ACLineStatus = 1; - PowerStatus->BatteryFlag = 128; - PowerStatus->BatteryLifePercent = 255; - PowerStatus->Reserved1 = 0; - PowerStatus->BatteryLifeTime = -1; - PowerStatus->BatteryFullLifeTime = -1; - return TRUE; }
@@ -243,20 +223,6 @@ /* * @unimplemented */ -BOOL WINAPI -SetSystemPowerState ( - BOOL fSuspend, - BOOL fForce - ) -{ - STUB; - return FALSE; -} - - -/* - * @unimplemented - */ BOOL WINAPI SetVDMCurrentDirectories ( @@ -372,19 +338,6 @@ */ BOOL WINAPI -CancelDeviceWakeupRequest( - HANDLE hDevice - ) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI CreateJobSet ( ULONG NumJob, PJOB_SET_ARRAY UserJobSet, @@ -416,20 +369,6 @@ HANDLE hProcess, PULONG_PTR NumberOfPages, PULONG_PTR PageArray - ) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GetDevicePowerState( - HANDLE hDevice, - BOOL *pfOn ) { STUB; @@ -505,19 +444,6 @@ HEAP_INFORMATION_CLASS HeapInformationClass, PVOID HeapInformation OPTIONAL, SIZE_T HeapInformationLength OPTIONAL - ) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -IsSystemResumeAutomatic( - VOID ) { STUB; @@ -612,32 +538,6 @@ /* * @unimplemented */ -BOOL -WINAPI -RequestDeviceWakeup( - HANDLE hDevice - ) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -RequestWakeupLatency( - LATENCY_TIME latency - ) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ UINT WINAPI ResetWriteWatch( @@ -659,20 +559,6 @@ ) { STUB; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -SetMessageWaitingIndicator( - HANDLE hMsgIndicator, - ULONG ulMsgCount - ) -{ - STUB; - return 0; }
/*