本文整理汇总了C++中QNetworkSession::state方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkSession::state方法的具体用法?C++ QNetworkSession::state怎么用?C++ QNetworkSession::state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkSession
的用法示例。
在下文中一共展示了QNetworkSession::state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _q_networkSessionConnected
void QNetworkReplyImplPrivate::_q_networkSessionConnected()
{
Q_Q(QNetworkReplyImpl);
if (manager.isNull())
return;
QNetworkSession *session = manager->d_func()->networkSession;
if (!session)
return;
if (session->state() != QNetworkSession::Connected)
return;
switch (state) {
case QNetworkReplyImplPrivate::Buffering:
case QNetworkReplyImplPrivate::Working:
case QNetworkReplyImplPrivate::Reconnecting:
// Migrate existing downloads to new network connection.
migrateBackend();
break;
case QNetworkReplyImplPrivate::WaitingForSession:
// Start waiting requests.
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
break;
default:
;
}
}
示例2: finished
void QNetworkReplyImplPrivate::finished()
{
Q_Q(QNetworkReplyImpl);
if (state == Finished || state == Aborted || state == WaitingForSession)
return;
pauseNotificationHandling();
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
if (!manager.isNull()) {
#ifndef QT_NO_BEARERMANAGEMENT
QNetworkSession *session = manager->d_func()->networkSession;
if (session && session->state() == QNetworkSession::Roaming &&
state == Working && errorCode != QNetworkReply::OperationCanceledError) {
// only content with a known size will fail with a temporary network failure error
if (!totalSize.isNull()) {
if (bytesDownloaded != totalSize) {
if (migrateBackend()) {
// either we are migrating or the request is finished/aborted
if (state == Reconnecting || state == WaitingForSession) {
resumeNotificationHandling();
return; // exit early if we are migrating.
}
} else {
error(QNetworkReply::TemporaryNetworkFailureError,
QNetworkReply::tr("Temporary network failure."));
}
}
}
}
#endif
}
resumeNotificationHandling();
state = Finished;
pendingNotifications.clear();
pauseNotificationHandling();
if (totalSize.isNull() || totalSize == -1) {
emit q->downloadProgress(bytesDownloaded, bytesDownloaded);
}
if (bytesUploaded == -1 && (outgoingData || outgoingDataBuffer))
emit q->uploadProgress(0, 0);
resumeNotificationHandling();
// if we don't know the total size of or we received everything save the cache
if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize)
completeCacheSave();
// note: might not be a good idea, since users could decide to delete us
// which would delete the backend too...
// maybe we should protect the backend
pauseNotificationHandling();
emit q->readChannelFinished();
emit q->finished();
resumeNotificationHandling();
}