mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
* Added insert_preserve helper functions to torrent::Object.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1000 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -87,7 +87,7 @@ apply_d_change_link(int changeType, core::Download* download, const torrent::Obj
|
||||
if (args.size() != 3)
|
||||
throw torrent::input_error("Wrong argument count.");
|
||||
|
||||
torrent::Object::list_type::const_iterator itr = args.begin();
|
||||
torrent::Object::list_const_iterator itr = args.begin();
|
||||
|
||||
const std::string& type = (itr++)->as_string();
|
||||
const std::string& prefix = (itr++)->as_string();
|
||||
@@ -251,7 +251,7 @@ f_multicall(core::Download* download, const torrent::Object& rawArgs) {
|
||||
for (torrent::FileList::const_iterator itr = download->file_list()->begin(), last = download->file_list()->end(); itr != last; itr++) {
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
|
||||
|
||||
for (torrent::Object::list_type::const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
const std::string& cmd = cItr->as_string();
|
||||
row.push_back(rpc::parse_command(rpc::make_target(*itr), cmd.c_str(), cmd.c_str() + cmd.size()).first);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ t_multicall(core::Download* download, const torrent::Object& rawArgs) {
|
||||
for (int itr = 0, last = download->tracker_list()->size(); itr != last; itr++) {
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
|
||||
|
||||
for (torrent::Object::list_type::const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
const std::string& cmd = cItr->as_string();
|
||||
torrent::Tracker t = download->tracker_list()->get(itr);
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ apply_on_ratio(int action, const torrent::Object& rawArgs) {
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
torrent::Object::list_type::const_iterator argItr = args.begin();
|
||||
torrent::Object::list_const_iterator argItr = args.begin();
|
||||
|
||||
// first argument: minimum ratio to reach
|
||||
// second argument: minimum upload amount to reach [optional]
|
||||
@@ -119,7 +119,7 @@ apply_on_ratio(int action, const torrent::Object& rawArgs) {
|
||||
|
||||
rpc::call_command("d.set_ignore_commands", (int64_t)1, rpc::make_target(*itr));
|
||||
|
||||
for (torrent::Object::list_type::const_iterator itr2 = argItr; itr2 != args.end(); itr2++)
|
||||
for (torrent::Object::list_const_iterator itr2 = argItr; itr2 != args.end(); itr2++)
|
||||
rpc::parse_command_object(rpc::make_target(*itr), *itr2);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ apply_schedule(const torrent::Object& rawArgs) {
|
||||
if (args.size() != 4)
|
||||
throw torrent::input_error("Wrong number of arguments.");
|
||||
|
||||
torrent::Object::list_type::const_iterator itr = args.begin();
|
||||
torrent::Object::list_const_iterator itr = args.begin();
|
||||
|
||||
const std::string& arg1 = (itr++)->as_string();
|
||||
const std::string& arg2 = (itr++)->as_string();
|
||||
@@ -213,7 +213,7 @@ apply_schedule(const torrent::Object& rawArgs) {
|
||||
torrent::Object
|
||||
apply_load(int flags, const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
torrent::Object::list_type::const_iterator argsItr = args.begin();
|
||||
torrent::Object::list_const_iterator argsItr = args.begin();
|
||||
|
||||
if (argsItr == args.end())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
@@ -260,7 +260,7 @@ apply_close_low_diskspace(int64_t arg) {
|
||||
torrent::Object
|
||||
apply_download_list(const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
torrent::Object::list_type::const_iterator argsItr = args.begin();
|
||||
torrent::Object::list_const_iterator argsItr = args.begin();
|
||||
|
||||
core::ViewManager* viewManager = control->view_manager();
|
||||
core::ViewManager::iterator viewItr;
|
||||
@@ -322,7 +322,7 @@ d_multicall(const torrent::Object& rawArgs) {
|
||||
for (core::View::const_iterator vItr = (*viewItr)->begin_visible(), vLast = (*viewItr)->end_visible(); vItr != vLast; vItr++) {
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
|
||||
|
||||
for (torrent::Object::list_type::const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
const std::string& cmd = cItr->as_string();
|
||||
row.push_back(rpc::parse_command(rpc::make_target(*vItr), cmd.c_str(), cmd.c_str() + cmd.size()).first);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ apply_encryption(const torrent::Object& rawArgs) {
|
||||
|
||||
uint32_t options_mask = torrent::ConnectionManager::encryption_none;
|
||||
|
||||
for (torrent::Object::list_type::const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
|
||||
const std::string& opt = itr->as_string();
|
||||
|
||||
if (opt == "none")
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ apply_view_filter(view_filter_slot viewFilterSlot, const torrent::Object& rawArg
|
||||
|
||||
core::ViewManager::filter_args filterArgs;
|
||||
|
||||
for (torrent::Object::list_type::const_iterator itr = ++args.begin(), last = args.end(); itr != last; itr++)
|
||||
for (torrent::Object::list_const_iterator itr = ++args.begin(), last = args.end(); itr != last; itr++)
|
||||
filterArgs.push_back(itr->as_string());
|
||||
|
||||
(control->view_manager()->*viewFilterSlot)(name, filterArgs);
|
||||
@@ -207,7 +207,7 @@ apply_to_xb(const torrent::Object& rawArgs) {
|
||||
torrent::Object
|
||||
apply_if(rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
torrent::Object::list_type::const_iterator itr = args.begin();
|
||||
torrent::Object::list_const_iterator itr = args.begin();
|
||||
|
||||
while (itr != args.end() && itr != --args.end()) {
|
||||
torrent::Object tmp;
|
||||
|
||||
@@ -177,10 +177,7 @@ DownloadFactory::receive_success() {
|
||||
root->erase_key("libtorrent");
|
||||
}
|
||||
|
||||
if (!root->has_key_map("rtorrent"))
|
||||
root->insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
|
||||
|
||||
torrent::Object* rtorrent = &root->get_key("rtorrent");
|
||||
torrent::Object* rtorrent = &root->insert_preserve_map("rtorrent").first->second;
|
||||
|
||||
initialize_rtorrent(download, rtorrent);
|
||||
|
||||
@@ -232,10 +229,7 @@ DownloadFactory::receive_success() {
|
||||
|
||||
rpc::call_command("d.set_peer_exchange", rpc::call_command_value("get_peer_exchange"), rpc::make_target(download));
|
||||
|
||||
torrent::Object& resumeObject = root->has_key_map("libtorrent_resume")
|
||||
? root->get_key("libtorrent_resume")
|
||||
: root->insert_key("libtorrent_resume", torrent::Object(torrent::Object::TYPE_MAP));
|
||||
|
||||
torrent::Object& resumeObject = root->insert_preserve_map("libtorrent_resume").first->second;
|
||||
torrent::resume_load_addresses(*download->download(), resumeObject);
|
||||
torrent::resume_load_file_priorities(*download->download(), resumeObject);
|
||||
torrent::resume_load_tracker_settings(*download->download(), resumeObject);
|
||||
@@ -322,14 +316,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
|
||||
rtorrent->insert_key("state_changed", cachedTime.seconds());
|
||||
}
|
||||
|
||||
if (!rtorrent->has_key_value("complete"))
|
||||
rtorrent->insert_key("complete", (int64_t)0);
|
||||
|
||||
if (!rtorrent->has_key_value("hashing"))
|
||||
rtorrent->insert_key("hashing", (int64_t)Download::variable_hashing_stopped);
|
||||
|
||||
if (!rtorrent->has_key_string("tied_to_file"))
|
||||
rtorrent->insert_key("tied_to_file", std::string());
|
||||
rtorrent->insert_preserve_value("complete", 0);
|
||||
rtorrent->insert_preserve_value("hashing", Download::variable_hashing_stopped);
|
||||
rtorrent->insert_preserve_cstr("tied_to_file", "");
|
||||
|
||||
if (rtorrent->has_key_value("priority"))
|
||||
rpc::call_command("d.set_priority", rtorrent->get_key_value("priority") % 4, rpc::make_target(download));
|
||||
@@ -351,8 +340,7 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
|
||||
download->download()->set_chunks_done(std::min<uint32_t>(rtorrent->get_key_value("chunks_done"),
|
||||
download->download()->file_list()->size_chunks()));
|
||||
|
||||
if (!rtorrent->has_key_value("ignore_commands"))
|
||||
rtorrent->insert_key("ignore_commands", (int64_t)0);
|
||||
rtorrent->insert_preserve_value("ignore_commands", 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ ExecFile::execute_object(const torrent::Object& rawArgs, int flags) {
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
for (torrent::Object::list_type::const_iterator itr = args.begin(), last = args.end(); itr != last; itr++, argsCurrent++) {
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++, argsCurrent++) {
|
||||
if (argsCurrent == argsBuffer + max_args - 1)
|
||||
throw torrent::input_error("Too many arguments.");
|
||||
|
||||
|
||||
+6
-6
@@ -235,8 +235,8 @@ convert_list_to_string(const torrent::Object& src) {
|
||||
}
|
||||
|
||||
std::string
|
||||
convert_list_to_string(torrent::Object::list_type::const_iterator first,
|
||||
torrent::Object::list_type::const_iterator last) {
|
||||
convert_list_to_string(torrent::Object::list_const_iterator first,
|
||||
torrent::Object::list_const_iterator last) {
|
||||
std::string dest;
|
||||
|
||||
while (first != last) {
|
||||
@@ -270,8 +270,8 @@ convert_list_to_string(torrent::Object::list_type::const_iterator first,
|
||||
}
|
||||
|
||||
std::string
|
||||
convert_list_to_command(torrent::Object::list_type::const_iterator first,
|
||||
torrent::Object::list_type::const_iterator last) {
|
||||
convert_list_to_command(torrent::Object::list_const_iterator first,
|
||||
torrent::Object::list_const_iterator last) {
|
||||
if (first == last)
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
@@ -375,7 +375,7 @@ print_object(char* first, char* last, const torrent::Object* src, int flags) {
|
||||
return std::max(first + snprintf(first, std::distance(first, last), "%lli", src->as_value()), last);
|
||||
|
||||
case torrent::Object::TYPE_LIST:
|
||||
for (torrent::Object::list_type::const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||
for (torrent::Object::list_const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||
first = print_object(first, last, &*itr, flags);
|
||||
|
||||
// Don't expand tilde after the first element in the list.
|
||||
@@ -412,7 +412,7 @@ print_object_std(std::string* dest, const torrent::Object* src, int flags) {
|
||||
return;
|
||||
}
|
||||
case torrent::Object::TYPE_LIST:
|
||||
for (torrent::Object::list_type::const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||
for (torrent::Object::list_const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||
print_object_std(dest, &*itr, flags);
|
||||
|
||||
// Don't expand tilde after the first element in the list.
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ const char* parse_list(const char* first, const char* last, torrent::Object* des
|
||||
const char* parse_whole_list(const char* first, const char* last, torrent::Object* dest);
|
||||
|
||||
std::string convert_list_to_string(const torrent::Object& src);
|
||||
std::string convert_list_to_string(torrent::Object::list_type::const_iterator first, torrent::Object::list_type::const_iterator last);
|
||||
std::string convert_list_to_command(torrent::Object::list_type::const_iterator first, torrent::Object::list_type::const_iterator last);
|
||||
std::string convert_list_to_string(torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last);
|
||||
std::string convert_list_to_command(torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last);
|
||||
|
||||
int64_t convert_to_value(const torrent::Object& src, int base = 0, int unit = 1);
|
||||
bool convert_to_value_nothrow(const torrent::Object& src, int64_t* value, int base = 0, int unit = 1);
|
||||
|
||||
@@ -86,7 +86,7 @@ parse_command_execute(target_type target, torrent::Object* object) {
|
||||
if (object->is_list()) {
|
||||
// For now, until we can flag the lists we want executed and those
|
||||
// we can't, disable recursion completely.
|
||||
for (torrent::Object::list_type::iterator itr = object->as_list().begin(), last = object->as_list().end(); itr != last; itr++) {
|
||||
for (torrent::Object::list_iterator itr = object->as_list().begin(), last = object->as_list().end(); itr != last; itr++) {
|
||||
if (itr->is_list())
|
||||
continue;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ inline void call_command_d_set_string(const char* key, core::Download
|
||||
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)); }
|
||||
|
||||
inline torrent::Object
|
||||
call_command_d_range(const char* key, core::Download* download, torrent::Object::list_type::const_iterator first, torrent::Object::list_type::const_iterator last) {
|
||||
call_command_d_range(const char* key, core::Download* download, torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last) {
|
||||
// Change to using range ctor.
|
||||
torrent::Object rawArgs(torrent::Object::TYPE_LIST);
|
||||
torrent::Object::list_type& args = rawArgs.as_list();
|
||||
|
||||
+2
-2
@@ -350,7 +350,7 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
||||
{
|
||||
xmlrpc_value* result = xmlrpc_array_new(env);
|
||||
|
||||
for (torrent::Object::list_type::const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++)
|
||||
for (torrent::Object::list_const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++)
|
||||
xmlrpc_array_append_item(env, result, object_to_xmlrpc(env, *itr));
|
||||
|
||||
return result;
|
||||
@@ -360,7 +360,7 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
||||
{
|
||||
xmlrpc_value* result = xmlrpc_struct_new(env);
|
||||
|
||||
for (torrent::Object::map_type::const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++)
|
||||
for (torrent::Object::map_const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++)
|
||||
xmlrpc_struct_set_value(env, result, itr->first.c_str(), object_to_xmlrpc(env, itr->second));
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user