mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 13:12:32 +00:00
* Added 'event.download.inserted_{new,session}' that are triggered
when a new or a session torrent is added. Ticket #1516. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1075 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
#include <torrent/peer/peer_list.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/download_store.h"
|
||||
#include "core/manager.h"
|
||||
#include "rpc/command_variable.h"
|
||||
|
||||
@@ -488,6 +489,8 @@ initialize_command_download() {
|
||||
ADD_CD_F_VOID("erase", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::erase_ptr));
|
||||
ADD_CD_F_VOID("check_hash", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::check_hash));
|
||||
|
||||
ADD_CD_F_VOID("save_session", rak::make_mem_fun(control->core()->download_store(), &core::DownloadStore::save));
|
||||
|
||||
ADD_CD_F_VOID("update_priorities", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::update_priorities)));
|
||||
|
||||
ADD_CD_STRING("add_peer", std::ptr_fun(&apply_d_add_peer));
|
||||
|
||||
@@ -257,27 +257,11 @@ DownloadFactory::receive_success() {
|
||||
if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end())
|
||||
throw torrent::input_error("The newly created download was removed.");
|
||||
|
||||
// When a download scheduler is implemented, this is handled by
|
||||
// the above insertion into download list.
|
||||
if (m_session) {
|
||||
// This torrent was queued for hashing or hashing when the
|
||||
// session file was saved. Or it was in a started state.
|
||||
if (//rpc::call_command_value("d.get_hashing", rpc::make_target(download)) != Download::variable_hashing_stopped ||
|
||||
rpc::call_command_value("d.get_state", rpc::make_target(download)) != 0)
|
||||
// m_manager->download_list()->resume(download);
|
||||
rpc::parse_command_single(rpc::make_target(download), "view.set_visible=started");
|
||||
else
|
||||
rpc::parse_command_single(rpc::make_target(download), "view.set_visible=stopped");
|
||||
if (!m_session)
|
||||
rpc::call_command("d.set_state", (int64_t)m_start, rpc::make_target(download));
|
||||
|
||||
} else {
|
||||
// Use the state thingie here, move below.
|
||||
if (m_start)
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.start=");
|
||||
else
|
||||
rpc::parse_command_single(rpc::make_target(download), "view.set_visible=stopped");
|
||||
|
||||
m_manager->download_store()->save(download);
|
||||
}
|
||||
rpc::commands.call_catch(m_session ? "event.download.inserted_session" : "event.download.inserted_new",
|
||||
rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
|
||||
} catch (torrent::input_error& e) {
|
||||
std::string msg = "Command on torrent creation failed: " + std::string(e.what());
|
||||
|
||||
@@ -211,11 +211,6 @@ Manager::initialize_second() {
|
||||
|
||||
CurlStack::global_init();
|
||||
|
||||
// Register slots to be called when a download is inserted/erased,
|
||||
// opened or closed.
|
||||
rpc::parse_command_single(rpc::make_target(), "system.method.set_key = event.download.inserted, 1_connect_logs, d.initialize_logs=");
|
||||
rpc::parse_command_single(rpc::make_target(), "system.method.set_key = event.download.erased, 9_delete_tied, d.delete_tied=");
|
||||
|
||||
torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -174,17 +174,26 @@ main(int argc, char** argv) {
|
||||
rpc::parse_command_multiple
|
||||
(rpc::make_target(),
|
||||
"system.method.insert = event.download.inserted,list\n"
|
||||
"system.method.insert = event.download.inserted_new,list\n"
|
||||
"system.method.insert = event.download.inserted_session,list\n"
|
||||
"system.method.insert = event.download.erased,list\n"
|
||||
"system.method.insert = event.download.opened,list\n"
|
||||
"system.method.insert = event.download.closed,list\n"
|
||||
"system.method.insert = event.download.resumed,list\n"
|
||||
"system.method.insert = event.download.paused,list\n"
|
||||
|
||||
|
||||
"system.method.insert = event.download.finished,list\n"
|
||||
"system.method.insert = event.download.hash_done,list\n"
|
||||
"system.method.insert = event.download.hash_removed,list\n"
|
||||
"system.method.insert = event.download.hash_queued,list\n"
|
||||
|
||||
"system.method.set_key = event.download.inserted, 1_connect_logs, d.initialize_logs=\n"
|
||||
"system.method.set_key = event.download.inserted_new, 1_prepare, \"branch=d.get_state=,view.set_visible=started,view.set_visible=stopped ;d.save_session=\"\n"
|
||||
"system.method.set_key = event.download.inserted_session, 1_prepare, \"branch=d.get_state=,view.set_visible=started,view.set_visible=stopped\"\n"
|
||||
|
||||
"system.method.set_key = event.download.erased, 0_download_list, ui.unfocus_download=\n"
|
||||
"system.method.set_key = event.download.erased, 9_delete_tied, d.delete_tied=\n"
|
||||
|
||||
"set_name = \"$cat=$system.hostname=,:,$system.pid=\"\n"
|
||||
|
||||
// Currently not doing any sorting on main.
|
||||
|
||||
@@ -98,7 +98,6 @@ DownloadList::activate(display::Frame* frame, bool focus) {
|
||||
m_frame = frame;
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
rpc::commands.call("system.method.set_key", rpc::make_target(), rpc::create_object_list("event.download.erased", "0_download_list", "ui.unfocus_download="));
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user