本文整理汇总了C++中QNetworkReply::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::readLine方法的具体用法?C++ QNetworkReply::readLine怎么用?C++ QNetworkReply::readLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::readLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readLine
QByteArray QNetworkReplyProto::readLine(qint64 maxSize)
{
QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
if (item)
return item->readLine(maxSize);
return QByteArray();
}
示例2: gotReplyFromUserRequest
void UpdateChecker::gotReplyFromUserRequest() {
qDebug("UpdateChecker::gotReplyFromUserRequest");
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (reply) {
if (reply->error() == QNetworkReply::NoError) {
QRegExp rx_version("^latest_version=(.*)");
QString version;
while (reply->canReadLine()) {
QByteArray line = reply->readLine().trimmed();
if (rx_version.indexIn(line) != -1) {
version = rx_version.cap(1);
break;
}
}
if (!version.isEmpty()) {
if ((formattedVersion(version) > formattedVersion(Version::with_revision()))) {
qDebug("UpdateChecker::gotReplyFromUserRequest: new version found: %s", version.toUtf8().constData());
emit newVersionFound(version);
} else {
emit noNewVersionFound(version);
}
} else {
emit errorOcurred(1, tr("Failed to get the latest version number") );
}
} else {
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug("UpdateChecker::gotReplyFromUserRequest: status: %d", status);
emit errorOcurred((int)reply->error(), reply->errorString());
}
reply->deleteLater();
}
}
示例3: 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;
}
示例4: gotReply
void UpdateChecker::gotReply() {
qDebug("UpdateChecker::gotReply");
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (reply) {
if (reply->error() == QNetworkReply::NoError) {
//read data from reply
QRegExp rx_version("^version=(.*)");
QString version;
while (reply->canReadLine()) {
QByteArray line = reply->readLine().trimmed();
//qDebug("line: %s", line.constData());
if (rx_version.indexIn(line) != -1) {
version = rx_version.cap(1);
//qDebug("version: %s", version.toUtf8().constData());
break;
}
}
if (!version.isEmpty()) {
d->last_checked = QDate::currentDate();
//qDebug("last known: %s version: %s", d->last_known_version.toUtf8().constData(), version.toUtf8().constData());
//qDebug("version_with_revision: %s", Version::with_revision().toUtf8().constData());
if ((d->last_known_version != version) && (formattedVersion(version) > formattedVersion(Version::with_revision()))) {
qDebug("UpdateChecker::gotReply: new version found: %s", version.toUtf8().constData());
emit newVersionFound(version);
}
}
} else {
//get http status code
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug("UpdateChecker::gotReply: status: %d", status);
}
reply->deleteLater();
}
}