tools/qtestlib/wince/remotelib/commands.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 4 3b1da2848fc7
--- a/tools/qtestlib/wince/remotelib/commands.cpp	Mon Mar 15 12:43:09 2010 +0200
+++ b/tools/qtestlib/wince/remotelib/commands.cpp	Thu Apr 08 14:19:33 2010 +0300
@@ -39,6 +39,9 @@
 **
 ****************************************************************************/
 #include "commands.h"
+#include <Pm.h>
+#include <Pmpolicy.h>
+
 
 #define CLEAN_FAIL(a) {delete appName; \
     delete arguments; \
@@ -124,3 +127,86 @@
     }
     return true;
 }
+/**
+\brief Reset the device.
+*/
+int qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
+{   
+    //POWER_STATE_ON        On state 
+    //POWER_STATE_OFF       Off state 
+    //POWER_STATE_CRITICAL  Critical state 
+    //POWER_STATE_BOOT      Boot state 
+    //POWER_STATE_IDLE      Idle state 
+    //POWER_STATE_SUSPEND   Suspend state 
+    //POWER_STATE_RESET     Reset state
+
+    DWORD returnValue  = SetSystemPowerState(0, POWER_STATE_RESET, POWER_FORCE);
+    return returnValue;
+}
+
+/**
+\brief Toggle the unattended powermode of the device
+*/
+int qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
+{
+    if (!stream)
+        return -1;
+
+    DWORD bytesRead;
+    int toggleVal   = 0;
+    int returnValue = S_OK;
+
+    if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead))
+        return -2;
+
+    //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). 
+    //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). 
+    //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. 
+    //PPN_SUSPENDKEYPRESSED or
+    //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). 
+    //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). 
+    //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). 
+    //PPN_OEMBASE Greater than or equal to 0x10000 
+    //You can define higher values, such as 0x10001, 0x10002, and so on.
+    // Reserved. Set dwData to zero (0). 
+    returnValue = PowerPolicyNotify(PPN_UNATTENDEDMODE, toggleVal);
+
+    if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead))
+        return -3;
+    else
+        return S_OK;
+}
+
+/**
+\brief Virtually press the power button of the device
+*/
+int qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
+{
+    if (!stream)
+        return -1;
+
+    DWORD bytesRead;
+    int toggleVal   = 0;
+    int returnValue = S_OK;
+
+    if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead))
+        return -2;
+
+    //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). 
+    //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). 
+    //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. 
+    //PPN_SUSPENDKEYPRESSED or
+    //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). 
+    //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). 
+    //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). 
+    //PPN_OEMBASE Greater than or equal to 0x10000 
+    //You can define higher values, such as 0x10001, 0x10002, and so on.
+    // Reserved. Set dwData to zero (0). 
+    returnValue = PowerPolicyNotify(PPN_POWERBUTTONPRESSED, 0);
+
+    if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead))
+        return -3;
+    else
+        return S_OK;
+}
+