Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/qtestlib/wince/cetest/activesyncconnection.cpp

    r651 r769  
    444444}
    445445
     446bool ActiveSyncConnection::setDeviceAwake(bool activate, int *returnValue)
     447{
     448    if (!isConnected()) {
     449        qWarning("Cannot execute, connect to device first!");
     450        return false;
     451    }
     452    bool result = false;
     453
     454    // If we want to wait, we have to use CeRapiInvoke, as CeCreateProcess has no way to wait
     455    // until the process ends. The lib must have been build and also deployed already.
     456    if (!isConnected() && !connect())
     457        return false;
     458
     459    HRESULT res = S_OK;
     460
     461    //SYSTEM_POWER_STATUS_EX systemPowerState;
     462
     463    //res = CeGetSystemPowerStatusEx(&systemPowerState, true);
     464
     465    QString dllLocation = "\\Windows\\QtRemote.dll";
     466    QString functionName = "qRemoteToggleUnattendedPowerMode";
     467
     468    DWORD outputSize;
     469    BYTE* output;
     470    IRAPIStream *stream;
     471    int returned = 0;
     472    int toggle = int(activate);
     473
     474    res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0);
     475    if (S_OK != res) {
     476        DWORD ce_error = CeGetLastError();
     477        if (S_OK != ce_error) {
     478            qWarning("Error invoking %s on %s: %s", qPrintable(functionName),
     479                qPrintable(dllLocation), strwinerror(ce_error).constData());
     480        } else {
     481            qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName),
     482                qPrintable(dllLocation), res);
     483        }
     484    } else {
     485        DWORD written;
     486
     487        if (S_OK != stream->Write(&toggle, sizeof(toggle), &written)) {
     488            qWarning("   Could not write toggle option to process");
     489            return false;
     490        }
     491
     492        if (S_OK != stream->Read(&returned, sizeof(returned), &written)) {
     493            qWarning("   Could not access return value of process");
     494        }
     495        else
     496            result = true;
     497    }
     498
     499    if (returnValue)
     500        *returnValue = returned;
     501
     502    return result;
     503}
     504
     505bool ActiveSyncConnection::resetDevice()
     506{
     507    if (!isConnected()) {
     508        qWarning("Cannot execute, connect to device first!");
     509        return false;
     510    }
     511
     512    bool result = false;
     513    if (!isConnected() && !connect())
     514        return false;
     515
     516    QString dllLocation = "\\Windows\\QtRemote.dll";
     517    QString functionName = "qRemoteSoftReset";
     518
     519    DWORD outputSize;
     520    BYTE* output;
     521    IRAPIStream *stream;
     522
     523    int returned = 0;
     524
     525    HRESULT res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0);
     526    if (S_OK != res) {
     527        DWORD ce_error = CeGetLastError();
     528        if (S_OK != ce_error) {
     529            qWarning("Error invoking %s on %s: %s", qPrintable(functionName),
     530                qPrintable(dllLocation), strwinerror(ce_error).constData());
     531        } else {
     532            qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName),
     533                qPrintable(dllLocation), res);
     534        }
     535    } else {
     536        result = true;
     537    }
     538    return result;
     539}
     540
     541bool ActiveSyncConnection::toggleDevicePower(int *returnValue)
     542{
     543    if (!isConnected()) {
     544        qWarning("Cannot execute, connect to device first!");
     545        return false;
     546    }
     547
     548    bool result = false;
     549    if (!isConnected() && !connect())
     550        return false;
     551
     552    QString dllLocation = "\\Windows\\QtRemote.dll";
     553    QString functionName = "qRemotePowerButton";
     554
     555    DWORD outputSize;
     556    BYTE* output;
     557    IRAPIStream *stream;
     558    int returned = 0;
     559
     560    HRESULT res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0);
     561    if (S_OK != res) {
     562        DWORD ce_error = CeGetLastError();
     563        if (S_OK != ce_error) {
     564            qWarning("Error invoking %s on %s: %s", qPrintable(functionName),
     565                qPrintable(dllLocation), strwinerror(ce_error).constData());
     566        } else {
     567            qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName),
     568                qPrintable(dllLocation), res);
     569        }
     570    } else {
     571        DWORD written;
     572        if (S_OK != stream->Read(&returned, sizeof(returned), &written)) {
     573            qWarning("   Could not access return value of process");
     574        }
     575        else {
     576            result = true;
     577        }
     578    }
     579
     580    if (returnValue)
     581        *returnValue = returned;
     582    return result;
     583}
     584
    446585bool ActiveSyncConnection::createDirectory(const QString &path, bool deleteBefore)
    447586{
Note: See TracChangeset for help on using the changeset viewer.