mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-06 18:22:32 +00:00
* Added "d_delete_tied" command.
* Moved CommandScheduler into src/rpc. * Fixed a bug in the "download_list" command. * Partial cleanup of the tracker list. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@924 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -24,10 +24,6 @@ rtorrent_SOURCES = \
|
||||
command_local.cc \
|
||||
command_network.cc \
|
||||
command_ui.cc \
|
||||
command_scheduler.cc \
|
||||
command_scheduler.h \
|
||||
command_scheduler_item.cc \
|
||||
command_scheduler_item.h \
|
||||
control.cc \
|
||||
control.h \
|
||||
globals.cc \
|
||||
|
||||
+68
-5
@@ -173,6 +173,61 @@ apply_d_delete_link(core::Download* download, const torrent::Object& rawArgs) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
apply_d_delete_tied(core::Download* download) {
|
||||
const std::string& tie = rpc::call_command_d_string("get_d_tied_to_file", download);
|
||||
|
||||
if (tie.empty())
|
||||
return;
|
||||
|
||||
if (::unlink(rak::path_expand(tie).c_str()) == -1)
|
||||
control->core()->push_log("Could not unlink tied file: " + std::string(rak::error_number::current().c_str()));
|
||||
|
||||
rpc::call_command_d("set_d_tied_to_file", download, std::string());
|
||||
}
|
||||
|
||||
void
|
||||
apply_d_connection_type(core::Download* download, const std::string& name) {
|
||||
torrent::Download::ConnectionType connType;
|
||||
|
||||
if (name == "leech")
|
||||
connType = torrent::Download::CONNECTION_LEECH;
|
||||
else if (name == "seed")
|
||||
connType = torrent::Download::CONNECTION_SEED;
|
||||
else
|
||||
throw torrent::input_error("Unknown peer connection type selected.");
|
||||
|
||||
download->download()->set_connection_type(connType);
|
||||
}
|
||||
|
||||
const char*
|
||||
retrieve_d_connection_type(core::Download* download) {
|
||||
switch (download->download()->connection_type()) {
|
||||
case torrent::Download::CONNECTION_LEECH:
|
||||
return "leech";
|
||||
case torrent::Download::CONNECTION_SEED:
|
||||
return "seed";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
retrieve_d_priority_str(core::Download* download) {
|
||||
switch (download->priority()) {
|
||||
case 0:
|
||||
return "off";
|
||||
case 1:
|
||||
return "low";
|
||||
case 2:
|
||||
return "normal";
|
||||
case 3:
|
||||
return "high";
|
||||
default:
|
||||
throw torrent::input_error("Priority out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_SLOT(key, function, slot, parm, doc) \
|
||||
commandDownloadSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert(key, commandDownloadSlotsItr++, NULL, &rpc::CommandDownloadSlot::function, rpc::CommandMap::flag_dont_delete, parm, doc);
|
||||
@@ -184,6 +239,9 @@ apply_d_delete_link(core::Download* download, const torrent::Object& rawArgs) {
|
||||
#define ADD_COMMAND_DOWNLOAD_VOID(key, slot) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC("get_d_" key, call_unknown, rpc::object_d_fn(slot), "i:", "")
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_V_VOID(key, slot) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC("d_" key, call_unknown, rpc::object_d_fn(slot), "i:", "")
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_LIST(key, slot) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC(key, call_list, slot, "i:", "")
|
||||
|
||||
@@ -205,6 +263,9 @@ apply_d_delete_link(core::Download* download, const torrent::Object& rawArgs) {
|
||||
#define ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI(key, target, get) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC("get_d_" key, call_unknown, rpc::object_void_d_fn(rak::on(rak::on(std::mem_fun(&core::Download::download), std::mem_fun(target)), std::mem_fun(get))), "i:", "");
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_STRING_UNI(key, get) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC("get_d_" key, call_unknown, rpc::object_void_d_fn(get), "s:", "")
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_STRING_BI(key, set, get) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC("set_d_" key, call_string, rpc::object_string_d_fn(set), "i:s", "") \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT_PUBLIC("get_d_" key, call_unknown, rpc::object_void_d_fn(get), "s:", "")
|
||||
@@ -224,8 +285,9 @@ initialize_command_download() {
|
||||
ADD_COMMAND_DOWNLOAD_VOID("base_path", &retrieve_d_base_path);
|
||||
ADD_COMMAND_DOWNLOAD_VOID("base_filename", &retrieve_d_base_filename);
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_LIST("create_link", rak::ptr_fn(&apply_d_create_link));
|
||||
ADD_COMMAND_DOWNLOAD_LIST("delete_link", rak::ptr_fn(&apply_d_delete_link));
|
||||
ADD_COMMAND_DOWNLOAD_LIST("create_link", rak::ptr_fn(&apply_d_create_link));
|
||||
ADD_COMMAND_DOWNLOAD_LIST("delete_link", rak::ptr_fn(&apply_d_delete_link));
|
||||
ADD_COMMAND_DOWNLOAD_V_VOID("delete_tied", &apply_d_delete_tied);
|
||||
|
||||
// 0 - stopped
|
||||
// 1 - started
|
||||
@@ -244,7 +306,7 @@ initialize_command_download() {
|
||||
ADD_COMMAND_DOWNLOAD_VARIABLE_VALUE("state_changed", "rtorrent", "state_changed");
|
||||
ADD_COMMAND_DOWNLOAD_VARIABLE_VALUE("ignore_commands", "rtorrent", "ignore_commands");
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_STRING_BI("connection_current", std::mem_fun(&core::Download::set_connection_current), std::mem_fun(&core::Download::connection_current));
|
||||
ADD_COMMAND_DOWNLOAD_STRING_BI("connection_current", std::ptr_fun(&apply_d_connection_type), std::ptr_fun(&retrieve_d_connection_type));
|
||||
|
||||
add_copy_to_download("get_connection_leech", "get_d_connection_leech");
|
||||
add_copy_to_download("set_connection_leech", "set_d_connection_leech");
|
||||
@@ -271,6 +333,7 @@ initialize_command_download() {
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_BI("tracker_numwant", &core::Download::tracker_list, &torrent::TrackerList::set_numwant, &torrent::TrackerList::numwant);
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_STRING_BI("directory", std::mem_fun(&core::Download::set_root_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir)));
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_BI("priority", std::mem_fun(&core::Download::set_priority), std::mem_fun(&core::Download::priority));
|
||||
ADD_COMMAND_DOWNLOAD_STRING_BI("directory", std::mem_fun(&core::Download::set_root_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir)));
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_BI("priority", std::mem_fun(&core::Download::set_priority), std::mem_fun(&core::Download::priority));
|
||||
ADD_COMMAND_DOWNLOAD_STRING_UNI("priority_str", std::ptr_fun(&retrieve_d_priority_str));
|
||||
}
|
||||
|
||||
+11
-11
@@ -48,6 +48,7 @@
|
||||
#include "core/download_list.h"
|
||||
#include "core/manager.h"
|
||||
#include "core/view_manager.h"
|
||||
#include "rpc/command_scheduler.h"
|
||||
#include "rpc/command_slot.h"
|
||||
#include "rpc/command_variable.h"
|
||||
#include "rpc/parse.h"
|
||||
@@ -56,7 +57,6 @@
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
#include "command_helpers.h"
|
||||
#include "command_scheduler.h"
|
||||
|
||||
torrent::Object
|
||||
apply_on_state_change(core::DownloadList::slot_map* slotMap, const torrent::Object& rawArgs) {
|
||||
@@ -309,18 +309,18 @@ initialize_command_events() {
|
||||
ADD_COMMAND_SLOT_PRIVATE("remove_untied", call_string, rpc::object_fn(&apply_remove_untied));
|
||||
|
||||
ADD_COMMAND_LIST("schedule", rak::ptr_fn(&apply_schedule));
|
||||
ADD_COMMAND_STRING_UN("schedule_remove", rak::make_mem_fun(control->command_scheduler(), &CommandScheduler::erase_str));
|
||||
ADD_COMMAND_STRING_UN("schedule_remove", rak::make_mem_fun(control->command_scheduler(), &rpc::CommandScheduler::erase_str));
|
||||
|
||||
ADD_COMMAND_STRING_UN("import", std::ptr_fun(&apply_import));
|
||||
ADD_COMMAND_STRING_UN("try_import", std::ptr_fun(&apply_try_import));
|
||||
ADD_COMMAND_STRING_UN("import", std::ptr_fun(&apply_import));
|
||||
ADD_COMMAND_STRING_UN("try_import", std::ptr_fun(&apply_try_import));
|
||||
|
||||
ADD_COMMAND_STRING_UN("load", std::ptr_fun(&apply_load));
|
||||
ADD_COMMAND_STRING_UN("load_verbose", std::ptr_fun(&apply_load_verbose));
|
||||
ADD_COMMAND_STRING_UN("load_start", std::ptr_fun(&apply_load_start));
|
||||
ADD_COMMAND_STRING_UN("load_start_verbose", std::ptr_fun(&apply_load_start_verbose));
|
||||
ADD_COMMAND_STRING_UN("load", std::ptr_fun(&apply_load));
|
||||
ADD_COMMAND_STRING_UN("load_verbose", std::ptr_fun(&apply_load_verbose));
|
||||
ADD_COMMAND_STRING_UN("load_start", std::ptr_fun(&apply_load_start));
|
||||
ADD_COMMAND_STRING_UN("load_start_verbose", std::ptr_fun(&apply_load_start_verbose));
|
||||
|
||||
ADD_COMMAND_VALUE_UN("close_low_diskspace", std::ptr_fun(&apply_close_low_diskspace));
|
||||
ADD_COMMAND_VALUE_UN("close_low_diskspace", std::ptr_fun(&apply_close_low_diskspace));
|
||||
|
||||
ADD_COMMAND_LIST("download_list", rak::ptr_fn(&apply_download_list));
|
||||
ADD_COMMAND_LIST("call_download", rak::ptr_fn(&apply_call_download));
|
||||
ADD_COMMAND_LIST("download_list", rak::ptr_fn(&apply_download_list));
|
||||
ADD_COMMAND_LIST("call_download", rak::ptr_fn(&apply_call_download));
|
||||
}
|
||||
|
||||
+2
-4
@@ -50,14 +50,13 @@
|
||||
#include "display/manager.h"
|
||||
#include "input/manager.h"
|
||||
#include "input/input_event.h"
|
||||
#include "rpc/command_scheduler.h"
|
||||
#include "rpc/fast_cgi.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
#include "rpc/scgi.h"
|
||||
#include "rpc/xmlrpc.h"
|
||||
#include "ui/root.h"
|
||||
|
||||
#include "command_scheduler.h"
|
||||
|
||||
#include "control.h"
|
||||
|
||||
Control::Control() :
|
||||
@@ -69,7 +68,7 @@ Control::Control() :
|
||||
m_input(new input::Manager()),
|
||||
m_inputStdin(new input::InputEvent(STDIN_FILENO)),
|
||||
|
||||
m_commandScheduler(new CommandScheduler()),
|
||||
m_commandScheduler(new rpc::CommandScheduler()),
|
||||
|
||||
m_fastCgi(NULL),
|
||||
m_scgi(NULL),
|
||||
@@ -85,7 +84,6 @@ Control::Control() :
|
||||
|
||||
m_taskShutdown.set_slot(rak::mem_fn(this, &Control::handle_shutdown));
|
||||
|
||||
m_commandScheduler->set_slot_command(rak::ptr_fn(&rpc::parse_command_single_std));
|
||||
m_commandScheduler->set_slot_error_message(rak::mem_fn(m_core, &core::Manager::push_log));
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -63,13 +63,12 @@ namespace input {
|
||||
}
|
||||
|
||||
namespace rpc {
|
||||
class CommandScheduler;
|
||||
class FastCgi;
|
||||
class SCgi;
|
||||
class XmlRpc;
|
||||
}
|
||||
|
||||
class CommandScheduler;
|
||||
|
||||
class Control {
|
||||
public:
|
||||
Control();
|
||||
@@ -98,7 +97,7 @@ public:
|
||||
input::Manager* input() { return m_input; }
|
||||
input::InputEvent* input_stdin() { return m_inputStdin; }
|
||||
|
||||
CommandScheduler* command_scheduler() { return m_commandScheduler; }
|
||||
rpc::CommandScheduler* command_scheduler() { return m_commandScheduler; }
|
||||
|
||||
rpc::FastCgi* fast_cgi() { return m_fastCgi; }
|
||||
void set_fast_cgi(rpc::FastCgi* f) { m_fastCgi = f; }
|
||||
@@ -134,7 +133,7 @@ private:
|
||||
input::Manager* m_input;
|
||||
input::InputEvent* m_inputStdin;
|
||||
|
||||
CommandScheduler* m_commandScheduler;
|
||||
rpc::CommandScheduler* m_commandScheduler;
|
||||
|
||||
rpc::FastCgi* m_fastCgi;
|
||||
rpc::SCgi* m_scgi;
|
||||
|
||||
@@ -125,59 +125,6 @@ Download::receive_storage_error(std::string msg) {
|
||||
m_message = "Storage error: [" + msg + "]";
|
||||
}
|
||||
|
||||
Download::download_type::ConnectionType
|
||||
Download::string_to_connection_type(const std::string& name) {
|
||||
// Return default if the name isn't found.
|
||||
if (name == "leech")
|
||||
return download_type::CONNECTION_LEECH;
|
||||
else if (name == "seed")
|
||||
return download_type::CONNECTION_SEED;
|
||||
else
|
||||
throw torrent::input_error("Unknown peer connection type selected: \"" + name + "\"");
|
||||
}
|
||||
|
||||
const char*
|
||||
Download::connection_type_to_string(download_type::ConnectionType t) {
|
||||
switch (t) {
|
||||
case download_type::CONNECTION_LEECH:
|
||||
return "leech";
|
||||
case download_type::CONNECTION_SEED:
|
||||
return "seed";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Download::string_to_priority(const std::string& name) {
|
||||
if (name == "off")
|
||||
return 0;
|
||||
else if (name == "low")
|
||||
return 1;
|
||||
else if (name == "normal")
|
||||
return 2;
|
||||
else if (name == "high")
|
||||
return 3;
|
||||
else
|
||||
throw torrent::input_error("Could not convert string to priority.");
|
||||
}
|
||||
|
||||
const char*
|
||||
Download::priority_to_string(uint32_t p) {
|
||||
switch (p) {
|
||||
case 0:
|
||||
return "off";
|
||||
case 1:
|
||||
return "low";
|
||||
case 2:
|
||||
return "normal";
|
||||
case 3:
|
||||
return "high";
|
||||
default:
|
||||
throw torrent::input_error("Priority out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
Download::distributed_copies() const {
|
||||
const uint8_t* avail = m_download.chunks_seen();
|
||||
|
||||
@@ -104,17 +104,6 @@ public:
|
||||
|
||||
bool operator == (const std::string& str) const;
|
||||
|
||||
void set_connection_type(const std::string& t) { m_download.set_connection_type(string_to_connection_type(t)); }
|
||||
|
||||
static connection_type string_to_connection_type(const std::string& name);
|
||||
static const char* connection_type_to_string(connection_type t);
|
||||
|
||||
const char* connection_current() const { return connection_type_to_string(m_download.connection_type()); }
|
||||
void set_connection_current(const std::string& t) { return m_download.set_connection_type(string_to_connection_type(t.c_str())); }
|
||||
|
||||
static uint32_t string_to_priority(const std::string& name);
|
||||
static const char* priority_to_string(uint32_t p);
|
||||
|
||||
float distributed_copies() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -352,9 +352,9 @@ DownloadList::resume(Download* download) {
|
||||
rpc::call_command_d("set_d_state_changed", download, cachedTime.seconds());
|
||||
|
||||
if (download->is_done()) {
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_seed", download));
|
||||
rpc::call_command_d("set_d_connection_current", download, rpc::call_command_d_void("get_d_connection_seed", download));
|
||||
} else {
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_leech", download));
|
||||
rpc::call_command_d("set_d_connection_current", download, rpc::call_command_d_void("get_d_connection_leech", download));
|
||||
|
||||
// For the moment, clear the resume data so we force hash-check
|
||||
// on non-complete downloads after a crash. This shouldn't be
|
||||
@@ -536,7 +536,7 @@ DownloadList::confirm_finished(Download* download) {
|
||||
|
||||
rpc::call_command_d("set_d_complete", download, (int64_t)1);
|
||||
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_seed", download));
|
||||
rpc::call_command_d("set_d_connection_current", download, rpc::call_command_d_void("get_d_connection_seed", download));
|
||||
download->set_priority(download->priority());
|
||||
|
||||
if (rpc::call_command_d_value("get_d_min_peers", download) == rpc::call_command_value("get_min_peers") && rpc::call_command_value("get_min_peers_seed") >= 0)
|
||||
|
||||
+1
-23
@@ -165,22 +165,6 @@ Manager::handshake_log(const sockaddr* sa, int msg, int err, const torrent::Hash
|
||||
}
|
||||
}
|
||||
|
||||
// Hmm... find some better place for all this.
|
||||
void
|
||||
Manager::delete_tied(Download* download) {
|
||||
const std::string& tie = rpc::call_command_d_string("get_d_tied_to_file", download);
|
||||
|
||||
// This should be configurable, need to wait for the variable
|
||||
// thingie to be implemented.
|
||||
if (tie.empty())
|
||||
return;
|
||||
|
||||
if (::unlink(rak::path_expand(tie).c_str()) == -1)
|
||||
push_log("Could not unlink tied file: " + std::string(rak::error_number::current().c_str()));
|
||||
|
||||
rpc::call_command_d("set_d_tied_to_file", download, std::string());
|
||||
}
|
||||
|
||||
Manager::Manager() :
|
||||
m_hashingView(NULL),
|
||||
|
||||
@@ -240,7 +224,7 @@ Manager::initialize_second() {
|
||||
m_downloadList->slot_map_insert()["1_connect_storage_log"] = sigc::bind(sigc::ptr_fun(&connect_signal_storage_log), sigc::mem_fun(m_logComplete, &Log::push_front));
|
||||
m_downloadList->slot_map_insert()["1_connect_tracker_dump"] = sigc::bind(sigc::ptr_fun(&connect_signal_tracker_dump), sigc::ptr_fun(&receive_tracker_dump));
|
||||
|
||||
m_downloadList->slot_map_erase()["9_delete_tied"] = sigc::mem_fun(this, &Manager::delete_tied);
|
||||
m_downloadList->slot_map_erase()["9_delete_tied"] = sigc::bind<0>(&rpc::call_command_d_v_void, "d_delete_tied");
|
||||
|
||||
torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
|
||||
}
|
||||
@@ -260,12 +244,6 @@ Manager::cleanup() {
|
||||
|
||||
void
|
||||
Manager::shutdown(bool force) {
|
||||
// This doesn't trigger a compiler error on gcc-3.4.5 for some reason.
|
||||
// if (!force)
|
||||
// std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::pause), &m_downloadList));
|
||||
// else
|
||||
// std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::close), &m_downloadList));
|
||||
|
||||
if (!force)
|
||||
std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::pause), m_downloadList));
|
||||
else
|
||||
|
||||
@@ -100,8 +100,6 @@ public:
|
||||
void try_create_download(const std::string& uri, bool start, bool printLog = true, bool tied = false);
|
||||
void try_create_download_expand(const std::string& uri, bool start, bool printLog = true, bool tied = false);
|
||||
|
||||
void delete_tied(Download* d);
|
||||
|
||||
private:
|
||||
void create_http(const std::string& uri);
|
||||
void create_final(std::istream* s);
|
||||
|
||||
@@ -165,7 +165,7 @@ print_download_info(char* first, char* last, core::Download* d) {
|
||||
d->download()->bytes_done() > 0 ? (double)(100 * d->download()->up_rate()->total() / d->download()->bytes_done()) / 100 : 0.0);
|
||||
|
||||
if (d->priority() != 2)
|
||||
first = print_buffer(first, last, " %s]", core::Download::priority_to_string(d->priority()));
|
||||
first = print_buffer(first, last, " %s]", rpc::call_command_d_string("get_d_priority_str", d).c_str());
|
||||
else
|
||||
first = print_buffer(first, last, "]");
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <rak/algorithm.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/tracker.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
|
||||
@@ -66,34 +66,42 @@ WindowTrackerList::redraw() {
|
||||
m_canvas->print(2, pos, "Trackers: [Key: %08x]", tl->key());
|
||||
++pos;
|
||||
|
||||
if (tl->size() == 0)
|
||||
if (tl->size() == 0 || *m_focus >= tl->size())
|
||||
return;
|
||||
|
||||
if (*m_focus >= tl->size())
|
||||
throw std::logic_error("WindowTrackerList::redraw() called on an object with a bad focus value.");
|
||||
|
||||
typedef std::pair<unsigned int, unsigned int> Range;
|
||||
|
||||
unsigned int group = 0;
|
||||
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, tl->size(), (m_canvas->height() + 1) / 2);
|
||||
|
||||
while (range.first != range.second) {
|
||||
torrent::Tracker t = tl->get(range.first);
|
||||
torrent::Tracker tracker = tl->get(range.first);
|
||||
|
||||
m_canvas->print(0, pos++, "%c %s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
t.url().c_str());
|
||||
// m_canvas->print(0, pos, "[%c] [S/L %5i/%5i] %s",
|
||||
// tracker.is_enabled() ? (tracker.is_open() ? '*' : ' ') : '-',
|
||||
// tracker.scrape_complete(), tracker.scrape_incomplete(),
|
||||
// tracker.url().c_str());
|
||||
|
||||
m_canvas->print(0, pos++, "%c Group: %2i Id: %s Focus: %s Enabled: %s Open: %s S/L: %u/%u",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
t.group(),
|
||||
rak::copy_escape_html(t.tracker_id()).c_str(),
|
||||
if (tracker.group() == group)
|
||||
m_canvas->print(0, pos, "%2i:", group++);
|
||||
|
||||
m_canvas->print(4, pos++, "%s",
|
||||
tracker.url().c_str());
|
||||
|
||||
m_canvas->print(4, pos++, "Id: %s Focus: %s Enabled: %s Open: %s S/L: %u/%u",
|
||||
rak::copy_escape_html(tracker.tracker_id()).c_str(),
|
||||
range.first == tl->focus() ? "yes" : " no",
|
||||
t.is_enabled() ? "yes" : " no",
|
||||
t.is_open() ? "yes" : " no",
|
||||
t.scrape_complete(),
|
||||
t.scrape_incomplete());
|
||||
tracker.is_enabled() ? "yes" : " no",
|
||||
tracker.is_open() ? "yes" : " no",
|
||||
tracker.scrape_complete(),
|
||||
tracker.scrape_incomplete());
|
||||
|
||||
++range.first;
|
||||
if (range.first == *m_focus) {
|
||||
m_canvas->set_attr(0, pos - 2, m_canvas->width(), is_focused() ? A_REVERSE : A_BOLD, COLOR_PAIR(0));
|
||||
m_canvas->set_attr(0, pos - 1, m_canvas->width(), is_focused() ? A_REVERSE : A_BOLD, COLOR_PAIR(0));
|
||||
}
|
||||
|
||||
range.first++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,14 +37,8 @@
|
||||
#ifndef RTORRENT_DISPLAY_TRACKER_LIST_H
|
||||
#define RTORRENT_DISPLAY_TRACKER_LIST_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace torrent {
|
||||
class Tracker;
|
||||
}
|
||||
|
||||
namespace core {
|
||||
class Download;
|
||||
}
|
||||
|
||||
+2
-2
@@ -58,6 +58,8 @@
|
||||
#include "display/manager.h"
|
||||
#include "input/bindings.h"
|
||||
|
||||
#include "rpc/command_scheduler.h"
|
||||
#include "rpc/command_scheduler_item.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
#include "utils/directory.h"
|
||||
|
||||
@@ -65,8 +67,6 @@
|
||||
#include "globals.h"
|
||||
#include "signal_handler.h"
|
||||
#include "option_parser.h"
|
||||
#include "command_scheduler.h"
|
||||
#include "command_scheduler_item.h"
|
||||
|
||||
void do_panic(int signum);
|
||||
void print_help();
|
||||
|
||||
+6
-2
@@ -2,14 +2,18 @@ noinst_LIBRARIES = libsub_rpc.a
|
||||
|
||||
libsub_rpc_a_SOURCES = \
|
||||
command.h \
|
||||
command_download_slot.cc \
|
||||
command_download_slot.h \
|
||||
command_map.cc \
|
||||
command_map.h \
|
||||
command_scheduler.cc \
|
||||
command_scheduler.h \
|
||||
command_scheduler_item.cc \
|
||||
command_scheduler_item.h \
|
||||
command_slot.cc \
|
||||
command_slot.h \
|
||||
command_variable.cc \
|
||||
command_variable.h \
|
||||
command_download_slot.cc \
|
||||
command_download_slot.h \
|
||||
fast_cgi.cc \
|
||||
fast_cgi.h \
|
||||
parse.cc \
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
|
||||
#include "command_scheduler.h"
|
||||
#include "command_scheduler_item.h"
|
||||
#include "parse_commands.h"
|
||||
|
||||
namespace rpc {
|
||||
|
||||
CommandScheduler::~CommandScheduler() {
|
||||
std::for_each(begin(), end(), rak::call_delete<CommandSchedulerItem>());
|
||||
@@ -94,7 +97,7 @@ CommandScheduler::call_item(value_type item) {
|
||||
// removed.
|
||||
|
||||
try {
|
||||
m_slotCommand(item->command());
|
||||
rpc::parse_command_single_std(item->command());
|
||||
|
||||
} catch (torrent::input_error& e) {
|
||||
if (m_slotErrorMessage.is_valid())
|
||||
@@ -209,3 +212,5 @@ CommandScheduler::parse_time(const char* str) {
|
||||
str = pos + 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,6 +42,8 @@
|
||||
#include <inttypes.h>
|
||||
#include <rak/functional_fun.h>
|
||||
|
||||
namespace rpc {
|
||||
|
||||
class CommandSchedulerItem;
|
||||
|
||||
class CommandScheduler : public std::vector<CommandSchedulerItem*> {
|
||||
@@ -57,7 +59,6 @@ public:
|
||||
CommandScheduler() {}
|
||||
~CommandScheduler();
|
||||
|
||||
void set_slot_command(SlotString::base_type* s) { m_slotCommand.set(s); }
|
||||
void set_slot_error_message(SlotString::base_type* s) { m_slotErrorMessage.set(s); }
|
||||
|
||||
// slot_error_message or something.
|
||||
@@ -80,8 +81,9 @@ public:
|
||||
private:
|
||||
void call_item(value_type item);
|
||||
|
||||
SlotString m_slotCommand;
|
||||
SlotString m_slotErrorMessage;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,8 @@
|
||||
|
||||
#include "command_scheduler_item.h"
|
||||
|
||||
namespace rpc {
|
||||
|
||||
CommandSchedulerItem::~CommandSchedulerItem() {
|
||||
priority_queue_erase(&taskScheduler, &m_task);
|
||||
}
|
||||
@@ -82,3 +84,5 @@ CommandSchedulerItem::next_time_scheduled() const {
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
namespace rpc {
|
||||
|
||||
class CommandSchedulerItem {
|
||||
public:
|
||||
typedef rak::function0<void> Slot;
|
||||
@@ -80,4 +82,6 @@ private:
|
||||
// Flags for various things.
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -85,6 +85,8 @@ inline torrent::Object call_command_d_void(const char* key, core::Download* down
|
||||
inline std::string call_command_d_string(const char* key, core::Download* download) { return commands.call_command_d(key, download, torrent::Object()).as_string(); }
|
||||
inline int64_t call_command_d_value(const char* key, core::Download* download) { return commands.call_command_d(key, download, torrent::Object()).as_value(); }
|
||||
|
||||
inline void call_command_d_v_void(const char* key, core::Download* download) { commands.call_command_d(key, download, torrent::Object()); }
|
||||
|
||||
inline void call_command_d_set_value(const char* key, core::Download* download, int64_t arg) { commands.call_command_d(key, download, torrent::Object(arg)); }
|
||||
inline void call_command_d_set_string(const char* key, core::Download* download, const std::string& arg) { commands.call_command_d(key, download, torrent::Object(arg)); }
|
||||
inline void call_command_d_set_std_string(const std::string& key, core::Download* download, const std::string& arg) { commands.call_command_d(key.c_str(), download, torrent::Object(arg)); }
|
||||
|
||||
@@ -161,6 +161,7 @@ Download::create_info() {
|
||||
element->push_column("Priority:", te_variable_value("get_d_priority"));
|
||||
|
||||
element->push_column("State changed:", te_variable_value("get_d_state_changed", value_base::flag_timer | value_base::flag_elapsed));
|
||||
element->push_column("Connection type:", te_variable_string("get_d_connection_current"));
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Memory usage:", te_value(&torrent::ChunkManager::memory_usage, value_base::flag_mb), " MB");
|
||||
|
||||
@@ -223,10 +223,9 @@ ElementDownloadList::receive_clear_tied() {
|
||||
const std::string& tiedFile = rpc::call_command_d_string("get_d_tied_to_file", *m_view->focus());
|
||||
|
||||
if (!tiedFile.empty()) {
|
||||
// Move this into core?
|
||||
control->core()->delete_tied(*m_view->focus());
|
||||
rpc::call_command_d_void("d_delete_tied", *m_view->focus());
|
||||
|
||||
control->core()->push_log("Cleared tied to file association for download.");
|
||||
control->core()->push_log("Cleared tied to file association for the selected download.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ ElementTrackerList::activate(display::Frame* frame, bool focus) {
|
||||
|
||||
m_window = new WTrackerList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
m_window->set_focused(focus);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
|
||||
Reference in New Issue
Block a user