diff --git a/Jamfile b/Jamfile index a36de0b23..778b7eab8 100755 --- a/Jamfile +++ b/Jamfile @@ -227,6 +227,9 @@ feature.compose unicode : _UNICODE UNICODE ; feature zlib : shipped system : composite propagated link-incompatible ; +feature deprecated-functions : on off : composite propagated link-incompatible ; +feature.compose off : TORRENT_NO_DEPRECATE ; + feature statistics : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_STATS ; diff --git a/docs/building.html b/docs/building.html index 19cc07b79..36dc70ab8 100644 --- a/docs/building.html +++ b/docs/building.html @@ -198,8 +198,8 @@ For more build configuration flags see - - + + boost build feature @@ -374,6 +374,17 @@ symbols. +deprecated-functions +
    +
  • on - default. Includes deprecated functions +of the API (might produce warnings during build +when deprecated functions are used).
  • +
  • off - excludes deprecated functions from the +API. Generates build errors when deprecated +functions are used.
  • +
+ +

The variant feature is implicit, which means you don't need to specify @@ -655,6 +666,10 @@ make the resulting executable faster. checks. Useful for finding particular bugs or for running before releases. +TORRENT_NO_DEPRECATE +This will exclude all deprecated functions from +the header files and cpp files. +

If you experience that libtorrent uses unreasonable amounts of cpu, it will diff --git a/docs/building.rst b/docs/building.rst index c889a6328..2537571b1 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -215,114 +215,121 @@ For more build configuration flags see `Build configurations`_. Build features: -+------------------------+----------------------------------------------------+ -| boost build feature | values | -+========================+====================================================+ -| ``boost`` | * ``system`` - default. Tells the Jamfile that | -| | boost is installed and should be linked against | -| | the system libraries. | -| | * ``source`` - Specifies that boost is to be built | -| | from source. The environment variable | -| | ``BOOST_ROOT`` must be defined to point to the | -| | boost directory. | -+------------------------+----------------------------------------------------+ -| ``boost-link`` | * ``static`` - links statically against the boost | -| | libraries. | -| | * ``shared`` - links dynamically against the boost | -| | libraries. | -+------------------------+----------------------------------------------------+ -| ``logging`` | * ``none`` - no logging. | -| | * ``default`` - basic session logging. | -| | * ``verbose`` - verbose peer wire logging. | -| | * ``errors`` - like verbose, but limited to errors.| -+------------------------+----------------------------------------------------+ -| ``dht-support`` | * ``on`` - build with support for tracker less | -| | torrents and DHT support. | -| | * ``logging`` - build with DHT support and verbose | -| | logging of the DHT protocol traffic. | -| | * ``off`` - build without DHT support. | -+------------------------+----------------------------------------------------+ -| ``need-librt`` | * ``no`` - this platform does not need to link | -| | against librt to have POSIX time functions. | -| | * ``yes`` - specify this if your linux system | -| | requires you to link against librt.a. This is | -| | typically the case on x86 64 bit systems. | -+------------------------+----------------------------------------------------+ -| ``zlib`` | * ``system`` - links against the zlib supplied | -| | with your operating system. | -| | * ``shipped`` - links against the zlib bundled | -| | with the libtorrent package. | -+------------------------+----------------------------------------------------+ -| ``geoip`` | * ``off`` - geo ip lookups disabled | -| | * ``static`` - MaxMind_ geo ip lookup code linked | -| | in statically. Note that this code is under | -| | LGPL license. | -| | * ``shared`` - The MaxMind_ geo ip lookup library | -| | is expected to be installed on the system and | -| | it will be used. | -+------------------------+----------------------------------------------------+ -| ``upnp-logging`` | * ``off`` - default. Does not log UPnP traffic. | -| | * ``on`` - creates "upnp.log" with the messages | -| | sent to and received from UPnP devices. | -+------------------------+----------------------------------------------------+ -| ``openssl`` | * ``pe`` - turns on support for encrypted | -| | connections. requires openssl (libcrypto) | -| | * ``sha-1`` - openssl will be used instead of the | -| | public domain SHA-1 implementation shipped with | -| | libtorrent. ``libcrypto.a`` will be required for | -| | linking. Encryption support is still turned off. | -| | * ``off`` - turns off support for encrypted | -| | connections. openssl is not linked in. The | -| | shipped public domain SHA-1 implementation is | -| | used. | -+------------------------+----------------------------------------------------+ -| ``pool-allocators`` | * ``on`` - default, uses pool allocators for send | -| | buffers. | -| | * ``off`` - uses ``malloc()`` and ``free()`` | -| | instead. Might be useful to debug buffer issues | -| | with tools like electric fence or libgmalloc. | -+------------------------+----------------------------------------------------+ -| ``link`` | * ``static`` - builds libtorrent as a static | -| | library (.a / .lib) | -| | * ``shared`` - builds libtorrent as a shared | -| | library (.so / .dll). | -+------------------------+----------------------------------------------------+ -| ``runtime-link`` | * ``static`` - links statically against the | -| | run-time library (if available on your | -| | platform). | -| | * ``shared`` - link dynamically against the | -| | run-time library (default). | -+------------------------+----------------------------------------------------+ -| ``variant`` | * ``debug`` - builds libtorrent with debug | -| | information and invariant checks. | -| | * ``release`` - builds libtorrent in release mode | -| | without invariant checks and with optimization. | -| | * ``profile`` - builds libtorrent with profile | -| | information. | -+------------------------+----------------------------------------------------+ -| ``character-set`` | This setting will only have an affect on windows. | -| | Other platforms are expected to support UTF-8. | -| | | -| | * ``unicode`` - The unicode version of the win32 | -| | API is used. This is default. | -| | * ``ansi`` - The ansi version of the win32 API is | -| | used. | -+------------------------+----------------------------------------------------+ -| ``invariant-checks`` | This setting only affects debug builds (where | -| | ``NDEBUG`` is not defined). It defaults to ``on``. | -| | | -| | * ``on`` - internal invariant checks are enabled. | -| | * ``off`` - internal invariant checks are | -| | disabled. The resulting executable will run | -| | faster than a regular debug build. | -| | * ``full`` - turns on extra expensive invariant | -| | checks. | -+------------------------+----------------------------------------------------+ -| ``debug-symbols`` | * ``on`` - default for debug builds. This setting | -| | is useful for building release builds with | -| | symbols. | -| | * ``off`` - default for release builds. | -+------------------------+----------------------------------------------------+ ++--------------------------+----------------------------------------------------+ +| boost build feature | values | ++==========================+====================================================+ +| ``boost`` | * ``system`` - default. Tells the Jamfile that | +| | boost is installed and should be linked against | +| | the system libraries. | +| | * ``source`` - Specifies that boost is to be built | +| | from source. The environment variable | +| | ``BOOST_ROOT`` must be defined to point to the | +| | boost directory. | ++--------------------------+----------------------------------------------------+ +| ``boost-link`` | * ``static`` - links statically against the boost | +| | libraries. | +| | * ``shared`` - links dynamically against the boost | +| | libraries. | ++--------------------------+----------------------------------------------------+ +| ``logging`` | * ``none`` - no logging. | +| | * ``default`` - basic session logging. | +| | * ``verbose`` - verbose peer wire logging. | +| | * ``errors`` - like verbose, but limited to errors.| ++--------------------------+----------------------------------------------------+ +| ``dht-support`` | * ``on`` - build with support for tracker less | +| | torrents and DHT support. | +| | * ``logging`` - build with DHT support and verbose | +| | logging of the DHT protocol traffic. | +| | * ``off`` - build without DHT support. | ++--------------------------+----------------------------------------------------+ +| ``need-librt`` | * ``no`` - this platform does not need to link | +| | against librt to have POSIX time functions. | +| | * ``yes`` - specify this if your linux system | +| | requires you to link against librt.a. This is | +| | typically the case on x86 64 bit systems. | ++--------------------------+----------------------------------------------------+ +| ``zlib`` | * ``system`` - links against the zlib supplied | +| | with your operating system. | +| | * ``shipped`` - links against the zlib bundled | +| | with the libtorrent package. | ++--------------------------+----------------------------------------------------+ +| ``geoip`` | * ``off`` - geo ip lookups disabled | +| | * ``static`` - MaxMind_ geo ip lookup code linked | +| | in statically. Note that this code is under | +| | LGPL license. | +| | * ``shared`` - The MaxMind_ geo ip lookup library | +| | is expected to be installed on the system and | +| | it will be used. | ++--------------------------+----------------------------------------------------+ +| ``upnp-logging`` | * ``off`` - default. Does not log UPnP traffic. | +| | * ``on`` - creates "upnp.log" with the messages | +| | sent to and received from UPnP devices. | ++--------------------------+----------------------------------------------------+ +| ``openssl`` | * ``pe`` - turns on support for encrypted | +| | connections. requires openssl (libcrypto) | +| | * ``sha-1`` - openssl will be used instead of the | +| | public domain SHA-1 implementation shipped with | +| | libtorrent. ``libcrypto.a`` will be required for | +| | linking. Encryption support is still turned off. | +| | * ``off`` - turns off support for encrypted | +| | connections. openssl is not linked in. The | +| | shipped public domain SHA-1 implementation is | +| | used. | ++--------------------------+----------------------------------------------------+ +| ``pool-allocators`` | * ``on`` - default, uses pool allocators for send | +| | buffers. | +| | * ``off`` - uses ``malloc()`` and ``free()`` | +| | instead. Might be useful to debug buffer issues | +| | with tools like electric fence or libgmalloc. | ++--------------------------+----------------------------------------------------+ +| ``link`` | * ``static`` - builds libtorrent as a static | +| | library (.a / .lib) | +| | * ``shared`` - builds libtorrent as a shared | +| | library (.so / .dll). | ++--------------------------+----------------------------------------------------+ +| ``runtime-link`` | * ``static`` - links statically against the | +| | run-time library (if available on your | +| | platform). | +| | * ``shared`` - link dynamically against the | +| | run-time library (default). | ++--------------------------+----------------------------------------------------+ +| ``variant`` | * ``debug`` - builds libtorrent with debug | +| | information and invariant checks. | +| | * ``release`` - builds libtorrent in release mode | +| | without invariant checks and with optimization. | +| | * ``profile`` - builds libtorrent with profile | +| | information. | ++--------------------------+----------------------------------------------------+ +| ``character-set`` | This setting will only have an affect on windows. | +| | Other platforms are expected to support UTF-8. | +| | | +| | * ``unicode`` - The unicode version of the win32 | +| | API is used. This is default. | +| | * ``ansi`` - The ansi version of the win32 API is | +| | used. | ++--------------------------+----------------------------------------------------+ +| ``invariant-checks`` | This setting only affects debug builds (where | +| | ``NDEBUG`` is not defined). It defaults to ``on``. | +| | | +| | * ``on`` - internal invariant checks are enabled. | +| | * ``off`` - internal invariant checks are | +| | disabled. The resulting executable will run | +| | faster than a regular debug build. | +| | * ``full`` - turns on extra expensive invariant | +| | checks. | ++--------------------------+----------------------------------------------------+ +| ``debug-symbols`` | * ``on`` - default for debug builds. This setting | +| | is useful for building release builds with | +| | symbols. | +| | * ``off`` - default for release builds. | ++--------------------------+----------------------------------------------------+ +| ``deprecated-functions`` | * ``on`` - default. Includes deprecated functions | +| | of the API (might produce warnings during build | +| | when deprecated functions are used). | +| | * ``off`` - excludes deprecated functions from the | +| | API. Generates build errors when deprecated | +| | functions are used. | ++--------------------------+----------------------------------------------------+ .. _MaxMind: http://www.maxmind.com/app/api @@ -602,6 +609,9 @@ defines you can use to control the build. | | checks. Useful for finding particular bugs | | | or for running before releases. | +----------------------------------------+-------------------------------------------------+ +| ``TORRENT_NO_DEPRECATE`` | This will exclude all deprecated functions from | +| | the header files and cpp files. | ++----------------------------------------+-------------------------------------------------+ If you experience that libtorrent uses unreasonable amounts of cpu, it will diff --git a/docs/manual.html b/docs/manual.html index fd887e7bf..5967bd01e 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -144,85 +144,88 @@

  • identify_client()
  • client_fingerprint()
  • bdecode() bencode()
  • +
  • add_magnet_uri()
  • +
  • make_magnet_uri()
  • -
  • alerts
      -
    • external_ip_alert
    • -
    • listen_failed_alert
    • -
    • portmap_error_alert
    • -
    • portmap_alert
    • -
    • file_error_alert
    • -
    • tracker_announce_alert
    • -
    • tracker_error_alert
    • -
    • tracker_reply_alert
    • -
    • dht_reply_alert
    • -
    • tracker_warning_alert
    • -
    • scrape_reply_alert
    • -
    • scrape_failed_alert
    • -
    • url_seed_alert
    • -
    • hash_failed_alert
    • -
    • peer_ban_alert
    • -
    • peer_error_alert
    • -
    • invalid_request_alert
    • -
    • torrent_finished_alert
    • -
    • metadata_failed_alert
    • -
    • metadata_received_alert
    • -
    • fastresume_rejected_alert
    • -
    • peer_blocked_alert
    • -
    • storage_moved_alert
    • -
    • torrent_paused_alert
    • -
    • torrent_resumed_alert
    • -
    • save_resume_data_alert
    • -
    • save_resume_data_failed_alert
    • -
    • dispatcher
    • +
    • alerts
    • -
    • exceptions
        -
      • invalid_handle
      • -
      • duplicate_torrent
      • -
      • invalid_encoding
      • -
      • type_error
      • -
      • invalid_torrent_file
      • +
      • exceptions
      • -
      • storage_interface
          -
        • initialize()
        • -
        • read()
        • -
        • write()
        • -
        • move_storage()
        • -
        • verify_resume_data()
        • -
        • write_resume_data()
        • -
        • move_slot()
        • -
        • swap_slots()
        • -
        • swap_slots3()
        • -
        • hash_for_slot()
        • -
        • release_files()
        • -
        • delete_files()
        • +
        • storage_interface
        • -
        • queuing
            -
          • downloading
          • -
          • seeding
          • +
          • magnet links
          • +
          • queuing
          • -
          • fast resume
              -
            • file format
            • +
            • fast resume
            • -
            • threads
            • -
            • storage allocation
                -
              • sparse allocation
              • -
              • full allocation
              • -
              • compact allocation
              • +
              • threads
              • +
              • storage allocation
              • -
              • extensions
                @@ -3633,6 +3636,32 @@ entry e = bdecode(buf, buf + data_size);

                If bdecode() encounters invalid encoded data in the range given to it it will throw invalid_encoding.

                +
                +

                add_magnet_uri()

                +
                +
                +torrent_handle add_magnet_uri(session& ses, std::string const& uri
                +        add_torrent_params p);
                +
                +
                +

                This function parses the magnet URI (uri) as a bittorrent magnet link, +and adds the torrent to the specified session (ses). It returns the +handle to the newly added torrent, or an invalid handle in case parsing +failed. To control some initial settings of the torrent, sepcify those in +the add_torrent_params, p. See add_torrent().

                +

                For more information about magnet links, see magnet links.

                +
                +
                +

                make_magnet_uri()

                +
                +
                +std::string make_magnet_uri(torrent_handle const& handle);
                +
                +
                +

                Generates a magnet URI from the specified torrent. If the torrent +handle is invalid, an empty string is returned.

                +

                For more information about magnet links, see magnet links.

                +

                alerts

                @@ -4406,6 +4435,15 @@ void delete_files() = 0;
                +

                magnet links

                +

                Magnet links are URIs that includes an info-hash, a display name and optionally +a tracker url. The idea behind magnet links is that an end user can click on a +link in a browser and have it handled by a bittorrent application, to start a +download, without any .torrent file.

                +

                The format of the magnet URI is:

                +

                magnet:?xt=urn:btih: Base32 encoded info-hash [ &dn= name of download ] [ &tr= tracker URL ]*

                +
                +

                queuing

                libtorrent supports queuing. Which means it makes sure that a limited number of torrents are being downloaded at any given time, and once a torrent is completely diff --git a/docs/manual.rst b/docs/manual.rst index 446e594e6..df48a0dd4 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3722,6 +3722,34 @@ Now we just need to know how to retrieve information from the entry_. If ``bdecode()`` encounters invalid encoded data in the range given to it it will throw invalid_encoding_. +add_magnet_uri() +---------------- + + :: + + torrent_handle add_magnet_uri(session& ses, std::string const& uri + add_torrent_params p); + +This function parses the magnet URI (``uri``) as a bittorrent magnet link, +and adds the torrent to the specified session (``ses``). It returns the +handle to the newly added torrent, or an invalid handle in case parsing +failed. To control some initial settings of the torrent, sepcify those in +the ``add_torrent_params``, ``p``. See `add_torrent()`_. + +For more information about magnet links, see `magnet links`_. + +make_magnet_uri() +----------------- + + :: + + std::string make_magnet_uri(torrent_handle const& handle); + +Generates a magnet URI from the specified torrent. If the torrent +handle is invalid, an empty string is returned. + +For more information about magnet links, see `magnet links`_. + alerts ====== @@ -4611,6 +4639,18 @@ delete_files() This function should delete all files and directories belonging to this storage. +magnet links +============ + +Magnet links are URIs that includes an info-hash, a display name and optionally +a tracker url. The idea behind magnet links is that an end user can click on a +link in a browser and have it handled by a bittorrent application, to start a +download, without any .torrent file. + +The format of the magnet URI is: + +**magnet:?xt=urn:btih:** *Base32 encoded info-hash* [ **&dn=** *name of download* ] [ **&tr=** *tracker URL* ]* + queuing ======= diff --git a/examples/client_test.cpp b/examples/client_test.cpp index c51597472..9d9ab1c4a 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -861,6 +861,7 @@ int main(int ac, char* av[]) ses.set_peer_proxy(ps); ses.set_web_seed_proxy(ps); +#ifndef TORRENT_NO_DEPRECATE if (log_level == "debug") ses.set_severity_level(alert::debug); else if (log_level == "warning") @@ -869,6 +870,7 @@ int main(int ac, char* av[]) ses.set_severity_level(alert::fatal); else ses.set_severity_level(alert::info); +#endif boost::filesystem::ifstream ses_state_file(".ses_state" , std::ios_base::binary); @@ -956,10 +958,12 @@ int main(int ac, char* av[]) // first see if this is a torrentless download if (i->substr(0, 7) == "magnet:") { + add_torrent_params p; + p.save_path = save_path; + p.storage_mode = compact_allocation_mode ? storage_mode_compact + : storage_mode_sparse; std::cout << "adding MANGET link: " << *i << std::endl; - torrent_handle h = add_magnet_uri(ses, *i, save_path - , compact_allocation_mode ? storage_mode_compact - : storage_mode_sparse); + torrent_handle h = add_magnet_uri(ses, *i, p); handles.insert(std::make_pair(std::string(), h)); diff --git a/examples/simple_client.cpp b/examples/simple_client.cpp index fb16570da..f9a120c09 100644 --- a/examples/simple_client.cpp +++ b/examples/simple_client.cpp @@ -60,7 +60,10 @@ int main(int argc, char* argv[]) { session s; s.listen_on(std::make_pair(6881, 6889)); - s.add_torrent(torrent_info(argv[1]), "./"); + add_torrent_params p; + p.save_path = "./"; + p.ti = new torrent_info(argv[1]); + s.add_torrent(p); // wait for the user to end char a; diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 49b1129b4..f3df27742 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -96,7 +96,9 @@ namespace libtorrent { virtual std::string message() const = 0; virtual int category() const = 0; +#ifndef TORRENT_NO_DEPRECATE severity_t severity() const TORRENT_DEPRECATED { return warning; } +#endif virtual std::auto_ptr clone() const = 0; diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index 2e947efa0..a77880d16 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -47,12 +47,18 @@ namespace libtorrent std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle); +#ifndef TORRENT_NO_DEPRECATE + // deprecated in 0.14 torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri , fs::path const& save_path , storage_mode_t storage_mode = storage_mode_sparse , bool paused = false , storage_constructor_type sc = default_storage_constructor - , void* userdata = 0); + , void* userdata = 0) TORRENT_DEPRECATED; +#endif + + torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri + , add_torrent_params p); } #endif diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 6b628bdbf..a3fa9e5cd 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -179,6 +179,7 @@ namespace libtorrent // all torrent_handles must be destructed before the session is destructed! torrent_handle add_torrent(add_torrent_params const& params); +#ifndef TORRENT_NO_DEPRECATE // deprecated in 0.14 torrent_handle add_torrent( torrent_info const& ti @@ -209,6 +210,7 @@ namespace libtorrent , bool paused = false , storage_constructor_type sc = default_storage_constructor , void* userdata = 0) TORRENT_DEPRECATED; +#endif session_proxy abort() { return session_proxy(m_impl); } @@ -317,7 +319,9 @@ namespace libtorrent void set_max_half_open_connections(int limit); std::auto_ptr pop_alert(); +#ifndef TORRENT_NO_DEPRECATE void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED; +#endif void set_alert_mask(int m); alert const* wait_for_alert(time_duration max_wait); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index b19b2a2a9..22d01ab90 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -319,10 +319,12 @@ namespace libtorrent torrent_status status() const; void get_download_queue(std::vector& queue) const; +#ifndef TORRENT_NO_DEPRECATE // fills the specified vector with the download progress [0, 1] // of each file in the torrent. The files are ordered as in // the torrent_info. void file_progress(std::vector& progress) const TORRENT_DEPRECATED; +#endif void file_progress(std::vector& progress) const; void clear_error() const; @@ -370,6 +372,7 @@ namespace libtorrent // ================ start deprecation ============ +#ifndef TORRENT_NO_DEPRECATE // deprecated in 0.13 // marks the piece with the given index as filtered // it will not be downloaded @@ -382,6 +385,7 @@ namespace libtorrent void filter_files(std::vector const& files) const TORRENT_DEPRECATED; // ================ end deprecation ============ +#endif void piece_availability(std::vector& avail) const; @@ -403,10 +407,12 @@ namespace libtorrent // to. void use_interface(const char* net_interface) const; +#ifndef TORRENT_NO_DEPRECATE // deprecated in 0.14 // use save_resume_data() instead. It is async. and // will return the resume data in an alert entry write_resume_data() const TORRENT_DEPRECATED; +#endif // forces this torrent to reannounce // (make a rerequest from the tracker) diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 6c87b475a..a027e3460 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -125,11 +125,13 @@ namespace libtorrent peer_request map_file(int file, size_type offset, int size) const { return m_files.map_file(file, offset, size); } +#ifndef TORRENT_NO_DEPRECATE // ------- start deprecation ------- // these functions will be removed in a future version torrent_info(entry const& torrent_file) TORRENT_DEPRECATED; void print(std::ostream& os) const TORRENT_DEPRECATED; // ------- end deprecation ------- +#endif bool is_valid() const { return m_files.is_valid(); } diff --git a/src/magnet_uri.cpp b/src/magnet_uri.cpp index bd582476a..af54de9e0 100644 --- a/src/magnet_uri.cpp +++ b/src/magnet_uri.cpp @@ -69,6 +69,7 @@ namespace libtorrent return ret.str(); } +#ifndef TORRENT_NO_DEPRECATE torrent_handle add_magnet_uri(session& ses, std::string const& uri , fs::path const& save_path , storage_mode_t storage_mode @@ -95,6 +96,31 @@ namespace libtorrent , name.empty() ? 0 : name.c_str(), save_path, entry() , storage_mode, paused, sc, userdata); } +#endif + + torrent_handle add_magnet_uri(session& ses, std::string const& uri + , add_torrent_params p) + { + std::string name; + std::string tracker; + + boost::optional display_name = url_has_argument(uri, "dn"); + if (display_name) name = unescape_string(display_name->c_str()); + boost::optional tracker_string = url_has_argument(uri, "tr"); + if (tracker_string) tracker = unescape_string(tracker_string->c_str()); + + boost::optional btih = url_has_argument(uri, "xt"); + if (!btih) return torrent_handle(); + + if (btih->compare(0, 9, "urn:btih:") != 0) return torrent_handle(); + + sha1_hash info_hash(base32decode(btih->substr(9))); + + if (!tracker.empty()) p.tracker_url = tracker.c_str(); + p.info_hash = info_hash; + if (!name.empty()) p.name = name.c_str(); + return ses.add_torrent(p); + } } diff --git a/src/session.cpp b/src/session.cpp index 5e0ad1205..3c65d02b5 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -244,6 +244,7 @@ namespace libtorrent return m_impl->add_torrent(params); } +#ifndef TORRENT_NO_DEPRECATE // if the torrent already exists, this will throw duplicate_torrent torrent_handle session::add_torrent( torrent_info const& ti @@ -311,6 +312,7 @@ namespace libtorrent p.userdata = userdata; return m_impl->add_torrent(p); } +#endif void session::remove_torrent(const torrent_handle& h, int options) { @@ -518,6 +520,7 @@ namespace libtorrent m_impl->set_alert_mask(m); } +#ifndef TORRENT_NO_DEPRECATE void session::set_severity_level(alert::severity_t s) { int m = 0; @@ -535,6 +538,7 @@ namespace libtorrent m_impl->set_alert_mask(m); } +#endif void session::start_lsd() { diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index e9f179e32..b1ee00296 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -332,11 +332,13 @@ namespace libtorrent TORRENT_FORWARD(set_tracker_login(name, password)); } +#ifndef TORRENT_NO_DEPRECATE void torrent_handle::file_progress(std::vector& progress) const { INVARIANT_CHECK; TORRENT_FORWARD(file_progress(progress)); } +#endif void torrent_handle::file_progress(std::vector& progress) const { @@ -426,6 +428,7 @@ namespace libtorrent return ret; } +#ifndef TORRENT_NO_DEPRECATE // ============ start deprecation =============== void torrent_handle::filter_piece(int index, bool filter) const @@ -461,7 +464,7 @@ namespace libtorrent } // ============ end deprecation =============== - +#endif std::vector const& torrent_handle::trackers() const { @@ -525,6 +528,7 @@ namespace libtorrent return !m_torrent.expired(); } +#ifndef TORRENT_NO_DEPRECATE entry torrent_handle::write_resume_data() const { INVARIANT_CHECK; @@ -535,7 +539,7 @@ namespace libtorrent return ret; } - +#endif fs::path torrent_handle::save_path() const { diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 03dc235d6..0c3e0fe5d 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -227,6 +227,7 @@ namespace libtorrent return 0; } +#ifndef TORRENT_NO_DEPRECATE // standard constructor that parses a torrent file torrent_info::torrent_info(entry const& torrent_file) : m_creation_date(pt::ptime(pt::not_a_date_time)) @@ -249,6 +250,7 @@ namespace libtorrent parse_torrent_file(e, error); #endif } +#endif torrent_info::torrent_info(lazy_entry const& torrent_file) : m_creation_date(pt::ptime(pt::not_a_date_time)) @@ -583,6 +585,7 @@ namespace libtorrent , bind(&announce_entry::tier, _1), bind(&announce_entry::tier, _2))); } +#ifndef TORRENT_NO_DEPRECATE // ------- start deprecation ------- void torrent_info::print(std::ostream& os) const @@ -606,6 +609,7 @@ namespace libtorrent } // ------- end deprecation ------- +#endif }