mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-11 16:49:22 +00:00
* Renamed 't.get_enabled' to 't.is_enabled'.
* The torrent is no longer closed on finished for on_finished commands, instead d.set_directory causes the download to call close_directly. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@974 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+22
-16
@@ -62,34 +62,40 @@ apply_t_set_enabled(torrent::Tracker* tracker, int64_t state) {
|
|||||||
rpc::commands.insert_tracker(key, commandTrackerSlotsItr++, &rpc::CommandSlot<torrent::Tracker*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
|
rpc::commands.insert_tracker(key, commandTrackerSlotsItr++, &rpc::CommandSlot<torrent::Tracker*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
|
||||||
|
|
||||||
#define ADD_CT_VOID(key, slot) \
|
#define ADD_CT_VOID(key, slot) \
|
||||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_fn(slot), "i:", "")
|
ADD_CT_SLOT_PUBLIC("t." key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(slot), "i:", "")
|
||||||
|
|
||||||
|
#define ADD_CT_VOID_UNI(key, get) \
|
||||||
|
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||||
|
|
||||||
#define ADD_CT_VALUE_UNI(key, get) \
|
#define ADD_CT_VALUE_UNI(key, get) \
|
||||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||||
|
|
||||||
#define ADD_CT_VALUE_BI(key, set, get) \
|
#define ADD_CT_VALUE_BI(key, set, get) \
|
||||||
ADD_CT_SLOT_PUBLIC("t.set_" key, call_value, rpc::object_value_fn<torrent::Tracker*>(set), "i:i", "") \
|
ADD_CT_SLOT_PUBLIC("t.set_" key, call_value, rpc::object_value_fn<torrent::Tracker*>(set), "i:i", "") \
|
||||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||||
|
|
||||||
|
#define ADD_CT_BOOL(key, set, get) \
|
||||||
|
ADD_CT_SLOT_PUBLIC("t.set_" key, call_value, rpc::object_value_fn<torrent::Tracker*>(set), "i:i", "") \
|
||||||
|
ADD_CT_SLOT_PUBLIC("t.is_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||||
|
|
||||||
#define ADD_CT_STRING_UNI(key, get) \
|
#define ADD_CT_STRING_UNI(key, get) \
|
||||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "s:", "")
|
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "s:", "")
|
||||||
|
|
||||||
void
|
void
|
||||||
initialize_command_tracker() {
|
initialize_command_tracker() {
|
||||||
ADD_CT_STRING_UNI("url", std::mem_fun(&torrent::Tracker::url));
|
ADD_CT_STRING_UNI("url", std::mem_fun(&torrent::Tracker::url));
|
||||||
ADD_CT_VALUE_UNI("group", std::mem_fun(&torrent::Tracker::group));
|
ADD_CT_VOID_UNI("group", std::mem_fun(&torrent::Tracker::group));
|
||||||
ADD_CT_VALUE_UNI("type", std::mem_fun(&torrent::Tracker::tracker_type));
|
ADD_CT_VOID_UNI("type", std::mem_fun(&torrent::Tracker::tracker_type));
|
||||||
ADD_CT_STRING_UNI("id", std::mem_fun(&torrent::Tracker::tracker_id));
|
ADD_CT_STRING_UNI("id", std::mem_fun(&torrent::Tracker::tracker_id));
|
||||||
|
|
||||||
ADD_CT_VALUE_BI("enabled", std::ptr_fun(&apply_t_set_enabled), std::mem_fun(&torrent::Tracker::is_enabled));
|
ADD_CT_VOID("is_open", std::mem_fun(&torrent::Tracker::is_open));
|
||||||
|
ADD_CT_BOOL("enabled", std::ptr_fun(&apply_t_set_enabled), std::mem_fun(&torrent::Tracker::is_enabled));
|
||||||
|
|
||||||
|
ADD_CT_VOID_UNI("normal_interval", std::mem_fun(&torrent::Tracker::normal_interval));
|
||||||
|
ADD_CT_VOID_UNI("min_interval", std::mem_fun(&torrent::Tracker::min_interval));
|
||||||
|
|
||||||
ADD_CT_VALUE_UNI("is_open", std::mem_fun(&torrent::Tracker::is_open));
|
ADD_CT_VOID_UNI("scrape_time_last", std::mem_fun(&torrent::Tracker::scrape_time_last));
|
||||||
|
ADD_CT_VOID_UNI("scrape_complete", std::mem_fun(&torrent::Tracker::scrape_complete));
|
||||||
ADD_CT_VALUE_UNI("normal_interval", std::mem_fun(&torrent::Tracker::normal_interval));
|
ADD_CT_VOID_UNI("scrape_incomplete", std::mem_fun(&torrent::Tracker::scrape_incomplete));
|
||||||
ADD_CT_VALUE_UNI("min_interval", std::mem_fun(&torrent::Tracker::min_interval));
|
ADD_CT_VOID_UNI("scrape_downloaded", std::mem_fun(&torrent::Tracker::scrape_downloaded));
|
||||||
|
|
||||||
ADD_CT_VALUE_UNI("scrape_time_last", std::mem_fun(&torrent::Tracker::scrape_time_last));
|
|
||||||
ADD_CT_VALUE_UNI("scrape_complete", std::mem_fun(&torrent::Tracker::scrape_complete));
|
|
||||||
ADD_CT_VALUE_UNI("scrape_incomplete", std::mem_fun(&torrent::Tracker::scrape_incomplete));
|
|
||||||
ADD_CT_VALUE_UNI("scrape_downloaded", std::mem_fun(&torrent::Tracker::scrape_downloaded));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include "control.h"
|
#include "control.h"
|
||||||
#include "download.h"
|
#include "download.h"
|
||||||
|
#include "manager.h"
|
||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
@@ -158,6 +159,8 @@ void
|
|||||||
Download::set_root_directory(const std::string& path) {
|
Download::set_root_directory(const std::string& path) {
|
||||||
torrent::FileList* fileList = m_download.file_list();
|
torrent::FileList* fileList = m_download.file_list();
|
||||||
|
|
||||||
|
control->core()->download_list()->close_directly(this);
|
||||||
|
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
fileList->set_root_dir("./" + (fileList->is_multi_file() ? m_download.name() : std::string()));
|
fileList->set_root_dir("./" + (fileList->is_multi_file() ? m_download.name() : std::string()));
|
||||||
|
|
||||||
|
|||||||
+11
-12
@@ -234,6 +234,17 @@ DownloadList::close(Download* download) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DownloadList::close_directly(Download* download) {
|
||||||
|
if (download->download()->is_active()) {
|
||||||
|
download->download()->stop2(torrent::Download::stop_skip_tracker);
|
||||||
|
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (download->download()->is_open())
|
||||||
|
download->download()->close();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::close_quick(Download* download) {
|
DownloadList::close_quick(Download* download) {
|
||||||
close(download);
|
close(download);
|
||||||
@@ -582,18 +593,6 @@ DownloadList::confirm_finished(Download* download) {
|
|||||||
// up/downloaded baseline.
|
// up/downloaded baseline.
|
||||||
download->download()->tracker_list().send_completed();
|
download->download()->tracker_list().send_completed();
|
||||||
|
|
||||||
// Close before calling on_finished to ensure the user can do stuff
|
|
||||||
// like change move the downloaded files and change the directory.
|
|
||||||
// close_throw(download);
|
|
||||||
// HACK:
|
|
||||||
if (download->is_open()) {
|
|
||||||
pause(download, torrent::Download::stop_skip_tracker);
|
|
||||||
download->download()->close();
|
|
||||||
std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));
|
|
||||||
std::for_each(slot_map_close().begin(), slot_map_close().end(), download_list_call(download));
|
|
||||||
}
|
|
||||||
// END
|
|
||||||
|
|
||||||
std::for_each(slot_map_finished().begin(), slot_map_finished().end(), download_list_call(download));
|
std::for_each(slot_map_finished().begin(), slot_map_finished().end(), download_list_call(download));
|
||||||
|
|
||||||
if (download->resume_flags() != ~uint32_t())
|
if (download->resume_flags() != ~uint32_t())
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public:
|
|||||||
void open_throw(Download* d);
|
void open_throw(Download* d);
|
||||||
|
|
||||||
void close(Download* d);
|
void close(Download* d);
|
||||||
|
void close_directly(Download* d);
|
||||||
void close_quick(Download* d);
|
void close_quick(Download* d);
|
||||||
void close_throw(Download* d);
|
void close_throw(Download* d);
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,9 @@ DownloadList::receive_exit_input(Input type) {
|
|||||||
if (current_view()->focus() == current_view()->end_visible())
|
if (current_view()->focus() == current_view()->end_visible())
|
||||||
throw torrent::input_error("No download in focus to change root directory.");
|
throw torrent::input_error("No download in focus to change root directory.");
|
||||||
|
|
||||||
|
if ((*current_view()->focus())->is_open())
|
||||||
|
throw torrent::input_error("Cannot change root directory on an open download.");
|
||||||
|
|
||||||
rpc::call_command("d.set_directory", rak::trim(input->str()), rpc::make_target(*current_view()->focus()));
|
rpc::call_command("d.set_directory", rak::trim(input->str()), rpc::make_target(*current_view()->focus()));
|
||||||
control->core()->push_log_std("New root directory \"" + rpc::call_command_string("d.get_directory", rpc::make_target(*current_view()->focus())) + "\" for torrent.");
|
control->core()->push_log_std("New root directory \"" + rpc::call_command_string("d.get_directory", rpc::make_target(*current_view()->focus())) + "\" for torrent.");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user