simplify session call and replace session_handle and torrent_handle macros (#741)
remove use of macros in session_handle and torrent_handle forwarders
This commit is contained in:
parent
b4e11a06c0
commit
dceee3b065
|
@ -37,70 +37,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/aux_/session_impl.hpp"
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace libtorrent { namespace aux {
|
||||
|
||||
void blocking_call();
|
||||
void dump_call_profile();
|
||||
|
||||
void fun_wrap(bool& done, std::condition_variable& e, std::mutex& m, boost::function<void(void)> f);
|
||||
|
||||
template <class R>
|
||||
void fun_ret(R& ret, bool& done, std::condition_variable& e, std::mutex& m, boost::function<R(void)> f)
|
||||
{
|
||||
ret = f();
|
||||
std::unique_lock<std::mutex> l(m);
|
||||
done = true;
|
||||
e.notify_all();
|
||||
}
|
||||
|
||||
void torrent_wait(bool& done, aux::session_impl& ses);
|
||||
|
||||
void sync_call(aux::session_impl& ses, boost::function<void(void)> f);
|
||||
|
||||
template <typename Handle>
|
||||
void sync_call_handle(Handle& h, boost::function<void(void)> f)
|
||||
{
|
||||
bool done = false;
|
||||
session_impl& ses = static_cast<session_impl&>(h->session());
|
||||
ses.get_io_service().dispatch(boost::bind(&aux::fun_wrap
|
||||
, boost::ref(done)
|
||||
, boost::ref(ses.cond)
|
||||
, boost::ref(ses.mut), f));
|
||||
h.reset();
|
||||
aux::torrent_wait(done, ses);
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
Ret sync_call_ret(aux::session_impl& ses, boost::function<Ret(void)> f)
|
||||
{
|
||||
bool done = false;
|
||||
Ret r;
|
||||
ses.get_io_service().dispatch(boost::bind(&fun_ret<Ret>
|
||||
, boost::ref(r)
|
||||
, boost::ref(done)
|
||||
, boost::ref(ses.cond)
|
||||
, boost::ref(ses.mut)
|
||||
, f));
|
||||
torrent_wait(done, ses);
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename Handle, typename Ret>
|
||||
void sync_call_ret_handle(Handle& h, Ret& r, boost::function<Ret(void)> f)
|
||||
{
|
||||
bool done = false;
|
||||
session_impl& ses = static_cast<session_impl&>(h->session());
|
||||
ses.get_io_service().dispatch(boost::bind(&aux::fun_ret<Ret>
|
||||
, boost::ref(r)
|
||||
, boost::ref(done)
|
||||
, boost::ref(ses.cond)
|
||||
, boost::ref(ses.mut)
|
||||
, f));
|
||||
h.reset();
|
||||
aux::torrent_wait(done, ses);
|
||||
}
|
||||
|
||||
} } // namespace aux namespace libtorrent
|
||||
|
||||
#endif // TORRENT_SESSION_CALL_HPP_INCLUDED
|
||||
|
|
|
@ -339,7 +339,8 @@ namespace libtorrent
|
|||
void dht_get_peers(sha1_hash const& info_hash);
|
||||
void dht_announce(sha1_hash const& info_hash, int port = 0, int flags = 0);
|
||||
|
||||
void dht_direct_request(udp::endpoint ep, entry& e, void* userdata = 0);
|
||||
void dht_direct_request(udp::endpoint ep, entry& e
|
||||
, void* userdata = 0);
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
entry dht_state() const;
|
||||
|
@ -443,15 +444,15 @@ namespace libtorrent
|
|||
void pop_alerts();
|
||||
alert const* pop_alert();
|
||||
size_t set_alert_queue_size_limit(size_t queue_size_limit_);
|
||||
int upload_rate_limit() const;
|
||||
int download_rate_limit() const;
|
||||
int upload_rate_limit_depr() const;
|
||||
int download_rate_limit_depr() const;
|
||||
int local_upload_rate_limit() const;
|
||||
int local_download_rate_limit() const;
|
||||
|
||||
void set_local_download_rate_limit(int bytes_per_second);
|
||||
void set_local_upload_rate_limit(int bytes_per_second);
|
||||
void set_download_rate_limit(int bytes_per_second);
|
||||
void set_upload_rate_limit(int bytes_per_second);
|
||||
void set_download_rate_limit_depr(int bytes_per_second);
|
||||
void set_upload_rate_limit_depr(int bytes_per_second);
|
||||
void set_max_connections(int limit);
|
||||
void set_max_uploads(int limit);
|
||||
|
||||
|
|
|
@ -1021,6 +1021,16 @@ namespace libtorrent
|
|||
{ return m_impl; }
|
||||
|
||||
private:
|
||||
|
||||
template <typename Fun, typename... Args>
|
||||
void async_call(Fun f, Args&&... a) const;
|
||||
|
||||
template <typename Fun, typename... Args>
|
||||
void sync_call(Fun f, Args&&... a) const;
|
||||
|
||||
template <typename Ret, typename Fun, typename... Args>
|
||||
Ret sync_call_ret(Fun f, Args&&... a) const;
|
||||
|
||||
aux::session_impl* m_impl;
|
||||
};
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
void add_extension(boost::shared_ptr<torrent_plugin>);
|
||||
void remove_extension(boost::shared_ptr<torrent_plugin>);
|
||||
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
void add_extension_fun(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata);
|
||||
void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags);
|
||||
#endif
|
||||
|
@ -508,7 +508,7 @@ namespace libtorrent
|
|||
void filtered_pieces(std::vector<bool>& bitmask) const;
|
||||
void filter_files(std::vector<bool> const& files);
|
||||
#if !TORRENT_NO_FPU
|
||||
void file_progress(std::vector<float>& fp);
|
||||
void file_progress_float(std::vector<float>& fp);
|
||||
#endif
|
||||
// ============ end deprecation =============
|
||||
|
||||
|
@ -579,16 +579,17 @@ namespace libtorrent
|
|||
|
||||
// add or remove a url that will be attempted for
|
||||
// finding the file(s) in this torrent.
|
||||
void add_web_seed(std::string const& url, web_seed_t::type_t type);
|
||||
void add_web_seed(std::string const& url, web_seed_t::type_t type
|
||||
, std::string const& auth, web_seed_t::headers_t const& extra_headers);
|
||||
void add_web_seed(std::string const& url
|
||||
, web_seed_t::type_t type
|
||||
, std::string const& auth = std::string()
|
||||
, web_seed_t::headers_t const& extra_headers = web_seed_entry::headers_t());
|
||||
|
||||
void remove_web_seed(std::string const& url, web_seed_t::type_t type);
|
||||
void disconnect_web_seed(peer_connection* p);
|
||||
|
||||
void retry_web_seed(peer_connection* p, int retry = 0);
|
||||
|
||||
void remove_web_seed(peer_connection* p, error_code const& ec
|
||||
void remove_web_seed_conn(peer_connection* p, error_code const& ec
|
||||
, operation_t op, int error = 0);
|
||||
|
||||
std::set<std::string> web_seeds(web_seed_entry::type_t type) const;
|
||||
|
@ -747,7 +748,7 @@ namespace libtorrent
|
|||
return m_super_seeding && is_seed();
|
||||
}
|
||||
|
||||
void super_seeding(bool on);
|
||||
void set_super_seeding(bool on);
|
||||
int get_piece_to_super_seed(bitfield const&);
|
||||
|
||||
// returns true if we have downloaded the given piece
|
||||
|
@ -864,7 +865,7 @@ namespace libtorrent
|
|||
|
||||
// remove a web seed, or schedule it for removal in case there
|
||||
// are outstanding operations on it
|
||||
void remove_web_seed(std::list<web_seed_t>::iterator web);
|
||||
void remove_web_seed_iter(std::list<web_seed_t>::iterator web);
|
||||
|
||||
// this is called when the torrent has finished. i.e.
|
||||
// all the pieces we have not filtered have been downloaded.
|
||||
|
|
|
@ -241,6 +241,8 @@ namespace libtorrent
|
|||
// with just set_flags() and clear_flags() using the flags from
|
||||
// add_torrent_params. Perhaps those flags should have a more generic
|
||||
// name.
|
||||
|
||||
// TODO: 4 remove some of these friends
|
||||
friend class invariant_access;
|
||||
friend struct aux::session_impl;
|
||||
friend class session;
|
||||
|
@ -1281,6 +1283,15 @@ namespace libtorrent
|
|||
|
||||
private:
|
||||
|
||||
template<typename Fun, typename... Args>
|
||||
void async_call(Fun f, Args&&... a) const;
|
||||
|
||||
template<typename Fun, typename... Args>
|
||||
void sync_call(Fun f, Args&&... a) const;
|
||||
|
||||
template<typename Ret, typename Fun, typename... Args>
|
||||
Ret sync_call_ret(Ret def, Fun f, Args&&... a) const;
|
||||
|
||||
torrent_handle(boost::weak_ptr<torrent> const& t)
|
||||
{ if (!t.expired()) m_torrent = t; }
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace libtorrent
|
|||
peer_connection::disconnect(ec, op, error);
|
||||
if (t) t->disconnect_web_seed(this);
|
||||
}
|
||||
|
||||
|
||||
boost::optional<piece_block_progress>
|
||||
http_seed_connection::downloading_piece_progress() const
|
||||
{
|
||||
|
@ -269,9 +269,9 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
TORRENT_ASSERT(recv_buffer.left() == 0 || *recv_buffer.begin == 'H');
|
||||
|
||||
|
||||
TORRENT_ASSERT(recv_buffer.left() <= m_recv_buffer.packet_size());
|
||||
|
||||
|
||||
// this means the entire status line hasn't been received yet
|
||||
if (m_parser.status_code() == -1)
|
||||
{
|
||||
|
@ -320,13 +320,13 @@ namespace libtorrent
|
|||
if (location.empty())
|
||||
{
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(this, errors::missing_location, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::missing_location, op_bittorrent, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// add the redirected url and remove the current one
|
||||
t->add_web_seed(location, web_seed_entry::http_seed);
|
||||
t->remove_web_seed(this, errors::redirecting, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::redirecting, op_bittorrent, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -345,14 +345,14 @@ namespace libtorrent
|
|||
{
|
||||
received_bytes(0, int(bytes_transferred));
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(this, errors::no_content_length, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::no_content_length, op_bittorrent, 2);
|
||||
return;
|
||||
}
|
||||
if (m_response_left != front_request.length)
|
||||
{
|
||||
received_bytes(0, int(bytes_transferred));
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(this, errors::invalid_range, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::invalid_range, op_bittorrent, 2);
|
||||
return;
|
||||
}
|
||||
m_body_start = m_parser.body_start();
|
||||
|
|
|
@ -71,14 +71,6 @@ void dump_call_profile()
|
|||
#endif
|
||||
}
|
||||
|
||||
void fun_wrap(bool& done, std::condition_variable& e, std::mutex& m, boost::function<void(void)> f)
|
||||
{
|
||||
f();
|
||||
std::unique_lock<std::mutex> l(m);
|
||||
done = true;
|
||||
e.notify_all();
|
||||
}
|
||||
|
||||
void torrent_wait(bool& done, aux::session_impl& ses)
|
||||
{
|
||||
blocking_call();
|
||||
|
@ -86,15 +78,4 @@ void torrent_wait(bool& done, aux::session_impl& ses)
|
|||
while (!done) { ses.cond.wait(l); };
|
||||
}
|
||||
|
||||
void sync_call(aux::session_impl& ses, boost::function<void(void)> f)
|
||||
{
|
||||
bool done = false;
|
||||
ses.get_io_service().dispatch(boost::bind(&fun_wrap
|
||||
, boost::ref(done)
|
||||
, boost::ref(ses.cond)
|
||||
, boost::ref(ses.mut)
|
||||
, f));
|
||||
torrent_wait(done, ses);
|
||||
}
|
||||
|
||||
} } // namespace aux namespace libtorrent
|
||||
|
|
|
@ -36,74 +36,67 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/torrent.hpp"
|
||||
#include "libtorrent/lazy_entry.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
#include "libtorrent/read_resume_data.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-macros"
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-macros"
|
||||
#endif
|
||||
|
||||
#define TORRENT_ASYNC_CALL(x) \
|
||||
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl))
|
||||
|
||||
#define TORRENT_ASYNC_CALL1(x, a1) \
|
||||
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl, a1))
|
||||
|
||||
#define TORRENT_ASYNC_CALL2(x, a1, a2) \
|
||||
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl, a1, a2))
|
||||
|
||||
#define TORRENT_ASYNC_CALL3(x, a1, a2, a3) \
|
||||
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl, a1, a2, a3))
|
||||
|
||||
#define TORRENT_SYNC_CALL(x) \
|
||||
aux::sync_call(*m_impl, boost::function<void(void)>(boost::bind(&session_impl:: x, m_impl)))
|
||||
|
||||
#define TORRENT_SYNC_CALL1(x, a1) \
|
||||
aux::sync_call(*m_impl, boost::function<void(void)>(boost::bind(&session_impl:: x, m_impl, a1)))
|
||||
|
||||
#define TORRENT_SYNC_CALL2(x, a1, a2) \
|
||||
aux::sync_call(*m_impl, boost::function<void(void)>(boost::bind(&session_impl:: x, m_impl, a1, a2)))
|
||||
|
||||
#define TORRENT_SYNC_CALL3(x, a1, a2, a3) \
|
||||
aux::sync_call(*m_impl, boost::function<void(void)>(boost::bind(&session_impl:: x, m_impl, a1, a2, a3)))
|
||||
|
||||
#define TORRENT_SYNC_CALL4(x, a1, a2, a3, a4) \
|
||||
aux::sync_call(*m_impl, boost::function<void(void)>(boost::bind(&session_impl:: x, m_impl, a1, a2, a3, a4)))
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET(type, x) \
|
||||
aux::sync_call_ret<type>(*m_impl, boost::function<type(void)>(boost::bind(&session_impl:: x, m_impl)))
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET1(type, x, a1) \
|
||||
aux::sync_call_ret<type>(*m_impl, boost::function<type(void)>(boost::bind(&session_impl:: x, m_impl, a1)))
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET2(type, x, a1, a2) \
|
||||
aux::sync_call_ret<type>(*m_impl, boost::function<type(void)>(boost::bind(&session_impl:: x, m_impl, a1, a2)))
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET3(type, x, a1, a2, a3) \
|
||||
aux::sync_call_ret<type>(*m_impl, boost::function<type(void)>(boost::bind(&session_impl:: x, m_impl, a1, a2, a3)))
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
using libtorrent::aux::session_impl;
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
template <typename Fun, typename... Args>
|
||||
void session_handle::async_call(Fun f, Args&&... a) const
|
||||
{
|
||||
m_impl->get_io_service().dispatch([=]() mutable
|
||||
{ (m_impl->*f)(a...); });
|
||||
}
|
||||
|
||||
template<typename Fun, typename... Args>
|
||||
void session_handle::sync_call(Fun f, Args&&... a) const
|
||||
{
|
||||
// this is the flag to indicate the call has completed
|
||||
// capture them by pointer to allow everything to be captured by value
|
||||
// and simplify the capture expression
|
||||
bool done = false;
|
||||
|
||||
m_impl->get_io_service().dispatch([=,&done]() mutable
|
||||
{
|
||||
(m_impl->*f)(a...);
|
||||
std::unique_lock<std::mutex> l(m_impl->mut);
|
||||
done = true;
|
||||
m_impl->cond.notify_all();
|
||||
});
|
||||
|
||||
aux::torrent_wait(done, *m_impl);
|
||||
}
|
||||
|
||||
template<typename Ret, typename Fun, typename... Args>
|
||||
Ret session_handle::sync_call_ret(Fun f, Args&&... a) const
|
||||
{
|
||||
// this is the flag to indicate the call has completed
|
||||
// capture them by pointer to allow everything to be captured by value
|
||||
// and simplify the capture expression
|
||||
bool done = false;
|
||||
Ret r;
|
||||
m_impl->get_io_service().dispatch([=,&r,&done]() mutable
|
||||
{
|
||||
r = (m_impl->*f)(a...);
|
||||
std::unique_lock<std::mutex> l(m_impl->mut);
|
||||
done = true;
|
||||
m_impl->cond.notify_all();
|
||||
});
|
||||
|
||||
aux::torrent_wait(done, *m_impl);
|
||||
return r;
|
||||
}
|
||||
|
||||
void session_handle::save_state(entry& e, boost::uint32_t flags) const
|
||||
{
|
||||
TORRENT_SYNC_CALL2(save_state, &e, flags);
|
||||
entry* ep = &e;
|
||||
sync_call(&session_impl::save_state, ep, flags);
|
||||
}
|
||||
|
||||
void session_handle::load_state(bdecode_node const& e
|
||||
|
@ -111,35 +104,36 @@ namespace libtorrent
|
|||
{
|
||||
// this needs to be synchronized since the lifespan
|
||||
// of e is tied to the caller
|
||||
TORRENT_SYNC_CALL2(load_state, &e, flags);
|
||||
sync_call(&session_impl::load_state, &e, flags);
|
||||
}
|
||||
|
||||
void session_handle::get_torrent_status(std::vector<torrent_status>* ret
|
||||
, boost::function<bool(torrent_status const&)> const& pred
|
||||
, boost::uint32_t flags) const
|
||||
{
|
||||
TORRENT_SYNC_CALL3(get_torrent_status, ret, boost::ref(pred), flags);
|
||||
auto predr = std::ref(pred);
|
||||
sync_call(&session_impl::get_torrent_status, ret, predr, flags);
|
||||
}
|
||||
|
||||
void session_handle::refresh_torrent_status(std::vector<torrent_status>* ret
|
||||
, boost::uint32_t flags) const
|
||||
{
|
||||
TORRENT_SYNC_CALL2(refresh_torrent_status, ret, flags);
|
||||
sync_call(&session_impl::refresh_torrent_status, ret, flags);
|
||||
}
|
||||
|
||||
void session_handle::post_torrent_updates(boost::uint32_t flags)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(post_torrent_updates, flags);
|
||||
async_call(&session_impl::post_torrent_updates, flags);
|
||||
}
|
||||
|
||||
void session_handle::post_session_stats()
|
||||
{
|
||||
TORRENT_ASYNC_CALL(post_session_stats);
|
||||
async_call(&session_impl::post_session_stats);
|
||||
}
|
||||
|
||||
void session_handle::post_dht_stats()
|
||||
{
|
||||
TORRENT_ASYNC_CALL(post_dht_stats);
|
||||
async_call(&session_impl::post_dht_stats);
|
||||
}
|
||||
|
||||
io_service& session_handle::get_io_service()
|
||||
|
@ -149,12 +143,12 @@ namespace libtorrent
|
|||
|
||||
torrent_handle session_handle::find_torrent(sha1_hash const& info_hash) const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET1(torrent_handle, find_torrent_handle, info_hash);
|
||||
return sync_call_ret<torrent_handle>(&session_impl::find_torrent_handle, info_hash);
|
||||
}
|
||||
|
||||
std::vector<torrent_handle> session_handle::get_torrents() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(std::vector<torrent_handle>, get_torrents);
|
||||
return sync_call_ret<std::vector<torrent_handle>>(&session_impl::get_torrents);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
@ -289,7 +283,8 @@ namespace libtorrent
|
|||
add_torrent_params const& p = params;
|
||||
#endif
|
||||
error_code ec;
|
||||
torrent_handle r = TORRENT_SYNC_CALL_RET2(torrent_handle, add_torrent, p, boost::ref(ec));
|
||||
auto ecr = std::ref(ec);
|
||||
torrent_handle r = sync_call_ret<torrent_handle>(&session_impl::add_torrent, p, ecr);
|
||||
if (ec) throw system_error(ec);
|
||||
return r;
|
||||
}
|
||||
|
@ -306,7 +301,8 @@ namespace libtorrent
|
|||
#else
|
||||
add_torrent_params const& p = params;
|
||||
#endif
|
||||
return TORRENT_SYNC_CALL_RET2(torrent_handle, add_torrent, p, boost::ref(ec));
|
||||
auto ecr = std::ref(ec);
|
||||
return sync_call_ret<torrent_handle>(&session_impl::add_torrent, p, ecr);
|
||||
}
|
||||
|
||||
void session_handle::async_add_torrent(add_torrent_params const& params)
|
||||
|
@ -319,7 +315,7 @@ namespace libtorrent
|
|||
handle_backwards_compatible_resume_data(*p);
|
||||
#endif
|
||||
|
||||
TORRENT_ASYNC_CALL1(async_add_torrent, p);
|
||||
async_call(&session_impl::async_add_torrent, p);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
@ -382,28 +378,28 @@ namespace libtorrent
|
|||
|
||||
void session_handle::pause()
|
||||
{
|
||||
TORRENT_ASYNC_CALL(pause);
|
||||
async_call(&session_impl::pause);
|
||||
}
|
||||
|
||||
void session_handle::resume()
|
||||
{
|
||||
TORRENT_ASYNC_CALL(resume);
|
||||
async_call(&session_impl::resume);
|
||||
}
|
||||
|
||||
bool session_handle::is_paused() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(bool, is_paused);
|
||||
return sync_call_ret<bool>(&session_impl::is_paused);
|
||||
}
|
||||
|
||||
void session_handle::set_load_function(user_load_function_t fun)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_load_function, fun);
|
||||
async_call(&session_impl::set_load_function, fun);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
session_status session_handle::status() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(session_status, status);
|
||||
return sync_call_ret<session_status>(&session_impl::status);
|
||||
}
|
||||
|
||||
void session_handle::get_cache_info(sha1_hash const& ih
|
||||
|
@ -456,7 +452,7 @@ namespace libtorrent
|
|||
void session_handle::set_dht_settings(dht_settings const& settings)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(set_dht_settings, settings);
|
||||
async_call(&session_impl::set_dht_settings, settings);
|
||||
#else
|
||||
TORRENT_UNUSED(settings);
|
||||
#endif
|
||||
|
@ -465,7 +461,7 @@ namespace libtorrent
|
|||
dht_settings session_handle::get_dht_settings() const
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
return TORRENT_SYNC_CALL_RET(dht_settings, get_dht_settings);
|
||||
return sync_call_ret<dht_settings>(&session_impl::get_dht_settings);
|
||||
#else
|
||||
return dht_settings();
|
||||
#endif
|
||||
|
@ -474,7 +470,7 @@ namespace libtorrent
|
|||
bool session_handle::is_dht_running() const
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
return TORRENT_SYNC_CALL_RET(bool, is_dht_running);
|
||||
return sync_call_ret<bool>(&session_impl::is_dht_running);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -483,7 +479,7 @@ namespace libtorrent
|
|||
void session_handle::set_dht_storage(dht::dht_storage_constructor_type sc)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(set_dht_storage, sc);
|
||||
async_call(&session_impl::set_dht_storage, sc);
|
||||
#else
|
||||
TORRENT_UNUSED(sc);
|
||||
#endif
|
||||
|
@ -492,7 +488,7 @@ namespace libtorrent
|
|||
void session_handle::add_dht_node(std::pair<std::string, int> const& node)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(add_dht_node_name, node);
|
||||
async_call(&session_impl::add_dht_node_name, node);
|
||||
#else
|
||||
TORRENT_UNUSED(node);
|
||||
#endif
|
||||
|
@ -501,7 +497,7 @@ namespace libtorrent
|
|||
void session_handle::add_dht_router(std::pair<std::string, int> const& node)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(add_dht_router, node);
|
||||
async_call(&session_impl::add_dht_router, node);
|
||||
#else
|
||||
TORRENT_UNUSED(node);
|
||||
#endif
|
||||
|
@ -510,7 +506,7 @@ namespace libtorrent
|
|||
void session_handle::dht_get_item(sha1_hash const& target)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(dht_get_immutable_item, target);
|
||||
async_call(&session_impl::dht_get_immutable_item, target);
|
||||
#else
|
||||
TORRENT_UNUSED(target);
|
||||
#endif
|
||||
|
@ -520,7 +516,7 @@ namespace libtorrent
|
|||
, std::string salt)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL2(dht_get_mutable_item, key, salt);
|
||||
async_call(&session_impl::dht_get_mutable_item, key, salt);
|
||||
#else
|
||||
TORRENT_UNUSED(key);
|
||||
TORRENT_UNUSED(salt);
|
||||
|
@ -534,7 +530,7 @@ namespace libtorrent
|
|||
sha1_hash ret = hasher(&buf[0], int(buf.size())).final();
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL2(dht_put_immutable_item, data, ret);
|
||||
async_call(&session_impl::dht_put_immutable_item, data, ret);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -545,7 +541,7 @@ namespace libtorrent
|
|||
, std::string salt)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL3(dht_put_mutable_item, key, cb, salt);
|
||||
async_call(&session_impl::dht_put_mutable_item, key, cb, salt);
|
||||
#else
|
||||
TORRENT_UNUSED(key);
|
||||
TORRENT_UNUSED(cb);
|
||||
|
@ -556,7 +552,7 @@ namespace libtorrent
|
|||
void session_handle::dht_get_peers(sha1_hash const& info_hash)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(dht_get_peers, info_hash);
|
||||
async_call(&session_impl::dht_get_peers, info_hash);
|
||||
#else
|
||||
TORRENT_UNUSED(info_hash);
|
||||
#endif
|
||||
|
@ -565,7 +561,7 @@ namespace libtorrent
|
|||
void session_handle::dht_announce(sha1_hash const& info_hash, int port, int flags)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL3(dht_announce, info_hash, port, flags);
|
||||
async_call(&session_impl::dht_announce, info_hash, port, flags);
|
||||
#else
|
||||
TORRENT_UNUSED(info_hash);
|
||||
TORRENT_UNUSED(port);
|
||||
|
@ -576,7 +572,8 @@ namespace libtorrent
|
|||
void session_handle::dht_direct_request(udp::endpoint ep, entry const& e, void* userdata)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL3(dht_direct_request, ep, e, userdata);
|
||||
entry copy = e;
|
||||
async_call(&session_impl::dht_direct_request, ep, copy, userdata);
|
||||
#else
|
||||
TORRENT_UNUSED(ep);
|
||||
TORRENT_UNUSED(e);
|
||||
|
@ -588,7 +585,7 @@ namespace libtorrent
|
|||
entry session_handle::dht_state() const
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
return TORRENT_SYNC_CALL_RET(entry, dht_state);
|
||||
return sync_call_ret<entry>(&session_impl::dht_state);
|
||||
#else
|
||||
return entry();
|
||||
#endif
|
||||
|
@ -597,7 +594,7 @@ namespace libtorrent
|
|||
void session_handle::start_dht(entry const& startup_state)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL1(start_dht_deprecated, startup_state);
|
||||
async_call(&session_impl::start_dht_deprecated, startup_state);
|
||||
#else
|
||||
TORRENT_UNUSED(startup_state);
|
||||
#endif
|
||||
|
@ -607,7 +604,7 @@ namespace libtorrent
|
|||
void session_handle::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> ext)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
TORRENT_ASYNC_CALL1(add_extension, ext);
|
||||
async_call(&session_impl::add_extension, ext);
|
||||
#else
|
||||
TORRENT_UNUSED(ext);
|
||||
#endif
|
||||
|
@ -616,7 +613,7 @@ namespace libtorrent
|
|||
void session_handle::add_extension(boost::shared_ptr<plugin> ext)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
TORRENT_ASYNC_CALL1(add_ses_extension, ext);
|
||||
async_call(&session_impl::add_ses_extension, ext);
|
||||
#else
|
||||
TORRENT_UNUSED(ext);
|
||||
#endif
|
||||
|
@ -651,13 +648,14 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (ret != 0) throw system_error(ec);
|
||||
#endif
|
||||
TORRENT_SYNC_CALL2(load_state, &e, flags);
|
||||
sync_call(&session_impl::load_state, &e, flags);
|
||||
}
|
||||
|
||||
entry session_handle::state() const
|
||||
{
|
||||
entry ret;
|
||||
TORRENT_SYNC_CALL2(save_state, &ret, 0xffffffff);
|
||||
auto retp = &ret;
|
||||
sync_call(&session_impl::save_state, retp, 0xffffffff);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -677,24 +675,24 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (ret != 0) throw system_error(ec);
|
||||
#endif
|
||||
TORRENT_SYNC_CALL2(load_state, &e, flags);
|
||||
sync_call(&session_impl::load_state, &e, flags);
|
||||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
||||
void session_handle::set_ip_filter(ip_filter const& f)
|
||||
{
|
||||
boost::shared_ptr<ip_filter> copy = boost::make_shared<ip_filter>(f);
|
||||
TORRENT_ASYNC_CALL1(set_ip_filter, copy);
|
||||
async_call(&session_impl::set_ip_filter, copy);
|
||||
}
|
||||
|
||||
ip_filter session_handle::get_ip_filter() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(ip_filter, get_ip_filter);
|
||||
return sync_call_ret<ip_filter>(&session_impl::get_ip_filter);
|
||||
}
|
||||
|
||||
void session_handle::set_port_filter(port_filter const& f)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_port_filter, f);
|
||||
async_call(&session_impl::set_port_filter, f);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
@ -708,57 +706,57 @@ namespace libtorrent
|
|||
|
||||
peer_id session_handle::id() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(peer_id, get_peer_id);
|
||||
return sync_call_ret<peer_id>(&session_impl::get_peer_id);
|
||||
}
|
||||
|
||||
void session_handle::set_key(int key)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_key, key);
|
||||
async_call(&session_impl::set_key, key);
|
||||
}
|
||||
|
||||
unsigned short session_handle::listen_port() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(unsigned short, listen_port);
|
||||
return sync_call_ret<unsigned short>(&session_impl::listen_port);
|
||||
}
|
||||
|
||||
unsigned short session_handle::ssl_listen_port() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(unsigned short, ssl_listen_port);
|
||||
return sync_call_ret<unsigned short>(&session_impl::ssl_listen_port);
|
||||
}
|
||||
|
||||
bool session_handle::is_listening() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(bool, is_listening);
|
||||
return sync_call_ret<bool>(&session_impl::is_listening);
|
||||
}
|
||||
|
||||
void session_handle::set_peer_class_filter(ip_filter const& f)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_peer_class_filter, f);
|
||||
async_call(&session_impl::set_peer_class_filter, f);
|
||||
}
|
||||
|
||||
void session_handle::set_peer_class_type_filter(peer_class_type_filter const& f)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_peer_class_type_filter, f);
|
||||
async_call(&session_impl::set_peer_class_type_filter, f);
|
||||
}
|
||||
|
||||
int session_handle::create_peer_class(char const* name)
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET1(int, create_peer_class, name);
|
||||
return sync_call_ret<int>(&session_impl::create_peer_class, name);
|
||||
}
|
||||
|
||||
void session_handle::delete_peer_class(int cid)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(delete_peer_class, cid);
|
||||
async_call(&session_impl::delete_peer_class, cid);
|
||||
}
|
||||
|
||||
peer_class_info session_handle::get_peer_class(int cid)
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET1(peer_class_info, get_peer_class, cid);
|
||||
return sync_call_ret<peer_class_info>(&session_impl::get_peer_class, cid);
|
||||
}
|
||||
|
||||
void session_handle::set_peer_class(int cid, peer_class_info const& pci)
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(set_peer_class, cid, pci);
|
||||
async_call(&session_impl::set_peer_class, cid, pci);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
@ -797,18 +795,18 @@ namespace libtorrent
|
|||
#else
|
||||
throw_invalid_handle();
|
||||
#endif
|
||||
TORRENT_ASYNC_CALL2(remove_torrent, h, options);
|
||||
async_call(&session_impl::remove_torrent, h, options);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void session_handle::set_settings(session_settings const& s)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_settings, s);
|
||||
async_call(&session_impl::set_settings, s);
|
||||
}
|
||||
|
||||
session_settings session_handle::settings() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(session_settings, deprecated_settings);
|
||||
return sync_call_ret<session_settings>(&session_impl::deprecated_settings);
|
||||
}
|
||||
|
||||
void session_handle::set_pe_settings(pe_settings const& r)
|
||||
|
@ -848,12 +846,12 @@ namespace libtorrent
|
|||
<= settings_pack::pe_both);
|
||||
|
||||
boost::shared_ptr<settings_pack> copy = boost::make_shared<settings_pack>(s);
|
||||
TORRENT_ASYNC_CALL1(apply_settings_pack, copy);
|
||||
async_call(&session_impl::apply_settings_pack, copy);
|
||||
}
|
||||
|
||||
settings_pack session_handle::get_settings() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(settings_pack, get_settings);
|
||||
return sync_call_ret<settings_pack>(&session_impl::get_settings);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
@ -897,12 +895,12 @@ namespace libtorrent
|
|||
|
||||
int session_handle::num_uploads() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, num_uploads);
|
||||
return sync_call_ret<int>(&session_impl::num_uploads);
|
||||
}
|
||||
|
||||
int session_handle::num_connections() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, num_connections);
|
||||
return sync_call_ret<int>(&session_impl::num_connections);
|
||||
}
|
||||
|
||||
void session_handle::set_peer_proxy(proxy_settings const& s)
|
||||
|
@ -947,66 +945,66 @@ namespace libtorrent
|
|||
|
||||
int session_handle::upload_rate_limit() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, upload_rate_limit);
|
||||
return sync_call_ret<int>(&session_impl::upload_rate_limit_depr);
|
||||
}
|
||||
|
||||
int session_handle::download_rate_limit() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, download_rate_limit);
|
||||
return sync_call_ret<int>(&session_impl::download_rate_limit_depr);
|
||||
}
|
||||
|
||||
int session_handle::local_upload_rate_limit() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, local_upload_rate_limit);
|
||||
return sync_call_ret<int>(&session_impl::local_upload_rate_limit);
|
||||
}
|
||||
|
||||
int session_handle::local_download_rate_limit() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, local_download_rate_limit);
|
||||
return sync_call_ret<int>(&session_impl::local_download_rate_limit);
|
||||
}
|
||||
|
||||
int session_handle::max_half_open_connections() const { return 8; }
|
||||
|
||||
void session_handle::set_local_upload_rate_limit(int bytes_per_second)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_local_upload_rate_limit, bytes_per_second);
|
||||
async_call(&session_impl::set_local_upload_rate_limit, bytes_per_second);
|
||||
}
|
||||
|
||||
void session_handle::set_local_download_rate_limit(int bytes_per_second)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_local_download_rate_limit, bytes_per_second);
|
||||
async_call(&session_impl::set_local_download_rate_limit, bytes_per_second);
|
||||
}
|
||||
|
||||
void session_handle::set_upload_rate_limit(int bytes_per_second)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_upload_rate_limit, bytes_per_second);
|
||||
async_call(&session_impl::set_upload_rate_limit_depr, bytes_per_second);
|
||||
}
|
||||
|
||||
void session_handle::set_download_rate_limit(int bytes_per_second)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_download_rate_limit, bytes_per_second);
|
||||
async_call(&session_impl::set_download_rate_limit_depr, bytes_per_second);
|
||||
}
|
||||
|
||||
void session_handle::set_max_connections(int limit)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_max_connections, limit);
|
||||
async_call(&session_impl::set_max_connections, limit);
|
||||
}
|
||||
|
||||
void session_handle::set_max_uploads(int limit)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_max_uploads, limit);
|
||||
async_call(&session_impl::set_max_uploads, limit);
|
||||
}
|
||||
|
||||
void session_handle::set_max_half_open_connections(int) {}
|
||||
|
||||
int session_handle::max_uploads() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, max_uploads);
|
||||
return sync_call_ret<int>(&session_impl::max_uploads);
|
||||
}
|
||||
|
||||
int session_handle::max_connections() const
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET(int, max_connections);
|
||||
return sync_call_ret<int>(&session_impl::max_connections);
|
||||
}
|
||||
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
@ -1051,7 +1049,7 @@ namespace libtorrent
|
|||
|
||||
size_t session_handle::set_alert_queue_size_limit(size_t queue_size_limit_)
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET1(size_t, set_alert_queue_size_limit, queue_size_limit_);
|
||||
return sync_call_ret<size_t>(&session_impl::set_alert_queue_size_limit, queue_size_limit_);
|
||||
}
|
||||
|
||||
void session_handle::set_alert_mask(boost::uint32_t m)
|
||||
|
@ -1111,12 +1109,12 @@ namespace libtorrent
|
|||
|
||||
int session_handle::add_port_mapping(session::protocol_type t, int external_port, int local_port)
|
||||
{
|
||||
return TORRENT_SYNC_CALL_RET3(int, add_port_mapping, int(t), external_port, local_port);
|
||||
return sync_call_ret<int>(&session_impl::add_port_mapping, int(t), external_port, local_port);
|
||||
}
|
||||
|
||||
void session_handle::delete_port_mapping(int handle)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(delete_port_mapping, handle);
|
||||
async_call(&session_impl::delete_port_mapping, handle);
|
||||
}
|
||||
|
||||
} // namespace libtorrent
|
||||
|
|
|
@ -5925,14 +5925,14 @@ namespace aux {
|
|||
apply_settings_pack_impl(p);
|
||||
}
|
||||
|
||||
void session_impl::set_download_rate_limit(int bytes_per_second)
|
||||
void session_impl::set_download_rate_limit_depr(int bytes_per_second)
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_int(settings_pack::download_rate_limit, bytes_per_second);
|
||||
apply_settings_pack_impl(p);
|
||||
}
|
||||
|
||||
void session_impl::set_upload_rate_limit(int bytes_per_second)
|
||||
void session_impl::set_upload_rate_limit_depr(int bytes_per_second)
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_int(settings_pack::upload_rate_limit, bytes_per_second);
|
||||
|
@ -5963,12 +5963,12 @@ namespace aux {
|
|||
return download_rate_limit(m_local_peer_class);
|
||||
}
|
||||
|
||||
int session_impl::upload_rate_limit() const
|
||||
int session_impl::upload_rate_limit_depr() const
|
||||
{
|
||||
return upload_rate_limit(m_global_class);
|
||||
}
|
||||
|
||||
int session_impl::download_rate_limit() const
|
||||
int session_impl::download_rate_limit_depr() const
|
||||
{
|
||||
return download_rate_limit(m_global_class);
|
||||
}
|
||||
|
|
|
@ -1434,7 +1434,7 @@ namespace libtorrent
|
|||
m_extensions.erase(i);
|
||||
}
|
||||
|
||||
void torrent::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
void torrent::add_extension_fun(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata)
|
||||
{
|
||||
boost::shared_ptr<torrent_plugin> tp(ext(get_handle(), userdata));
|
||||
|
@ -4773,7 +4773,7 @@ namespace libtorrent
|
|||
m_state_subscription = false;
|
||||
}
|
||||
|
||||
void torrent::super_seeding(bool on)
|
||||
void torrent::set_super_seeding(bool on)
|
||||
{
|
||||
if (on == m_super_seeding) return;
|
||||
|
||||
|
@ -5948,7 +5948,7 @@ namespace libtorrent
|
|||
update_want_tick();
|
||||
}
|
||||
|
||||
void torrent::remove_web_seed(std::list<web_seed_t>::iterator web)
|
||||
void torrent::remove_web_seed_iter(std::list<web_seed_t>::iterator web)
|
||||
{
|
||||
if (web->resolving)
|
||||
{
|
||||
|
@ -6014,7 +6014,7 @@ namespace libtorrent
|
|||
, web->url, ec);
|
||||
}
|
||||
// never try it again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6029,7 +6029,7 @@ namespace libtorrent
|
|||
, error_code(libtorrent::errors::peer_banned, get_libtorrent_category()));
|
||||
}
|
||||
// never try it again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6044,7 +6044,7 @@ namespace libtorrent
|
|||
m_ses.alerts().emplace_alert<url_seed_alert>(get_handle(), web->url, errors::unsupported_url_protocol);
|
||||
}
|
||||
// never try it again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6056,7 +6056,7 @@ namespace libtorrent
|
|||
, errors::invalid_hostname);
|
||||
}
|
||||
// never try it again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6068,7 +6068,7 @@ namespace libtorrent
|
|||
, errors::invalid_port);
|
||||
}
|
||||
// never try it again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6080,7 +6080,7 @@ namespace libtorrent
|
|||
, web->url, errors::port_blocked);
|
||||
}
|
||||
// never try it again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6146,7 +6146,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
debug_log("removed web seed");
|
||||
#endif
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6162,7 +6162,7 @@ namespace libtorrent
|
|||
|
||||
// the name lookup failed for the http host. Don't try
|
||||
// this host again
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6189,7 +6189,7 @@ namespace libtorrent
|
|||
m_ses.alerts().emplace_alert<url_seed_alert>(get_handle()
|
||||
, web->url, ec);
|
||||
}
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6226,7 +6226,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
debug_log("removed web seed");
|
||||
#endif
|
||||
remove_web_seed(web);
|
||||
remove_web_seed_iter(web);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9146,17 +9146,10 @@ namespace libtorrent
|
|||
|
||||
// add or remove a url that will be attempted for
|
||||
// finding the file(s) in this torrent.
|
||||
void torrent::add_web_seed(std::string const& url, web_seed_entry::type_t type)
|
||||
{
|
||||
web_seed_t ent(url, type);
|
||||
// don't add duplicates
|
||||
if (std::find(m_web_seeds.begin(), m_web_seeds.end(), ent) != m_web_seeds.end()) return;
|
||||
m_web_seeds.push_back(ent);
|
||||
set_need_save_resume();
|
||||
}
|
||||
|
||||
void torrent::add_web_seed(std::string const& url, web_seed_entry::type_t type
|
||||
, std::string const& auth, web_seed_entry::headers_t const& extra_headers)
|
||||
void torrent::add_web_seed(std::string const& url
|
||||
, web_seed_entry::type_t type
|
||||
, std::string const& auth
|
||||
, web_seed_entry::headers_t const& extra_headers)
|
||||
{
|
||||
web_seed_t ent(url, type, auth, extra_headers);
|
||||
// don't add duplicates
|
||||
|
@ -10444,7 +10437,7 @@ namespace libtorrent
|
|||
, (boost::bind(&web_seed_t::url, _1)
|
||||
== url && boost::bind(&web_seed_t::type, _1) == type));
|
||||
|
||||
if (i != m_web_seeds.end()) remove_web_seed(i);
|
||||
if (i != m_web_seeds.end()) remove_web_seed_iter(i);
|
||||
}
|
||||
|
||||
void torrent::disconnect_web_seed(peer_connection* p)
|
||||
|
@ -10465,7 +10458,7 @@ namespace libtorrent
|
|||
i->peer_info.connection = 0;
|
||||
}
|
||||
|
||||
void torrent::remove_web_seed(peer_connection* p, error_code const& ec
|
||||
void torrent::remove_web_seed_conn(peer_connection* p, error_code const& ec
|
||||
, operation_t op, int error)
|
||||
{
|
||||
std::list<web_seed_t>::iterator i = std::find_if(m_web_seeds.begin()
|
||||
|
@ -10485,7 +10478,7 @@ namespace libtorrent
|
|||
peer->disconnect(ec, op, error);
|
||||
peer->set_peer_info(0);
|
||||
}
|
||||
remove_web_seed(i);
|
||||
remove_web_seed_iter(i);
|
||||
}
|
||||
|
||||
void torrent::retry_web_seed(peer_connection* p, int retry)
|
||||
|
@ -10791,7 +10784,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#if !TORRENT_NO_FPU
|
||||
void torrent::file_progress(std::vector<float>& fp)
|
||||
void torrent::file_progress_float(std::vector<float>& fp)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
if (!valid_metadata())
|
||||
|
|
|
@ -30,19 +30,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
*/
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/bt_peer_connection.hpp"
|
||||
|
@ -62,85 +54,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/peer_info.hpp" // for peer_list_entry
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-macros"
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-macros"
|
||||
#endif
|
||||
|
||||
#define TORRENT_ASYNC_CALL(x) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return; \
|
||||
session_impl& ses = static_cast<session_impl&>(t->session()); \
|
||||
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t))
|
||||
|
||||
#define TORRENT_ASYNC_CALL1(x, a1) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return; \
|
||||
session_impl& ses = static_cast<session_impl&>(t->session()); \
|
||||
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1))
|
||||
|
||||
#define TORRENT_ASYNC_CALL2(x, a1, a2) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return; \
|
||||
session_impl& ses = static_cast<session_impl&>(t->session()); \
|
||||
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1, a2))
|
||||
|
||||
#define TORRENT_ASYNC_CALL3(x, a1, a2, a3) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return; \
|
||||
session_impl& ses = static_cast<session_impl&>(t->session()); \
|
||||
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1, a2, a3))
|
||||
|
||||
#define TORRENT_ASYNC_CALL4(x, a1, a2, a3, a4) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return; \
|
||||
session_impl& ses = static_cast<session_impl&>(t->session()); \
|
||||
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1, a2, a3, a4))
|
||||
|
||||
#define TORRENT_SYNC_CALL(x) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (t) aux::sync_call_handle(t, boost::bind(&torrent:: x, t));
|
||||
|
||||
#define TORRENT_SYNC_CALL1(x, a1) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (t) aux::sync_call_handle(t, boost::bind(&torrent:: x, t, a1));
|
||||
|
||||
#define TORRENT_SYNC_CALL2(x, a1, a2) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (t) aux::sync_call_handle(t, boost::bind(&torrent:: x, t, a1, a2));
|
||||
|
||||
#define TORRENT_SYNC_CALL3(x, a1, a2, a3) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (t) aux::sync_call_handle(t, boost::bind(&torrent:: x, t, a1, a2, a3));
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET(type, def, x) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
type r = def; \
|
||||
if (t) aux::sync_call_ret_handle(t, r, boost::function<type(void)>(boost::bind(&torrent:: x, t)));
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET1(type, def, x, a1) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
type r = def; \
|
||||
if (t) aux::sync_call_ret_handle(t, r, boost::function<type(void)>(boost::bind(&torrent:: x, t, a1)));
|
||||
|
||||
#define TORRENT_SYNC_CALL_RET2(type, def, x, a1, a2) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
type r = def; \
|
||||
if (t) aux::sync_call_ret_handle(t, r, boost::function<type(void)>(boost::bind(&torrent:: x, t, a1, a2)));
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
using libtorrent::aux::session_impl;
|
||||
|
||||
namespace libtorrent
|
||||
|
@ -153,6 +66,63 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
template<typename Fun, typename... Args>
|
||||
void torrent_handle::async_call(Fun f, Args&&... a) const
|
||||
{
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
TORRENT_ASSERT_PRECOND(t);
|
||||
if (!t) return;
|
||||
session_impl& ses = static_cast<session_impl&>(t->session());
|
||||
ses.get_io_service().dispatch([=] () { (t.get()->*f)(a...); } );
|
||||
}
|
||||
|
||||
template<typename Fun, typename... Args>
|
||||
void torrent_handle::sync_call(Fun f, Args&&... a) const
|
||||
{
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
TORRENT_ASSERT_PRECOND(t);
|
||||
if (!t) return;
|
||||
session_impl& ses = static_cast<session_impl&>(t->session());
|
||||
|
||||
// this is the flag to indicate the call has completed
|
||||
bool done = false;
|
||||
|
||||
ses.get_io_service().dispatch([=,&done,&ses] ()
|
||||
{
|
||||
(t.get()->*f)(a...);
|
||||
std::unique_lock<std::mutex> l(ses.mut);
|
||||
done = true;
|
||||
ses.cond.notify_all();
|
||||
} );
|
||||
|
||||
aux::torrent_wait(done, ses);
|
||||
}
|
||||
|
||||
template<typename Ret, typename Fun, typename... Args>
|
||||
Ret torrent_handle::sync_call_ret(Ret def, Fun f, Args&&... a) const
|
||||
{
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
TORRENT_ASSERT_PRECOND(t);
|
||||
Ret r = def;
|
||||
if (!t) return r;
|
||||
session_impl& ses = static_cast<session_impl&>(t->session());
|
||||
|
||||
// this is the flag to indicate the call has completed
|
||||
bool done = false;
|
||||
|
||||
ses.get_io_service().dispatch([=,&r,&done,&ses] ()
|
||||
{
|
||||
r = (t.get()->*f)(a...);
|
||||
std::unique_lock<std::mutex> l(ses.mut);
|
||||
done = true;
|
||||
ses.cond.notify_all();
|
||||
} );
|
||||
|
||||
aux::torrent_wait(done, ses);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
sha1_hash torrent_handle::info_hash() const
|
||||
{
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
@ -163,56 +133,52 @@ namespace libtorrent
|
|||
|
||||
int torrent_handle::max_uploads() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(int, 0, max_uploads);
|
||||
return r;
|
||||
return sync_call_ret<int>(0, &torrent::max_uploads);
|
||||
}
|
||||
|
||||
void torrent_handle::set_max_uploads(int max_uploads) const
|
||||
{
|
||||
TORRENT_ASSERT_PRECOND(max_uploads >= 2 || max_uploads == -1);
|
||||
TORRENT_ASYNC_CALL2(set_max_uploads, max_uploads, true);
|
||||
async_call(&torrent::set_max_uploads, max_uploads, true);
|
||||
}
|
||||
|
||||
int torrent_handle::max_connections() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(int, 0, max_connections);
|
||||
return r;
|
||||
return sync_call_ret<int>(0, &torrent::max_connections);
|
||||
}
|
||||
|
||||
void torrent_handle::set_max_connections(int max_connections) const
|
||||
{
|
||||
TORRENT_ASSERT_PRECOND(max_connections >= 2 || max_connections == -1);
|
||||
TORRENT_ASYNC_CALL2(set_max_connections, max_connections, true);
|
||||
async_call(&torrent::set_max_connections, max_connections, true);
|
||||
}
|
||||
|
||||
void torrent_handle::set_upload_limit(int limit) const
|
||||
{
|
||||
TORRENT_ASSERT_PRECOND(limit >= -1);
|
||||
TORRENT_ASYNC_CALL1(set_upload_limit, limit);
|
||||
async_call(&torrent::set_upload_limit, limit);
|
||||
}
|
||||
|
||||
int torrent_handle::upload_limit() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(int, 0, upload_limit);
|
||||
return r;
|
||||
return sync_call_ret<int>(0, &torrent::upload_limit);
|
||||
}
|
||||
|
||||
void torrent_handle::set_download_limit(int limit) const
|
||||
{
|
||||
TORRENT_ASSERT_PRECOND(limit >= -1);
|
||||
TORRENT_ASYNC_CALL1(set_download_limit, limit);
|
||||
async_call(&torrent::set_download_limit, limit);
|
||||
}
|
||||
|
||||
int torrent_handle::download_limit() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(int, 0, download_limit);
|
||||
return r;
|
||||
return sync_call_ret<int>(0, &torrent::download_limit);
|
||||
}
|
||||
|
||||
void torrent_handle::move_storage(
|
||||
std::string const& save_path, int flags) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(move_storage, save_path, flags);
|
||||
async_call(&torrent::move_storage, save_path, flags);
|
||||
}
|
||||
|
||||
#if TORRENT_USE_WSTRING
|
||||
|
@ -222,21 +188,21 @@ namespace libtorrent
|
|||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(save_path, utf8);
|
||||
TORRENT_ASYNC_CALL2(move_storage, utf8, flags);
|
||||
async_call(&torrent::move_storage, utf8, flags);
|
||||
}
|
||||
|
||||
void torrent_handle::rename_file(int index, std::wstring const& new_name) const
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(new_name, utf8);
|
||||
TORRENT_ASYNC_CALL2(rename_file, index, utf8);
|
||||
async_call(&torrent::rename_file, index, utf8);
|
||||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
#endif // TORRENT_USE_WSTRING
|
||||
|
||||
void torrent_handle::rename_file(int index, std::string const& new_name) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(rename_file, index, new_name);
|
||||
async_call(&torrent::rename_file, index, new_name);
|
||||
}
|
||||
|
||||
void torrent_handle::add_extension(
|
||||
|
@ -244,7 +210,7 @@ namespace libtorrent
|
|||
, void* userdata)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
TORRENT_ASYNC_CALL2(add_extension, ext, userdata);
|
||||
async_call(&torrent::add_extension_fun, ext, userdata);
|
||||
#else
|
||||
TORRENT_UNUSED(ext);
|
||||
TORRENT_UNUSED(userdata);
|
||||
|
@ -253,38 +219,37 @@ namespace libtorrent
|
|||
|
||||
bool torrent_handle::set_metadata(char const* metadata, int size) const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET2(bool, false, set_metadata, metadata, size);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::set_metadata, metadata, size);
|
||||
}
|
||||
|
||||
void torrent_handle::pause(int flags) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(pause, bool(flags & graceful_pause));
|
||||
async_call(&torrent::pause, bool(flags & graceful_pause));
|
||||
}
|
||||
|
||||
void torrent_handle::stop_when_ready(bool b) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(stop_when_ready, b);
|
||||
async_call(&torrent::stop_when_ready, b);
|
||||
}
|
||||
|
||||
void torrent_handle::apply_ip_filter(bool b) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_apply_ip_filter, b);
|
||||
async_call(&torrent::set_apply_ip_filter, b);
|
||||
}
|
||||
|
||||
void torrent_handle::set_share_mode(bool b) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_share_mode, b);
|
||||
async_call(&torrent::set_share_mode, b);
|
||||
}
|
||||
|
||||
void torrent_handle::set_upload_mode(bool b) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_upload_mode, b);
|
||||
async_call(&torrent::set_upload_mode, b);
|
||||
}
|
||||
|
||||
void torrent_handle::flush_cache() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(flush_cache);
|
||||
async_call(&torrent::flush_cache);
|
||||
}
|
||||
|
||||
void torrent_handle::set_ssl_certificate(
|
||||
|
@ -294,7 +259,7 @@ namespace libtorrent
|
|||
, std::string const& passphrase)
|
||||
{
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
TORRENT_ASYNC_CALL4(set_ssl_cert, certificate, private_key, dh_params, passphrase);
|
||||
async_call(&torrent::set_ssl_cert, certificate, private_key, dh_params, passphrase);
|
||||
#else
|
||||
TORRENT_UNUSED(certificate);
|
||||
TORRENT_UNUSED(private_key);
|
||||
|
@ -309,7 +274,7 @@ namespace libtorrent
|
|||
, std::string const& dh_params)
|
||||
{
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
TORRENT_ASYNC_CALL3(set_ssl_cert_buffer, certificate, private_key, dh_params);
|
||||
async_call(&torrent::set_ssl_cert_buffer, certificate, private_key, dh_params);
|
||||
#else
|
||||
TORRENT_UNUSED(certificate);
|
||||
TORRENT_UNUSED(private_key);
|
||||
|
@ -319,149 +284,148 @@ namespace libtorrent
|
|||
|
||||
void torrent_handle::save_resume_data(int f) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(save_resume_data, f);
|
||||
async_call(&torrent::save_resume_data, f);
|
||||
}
|
||||
|
||||
bool torrent_handle::need_save_resume_data() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, need_save_resume_data);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::need_save_resume_data);
|
||||
}
|
||||
|
||||
void torrent_handle::force_recheck() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(force_recheck);
|
||||
async_call(&torrent::force_recheck);
|
||||
}
|
||||
|
||||
void torrent_handle::resume() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(resume);
|
||||
async_call(&torrent::resume);
|
||||
}
|
||||
|
||||
void torrent_handle::auto_managed(bool m) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(auto_managed, m);
|
||||
async_call(&torrent::auto_managed, m);
|
||||
}
|
||||
|
||||
void torrent_handle::set_priority(int p) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_priority, p);
|
||||
async_call(&torrent::set_priority, p);
|
||||
}
|
||||
|
||||
int torrent_handle::queue_position() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(int, -1, queue_position);
|
||||
return r;
|
||||
return sync_call_ret<int>(-1, &torrent::queue_position);
|
||||
}
|
||||
|
||||
void torrent_handle::queue_position_up() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(queue_up);
|
||||
async_call(&torrent::queue_up);
|
||||
}
|
||||
|
||||
void torrent_handle::queue_position_down() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(queue_down);
|
||||
async_call(&torrent::queue_down);
|
||||
}
|
||||
|
||||
void torrent_handle::queue_position_top() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_queue_position, 0);
|
||||
async_call(&torrent::set_queue_position, 0);
|
||||
}
|
||||
|
||||
void torrent_handle::queue_position_bottom() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_queue_position, INT_MAX);
|
||||
async_call(&torrent::set_queue_position, INT_MAX);
|
||||
}
|
||||
|
||||
void torrent_handle::clear_error() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(clear_error);
|
||||
async_call(&torrent::clear_error);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void torrent_handle::set_tracker_login(std::string const& name
|
||||
, std::string const& password) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(set_tracker_login, name, password);
|
||||
async_call(&torrent::set_tracker_login, name, password);
|
||||
}
|
||||
#endif
|
||||
|
||||
void torrent_handle::file_progress(std::vector<boost::int64_t>& progress, int flags) const
|
||||
{
|
||||
TORRENT_SYNC_CALL2(file_progress, boost::ref(progress), flags);
|
||||
sync_call(&torrent::file_progress, std::ref(progress), flags);
|
||||
}
|
||||
|
||||
torrent_status torrent_handle::status(boost::uint32_t flags) const
|
||||
{
|
||||
torrent_status st;
|
||||
TORRENT_SYNC_CALL2(status, &st, flags);
|
||||
sync_call(&torrent::status, &st, flags);
|
||||
return st;
|
||||
}
|
||||
|
||||
void torrent_handle::set_pinned(bool p) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_pinned, p);
|
||||
async_call(&torrent::set_pinned, p);
|
||||
}
|
||||
|
||||
void torrent_handle::set_sequential_download(bool sd) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(set_sequential_download, sd);
|
||||
async_call(&torrent::set_sequential_download, sd);
|
||||
}
|
||||
|
||||
void torrent_handle::piece_availability(std::vector<int>& avail) const
|
||||
{
|
||||
TORRENT_SYNC_CALL1(piece_availability, boost::ref(avail));
|
||||
auto availr = std::ref(avail);
|
||||
sync_call(&torrent::piece_availability, availr);
|
||||
}
|
||||
|
||||
void torrent_handle::piece_priority(int index, int priority) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(set_piece_priority, index, priority);
|
||||
async_call(&torrent::set_piece_priority, index, priority);
|
||||
}
|
||||
|
||||
int torrent_handle::piece_priority(int index) const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET1(int, 0, piece_priority, index);
|
||||
return r;
|
||||
return sync_call_ret<int>(0, &torrent::piece_priority, index);
|
||||
}
|
||||
|
||||
void torrent_handle::prioritize_pieces(std::vector<int> const& pieces) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(prioritize_pieces, pieces);
|
||||
async_call(&torrent::prioritize_pieces, pieces);
|
||||
}
|
||||
|
||||
void torrent_handle::prioritize_pieces(std::vector<std::pair<int, int> > const& pieces) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(prioritize_piece_list, pieces);
|
||||
async_call(&torrent::prioritize_piece_list, pieces);
|
||||
}
|
||||
|
||||
std::vector<int> torrent_handle::piece_priorities() const
|
||||
{
|
||||
std::vector<int> ret;
|
||||
TORRENT_SYNC_CALL1(piece_priorities, &ret);
|
||||
auto retp = &ret;
|
||||
sync_call(&torrent::piece_priorities, retp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void torrent_handle::file_priority(int index, int priority) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(set_file_priority, index, priority);
|
||||
async_call(&torrent::set_file_priority, index, priority);
|
||||
}
|
||||
|
||||
int torrent_handle::file_priority(int index) const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET1(int, 0, file_priority, index);
|
||||
return r;
|
||||
return sync_call_ret<int>(0, &torrent::file_priority, index);
|
||||
}
|
||||
|
||||
void torrent_handle::prioritize_files(std::vector<int> const& files) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(prioritize_files, files);
|
||||
async_call(&torrent::prioritize_files, files);
|
||||
}
|
||||
|
||||
std::vector<int> torrent_handle::file_priorities() const
|
||||
{
|
||||
std::vector<int> ret;
|
||||
TORRENT_SYNC_CALL1(file_priorities, &ret);
|
||||
auto retp = &ret;
|
||||
sync_call(&torrent::file_priorities, retp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -475,84 +439,78 @@ namespace libtorrent
|
|||
void torrent_handle::set_ratio(float) const {}
|
||||
void torrent_handle::use_interface(const char* net_interface) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(use_interface, std::string(net_interface));
|
||||
async_call(&torrent::use_interface, std::string(net_interface));
|
||||
}
|
||||
|
||||
#if !TORRENT_NO_FPU
|
||||
void torrent_handle::file_progress(std::vector<float>& progress) const
|
||||
{
|
||||
TORRENT_SYNC_CALL1(file_progress, boost::ref(progress));
|
||||
sync_call(&torrent::file_progress_float, std::ref(progress));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool torrent_handle::is_seed() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, is_seed);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::is_seed);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_finished() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, is_finished);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::is_finished);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_paused() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, is_torrent_paused);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::is_torrent_paused);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_sequential_download() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, is_sequential_download);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::is_sequential_download);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_auto_managed() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, is_auto_managed);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::is_auto_managed);
|
||||
}
|
||||
|
||||
bool torrent_handle::has_metadata() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, valid_metadata);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::valid_metadata);
|
||||
}
|
||||
|
||||
void torrent_handle::filter_piece(int index, bool filter) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(filter_piece, index, filter);
|
||||
async_call(&torrent::filter_piece, index, filter);
|
||||
}
|
||||
|
||||
void torrent_handle::filter_pieces(std::vector<bool> const& pieces) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(filter_pieces, pieces);
|
||||
async_call(&torrent::filter_pieces, pieces);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_piece_filtered(int index) const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET1(bool, false, is_piece_filtered, index);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::is_piece_filtered, index);
|
||||
}
|
||||
|
||||
std::vector<bool> torrent_handle::filtered_pieces() const
|
||||
{
|
||||
std::vector<bool> ret;
|
||||
TORRENT_SYNC_CALL1(filtered_pieces, ret);
|
||||
auto retr = std::ref(ret);
|
||||
sync_call(&torrent::filtered_pieces, retr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void torrent_handle::filter_files(std::vector<bool> const& files) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(filter_files, files);
|
||||
auto filesr= std::ref(files);
|
||||
async_call(&torrent::filter_files, filesr);
|
||||
}
|
||||
|
||||
bool torrent_handle::super_seeding() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(bool, false, super_seeding);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::super_seeding);
|
||||
}
|
||||
|
||||
// ============ end deprecation ===============
|
||||
|
@ -561,75 +519,72 @@ namespace libtorrent
|
|||
std::vector<announce_entry> torrent_handle::trackers() const
|
||||
{
|
||||
static const std::vector<announce_entry> empty;
|
||||
TORRENT_SYNC_CALL_RET(std::vector<announce_entry>, empty, trackers);
|
||||
return r;
|
||||
return sync_call_ret<std::vector<announce_entry>>(empty, &torrent::trackers);
|
||||
}
|
||||
|
||||
void torrent_handle::add_url_seed(std::string const& url) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(add_web_seed, url, web_seed_entry::url_seed);
|
||||
async_call(&torrent::add_web_seed, url, web_seed_entry::url_seed
|
||||
, std::string(), web_seed_entry::headers_t());
|
||||
}
|
||||
|
||||
void torrent_handle::remove_url_seed(std::string const& url) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(remove_web_seed, url, web_seed_entry::url_seed);
|
||||
async_call(&torrent::remove_web_seed, url, web_seed_entry::url_seed);
|
||||
}
|
||||
|
||||
std::set<std::string> torrent_handle::url_seeds() const
|
||||
{
|
||||
static const std::set<std::string> empty;
|
||||
TORRENT_SYNC_CALL_RET1(std::set<std::string>, empty, web_seeds, web_seed_entry::url_seed);
|
||||
return r;
|
||||
return sync_call_ret<std::set<std::string>>(empty, &torrent::web_seeds, web_seed_entry::url_seed);
|
||||
}
|
||||
|
||||
void torrent_handle::add_http_seed(std::string const& url) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(add_web_seed, url, web_seed_entry::http_seed);
|
||||
async_call(&torrent::add_web_seed, url, web_seed_entry::http_seed
|
||||
, std::string(), web_seed_entry::headers_t());
|
||||
}
|
||||
|
||||
void torrent_handle::remove_http_seed(std::string const& url) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(remove_web_seed, url, web_seed_entry::http_seed);
|
||||
async_call(&torrent::remove_web_seed, url, web_seed_entry::http_seed);
|
||||
}
|
||||
|
||||
std::set<std::string> torrent_handle::http_seeds() const
|
||||
{
|
||||
static const std::set<std::string> empty;
|
||||
TORRENT_SYNC_CALL_RET1(std::set<std::string>, empty, web_seeds, web_seed_entry::http_seed);
|
||||
return r;
|
||||
return sync_call_ret<std::set<std::string>>(empty, &torrent::web_seeds, web_seed_entry::http_seed);
|
||||
}
|
||||
|
||||
void torrent_handle::replace_trackers(
|
||||
std::vector<announce_entry> const& urls) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(replace_trackers, urls);
|
||||
async_call(&torrent::replace_trackers, urls);
|
||||
}
|
||||
|
||||
void torrent_handle::add_tracker(announce_entry const& url) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(add_tracker, url);
|
||||
async_call(&torrent::add_tracker, url);
|
||||
}
|
||||
|
||||
void torrent_handle::add_piece(int piece, char const* data, int flags) const
|
||||
{
|
||||
TORRENT_SYNC_CALL3(add_piece, piece, data, flags);
|
||||
sync_call(&torrent::add_piece, piece, data, flags);
|
||||
}
|
||||
|
||||
void torrent_handle::read_piece(int piece) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(read_piece, piece);
|
||||
async_call(&torrent::read_piece, piece);
|
||||
}
|
||||
|
||||
bool torrent_handle::have_piece(int piece) const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET1(bool, false, have_piece, piece);
|
||||
return r;
|
||||
return sync_call_ret<bool>(false, &torrent::have_piece, piece);
|
||||
}
|
||||
|
||||
storage_interface* torrent_handle::get_storage_impl() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(storage_interface*, 0, get_storage);
|
||||
return r;
|
||||
return sync_call_ret<storage_interface*>(nullptr, &torrent::get_storage);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_valid() const
|
||||
|
@ -639,9 +594,8 @@ namespace libtorrent
|
|||
|
||||
boost::shared_ptr<const torrent_info> torrent_handle::torrent_file() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(boost::shared_ptr<const torrent_info>
|
||||
, boost::shared_ptr<const torrent_info>(), get_torrent_copy);
|
||||
return r;
|
||||
return sync_call_ret<boost::shared_ptr<const torrent_info>>(
|
||||
boost::shared_ptr<const torrent_info>(), &torrent::get_torrent_copy);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
@ -665,34 +619,33 @@ namespace libtorrent
|
|||
entry torrent_handle::write_resume_data() const
|
||||
{
|
||||
entry ret(entry::dictionary_t);
|
||||
TORRENT_SYNC_CALL1(write_resume_data, boost::ref(ret));
|
||||
auto retr = std::ref(ret);
|
||||
sync_call(&torrent::write_resume_data, retr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string torrent_handle::save_path() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(std::string, "", save_path);
|
||||
return r;
|
||||
return sync_call_ret<std::string>("", &torrent::save_path);
|
||||
}
|
||||
|
||||
std::string torrent_handle::name() const
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET(std::string, "", name);
|
||||
return r;
|
||||
return sync_call_ret<std::string>("", &torrent::name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void torrent_handle::connect_peer(tcp::endpoint const& adr, int source, int flags) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL3(add_peer, adr, source, flags);
|
||||
async_call(&torrent::add_peer, adr, source, flags);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void torrent_handle::force_reannounce(
|
||||
boost::posix_time::time_duration duration) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(force_tracker_request, aux::time_now()
|
||||
async_call(&torrent::force_tracker_request, aux::time_now()
|
||||
+ seconds(duration.total_seconds()), -1);
|
||||
}
|
||||
#endif
|
||||
|
@ -700,13 +653,13 @@ namespace libtorrent
|
|||
void torrent_handle::force_dht_announce() const
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
TORRENT_ASYNC_CALL(dht_announce);
|
||||
async_call(&torrent::dht_announce);
|
||||
#endif
|
||||
}
|
||||
|
||||
void torrent_handle::force_reannounce(int s, int idx) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(force_tracker_request, aux::time_now() + seconds(s), idx);
|
||||
async_call(&torrent::force_tracker_request, aux::time_now() + seconds(s), idx);
|
||||
}
|
||||
|
||||
void torrent_handle::file_status(std::vector<pool_file_status>& status) const
|
||||
|
@ -721,42 +674,45 @@ namespace libtorrent
|
|||
|
||||
void torrent_handle::scrape_tracker(int idx) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL2(scrape_tracker, idx, true);
|
||||
async_call(&torrent::scrape_tracker, idx, true);
|
||||
}
|
||||
|
||||
void torrent_handle::super_seeding(bool on) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(super_seeding, on);
|
||||
async_call(&torrent::set_super_seeding, on);
|
||||
}
|
||||
|
||||
void torrent_handle::get_full_peer_list(std::vector<peer_list_entry>& v) const
|
||||
{
|
||||
TORRENT_SYNC_CALL1(get_full_peer_list, &v);
|
||||
auto vp = &v;
|
||||
sync_call(&torrent::get_full_peer_list, vp);
|
||||
}
|
||||
|
||||
void torrent_handle::get_peer_info(std::vector<peer_info>& v) const
|
||||
{
|
||||
TORRENT_SYNC_CALL1(get_peer_info, &v);
|
||||
auto vp = &v;
|
||||
sync_call(&torrent::get_peer_info, vp);
|
||||
}
|
||||
|
||||
void torrent_handle::get_download_queue(std::vector<partial_piece_info>& queue) const
|
||||
{
|
||||
TORRENT_SYNC_CALL1(get_download_queue, &queue);
|
||||
auto queuep = &queue;
|
||||
sync_call(&torrent::get_download_queue, queuep);
|
||||
}
|
||||
|
||||
void torrent_handle::set_piece_deadline(int index, int deadline, int flags) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL3(set_piece_deadline, index, deadline, flags);
|
||||
async_call(&torrent::set_piece_deadline, index, deadline, flags);
|
||||
}
|
||||
|
||||
void torrent_handle::reset_piece_deadline(int index) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(reset_piece_deadline, index);
|
||||
async_call(&torrent::reset_piece_deadline, index);
|
||||
}
|
||||
|
||||
void torrent_handle::clear_piece_deadlines() const
|
||||
{
|
||||
TORRENT_ASYNC_CALL(clear_time_critical);
|
||||
async_call(&torrent::clear_time_critical);
|
||||
}
|
||||
|
||||
boost::shared_ptr<torrent> torrent_handle::native_handle() const
|
||||
|
|
|
@ -581,7 +581,7 @@ void web_peer_connection::handle_redirect(int bytes_left)
|
|||
if (location.empty())
|
||||
{
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(this, errors::missing_location, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::missing_location, op_bittorrent, 2);
|
||||
m_web = NULL;
|
||||
TORRENT_ASSERT(is_disconnecting());
|
||||
return;
|
||||
|
@ -614,7 +614,7 @@ void web_peer_connection::handle_redirect(int bytes_left)
|
|||
size_t i = location.rfind(path);
|
||||
if (i == std::string::npos)
|
||||
{
|
||||
t->remove_web_seed(this, errors::invalid_redirection, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::invalid_redirection, op_bittorrent, 2);
|
||||
m_web = NULL;
|
||||
TORRENT_ASSERT(is_disconnecting());
|
||||
return;
|
||||
|
@ -630,7 +630,7 @@ void web_peer_connection::handle_redirect(int bytes_left)
|
|||
peer_log(peer_log_alert::info, "LOCATION", "%s", location.c_str());
|
||||
#endif
|
||||
t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers);
|
||||
t->remove_web_seed(this, errors::redirecting, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, errors::redirecting, op_bittorrent, 2);
|
||||
m_web = NULL;
|
||||
TORRENT_ASSERT(is_disconnecting());
|
||||
return;
|
||||
|
@ -763,7 +763,7 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
{
|
||||
received_bytes(0, recv_buffer.left());
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(this, ec, op_bittorrent, 2);
|
||||
t->remove_web_seed_conn(this, ec, op_bittorrent, 2);
|
||||
m_web = NULL;
|
||||
TORRENT_ASSERT(is_disconnecting());
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue