- Implement GetDevicePowerState
authorDmitry Chapyshev <dmitry@reactos.org>
Thu, 15 Jan 2009 16:09:03 +0000 (16:09 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Thu, 15 Jan 2009 16:09:03 +0000 (16:09 +0000)
- Implement RequestWakeupLatency
- Add prototypes for GetDevicePowerState and RequestWakeupLatency to pofuncs.h

svn path=/trunk/; revision=38770

reactos/dll/win32/kernel32/misc/power.c
reactos/include/ndk/pofuncs.h

index 2d8bc3a..bb708ec 100644 (file)
@@ -91,14 +91,30 @@ SetSystemPowerState(BOOL fSuspend, BOOL fForce)
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 WINAPI
 GetDevicePowerState(HANDLE hDevice, BOOL *pfOn)
 {
-    STUB;
-    return 0;
+    DEVICE_POWER_STATE DevicePowerState;
+    NTSTATUS Status;
+
+    Status = NtGetDevicePowerState(hDevice, &DevicePowerState);
+
+    if (NT_SUCCESS(Status))
+    {
+        if ((DevicePowerState != PowerDeviceUnspecified) &&
+            (DevicePowerState != PowerDeviceD0))
+            *pfOn = FALSE;
+        else
+            *pfOn = TRUE;
+
+        return TRUE;
+    }
+
+    SetLastErrorByStatus(Status);
+    return FALSE;
 }
 
 /*
@@ -113,14 +129,23 @@ RequestDeviceWakeup(HANDLE hDevice)
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 WINAPI
 RequestWakeupLatency(LATENCY_TIME latency)
 {
-    STUB;
-    return 0;
+    NTSTATUS Status;
+
+    Status = NtRequestWakeupLatency(latency);
+
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 /*
index 44bf815..24dff1c 100644 (file)
@@ -86,4 +86,20 @@ ZwSetSystemPowerState(
     IN SYSTEM_POWER_STATE MinSystemState,
     IN ULONG Flags
 );
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+NtGetDevicePowerState(
+    IN HANDLE Device,
+    IN PDEVICE_POWER_STATE PowerState
+);
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+NtRequestWakeupLatency(
+    IN LATENCY_TIME latency
+);
+
 #endif