本文整理汇总了C++中UserConnection::setDownload方法的典型用法代码示例。如果您正苦于以下问题:C++ UserConnection::setDownload方法的具体用法?C++ UserConnection::setDownload怎么用?C++ UserConnection::setDownload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserConnection
的用法示例。
在下文中一共展示了UserConnection::setDownload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
Download::Download(UserConnection& conn, QueueItem& qi, const string& path, bool supportsTrees) throw() : Transfer(conn, path, qi.getTTH()),
tempTarget(qi.getTempTarget()), file(0), treeValid(false)
{
conn.setDownload(this);
if(qi.isSet(QueueItem::FLAG_PARTIAL_LIST)) {
setType(TYPE_PARTIAL_LIST);
} else if(qi.isSet(QueueItem::FLAG_USER_LIST)) {
setType(TYPE_FULL_LIST);
}
if(qi.getSize() != -1) {
if(HashManager::getInstance()->getTree(getTTH(), getTigerTree())) {
setTreeValid(true);
setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), conn.getChunkSize()));
} else if(supportsTrees && !qi.getSource(conn.getUser())->isSet(QueueItem::Source::FLAG_NO_TREE) && qi.getSize() > HashManager::MIN_BLOCK_SIZE) {
// Get the tree unless the file is small (for small files, we'd probably only get the root anyway)
setType(TYPE_TREE);
getTigerTree().setFileSize(qi.getSize());
setSegment(Segment(0, -1));
} else {
// Use the root as tree to get some sort of validation at least...
getTigerTree() = TigerTree(qi.getSize(), qi.getSize(), getTTH());
setTreeValid(true);
setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), 0));
}
}
}
示例2: Transfer
Download::Download(UserConnection& conn, QueueItem& qi, const string& path, bool supportsTrees) noexcept : Transfer(conn, path, qi.getTTH()),
tempTarget(qi.getTempTarget()), file(0), treeValid(false)
{
conn.setDownload(this);
QueueItem::SourceConstIter source = qi.getSource(getUser());
if(qi.isSet(QueueItem::FLAG_PARTIAL_LIST)) {
setType(TYPE_PARTIAL_LIST);
} else if(qi.isSet(QueueItem::FLAG_USER_LIST)) {
setType(TYPE_FULL_LIST);
}
if(getType() == TYPE_FILE && qi.getSize() != -1) {
if(HashManager::getInstance()->getTree(getTTH(), getTigerTree())) {
setTreeValid(true);
setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), conn.getChunkSize(),conn.getSpeed(), source->getPartialSource()));
} else if(supportsTrees && conn.isSet(UserConnection::FLAG_SUPPORTS_TTHL) && !qi.getSource(conn.getUser())->isSet(QueueItem::Source::FLAG_NO_TREE) && qi.getSize() > HashManager::MIN_BLOCK_SIZE) {
// Get the tree unless the file is small (for small files, we'd probably only get the root anyway)
setType(TYPE_TREE);
getTigerTree().setFileSize(qi.getSize());
setSegment(Segment(0, -1));
} else {
// Use the root as tree to get some sort of validation at least...
getTigerTree() = TigerTree(qi.getSize(), qi.getSize(), getTTH());
setTreeValid(true);
setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), 0, 0, source->getPartialSource()));
}
if(getSegment().getOverlapped()) {
setFlag(FLAG_OVERLAP);
// set overlapped flag to original segment
for(DownloadList::const_iterator i = qi.getDownloads().begin(); i != qi.getDownloads().end(); ++i) {
if((*i)->getSegment().contains(getSegment())) {
(*i)->setOverlapped(true);
break;
}
}
}
}
}
示例3: Transfer
Download::Download(UserConnection& conn, QueueItem& qi) noexcept : Transfer(conn, qi.getTarget(), qi.getTTH()),
tempTarget(qi.getTempTarget())
{
conn.setDownload(this);
QueueItem::SourceConstIter source = qi.getSource(getUser());
if(qi.isSet(QueueItem::FLAG_PARTIAL_LIST)) {
setType(TYPE_PARTIAL_LIST);
} else if(qi.isSet(QueueItem::FLAG_USER_LIST)) {
setType(TYPE_FULL_LIST);
}
if(source->isSet(QueueItem::Source::FLAG_PARTIAL))
setFlag(FLAG_PARTIAL);
if(qi.isSet(QueueItem::FLAG_CLIENT_VIEW))
setFlag(FLAG_VIEW);
if(qi.isSet(QueueItem::FLAG_MATCH_QUEUE))
setFlag(FLAG_QUEUE);
if(qi.isSet(QueueItem::FLAG_VIEW_NFO))
setFlag(FLAG_NFO);
if(qi.isSet(QueueItem::FLAG_RECURSIVE_LIST))
setFlag(FLAG_RECURSIVE);
if(qi.isSet(QueueItem::FLAG_TTHLIST_BUNDLE))
setFlag(FLAG_TTHLIST_BUNDLE);
if (qi.getPriority() == QueueItemBase::HIGHEST)
setFlag(FLAG_HIGHEST_PRIO);
if (qi.getBundle()) {
dcassert(!qi.isSet(QueueItem::FLAG_USER_LIST));
dcassert(!qi.isSet(QueueItem::FLAG_TEXT));
setBundle(qi.getBundle());
}
if(getType() == TYPE_FILE && qi.getSize() != -1) {
if(HashManager::getInstance()->getTree(getTTH(), getTigerTree())) {
setTreeValid(true);
setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), conn.getChunkSize(), conn.getSpeed(), source->getPartialSource(), true));
qi.setBlockSize(getTigerTree().getBlockSize());
} else if(conn.isSet(UserConnection::FLAG_SUPPORTS_TTHL) && !source->isSet(QueueItem::Source::FLAG_NO_TREE) && qi.getSize() > HashManager::MIN_BLOCK_SIZE) {
// Get the tree unless the file is small (for small files, we'd probably only get the root anyway)
setType(TYPE_TREE);
getTigerTree().setFileSize(qi.getSize());
setSegment(Segment(0, -1));
} else {
// Use the root as tree to get some sort of validation at least...
getTigerTree() = TigerTree(qi.getSize(), qi.getSize(), getTTH());
setTreeValid(true);
setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), 0, 0, source->getPartialSource(), true));
}
if ((getStartPos() + getSegmentSize()) != qi.getSize() || (conn.getDownload() && conn.getDownload()->isSet(FLAG_CHUNKED))) {
setFlag(FLAG_CHUNKED);
}
if(getSegment().getOverlapped()) {
setFlag(FLAG_OVERLAP);
// set overlapped flag to original segment
for(auto d: qi.getDownloads()) {
if(d->getSegment().contains(getSegment())) {
d->setOverlapped(true);
break;
}
}
}
}
}