void DownloadManager::startData(UserConnection* aSource, int64_t start, int64_t bytes, bool z) { Download* d = aSource->getDownload(); dcassert(d != NULL); dcdebug("Preparing " I64_FMT ":" I64_FMT ", " I64_FMT ":" I64_FMT"\n", static_cast<long long int>(d->getStartPos()), static_cast<long long int>(start), static_cast<long long int>(d->getSize()), static_cast<long long int>(bytes)); if(d->getSize() == -1) { if(bytes >= 0) { d->setSize(bytes); } else { failDownload(aSource, _("Invalid size")); return; } } else if(d->getSize() != bytes || d->getStartPos() != start) { // This is not what we requested... failDownload(aSource, _("Response does not match request")); return; } try { QueueManager::getInstance()->setFile(d); } catch(const FileException& e) { failDownload(aSource, str(F_("Could not open target file: %1%") % e.getError())); return; } catch(const Exception& e) { failDownload(aSource, e.getError()); return; } if((d->getType() == Transfer::TYPE_FILE || d->getType() == Transfer::TYPE_FULL_LIST) && SETTING(BUFFER_SIZE) > 0 ) { d->setFile(new BufferedOutputStream<true>(d->getFile())); } if(d->getType() == Transfer::TYPE_FILE) { typedef MerkleCheckOutputStream<TigerTree, true> MerkleStream; d->setFile(new MerkleStream(d->getTigerTree(), d->getFile(), d->getStartPos())); d->setFlag(Download::FLAG_TTH_CHECK); } // Check that we don't get too many bytes d->setFile(new LimitedOutputStream<true>(d->getFile(), bytes)); if(z) { d->setFlag(Download::FLAG_ZDOWNLOAD); d->setFile(new FilteredOutputStream<UnZFilter, true>(d->getFile())); } d->setStart(GET_TICK()); d->tick(); aSource->setState(UserConnection::STATE_RUNNING); fire(DownloadManagerListener::Starting(), d); if(d->getPos() == d->getSize()) { try { // Already finished? A zero-byte file list could cause this... endData(aSource); } catch(const Exception& e) { failDownload(aSource, e.getError()); } } else { aSource->setDataMode(); } }
void SearchManager::search(StringList& who, const string& aName, int64_t aSize /* = 0 */, TypeModes aTypeMode /* = TYPE_ANY */, SizeModes aSizeMode /* = SIZE_ATLEAST */, const string& aToken /* = Util::emptyString */) { if(okToSearch()) { ClientManager::getInstance()->search(who, aSizeMode, aSize, aTypeMode, aName, aToken); lastSearch = GET_TICK(); } }
IndexManager::IndexManager(void) : publish(false), publishing(0), nextRepublishTime(GET_TICK()) { }
// Set all new nodes' type to 3 to avoid spreading dead nodes.. Node::Node(const UserPtr& u) : OnlineUser(u, dht::client, 0), created(GET_TICK()), type(3), expires(0), ipVerified(false), online(false) { }
bool FileList::allowGenerateNew(bool forced) noexcept { bool dirty = (forced && xmlDirty) || forceXmlRefresh || (xmlDirty && (lastXmlUpdate + 15 * 60 * 1000 < GET_TICK())); if (!dirty) { return false; } listN++; return true; }
void Session::updateActivity() noexcept { lastActivity = GET_TICK(); }
void UserConnection::send(const string& aString) { lastActivity = GET_TICK(); COMMAND_DEBUG(aString, DebugManager::TYPE_CLIENT, DebugManager::OUTGOING, getRemoteIp()); socket->write(aString); }
void UserConnection::on(ModeChange) noexcept { lastActivity = GET_TICK(); fire(UserConnectionListener::ModeChange(), this); }
void UserConnection::on(BytesSent, size_t bytes, size_t actual) noexcept { lastActivity = GET_TICK(); fire(UserConnectionListener::BytesSent(), this, bytes, actual); }
void UserConnection::on(Data, uint8_t* data, size_t len) noexcept { lastActivity = GET_TICK(); fire(UserConnectionListener::Data(), this, data, len); }
void UserConnection::on(Connected) noexcept { lastActivity = GET_TICK(); fire(UserConnectionListener::Connected(), this); }