当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkReply::isFinished方法代码示例

本文整理汇总了C++中QNetworkReply::isFinished方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::isFinished方法的具体用法?C++ QNetworkReply::isFinished怎么用?C++ QNetworkReply::isFinished使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QNetworkReply的用法示例。


在下文中一共展示了QNetworkReply::isFinished方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkManifest

int Updater::checkManifest()
{
    QUrl baseUrl(MANIFEST_URL);
    QNetworkAccessManager manager;
    QNetworkRequest request = getNetworkRequest(baseUrl);
    QNetworkReply *rep = manager.get(request);

    while(rep->error() == QNetworkReply::NoError && !rep->isFinished())
        QCoreApplication::processEvents();

    while(true)
    {
        while(!rep->isFinished())
            QCoreApplication::processEvents();

        if(rep->error() != QNetworkReply::NoError)
            return RES_CHECK_FAILED;

        QVariant redirect = rep->attribute(QNetworkRequest::RedirectionTargetAttribute);
        if(redirect.type() != QVariant::Url)
            break;

        // redirect
        baseUrl = baseUrl.resolved(redirect.toUrl());
        request = getNetworkRequest(baseUrl);
        rep = manager.get(request);
    }

    if(rep->isFinished() && rep->size() != 0)
    {
        QString s;
        QString ver(VERSION);
        while(!rep->atEnd())
        {
            s = rep->readLine();

            QStringList parts = s.split(' ', QString::SkipEmptyParts);
            if(parts.size() < 3 || !ver.contains(parts[0]))
                continue;

            if(REVISION < parts[1].toInt())
                return RES_UPDATE_AVAILABLE;
            else
                return RES_NO_UPDATE;
        }
    }
    return RES_NO_UPDATE;
}
开发者ID:dimitarm1,项目名称:Lorris,代码行数:48,代码来源:updater.cpp

示例2: getUpdateFile

AutoUpdater::UpdateFile AutoUpdater::getUpdateFile(UpdateFileMeta fileMeta)
{
    UpdateFile file;
    file.metadata = fileMeta;

    QNetworkAccessManager *manager = new QNetworkAccessManager;
    QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(filesURI+fileMeta.id)));
    while (!reply->isFinished())
    {
        if (abortFlag)
            return file;
        qApp->processEvents();
    }

    if (reply->error() != QNetworkReply::NoError)
    {
        qWarning() << "AutoUpdater: getUpdateFile: network error: "<<reply->errorString();
        reply->deleteLater();
        manager->deleteLater();
        return file;
    }

    file.data = reply->readAll();
    reply->deleteLater();
    manager->deleteLater();

    return file;
}
开发者ID:rokups,项目名称:qTox,代码行数:28,代码来源:autoupdate.cpp

示例3: qDebug

void KDSoapPendingCall::Private::parseReply()
{
    if (parsed) {
        return;
    }

    QNetworkReply *reply = this->reply.data();

	if (!reply->isFinished()) {
		qDebug() << "KDSoapPendingCall::parseReply: Reply is not finished. Bytes available" << reply->bytesAvailable() << "Error" << reply->error();
	}
    parsed = true;
    if (reply->error()) {
        replyMessage.setFault(true);
        replyMessage.addArgument(QString::fromLatin1("faultcode"), QString::number(reply->error()));
        replyMessage.addArgument(QString::fromLatin1("faultstring"), reply->errorString());
        if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 500) {
            qDebug() << "Status code:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() << "Error:" << reply->errorString();
            return;
        }
    }

    const QByteArray data = reply->readAll();
    if (!data.isEmpty()) {
        KDSoapMessageReader reader;
        reader.xmlToMessage(data, &replyMessage, 0, &replyHeaders);
    }
}
开发者ID:lolopoloskos,项目名称:KDSoap,代码行数:28,代码来源:KDSoapPendingCall.cpp

示例4: getUpdateFlist

