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


C++ Download::getCommand方法代码示例

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


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

示例1: checkDownloads

void DownloadManager::checkDownloads(UserConnection* aConn) {
    dcassert(aConn->getDownload() == NULL);

    QueueItem::Priority prio = QueueManager::getInstance()->hasDownload(aConn->getUser());
    if(!startDownload(prio)) {
        removeConnection(aConn);
        return;
    }

    Download* d = QueueManager::getInstance()->getDownload(*aConn, aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL));

    if(!d) {
        Lock l(cs);
        aConn->setState(UserConnection::STATE_IDLE);
        idlers.push_back(aConn);
        return;
    }

    aConn->setState(UserConnection::STATE_SND);

    if(aConn->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST) && d->getType() == Transfer::TYPE_FULL_LIST) {
        d->setFlag(Download::FLAG_XML_BZ_LIST);
    }

    {
        Lock l(cs);
        downloads.push_back(d);
    }
    fire(DownloadManagerListener::Requesting(), d);

    dcdebug("Requesting " I64_FMT "/" I64_FMT "\n", static_cast<long long int>(d->getStartPos()), static_cast<long long int>(d->getSize()));

    aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET)));
}
开发者ID:pk2010,项目名称:eiskaltdcpp,代码行数:34,代码来源:DownloadManager.cpp

示例2: checkDownloads

void DownloadManager::checkDownloads(UserConnection* aConn) {

	Download* d = aConn->getDownload();

	bool firstTry = false;
	if(d == NULL) {
		firstTry = true;

		bool slotsFull = (SETTING(DOWNLOAD_SLOTS) != 0) && (getDownloads() >= (size_t)SETTING(DOWNLOAD_SLOTS));
		bool speedFull = (SETTING(MAX_DOWNLOAD_SPEED) != 0) && (getAverageSpeed() >= (SETTING(MAX_DOWNLOAD_SPEED)*1024));

		if( slotsFull || speedFull ) {
			bool extraFull = (SETTING(DOWNLOAD_SLOTS) != 0) && (getDownloads() >= (size_t)(SETTING(DOWNLOAD_SLOTS)+3));
			if(extraFull || !QueueManager::getInstance()->hasDownload(aConn->getUser(), QueueItem::HIGHEST)) {
				removeConnection(aConn);
				return;
			}
		}

		d = QueueManager::getInstance()->getDownload(aConn->getUser());

		if(d == NULL) {
			removeConnection(aConn, true);
			return;
		}

		{
			Lock l(cs);
			downloads.push_back(d);
		}

		d->setUserConnection(aConn);
		aConn->setDownload(d);
	}

	if(firstTry && !d->getTreeValid() && 
		!d->isSet(Download::FLAG_USER_LIST) && d->getTTH() != NULL)
	{
		if(HashManager::getInstance()->getTree(d->getTarget(), d->getTTH(), d->getTigerTree())) {
			d->setTreeValid(true);
		} else if(!d->isSet(Download::FLAG_TREE_TRIED) && 
			aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL)) 
		{
			// So, we need to download the tree...
			Download* tthd = new Download();
			tthd->setOldDownload(d);
			tthd->setFlag(Download::FLAG_TREE_DOWNLOAD);
			tthd->setTarget(d->getTarget());
			tthd->setSource(d->getSource());

			tthd->setUserConnection(aConn);
			aConn->setDownload(tthd);

			aConn->setState(UserConnection::STATE_TREE);
			// Hack to get by TTH if possible
			tthd->setTTH(d->getTTH());
			aConn->send(tthd->getCommand(false, aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHF)));
			tthd->setTTH(NULL);
			return;
		}
	}

	aConn->setState(UserConnection::STATE_FILELENGTH);
	
	if(d->isSet(Download::FLAG_RESUME)) {
		dcassert(d->getSize() != -1);

		const string& target = (d->getTempTarget().empty() ? d->getTarget() : d->getTempTarget());
		int64_t start = File::getSize(target);

		// Only use antifrag if we don't have a previous non-antifrag part
		if( BOOLSETTING(ANTI_FRAG) && (start == -1) && (d->getSize() != -1) ) {
			int64_t aSize = File::getSize(target + Download::ANTI_FRAG_EXT);

			if(aSize == d->getSize())
				start = d->getPos();
			else
				start = 0;

			d->setFlag(Download::FLAG_ANTI_FRAG);
		}
		
		int rollback = SETTING(ROLLBACK);
		if(rollback > start) {
			d->setStartPos(0);
		} else {
			d->setStartPos(start - rollback);
			d->setFlag(Download::FLAG_ROLLBACK);
		}
	} else {
		d->setStartPos(0);
	}

	if(d->isSet(Download::FLAG_USER_LIST)) {
		if(aConn->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST)) {
			d->setSource("files.xml.bz2");
		}
	}

	if(aConn->isSet(UserConnection::FLAG_SUPPORTS_ADCGET) && d->isSet(Download::FLAG_UTF8)) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:linuxdcpp,代码行数:101,代码来源:DownloadManager.cpp


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