From 6afb0fd51b4ea5a12497a4899ec9c7d943d144df Mon Sep 17 00:00:00 2001 From: "pavel.pimenov" Date: Fri, 31 Mar 2017 10:39:04 +0300 Subject: [PATCH 1/5] fix m_host_resolver (for RC_1_1) --- include/libtorrent/aux_/session_impl.hpp | 4 ++-- src/session_impl.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index b028168e5..ee7ccc17b 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -773,6 +773,8 @@ namespace libtorrent // peer class for local peers peer_class_t m_local_peer_class; + resolver m_host_resolver; + tracker_manager m_tracker_manager; torrent_map m_torrents; @@ -1124,8 +1126,6 @@ namespace libtorrent // time it's called, to force the windows disk cache to be flushed deadline_timer m_close_file_timer; - resolver m_host_resolver; - // the index of the torrent that will be offered to // connect to a peer next time on_tick is called. // This implements a round robin peer connections among diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0a7d47d12..633a5edf5 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -355,6 +355,7 @@ namespace aux { , m_global_class(0) , m_tcp_peer_class(0) , m_local_peer_class(0) + , m_host_resolver(m_io_service) , m_tracker_manager(m_udp_socket, m_stats_counters, m_host_resolver , m_settings #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS @@ -408,7 +409,6 @@ namespace aux { , m_timer(m_io_service) , m_lsd_announce_timer(m_io_service) , m_close_file_timer(m_io_service) - , m_host_resolver(m_io_service) , m_next_downloading_connect_torrent(0) , m_next_finished_connect_torrent(0) , m_download_connect_attempts(0) From b06553602311f6e294fd6c0c82ba54e3d09e539e Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 2 Apr 2017 15:23:06 -0400 Subject: [PATCH 2/5] bump version number --- CMakeLists.txt | 2 +- ChangeLog | 2 ++ Jamfile | 2 +- bindings/python/setup.py | 2 +- configure.ac | 2 +- docs/building.rst | 2 +- docs/contributing.rst | 2 +- docs/dht_rss.rst | 2 +- docs/dht_sec.rst | 2 +- docs/dht_store.rst | 2 +- docs/examples.rst | 2 +- docs/features.rst | 2 +- docs/gen_reference_doc.py | 2 +- docs/hacking.rst | 2 +- docs/index.rst | 2 +- docs/manual.rst | 2 +- docs/troubleshooting.rst | 2 +- docs/tuning.rst | 2 +- docs/tutorial.rst | 2 +- docs/utp.rst | 2 +- include/libtorrent/version.hpp | 6 +++--- src/settings_pack.cpp | 2 +- 22 files changed, 25 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a307d907c..848613fd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(libtorrent) set (SOVERSION "8") -set (VERSION "1.1.2") +set (VERSION "1.1.3") set(sources web_connection_base diff --git a/ChangeLog b/ChangeLog index 942b3eab0..2b15ce583 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +1.1.3 release + * removed (broken) support for incoming connections over socks5 * restore announce_entry's timestamp fields to posix time in python binding * deprecate torrent_added_alert (in favor of add_torrent_alert) diff --git a/Jamfile b/Jamfile index efe2b91cc..9965427ac 100644 --- a/Jamfile +++ b/Jamfile @@ -58,7 +58,7 @@ else : : $(boost-include-path) ; } -VERSION = 1.1.2 ; +VERSION = 1.1.3 ; # rule for linking the correct libraries depending # on features and target-os diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 8f857e2cf..f6dcfa05f 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -133,7 +133,7 @@ else: libraries = ['torrent-rasterbar'] + flags.libraries)] setup(name = 'python-libtorrent', - version = '1.1.2', + version = '1.1.3', author = 'Arvid Norberg', author_email = 'arvid@libtorrent.org', description = 'Python bindings for libtorrent-rasterbar', diff --git a/configure.ac b/configure.ac index df2e859ff..5a9deac97 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ AC_PREREQ([2.63]) -AC_INIT([libtorrent-rasterbar],[1.1.2],[arvid@libtorrent.org], +AC_INIT([libtorrent-rasterbar],[1.1.3],[arvid@libtorrent.org], [libtorrent-rasterbar],[http://www.libtorrent.org]) AC_CONFIG_SRCDIR([src/torrent.cpp]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/docs/building.rst b/docs/building.rst index 14731cec2..6c915f625 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/contributing.rst b/docs/contributing.rst index d47f77dc5..9e4e23324 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/dht_rss.rst b/docs/dht_rss.rst index 37debbf14..b7af6f79b 100644 --- a/docs/dht_rss.rst +++ b/docs/dht_rss.rst @@ -3,7 +3,7 @@ BitTorrent extension for DHT RSS feeds ====================================== :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/dht_sec.rst b/docs/dht_sec.rst index e29fb1f90..7639c44b4 100644 --- a/docs/dht_sec.rst +++ b/docs/dht_sec.rst @@ -3,7 +3,7 @@ BitTorrent DHT security extension ================================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/dht_store.rst b/docs/dht_store.rst index a27cbc3c9..1704255a5 100644 --- a/docs/dht_store.rst +++ b/docs/dht_store.rst @@ -3,7 +3,7 @@ BitTorrent extension for arbitrary DHT store ============================================ :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/examples.rst b/docs/examples.rst index 00a644de5..d066a42d8 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -3,7 +3,7 @@ libtorrent Examples =================== :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/features.rst b/docs/features.rst index 03bb4ddc8..9a0a67707 100644 --- a/docs/features.rst +++ b/docs/features.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/gen_reference_doc.py b/docs/gen_reference_doc.py index 6b261fe4a..ea5f7cacd 100644 --- a/docs/gen_reference_doc.py +++ b/docs/gen_reference_doc.py @@ -1005,7 +1005,7 @@ for cat in categories: out.write(''' :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 `home`__ diff --git a/docs/hacking.rst b/docs/hacking.rst index 66c9c6fe1..8e48cec5d 100644 --- a/docs/hacking.rst +++ b/docs/hacking.rst @@ -3,7 +3,7 @@ libtorrent hacking ================== :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/index.rst b/docs/index.rst index 008a0a553..962dfddb1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,5 @@ :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. raw:: html diff --git a/docs/manual.rst b/docs/manual.rst index 8cca26821..722512315 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3,7 +3,7 @@ libtorrent API Documentation ============================ :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 1 diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 4dd599d91..bb851bcb4 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/tuning.rst b/docs/tuning.rst index 53b1652ac..c8dbe2eeb 100644 --- a/docs/tuning.rst +++ b/docs/tuning.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 8b6c1c5b7..6f3a5607f 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/docs/utp.rst b/docs/utp.rst index 4233a4369..3c12ab4fb 100644 --- a/docs/utp.rst +++ b/docs/utp.rst @@ -3,7 +3,7 @@ libtorrent manual ================= :Author: Arvid Norberg, arvid@libtorrent.org -:Version: 1.1.2 +:Version: 1.1.3 .. contents:: Table of contents :depth: 2 diff --git a/include/libtorrent/version.hpp b/include/libtorrent/version.hpp index 6e01fbeec..edda9e46b 100644 --- a/include/libtorrent/version.hpp +++ b/include/libtorrent/version.hpp @@ -37,14 +37,14 @@ POSSIBILITY OF SUCH DAMAGE. #define LIBTORRENT_VERSION_MAJOR 1 #define LIBTORRENT_VERSION_MINOR 1 -#define LIBTORRENT_VERSION_TINY 2 +#define LIBTORRENT_VERSION_TINY 3 // the format of this version is: MMmmtt // M = Major version, m = minor version, t = tiny version #define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTORRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY) -#define LIBTORRENT_VERSION "1.1.2.0" -#define LIBTORRENT_REVISION "6e65851" +#define LIBTORRENT_VERSION "1.1.3.0" +#define LIBTORRENT_REVISION "6afb0fd" namespace libtorrent { diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 8be2a279a..84352fc40 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -148,7 +148,7 @@ namespace libtorrent SET_NOPREV(proxy_username, "", &session_impl::update_proxy), SET_NOPREV(proxy_password, "", &session_impl::update_proxy), SET_NOPREV(i2p_hostname, "", &session_impl::update_i2p_bridge), - SET_NOPREV(peer_fingerprint, "-LT1120-", &session_impl::update_peer_fingerprint), + SET_NOPREV(peer_fingerprint, "-LT1130-", &session_impl::update_peer_fingerprint), SET_NOPREV(dht_bootstrap_nodes, "dht.libtorrent.org:25401", &session_impl::update_dht_bootstrap_nodes) }; From 91838d8a65a0800a125e2c4dea8ef3343cc0e139 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 12 Apr 2017 14:34:17 -0700 Subject: [PATCH 3/5] clean up declaration for removed function --- bindings/python/src/session.cpp | 3 +-- include/libtorrent/aux_/session_impl.hpp | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 40c374c28..bbddc7692 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -9,15 +9,14 @@ #include #include #include -#include #include #include #include -#include // for settings_map() #include #include // for sign_mutable_item #include #include +#include #ifndef TORRENT_NO_DEPRECATE #include diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index ee7ccc17b..c923dbbb5 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -155,8 +155,6 @@ namespace libtorrent struct tracker_logger; #endif - TORRENT_EXPORT std::pair settings_map(); - // this is the link between the main thread and the // thread started to run the main downloader loop struct TORRENT_EXTRA_EXPORT session_impl TORRENT_FINAL @@ -172,9 +170,6 @@ namespace libtorrent // maximum length of query names which can be registered by extensions enum { max_dht_query_length = 15 }; -#ifdef TORRENT_DEBUG -// friend class ::libtorrent::peer_connection; -#endif #if TORRENT_USE_INVARIANT_CHECKS friend class libtorrent::invariant_access; #endif From 0445ae49171cd8c4984ca2e91867c31381a2b109 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 12 Apr 2017 15:29:00 -0400 Subject: [PATCH 4/5] remove use of deprecated peer_info queued state in client.py --- bindings/python/client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bindings/python/client.py b/bindings/python/client.py index 10cd91ddb..d736fe198 100755 --- a/bindings/python/client.py +++ b/bindings/python/client.py @@ -121,8 +121,6 @@ def print_peer_info(console, peers): id = 'waiting for handshake' elif p.flags & lt.peer_info.connecting: id = 'connecting to peer' - elif p.flags & lt.peer_info.queued: - id = 'queued' else: id = p.client From e7a379551cd0b0a2589f8db8a4406d1cd28c298b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 13 Apr 2017 06:48:01 -0700 Subject: [PATCH 5/5] discourage forward declarations of libtorrent types, introduce forward declaration header (#1910) --- ChangeLog | 2 + docs/manual.rst | 16 +- docs/troubleshooting.rst | 6 +- examples/session_view.cpp | 36 ++++ examples/session_view.hpp | 36 +++- examples/torrent_view.cpp | 33 ++++ examples/torrent_view.hpp | 35 +++- include/libtorrent/Makefile.am | 1 + include/libtorrent/alert_types.hpp | 2 +- include/libtorrent/error_code.hpp | 2 +- include/libtorrent/fwd.hpp | 265 +++++++++++++++++++++++++++++ include/libtorrent/magnet_uri.hpp | 22 +-- include/libtorrent/session.hpp | 2 +- tools/gen_fwd.py | 96 +++++++++++ 14 files changed, 532 insertions(+), 22 deletions(-) create mode 100644 include/libtorrent/fwd.hpp create mode 100644 tools/gen_fwd.py diff --git a/ChangeLog b/ChangeLog index 2b15ce583..694518b00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * forward declaring libtorrent types is discouraged. a new fwd.hpp header is provided + 1.1.3 release * removed (broken) support for incoming connections over socks5 diff --git a/docs/manual.rst b/docs/manual.rst index 722512315..678e66e23 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -46,8 +46,15 @@ For a description on how to create torrent files, see create_torrent. .. _make_torrent: make_torrent.html -things to keep in mind -====================== +forward declarations +==================== + +Forward declaring types from the libtorrent namespace is discouraged as it may +break in future releases. Instead include ``libtorrent/fwd.hpp`` for forward +declarations of all public types in libtorrent. + +trouble shooting +================ A common problem developers are facing is torrents stopping without explanation. Here is a description on which conditions libtorrent will stop your torrents, @@ -73,6 +80,11 @@ from certain disk errors if the problem is resolved. If the torrent is not auto managed, you have to call set_upload_mode() to turn downloading back on again. +For a more detailed guide on how to trouble shoot performance issues, see +troubleshooting_ + +.. _troubleshooting: troubleshooting.html + network primitives ================== diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index bb851bcb4..e2682f878 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -10,9 +10,9 @@ libtorrent manual :backlinks: none The following troubleshooting chart may help in finding out why torrents fail -to download. It is not complete, please submit suggestions via mail to -arvid@libtorrent.org or to the `mailing list`_. Ideally in the form of patches -against ``docs/troubleshooting.dot``. +to download. It is not complete, please submit suggestions via pull requests at +https://github.com/arvidn/libtorrent or to the `mailing list`_. Ideally in the +form of patches against ``docs/troubleshooting.dot``. .. _`mailing list`: http://lists.sourceforge.net/lists/listinfo/libtorrent-discuss diff --git a/examples/session_view.cpp b/examples/session_view.cpp index a2011d2b4..2cfc10df6 100644 --- a/examples/session_view.cpp +++ b/examples/session_view.cpp @@ -1,8 +1,44 @@ +/* + +Copyright (c) 2003-2017, 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. + +*/ + #include "session_view.hpp" #include "print.hpp" +#include "libtorrent/session_stats.hpp" +#include "libtorrent/torrent_handle.hpp" #include // for std::max +namespace lt = libtorrent; + session_view::session_view() : m_position(0) , m_print_utp_stats(false) diff --git a/examples/session_view.hpp b/examples/session_view.hpp index 12fa29860..e7a7484fe 100644 --- a/examples/session_view.hpp +++ b/examples/session_view.hpp @@ -1,10 +1,40 @@ +/* + +Copyright (c) 2003-2017, 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 SESSION_VIEW_HPP_ #define SESSION_VIEW_HPP_ -#include "libtorrent/session_stats.hpp" #include - -namespace lt = libtorrent; +#include struct session_view { diff --git a/examples/torrent_view.cpp b/examples/torrent_view.cpp index 75c8a5d0c..4c6ebf21b 100644 --- a/examples/torrent_view.cpp +++ b/examples/torrent_view.cpp @@ -1,5 +1,38 @@ +/* + +Copyright (c) 2003-2017, 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. + +*/ + #include "torrent_view.hpp" #include "print.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/torrent_status.hpp" const int header_size = 2; diff --git a/examples/torrent_view.hpp b/examples/torrent_view.hpp index 0060b8c47..15946e081 100644 --- a/examples/torrent_view.hpp +++ b/examples/torrent_view.hpp @@ -1,3 +1,35 @@ +/* + +Copyright (c) 2003-2017, 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_VIEW_HPP_ #define TORRENT_VIEW_HPP_ @@ -5,7 +37,8 @@ #include #include -#include "libtorrent/torrent_handle.hpp" +#include "libtorrent/fwd.hpp" +#include "libtorrent/torrent_status.hpp" namespace lt = libtorrent; diff --git a/include/libtorrent/Makefile.am b/include/libtorrent/Makefile.am index 508541838..7c6d42480 100644 --- a/include/libtorrent/Makefile.am +++ b/include/libtorrent/Makefile.am @@ -51,6 +51,7 @@ nobase_include_HEADERS = \ file_pool.hpp \ file_storage.hpp \ fingerprint.hpp \ + fwd.hpp \ gzip.hpp \ hasher.hpp \ hex.hpp \ diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 93af05996..ff93750d5 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1885,7 +1885,7 @@ namespace libtorrent }; #ifndef TORRENT_NO_DEPRECATE - struct TORRENT_DEPRECATED TORRENT_EXPORT mmap_cache_alert TORRENT_FINAL : alert + struct TORRENT_DEPRECATED_EXPORT mmap_cache_alert TORRENT_FINAL : alert { mmap_cache_alert(aux::stack_allocator& alloc , error_code const& ec); diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index 8cffcc11f..fa1ac1721 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -500,7 +500,7 @@ namespace libtorrent #endif #ifndef BOOST_NO_EXCEPTIONS - struct TORRENT_EXPORT libtorrent_exception: std::exception + struct TORRENT_EXPORT libtorrent_exception : std::exception { libtorrent_exception(error_code const& s): m_error(s), m_msg(0) {} virtual const char* what() const TORRENT_EXCEPTION_THROW_SPECIFIER; diff --git a/include/libtorrent/fwd.hpp b/include/libtorrent/fwd.hpp new file mode 100644 index 000000000..b9f44ddd2 --- /dev/null +++ b/include/libtorrent/fwd.hpp @@ -0,0 +1,265 @@ +/* + +Copyright (c) 2017, 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_FWD_HPP +#define TORRENT_FWD_HPP + +#include "libtorrent/export.hpp" + +namespace libtorrent { + +// include/libtorrent/add_torrent_params.hpp +struct add_torrent_params; + +// include/libtorrent/alert.hpp +class alert; + +// include/libtorrent/alert_types.hpp +struct torrent_alert; +struct peer_alert; +struct tracker_alert; +struct torrent_removed_alert; +struct read_piece_alert; +struct file_completed_alert; +struct file_renamed_alert; +struct file_rename_failed_alert; +struct performance_alert; +struct state_changed_alert; +struct tracker_error_alert; +struct tracker_warning_alert; +struct scrape_reply_alert; +struct scrape_failed_alert; +struct tracker_reply_alert; +struct dht_reply_alert; +struct tracker_announce_alert; +struct hash_failed_alert; +struct peer_ban_alert; +struct peer_unsnubbed_alert; +struct peer_snubbed_alert; +struct peer_error_alert; +struct peer_connect_alert; +struct peer_disconnected_alert; +struct invalid_request_alert; +struct torrent_finished_alert; +struct piece_finished_alert; +struct request_dropped_alert; +struct block_timeout_alert; +struct block_finished_alert; +struct block_downloading_alert; +struct unwanted_block_alert; +struct storage_moved_alert; +struct storage_moved_failed_alert; +struct torrent_deleted_alert; +struct torrent_delete_failed_alert; +struct save_resume_data_alert; +struct save_resume_data_failed_alert; +struct torrent_paused_alert; +struct torrent_resumed_alert; +struct torrent_checked_alert; +struct url_seed_alert; +struct file_error_alert; +struct metadata_failed_alert; +struct metadata_received_alert; +struct udp_error_alert; +struct external_ip_alert; +struct listen_failed_alert; +struct listen_succeeded_alert; +struct portmap_error_alert; +struct portmap_alert; +struct portmap_log_alert; +struct fastresume_rejected_alert; +struct peer_blocked_alert; +struct dht_announce_alert; +struct dht_get_peers_alert; +struct stats_alert; +struct cache_flushed_alert; +struct anonymous_mode_alert; +struct lsd_peer_alert; +struct trackerid_alert; +struct dht_bootstrap_alert; +struct torrent_error_alert; +struct torrent_need_cert_alert; +struct incoming_connection_alert; +struct add_torrent_alert; +struct state_update_alert; +struct session_stats_alert; +struct torrent_update_alert; +struct rss_item_alert; +struct dht_error_alert; +struct dht_immutable_item_alert; +struct dht_mutable_item_alert; +struct dht_put_alert; +struct i2p_alert; +struct dht_outgoing_get_peers_alert; +struct log_alert; +struct torrent_log_alert; +struct peer_log_alert; +struct lsd_error_alert; +struct dht_lookup; +struct dht_routing_bucket; +struct dht_stats_alert; +struct incoming_request_alert; +struct dht_log_alert; +struct dht_pkt_alert; +struct dht_get_peers_reply_alert; +struct dht_direct_response_alert; +struct picker_log_alert; + +// include/libtorrent/announce_entry.hpp +struct announce_entry; + +// include/libtorrent/bdecode.hpp +struct bdecode_node; + +// include/libtorrent/bitfield.hpp +struct bitfield; + +// include/libtorrent/create_torrent.hpp +struct create_torrent; + +// include/libtorrent/disk_buffer_holder.hpp +struct disk_buffer_holder; + +// include/libtorrent/disk_io_thread.hpp +struct cache_status; + +// include/libtorrent/entry.hpp +class entry; + +// include/libtorrent/error_code.hpp +struct libtorrent_exception; +struct storage_error; + +// include/libtorrent/extensions.hpp +struct plugin; +struct torrent_plugin; +struct peer_plugin; +struct crypto_plugin; + +// include/libtorrent/file_pool.hpp +struct file_pool; + +// include/libtorrent/file_storage.hpp +struct file_slice; +class file_storage; + +// include/libtorrent/hasher.hpp +class hasher; + +// include/libtorrent/ip_filter.hpp +struct ip_filter; +class port_filter; + +// include/libtorrent/kademlia/dht_storage.hpp +struct dht_storage_counters; +struct dht_storage_interface; + +// include/libtorrent/peer_connection_handle.hpp +struct peer_connection_handle; +struct bt_peer_connection_handle; + +// include/libtorrent/peer_info.hpp +struct peer_info; +struct peer_list_entry; + +// include/libtorrent/peer_request.hpp +struct peer_request; + +// include/libtorrent/rss.hpp +struct feed_item; +struct feed_settings; +struct feed_status; +struct feed_handle; + +// include/libtorrent/session.hpp +class session_proxy; +class session; + +// include/libtorrent/session_handle.hpp +struct session_handle; + +// include/libtorrent/session_settings.hpp +struct session_settings; +struct dht_settings; +struct pe_settings; + +// include/libtorrent/session_stats.hpp +struct stats_metric; + +// include/libtorrent/session_status.hpp +struct utp_status; +struct session_status; + +// include/libtorrent/settings_pack.hpp +struct settings_pack; + +// include/libtorrent/sha1_hash.hpp +class sha1_hash; + +// include/libtorrent/storage.hpp +struct storage_interface; +class default_storage; + +// include/libtorrent/storage_defs.hpp +struct storage_params; + +// include/libtorrent/torrent_handle.hpp +struct block_info; +struct partial_piece_info; +struct torrent_handle; + +// include/libtorrent/torrent_info.hpp +struct web_seed_entry; +class torrent_info; + +// include/libtorrent/torrent_status.hpp +struct torrent_status; + +#ifndef TORRENT_NO_DEPRECATE + +// include/libtorrent/alert_types.hpp +struct torrent_added_alert; +struct mmap_cache_alert; + +// include/libtorrent/file_storage.hpp +struct file_entry; +struct internal_file_entry; + +// include/libtorrent/lazy_entry.hpp +struct pascal_string; +struct lazy_entry; + +#endif // TORRENT_NO_DEPRECATE + +} + +#endif // TORRENT_FWD_HPP diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index 9b0f7b66b..444751735 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -48,14 +48,14 @@ namespace libtorrent // // For more information about magnet links, see magnet-links_. // - std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle); - std::string TORRENT_EXPORT make_magnet_uri(torrent_info const& info); + TORRENT_EXPORT std::string make_magnet_uri(torrent_handle const& handle); + TORRENT_EXPORT std::string make_magnet_uri(torrent_info const& info); #ifndef TORRENT_NO_DEPRECATE #ifndef BOOST_NO_EXCEPTIONS // deprecated in 0.14 - TORRENT_DEPRECATED - torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri + TORRENT_DEPRECATED_EXPORT + torrent_handle add_magnet_uri(session& ses, std::string const& uri , std::string const& save_path , storage_mode_t storage_mode = storage_mode_sparse , bool paused = false @@ -63,24 +63,26 @@ namespace libtorrent , void* userdata = 0); // deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url - TORRENT_DEPRECATED - torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri + TORRENT_DEPRECATED_EXPORT + torrent_handle add_magnet_uri(session& ses, std::string const& uri , add_torrent_params const& p); #endif // deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url - TORRENT_DEPRECATED - torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri + TORRENT_DEPRECATED_EXPORT + torrent_handle add_magnet_uri(session& ses, std::string const& uri , add_torrent_params const& p, error_code& ec); #endif // This function parses out information from the magnet link and populates the // add_torrent_params object. - TORRENT_EXPORT void parse_magnet_uri(std::string const& uri, add_torrent_params& p, error_code& ec); + TORRENT_EXPORT + void parse_magnet_uri(std::string const& uri, add_torrent_params& p, error_code& ec); // internal, delete when merge in master - TORRENT_EXTRA_EXPORT void parse_magnet_uri_peers(std::string const& uri, std::vector& peers); + TORRENT_EXTRA_EXPORT + void parse_magnet_uri_peers(std::string const& uri, std::vector& peers); } #endif diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 6a0476d3a..7f6e91650 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -155,7 +155,7 @@ namespace libtorrent // the settings to be set and pass it in to ``session::apply_settings()``. // // see apply_settings(). - class TORRENT_EXPORT session: public boost::noncopyable, public session_handle + class TORRENT_EXPORT session : public boost::noncopyable, public session_handle { public: diff --git a/tools/gen_fwd.py b/tools/gen_fwd.py new file mode 100644 index 000000000..8febe76e8 --- /dev/null +++ b/tools/gen_fwd.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python + +import os +import sys + +file_header ='''/* + +Copyright (c) 2017, 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_FWD_HPP +#define TORRENT_FWD_HPP + +#include "libtorrent/export.hpp" + +namespace libtorrent { +''' + +file_footer = ''' + +} + +#endif // TORRENT_FWD_HPP +''' + +classes = os.popen('git grep TORRENT_EXPORT').read().split('\n') + +deprecated_classes = os.popen('git grep TORRENT_DEPRECATED_EXPORT').read().split('\n') + +def filter_classes(classes, keyword): + current_file = '' + ret = '' + for c in classes: + line = c.split(':', 1) + if not line[0].endswith('.hpp'): continue + # ignore the forward header itself, that's the one we're generating + if line[0].endswith('/fwd.hpp'): continue + # don't provide forward declarations of internal types + if '/aux_/' in line[0]: continue + this_file = line[0].strip() + decl = ':'.join(line[1:]).strip().split(' ') + + if decl[0].strip() not in ['struct', 'class']: continue + # TODO: support TORRENT_DEPRECATED_EXPORT + if decl[1].strip() != keyword: continue + + if this_file != current_file: + ret += '\n// ' + this_file + '\n' + current_file = this_file; + decl = decl[0] + ' ' + decl[2] + if not decl.endswith(';'): decl += ';' + ret += decl + '\n' + return ret + +os.remove('include/libtorrent/fwd.hpp') +with open('include/libtorrent/fwd.hpp', 'w+') as f: + f.write(file_header) + + f.write(filter_classes(classes, 'TORRENT_EXPORT')); + + f.write('\n#ifndef TORRENT_NO_DEPRECATE\n') + + f.write(filter_classes(deprecated_classes, 'TORRENT_DEPRECATED_EXPORT')); + + f.write('\n#endif // TORRENT_NO_DEPRECATE') + + f.write(file_footer) + +