QByteArray AutoUpdater::getUpdateFlist()
{
    QByteArray flist;

    QNetworkAccessManager *manager = new QNetworkAccessManager;
    manager->setProxy(Settings::getInstance().getProxy());
    QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(flistURI)));
    while (!reply->isFinished())
    {
        if (abortFlag)
            return flist;
        qApp->processEvents();
    }

    if (reply->error() != QNetworkReply::NoError)
    {
        qWarning() << "getUpdateFlist: network error: " + reply->errorString();
        reply->deleteLater();
        manager->deleteLater();
        return flist;
    }

    flist = reply->readAll();
    reply->deleteLater();
    manager->deleteLater();

    return flist;
}
开发者ID:13983441921,项目名称:qTox,代码行数:28,代码来源:autoupdate.cpp

示例5: positionUpdated

//! [3]
void AppModel::positionUpdated(QGeoPositionInfo gpsPos)
{
    d->coord = gpsPos.coordinate();

    if (!(d->useGps))
        return;

    QString latitude, longitude;
    longitude.setNum(d->coord.longitude());
    latitude.setNum(d->coord.latitude());
//! [3]
    QUrl url("http://maps.google.com/maps/geo");
    QUrlQuery query;
    query.addQueryItem("q", latitude + "," + longitude);
    query.addQueryItem("output", "xml");
    url.setQuery(query);

    QNetworkReply *rep = d->nam->get(QNetworkRequest(url));
    // connect up the signal right away
    d->geoReplyMapper->setMapping(rep, rep);
    connect(rep, SIGNAL(finished()),
            d->geoReplyMapper, SLOT(map()));
    // it might have finished though while we were connecting it
    // if so, pass it straight on
    if (rep->isFinished())
        this->handleGeoNetworkData(rep);
}
开发者ID:amccarthy,项目名称:qtlocation,代码行数:28,代码来源:appmodel.cpp

示例6: testMessageParts

void ImapMsgPartNetAccessManagerTest::testMessageParts()
{
    QFETCH(QByteArray, bodystructure);
    QFETCH(QByteArray, partId);
    QFETCH(QString, url);
    QFETCH(bool, validity);
    QFETCH(QByteArray, text);

    cServer("* 1 FETCH (UID 1 BODYSTRUCTURE (" + bodystructure + "))\r\n" +
            "* 2 FETCH (UID 2 BODYSTRUCTURE (" + bodystructure + "))\r\n"
            + t.last("OK fetched\r\n"));
    QVERIFY(model->rowCount(msg1) > 0);

    netAccessManager->setModelMessage(msg1);
    QNetworkRequest req;
    req.setUrl(QUrl(url));
    QNetworkReply *res = netAccessManager->get(req);
    if (validity) {
        QVERIFY(qobject_cast<Imap::Network::MsgPartNetworkReply*>(res));
        cClient(t.mk("UID FETCH 1 (BODY.PEEK[") + partId + "])\r\n");
        cServer("* 1 FETCH (UID 1 BODY[" + partId + "] {" + QByteArray::number(text.size()) + "}\r\n" +
                                                                               text + ")\r\n" + t.last("OK fetched\r\n"));
        cEmpty();
        QCOMPARE(text, res->readAll());
    } else {
        QVERIFY(qobject_cast<Imap::Network::ForbiddenReply*>(res));
    }
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
    QCOMPARE(res->isFinished(), true);
#endif
    cEmpty();
    QVERIFY(errorSpy->isEmpty());
}
开发者ID:adamkudrna,项目名称:trojita,代码行数:33,代码来源:test_Imap_MsgPartNetAccessManager.cpp

示例7: loadResourceSynchronously

