Ejemplo n.º 1
0
static int __stdcall winGetExistDirCallbackProc(HWND hwnd,
        UINT uMsg,
        LPARAM lParam,
        LPARAM lpData)
{
#ifndef Q_OS_WINCE
    if (uMsg == BFFM_INITIALIZED && lpData != 0) {
        QString *initDir = (QString *)(lpData);
        if (!initDir->isEmpty()) {
            SendMessage(hwnd, BFFM_SETSELECTION, TRUE, Q_ULONG(initDir->utf16()));
        }
    } else if (uMsg == BFFM_SELCHANGED) {
        wchar_t path[MAX_PATH];
        SHGetPathFromIDList(LPITEMIDLIST(lParam), path);
        QString tmpStr = QString::fromWCharArray(path);
        if (!tmpStr.isEmpty())
            SendMessage(hwnd, BFFM_ENABLEOK, 1, 1);
        else
            SendMessage(hwnd, BFFM_ENABLEOK, 0, 0);
        SendMessage(hwnd, BFFM_SETSTATUSTEXT, 1, Q_ULONG(path));
    }
#endif
    return 0;
}
Ejemplo n.º 2
0
void tst_Q3SocketDevice::readNull()
{
    Q3SocketDevice device;
    device.setBlocking(true);

    int attempts = 10;
    while (attempts--) {
        if (device.connect(QtNetworkSettings::serverIP(), 143))
            break;
    }

    // some static state checking
    QVERIFY(device.isValid());
    QCOMPARE(device.type(), Q3SocketDevice::Stream);
    QCOMPARE(device.protocol(), Q3SocketDevice::IPv4);
    QVERIFY(device.socket() != -1);
    QVERIFY(device.blocking());
#if defined Q_OS_IRIX
    // IRIX defaults to the opposite in Qt 3, so we won't fix
    // this in Qt 4.
    QVERIFY(device.addressReusable());
#else
    QVERIFY(!device.addressReusable());
#endif
    QCOMPARE(device.peerPort(), quint16(143));
    QCOMPARE(device.peerAddress().toString(),
            QtNetworkSettings::serverIP().toString());
    QCOMPARE(device.error(), Q3SocketDevice::NoError);

    // write a logout notice
    QCOMPARE(device.writeBlock("X LOGOUT\r\n", Q_ULONG(10)), Q_LONG(10));

    // expect three lines of response: greeting, bye-warning and
    // logout command completion.
    int ch;
    for (int i = 0; i < 3; ++i) {
        do {
            QVERIFY((ch = device.getch()) != -1);
        } while (char(ch) != '\n');
    }

    // here, read() will return 0.
    char c;
    QCOMPARE(device.readBlock(&c, 1), qint64(0));
    QVERIFY(!device.isValid());
}
Ejemplo n.º 3
0
QString Q3FileDialog::winGetExistingDirectory(const QString& initialDirectory,
        QWidget *parent,
        const char* /*name*/,
        const QString& caption)
{
#ifndef Q_OS_WINCE
    QString currentDir = QDir::currentDirPath();
    QString result;
    if (parent)
        parent = parent->window();
    else
        parent = qApp->activeWindow();
    QString title = caption;
    if (title.isNull())
        title = tr("Select a Directory");

    if (parent) {
        QEvent e(QEvent::WindowBlocked);
        QApplication::sendEvent(parent, &e);
        QApplicationPrivate::enterModal(parent);
    }

    QString initDir = QDir::toNativeSeparators(initialDirectory);
    wchar_t path[MAX_PATH];
    wchar_t initPath[MAX_PATH];
    initPath[0] = 0;
    path[0] = 0;
    tTitle = title;
    BROWSEINFO bi;
    bi.hwndOwner = (parent ? parent->winId() : 0);
    bi.pidlRoot = NULL;
    bi.lpszTitle = (wchar_t*)tTitle.utf16();
    bi.pszDisplayName = initPath;
    bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
    bi.lpfn = winGetExistDirCallbackProc;
    bi.lParam = Q_ULONG(&initDir);
    LPITEMIDLIST pItemIDList = SHBrowseForFolder(&bi);
    if (pItemIDList) {
        SHGetPathFromIDList(pItemIDList, path);
        IMalloc *pMalloc;
        if (SHGetMalloc(&pMalloc) != NOERROR)
            result.clear();
        else {
            pMalloc->Free(pItemIDList);
            pMalloc->Release();
            result = QString::fromWCharArray(path);
        }
    } else
        result.clear();
    tTitle.clear();

    if (parent) {
        QApplicationPrivate::leaveModal(parent);
        QEvent e(QEvent::WindowUnblocked);
        QApplication::sendEvent(parent, &e);
    }

    if (!result.isEmpty())
        result.replace(QLatin1Char('\\'), QLatin1Char('/'));
    return result;
#else
    return QString();
#endif
}