summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorninerider <qt-info@nokia.com>2010-02-19 09:48:27 (GMT)
committerninerider <qt-info@nokia.com>2010-02-19 09:53:29 (GMT)
commit254676322463778319e4a1b572d6c76f9c256393 (patch)
treee2a666d2cfc4b836a13c9b8858c163fc679e7eb1 /tools
parent52e517b50aafd6cc0bec597abd50d8b3f7e982dd (diff)
downloadQt-254676322463778319e4a1b572d6c76f9c256393.zip
Qt-254676322463778319e4a1b572d6c76f9c256393.tar.gz
Qt-254676322463778319e4a1b572d6c76f9c256393.tar.bz2
Remote lib extensions for Windows Mobile device power operations.
Function to change the power mode and to reset the device were added. The reset is needed to put the device in a defined state after an error has occurred. The unattended power mode ensures that the reset can be effected and that the device will not go to sleep. Reviewed by: Joerg
Diffstat (limited to 'tools')
-rw-r--r--tools/qtestlib/wince/remotelib/commands.cpp86
-rw-r--r--tools/qtestlib/wince/remotelib/commands.h3
2 files changed, 89 insertions, 0 deletions
diff --git a/tools/qtestlib/wince/remotelib/commands.cpp b/tools/qtestlib/wince/remotelib/commands.cpp
index 4244424..88bf9e6 100644
--- a/tools/qtestlib/wince/remotelib/commands.cpp
+++ b/tools/qtestlib/wince/remotelib/commands.cpp
@@ -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 @@ bool qRemoteExecute(const wchar_t* program, const wchar_t* arguments, int *retur
}
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;
+}
+
diff --git a/tools/qtestlib/wince/remotelib/commands.h b/tools/qtestlib/wince/remotelib/commands.h
index c5cc926..8f202c8 100644
--- a/tools/qtestlib/wince/remotelib/commands.h
+++ b/tools/qtestlib/wince/remotelib/commands.h
@@ -45,6 +45,9 @@
extern "C" {
int __declspec(dllexport) qRemoteLaunch(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream*);
+ int __declspec(dllexport) qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream);
+ int __declspec(dllexport) qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream);
+ int __declspec(dllexport) qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream);
bool __declspec(dllexport) qRemoteExecute(const wchar_t* program, const wchar_t* arguments = NULL, int *returnValue = NULL , DWORD* error = NULL, int timeout = -1);
}