void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials /*storedCredentials*/, ResourceError& error, ResourceResponse& response, Vector<char>& data)
{
    WebCoreSynchronousLoader syncLoader;
    RefPtr<ResourceHandle> handle = adoptRef(new ResourceHandle(request, &syncLoader, true, false));

    ResourceHandleInternal* d = handle->getInternal();
    if (!d->m_user.isEmpty() || !d->m_pass.isEmpty()) {
        // If credentials were specified for this request, add them to the url,
        // so that they will be passed to QNetworkRequest.
        KURL urlWithCredentials(d->m_firstRequest.url());
        urlWithCredentials.setUser(d->m_user);
        urlWithCredentials.setPass(d->m_pass);
        d->m_firstRequest.setURL(urlWithCredentials);
    }
    d->m_context = context;
    d->m_job = new QNetworkReplyHandler(handle.get(), QNetworkReplyHandler::SynchronousLoad);

    QNetworkReply* reply = d->m_job->reply();
    // When using synchronous calls, we are finished when reaching this point.
    if (reply->isFinished()) {
        syncLoader.setReplyFinished(true);
        d->m_job->forwardData();
        d->m_job->finish();
    } else
        syncLoader.waitForCompletion();

    error = syncLoader.resourceError();
    data = syncLoader.data();
    response = syncLoader.resourceResponse();
}
开发者ID:dankurka,项目名称:webkit_titanium,代码行数:30,代码来源:ResourceHandleQt.cpp

示例8: logout

void auto_dirvers_fatie::logout()
{
	QString str_url_1 = "http://passport.mydrivers.com/logout.aspx?returnurl=http://www.mydrivers.com";

	QUrl url_1(str_url_1);
	url_1.setUrl(str_url_1);
	HttpParamList header_list1;
	header_list1.push_back(HttpParamItem("Accept", "text/html, application/xhtml+xml, */*"));
	header_list1.push_back(HttpParamItem("Connection", "Keep-Alive"));
	header_list1.push_back(HttpParamItem("Accept-Encoding", "gzip, deflate"));
	header_list1.push_back(HttpParamItem("Accept-Language", "zh-cn"));
	header_list1.push_back(HttpParamItem("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"));
	header_list1.push_back(HttpParamItem("DNT", "1"));
	//header_list1.push_back(HttpParamItem("Cache-Control", "max-age=0"));
	header_list1.push_back(HttpParamItem("Host", "passport.mydrivers.com")); // mhost
	header_list1.push_back(HttpParamItem("User-Agent", S_UA));

	QNetworkReply* rp = network.GetRequest(url_1, header_list1);

	QTime _t;
	_t.start();

	bool _timeout = false;

	while (rp && !rp->isFinished())
	{
		QCoreApplication::processEvents();
		if (_t.elapsed() >= 20000) {
			_timeout = true;
			break;
		}
	}

	rp->deleteLater();
}
开发者ID:blacksjt,项目名称:autobots,代码行数:35,代码来源:auto_dirvers_mobile.cpp

示例9: testFetchResultOfflineSingle

/** short A fetching operation gets interrupted by switching to the offline mode */
void ImapMsgPartNetAccessManagerTest::testFetchResultOfflineSingle()
{
    COMMON_METADATA_CHAT_PLAIN_AND_SIGNED

    netAccessManager->setModelMessage(msg1);
    QNetworkRequest req;
    req.setUrl(QUrl(QLatin1String("trojita-imap://msg/0")));
    QNetworkReply *res = netAccessManager->get(req);
    QVERIFY(qobject_cast<Imap::Network::MsgPartNetworkReply*>(res));
    cClient(t.mk("UID FETCH 1 (BODY.PEEK[1])\r\n"));

    QPersistentModelIndex msg1p1 = msgListA.child(0, 0).child(0, 0);
    QVERIFY(msg1p1.isValid());
    QCOMPARE(msg1p1.data(Imap::Mailbox::RoleMessageUid), QVariant(1u));
    QCOMPARE(msg1p1.data(Imap::Mailbox::RoleIsFetched), QVariant(false));
    QCOMPARE(msg1p1.data(Imap::Mailbox::RoleIsUnavailable), QVariant(false));

    networkPolicy->setNetworkOffline();
    cClient(t.mk("LOGOUT\r\n"));
    cServer(t.last("OK logged out\r\n") + "* BYE eh\r\n");
    QCOMPARE(msg1p1.data(Imap::Mailbox::RoleIsFetched), QVariant(false));
    QCOMPARE(msg1p1.data(Imap::Mailbox::RoleIsUnavailable), QVariant(true));

#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
    QCOMPARE(res->isFinished(), true);
#endif
    QCOMPARE(res->error(), QNetworkReply::TimeoutError);
}
开发者ID:adamkudrna,项目名称:trojita,代码行数:29,代码来源:test_Imap_MsgPartNetAccessManager.cpp

