Ejemplo n.º 1
0
void Identity::getParams(ParamMap& sm, const string& prefix, bool compatibility) const noexcept {
	{
		RLock l(cs);
		for(auto& i: info) {
			sm[prefix + string((char*)(&i.first), 2)] = i.second;
		}
	}
	if(user) {
		sm[prefix + "NI"] = getNick();
		sm[prefix + "SID"] = getSIDString();
		sm[prefix + "CID"] = user->getCID().toBase32();
		sm[prefix + "TAG"] = getTag();
		sm[prefix + "CO"] = getNmdcConnection();
		sm[prefix + "DS"] = getDownloadSpeed();
		sm[prefix + "SSshort"] = Util::formatBytes(get("SS"));

		if(compatibility) {
			if(prefix == "my") {
				sm["mynick"] = getNick();
				sm["mycid"] = user->getCID().toBase32();
			} else {
				sm["nick"] = getNick();
				sm["cid"] = user->getCID().toBase32();
				sm["ip"] = get("I4");
				sm["tag"] = getTag();
				sm["description"] = get("DE");
				sm["email"] = get("EM");
				sm["share"] = get("SS");
				sm["shareshort"] = Util::formatBytes(get("SS"));
				sm["realshareformat"] = Util::formatBytes(get("RS"));
			}
		}
	}
}
Ejemplo n.º 2
0
void ConsoleProgress::updateHook(bool immediate)
{
	if (!__impl->isUpdateNeeded(immediate))
	{
		return;
	}

	vector< DownloadRecordForPrint > printRecords;
	const std::map< string, DownloadRecord >& records = this->getDownloadRecords();
	for (const auto& item: records)
	{
		if (item.second.phase < DownloadRecord::Phase::Started) continue;

		DownloadRecordForPrint recordForPrint;
		recordForPrint.record = item.second;
		recordForPrint.uri = item.first;
		recordForPrint.shortAlias = this->getShortAliasForUri(recordForPrint.uri);
		printRecords.push_back(std::move(recordForPrint));
	}

	auto estimatedSize = getOverallEstimatedSize();
	uint8_t overallPercent = estimatedSize ? (getOverallDownloadedSize() * 100 / estimatedSize) : 0;
	auto estimatedRemainingTime = getOverallEstimatedTime() - getOverallDownloadTime();
	__impl->updateView(printRecords, overallPercent, estimatedRemainingTime, getDownloadSpeed());
}
Ejemplo n.º 3
0
	void ChunkDownload::getStats(Stats & s)
	{
		s.chunk_index = chunk->getIndex();
		s.current_peer_id = getCurrentPeerID();
		s.download_speed = getDownloadSpeed();
		s.num_downloaders = getNumDownloaders();
		s.pieces_downloaded = num_downloaded;
		s.total_pieces = num;
	}