From ea98a7050e7d6ec83e3b85d59f52e22140985360 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 4 May 2013 03:59:52 +0000 Subject: [PATCH] merged python fix from RC_0_16 --- bindings/python/src/magnet_uri.cpp | 6 ++++-- bindings/python/src/session.cpp | 29 ++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/bindings/python/src/magnet_uri.cpp b/bindings/python/src/magnet_uri.cpp index f292763cd..410565a17 100644 --- a/bindings/python/src/magnet_uri.cpp +++ b/bindings/python/src/magnet_uri.cpp @@ -12,7 +12,8 @@ using namespace boost::python; using namespace libtorrent; extern void dict_to_add_torrent_params(dict params - , add_torrent_params& p, std::vector& rd); + , add_torrent_params& p, std::vector& rd + , std::vector& fp); namespace { @@ -22,7 +23,8 @@ namespace { add_torrent_params p; std::vector resume_buf; - dict_to_add_torrent_params(params, p, resume_buf); + std::vector files_buf; + dict_to_add_torrent_params(params, p, resume_buf, files_buf); allow_threading_guard guard; diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 2164f1b10..99c6e5536 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -176,7 +176,7 @@ namespace } void dict_to_add_torrent_params(dict params, add_torrent_params& p - , std::vector& rd) + , std::vector& rd, std::vector& fp) { // torrent_info objects are always held by an intrusive_ptr in the python binding if (params.has_key("ti") && params.get("ti") != boost::python::object()) @@ -247,6 +247,16 @@ namespace p.source_feed_url = extract(params["source_feed_url"]); if (params.has_key("uuid")) p.uuid = extract(params["uuid"]); + + fp.clear(); + if (params.has_key("file_priorities")) + { + list l = extract(params["file_priorities"]); + int n = boost::python::len(l); + for(int i = 0; i < n; i++) + fp.push_back(extract(l[i])); + p.file_priorities = &fp; + } } namespace @@ -256,7 +266,8 @@ namespace { add_torrent_params p; std::vector resume_buf; - dict_to_add_torrent_params(params, p, resume_buf); + std::vector files_buf; + dict_to_add_torrent_params(params, p, resume_buf, files_buf); allow_threading_guard guard; @@ -272,7 +283,8 @@ namespace { add_torrent_params p; std::vector resume_buf; - dict_to_add_torrent_params(params, p, resume_buf); + std::vector files_buf; + dict_to_add_torrent_params(params, p, resume_buf, files_buf); allow_threading_guard guard; @@ -285,7 +297,8 @@ namespace } void dict_to_feed_settings(dict params, feed_settings& feed - , std::vector& resume_buf) + , std::vector& resume_buf + , std::vector files_buf) { if (params.has_key("auto_download")) feed.auto_download = extract(params["auto_download"]); @@ -295,7 +308,7 @@ namespace feed.url = extract(params["url"]); if (params.has_key("add_args")) dict_to_add_torrent_params(dict(params["add_args"]), feed.add_args - , resume_buf); + , resume_buf, files_buf); } feed_handle add_feed(session& s, dict params) @@ -304,7 +317,8 @@ namespace // this static here is a bit of a hack. It will // probably work for the most part static std::vector resume_buf; - dict_to_feed_settings(params, feed, resume_buf); + static std::vector files_buf; + dict_to_feed_settings(params, feed, resume_buf, files_buf); allow_threading_guard guard; return s.add_feed(feed); @@ -351,7 +365,8 @@ namespace { feed_settings feed; static std::vector resume_buf; - dict_to_feed_settings(sett, feed, resume_buf); + static std::vector files_buf; + dict_to_feed_settings(sett, feed, resume_buf, files_buf); h.set_settings(feed); }