added option to set alert mask when constructing session

This commit is contained in:
Arvid Norberg 2008-11-16 02:09:53 +00:00
parent 7e4d5dc72f
commit e9a33e6a05
4 changed files with 18 additions and 5 deletions

View File

@ -75,13 +75,15 @@ The ``session`` class has the following synopsis::
session(fingerprint const& print session(fingerprint const& print
= libtorrent::fingerprint( = libtorrent::fingerprint(
"LT", 0, 1, 0, 0) "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( session(
fingerprint const& print fingerprint const& print
, std::pair<int, int> listen_port_range , std::pair<int, int> listen_port_range
, char const* listen_interface = 0 , 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); torrent_handle add_torrent(add_torrent_params const& params);
@ -187,12 +189,14 @@ session()
session(fingerprint const& print session(fingerprint const& print
= libtorrent::fingerprint("LT", 0, 1, 0, 0) = 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 session(fingerprint const& print
, std::pair<int, int> listen_port_range , std::pair<int, int> listen_port_range
, char const* listen_interface = 0 , 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 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 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 (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. 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() ~session()
---------- ----------

View File

@ -855,7 +855,8 @@ int main(int ac, char* av[])
// be able to remove torrents that were added via the directory // be able to remove torrents that were added via the directory
// monitor when they're not in the directory anymore. // monitor when they're not in the directory anymore.
handles_t handles; 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 #ifndef TORRENT_DISABLE_GEO_IP
ses.load_asnum_db("GeoIPASNum.dat"); ses.load_asnum_db("GeoIPASNum.dat");
ses.load_country_db("GeoIP.dat"); ses.load_country_db("GeoIP.dat");

View File

@ -156,6 +156,7 @@ namespace libtorrent
session(fingerprint const& print = fingerprint("LT" session(fingerprint const& print = fingerprint("LT"
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0) , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
, int flags = start_default_features | add_default_plugins , 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 #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
, fs::path logpath = "." , fs::path logpath = "."
#endif #endif
@ -165,6 +166,7 @@ namespace libtorrent
, std::pair<int, int> listen_port_range , std::pair<int, int> listen_port_range
, char const* listen_interface = "0.0.0.0" , char const* listen_interface = "0.0.0.0"
, int flags = start_default_features | add_default_plugins , 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 #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
, fs::path logpath = "." , fs::path logpath = "."
#endif #endif

View File

@ -116,6 +116,7 @@ namespace libtorrent
, std::pair<int, int> listen_port_range , std::pair<int, int> listen_port_range
, char const* listen_interface , char const* listen_interface
, int flags , int flags
, int alert_mask
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
, fs::path logpath , fs::path logpath
#endif #endif
@ -139,6 +140,7 @@ namespace libtorrent
boost::function0<void> test = boost::ref(*m_impl); boost::function0<void> test = boost::ref(*m_impl);
TORRENT_ASSERT(!test.empty()); TORRENT_ASSERT(!test.empty());
#endif #endif
set_alert_mask(alert_mask);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
if (flags & add_default_plugins) if (flags & add_default_plugins)
{ {
@ -160,6 +162,7 @@ namespace libtorrent
session::session(fingerprint const& id session::session(fingerprint const& id
, int flags , int flags
, int alert_mask
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
, fs::path logpath , fs::path logpath
#endif #endif
@ -177,6 +180,7 @@ namespace libtorrent
boost::function0<void> test = boost::ref(*m_impl); boost::function0<void> test = boost::ref(*m_impl);
TORRENT_ASSERT(!test.empty()); TORRENT_ASSERT(!test.empty());
#endif #endif
set_alert_mask(alert_mask);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
if (flags & add_default_plugins) if (flags & add_default_plugins)
{ {