merged changes from RC_1_0

This commit is contained in:
Arvid Norberg 2014-11-20 05:53:12 +00:00
parent fddb25308b
commit 179df62379
5 changed files with 71 additions and 48 deletions

View File

@ -214,7 +214,9 @@ void bind_torrent_info()
class_<torrent_info, boost::shared_ptr<torrent_info> >("torrent_info", no_init)
#ifndef TORRENT_NO_DEPRECATE
#ifndef BOOST_NO_EXCEPTIONS
.def(init<entry const&>(arg("e")))
#endif
#endif
.def(init<sha1_hash const&, int>((arg("info_hash"), arg("flags") = 0)))

View File

@ -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.

View File

@ -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)

View File

@ -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();
};

View File

@ -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