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


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

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


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

示例1: isReadable

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

示例2: httpUpdateDownloadFinished

void FvUpdater::httpUpdateDownloadFinished()
{
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
	if(reply==NULL)
	{
		qWarning()<<"The slot httpUpdateDownloadFinished() should only be invoked by S&S.";
		return;
	}

	if(reply->error() == QNetworkReply::NoError)
	{
		int httpstatuscode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toUInt();

		// no error received?
		if (reply->error() == QNetworkReply::NoError)
		{
			if (reply->isReadable())
			{
#ifdef Q_OS_MAC
                CFURLRef appURLRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
                char path[PATH_MAX];
                if (!CFURLGetFileSystemRepresentation(appURLRef, TRUE, (UInt8 *)path, PATH_MAX)) {
                    // error!
                }

                CFRelease(appURLRef);
                QString filePath = QString(path);
                QString rootDirectory = filePath.left(filePath.lastIndexOf("/"));
#else
                QString rootDirectory = QCoreApplication::applicationDirPath() + "/";
#endif
                
				// Write download into File
				QFileInfo fileInfo=reply->url().path();
				QString fileName = rootDirectory + fileInfo.fileName();
				//qDebug()<<"Writing downloaded file into "<<fileName;
	
				QFile file(fileName);
				file.open(QIODevice::WriteOnly);
				file.write(reply->readAll());
				file.close();

				// Retrieve List of updated files (Placed in an extra scope to avoid QuaZIP handles the archive permanently and thus avoids the deletion.)
				{	
					QuaZip zip(fileName);
					if (!zip.open(QuaZip::mdUnzip)) {
						qWarning("testRead(): zip.open(): %d", zip.getZipError());
						return;
					}
					zip.setFileNameCodec("IBM866");
					QList<QuaZipFileInfo> updateFiles = zip.getFileInfoList();
		
					// Rename all current files with available update.
					for (int i=0;i<updateFiles.size();i++)
					{
						QString sourceFilePath = rootDirectory + "\\" + updateFiles[i].name;
						QDir appDir( QCoreApplication::applicationDirPath() );

						QFileInfo file(	sourceFilePath );
						if(file.exists())
						{
							//qDebug()<<tr("Moving file %1 to %2").arg(sourceFilePath).arg(sourceFilePath+".oldversion");
							appDir.rename( sourceFilePath, sourceFilePath+".oldversion" );
						}
					}
				}

				// Install updated Files
				unzipUpdate(fileName, rootDirectory);

				// Delete update archive
                while(QFile::remove(fileName) )
                {
                };

				// Restart ap to clean up and start usual business
				restartApplication();

			}
			else qDebug()<<"Error: QNetworkReply is not readable!";
		}
		else 
		{
			qDebug()<<"Download errors ocurred! HTTP Error Code:"<<httpstatuscode;
		}

		reply->deleteLater();
    }	// If !reply->error END
}	// httpUpdateDownloadFinished END
开发者ID:macressler,项目名称:hifi,代码行数:89,代码来源:fvupdater.cpp


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