本文整理汇总了C++中QueueItemPtr::getTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ QueueItemPtr::getTarget方法的具体用法?C++ QueueItemPtr::getTarget怎么用?C++ QueueItemPtr::getTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueItemPtr
的用法示例。
在下文中一共展示了QueueItemPtr::getTarget方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareFiles
int QueueFileUtils::compareFiles(const QueueItemPtr& a, const QueueItemPtr& b, int aPropertyName) noexcept {
switch (aPropertyName) {
case PROP_NAME: {
return Util::pathSort(a->getTarget(), b->getTarget());
}
case PROP_TYPE: {
return Util::stricmp(Util::getFileExt(a->getTarget()), Util::getFileExt(b->getTarget()));
}
case PROP_PRIORITY: {
COMPARE_FINISHED(a, b);
return compare(static_cast<int>(a->getPriority()), static_cast<int>(b->getPriority()));
}
case PROP_STATUS: {
COMPARE_FINISHED(a, b);
return compare(
a->getPercentage(QueueManager::getInstance()->getDownloadedBytes(a)),
b->getPercentage(QueueManager::getInstance()->getDownloadedBytes(b))
);
}
case PROP_SOURCES: {
COMPARE_FINISHED(a, b);
auto countsA = QueueManager::getInstance()->getSourceCount(a);
auto countsB = QueueManager::getInstance()->getSourceCount(b);
return QueueItemBase::SourceCount::compare(countsA, countsB);
}
default:
dcassert(0);
}
return 0;
}
示例2: getDisplayName
string QueueFileUtils::getDisplayName(const QueueItemPtr& aItem) noexcept {
if (aItem->getBundle() && !aItem->getBundle()->isFileBundle()) {
return aItem->getTarget().substr(aItem->getBundle()->getTarget().size(), aItem->getTarget().size());
}
return aItem->getTargetFileName();
}
示例3: on
void ViewFileManager::on(QueueManagerListener::ItemAdded, const QueueItemPtr& aQI) noexcept {
if (!isViewedItem(aQI)) {
return;
}
auto file = createFile(aQI->getTarget(), aQI->getTTH(), aQI->isSet(QueueItem::FLAG_TEXT), false);
if (file) {
file->onAddedQueue(aQI->getTarget(), aQI->getSize());
}
}
示例4: getStringInfo
std::string QueueFileUtils::getStringInfo(const QueueItemPtr& aItem, int aPropertyName) noexcept {
switch (aPropertyName) {
case PROP_NAME: return getDisplayName(aItem);
case PROP_TARGET: return aItem->getTarget();
case PROP_TYPE: return Format::formatFileType(aItem->getTarget());
case PROP_STATUS: return formatDisplayStatus(aItem);
case PROP_PRIORITY: return AirUtil::getPrioText(aItem->getPriority());
case PROP_SOURCES: return formatFileSources(aItem);
case PROP_TTH: return aItem->getTTH().toBase32();
default: dcassert(0); return Util::emptyString;
}
}
示例5: removeBundleItem
void BundleQueue::removeBundleItem(QueueItemPtr& aQI, bool aDownloadFinished) noexcept {
dcassert(aQI->getBundle());
aQI->getBundle()->removeQueue(aQI, aDownloadFinished);
if (!aQI->getBundle()->isFileBundle()) {
forEachPath(aQI->getBundle(), aQI->getTarget(), [&](PathInfo& aInfo) {
if (aQI->isDownloaded()) {
aInfo.finishedFiles--;
} else {
aInfo.queuedFiles--;
}
if (!aDownloadFinished) {
aInfo.size -= aQI->getSize();
}
#ifdef _DEBUG
if (aInfo.queuedFiles == 0 && aInfo.finishedFiles == 0) {
dcassert(aInfo.size == 0);
}
dcassert(aInfo.size >= 0 && aInfo.finishedFiles >= 0 && aInfo.queuedFiles >= 0);
#endif
});
}
if (aDownloadFinished || !aQI->isDownloaded()) {
queueSize -= aQI->getSize();
dcassert(queueSize >= 0);
}
}
示例6: serializeFileProperty
json QueueFileUtils::serializeFileProperty(const QueueItemPtr& aFile, int aPropertyName) noexcept {
switch (aPropertyName) {
case PROP_SOURCES:
{
auto c = QueueManager::getInstance()->getSourceCount(aFile);
return Serializer::serializeSourceCount(c);
}
case PROP_STATUS:
{
return {
{ "finished", aFile->isSet(QueueItem::FLAG_FINISHED) },
{ "str", formatDisplayStatus(aFile) },
};
}
case PROP_PRIORITY: {
return Serializer::serializePriority(*aFile.get());
}
case PROP_TYPE:
{
return Serializer::serializeFileType(aFile->getTarget());
}
}
dcassert(0);
return nullptr;
}
示例7: on
void DirectoryListingManager::on(QueueManagerListener::ItemRemoved, const QueueItemPtr& qi, bool aFinished) noexcept {
if (!qi->isSet(QueueItem::FLAG_USER_LIST))
return;
auto u = qi->getSources()[0].getUser();
if (qi->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD) && !aFinished)
removeDirectoryDownload(u, qi->getTempTarget(), qi->isSet(QueueItem::FLAG_PARTIAL_LIST));
if (qi->isSet(QueueItem::FLAG_CLIENT_VIEW)) {
DirectoryListingPtr dl = nullptr;
{
RLock l(cs);
auto p = viewedLists.find(u);
if (p == viewedLists.end()) {
dcassert(0);
return;
}
dl = p->second;
}
dl->onListRemovedQueue(qi->getTarget(), qi->getTempTarget(), aFinished);
bool closing = (dl->getClosing() || !dl->hasCompletedDownloads());
if (!aFinished && !dl->hasDownloads() && closing) {
removeList(u);
}
}
}
示例8: add
void FileQueue::add(QueueItemPtr& qi) noexcept {
if (!qi->isSet(QueueItem::FLAG_USER_LIST) && !qi->isSet(QueueItem::FLAG_CLIENT_VIEW) && !qi->isSet(QueueItem::FLAG_FINISHED)) {
dcassert(qi->getSize() >= 0);
queueSize += qi->getSize();
}
dcassert(queueSize >= 0);
queue.emplace(const_cast<string*>(&qi->getTarget()), qi);
tthIndex.emplace(const_cast<TTHValue*>(&qi->getTTH()), qi);
}
示例9:
pair<QueueItem::StringMap::const_iterator, bool> FileQueue::add(QueueItemPtr& qi) noexcept {
dcassert(queueSize >= 0);
auto ret = queue.emplace(const_cast<string*>(&qi->getTarget()), qi);
if (ret.second) {
tthIndex.emplace(const_cast<TTHValue*>(&qi->getTTH()), qi);
if (!qi->isSet(QueueItem::FLAG_USER_LIST) && !qi->isSet(QueueItem::FLAG_CLIENT_VIEW) && !qi->isSet(QueueItem::FLAG_FINISHED)) {
dcassert(qi->getSize() >= 0);
queueSize += qi->getSize();
}
}
return ret;
}
示例10: on
void FinishedManager::on(QueueManagerListener::Finished, const QueueItemPtr& qi, const string&, const HintedUser& aUser, int64_t aSpeed) noexcept {
if(!qi->isSet(QueueItem::FLAG_USER_LIST) || SETTING(LOG_FILELIST_TRANSFERS)) {
FinishedItemPtr item = new FinishedItem(qi->getTarget(), aUser, qi->getSize(), static_cast<int64_t>(aSpeed), GET_TIME(), qi->getTTH().toBase32());
{
Lock l(cs);
downloads.push_back(item);
}
fire(FinishedManagerListener::AddedDl(), item);
if(SETTING(SYSTEM_SHOW_DOWNLOADS)) {
size_t BUF_SIZE = STRING(FINISHED_DOWNLOAD).size() + UNC_MAX_PATH + 128;
char* buf = new char[BUF_SIZE];
snprintf(buf, BUF_SIZE, CSTRING(FINISHED_DOWNLOAD), Util::getFileName(qi->getTarget()).c_str(),
Util::toString(ClientManager::getInstance()->getNicks(aUser)).c_str());
LogManager::getInstance()->message(buf, LogManager::LOG_INFO);
delete[] buf;
}
}
}
示例11: on
void FinishedManager::on(QueueManagerListener::Finished, const QueueItemPtr& qi, const string&, const DownloadPtr& p_download) noexcept
{
if (!ClientManager::isShutdown())
{
const bool isFile = !qi->isAnySet(QueueItem::FLAG_USER_LIST | QueueItem::FLAG_DCLST_LIST | QueueItem::FLAG_USER_GET_IP);
if (isFile)
{
PLAY_SOUND(SOUND_FINISHFILE);
}
if (isFile || (qi->isAnySet(QueueItem::FLAG_USER_LIST | QueueItem::FLAG_DCLST_LIST) && BOOLSETTING(LOG_FILELIST_TRANSFERS)))
{
auto item = std::make_shared<FinishedItem>(qi->getTarget(), p_download->getHintedUser(),
qi->getSize(), p_download->getRunningAverage(),
GET_TIME(), qi->getTTH(), p_download->getActual(), p_download->getUser()->getIPAsString());
if (SETTING(DB_LOG_FINISHED_DOWNLOADS))
{
CFlylinkDBManager::getInstance()->save_transfer_history(false, e_TransferDownload, item);
}
rotation_items(item, e_Download);
fly_fire2(FinishedManagerListener::AddedDl(), item, false);
log(p_download->getUser()->getCID(), qi->getTarget(), STRING(FINISHED_DOWNLOAD));
}
}
}
示例12: addBundleItem
void BundleQueue::addBundleItem(QueueItemPtr& aQI, BundlePtr& aBundle) noexcept {
dcassert(!aQI->getBundle());
aBundle->addQueue(aQI);
aQI->setBundle(aBundle);
if (!aBundle->isFileBundle()) {
forEachPath(aBundle, aQI->getTarget(), [&](PathInfo& aInfo) {
if (aQI->isDownloaded()) {
aInfo.finishedFiles++;
} else {
aInfo.queuedFiles++;
}
aInfo.size += aQI->getSize();
});
}
if (!aQI->isDownloaded()) {
queueSize += aQI->getSize();
}
}
示例13: remove
void FileQueue::remove(QueueItemPtr& qi) noexcept {
//TargetMap
auto f = queue.find(const_cast<string*>(&qi->getTarget()));
if (f != queue.end()) {
queue.erase(f);
if (!qi->isSet(QueueItem::FLAG_USER_LIST) && (!qi->isSet(QueueItem::FLAG_FINISHED) || !qi->getBundle()) && !qi->isSet(QueueItem::FLAG_CLIENT_VIEW)) {
dcassert(qi->getSize() >= 0);
queueSize -= qi->getSize();
}
}
dcassert(queueSize >= 0);
//TTHIndex
auto s = tthIndex.equal_range(const_cast<TTHValue*>(&qi->getTTH()));
dcassert(s.first != s.second);
auto k = find(s | map_values, qi);
if (k.base() != s.second) {
tthIndex.erase(k.base());
}
}
示例14: move
void FileQueue::move(QueueItemPtr& qi, const string& aTarget) noexcept {
pathQueue.erase(const_cast<string*>(&qi->getTarget()));
qi->setTarget(aTarget);
pathQueue.emplace(const_cast<string*>(&qi->getTarget()), qi);
}