* Enabled 'max_downloads_div' by default.

* Added 'get_{client,library}_version' commands.

* Removed support for appending more than one command to 'schedule'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@949 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-08-03 11:56:18 +00:00
parent ba634e7d62
commit 37bc4c85c4
8 changed files with 37 additions and 59 deletions
+4 -3
View File
@@ -183,16 +183,17 @@ torrent::Object
apply_schedule(const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
if (args.size() < 4)
throw torrent::input_error("Too few arguments.");
if (args.size() != 4)
throw torrent::input_error("Wrong number of arguments.");
torrent::Object::list_type::const_iterator itr = args.begin();
const std::string& arg1 = (itr++)->as_string();
const std::string& arg2 = (itr++)->as_string();
const std::string& arg3 = (itr++)->as_string();
const std::string& arg4 = (itr++)->as_string();
control->command_scheduler()->parse(arg1, arg2, arg3, rpc::convert_list_to_command(itr, args.end()));
control->command_scheduler()->parse(arg1, arg2, arg3, arg4);
return torrent::Object();
}
+3 -1
View File
@@ -101,7 +101,9 @@ add_variable(const char* getKey, const char* setKey, const char* defaultSetKey,
variable->set_variable(defaultObject);
rpc::commands.insert_generic(getKey, variable, getSlot, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, "i:", "");
rpc::commands.insert_generic(setKey, variable, setSlot, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, "i:", "");
if (setKey)
rpc::commands.insert_generic(setKey, variable, setSlot, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, "i:", "");
if (defaultSetKey)
rpc::commands.insert_generic(defaultSetKey, variable, setSlot, rpc::CommandMap::flag_dont_delete, "i:", "");
+3
View File
@@ -84,6 +84,9 @@ add_variable("get_" key, "set_" key, key, &rpc::CommandVariable::get_value, &rpc
#define ADD_VARIABLE_STRING(key, defaultValue) \
add_variable("get_" key, "set_" key, key, &rpc::CommandVariable::get_string, &rpc::CommandVariable::set_string, std::string(defaultValue));
#define ADD_VARIABLE_C_STRING(key, defaultValue) \
add_variable("get_" key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::string(defaultValue));
#define ADD_COMMAND_SLOT(key, function, slot, parm, doc) \
commandSlotsItr->set_slot(slot); \
rpc::commands.insert_generic(key, commandSlotsItr++, &rpc::CommandSlot::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
+3 -2
View File
@@ -39,7 +39,6 @@
#include <functional>
#include <torrent/torrent.h>
#include <torrent/chunk_manager.h>
//#include <torrent/connection_manager.h>
#include "core/download_list.h"
#include "core/download_store.h"
@@ -56,11 +55,13 @@ typedef torrent::ChunkManager CM_t;
void
initialize_command_local() {
// core::DownloadList* downloadList = control->core()->download_list();
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
core::DownloadList* dList = control->core()->download_list();
core::DownloadStore* dStore = control->core()->download_store();
ADD_VARIABLE_C_STRING("client_version", PACKAGE_VERSION);
ADD_VARIABLE_C_STRING("library_version", torrent::version());
ADD_VARIABLE_VALUE("max_file_size", -1);
ADD_VARIABLE_VALUE("split_file_size", -1);
ADD_VARIABLE_STRING("split_suffix", ".part");
+9 -7
View File
@@ -283,12 +283,17 @@ initialize_command_network() {
ADD_VARIABLE_VALUE("max_peers_seed", -1);
ADD_VARIABLE_VALUE("max_uploads", 15);
ADD_VARIABLE_VALUE("max_uploads_div", 1);
ADD_VARIABLE_VALUE("max_downloads_div", 0);
ADD_VARIABLE_VALUE("max_uploads_div", 1);
ADD_VARIABLE_VALUE("max_uploads_global", 0);
ADD_VARIABLE_VALUE("max_downloads_div", 1);
ADD_VARIABLE_VALUE("max_downloads_global", 0);
ADD_COMMAND_VALUE_TRI_KB("download_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_down_throttle_i64), rak::ptr_fun(&torrent::down_throttle));
ADD_COMMAND_VALUE_TRI_KB("upload_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_up_throttle_i64), rak::ptr_fun(&torrent::up_throttle));
// ADD_COMMAND_VALUE_TRI("max_uploads_global", rak::make_mem_fun(control->ui(), &ui::Root::set_max_uploads_global), rak::make_mem_fun(control->ui(), &ui::Root::max_uploads_global));
// ADD_COMMAND_VALUE_TRI("max_downloads_global", rak::make_mem_fun(control->ui(), &ui::Root::set_max_downloads_global), rak::make_mem_fun(control->ui(), &ui::Root::max_downloads_global));
ADD_COMMAND_VALUE_TRI_KB("download_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_down_throttle_i64), rak::ptr_fun(&torrent::down_throttle));
ADD_COMMAND_VALUE_TRI_KB("upload_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_up_throttle_i64), rak::ptr_fun(&torrent::up_throttle));
ADD_VARIABLE_VALUE("tracker_numwant", -1);
@@ -306,9 +311,6 @@ initialize_command_network() {
ADD_COMMAND_VALUE_TRI("send_buffer_size", rak::make_mem_fun(cm, &torrent::ConnectionManager::set_send_buffer_size), rak::make_mem_fun(cm, &torrent::ConnectionManager::send_buffer_size));
ADD_COMMAND_VALUE_TRI("receive_buffer_size", rak::make_mem_fun(cm, &torrent::ConnectionManager::set_receive_buffer_size), rak::make_mem_fun(cm, &torrent::ConnectionManager::receive_buffer_size));
ADD_COMMAND_VALUE_TRI("max_uploads_global", rak::make_mem_fun(control->ui(), &ui::Root::set_max_uploads_global), rak::make_mem_fun(control->ui(), &ui::Root::max_uploads_global));
ADD_COMMAND_VALUE_TRI("max_downloads_global", rak::make_mem_fun(control->ui(), &ui::Root::set_max_downloads_global), rak::make_mem_fun(control->ui(), &ui::Root::max_downloads_global));
ADD_COMMAND_VALUE_TRI("hash_max_tries", std::ptr_fun(&torrent::set_hash_max_tries), rak::ptr_fun(&torrent::hash_max_tries));
ADD_COMMAND_VALUE_TRI("max_open_files", std::ptr_fun(&torrent::set_max_open_files), rak::ptr_fun(&torrent::max_open_files));
ADD_COMMAND_VALUE_TRI("max_open_sockets", rak::make_mem_fun(cm, &torrent::ConnectionManager::set_max_size), rak::make_mem_fun(cm, &torrent::ConnectionManager::max_size));
+2 -3
View File
@@ -79,9 +79,8 @@ parse_string(const char* first, const char* last, std::string* dest) {
return first;
}
if (parse_is_escape(*first))
if (++first == last)
throw torrent::input_error("Escape character at end of input.");
if (parse_is_escape(*first) && ++first == last)
throw torrent::input_error("Escape character at end of input.");
dest->push_back(*first);
first++;
+13 -34
View File
@@ -64,10 +64,7 @@ Root::Root() :
m_windowTitle(NULL),
m_windowHttpQueue(NULL),
m_windowInput(NULL),
m_windowStatusbar(NULL),
m_maxUploadsGlobal(0),
m_maxDownloadsGlobal(0) {
m_windowStatusbar(NULL) {
}
void
@@ -187,10 +184,11 @@ Root::set_down_throttle(unsigned int throttle) {
torrent::set_down_throttle(throttle * 1024);
int64_t div = rpc::call_command_value("get_max_downloads_div");
unsigned int div = std::max<int>(rpc::call_command_value("get_max_downloads_div"), 0);
unsigned int global = std::max<int>(rpc::call_command_value("get_max_downloads_global"), 0);
if (throttle == 0 || div <= 0) {
torrent::set_max_download_unchoked(m_maxDownloadsGlobal);
if (throttle == 0 || div == 0) {
torrent::set_max_download_unchoked(global);
return;
}
@@ -203,8 +201,8 @@ Root::set_down_throttle(unsigned int throttle) {
else
maxUnchoked = 10 + throttle / 5;
if (m_maxDownloadsGlobal != 0)
torrent::set_max_download_unchoked(std::min(maxUnchoked, m_maxDownloadsGlobal));
if (global != 0)
torrent::set_max_download_unchoked(std::min(maxUnchoked, global));
else
torrent::set_max_download_unchoked(maxUnchoked);
}
@@ -216,10 +214,11 @@ Root::set_up_throttle(unsigned int throttle) {
torrent::set_up_throttle(throttle * 1024);
int64_t div = rpc::call_command_value("get_max_uploads_div");
unsigned int div = std::max<int>(rpc::call_command_value("get_max_uploads_div"), 0);
unsigned int global = std::max<int>(rpc::call_command_value("get_max_uploads_global"), 0);
if (throttle == 0 || div <= 0) {
torrent::set_max_unchoked(m_maxUploadsGlobal);
if (throttle == 0 || div == 0) {
torrent::set_max_unchoked(global);
return;
}
@@ -232,8 +231,8 @@ Root::set_up_throttle(unsigned int throttle) {
else
maxUnchoked = 10 + throttle / 5;
if (m_maxUploadsGlobal != 0)
torrent::set_max_unchoked(std::min(maxUnchoked, m_maxUploadsGlobal));
if (global != 0)
torrent::set_max_unchoked(std::min(maxUnchoked, global));
else
torrent::set_max_unchoked(maxUnchoked);
}
@@ -248,26 +247,6 @@ Root::adjust_up_throttle(int throttle) {
set_up_throttle(std::max<int>(torrent::up_throttle() / 1024 + throttle, 0));
}
void
Root::set_max_uploads_global(int64_t slots) {
if (slots < 0)
throw torrent::input_error("Out of range.");
m_maxUploadsGlobal = slots;
set_up_throttle(torrent::up_throttle() / 1024);
}
void
Root::set_max_downloads_global(int64_t slots) {
if (slots < 0)
throw torrent::input_error("Out of range.");
m_maxDownloadsGlobal = slots;
set_down_throttle(torrent::down_throttle() / 1024);
}
void
Root::enable_input(const std::string& title, input::TextInput* input) {
if (m_windowInput->input() != NULL)
-9
View File
@@ -84,12 +84,6 @@ public:
void adjust_down_throttle(int throttle);
void adjust_up_throttle(int throttle);
unsigned int max_uploads_global() { return m_maxUploadsGlobal; }
void set_max_uploads_global(int64_t slots);
unsigned int max_downloads_global() { return m_maxDownloadsGlobal; }
void set_max_downloads_global(int64_t slots);
void enable_input(const std::string& title, input::TextInput* input);
void disable_input();
@@ -107,9 +101,6 @@ private:
WStatusbar* m_windowStatusbar;
input::Bindings m_bindings;
unsigned int m_maxUploadsGlobal;
unsigned int m_maxDownloadsGlobal;
};
}