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


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

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


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

示例1: 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

示例2: searchFinished

/**
 * @brief Called when the search result was downloaded
 *        Emits "searchDone" if there are no more pages in the result set
 * @see Cinefacts::parseSearch
 */
void Cinefacts::searchFinished()
{
    QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
    reply->deleteLater();

    if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 302 ||
        reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 301) {
        qDebug() << "Got redirect" << reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
        QString redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString();
        if (!redirect.startsWith("http"))
            redirect.prepend("http://www.cinefacts.de");
        QUrl url(redirect);
        QNetworkReply *reply = qnam()->get(QNetworkRequest(url));
        new NetworkReplyWatcher(this, reply);
        connect(reply, SIGNAL(finished()), this, SLOT(searchFinished()));
        return;
    }

    QList<ScraperSearchResult> results;
    if (reply->error() == QNetworkReply::NoError) {
        QString msg = QString::fromUtf8(reply->readAll());
        results = parseSearch(msg);
    } else {
        qWarning() << "Network Error" << reply->errorString();
    }
    emit searchDone(results);
}
开发者ID:BlitzGLEP1326,项目名称:MediaElch,代码行数:32,代码来源:Cinefacts.cpp

示例3: sendRequest

QJsonDocument sendRequest(const QString &url) {
    // create custom temporary event loop on stack
    QEventLoop eventLoop;
    // "quit()" the event-loop, when the network request "finished()"
    QNetworkAccessManager mgr;
    QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
    // the HTTP request
    QUrl qurl = QUrl( url );
    QNetworkRequest req( qurl );
    QNetworkReply *reply = mgr.get(req);
    eventLoop.exec(); // blocks stack until "finished()" has been called
    if (reply->error() == QNetworkReply::NoError) {
        QString strReply = (QString)reply->readAll();
        //qDebug() << "Response:" << strReply;
        QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
        delete reply;
        return jsonResponse;
    }
    else {
        //failure
        qDebug() << "sendRequest failure: " <<reply->errorString();
        delete reply;
    }
    return QJsonDocument();
}
开发者ID:CryptArc,项目名称:cryptoportfolio-qt,代码行数:25,代码来源:marketdata.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: backdropFinished

/**
 * @brief Called when backdrops are loaded
 */
void VideoBuster::backdropFinished()
{
    QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
    Movie *movie = reply->property("storage").value<Storage*>()->movie();
    QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
    reply->deleteLater();
    if (!movie)
        return;

    if (reply->error() == QNetworkReply::NoError ) {
        QString msg = reply->readAll();
        QRegExp rx("href=\"https://gfx.videobuster.de/archive/resized/([^\"]*)\"(.*)([^<]*)<img (.*) src=\"https://gfx.videobuster.de/archive/resized/c110/([^\"]*)\"");
        rx.setMinimal(true);
        int pos = 0;
        while ((pos = rx.indexIn(msg, pos)) != -1) {
            pos += rx.matchedLength();
            if (rx.cap(2).contains("titledtl_cover_pictures")) {
                continue;
            }
            Poster p;
            p.thumbUrl = QUrl(QString("https://gfx.videobuster.de/archive/resized/w700/%1").arg(rx.cap(5)));
            p.originalUrl = QUrl(QString("https://gfx.videobuster.de/archive/resized/%1").arg(rx.cap(1)));
            movie->addBackdrop(p);
        }
    } else {
        qWarning() << "Network Error" << reply->errorString();
    }
    movie->controller()->scraperLoadDone();
}
开发者ID:zabinko,项目名称:MediaElch,代码行数:32,代码来源:VideoBuster.cpp

示例6: onCreateDbReceived

void Config::onCreateDbReceived()
{
    qDebug("[Config::onCreateDbReceived]");

    // extract code
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
    int httpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();

    qDebug() << "[Config::onCreateDbReceived] Code is: " << httpCode;

    // 201 -> created
    if (httpCode == 201) {
        CliErrorReporter::printNotification("[INFO] Database '" + m_couchDbStruct.dbName + "' created");

        // notify that the configuration process has terminated
        Q_EMIT ready();
    } else {
        CliErrorReporter::printError(CliErrorReporter::DATABASE
                                    , CliErrorReporter::ERROR
                                    , reply->errorString() + "\n" + reply->readAll());

        reply->deleteLater();
        std::exit(1);
    }

    reply->deleteLater();
}
开发者ID:nwoki,项目名称:agatha-server,代码行数:27,代码来源:config.cpp

示例7: retrieveCredentials

