diff --git a/ChangeLog b/ChangeLog index 976487313..ea91d73f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * deprecate std::wstring overloads. long live utf-8 * improve time-critical pieces feature (streaming) * introduce bandwidth exhaustion attack-mitigation in allowed-fast pieces * python binding fix issue where torrent_info objects where destructing when their torrents were deleted diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index f93255fb4..499a0fc01 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -466,8 +466,10 @@ namespace libtorrent char const* country_for_ip(address const& a); #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE void load_asnum_dbw(std::wstring file); void load_country_dbw(std::wstring file); +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING #endif // TORRENT_DISABLE_GEO_IP diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 58b9869f9..2f635f3ae 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -236,8 +236,14 @@ namespace libtorrent #if TORRENT_USE_WSTRING // wstring versions + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings +#ifndef TORRENT_NO_DEPRECATE + template - void add_files(file_storage& fs, std::wstring const& wfile, Pred p, boost::uint32_t flags = 0) + TORRENT_DEPRECATED_PREFIX + void TORRENT_DEPRECATED add_files(file_storage& fs, std::wstring const& wfile, Pred p, boost::uint32_t flags = 0) { std::string utf8; wchar_utf8(wfile, utf8); @@ -245,7 +251,8 @@ namespace libtorrent , filename(utf8), p, flags); } - inline void add_files(file_storage& fs, std::wstring const& wfile, boost::uint32_t flags = 0) + TORRENT_DEPRECATED_PREFIX + inline void TORRENT_DEPRECATED add_files(file_storage& fs, std::wstring const& wfile, boost::uint32_t flags = 0) { std::string utf8; wchar_utf8(wfile, utf8); @@ -258,14 +265,16 @@ namespace libtorrent #ifndef BOOST_NO_EXCEPTIONS template - void set_piece_hashes(create_torrent& t, std::wstring const& p, Fun f) + TORRENT_DEPRECATED_PREFIX + void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t, std::wstring const& p, Fun f) { error_code ec; set_piece_hashes(t, p, f, ec); if (ec) throw libtorrent_exception(ec); } - inline void set_piece_hashes(create_torrent& t, std::wstring const& p) + TORRENT_DEPRECATED_PREFIX + inline void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t, std::wstring const& p) { error_code ec; set_piece_hashes(t, p, detail::nop, ec); @@ -273,12 +282,13 @@ namespace libtorrent } #endif - inline void set_piece_hashes(create_torrent& t, std::wstring const& p, error_code& ec) + TORRENT_DEPRECATED_PREFIX + inline void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t, std::wstring const& p, error_code& ec) { set_piece_hashes(t, p, detail::nop, ec); - } - -#endif // TORRENT_USE_WPATH + } +#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_USE_WSTRING } diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index bbcf957e2..1c2bb49f4 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -234,11 +234,19 @@ namespace libtorrent void rename_file(int index, std::string const& new_filename); #if TORRENT_USE_WSTRING + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED_PREFIX void add_file(std::wstring const& p, size_type size, int flags = 0 - , std::time_t mtime = 0, std::string const& s_p = ""); - void rename_file(int index, std::wstring const& new_filename); - void set_name(std::wstring const& n); -#endif + , std::time_t mtime = 0, std::string const& s_p = "") TORRENT_DEPRECATED; + TORRENT_DEPRECATED_PREFIX + void rename_file(int index, std::wstring const& new_filename) TORRENT_DEPRECATED; + TORRENT_DEPRECATED_PREFIX + void set_name(std::wstring const& n) TORRENT_DEPRECATED; +#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_USE_WSTRING std::vector map_block(int piece, size_type offset , int size) const; diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 2b1ff1a03..27bff4150 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -507,10 +507,17 @@ namespace libtorrent void load_country_db(char const* file); int as_for_ip(address const& addr); #if TORRENT_USE_WSTRING - void load_country_db(wchar_t const* file); - void load_asnum_db(wchar_t const* file); -#endif -#endif + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED_PREFIX + void load_country_db(wchar_t const* file) TORRENT_DEPRECATED; + TORRENT_DEPRECATED_PREFIX + void load_asnum_db(wchar_t const* file) TORRENT_DEPRECATED; +#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_USE_WSTRING +#endif // TORRENT_DISABLE_GEO_IP #ifndef TORRENT_NO_DEPRECATE // deprecated in 0.15 diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 149ce0e3f..0c917d1fb 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -405,9 +405,16 @@ namespace libtorrent void rename_file(int index, std::string const& new_name) const; #if TORRENT_USE_WSTRING - void move_storage(std::wstring const& save_path, int flags = 0) const; - void rename_file(int index, std::wstring const& new_name) const; -#endif +#ifndef TORRENT_NO_DEPRECATE + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings + TORRENT_DEPRECATED_PREFIX + void move_storage(std::wstring const& save_path, int flags = 0) const TORRENT_DEPRECATED; + TORRENT_DEPRECATED_PREFIX + void rename_file(int index, std::wstring const& new_name) const TORRENT_DEPRECATED; +#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_USE_WSTRING void super_seeding(bool on) const; diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 7b19f7374..2c6483640 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -304,7 +304,13 @@ namespace libtorrent torrent_info(char const* buffer, int size, int flags = 0); torrent_info(std::string const& filename, int flags = 0); #if TORRENT_USE_WSTRING - torrent_info(std::wstring const& filename, int flags = 0); + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED_PREFIX + torrent_info(std::wstring const& filename, int flags = 0) TORRENT_DEPRECATED; +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING #endif torrent_info(torrent_info const& t, int flags = 0); @@ -313,7 +319,13 @@ namespace libtorrent torrent_info(char const* buffer, int size, error_code& ec, int flags = 0); torrent_info(std::string const& filename, error_code& ec, int flags = 0); #if TORRENT_USE_WSTRING - torrent_info(std::wstring const& filename, error_code& ec, int flags = 0); + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED_PREFIX + torrent_info(std::wstring const& filename, error_code& ec, int flags = 0) TORRENT_DEPRECATED; +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING ~torrent_info(); @@ -352,11 +364,17 @@ namespace libtorrent m_files.rename_file(index, new_filename); } #if TORRENT_USE_WSTRING - void rename_file(int index, std::wstring const& new_filename) + // all wstring APIs are deprecated since 0.16.11 + // instead, use the wchar -> utf8 conversion functions + // and pass in utf8 strings +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED_PREFIX + void rename_file(int index, std::wstring const& new_filename) TORRENT_DEPRECATED { copy_on_write(); m_files.rename_file(index, new_filename); } +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING // Remaps the file storage to a new file layout. This can be used to, for instance, diff --git a/src/file_storage.cpp b/src/file_storage.cpp index a2cf924b7..0d7130dcb 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -166,6 +166,7 @@ namespace libtorrent } #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE void file_storage::set_name(std::wstring const& n) { std::string utf8; @@ -189,6 +190,7 @@ namespace libtorrent wchar_utf8(file, utf8); add_file(utf8, size, flags, mtime, symlink_path); } +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING void file_storage::rename_file(int index, std::string const& new_filename) diff --git a/src/session.cpp b/src/session.cpp index df52311aa..944bb420d 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -523,6 +523,7 @@ namespace libtorrent } #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE void session::load_asnum_db(wchar_t const* file) { TORRENT_ASYNC_CALL1(load_asnum_dbw, std::wstring(file)); @@ -532,6 +533,7 @@ namespace libtorrent { TORRENT_ASYNC_CALL1(load_country_dbw, std::wstring(file)); } +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING #endif // TORRENT_DISABLE_GEO_IP diff --git a/src/session_impl.cpp b/src/session_impl.cpp index eeaa27886..85a389440 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1636,6 +1636,7 @@ namespace aux { } #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE void session_impl::load_asnum_dbw(std::wstring file) { TORRENT_ASSERT(is_network_thread()); @@ -1657,6 +1658,7 @@ namespace aux { m_country_db = GeoIP_open(utf8.c_str(), GEOIP_STANDARD); // return m_country_db; } +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING void session_impl::load_country_db(std::string file) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index a9db6f0fd..8b847a912 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -345,6 +345,7 @@ namespace libtorrent } #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE void torrent_handle::move_storage( std::wstring const& save_path, int flags) const { @@ -361,6 +362,7 @@ namespace libtorrent wchar_utf8(new_name, utf8); TORRENT_ASYNC_CALL2(rename_file, index, utf8); } +#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING void torrent_handle::rename_file(int index, std::string const& new_name) const diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 7d35e2e86..d73424fd8 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -720,6 +720,7 @@ namespace libtorrent } #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE torrent_info::torrent_info(std::wstring const& filename, int flags) : m_merkle_first_leaf(0) , m_piece_hashes(0) @@ -745,7 +746,8 @@ namespace libtorrent INVARIANT_CHECK; } -#endif +#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_USE_WSTRING #endif torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec, int flags) @@ -801,6 +803,7 @@ namespace libtorrent } #if TORRENT_USE_WSTRING +#ifndef TORRENT_NO_DEPRECATE torrent_info::torrent_info(std::wstring const& filename, error_code& ec, int flags) : m_merkle_first_leaf(0) , m_piece_hashes(0) @@ -823,7 +826,8 @@ namespace libtorrent INVARIANT_CHECK; } -#endif +#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_USE_WSTRING // constructor used for creating new torrents // will not contain any hashes, comments, creation date