mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
* Last of the old commands moved.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@903 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -33,8 +33,6 @@ rtorrent_SOURCES = \
|
||||
globals.cc \
|
||||
globals.h \
|
||||
main.cc \
|
||||
option_handler_rules.cc \
|
||||
option_handler_rules.h \
|
||||
option_parser.cc \
|
||||
option_parser.h \
|
||||
signal_handler.cc \
|
||||
|
||||
+58
-2
@@ -40,12 +40,14 @@
|
||||
#include <rak/file_stat.h>
|
||||
#include <rak/error_number.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/data/file.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/manager.h"
|
||||
#include "utils/command_slot.h"
|
||||
#include "utils/command_variable.h"
|
||||
#include "utils/command_download_slot.h"
|
||||
|
||||
#include "globals.h"
|
||||
@@ -187,7 +189,31 @@ apply_d_delete_link(core::Download* download, const torrent::Object& rawArgs) {
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_VARIABLE_STRING(key, firstKey, secondKey) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("get_" key, call_unknown, utils::get_variable_d_fn(firstKey, secondKey), "i:", ""); \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("set_" key, call_string, utils::set_variable_d_fn(firstKey, secondKey), "i:s", "");
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("set_" key, call_string, utils::set_variable_d_fn(firstKey, secondKey), "i:s", "");
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_VALUE_BI(key, set, get) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("set_" key, call_value, utils::object_value_d_fn(set), "i:i", "") \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("get_" key, call_unknown, utils::object_void_d_fn(get), "i:", "")
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_VALUE_MEM_BI(key, target, set, get) \
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_BI(key, rak::on2(std::mem_fun(target), std::mem_fun(set)), rak::on(std::mem_fun(target), std::mem_fun(get)));
|
||||
|
||||
#define ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI(key, target, get) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("get_" key, call_unknown, utils::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_BI(key, set, get) \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("set_" key, call_string, utils::object_string_d_fn(set), "i:s", "") \
|
||||
ADD_COMMAND_DOWNLOAD_SLOT("get_" key, call_unknown, utils::object_void_d_fn(get), "s:", "")
|
||||
|
||||
void
|
||||
add_copy_to_download(const char* key) {
|
||||
utils::VariableMap::iterator itr = control->variable()->find(key);
|
||||
|
||||
if (itr == control->variable()->end())
|
||||
throw torrent::internal_error("add_copy_to_download(...) key not found.");
|
||||
|
||||
control->download_variables()->insert(key, itr->second);
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_download() {
|
||||
@@ -199,7 +225,7 @@ initialize_command_download() {
|
||||
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_STRING_UN("print", rak::make_mem_fun(control->core(), &core::Manager::push_log));
|
||||
add_copy_to_download("print");
|
||||
|
||||
// 0 - stopped
|
||||
// 1 - started
|
||||
@@ -217,4 +243,34 @@ initialize_command_download() {
|
||||
// resume/pause.
|
||||
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_copy_to_download("get_connection_leech");
|
||||
add_copy_to_download("set_connection_leech");
|
||||
add_copy_to_download("get_connection_seed");
|
||||
add_copy_to_download("set_connection_seed");
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_BI("max_file_size", &core::Download::file_list, &torrent::FileList::set_max_file_size, &torrent::FileList::max_file_size);
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_BI("min_peers", &core::Download::download, &torrent::Download::set_peers_min, &torrent::Download::peers_min);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_BI("max_peers", &core::Download::download, &torrent::Download::set_peers_max, &torrent::Download::peers_max);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_BI("max_uploads", &core::Download::download, &torrent::Download::set_uploads_max, &torrent::Download::uploads_max);
|
||||
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI("up_rate", &torrent::Download::mutable_up_rate, &torrent::Rate::rate);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI("up_total", &torrent::Download::mutable_up_rate, &torrent::Rate::total);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI("down_rate", &torrent::Download::mutable_down_rate, &torrent::Rate::rate);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI("down_total", &torrent::Download::mutable_down_rate, &torrent::Rate::total);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI("skip_rate", &torrent::Download::mutable_skip_rate, &torrent::Rate::rate);
|
||||
ADD_COMMAND_DOWNLOAD_VALUE_MEM_UNI("skip_total", &torrent::Download::mutable_skip_rate, &torrent::Rate::total);
|
||||
|
||||
// variables->insert("split_file_size", new utils::VariableValueSlot(rak::mem_fn(file_list(), &torrent::FileList::split_file_size),
|
||||
// rak::mem_fn(file_list(), &torrent::FileList::set_split_file_size)));
|
||||
// variables->insert("split_suffix", new utils::VariableStringSlot(rak::mem_fn(file_list(), &torrent::FileList::split_suffix),
|
||||
// rak::mem_fn(file_list(), &torrent::FileList::set_split_suffix)));
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ utils::CommandVariable* commandVariablesItr = commandVariables;
|
||||
utils::CommandDownloadSlot commandDownloadSlots[COMMAND_DOWNLOAD_SLOTS_SIZE];
|
||||
utils::CommandDownloadSlot* commandDownloadSlotsItr = commandDownloadSlots;
|
||||
|
||||
void initialize_download_variables();
|
||||
void initialize_command_download();
|
||||
void initialize_command_events();
|
||||
void initialize_command_local();
|
||||
@@ -62,12 +61,11 @@ void initialize_command_ui();
|
||||
|
||||
void
|
||||
initialize_commands() {
|
||||
initialize_download_variables();
|
||||
initialize_command_download();
|
||||
initialize_command_events();
|
||||
initialize_command_network();
|
||||
initialize_command_local();
|
||||
initialize_command_ui();
|
||||
initialize_command_download();
|
||||
|
||||
#ifdef ADDING_COMMANDS
|
||||
if (commandSlotsItr > commandSlots + COMMAND_SLOTS_SIZE ||
|
||||
@@ -86,8 +84,8 @@ add_variable(const char* getKey, const char* setKey, const char* defaultSetKey,
|
||||
utils::CommandVariable* variable = commandVariablesItr++;
|
||||
variable->set_variable(defaultObject);
|
||||
|
||||
control->variable()->insert(getKey, variable, getSlot, NULL, utils::VariableMap::flag_dont_delete);
|
||||
control->variable()->insert(setKey, variable, setSlot, NULL, utils::VariableMap::flag_dont_delete);
|
||||
control->variable()->insert(getKey, variable, getSlot, NULL, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc);
|
||||
control->variable()->insert(setKey, variable, setSlot, NULL, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc);
|
||||
|
||||
if (defaultSetKey)
|
||||
control->variable()->insert(defaultSetKey, variable, setSlot, NULL, utils::VariableMap::flag_dont_delete);
|
||||
|
||||
@@ -123,5 +123,4 @@ add_variable("get_" key, "set_" key, key, &utils::CommandVariable::get_string, &
|
||||
#define ADD_COMMAND_LIST(key, slot) \
|
||||
ADD_COMMAND_SLOT(key, call_list, slot, "i:", "")
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -174,27 +174,27 @@ DownloadFactory::receive_success() {
|
||||
initialize_rtorrent(download, rtorrent);
|
||||
|
||||
// Move to 'rtorrent'.
|
||||
download->set("connection_leech", m_variables["connection_leech"]);
|
||||
download->set("connection_seed", m_variables["connection_seed"]);
|
||||
download->set("set_connection_leech", m_variables["connection_leech"]);
|
||||
download->set("set_connection_seed", m_variables["connection_seed"]);
|
||||
|
||||
download->set("max_uploads", control->variable()->call_command_void("get_max_uploads"));
|
||||
download->set("min_peers", control->variable()->call_command_void("get_min_peers"));
|
||||
download->set("max_peers", control->variable()->call_command_void("get_max_peers"));
|
||||
download->set("tracker_numwant", control->variable()->call_command_void("get_tracker_numwant"));
|
||||
download->set("set_max_uploads", control->variable()->call_command_void("get_max_uploads"));
|
||||
download->set("set_min_peers", control->variable()->call_command_void("get_min_peers"));
|
||||
download->set("set_max_peers", control->variable()->call_command_void("get_max_peers"));
|
||||
download->set("set_tracker_numwant", control->variable()->call_command_void("get_tracker_numwant"));
|
||||
|
||||
if (download->get_value("get_complete") != 0) {
|
||||
if (control->variable()->call_command_value("get_min_peers_seed") >= 0)
|
||||
download->set("min_peers", control->variable()->call_command_void("get_min_peers_seed"));
|
||||
download->set("set_min_peers", control->variable()->call_command_void("get_min_peers_seed"));
|
||||
|
||||
if (control->variable()->call_command_value("get_max_peers_seed") >= 0)
|
||||
download->set("max_peers", control->variable()->call_command_void("get_max_peers_seed"));
|
||||
download->set("set_max_peers", control->variable()->call_command_void("get_max_peers_seed"));
|
||||
}
|
||||
|
||||
if (!control->variable()->call_command_value("get_use_udp_trackers"))
|
||||
download->enable_udp_trackers(false);
|
||||
|
||||
if (control->variable()->call_command_value("get_max_file_size") > 0)
|
||||
download->set("max_file_size", control->variable()->call_command_void("get_max_file_size"));
|
||||
download->set("set_max_file_size", control->variable()->call_command_void("get_max_file_size"));
|
||||
|
||||
// Check first if we already have these values set in the session
|
||||
// torrent, so that it is safe to change the values.
|
||||
@@ -206,9 +206,9 @@ DownloadFactory::receive_success() {
|
||||
control->variable()->call_command_string("split_suffix"));
|
||||
|
||||
if (!rtorrent->has_key_string("directory"))
|
||||
download->set("directory", m_variables["directory"]);
|
||||
download->set("set_directory", m_variables["directory"]);
|
||||
else
|
||||
download->set("directory", rtorrent->get_key("directory"));
|
||||
download->set("set_directory", rtorrent->get_key("directory"));
|
||||
|
||||
if (!m_session && m_variables["tied_to_file"].as_value())
|
||||
download->set("set_tied_to_file", m_uri);
|
||||
@@ -286,9 +286,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
|
||||
rtorrent->insert_key("tied_to_file", std::string());
|
||||
|
||||
if (rtorrent->has_key_value("priority"))
|
||||
download->set("priority", rtorrent->get_key_value("priority") % 4);
|
||||
download->set("set_priority", rtorrent->get_key_value("priority") % 4);
|
||||
else
|
||||
download->set("priority", (int64_t)2);
|
||||
download->set("set_priority", (int64_t)2);
|
||||
|
||||
if (rtorrent->has_key_value("key")) {
|
||||
download->tracker_list()->set_key(rtorrent->get_key_value("key"));
|
||||
|
||||
@@ -334,9 +334,9 @@ DownloadList::resume(Download* download) {
|
||||
download->set("set_state_changed", cachedTime.seconds());
|
||||
|
||||
if (download->is_done()) {
|
||||
download->set_connection_type(download->get_string("connection_seed"));
|
||||
download->set_connection_type(download->get_string("get_connection_seed"));
|
||||
} else {
|
||||
download->set_connection_type(download->get_string("connection_leech"));
|
||||
download->set_connection_type(download->get_string("get_connection_leech"));
|
||||
|
||||
// For the moment, clear the resume data so we force hash-check
|
||||
// on non-complete downloads after a crash. This shouldn't be
|
||||
@@ -518,14 +518,14 @@ DownloadList::confirm_finished(Download* download) {
|
||||
|
||||
download->set("set_complete", (int64_t)1);
|
||||
|
||||
download->set_connection_type(download->get_string("connection_seed"));
|
||||
download->set_connection_type(download->get_string("get_connection_seed"));
|
||||
download->set_priority(download->priority());
|
||||
|
||||
if (download->get_value("min_peers") == control->variable()->call_command_value("get_min_peers") && control->variable()->call_command_value("get_min_peers_seed") >= 0)
|
||||
download->set("min_peers", control->variable()->call_command_void("get_min_peers_seed"));
|
||||
if (download->get_value("get_min_peers") == control->variable()->call_command_value("get_min_peers") && control->variable()->call_command_value("get_min_peers_seed") >= 0)
|
||||
download->set("set_min_peers", control->variable()->call_command_void("get_min_peers_seed"));
|
||||
|
||||
if (download->get_value("max_peers") == control->variable()->call_command_value("get_max_peers") && control->variable()->call_command_value("get_max_peers_seed") >= 0)
|
||||
download->set("max_peers", control->variable()->call_command_void("get_max_peers_seed"));
|
||||
if (download->get_value("get_max_peers") == control->variable()->call_command_value("get_max_peers") && control->variable()->call_command_value("get_max_peers_seed") >= 0)
|
||||
download->set("set_max_peers", control->variable()->call_command_void("get_max_peers_seed"));
|
||||
|
||||
// Do this before the slots are called in case one of them closes
|
||||
// the download.
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
#include "control.h"
|
||||
#include "globals.h"
|
||||
#include "signal_handler.h"
|
||||
#include "option_handler_rules.h"
|
||||
#include "option_parser.h"
|
||||
#include "command_scheduler.h"
|
||||
#include "command_scheduler_item.h"
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <rak/file_stat.h>
|
||||
#include <rak/fs_stat.h>
|
||||
#include <rak/functional.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/chunk_manager.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/path.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/tracker.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
#include <torrent/data/file.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/download_list.h"
|
||||
#include "core/download_store.h"
|
||||
#include "core/manager.h"
|
||||
#include "core/scheduler.h"
|
||||
#include "core/view_manager.h"
|
||||
#include "rpc/fast_cgi.h"
|
||||
#include "rpc/xmlrpc.h"
|
||||
#include "ui/root.h"
|
||||
#include "utils/command_slot.h"
|
||||
#include "utils/command_variable.h"
|
||||
#include "utils/directory.h"
|
||||
#include "utils/parse.h"
|
||||
#include "utils/variable_generic.h"
|
||||
#include "utils/variable_map.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
#include "option_handler_rules.h"
|
||||
#include "command_scheduler.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
namespace core {
|
||||
extern void
|
||||
path_expand(std::vector<std::string>* paths, const std::string& pattern);
|
||||
}
|
||||
|
||||
template <typename Target, typename GetFunc, typename SetFunc>
|
||||
utils::Variable*
|
||||
var_d_value(Target target, GetFunc getFunc, SetFunc setFunc) {
|
||||
return new utils::VariableDownloadValueSlot(rak::ftor_fn1(rak::on(std::mem_fun(target), std::mem_fun(getFunc))),
|
||||
rak::ftor_fn2(rak::on2(std::mem_fun(target), std::mem_fun(setFunc))));
|
||||
}
|
||||
|
||||
template <typename Target, typename GetFunc, typename SetFunc>
|
||||
utils::Variable*
|
||||
var_d2_value(Target target, GetFunc getFunc, SetFunc setFunc) {
|
||||
return new utils::VariableDownloadValueSlot(rak::ftor_fn1(rak::on(rak::on(std::mem_fun(&core::Download::download), std::mem_fun(target)), std::mem_fun(getFunc))),
|
||||
rak::ftor_fn2(rak::on2(rak::on(std::mem_fun(&core::Download::download), std::mem_fun(target)), std::mem_fun(setFunc))));
|
||||
}
|
||||
|
||||
template <typename Target, typename GetFunc>
|
||||
utils::Variable*
|
||||
var_d2_get_value(Target target, GetFunc getFunc) {
|
||||
return new utils::VariableDownloadValueSlot(rak::ftor_fn1(rak::on(rak::on(std::mem_fun(&core::Download::download), std::mem_fun(target)), std::mem_fun(getFunc))), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
initialize_download_variables() {
|
||||
utils::VariableMap* variables = control->download_variables();
|
||||
|
||||
variables->insert("connection_current", new utils::VariableDownloadStringSlot(rak::ftor_fn1(std::mem_fun(&core::Download::connection_current)),
|
||||
rak::ftor_fn2(std::mem_fun(&core::Download::set_connection_current))));
|
||||
|
||||
variables->insert("connection_leech", new utils::VariableAny(core::Download::connection_type_to_string(torrent::Download::CONNECTION_LEECH)));
|
||||
variables->insert("connection_seed", new utils::VariableAny(core::Download::connection_type_to_string(torrent::Download::CONNECTION_SEED)));
|
||||
|
||||
variables->insert("directory", new utils::VariableDownloadStringSlot(rak::ftor_fn1(rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir))),
|
||||
rak::ftor_fn2(std::mem_fun(&core::Download::set_root_directory))));
|
||||
|
||||
variables->insert("min_peers", var_d_value(&core::Download::download, &torrent::Download::peers_min, &torrent::Download::set_peers_min));
|
||||
variables->insert("max_peers", var_d_value(&core::Download::download, &torrent::Download::peers_max, &torrent::Download::set_peers_max));
|
||||
variables->insert("max_uploads", var_d_value(&core::Download::download, &torrent::Download::uploads_max, &torrent::Download::set_uploads_max));
|
||||
|
||||
variables->insert("max_file_size", var_d_value(&core::Download::file_list, &torrent::FileList::max_file_size, &torrent::FileList::set_max_file_size));
|
||||
|
||||
// variables->insert("split_file_size", new utils::VariableValueSlot(rak::mem_fn(file_list(), &torrent::FileList::split_file_size),
|
||||
// rak::mem_fn(file_list(), &torrent::FileList::set_split_file_size)));
|
||||
// variables->insert("split_suffix", new utils::VariableStringSlot(rak::mem_fn(file_list(), &torrent::FileList::split_suffix),
|
||||
// rak::mem_fn(file_list(), &torrent::FileList::set_split_suffix)));
|
||||
|
||||
variables->insert("up_rate", var_d2_get_value(&torrent::Download::mutable_up_rate, &torrent::Rate::rate));
|
||||
variables->insert("up_total", var_d2_get_value(&torrent::Download::mutable_up_rate, &torrent::Rate::total));
|
||||
variables->insert("down_rate", var_d2_get_value(&torrent::Download::mutable_down_rate, &torrent::Rate::rate));
|
||||
variables->insert("down_total", var_d2_get_value(&torrent::Download::mutable_down_rate, &torrent::Rate::total));
|
||||
variables->insert("skip_rate", var_d2_get_value(&torrent::Download::mutable_skip_rate, &torrent::Rate::rate));
|
||||
variables->insert("skip_total", var_d2_get_value(&torrent::Download::mutable_skip_rate, &torrent::Rate::total));
|
||||
|
||||
variables->insert("priority", new utils::VariableDownloadValueSlot(rak::ftor_fn1(std::mem_fun(&core::Download::priority)), rak::ftor_fn2(std::mem_fun(&core::Download::set_priority))));
|
||||
variables->insert("tracker_numwant", var_d_value(&core::Download::tracker_list, &torrent::TrackerList::numwant, &torrent::TrackerList::set_numwant));
|
||||
|
||||
// Hmm... do we need dupicates?
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_OPTION_HANDLER_RULES_H
|
||||
#define RTORRENT_OPTION_HANDLER_RULES_H
|
||||
|
||||
class Control;
|
||||
|
||||
|
||||
#endif
|
||||
+4
-4
@@ -158,7 +158,7 @@ Download::create_info() {
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Chunks:", te_value(&torrent::FileList::completed_chunks), " / ", te_value(&torrent::FileList::size_chunks), " * ", te_value(&torrent::FileList::chunk_size));
|
||||
element->push_column("Priority:", te_variable_value("priority"));
|
||||
element->push_column("Priority:", te_variable_value("get_priority"));
|
||||
|
||||
element->push_column("State changed:", te_variable_value("get_state_changed", value_base::flag_timer | value_base::flag_elapsed));
|
||||
|
||||
@@ -174,9 +174,9 @@ Download::create_info() {
|
||||
element->push_column("Receive buffer:", te_value(&torrent::ConnectionManager::receive_buffer_size, value_base::flag_kb), " KB");
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Upload:", te_variable_value("up_rate", value_base::flag_kb), " KB / ", te_variable_value("up_total", value_base::flag_xb));
|
||||
element->push_column("Download:", te_variable_value("down_rate", value_base::flag_kb), " KB / ", te_variable_value("down_total", value_base::flag_xb));
|
||||
element->push_column("Skipped:", te_variable_value("skip_rate", value_base::flag_kb), " KB / ", te_variable_value("skip_total", value_base::flag_xb));
|
||||
element->push_column("Upload:", te_variable_value("get_up_rate", value_base::flag_kb), " KB / ", te_variable_value("get_up_total", value_base::flag_xb));
|
||||
element->push_column("Download:", te_variable_value("get_down_rate", value_base::flag_kb), " KB / ", te_variable_value("get_down_total", value_base::flag_xb));
|
||||
element->push_column("Skipped:", te_variable_value("get_skip_rate", value_base::flag_kb), " KB / ", te_variable_value("get_skip_total", value_base::flag_xb));
|
||||
element->push_column("Preload:", te_value(&torrent::ChunkManager::preload_type), " / ", te_value(&torrent::ChunkManager::stats_preloaded), " / ", te_value(&torrent::ChunkManager::stats_not_preloaded));
|
||||
|
||||
element->set_column_width(element->column_width() + 1);
|
||||
|
||||
@@ -285,8 +285,8 @@ DownloadList::receive_exit_input(Input type) {
|
||||
if (current_view()->focus() == current_view()->end_visible())
|
||||
throw torrent::input_error("No download in focus to change root directory.");
|
||||
|
||||
(*current_view()->focus())->set("directory", rak::trim(input->str()));
|
||||
control->core()->push_log("New root directory \"" + (*current_view()->focus())->get_string("directory") + "\" for torrent.");
|
||||
(*current_view()->focus())->set("set_directory", rak::trim(input->str()));
|
||||
control->core()->push_log("New root directory \"" + (*current_view()->focus())->get_string("set_directory") + "\" for torrent.");
|
||||
break;
|
||||
|
||||
case INPUT_COMMAND:
|
||||
|
||||
@@ -86,9 +86,9 @@ private:
|
||||
// function calls.
|
||||
|
||||
template <typename Func, typename Result = typename Func::result_type>
|
||||
class object_d_void_fn_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
class object_void_d_fn_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
object_d_void_fn_t(Func func) : m_func(func) {}
|
||||
object_void_d_fn_t(Func func) : m_func(func) {}
|
||||
|
||||
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1) { return torrent::Object(m_func(download)); }
|
||||
|
||||
@@ -96,80 +96,72 @@ private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
// template <typename Func>
|
||||
// class object_void_fn_t<Func, void> : public rak::function_base1<torrent::Object, const torrent::Object&> {
|
||||
// public:
|
||||
// object_void_fn_t(Func func) : m_func(func) {}
|
||||
template <typename Func>
|
||||
class object_void_d_fn_t<Func, void> : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
object_void_d_fn_t(Func func) : m_func(func) {}
|
||||
|
||||
// virtual torrent::Object operator () (const torrent::Object& arg1) {
|
||||
// m_func();
|
||||
// return torrent::Object();
|
||||
// }
|
||||
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1) {
|
||||
m_func(download);
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
// private:
|
||||
// Func m_func;
|
||||
// };
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
// template <typename Func, typename Result = typename Func::result_type>
|
||||
// class object_value_fn1_t : public rak::function_base1<torrent::Object, const torrent::Object&> {
|
||||
// public:
|
||||
// object_value_fn1_t(Func func) : m_func(func) {}
|
||||
template <typename Func, typename Result = typename Func::result_type>
|
||||
class object_value_d_fn1_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
object_value_d_fn1_t(Func func) : m_func(func) {}
|
||||
|
||||
// virtual torrent::Object operator () (const torrent::Object& arg1) { return torrent::Object((int64_t)m_func(arg1.as_value())); }
|
||||
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1) {
|
||||
return torrent::Object((int64_t)m_func(download, arg1.as_value()));
|
||||
}
|
||||
|
||||
// private:
|
||||
// Func m_func;
|
||||
// };
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
// template <typename Func>
|
||||
// class object_value_fn1_t<Func, void> : public rak::function_base1<torrent::Object, const torrent::Object&> {
|
||||
// public:
|
||||
// object_value_fn1_t(Func func) : m_func(func) {}
|
||||
template <typename Func>
|
||||
class object_value_d_fn1_t<Func, void> : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
object_value_d_fn1_t(Func func) : m_func(func) {}
|
||||
|
||||
// virtual torrent::Object operator () (const torrent::Object& arg1) {
|
||||
// m_func(arg1.as_value());
|
||||
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1) {
|
||||
m_func(download, arg1.as_value());
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
// return torrent::Object();
|
||||
// }
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
// private:
|
||||
// Func m_func;
|
||||
// };
|
||||
|
||||
// template <typename Func, typename Result = typename Func::result_type>
|
||||
// class object_string_fn1_t : public rak::function_base1<torrent::Object, const torrent::Object&> {
|
||||
// public:
|
||||
// object_string_fn1_t(Func func) : m_func(func) {}
|
||||
template <typename Func, typename Result = typename Func::result_type>
|
||||
class object_string_d_fn1_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
object_string_d_fn1_t(Func func) : m_func(func) {}
|
||||
|
||||
// virtual torrent::Object operator () (const torrent::Object& arg1) { return torrent::Object(m_func(arg1.as_string())); }
|
||||
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1) { return torrent::Object(m_func(download, arg1.as_string())); }
|
||||
|
||||
// private:
|
||||
// Func m_func;
|
||||
// };
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
// template <typename Func>
|
||||
// class object_string_fn1_t<Func, void> : public rak::function_base1<torrent::Object, const torrent::Object&> {
|
||||
// public:
|
||||
// object_string_fn1_t(Func func) : m_func(func) {}
|
||||
template <typename Func>
|
||||
class object_string_d_fn1_t<Func, void> : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
object_string_d_fn1_t(Func func) : m_func(func) {}
|
||||
|
||||
// virtual torrent::Object operator () (const torrent::Object& arg1) {
|
||||
// m_func(arg1.as_string());
|
||||
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1) {
|
||||
m_func(download, arg1.as_string());
|
||||
|
||||
// return torrent::Object();
|
||||
// }
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
// private:
|
||||
// Func m_func;
|
||||
// };
|
||||
|
||||
template <typename Return> object_d_void_fn_t<Return (*)(core::Download*), Return>*
|
||||
object_d_fn(Return (*func)(core::Download*)) {
|
||||
return new object_d_void_fn_t<Return (*)(core::Download*), Return>(func);
|
||||
}
|
||||
|
||||
// template <typename Func> object_void_fn_t<Func>* object_void_fn(Func func) { return new object_void_fn_t<Func>(func); }
|
||||
// template <typename Func> object_value_fn1_t<Func>* object_value_fn(Func func) { return new object_value_fn1_t<Func>(func); }
|
||||
// template <typename Func> object_string_fn1_t<Func>* object_string_fn(Func func) { return new object_string_fn1_t<Func>(func); }
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
class set_variable_d_fn_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
|
||||
public:
|
||||
@@ -193,6 +185,15 @@ private:
|
||||
const char* m_secondKey;
|
||||
};
|
||||
|
||||
template <typename Return> object_void_d_fn_t<Return (*)(core::Download*), Return>*
|
||||
object_d_fn(Return (*func)(core::Download*)) {
|
||||
return new object_void_d_fn_t<Return (*)(core::Download*), Return>(func);
|
||||
}
|
||||
|
||||
template <typename Func> object_void_d_fn_t<Func>* object_void_d_fn(Func func) { return new object_void_d_fn_t<Func>(func); }
|
||||
template <typename Func> object_value_d_fn1_t<Func>* object_value_d_fn(Func func) { return new object_value_d_fn1_t<Func>(func); }
|
||||
template <typename Func> object_string_d_fn1_t<Func>* object_string_d_fn(Func func) { return new object_string_d_fn1_t<Func>(func); }
|
||||
|
||||
inline set_variable_d_fn_t*
|
||||
set_variable_d_fn(const char* firstKey, const char* secondKey) { return new set_variable_d_fn_t(firstKey, secondKey); }
|
||||
inline get_variable_d_fn_t*
|
||||
|
||||
@@ -72,6 +72,17 @@ VariableMap::insert(key_type key, Variable* variable, generic_slot genericSlot,
|
||||
base_type::insert(itr, value_type(key, variable_map_data_type(variable, genericSlot, downloadSlot, flags, parm, doc)));
|
||||
}
|
||||
|
||||
void
|
||||
VariableMap::insert(key_type key, const variable_map_data_type src) {
|
||||
iterator itr = base_type::find(key);
|
||||
|
||||
if (itr != base_type::end())
|
||||
throw torrent::internal_error("VariableMap::insert(...) tried to insert an already existing key.");
|
||||
|
||||
base_type::insert(itr, value_type(key, variable_map_data_type(src.m_variable, src.m_genericSlot, src.m_downloadSlot,
|
||||
src.m_flags | flag_dont_delete, src.m_parm, src.m_doc)));
|
||||
}
|
||||
|
||||
const VariableMap::mapped_type
|
||||
VariableMap::get_d(core::Download* download, key_type key) const {
|
||||
const_iterator itr = base_type::find(key);
|
||||
|
||||
@@ -96,6 +96,7 @@ public:
|
||||
|
||||
using base_type::begin;
|
||||
using base_type::end;
|
||||
using base_type::find;
|
||||
|
||||
static const int max_size_key = 128;
|
||||
static const int max_size_opt = 1024;
|
||||
@@ -115,6 +116,8 @@ public:
|
||||
void insert(key_type key, Variable* variable, generic_slot genericSlot = NULL, download_slot downloadSlot = NULL, int flags = 0,
|
||||
const char* parm = "", const char* doc = "");
|
||||
|
||||
void insert(key_type key, const variable_map_data_type src);
|
||||
|
||||
// Consider uninlining the helper functions.
|
||||
const mapped_type get_d(core::Download* download, key_type key) const;
|
||||
const std::string get_d_string(core::Download* download, key_type key) const { return get_d(download, key).as_string(); }
|
||||
|
||||
Reference in New Issue
Block a user