void NXMAccessManager::retrieveCredentials()
{
  qDebug("retrieving credentials");
  QNetworkRequest request(ToQString(GameInfo::instance().getNexusPage())
                          + QString("/Core/Libs/Flamework/Entities/User?GetCredentials&game_id=%1"
                                    ).arg(GameInfo::instance().getNexusGameID()));
  request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
  request.setRawHeader("User-Agent", userAgent().toUtf8());

  QNetworkReply *reply = get(request);
  QTimer timeout;
  connect(&timeout, &QTimer::timeout, [reply] () {
    reply->deleteLater();
  });
  timeout.start();

  connect(reply, &QNetworkReply::finished, [reply, this] () {
    QJsonDocument jdoc = QJsonDocument::fromJson(reply->readAll());
    QJsonArray credentialsData = jdoc.array();
    emit credentialsReceived(credentialsData.at(2).toString(),
                             s_PremiumAccountStates.find(credentialsData.at(1).toInt())
                                                         != s_PremiumAccountStates.end());
    reply->deleteLater();
  });

  connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
          [=] (QNetworkReply::NetworkError) {
    qDebug("failed to retrieve account credentials: %s", qPrintable(reply->errorString()));
    reply->deleteLater();
  });
}
开发者ID:RevReese,项目名称:modorganizer,代码行数:31,代码来源:nxmaccessmanager.cpp

示例8: OnLoginPageFinished

void LoginDialog::OnLoginPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    if (reply->error()) {
        DisplayError("Network error: " + reply->errorString() + "\nTry using another login method.");
        return;
    }

    QByteArray bytes = reply->readAll();
    std::string page(bytes.constData(), bytes.size());
    std::string hash = Util::GetCsrfToken(page, "hash");
    if (hash.empty()) {
        DisplayError("Failed to log in (can't extract form hash from page)");
        return;
    }

    QUrlQuery query;
    query.addQueryItem("login_email", EncodeSpecialCharacters(ui->emailLineEdit->text()));
    query.addQueryItem("login_password", EncodeSpecialCharacters(ui->passwordLineEdit->text()));
    query.addQueryItem("hash", QString(hash.c_str()));
    query.addQueryItem("login", "Login");
    query.addQueryItem("remember_me", "1");

    QUrl url(POE_LOGIN_URL);
    QByteArray data(query.query().toUtf8());
    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    QNetworkReply *logged_in = login_manager_->post(request, data);
    connect(logged_in, SIGNAL(finished()), this, SLOT(OnLoggedIn()));
}
开发者ID:Methtra,项目名称:acquisition,代码行数:29,代码来源:logindialog.cpp

示例9: onLoadFinished

void IMDB::onLoadFinished()
{
    QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
    reply->deleteLater();
    Movie *movie = reply->property("storage").value<Storage*>()->movie();
    QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
    if (!movie)
        return;

    if (reply->error() == QNetworkReply::NoError ) {
        QString msg = QString::fromUtf8(reply->readAll());
        parseAndAssignInfos(msg, movie, infos);
        QString posterUrl = parsePosters(msg);
        if (infos.contains(MovieScraperInfos::Poster) && !posterUrl.isEmpty()) {
            QNetworkReply *reply = qnam()->get(QNetworkRequest(posterUrl));
            reply->setProperty("storage", Storage::toVariant(reply, movie));
            reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
            connect(reply, SIGNAL(finished()), this, SLOT(onPosterLoadFinished()));
        } else {
            movie->controller()->scraperLoadDone(this);
        }
    } else {
        qWarning() << "Network Error (load)" << reply->errorString();
    }
}
开发者ID:ArgelErx,项目名称:MediaElch,代码行数:25,代码来源:IMDB.cpp

示例10: networkReplyError

    void networkReplyError(QNetworkReply::NetworkError code)
    {
        Q_D(QJsonRpcHttpReply);
        QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
        if (!reply) {
            qJsonRpcDebug() << Q_FUNC_INFO << "invalid reply";
            return;
        }

        reply->deleteLater();
        if (code == QNetworkReply::NoError)
            return;

        QJsonRpcMessage response = QJsonRpcMessage::fromJson(reply->readAll());
        if (response.isValid()) {
            d->response = response;
            Q_EMIT messageReceived(response);
        } else {
            d->response = d->request.createErrorResponse(QJsonRpc::InternalError,
                                           QString("error with http request: %1").arg(reply->error()),
                                           reply->errorString());
        }

        Q_EMIT finished();
    }
开发者ID:yamamushi,项目名称:qjsonrpc,代码行数:25,代码来源:qjsonrpchttpclient.cpp

示例11: loginResult

