tools/qtestlib/wince/remotelib/commands.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
    37 **
    37 **
    38 ** $QT_END_LICENSE$
    38 ** $QT_END_LICENSE$
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 #include "commands.h"
    41 #include "commands.h"
       
    42 #include <Pm.h>
       
    43 #include <Pmpolicy.h>
       
    44 
    42 
    45 
    43 #define CLEAN_FAIL(a) {delete appName; \
    46 #define CLEAN_FAIL(a) {delete appName; \
    44     delete arguments; \
    47     delete arguments; \
    45     return (a); }
    48     return (a); }
    46 
    49 
   122                 *returnValue = exitCode;
   125                 *returnValue = exitCode;
   123         }
   126         }
   124     }
   127     }
   125     return true;
   128     return true;
   126 }
   129 }
       
   130 /**
       
   131 \brief Reset the device.
       
   132 */
       
   133 int qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
       
   134 {   
       
   135     //POWER_STATE_ON        On state 
       
   136     //POWER_STATE_OFF       Off state 
       
   137     //POWER_STATE_CRITICAL  Critical state 
       
   138     //POWER_STATE_BOOT      Boot state 
       
   139     //POWER_STATE_IDLE      Idle state 
       
   140     //POWER_STATE_SUSPEND   Suspend state 
       
   141     //POWER_STATE_RESET     Reset state
       
   142 
       
   143     DWORD returnValue  = SetSystemPowerState(0, POWER_STATE_RESET, POWER_FORCE);
       
   144     return returnValue;
       
   145 }
       
   146 
       
   147 /**
       
   148 \brief Toggle the unattended powermode of the device
       
   149 */
       
   150 int qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
       
   151 {
       
   152     if (!stream)
       
   153         return -1;
       
   154 
       
   155     DWORD bytesRead;
       
   156     int toggleVal   = 0;
       
   157     int returnValue = S_OK;
       
   158 
       
   159     if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead))
       
   160         return -2;
       
   161 
       
   162     //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). 
       
   163     //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). 
       
   164     //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. 
       
   165     //PPN_SUSPENDKEYPRESSED or
       
   166     //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). 
       
   167     //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). 
       
   168     //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). 
       
   169     //PPN_OEMBASE Greater than or equal to 0x10000 
       
   170     //You can define higher values, such as 0x10001, 0x10002, and so on.
       
   171     // Reserved. Set dwData to zero (0). 
       
   172     returnValue = PowerPolicyNotify(PPN_UNATTENDEDMODE, toggleVal);
       
   173 
       
   174     if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead))
       
   175         return -3;
       
   176     else
       
   177         return S_OK;
       
   178 }
       
   179 
       
   180 /**
       
   181 \brief Virtually press the power button of the device
       
   182 */
       
   183 int qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
       
   184 {
       
   185     if (!stream)
       
   186         return -1;
       
   187 
       
   188     DWORD bytesRead;
       
   189     int toggleVal   = 0;
       
   190     int returnValue = S_OK;
       
   191 
       
   192     if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead))
       
   193         return -2;
       
   194 
       
   195     //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). 
       
   196     //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). 
       
   197     //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. 
       
   198     //PPN_SUSPENDKEYPRESSED or
       
   199     //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). 
       
   200     //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). 
       
   201     //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). 
       
   202     //PPN_OEMBASE Greater than or equal to 0x10000 
       
   203     //You can define higher values, such as 0x10001, 0x10002, and so on.
       
   204     // Reserved. Set dwData to zero (0). 
       
   205     returnValue = PowerPolicyNotify(PPN_POWERBUTTONPRESSED, 0);
       
   206 
       
   207     if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead))
       
   208         return -3;
       
   209     else
       
   210         return S_OK;
       
   211 }
       
   212