示例10: download

void IconData::download()
{
    if(m_isRemoteFile)
    {
        if(!s_localImageCache.contains(m_localUrl))
        {
            snoreDebug( SNORE_DEBUG ) << "Downloading:" << m_url;
            QNetworkAccessManager manager;
            QEventLoop loop;
            QNetworkRequest request(m_url);
            request.setRawHeader("User-Agent", "SnoreNotify");
            QNetworkReply *reply = manager.get(request);
            QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
            QTimer::singleShot(1000,&loop, SLOT(quit()));//timeout
            loop.exec();
            if(reply->isFinished())
            {
                m_img = QImage::fromData(reply->readAll(), "PNG");
                m_img.save(m_localUrl,"PNG");
                s_localImageCache.insert(m_localUrl);
                snoreDebug( SNORE_DEBUG ) << m_localUrl << "added to cache";
            }
        }
        else
        {
            m_img = QImage(m_localUrl);
        }
    }
}
开发者ID:muesli,项目名称:Snorenotify,代码行数:29,代码来源:icon_p.cpp

示例11: qgetenv

void KDSoapPendingCall::Private::parseReply()
{
    if (parsed)
        return;
    parsed = true;
    const bool doDebug = qgetenv("KDSOAP_DEBUG").toInt();
    QNetworkReply* reply = this->reply.data();
#if QT_VERSION >= 0x040600
    if (!reply->isFinished()) {
        qWarning("KDSoap: Parsing reply before it finished!");
    }
#endif
    if (reply->error()) {
        replyMessage.setFault(true);
        replyMessage.addArgument(QString::fromLatin1("faultcode"), QString::number(reply->error()));
        replyMessage.addArgument(QString::fromLatin1("faultstring"), reply->errorString());
        if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 500) {
            if (doDebug) {
                //qDebug() << reply->readAll();
                qDebug() << reply->errorString();
            }
            return;
        }
        // HTTP 500 is used to return faults, so parse the fault, below
    }
    const QByteArray data = reply->readAll();
    if (doDebug)
        qDebug() << data;

    if (!data.isEmpty()) {
        KDSoapMessageReader reader;
        reader.xmlToMessage(data, &replyMessage, 0, &replyHeaders);
    }
}
开发者ID:hporten,项目名称:KDSoap,代码行数:34,代码来源:KDSoapPendingCall.cpp

示例12: initTestCase

void RigTests::initTestCase() {
//#define FROM_FILE "/Users/howardstearns/howardHiFi/Zack.fbx"
#ifdef FROM_FILE
    QFile file(FROM_FILE);
    QCOMPARE(file.open(QIODevice::ReadOnly), true);
    FBXGeometry geometry = readFBX(file.readAll(), QVariantHash());
#else
    QUrl fbxUrl("https://s3.amazonaws.com/hifi-public/models/skeletons/Zack/Zack.fbx");
    QNetworkReply* reply = OBJReader().request(fbxUrl, false);  // Just a convenience hack for synchronoud http request
    auto fbxHttpCode = !reply->isFinished() ? -1 : reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    QCOMPARE(fbxHttpCode, 200);
    FBXGeometry geometry = readFBX(reply->readAll(), QVariantHash());
#endif
 
    QVector<JointState> jointStates;
    for (int i = 0; i < geometry.joints.size(); ++i) {
        JointState state(geometry.joints[i]);
        jointStates.append(state);
    }

    _rig = std::make_shared<AvatarRig>();
    _rig->initJointStates(jointStates, glm::mat4(), 0, 41, 40, 39, 17, 16, 15); // FIXME? get by name? do we really want to exclude the shoulder blades?
    std::cout << "Rig is ready " << geometry.joints.count() << " joints " << std::endl;
    reportAll(_rig);
   }
