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


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

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


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

示例1: checkReplyFeedback

void ProfileController::checkReplyFeedback() {
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

    QString response;
    if (reply) {
        if (reply->error() == QNetworkReply::NoError) {
            const int available = reply->bytesAvailable();
            if (available > 0) {
                const QByteArray buffer(reply->readAll());
                response = QString::fromUtf8(buffer);

                QString directory = QDir::homePath() + QLatin1String("/HFRBlackData");
                QFile file(directory + "/cache.txt");
                if (file.open(QIODevice::WriteOnly)) {
                    file.write(buffer);
                    file.close();
                }

                parseFeedback(response);
            }
        } else {
            connectionTimedOut();
        }

        reply->deleteLater();
    }
}
开发者ID:amonchakai,项目名称:HFR10,代码行数:27,代码来源:ProfileController.cpp

示例2: checkReply

void GoogleConnectController::checkReply() {
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

    QString response;
    if (reply) {
        if (reply->error() == QNetworkReply::NoError) {
            const int available = reply->bytesAvailable();
            if (available > 0) {
                const QByteArray buffer(reply->readAll());
                response = QString::fromUtf8(buffer);

                parse(response);
            }
        } else {
            qDebug() << "reply... " << reply->errorString();
            if(reply->errorString() == "Host  not found") {
                emit failedConnection();
            } else
                emit failedRenew();


        }

        reply->deleteLater();
    }

}
开发者ID:amonchakai,项目名称:Hg10Service,代码行数:27,代码来源:GoogleConnectController.cpp

示例3: checkReply

void LoginController::checkReply() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

	QString response;
	if (reply) {
		if (reply->error() == QNetworkReply::NoError) {
			const int available = reply->bytesAvailable();
			if (available > 0) {
				const QByteArray buffer(reply->readAll());
				response = QString::fromUtf8(buffer);

				// save cookies on disk
				CookieJar::get()->saveToDisk();
				saveUserName();
				emit complete();
			}
		} else {
			connectionTimedOut();
		}

	    reply->deleteLater();
	}

	if (response.trimmed().isEmpty()) {
		errorMessage();
    }
}
开发者ID:Jendorski,项目名称:HFRBlack,代码行数:27,代码来源:LoginController.cpp

示例4: responseCreateGameMode

/**
 * Response: create GameMode
 */
void RatingsProcessor::responseCreateGameMode() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

	QString response;
	if (reply) {
		if (reply->error() == QNetworkReply::NoError) {
			const int available = reply->bytesAvailable();
			if (available > 0) {
				const QByteArray buffer(reply->readAll());
				response = QString::fromUtf8(buffer);

				requestGameModes();
			}
		} else {
			if (reply->error() < 100) {
				showError("Please check your internet connection");
				return;
			}
			response =
					tr("ResponseCreateGameMode. Error: %1 status: %2").arg(reply->errorString(),
							reply->attribute(
									QNetworkRequest::HttpStatusCodeAttribute).toString());
			if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString()
					== "422") {
			}
		}
		reply->deleteLater();
	}
}
开发者ID:QuickBlox,项目名称:quickblox-blackberry10-sdk,代码行数:32,代码来源:RatingsProcessor.cpp

示例5: checkReply

void SmileyPickerController::checkReply() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

	QString response;
	if (reply) {
		if (reply->error() == QNetworkReply::NoError) {
			const int available = reply->bytesAvailable();
			if (available > 0) {
				const QByteArray buffer(reply->readAll());
				response = QString::fromUtf8(buffer);
				m_Page = response;
				m_IndexSubpagesInFile.clear();
				m_IndexSubpagesInFile.append(0);
				m_lastId = 0;
				m_Mutex.lockForWrite();
				m_Pushing = true;
				m_Mutex.unlock();
				parse(response);
			}
		} else {
			response = tr("Error: %1 status: %2").arg(reply->errorString(), reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString());
			qDebug() << response;
		}

		reply->deleteLater();
	}
}
开发者ID:amonchakai,项目名称:HFR10,代码行数:27,代码来源:SmileyPickerController.cpp

示例6: onTimelineReply

//! [1]
void TwitterRequest::onTimelineReply()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

    QString response;
    bool success = false;
    if (reply) {
        if (reply->error() == QNetworkReply::NoError) {
            const int available = reply->bytesAvailable();
            if (available > 0) {
                const QByteArray buffer = reply->readAll();
                response = QString::fromUtf8(buffer);
                success = true;
            }
        } else {
            response =  tr("Error: %1 status: %2").arg(reply->errorString(), reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString());
        }

        reply->deleteLater();
    }

    if (response.trimmed().isEmpty()) {
        response = tr("Twitter request failed. Check internet connection");
    }

    emit complete(response, success);
}
开发者ID:Angtrim,项目名称:Cascades-Samples,代码行数:28,代码来源:TwitterRequest.cpp

