Ejemplo n.º 1
0
bool Torrent::pollEvent(gt::Event &event)
{
	if (getTotalProgress() >= 100) {
		event.type = gt::Event::DownloadCompleted;
		return true;
	}

	return false;
}
Ejemplo n.º 2
0
string Torrent::getTextState()
{
	switch (getState()) {
		case libtorrent::torrent_status::checking_files:
			return "Checking";
		break;
		case libtorrent::torrent_status::seeding:
			return "Seeding";
		break;
		case libtorrent::torrent_status::downloading:
		default:
			char p[5];
			sprintf(p, "%.1f %%", getTotalProgress());
			return p;
		break;
	}
}
Ejemplo n.º 3
0
string Torrent::getTextState()
{
	switch (getState())
	{
	case libtorrent::torrent_status::checking_files:
		return "Checking";
		break;
	case libtorrent::torrent_status::seeding:
		return "Seeding";
		break;
	case libtorrent::torrent_status::downloading:
	default:
		std::ostringstream o;
		o << setprecision(2) << getTotalProgress() << " %";
		return o.str();
		break;
	}
}
Ejemplo n.º 4
0
void ProgressData::callEvent() {
	if (eventHandler==NULL || !sendEvents) return;
	ItemState a;
	a.name=getItemName(lastChangedItem);
	a.currentAction=getItemCurrentAction(lastChangedItem);
	a.progress=10000.0f*(getItemProgress(lastChangedItem)/getItemProgressMaximum(lastChangedItem))/100;
	a.totalProgress=10000.0f*(getTotalProgress()/getTotalProgressMax())/100;
	a.itemOrder = getItemOrder(lastChangedItem);
	int64_t totalMem = 0;
	for (size_t i=0; i<itemName.size(); ++i) {
		totalMem += itemName[i].size();
	}
	for (size_t i=0; i<itemCurrentAction.size(); ++i) {
		totalMem += itemCurrentAction[i].size();
	}
	
	// This stuff is useful for debug: counts and shows events
	eventCounter++;
	//fprintf(stderr, "[%d] callEvent: %s, queue size: %Ld, total mem: %Ld (%s)\n", eventCounter, a.currentAction.c_str(), itemName.size(), totalMem, humanizeSize(totalMem).c_str());
	//fprintf(stderr, "[%d] callEvent: %s/%s, progress: %d, totalProgress: %d, max: %f\n", eventCounter, a.name.c_str(), a.currentAction.c_str(), a.progress, a.totalProgress, getTotalProgressMax());
	(*eventHandler) (a);
}
Ejemplo n.º 5
0
std::string gt::Torrent::getTextState()
{
	std::ostringstream o;
	int precision = 1;

	if(getHandle().status().queue_position != -1 && 
	   getHandle().status().queue_position >= stoi(gt::Settings::settings["ActiveDownloads"])) return "Queued";

	switch (getState())
	{
	case libtorrent::torrent_status::queued_for_checking:
		return "Queued for checking";
	case libtorrent::torrent_status::downloading_metadata:
		return "Downloading metadata...";
	case libtorrent::torrent_status::finished:
		return "Finished";
	case libtorrent::torrent_status::allocating:
		return "Allocating...";
	case libtorrent::torrent_status::checking_resume_data:
		return "Resuming...";
	case libtorrent::torrent_status::checking_files:
		return "Checking...";
	case libtorrent::torrent_status::seeding:
		return "Seeding";
	case libtorrent::torrent_status::downloading:
		break;
	}

	if(isPaused())
		return "Paused";

	if (m_torrent_params.ti != NULL) //m_torrent_params.ti is not initial initialized for magnet links
		precision = m_torrent_params.ti->total_size() < 0x2000000;//Set 0 decimal places if file is less than 1 gig.
	o << std::fixed << std::setprecision(precision) << getTotalProgress() << '%';
	return o.str();

}