开发者ID:bwent,项目名称:hifi,代码行数:25,代码来源:RigTests.cpp

示例13: getUpdateFile

AutoUpdater::UpdateFile AutoUpdater::getUpdateFile(UpdateFileMeta fileMeta,
                                        std::function<void(int,int)> progressCallback)
{
    UpdateFile file;
    file.metadata = fileMeta;

    QNetworkAccessManager *manager = new QNetworkAccessManager;
    manager->setProxy(Settings::getInstance().getProxy());
    QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(filesURI+fileMeta.id)));
    QObject::connect(reply, &QNetworkReply::downloadProgress, progressCallback);
    while (!reply->isFinished())
    {
        if (abortFlag)
            return file;
        qApp->processEvents();
    }

    if (reply->error() != QNetworkReply::NoError)
    {
        qWarning() << "getUpdateFile: network error: " + reply->errorString();
        reply->deleteLater();
        manager->deleteLater();
        return file;
    }

    file.data = reply->readAll();
    reply->deleteLater();
    manager->deleteLater();

    return file;
}
开发者ID:13983441921,项目名称:qTox,代码行数:31,代码来源:autoupdate.cpp

示例14: toBytes

PyObject *PythonQtDecorator::retrieve(QNetworkAccessManager *self, QString url)
{
    //qDebug("QNAM %p retrieve %s", self, qPrintable(url));
    QNetworkRequest request;
    request.setUrl(QUrl(url));
    request.setRawHeader("Connection", "keep-alive");

    QNetworkReply *reply = syncGet(self, request);

    if (reply->error() != QNetworkReply::NoError)
    {
        qWarning("Network Error: %s", qPrintable(reply->errorString()));

        QByteArray reason = reply->errorString().toUtf8();
        char *creason = (char*)malloc(reason.size() + 1);
        strcpy(creason, reason.constData());
        PyErr_SetString(PyExc_IOError, creason);

        reply->deleteLater();
        return NULL;
    }
    // Reply
#if 0
    qDebug("Reply: %s %i", qPrintable(reply->url().toString()), reply->isFinished());
    foreach(QNetworkReply::RawHeaderPair header, reply->rawHeaderPairs())
        qDebug("HDR: %s: %s", qPrintable(header.first), qPrintable(header.second));
#endif
    QByteArray barr = reply->readAll();
    reply->deleteLater();
    return toBytes(&barr);
}
开发者ID:Forkk,项目名称:vlyc2,代码行数:31,代码来源:pythonqtdecorator.cpp

示例15: makeJsonRequest

QByteArray Toxme::makeJsonRequest(QString url, QString json, QNetworkReply::NetworkError &error)
{
    if (error)
        return QByteArray();

    QNetworkAccessManager netman;
    netman.setProxy(Settings::getInstance().getProxy());
    QNetworkRequest request{url};
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
    QNetworkReply* reply = netman.post(request,json.toUtf8());

    while (!reply->isFinished())
    {
        QThread::msleep(1);
        qApp->processEvents();
    }

    error = reply->error();
    if (error)
    {
        qWarning() << "makeJsonRequest: A network error occured:" << reply->errorString();
        return QByteArray();
    }

    return reply->readAll();
}
开发者ID:1KoT1,项目名称:qTox,代码行数:26,代码来源:toxme.cpp


注:本文中的QNetworkReply::isFinished方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。