コード例 #1
0
ファイル: SkypeWinClient.cpp プロジェクト: Damra/qgvdial
bool
SkypeWinClient::ensureConnected ()
{
    MainApp *theApp = (MainApp *)qApp;
    bool rv = false;
    QString strResponse;
    do // Begin cleanup block (not a loop)
    {
        if (NULL == theApp->getSkypeHandle ())
        {
            MainApp *theApp = (MainApp *)qApp;
            UINT ret =
            SendMessageTimeout (HWND_BROADCAST,
                                theApp->getDiscover (),
                                (WPARAM)mainwin.winId (),
                                0,
                                SMTO_ABORTIFHUNG,
                                2 * 1000,   // 2 sec per top level window
                                NULL);
            if (1 != ret)
            {
                qWarning ("SkypeWinClient: Failed to send connect message");
                break;
            }

            rv = true;
            break;
        }

        rv = SkypeClient::ensureConnected ();
    } while (0); // End cleanup block (not a loop)

    if (!rv)
    {
        completeCurrentWork (SW_Connect, false);
    }

    return (rv);
}//SkypeWinClient::ensureConnected
コード例 #2
0
ファイル: SkypeWinClient.cpp プロジェクト: Damra/qgvdial
bool
SkypeWinClient::invoke (const QString &strCommand)
{
    MainApp *theApp = (MainApp *)qApp;
    LRESULT lRet = FALSE;
    do // Begin cleanup block (not a loop)
    {
        qDebug () << "SkypeWinClient: Sending command" << strCommand;

        QMutexLocker locker (&mutex);
        bInvokeInProgress = true;
        COPYDATASTRUCT cds;
        memset (&cds, 0, sizeof (cds));
        QByteArray ba = strCommand.toUtf8();
        cds.cbData = ba.size () + 1;
        cds.lpData = ba.data ();
        lRet = SendMessage (theApp->getSkypeHandle (),
                            WM_COPYDATA,
                            (WPARAM) mainwin.winId (),
                            (LPARAM) &cds);
        if (FALSE == lRet)
        {
            DWORD dw = GetLastError ();
            bInvokeInProgress = false;

            if (ERROR_INVALID_WINDOW_HANDLE == dw)
            {
                theApp->clearSkypeHandle ();
            }

            QString m = QString("Failed to Invoke. GetLastError = %1").arg(dw);
            emit internalCompleted (-1, m);
            break;
        }
    } while (0); // End cleanup block (not a loop)

    return (TRUE == lRet);
}//SkypeWinClient::invoke