Exemple #1
0
	torrent_alert::torrent_alert(aux::stack_allocator& alloc
		, torrent_handle const& h)
		: handle(h)
		, m_alloc(alloc)
	{
		std::string name_str;
		if (h.native_handle())
		{
			m_name_idx = alloc.copy_string(h.native_handle()->name());
		}
		else if (h.is_valid())
		{
			char msg[41];
			to_hex(h.native_handle()->info_hash().data(), 20, msg);
			m_name_idx = alloc.copy_string(msg);
		}
		else
		{
			m_name_idx = alloc.copy_string("");
		}

#ifndef TORRENT_NO_DEPRECATE
		name = torrent_name();
#endif
	}
Exemple #2
0
	torrent_alert::torrent_alert(aux::stack_allocator& alloc
		, torrent_handle const& h)
		: handle(h)
		, m_alloc(alloc)
	{
		boost::shared_ptr<torrent> t = h.native_handle();
		if (t)
		{
			std::string name_str = t->name();
			if (!name_str.empty()) {
				m_name_idx = alloc.copy_string(name_str);
			}
			else
			{
				char msg[41];
				to_hex(t->info_hash().data(), 20, msg);
				m_name_idx = alloc.copy_string(msg);
			}
		}
		else
		{
			m_name_idx = alloc.copy_string("");
		}

#ifndef TORRENT_NO_DEPRECATE
		name = torrent_name();
#endif
	}
Exemple #3
0
	dht_direct_response_alert::dht_direct_response_alert(
		aux::stack_allocator& alloc, void* userdata_
		, udp::endpoint const& addr_, bdecode_node const& response)
		: userdata(userdata_), addr(addr_), m_alloc(alloc)
		, m_response_idx(alloc.copy_buffer(response.data_section().first, response.data_section().second))
		, m_response_size(response.data_section().second)
	{}
Exemple #4
0
	portmap_log_alert::portmap_log_alert(aux::stack_allocator& alloc, int t, const char* m)
		: map_type(t)
#ifndef TORRENT_NO_DEPRECATE
		, msg(m)
#endif
		, m_alloc(alloc)
		, m_log_idx(alloc.copy_string(m))
	{}
Exemple #5
0
	storage_moved_alert::storage_moved_alert(aux::stack_allocator& alloc
		, torrent_handle const& h, std::string const& p)
		: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
		, path(p)
#endif
		, m_path_idx(alloc.copy_string(p))
	{}
Exemple #6
0
	dht_pkt_alert::dht_pkt_alert(aux::stack_allocator& alloc
		, char const* buf, int size, dht_pkt_alert::direction_t d, udp::endpoint ep)
		: dir(d)
		, node(ep)
		, m_alloc(alloc)
		, m_msg_idx(alloc.copy_buffer(buf, size))
		, m_size(size)
	{}
Exemple #7
0
	tracker_alert::tracker_alert(aux::stack_allocator& alloc
		, torrent_handle const& h
		, std::string const& u)
		: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
		, url(u)
#endif
		, m_url_idx(alloc.copy_string(u))
	{}
Exemple #8
0
	picker_log_alert::picker_log_alert(aux::stack_allocator& alloc, torrent_handle const& h
		, tcp::endpoint const& ep, peer_id const& peer_id, boost::uint32_t flags
		, piece_block const* blocks, int num_blocks)
		: peer_alert(alloc, h, ep, peer_id)
		, picker_flags(flags)
		, m_array_idx(alloc.copy_buffer(reinterpret_cast<char const*>(blocks)
			, num_blocks * sizeof(piece_block)))
		, m_num_blocks(num_blocks)
	{}
Exemple #9
0
	url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
		, std::string const& u, std::string const& m)
		: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
		, url(u)
		, msg(m)
#endif
		, m_url_idx(alloc.copy_string(u))
		, m_msg_idx(alloc.copy_string(m))
	{}
Exemple #10
0
	torrent_error_alert::torrent_error_alert(
		aux::stack_allocator& alloc
		, torrent_handle const& h
		, error_code const& e, std::string const& f)
		: torrent_alert(alloc, h)
		, error(e)
#ifndef TORRENT_NO_DEPRECATE
		, error_file(f)
#endif
		, m_file_idx(alloc.copy_string(f))
	{}
Exemple #11
0
	file_renamed_alert::file_renamed_alert(aux::stack_allocator& alloc
		, torrent_handle const& h
		, std::string const& n
		, int idx)
		: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
		, name(n)
#endif
		, index(idx)
		, m_name_idx(alloc.copy_string(n))
	{}
Exemple #12
0
	trackerid_alert::trackerid_alert(
		aux::stack_allocator& alloc
		, torrent_handle const& h
		, std::string const& u
		, const std::string& id)
		: tracker_alert(alloc, h, u)
#ifndef TORRENT_NO_DEPRECATE
		, trackerid(id)
#endif
		, m_tracker_idx(alloc.copy_string(id))
	{}
Exemple #13
0
	url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
		, std::string const& u, error_code const& e)
		: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
		, url(u)
		, msg(convert_from_native(e.message()))
#endif
		, error(e)
		, m_url_idx(alloc.copy_string(u))
		, m_msg_idx(-1)
	{}
