diff --git a/Jamfile b/Jamfile index 033fa8ca5..9c88f3325 100755 --- a/Jamfile +++ b/Jamfile @@ -212,6 +212,12 @@ rule tag ( name : type ? : property-set ) feature tcmalloc : no yes : composite propagated link-incompatible ; +feature timer : auto boost absolute performance clock : composite propagated link-incompatible ; +feature.compose boost : TORRENT_USE_BOOST_DATE_TIME=1 ; +feature.compose absolute : TORRENT_USE_ABSOLUTE_TIME=1 ; +feature.compose performance : TORRENT_USE_PERFORMANCE_TIMER=1 ; +feature.compose clock : TORRENT_USE_CLOCK_GETTIME=1 ; + feature need-librt : no yes : composite propagated link-incompatible ; feature pool-allocators : on off : composite propagated link-incompatible ; diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 7d832ed59..f3cff258b 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -58,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/magnet_uri.hpp" #include "libtorrent/bitfield.hpp" #include "libtorrent/file.hpp" +#include "libtorrent/peer_info.hpp" using boost::bind; diff --git a/include/libtorrent/Makefile.am b/include/libtorrent/Makefile.am index 74d1f1f82..825069be9 100644 --- a/include/libtorrent/Makefile.am +++ b/include/libtorrent/Makefile.am @@ -5,6 +5,7 @@ GEOIP_H = GeoIP.h endif nobase_include_HEADERS = \ + add_torrent_params.hpp \ alert.hpp \ alert_types.hpp \ alloca.hpp \ diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp new file mode 100644 index 000000000..2c2fe8d09 --- /dev/null +++ b/include/libtorrent/add_torrent_params.hpp @@ -0,0 +1,83 @@ +/* + +Copyright (c) 2009, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TORRENT_ADD_TORRENT_PARAMS_HPP_INCLUDED +#define TORRENT_ADD_TORRENT_PARAMS_HPP_INCLUDED + +#include +#include +#include + +#include "libtorrent/storage_defs.hpp" +#include "libtorrent/peer_id.hpp" // sha1_hash + +namespace libtorrent +{ + struct torrent_info; + + struct add_torrent_params + { + add_torrent_params(storage_constructor_type sc = default_storage_constructor) + : tracker_url(0) + , name(0) + , resume_data(0) + , storage_mode(storage_mode_sparse) + , paused(true) + , auto_managed(true) + , duplicate_is_error(false) + , storage(sc) + , userdata(0) + , seed_mode(false) + , override_resume_data(false) + , upload_mode(false) + {} + + boost::intrusive_ptr ti; + char const* tracker_url; + sha1_hash info_hash; + char const* name; + std::string save_path; + std::vector* resume_data; + storage_mode_t storage_mode; + bool paused; + bool auto_managed; + bool duplicate_is_error; + storage_constructor_type storage; + void* userdata; + bool seed_mode; + bool override_resume_data; + bool upload_mode; + }; +} + +#endif + diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index f71314040..f4ccf48c6 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -67,7 +67,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/session_settings.hpp" #include "libtorrent/session_status.hpp" -#include "libtorrent/session.hpp" +#include "libtorrent/add_torrent_params.hpp" #include "libtorrent/stat.hpp" #include "libtorrent/file_pool.hpp" #include "libtorrent/bandwidth_manager.hpp" diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 280efce0b..1de9d8fd7 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -61,7 +61,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_id.hpp" #include "libtorrent/stat.hpp" #include "libtorrent/alert.hpp" -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/torrent.hpp" #include "libtorrent/peer_request.hpp" #include "libtorrent/piece_block_progress.hpp" diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 75790c2b8..64560d49f 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -232,6 +232,13 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #endif // determine what timer implementation we can use +// if one is already defined, don't pick one +// autmatically. This lets the user control this +// from the Jamfile +#if !defined TORRENT_USE_ABSOLUTE_TIME \ + && !defined TORRENT_USE_QUERY_PERFORMANCE_TIMER \ + && !defined TORRENT_USE_CLOCK_GETTIME \ + && !defined TORRENT_USE_BOOST_DATE_TIME #if defined(__MACH__) #define TORRENT_USE_ABSOLUTE_TIME 1 @@ -243,5 +250,7 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_USE_BOOST_DATE_TIME 1 #endif +#endif + #endif // TORRENT_CONFIG_HPP_INCLUDED diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index df50f4aea..2e50d6854 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -36,11 +36,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" #include "libtorrent/torrent_handle.hpp" -#include "libtorrent/session.hpp" +#include "libtorrent/add_torrent_params.hpp" namespace libtorrent { struct torrent_handle; + struct session; std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle); std::string TORRENT_EXPORT make_magnet_uri(torrent_info const& info); diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index e6ea52115..daf5461d4 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -66,7 +66,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_request.hpp" #include "libtorrent/piece_block_progress.hpp" #include "libtorrent/config.hpp" -#include "libtorrent/session.hpp" #include "libtorrent/bandwidth_limit.hpp" #include "libtorrent/policy.hpp" #include "libtorrent/socket_type_fwd.hpp" @@ -86,6 +85,8 @@ namespace libtorrent { class torrent; struct peer_plugin; + struct peer_info; + struct disk_io_job; namespace detail { diff --git a/include/libtorrent/peer_id.hpp b/include/libtorrent/peer_id.hpp index fc76a4866..c2010f4de 100644 --- a/include/libtorrent/peer_id.hpp +++ b/include/libtorrent/peer_id.hpp @@ -40,9 +40,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" -#include "libtorrent/escape_string.hpp" #if TORRENT_USE_IOSTREAM +#include "libtorrent/escape_string.hpp" // to_hex, from_hex #include #include #endif diff --git a/include/libtorrent/ptime.hpp b/include/libtorrent/ptime.hpp index 68842c1e8..7b75ef100 100644 --- a/include/libtorrent/ptime.hpp +++ b/include/libtorrent/ptime.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_PTIME_HPP_INCLUDED #include "libtorrent/config.hpp" +#include #if defined TORRENT_USE_BOOST_DATE_TIME @@ -89,13 +90,6 @@ namespace libtorrent inline bool operator==(ptime lhs, ptime rhs) { return lhs.time == rhs.time;} - ptime time_now_hires(); - ptime min_time(); - ptime max_time(); - - char const* time_now_string(); - std::string log_time(); - inline bool is_negative(time_duration dt) { return dt.diff < 0; } inline bool operator==(time_duration lhs, time_duration rhs) { return lhs.diff == rhs.diff; } @@ -121,6 +115,19 @@ namespace libtorrent inline ptime operator-(ptime lhs, time_duration rhs) { return ptime(lhs.time - rhs.diff); } +} + +#endif // TORRENT_USE_BOOST_DATE_TIME + +namespace libtorrent +{ + ptime time_now_hires(); + ptime min_time(); + ptime max_time(); + + char const* time_now_string(); + std::string log_time(); + namespace aux { extern TORRENT_EXPORT ptime g_current_time; @@ -129,8 +136,5 @@ namespace libtorrent inline ptime const& time_now() { return aux::g_current_time; } } -#endif // TORRENT_USE_BOOST_DATE_TIME - - #endif diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index c6e0d8752..f5e34756c 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -54,7 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/fingerprint.hpp" #include "libtorrent/disk_io_thread.hpp" #include "libtorrent/peer_id.hpp" -#include "libtorrent/alert.hpp" +#include "libtorrent/alert.hpp" // alert::error_notification +#include "libtorrent/add_torrent_params.hpp" #include "libtorrent/storage.hpp" #include @@ -150,40 +151,6 @@ namespace libtorrent boost::shared_ptr m_impl; }; - struct add_torrent_params - { - add_torrent_params(storage_constructor_type sc = default_storage_constructor) - : tracker_url(0) - , name(0) - , resume_data(0) - , storage_mode(storage_mode_sparse) - , paused(true) - , auto_managed(true) - , duplicate_is_error(false) - , storage(sc) - , userdata(0) - , seed_mode(false) - , override_resume_data(false) - , upload_mode(false) - {} - - boost::intrusive_ptr ti; - char const* tracker_url; - sha1_hash info_hash; - char const* name; - std::string save_path; - std::vector* resume_data; - storage_mode_t storage_mode; - bool paused; - bool auto_managed; - bool duplicate_is_error; - storage_constructor_type storage; - void* userdata; - bool seed_mode; - bool override_resume_data; - bool upload_mode; - }; - class TORRENT_EXPORT session: public boost::noncopyable, aux::eh_initializer { public: diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 12345093d..a9fb94d73 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -47,13 +47,14 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include "libtorrent/peer_id.hpp" -#include "libtorrent/peer_info.hpp" #include "libtorrent/piece_picker.hpp" #include "libtorrent/torrent_info.hpp" #include "libtorrent/ptime.hpp" #include "libtorrent/config.hpp" #include "libtorrent/storage.hpp" #include "libtorrent/address.hpp" +#include "libtorrent/bitfield.hpp" +#include "libtorrent/socket.hpp" // tcp::endpoint namespace libtorrent { @@ -64,6 +65,8 @@ namespace libtorrent } struct torrent_plugin; + struct peer_info; + struct peer_list_entry; #ifndef BOOST_NO_EXCEPTIONS // for compatibility with 0.14 diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index e4517383e..60f6e9a2a 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/escape_string.hpp" +#include "libtorrent/peer_info.hpp" #ifndef TORRENT_DISABLE_ENCRYPTION #include "libtorrent/pe_crypto.hpp" diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 19ece4d74..7c8f7eec1 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/version.hpp" #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/parse_url.hpp" +#include "libtorrent/peer_info.hpp" using boost::bind; using boost::shared_ptr; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 8db5a2cda..80c5ff4d0 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -52,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/peer_info.hpp" #ifdef TORRENT_DEBUG #include diff --git a/src/policy.cpp b/src/policy.cpp index 6b34952cb..ce6e3881c 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -54,6 +54,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/piece_picker.hpp" #include "libtorrent/broadcast_socket.hpp" +#include "libtorrent/peer_info.hpp" #ifdef TORRENT_DEBUG #include "libtorrent/bt_peer_connection.hpp" diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 837a18dd4..6e4e6eca1 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -86,6 +86,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/natpmp.hpp" #include "libtorrent/lsd.hpp" #include "libtorrent/instantiate_connection.hpp" +#include "libtorrent/peer_info.hpp" #ifndef TORRENT_WINDOWS #include diff --git a/src/torrent.cpp b/src/torrent.cpp index 6d0004e33..1e89841d1 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -75,6 +75,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/kademlia/dht_tracker.hpp" +#include "libtorrent/peer_info.hpp" #if TORRENT_USE_IOSTREAM #include diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index dce9600c4..74a9ad968 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/extensions.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/socket_io.hpp" +#include "libtorrent/peer_info.hpp" #include "libtorrent/extensions/ut_pex.hpp" diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index cf9f60eae..32a3b198d 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/version.hpp" #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/parse_url.hpp" +#include "libtorrent/peer_info.hpp" using boost::bind; using boost::shared_ptr; diff --git a/test/test_swarm.cpp b/test/test_swarm.cpp index a4b7a7513..836688fe3 100644 --- a/test/test_swarm.cpp +++ b/test/test_swarm.cpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/thread.hpp" +#include "libtorrent/time.hpp" #include #include "test.hpp" diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 01d2001eb..6520d1113 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" #include "libtorrent/session_settings.hpp" +#include "libtorrent/time.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/create_torrent.hpp" #include "libtorrent/alert_types.hpp" diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index dda46f39c..66f40a813 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/thread.hpp" +#include "libtorrent/time.hpp" #include #include