mf/tests: Test IMediaObject_GetOutputSizeInfo.
[wine.git] / dlls / kernel32 / powermgnt.c
blobae83de3c5237d2227bc5f56c015c072f8c65375f
1 /*
2 * Copyright 1995 Thomas Sandford (tdgsandf@prds-grn.demon.co.uk)
3 * Copyright 2003 Dimitrie O. Paun
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #include "ntstatus.h"
23 #define WIN32_NO_STATUS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winternl.h"
27 #include "kernel_private.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(powermgnt);
32 /******************************************************************************
33 * GetDevicePowerState (KERNEL32.@)
35 BOOL WINAPI GetDevicePowerState(HANDLE hDevice, BOOL* pfOn)
37 WARN("(hDevice %p pfOn %p): stub\n", hDevice, pfOn);
38 return TRUE; /* no information */
41 /***********************************************************************
42 * GetSystemPowerStatus (KERNEL32.@)
44 BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS ps)
46 SYSTEM_BATTERY_STATE bs;
47 NTSTATUS status;
49 TRACE("(%p)\n", ps);
51 ps->ACLineStatus = AC_LINE_UNKNOWN;
52 ps->BatteryFlag = BATTERY_FLAG_UNKNOWN;
53 ps->BatteryLifePercent = BATTERY_PERCENTAGE_UNKNOWN;
54 ps->SystemStatusFlag = 0;
55 ps->BatteryLifeTime = BATTERY_LIFE_UNKNOWN;
56 ps->BatteryFullLifeTime = BATTERY_LIFE_UNKNOWN;
58 status = NtPowerInformation(SystemBatteryState, NULL, 0, &bs, sizeof(bs));
59 if (status == STATUS_NOT_IMPLEMENTED) return TRUE;
60 if (FAILED(status)) return FALSE;
62 ps->ACLineStatus = bs.AcOnLine;
64 if (bs.BatteryPresent)
66 ps->BatteryLifePercent = bs.MaxCapacity ? 100 * bs.RemainingCapacity / bs.MaxCapacity : 100;
67 ps->BatteryLifeTime = bs.EstimatedTime;
68 if (!bs.Charging && (LONG)bs.Rate < 0)
69 ps->BatteryFullLifeTime = 3600 * bs.MaxCapacity / -(LONG)bs.Rate;
71 ps->BatteryFlag = 0;
72 if (bs.Charging)
73 ps->BatteryFlag |= BATTERY_FLAG_CHARGING;
74 if (ps->BatteryLifePercent > 66)
75 ps->BatteryFlag |= BATTERY_FLAG_HIGH;
76 if (ps->BatteryLifePercent < 33)
77 ps->BatteryFlag |= BATTERY_FLAG_LOW;
78 if (ps->BatteryLifePercent < 5)
79 ps->BatteryFlag |= BATTERY_FLAG_CRITICAL;
81 else
83 ps->BatteryFlag = BATTERY_FLAG_NO_BATTERY;
86 return TRUE;
89 /***********************************************************************
90 * IsSystemResumeAutomatic (KERNEL32.@)
92 BOOL WINAPI IsSystemResumeAutomatic(void)
94 WARN("(): stub, harmless.\n");
95 return FALSE;
98 /***********************************************************************
99 * RequestWakeupLatency (KERNEL32.@)
101 BOOL WINAPI RequestWakeupLatency(LATENCY_TIME latency)
103 WARN("(): stub, harmless.\n");
104 return TRUE;
107 /***********************************************************************
108 * RequestDeviceWakeup (KERNEL32.@)
110 BOOL WINAPI RequestDeviceWakeup(HANDLE device)
112 FIXME("(%p): stub\n", device);
113 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
114 return FALSE;
117 /***********************************************************************
118 * SetSystemPowerState (KERNEL32.@)
120 BOOL WINAPI SetSystemPowerState(BOOL suspend_or_hibernate,
121 BOOL force_flag)
123 WARN("(): stub, harmless.\n");
124 return TRUE;
127 /***********************************************************************
128 * SetThreadExecutionState (KERNEL32.@)
130 * Informs the system that activity is taking place for
131 * power management purposes.
133 EXECUTION_STATE WINAPI SetThreadExecutionState(EXECUTION_STATE flags)
135 EXECUTION_STATE old;
137 NtSetThreadExecutionState(flags, &old);
139 return old;
142 /***********************************************************************
143 * PowerCreateRequest (KERNEL32.@)
145 HANDLE WINAPI PowerCreateRequest(REASON_CONTEXT *context)
147 FIXME("(%p): stub\n", context);
149 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
150 return INVALID_HANDLE_VALUE;
153 /***********************************************************************
154 * PowerSetRequest (KERNEL32.@)
156 BOOL WINAPI PowerSetRequest(HANDLE request, POWER_REQUEST_TYPE type)
158 FIXME("(%p, %u): stub\n", request, type);
160 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
161 return FALSE;
164 /***********************************************************************
165 * PowerClearRequest (KERNEL32.@)
167 BOOL WINAPI PowerClearRequest(HANDLE request, POWER_REQUEST_TYPE type)
169 FIXME("(%p, %u): stub\n", request, type);
171 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
172 return FALSE;