mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-06 06:09:22 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1ce2febf0 | |||
| 5ebb7bd151 | |||
| 50f0cad0c6 | |||
| 3717649bb3 | |||
| c32b56e9d8 | |||
| de54a4c2ad | |||
| 26fdca8f4d | |||
| 00bcdaee23 | |||
| 3787dbe7f3 |
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
m4_pattern_allow([PKG_CHECK_EXISTS])
|
m4_pattern_allow([PKG_CHECK_EXISTS])
|
||||||
|
|
||||||
AC_INIT([rtorrent],[0.16.22],[sundell.software@gmail.com])
|
AC_INIT([rtorrent],[0.16.23],[sundell.software@gmail.com])
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_MACRO_DIRS([scripts])
|
AC_CONFIG_MACRO_DIRS([scripts])
|
||||||
@@ -14,7 +14,7 @@ AX_CXX_COMPILE_STDCXX(20, noext, mandatory)
|
|||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
AC_DEFINE([API_VERSION], [26], [api version])
|
AC_DEFINE([API_VERSION], [27], [api version])
|
||||||
|
|
||||||
RAK_CHECK_CFLAGS
|
RAK_CHECK_CFLAGS
|
||||||
RAK_CHECK_CXXFLAGS
|
RAK_CHECK_CXXFLAGS
|
||||||
@@ -49,7 +49,7 @@ fi
|
|||||||
|
|
||||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||||
PKG_CHECK_MODULES([ZLIB], [zlib])
|
PKG_CHECK_MODULES([ZLIB], [zlib])
|
||||||
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.22])
|
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.23])
|
||||||
|
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
TORRENT_WITH_XMLRPC_C
|
TORRENT_WITH_XMLRPC_C
|
||||||
|
|||||||
@@ -431,6 +431,9 @@ p_call_target(const torrent::Object::list_type& args) {
|
|||||||
const std::string& peer_id = itr++->as_string();
|
const std::string& peer_id = itr++->as_string();
|
||||||
const std::string& command_key = itr++->as_string();
|
const std::string& command_key = itr++->as_string();
|
||||||
|
|
||||||
|
if (download == nullptr)
|
||||||
|
throw torrent::input_error("invalid parameters: info-hash not found");
|
||||||
|
|
||||||
torrent::HashString hash;
|
torrent::HashString hash;
|
||||||
|
|
||||||
if (peer_id.size() != 40)
|
if (peer_id.size() != 40)
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
|
|||||||
torrent::Object valueList = torrent::Object::create_list();
|
torrent::Object valueList = torrent::Object::create_list();
|
||||||
torrent::Object::list_type& valueListType = valueList.as_list();
|
torrent::Object::list_type& valueListType = valueList.as_list();
|
||||||
|
|
||||||
if ((itrArgs)->is_list())
|
if (itrArgs != args.end() && (itrArgs)->is_list())
|
||||||
valueListType = (itrArgs)->as_list();
|
valueListType = (itrArgs)->as_list();
|
||||||
|
|
||||||
control->object_storage()->insert_str(raw_key, valueList, flags);
|
control->object_storage()->insert_str(raw_key, valueList, flags);
|
||||||
|
|||||||
@@ -319,6 +319,11 @@ apply_ipv4_filter_load(const torrent::Object::list_type& args) {
|
|||||||
ipv4_filter_parse(buffer, value);
|
ipv4_filter_parse(buffer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file.fail() && !file.eof()) {
|
||||||
|
lineNumber++;
|
||||||
|
throw torrent::input_error("Exceeded max line length.");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (torrent::input_error& e) {
|
} catch (torrent::input_error& e) {
|
||||||
snprintf(buffer, 2048, "Error in ip filter file: %s:%u: %s", filename.c_str(), lineNumber, e.what());
|
snprintf(buffer, 2048, "Error in ip filter file: %s:%u: %s", filename.c_str(), lineNumber, e.what());
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -216,7 +216,7 @@ View::set_not_visible(Download* download) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
View::next_focus(unsigned int i) {
|
View::next_focus(unsigned int i) {
|
||||||
if (empty())
|
if (empty_visible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If at the boundary, roll over
|
// If at the boundary, roll over
|
||||||
@@ -239,7 +239,7 @@ View::next_focus(unsigned int i) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
View::prev_focus(unsigned int i) {
|
View::prev_focus(unsigned int i) {
|
||||||
if (empty())
|
if (empty_visible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If at the boundary, roll over
|
// If at the boundary, roll over
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ WindowFileList::WindowFileList(const ui::ElementFileList* element) :
|
|||||||
// Convert std::string to std::wstring of given width (in screen positions),
|
// Convert std::string to std::wstring of given width (in screen positions),
|
||||||
// taking into account that some characters may be occupying two screen positions.
|
// taking into account that some characters may be occupying two screen positions.
|
||||||
std::wstring
|
std::wstring
|
||||||
wstring_width(const std::string& i_str, [[maybe_unused]] int width) {
|
wstring_width(const std::string& i_str, int width) {
|
||||||
|
if (width < 0)
|
||||||
|
width = 0;
|
||||||
|
|
||||||
std::wstring result(width + 1, L' ');
|
std::wstring result(width + 1, L' ');
|
||||||
size_t length = std::mbstowcs(result.data(), i_str.c_str(), width);
|
size_t length = std::mbstowcs(result.data(), i_str.c_str(), width);
|
||||||
|
|
||||||
|
|||||||
@@ -61,14 +61,20 @@ CommandScheduler::call_item(value_type item) {
|
|||||||
// Remove the item before calling the command if it should be
|
// Remove the item before calling the command if it should be
|
||||||
// removed.
|
// removed.
|
||||||
|
|
||||||
|
std::string key = item->key();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rpc::call_object(item->command());
|
rpc::call_object(item->command());
|
||||||
|
|
||||||
} catch (torrent::input_error& e) {
|
} catch (torrent::input_error& e) {
|
||||||
if (m_slotErrorMessage)
|
if (m_slotErrorMessage)
|
||||||
m_slotErrorMessage("Scheduled command failed: " + item->key() + ": " + e.what());
|
m_slotErrorMessage("Scheduled command failed: " + key + ": " + e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The command is allowed to erase or replace this item, which deletes it.
|
||||||
|
if (std::find(begin(), end(), item) == end())
|
||||||
|
return;
|
||||||
|
|
||||||
// Still schedule if we caught a torrrent::input_error?
|
// Still schedule if we caught a torrrent::input_error?
|
||||||
auto next = item->next_time_scheduled();
|
auto next = item->next_time_scheduled();
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,11 @@ parse_command_file(const std::string& path) {
|
|||||||
getCount = 0;
|
getCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file.fail() && !file.eof()) {
|
||||||
|
lineNumber++;
|
||||||
|
throw torrent::input_error("Exceeded max line length.");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (torrent::input_error& e) {
|
} catch (torrent::input_error& e) {
|
||||||
snprintf(buffer, 2048, "Error in option file: %s:%u: %s", path.c_str(), lineNumber, e.what());
|
snprintf(buffer, 2048, "Error in option file: %s:%u: %s", path.c_str(), lineNumber, e.what());
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -44,10 +44,9 @@ xmlrpc_list_entry_to_object(xmlrpc_env* env, xmlrpc_value* src, int index) {
|
|||||||
if (env->fault_occurred)
|
if (env->fault_occurred)
|
||||||
throw xmlrpc_error_c(env);
|
throw xmlrpc_error_c(env);
|
||||||
|
|
||||||
torrent::Object obj = xmlrpc_to_object(env, tmp);
|
utils::scope_guard guard([tmp]() { xmlrpc_DECREF(tmp); });
|
||||||
xmlrpc_DECREF(tmp);
|
|
||||||
|
|
||||||
return obj;
|
return xmlrpc_to_object(env, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t
|
int64_t
|
||||||
@@ -213,11 +212,11 @@ xmlrpc_to_object(xmlrpc_env* env, xmlrpc_value* value, int call_type, rpc::targe
|
|||||||
if (env->fault_occurred)
|
if (env->fault_occurred)
|
||||||
throw xmlrpc_error_c(env);
|
throw xmlrpc_error_c(env);
|
||||||
|
|
||||||
|
utils::scope_guard guard([tmp]() { xmlrpc_DECREF(tmp); });
|
||||||
|
|
||||||
if (target != nullptr)
|
if (target != nullptr)
|
||||||
std::tie(*target, *deleter) = xmlrpc_to_target(env, tmp, call_type);
|
std::tie(*target, *deleter) = xmlrpc_to_target(env, tmp, call_type);
|
||||||
|
|
||||||
xmlrpc_DECREF(tmp);
|
|
||||||
|
|
||||||
if (env->fault_occurred)
|
if (env->fault_occurred)
|
||||||
throw xmlrpc_error_c(env);
|
throw xmlrpc_error_c(env);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "rpc/tinyxml2/tinyxml2.h"
|
#include "rpc/tinyxml2/tinyxml2.h"
|
||||||
#include "rpc/rpc_manager.h"
|
#include "rpc/rpc_manager.h"
|
||||||
#include "utils/base64.h"
|
#include "utils/base64.h"
|
||||||
|
#include "utils/functional.h"
|
||||||
#include "xmlrpc.h"
|
#include "xmlrpc.h"
|
||||||
|
|
||||||
namespace rpc {
|
namespace rpc {
|
||||||
@@ -258,6 +259,8 @@ execute_command(std::string method_name, const tinyxml2::XMLElement* params_elem
|
|||||||
torrent::Object params_raw = torrent::Object::create_list();
|
torrent::Object params_raw = torrent::Object::create_list();
|
||||||
torrent::Object::list_type& params = params_raw.as_list();
|
torrent::Object::list_type& params = params_raw.as_list();
|
||||||
rpc::target_type target = rpc::make_target();
|
rpc::target_type target = rpc::make_target();
|
||||||
|
std::function<void()> deleter = []() {};
|
||||||
|
utils::scope_guard guard([&deleter]() { deleter(); });
|
||||||
|
|
||||||
if (params_element != nullptr) {
|
if (params_element != nullptr) {
|
||||||
if (std::strncmp(params_element->Name(), "params", sizeof("params")) == 0) {
|
if (std::strncmp(params_element->Name(), "params", sizeof("params")) == 0) {
|
||||||
@@ -265,8 +268,6 @@ execute_command(std::string method_name, const tinyxml2::XMLElement* params_elem
|
|||||||
const auto* child = params_element->FirstChildElement("param");
|
const auto* child = params_element->FirstChildElement("param");
|
||||||
|
|
||||||
if (child != nullptr) {
|
if (child != nullptr) {
|
||||||
std::function<void()> deleter = []() {};
|
|
||||||
|
|
||||||
RpcManager::object_to_target(xml_value_to_object(child->FirstChildElement("value")), cmd_itr->second.m_flags, &target, &deleter);
|
RpcManager::object_to_target(xml_value_to_object(child->FirstChildElement("value")), cmd_itr->second.m_flags, &target, &deleter);
|
||||||
child = child->NextSiblingElement("param");
|
child = child->NextSiblingElement("param");
|
||||||
|
|
||||||
@@ -282,8 +283,6 @@ execute_command(std::string method_name, const tinyxml2::XMLElement* params_elem
|
|||||||
const auto* child = params_element->FirstChildElement("data")->FirstChildElement("value");
|
const auto* child = params_element->FirstChildElement("data")->FirstChildElement("value");
|
||||||
|
|
||||||
if (child != nullptr) {
|
if (child != nullptr) {
|
||||||
std::function<void()> deleter = []() {};
|
|
||||||
|
|
||||||
RpcManager::object_to_target(xml_value_to_object(child), cmd_itr->second.m_flags, &target, &deleter);
|
RpcManager::object_to_target(xml_value_to_object(child), cmd_itr->second.m_flags, &target, &deleter);
|
||||||
child = child->NextSiblingElement("value");
|
child = child->NextSiblingElement("value");
|
||||||
|
|
||||||
|
|||||||
@@ -61,3 +61,24 @@ TestCommandDynamic::test_old_style() {
|
|||||||
rpc::commands.call_command("method.insert", rpc::create_object_list("test_old_style.4", "simple", "cat=test.3"));
|
rpc::commands.call_command("method.insert", rpc::create_object_list("test_old_style.4", "simple", "cat=test.3"));
|
||||||
CPPUNIT_ASSERT(rpc::commands.call_command("test_old_style.4", torrent::Object()).as_string() == "test.3");
|
CPPUNIT_ASSERT(rpc::commands.call_command("test_old_style.4", torrent::Object()).as_string() == "test.3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestCommandDynamic::test_insert_list() {
|
||||||
|
torrent::Object key_only = torrent::Object::create_list();
|
||||||
|
key_only.as_list().push_back("test_insert_list.1");
|
||||||
|
|
||||||
|
rpc::commands.call_command("method.insert.list", key_only);
|
||||||
|
|
||||||
|
torrent::Object result = rpc::commands.call_command("test_insert_list.1", torrent::Object());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(result.is_list());
|
||||||
|
CPPUNIT_ASSERT(result.as_list().empty());
|
||||||
|
|
||||||
|
rpc::commands.call_command("method.insert.list",
|
||||||
|
rpc::create_object_list("test_insert_list.2", rpc::create_object_list("a", "b")));
|
||||||
|
|
||||||
|
torrent::Object filled = rpc::commands.call_command("test_insert_list.2", torrent::Object());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(filled.is_list());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)2, filled.as_list().size());
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class TestCommandDynamic : public test_fixture {
|
|||||||
CPPUNIT_TEST(test_basics);
|
CPPUNIT_TEST(test_basics);
|
||||||
CPPUNIT_TEST(test_get_set);
|
CPPUNIT_TEST(test_get_set);
|
||||||
CPPUNIT_TEST(test_old_style);
|
CPPUNIT_TEST(test_old_style);
|
||||||
|
CPPUNIT_TEST(test_insert_list);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ public:
|
|||||||
void test_get_set();
|
void test_get_set();
|
||||||
|
|
||||||
void test_old_style();
|
void test_old_style();
|
||||||
|
void test_insert_list();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<TestMainThread> m_test_main_thread;
|
std::unique_ptr<TestMainThread> m_test_main_thread;
|
||||||
|
|||||||
Reference in New Issue
Block a user