Exemple #14
0
	tracker_warning_alert::tracker_warning_alert(aux::stack_allocator& alloc
		, torrent_handle const& h
		, std::string const& u
		, std::string const& m)
		: tracker_alert(alloc, h, u)
#ifndef TORRENT_NO_DEPRECATE
		, msg(m)
#endif
		, m_msg_idx(alloc.copy_string(m))
	{
		TORRENT_ASSERT(!u.empty());
	}
Exemple #15
0
	peer_log_alert::peer_log_alert(aux::stack_allocator& alloc
		, torrent_handle const& h
		, tcp::endpoint const& i
		, peer_id const& pi
		, direction_t dir
		, char const* event
		, char const* log)
		: peer_alert(alloc, h, i, pi)
		, event_type(event)
		, direction(dir)
		, m_str_idx(alloc.copy_string(log))
	{}
Exemple #16
0
	listen_failed_alert::listen_failed_alert(
		aux::stack_allocator& alloc
		, std::string const& iface
		, tcp::endpoint const& ep
		, int op
		, error_code const& ec
		, socket_type_t t)
		: error(ec)
		, operation(op)
		, sock_type(t)
		, endpoint(ep)
		, m_alloc(alloc)
		, m_interface_idx(alloc.copy_string(iface))
	{}
Exemple #17
0
	storage_moved_failed_alert::storage_moved_failed_alert(
		aux::stack_allocator& alloc
		, torrent_handle const& h
		, error_code const& e
		, std::string const& f
		, char const* op)
		: torrent_alert(alloc, h)
		, error(e)
#ifndef TORRENT_NO_DEPRECATE
		, file(f)
#endif
		, operation(op)
		, m_file_idx(alloc.copy_string(f))
	{}
Exemple #18
0
	dht_get_peers_reply_alert::dht_get_peers_reply_alert(aux::stack_allocator& alloc
		, sha1_hash const& ih
		, std::vector<tcp::endpoint> const& peers)
		: info_hash(ih)
		, m_alloc(alloc)
		, m_num_peers(peers.size())
	{
		std::size_t total_size = m_num_peers; // num bytes for sizes
		for (int i = 0; i < m_num_peers; i++) {
			total_size += peers[i].size();
		}

		m_peers_idx = alloc.allocate(total_size);

		char *ptr = alloc.ptr(m_peers_idx);
		for (int i = 0; i < m_num_peers; i++) {
			tcp::endpoint endp = peers[i];
			std::size_t size = endp.size();

			detail::write_uint8(size, ptr);
			memcpy(ptr, endp.data(), size);
			ptr += size;
		}
	}
Exemple #19
0
	listen_failed_alert::listen_failed_alert(
		aux::stack_allocator& alloc
		, std::string iface
		, int op
		, error_code const& ec
		, socket_type_t t)
		:
#if !defined(TORRENT_NO_DEPRECATE) && !defined(TORRENT_WINRT)
			interface(iface),
#endif
		error(ec)
		, operation(op)
		, sock_type(t)
		, m_alloc(alloc)
		, m_interface_idx(alloc.copy_string(iface))
	{}
Exemple #20
0
	file_error_alert::file_error_alert(aux::stack_allocator& alloc
		, error_code const& ec
		, std::string const& f
		, char const* op
		, torrent_handle const& h)
		: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
		, file(f)
#endif
		, error(ec)
		, operation(op)
		, m_file_idx(alloc.copy_string(f))
	{
#ifndef TORRENT_NO_DEPRECATE
		msg = convert_from_native(error.message());
#endif
	}
Exemple #21
0
	tracker_error_alert::tracker_error_alert(aux::stack_allocator& alloc
		, torrent_handle const& h
		, int times
		, int status
		, std::string const& u
		, error_code const& e
		, std::string const& m)
		: tracker_alert(alloc, h, u)
		, times_in_row(times)
		, status_code(status)
		, error(e)
#ifndef TORRENT_NO_DEPRECATE
		, msg(m)
#endif
		, m_msg_idx(alloc.copy_string(m))
	{
		TORRENT_ASSERT(!u.empty());
	}
Exemple #22
0
	fastresume_rejected_alert::fastresume_rejected_alert(
		aux::stack_allocator& alloc
		, torrent_handle const& h
		, error_code const& ec
		, std::string const& file
		, char const* op)
		: torrent_alert(alloc, h)
		, error(ec)
#ifndef TORRENT_NO_DEPRECATE
		, file(file)
#endif
		, operation(op)
		, m_path_idx(alloc.copy_string(file))
	{
#ifndef TORRENT_NO_DEPRECATE
		msg = convert_from_native(error.message());
#endif
	}
Exemple #23
0
	log_alert::log_alert(aux::stack_allocator& alloc, char const* log)
		: m_alloc(alloc)
		, m_str_idx(alloc.copy_string(log))
	{}
Exemple #24
0
	dht_log_alert::dht_log_alert(aux::stack_allocator& alloc
		, dht_log_alert::dht_module_t m, const char* msg)
		: module(m)
		, m_alloc(alloc)
		, m_msg_idx(alloc.copy_string(msg))
	{}
Exemple #25
0
	torrent_log_alert::torrent_log_alert(aux::stack_allocator& alloc, torrent_handle h
		, char const* log)
		: torrent_alert(alloc, h)
		, m_str_idx(alloc.copy_string(log))
	{}