diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index 713fe6572..d64517104 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -214,7 +214,9 @@ void bind_torrent_info() class_ >("torrent_info", no_init) #ifndef TORRENT_NO_DEPRECATE +#ifndef BOOST_NO_EXCEPTIONS .def(init(arg("e"))) +#endif #endif .def(init((arg("info_hash"), arg("flags") = 0))) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e22fedbc7..1955766e2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,8 +4,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") # Add extra include and library search directories so examples can optionally # be built without a prior "make install" of libtorrent. -list(APPEND CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../include") -list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}/..") +list(INSERT CMAKE_INCLUDE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/../include") +list(INSERT CMAKE_LIBRARY_PATH 0 "${CMAKE_CURRENT_BINARY_DIR}/..") # Also use the generated pkg-config file prior to "make install". # In an independent project, these lines would simply not exist. diff --git a/examples/cmake/FindLibtorrentRasterbar.cmake b/examples/cmake/FindLibtorrentRasterbar.cmake index 0cab08bfe..e14c7c4ed 100644 --- a/examples/cmake/FindLibtorrentRasterbar.cmake +++ b/examples/cmake/FindLibtorrentRasterbar.cmake @@ -1,21 +1,54 @@ # - Try to find libtorrent-rasterbar +# +# If not using pkg-config, you can pre-set LibtorrentRasterbar_CUSTOM_DEFINITIONS +# for definitions unrelated to Boost's separate compilation (which are already +# decided by the LibtorrentRasterbar_USE_STATIC_LIBS variable). +# # Once done this will define # LibtorrentRasterbar_FOUND - System has libtorrent-rasterbar # LibtorrentRasterbar_INCLUDE_DIRS - The libtorrent-rasterbar include directories # LibtorrentRasterbar_LIBRARIES - The libraries needed to use libtorrent-rasterbar # LibtorrentRasterbar_DEFINITIONS - Compiler switches required for using libtorrent-rasterbar +# LibtorrentRasterbar_OPENSSL_ENABLED - libtorrent-rasterbar uses and links against OpenSSL -find_package(PkgConfig) -pkg_check_modules(PC_LIBTORRENT_RASTERBAR libtorrent-rasterbar) +find_package(PkgConfig QUIET) -if (PC_LIBTORRENT_RASTERBAR_FOUND) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBTORRENT_RASTERBAR QUIET libtorrent-rasterbar) +endif() + +if(LibtorrentRasterbar_USE_STATIC_LIBS) + set(LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) +endif() + +if(PC_LIBTORRENT_RASTERBAR_FOUND) set(LibtorrentRasterbar_DEFINITIONS ${PC_LIBTORRENT_RASTERBAR_CFLAGS}) -else () - # Without pkg-config, we can't possibly figure out the correct build flags. - # libtorrent is very picky about those. Let's take a set of defaults and - # hope that they apply. If not, you the user are on your own. - set(LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL -DTORRENT_DISABLE_GEO_IP -DTORRENT_LINKING_SHARED -DBOOST_ASIO_DYN_LINK -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_EXCEPTION_DISABLE -DBOOST_DATE_TIME_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK -DUNICODE -D_UNICODE -D_FILE_OFFSET_BITS=64) -endif () +else() + if(LibtorrentRasterbar_CUSTOM_DEFINITIONS) + set(LibtorrentRasterbar_DEFINITIONS ${LibtorrentRasterbar_CUSTOM_DEFINITIONS}) + else() + # Without pkg-config, we can't possibly figure out the correct build flags. + # libtorrent is very picky about those. Let's take a set of defaults and + # hope that they apply. If not, you the user are on your own. + set(LibtorrentRasterbar_DEFINITIONS + -DTORRENT_USE_OPENSSL + -DTORRENT_DISABLE_GEO_IP + -DBOOST_ASIO_ENABLE_CANCELIO + -DUNICODE -D_UNICODE -D_FILE_OFFSET_BITS=64) + endif() + + if(LibtorrentRasterbar_USE_STATIC_LIBS) + list(APPEND LibtorrentRasterbar_DEFINITIONS -DBOOST_ASIO_SEPARATE_COMPILATION) + else() + list(APPEND LibtorrentRasterbar_DEFINITIONS + -DTORRENT_LINKING_SHARED -DBOOST_ASIO_DYN_LINK + -DBOOST_DATE_TIME_DYN_LINK -DBOOST_THREAD_DYN_LINK + -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK) + endif() +endif() + +message(STATUS "libtorrent definitions: ${LibtorrentRasterbar_DEFINITIONS}") find_path(LibtorrentRasterbar_INCLUDE_DIR libtorrent HINTS ${PC_LIBTORRENT_RASTERBAR_INCLUDEDIR} ${PC_LIBTORRENT_RASTERBAR_INCLUDE_DIRS} @@ -24,14 +57,26 @@ find_path(LibtorrentRasterbar_INCLUDE_DIR libtorrent find_library(LibtorrentRasterbar_LIBRARY NAMES torrent-rasterbar HINTS ${PC_LIBTORRENT_RASTERBAR_LIBDIR} ${PC_LIBTORRENT_RASTERBAR_LIBRARY_DIRS}) +if(LibtorrentRasterbar_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif() + set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARY}) set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIR}) -if (NOT Boost_SYSTEM_FOUND OR NOT Boost_THREAD_FOUND OR NOT Boost_DATE_TIME_FOUND OR NOT Boost_CHRONO_FOUND) +if(NOT Boost_SYSTEM_FOUND OR NOT Boost_THREAD_FOUND OR NOT Boost_DATE_TIME_FOUND OR NOT Boost_CHRONO_FOUND) find_package(Boost REQUIRED COMPONENTS system thread date_time chrono) set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${Boost_LIBRARIES}) set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) -endif () +endif() + +list(FIND LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL LibtorrentRasterbar_ENCRYPTION_INDEX) +if(LibtorrentRasterbar_ENCRYPTION_INDEX GREATER -1) + find_package(OpenSSL REQUIRED) + set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${OPENSSL_LIBRARIES}) + set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS}) + set(LibtorrentRasterbar_OPENSSL_ENABLED ON) +endif() include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LibtorrentRasterbar_FOUND to TRUE @@ -44,4 +89,6 @@ find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG Boost_DATE_TIME_FOUND Boost_CHRONO_FOUND) -mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY) +mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY + LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES + LibtorrentRasterbar_ENCRYPTION_INDEX) diff --git a/include/libtorrent/kademlia/refresh.hpp b/include/libtorrent/kademlia/refresh.hpp index f9ed06a68..328599797 100644 --- a/include/libtorrent/kademlia/refresh.hpp +++ b/include/libtorrent/kademlia/refresh.hpp @@ -43,37 +43,24 @@ namespace libtorrent { namespace dht class routing_table; class rpc_manager; -// TODO: 3 collapse this class into the bootstrap class (or maybe the other -// way around) -class refresh : public get_peers +class bootstrap : public get_peers { public: typedef get_peers::nodes_callback done_callback; - refresh(node_impl& node, node_id target + bootstrap(node_impl& node, node_id target , done_callback const& callback); - virtual char const* name() const; -protected: - observer_ptr new_observer(void* ptr, udp::endpoint const& ep , node_id const& id); - virtual bool invoke(observer_ptr o); -}; - -class bootstrap : public refresh -{ -public: - bootstrap(node_impl& node, node_id target - , done_callback const& callback); - - virtual char const* name() const; void trim_seed_nodes(); protected: + virtual bool invoke(observer_ptr o); + virtual void done(); }; diff --git a/src/kademlia/refresh.cpp b/src/kademlia/refresh.cpp index 6c6ed94ad..ffa3aab75 100644 --- a/src/kademlia/refresh.cpp +++ b/src/kademlia/refresh.cpp @@ -44,20 +44,7 @@ namespace libtorrent { namespace dht TORRENT_DECLARE_LOG(traversal); #endif -refresh::refresh( - node_impl& node - , node_id target - , done_callback const& callback) - : get_peers(node, target, get_peers::data_callback(), callback, false) -{ -} - -char const* refresh::name() const -{ - return "refresh"; -} - -observer_ptr refresh::new_observer(void* ptr +observer_ptr bootstrap::new_observer(void* ptr , udp::endpoint const& ep, node_id const& id) { observer_ptr o(new (ptr) get_peers_observer(this, ep, id)); @@ -67,7 +54,7 @@ observer_ptr refresh::new_observer(void* ptr return o; } -bool refresh::invoke(observer_ptr o) +bool bootstrap::invoke(observer_ptr o) { entry e; e["y"] = "q"; @@ -86,7 +73,7 @@ bootstrap::bootstrap( node_impl& node , node_id target , done_callback const& callback) - : refresh(node, target, callback) + : get_peers(node, target, get_peers::data_callback(), callback, false) { } @@ -115,7 +102,7 @@ void bootstrap::done() // this will send a ping m_node.add_node((*i)->target_ep()); } - refresh::done(); + get_peers::done(); } } } // namespace libtorrent::dht