Exemple #1
0
//! translate handle status to P2Pstatus
P2P::FileStatus TorrentWrapper::getP2PStatusFromHandle( const libtorrent::torrent_handle& handle ) const
{
	if ( !handle.is_valid() )
		return P2P::not_stored;
	if ( handle.is_seed() )
		return P2P::complete;
	if ( handle.is_paused() )
		return P2P::paused;
	if ( handle.queue_position() > m_torr->settings().active_downloads )
		return P2P::queued;
	return P2P::leeching;
}
void TorrentManager::createTorrent(lt::torrent_handle & handle)
{
    if (handle.is_valid()) {
        boost::shared_ptr<const lt::torrent_info> info = handle.torrent_file();
        
        lt::create_torrent createTorrent(*info);
        lt::entry entry = createTorrent.generate();

        string path = m_torrentsPath + "/" + lt::to_hex(info->info_hash().to_string()) + ".torrent";
        writeBencodedTree(path, entry);
    }
}
Exemple #3
0
DeltaDownloader::DeltaDownloader(const libtorrent::torrent_handle& handle):
    handle_(handle)
{
    boost::shared_ptr<const lt::torrent_info> torrent = handle_.torrent_file();
    if (!torrent || !torrent->is_valid())
    {
        LOG_ERROR << "Torrent is invalid.";
        return;
    }
    //Always seed.
    handle_.auto_managed(false);
    handle_.pause();
    fileStorage_ = torrent->files();
    createFilePaths();
    handle.set_sequential_download(true); //Download patches one by one
    for (int i = 0; i < fileStorage_.num_files(); ++i)
    {
        if (Global::guiless) //Seed everything in mirror mode.
        {
                continue;
        }
        //Do not download anything. Sets priority to 0 whenever file does not exist.
        handle_.file_priority(i, DownloadPriority::NO_DOWNLOAD);
    }
    auto priors = handle_.file_priorities();
    handle_.resume();
}
Exemple #4
0
inline void add_fake_peer(lt::torrent_handle& h, int const i)
{
	char ep[30];
	std::snprintf(ep, sizeof(ep), "60.0.0.%d", i);
	h.connect_peer(lt::tcp::endpoint(
		lt::address_v4::from_string(ep), 6881));
}
Exemple #5
0
inline void add_fake_peers(lt::torrent_handle h)
{
	// add the fake peers
	for (int i = 0; i < 5; ++i)
	{
		char ep[30];
		std::snprintf(ep, sizeof(ep), "60.0.0.%d", i);
		h.connect_peer(lt::tcp::endpoint(
			lt::address_v4::from_string(ep), 6881));
	}
}
			void LiveStreamManager::EnableOn (libtorrent::torrent_handle handle)
			{
				if (!Handle2Device_.contains (handle))
				{
					qDebug () << Q_FUNC_INFO
						<< "on"
						<< QString::fromUtf8 (handle.save_path ().string ().c_str ());
					LiveStreamDevice *lsd = new LiveStreamDevice (handle, this);
					Handle2Device_ [handle] = lsd;
					connect (lsd,
							SIGNAL (ready ()),
							this,
							SLOT (handleDeviceReady ()));
					lsd->CheckReady ();
				}
			}
void SeedManager::addTorrent(QString torrent) {
    QSettings s(settingsPath + torrent, QSettings::IniFormat);
    QByteArray data = s.value("data").toByteArray();
    libtorrent::entry e = libtorrent::bdecode(data.begin(), data.end());
    libtorrent::torrent_info *inf = new libtorrent::torrent_info(e);
    const libtorrent::torrent_handle h =
            session->add_torrent(inf, s.value("path").toString().toStdString(), e);

    h.set_upload_mode(true);
    h.auto_managed(false);
    if (h.is_paused())
        h.resume();

    torrentNames[h.name()] = torrent;
}
Exemple #8
0
		// Returns number of seconds the torrent has been active
		inline boost::int64_t getActiveTime()
		{
			return m_handle.status().active_time;
		}
Exemple #9
0
		//Returns the URL of the last working tracker
		inline std::string getCurrentTrackerURL()
		{
			return m_handle.status().current_tracker;
		}
Exemple #10
0
		// Returns the current torrent state (downloading, queueing, seeding, etc)
		inline libtorrent::torrent_status::state_t getState()
		{
			return m_handle.status().state;
		}
Exemple #11
0
		// Returns a the total size of files remaining to download in torrent
		inline boost::int64_t getRemaining() { return m_handle.status().total_wanted - m_handle.status().total_wanted_done; }