2008-09-09 16:03:35 +02:00
|
|
|
// Copyright Andrew Resch 2008. Use, modification and distribution is
|
|
|
|
// subject to the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
|
|
|
|
2009-03-02 06:23:25 +01:00
|
|
|
#include <boost/python.hpp>
|
2008-09-09 16:03:35 +02:00
|
|
|
#include <libtorrent/session.hpp>
|
|
|
|
#include <libtorrent/torrent.hpp>
|
|
|
|
#include <libtorrent/magnet_uri.hpp>
|
|
|
|
#include "gil.hpp"
|
|
|
|
|
|
|
|
using namespace boost::python;
|
|
|
|
using namespace libtorrent;
|
|
|
|
|
2011-11-08 06:36:22 +01:00
|
|
|
extern void dict_to_add_torrent_params(dict params
|
2012-10-19 07:18:48 +02:00
|
|
|
, add_torrent_params& p, std::vector<char>& rd);
|
2011-11-08 06:36:22 +01:00
|
|
|
|
2008-09-09 16:03:35 +02:00
|
|
|
namespace {
|
2012-06-14 17:41:39 +02:00
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2008-09-09 16:03:35 +02:00
|
|
|
torrent_handle _add_magnet_uri(session& s, std::string uri, dict params)
|
|
|
|
{
|
|
|
|
add_torrent_params p;
|
|
|
|
|
|
|
|
std::vector<char> resume_buf;
|
2012-10-19 07:18:48 +02:00
|
|
|
dict_to_add_torrent_params(params, p, resume_buf);
|
2011-11-08 06:36:22 +01:00
|
|
|
|
2011-11-29 12:12:11 +01:00
|
|
|
allow_threading_guard guard;
|
|
|
|
|
2010-08-22 18:45:12 +02:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2008-09-09 16:03:35 +02:00
|
|
|
return add_magnet_uri(s, uri, p);
|
2010-08-22 18:45:12 +02:00
|
|
|
#else
|
2011-11-08 06:36:22 +01:00
|
|
|
error_code ec;
|
2010-08-22 18:45:12 +02:00
|
|
|
return add_magnet_uri(s, uri, p, ec);
|
|
|
|
#endif
|
2008-09-09 16:03:35 +02:00
|
|
|
}
|
2012-06-14 17:41:39 +02:00
|
|
|
#endif
|
2011-11-16 07:12:48 +01:00
|
|
|
|
|
|
|
std::string (*make_magnet_uri0)(torrent_handle const&) = make_magnet_uri;
|
|
|
|
std::string (*make_magnet_uri1)(torrent_info const&) = make_magnet_uri;
|
2008-09-09 16:03:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void bind_magnet_uri()
|
|
|
|
{
|
2012-06-14 17:41:39 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2008-09-09 16:03:35 +02:00
|
|
|
def("add_magnet_uri", &_add_magnet_uri);
|
2012-06-14 17:41:39 +02:00
|
|
|
#endif
|
2011-11-16 07:12:48 +01:00
|
|
|
def("make_magnet_uri", make_magnet_uri0);
|
|
|
|
def("make_magnet_uri", make_magnet_uri1);
|
2008-09-09 16:03:35 +02:00
|
|
|
}
|
2011-11-16 07:12:48 +01:00
|
|
|
|