示例7: checkReply

void WebResourceManager::checkReply() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

	if (reply) {
		if (reply->error() == QNetworkReply::NoError) {
			const int available = reply->bytesAvailable();
			if (available > 0) {
				QImage qImage;
				qImage.loadFromData(reply->readAll());

				if (qImage.isNull()) {
					return;
				}

				QString diskPath = QDir::homePath() + "/Cache/"
								+ QString::number(qHash(reply->url().host())) + "_"
								+ QString::number(qHash(reply->url().path())) + ".PNG";

				if (qImage.save(diskPath)) {
						emit onImageReady(reply->url().toString(), diskPath);
				}

				// remove item from download queue
				m_EditQueue->lockForWrite();
				for(int i = 0 ; i < m_DownloadQueue->length() ; ++i)
					if(m_DownloadQueue->at(i).compare(reply->url().toString()) == 0) {
						m_DownloadQueue->removeAt(i);
						m_EditQueue->unlock();
						break;
					}
				m_EditQueue->unlock();
			}
		}
	}
}
开发者ID:Jendorski,项目名称:HFRBlack,代码行数:35,代码来源:WebResourceManager.cpp

示例8: onCurrentUserReply

/*
 * ForumRequest::onLoginReply()
 *
 * Callback handler for QNetworkReply finished() signal fired when requesting the currently logged in user.
 */
void Authenticator::onCurrentUserReply()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

    QString response;
    if (reply) {
        if (reply->error() == QNetworkReply::NoError) {
            const int available = reply->bytesAvailable();
            if (available > 0) {
                const QByteArray buffer = reply->readAll();
                response = QString::fromUtf8(buffer);
            }
        }

        reply->deleteLater();
    }

    if (response.contains("status=\"success\"", Qt::CaseInsensitive))
    {
    	int valStart = response.indexOf("<id type=\"int\">") + 15;
    	int valEnd = response.indexOf("</id>");
    	mUserId = "id/" + response.mid(valStart, (valEnd - valStart));
    }
    else
    {
    	mUserId = "";
    }
}
开发者ID:26filip,项目名称:Cascades-Community-Samples,代码行数:33,代码来源:Authenticator.cpp

示例9: responseScoreAverage

/**
 * Response: score average
 */
void RatingsProcessor::responseScoreAverage() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

	QString response;
	if (reply) {
		if (reply->error() == QNetworkReply::NoError) {
			const int available = reply->bytesAvailable();
			if (available > 0) {
				const QByteArray buffer(reply->readAll());
				response = QString::fromUtf8(buffer);

				bb::data::JsonDataAccess jda;
				QVariant vlist = jda.loadFromBuffer(response);

				QVariantMap list = vlist.toMap();

				float temp = list["value"].toFloat();

				m_ratValue = temp;

			}
		} else {
			m_ratValue = 0;
			if (reply->error() < 100) {
				showError("Please check your internet connection");
				return;
			}
			response =
					tr("Error: %1 status: %2").arg(reply->errorString(),
							reply->attribute(
									QNetworkRequest::HttpStatusCodeAttribute).toString());
			//another error
			showError("ResponseScoreAverage. QBlox Server Error = " + response);
			return;
		}
		reply->deleteLater();
	}

	emit ratValueChanged();

	emit imageChanged();

	m_label.clear();
	emit labelChanged();

	emit idRatChanged();

	m_loading = false;
	emit loadingChanged();

	m_urlImage = m_imageUrl;
	emit urlImageChanged();

	m_showing = true;
	emit showingChanged();

	emit ratValueChanged();

	return;
}
开发者ID:QuickBlox,项目名称:quickblox-blackberry10-sdk,代码行数:63,代码来源:RatingsProcessor.cpp

示例10: bytesAvailable

qint64 QNetworkReplyProto::bytesAvailable() const
{
  QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
  if (item)
    return item->bytesAvailable();
  return 0;
}
开发者ID:Dinesh-Ramakrishnan,项目名称:qt-client,代码行数:7,代码来源:qnetworkreplyproto.cpp

示例11: manifestReadyRead

