diff --git a/src/command_download.cc b/src/command_download.cc index 9afeafb3..0317b009 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -415,13 +415,13 @@ initialize_command_download() { // 1 - Normal hashing // 2 - Download finished, hashing // 3 - Rehashing - ADD_CD_VARIABLE_VALUE("hashing", "rtorrent", "hashing"); + ADD_CD_VARIABLE_VALUE("hashing", "rtorrent", "hashing"); ADD_CD_VARIABLE_STRING("tied_to_file", "rtorrent", "tied_to_file"); // The "state_changed" variable is required to be a valid unix time // value, it indicates the last time the torrent changed its state, // resume/pause. - ADD_CD_VARIABLE_VALUE("state_changed", "rtorrent", "state_changed"); + ADD_CD_VARIABLE_VALUE("state_changed", "rtorrent", "state_changed"); ADD_CD_VARIABLE_VALUE_PUBLIC("ignore_commands", "rtorrent", "ignore_commands"); ADD_CD_STRING_BI("connection_current", std::ptr_fun(&apply_d_connection_type), std::ptr_fun(&retrieve_d_connection_type)); diff --git a/src/command_local.cc b/src/command_local.cc index 1c0d2b41..45bd0f7d 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -130,7 +130,7 @@ initialize_command_local() { ADD_COMMAND_VALUE_SET_OCT("system.", "umask", std::ptr_fun(&umask)); ADD_COMMAND_STRING_PREFIX("system.", "cwd", std::ptr_fun(system_set_cwd), rak::ptr_fun(&system_get_cwd)); - ADD_VARIABLE_STRING("name", ""); + ADD_VARIABLE_STRING("name", ""); ADD_VARIABLE_VALUE("max_file_size", -1); ADD_VARIABLE_VALUE("split_file_size", -1); diff --git a/src/command_network.cc b/src/command_network.cc index c2d93880..9de66cb1 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -315,7 +315,7 @@ initialize_command_network() { ADD_COMMAND_VALUE_UN("enable_trackers", std::ptr_fun(&apply_enable_trackers)); ADD_COMMAND_STRING_UN("encoding_list", std::ptr_fun(&apply_encoding_list)); - ADD_VARIABLE_BOOL("peer_exchange", false); + ADD_VARIABLE_BOOL("peer_exchange", true); // Not really network stuff: ADD_VARIABLE_BOOL("handshake_log", false); diff --git a/src/command_ui.cc b/src/command_ui.cc index 9f8b8f7b..33d5a4c6 100644 --- a/src/command_ui.cc +++ b/src/command_ui.cc @@ -264,9 +264,9 @@ initialize_command_ui() { // ADD_COMMAND_LIST("view_sort_current", rak::bind_ptr_fn(&apply_view_filter, &core::ViewManager::set_sort_current)); - ADD_ANY_NONE("print", rak::ptr_fn(&apply_print)); - ADD_ANY_NONE("cat", rak::ptr_fn(&apply_cat)); - ADD_ANY_NONE("if", rak::ptr_fn(&apply_if)); + ADD_ANY_NONE("print", rak::ptr_fn(&apply_print)); + ADD_ANY_NONE("cat", rak::ptr_fn(&apply_cat)); + ADD_ANY_NONE("if", rak::ptr_fn(&apply_if)); ADD_COMMAND_VALUE("to_date", rak::ptr_fn(&apply_to_date)); ADD_COMMAND_VALUE("to_time", rak::ptr_fn(&apply_to_time)); diff --git a/src/core/download_list.cc b/src/core/download_list.cc index d78d5149..016e30d1 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -253,7 +253,7 @@ DownloadList::close_try(Download* download) { void DownloadList::close_directly(Download* download) { if (download->download()->is_active()) { - download->download()->stop2(torrent::Download::stop_skip_tracker); + download->download()->stop(torrent::Download::stop_skip_tracker); torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); } @@ -407,7 +407,7 @@ DownloadList::resume(Download* download, int flags) { // Update the priority to ensure it has the correct // seeding/unfinished modifiers. download->set_priority(download->priority()); - download->download()->start2(download->resume_flags()); + download->download()->start(download->resume_flags()); download->set_resume_flags(~uint32_t()); @@ -438,7 +438,7 @@ DownloadList::pause(Download* download, int flags) { if (!download->download()->is_active()) return; - download->download()->stop2(flags); + download->download()->stop(flags); torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); std::for_each(slot_map_stop().begin(), slot_map_stop().end(), download_list_call(download)); diff --git a/src/rpc/command_map.cc b/src/rpc/command_map.cc index ecd20af3..3e7d9a5e 100644 --- a/src/rpc/command_map.cc +++ b/src/rpc/command_map.cc @@ -74,7 +74,7 @@ void CommandMap::insert_any(key_type key, Command* variable, any_slot targetSlot, int flags, const char* parm, const char* doc) { iterator itr = insert(key, variable, flags, parm, doc); - itr->second.m_target = target_any; + itr->second.m_target = target_any; itr->second.m_anySlot = targetSlot; } @@ -149,10 +149,14 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe if (itr == base_type::end()) throw torrent::input_error("Command \"" + std::string(key) + "\" does not exist."); - if (target.second == NULL && - itr->second.m_target != target_generic && - !(itr->second.m_target == target_any && target.first == target_generic)) - throw torrent::input_error("Command type mis-match."); + if (target.first != target_generic && target.second == NULL) { + // We received a target that is NULL, so throw an exception unless + // we can convert it to a void target. + if (itr->second.m_target > target_any) + throw torrent::input_error("Command type mis-match."); + + target.first = target_generic; + } if (itr->second.m_target != target.first && itr->second.m_target > target_any) { // Mismatch between the target and command type. If it is not @@ -178,8 +182,16 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe const CommandMap::mapped_type CommandMap::call_command(const_iterator itr, const mapped_type& arg, target_type target) { - if ((itr->second.m_target != target.first && itr->second.m_target > target_any) || - (target.second == NULL && itr->second.m_target != target_generic && !(itr->second.m_target == target_any && target.first == target_generic))) + if (target.first != target_generic && target.second == NULL) { + // We received a target that is NULL, so throw an exception unless + // we can convert it to a void target. + if (itr->second.m_target > target_any) + throw torrent::input_error("Command type mis-match."); + + target.first = target_generic; + } + + if (itr->second.m_target != target.first && itr->second.m_target > target_any) throw torrent::input_error("Command type mis-match."); // This _should_ be optimized int just two calls.