void Session::Request::onLoginPage() {
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
    if (reply->error()) {
        emit loginResult(0x01, "A network error occured: " + reply->errorString());
    }
    else {
        QNetworkRequest request = reply->request();
        // Extract CSF
        const QString hash = getCSRFToken(reply->readAll());
        const QString username = getAttribute(&request, LoginUsername).toString();
        const QString password = getAttribute(&request, LoginPassword).toString();

        QUrlQuery query;
        query.addQueryItem("login_email", username);
        query.addQueryItem("login_password", password);
        query.addQueryItem("hash", hash);
        query.addQueryItem("login", "Login");
        QByteArray data(query.query().toUtf8());

        request = createRequest(LoginUrl());
        setAttribute(&request, LoginUsername, username);
        setAttribute(&request, LoginPassword, password);
        request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

        QNetworkReply *r = _manager->post(request, data);

        connect(r, &QNetworkReply::finished, this, &Session::Request::Request::onLoginPageResult);
    }
    reply->deleteLater();
}
开发者ID:Novynn,项目名称:Adamant,代码行数:30,代码来源:sessionrequest.cpp

示例12: onEpisodeLoadFinished

/**
 * @brief Called when the episode infos are downloaded
 * @see TheTvDb::parseAndAssignSingleEpisodeInfos
 */
void TheTvDb::onEpisodeLoadFinished()
{
    QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
    QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
    reply->deleteLater();
    TvShowEpisode *episode = reply->property("storage").value<Storage*>()->episode();
    if (!episode)
        return;

    if (reply->error() == QNetworkReply::NoError ) {
        QString msg = QString::fromUtf8(reply->readAll());
        QDomDocument domDoc;
        domDoc.setContent(msg);
        for (int i=0, n=domDoc.elementsByTagName("Episode").count() ; i<n ; ++i) {
            QDomElement elem = domDoc.elementsByTagName("Episode").at(i).toElement();
            if (!elem.elementsByTagName("SeasonNumber").isEmpty() && !elem.elementsByTagName("EpisodeNumber").isEmpty()) {
                int seasonNumber = elem.elementsByTagName("SeasonNumber").at(0).toElement().text().toInt();
                int episodeNumber = elem.elementsByTagName("EpisodeNumber").at(0).toElement().text().toInt();
                if (episode->season() == seasonNumber && episode->episode() == episodeNumber) {
                    episode->clear(episode->infosToLoad());
                    parseAndAssignSingleEpisodeInfos(elem, episode, infos);
                }
            }
        }
    } else {
        qWarning() << "Network Error" << reply->errorString();
    }
    episode->scraperLoadDone();
}
开发者ID:madsailor,项目名称:MediaElch,代码行数:33,代码来源:TheTvDb.cpp

示例13: 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

示例14: loadJson

//===========!!!!!!!!!!!!!!!!============================
void Var::loadJson(QString url, Var* params, QString method)
{
    QNetworkAccessManager* m_pQnaManager;
    m_pQnaManager = new QNetworkAccessManager();

    QString sep = "?";
    if(url.contains("?")) sep="&";
    url+=sep+params->toParamString();

    qDebug()<<url;

    QNetworkReply *r = m_pQnaManager->get(QNetworkRequest(QUrl(url)));
    QEventLoop eLoop;
    QObject::connect(m_pQnaManager, SIGNAL(finished(QNetworkReply*)), &eLoop, SLOT(quit()));
    eLoop.exec();
    if(r->error() != QNetworkReply::NoError)
    {
        qDebug() << " [!]ERROR: " << r->errorString();
    }
    else
    {
        importFromJsonString(r->readAll());
        print();
    }
    delete m_pQnaManager;
}
开发者ID:Aspenka,项目名称:SSD,代码行数:27,代码来源:var.cpp

示例15: onActorsFinished

/**
 * @brief Called when the tv show actors are downloaded
 * Starts download of banners
 * @see TheTvDb::parseAndAssignActors
 * @see TheTvDb::onBannersFinished
 */
void TheTvDb::onActorsFinished()
{
    QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
    reply->deleteLater();
    TvShow *show = reply->property("storage").value<Storage*>()->show();
    TvShowUpdateType updateType = static_cast<TvShowUpdateType>(reply->property("updateType").toInt());
    QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
    if (!show)
        return;

    if (reply->error() == QNetworkReply::NoError ) {
        QString msg = QString::fromUtf8(reply->readAll());
        if (show->infosToLoad().contains(TvShowScraperInfos::Actors) &&
                (updateType == UpdateShow || updateType == UpdateShowAndAllEpisodes || updateType == UpdateShowAndNewEpisodes))
            parseAndAssignActors(msg, show);
    } else {
        qWarning() << "Network Error" << reply->errorString();
    }
    QString mirror = m_xmlMirrors.at(qrand()%m_xmlMirrors.count());
    QUrl url(QString("%1/api/%2/series/%3/banners.xml").arg(mirror).arg(m_apiKey).arg(show->tvdbId()));
    reply = qnam()->get(QNetworkRequest(url));
    reply->setProperty("storage", Storage::toVariant(reply, show));
    reply->setProperty("updateType", updateType);
    reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
    connect(reply, SIGNAL(finished()), this, SLOT(onBannersFinished()));
}
开发者ID:madsailor,项目名称:MediaElch,代码行数:32,代码来源:TheTvDb.cpp


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