void PAAlternativeLauncher::manifestReadyRead()
{
	QNetworkReply *reply = dynamic_cast<QNetworkReply *>(sender());
	if(reply)
	{
		if(reply->error() == QNetworkReply::NoError)
		{
			qint64 bytes_available = reply->bytesAvailable();
			QByteArray input = reply->read(bytes_available);
			Q_ASSERT(input.size() == bytes_available);
			mZstream.next_in = (Bytef *)input.constData();
			mZstream.avail_in = bytes_available;

			uInt old_avail_out = mZstream.avail_out;
			int res = inflate(&mZstream, Z_SYNC_FLUSH);
			if(res != Z_OK && res != Z_STREAM_END)
			{
				reply->abort();
				info.warning("ZLib", mZstream.msg, false);
				return;
			}

			mManifestJson.write((const char *)mBuffer, old_avail_out - mZstream.avail_out);
			mZstream.avail_out = mBufferSize;
			mZstream.next_out = mBuffer;
			Q_ASSERT(mZstream.avail_in == 0);
		}
		else
		{
			reply->abort();
			info.critical(tr("Manifest"), tr("Error while getting manifest (1).\n%1").arg(reply->errorString()));
		}
	}
}
开发者ID:DeathByDenim,项目名称:PAAlternativeLauncher,代码行数:34,代码来源:paalternativelauncher.cpp

示例12: onGetReply

/**
 * PostHttp::onGetReply()
 *
 * SLOT
 * Read and return the http response from our http post request
 */
void PostHttp::onGetReply()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

    QString response;
    if (reply) {
        if (reply->error() == QNetworkReply::NoError) {
            const int available = reply->bytesAvailable();
            if (available > 0) {
                const QByteArray buffer(reply->readAll());
                response = QString::fromUtf8(buffer);
            }
        } else {
            response = tr("Error: %1 status: %2").arg(reply->errorString(), reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString());
            qDebug() << response;
        }

        reply->deleteLater();
    }

    if (response.trimmed().isEmpty()) {
        response = tr("Unable to retrieve post response");
    }

    emit complete(response);
}
开发者ID:13natty,项目名称:Cascades-Samples,代码行数:32,代码来源:PostHttp.cpp

示例13: onReplyFinished

	void ImageLoader::onReplyFinished() {
		QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

		QString response;
		if (reply) {
			if (reply->error() == QNetworkReply::NoError) {
				const int available = reply->bytesAvailable();
				if (available > 0) {
					const QByteArray data(reply->readAll());
					QImage image;
					image.loadFromData(data);
					image = image.scaled(120, 120, Qt::KeepAspectRatioByExpanding);
					const QImage swappedImage = image.rgbSwapped();
					const bb::ImageData imageData = bb::ImageData::fromPixels(swappedImage.bits(), bb::PixelFormat::RGBA_Premultiplied, swappedImage.width(), swappedImage.height(), swappedImage.bytesPerLine());

					_image = bb::cascades::Image(imageData);
					emit imageChanged();

					_loading = false;
					emit loadingChanged();

					reply->deleteLater();
					return;
				}
			}
			reply->deleteLater();
		}

		// TODO: handle error: set default icon
	}
开发者ID:Kernald,项目名称:tt-rss-bb10,代码行数:30,代码来源:imageloader.cpp

示例14: onTimelineReply

/*
 * TwitterRequest::onTimelineReply()
 *
 * Callback handler for QNetworkReply finished() signal
 */
void TwitterRequest::onTimelineReply()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
    QString response;
    bool success = false;
    if (reply)
    {
        if (reply->error() == QNetworkReply::NoError)
        {
            int available = reply->bytesAvailable();
            if (available > 0)
            {
                int bufSize = sizeof(char) * available + sizeof(char);
                QByteArray buffer(bufSize, 0);
                int read = reply->read(buffer.data(), available);
                response = QString::fromUtf8(buffer);
                success = true;
            }
        }
        else
        {
            response =  QString("Error: ") + reply->errorString() + QString(" status:") + reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString();
            qDebug() << response;
        }
        reply->deleteLater();
    }
    if (response.trimmed().isEmpty())
    {
        response = "Twitter request failed. Check internet connection";
        qDebug() << response;
    }
    emit complete(response, success);
}
开发者ID:bchilibeck,项目名称:Cascades-Samples,代码行数:38,代码来源:TwitterRequest.cpp

示例15: onRequestUsers

void QBNetwork::onRequestUsers() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
	if (reply) {
		const int available = reply->bytesAvailable();
		if (available > 0) {
			const QByteArray buffer(reply->readAll());
			QString response = QString::fromUtf8(buffer);

			JsonDataAccess jda;
			QVariant qtData = jda.loadFromBuffer(response);
			if (jda.hasError()) {
				const DataAccessError err = jda.error();
				emit error(
						tr("Error converting JSON data: %1").arg(
								err.errorMessage()));
			} else {
				emit usersReceived(response);
			}
		} else {
			emit error("Wrong reply for request users request");
		}
		reply->deleteLater();
	} else {
		emit error("Wrong reply for request users request");
	}

	disconnectFromAll();
}
开发者ID:QuickBlox,项目名称:quickblox-blackberry10-sdk,代码行数:28,代码来源:QBNetwork.cpp


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