From e9a33e6a0590a43ef8de70f9381200114700a50c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 16 Nov 2008 02:09:53 +0000 Subject: [PATCH] added option to set alert mask when constructing session --- docs/manual.rst | 14 ++++++++++---- examples/client_test.cpp | 3 ++- include/libtorrent/session.hpp | 2 ++ src/session.cpp | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index fdfeed6c4..e8b472403 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -75,13 +75,15 @@ The ``session`` class has the following synopsis:: session(fingerprint const& print = libtorrent::fingerprint( "LT", 0, 1, 0, 0) - , int flags = start_default_features | add_default_plugins); + , int flags = start_default_features | add_default_plugins + , int alert_mask = alert::error_notification); session( fingerprint const& print , std::pair listen_port_range , char const* listen_interface = 0 - , int flags = start_default_features | add_default_plugins); + , int flags = start_default_features | add_default_plugins + , int alert_mask = alert::error_notification); torrent_handle add_torrent(add_torrent_params const& params); @@ -187,12 +189,14 @@ session() session(fingerprint const& print = libtorrent::fingerprint("LT", 0, 1, 0, 0) - , int flags = start_default_features | add_default_plugins); + , int flags = start_default_features | add_default_plugins + , int alert_mask = alert::error_notification); session(fingerprint const& print , std::pair listen_port_range , char const* listen_interface = 0 - , int flags = start_default_features | add_default_plugins); + , int flags = start_default_features | add_default_plugins + , int alert_mask = alert::error_notification); If the fingerprint in the first overload is omited, the client will get a default fingerprint stating the version of libtorrent. The fingerprint is a short string that will be @@ -207,6 +211,8 @@ The flags paramater can be used to start default features (upnp & nat-pmp) and d (ut_metadata, ut_pex and smart_ban). The default is to start those things. If you do not want them to start, pass 0 as the flags parameter. +The ``alert_mask`` is the same mask that you would send to ``set_alert_mask``. + ~session() ---------- diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 85e6bedf2..ab0156684 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -855,7 +855,8 @@ int main(int ac, char* av[]) // be able to remove torrents that were added via the directory // monitor when they're not in the directory anymore. handles_t handles; - session ses; + session ses(fingerprint("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0) + , session::start_default_features | session::add_default_plugins, alert::all_categories); #ifndef TORRENT_DISABLE_GEO_IP ses.load_asnum_db("GeoIPASNum.dat"); ses.load_country_db("GeoIP.dat"); diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 52f82977c..0bda8eb87 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -156,6 +156,7 @@ namespace libtorrent session(fingerprint const& print = fingerprint("LT" , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0) , int flags = start_default_features | add_default_plugins + , int alert_mask = alert::error_notification #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING , fs::path logpath = "." #endif @@ -165,6 +166,7 @@ namespace libtorrent , std::pair listen_port_range , char const* listen_interface = "0.0.0.0" , int flags = start_default_features | add_default_plugins + , int alert_mask = alert::error_notification #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING , fs::path logpath = "." #endif diff --git a/src/session.cpp b/src/session.cpp index 08cdbd954..8876d4abc 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -116,6 +116,7 @@ namespace libtorrent , std::pair listen_port_range , char const* listen_interface , int flags + , int alert_mask #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING , fs::path logpath #endif @@ -139,6 +140,7 @@ namespace libtorrent boost::function0 test = boost::ref(*m_impl); TORRENT_ASSERT(!test.empty()); #endif + set_alert_mask(alert_mask); #ifndef TORRENT_DISABLE_EXTENSIONS if (flags & add_default_plugins) { @@ -160,6 +162,7 @@ namespace libtorrent session::session(fingerprint const& id , int flags + , int alert_mask #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING , fs::path logpath #endif @@ -177,6 +180,7 @@ namespace libtorrent boost::function0 test = boost::ref(*m_impl); TORRENT_ASSERT(!test.empty()); #endif + set_alert_mask(alert_mask); #ifndef TORRENT_DISABLE_EXTENSIONS if (flags & add_default_plugins) {