mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-10 04:02:30 +00:00
* Added "create_link" and "delete_link" options for creating and
deleting symbolic links to downloads. * Added "on_*" options for calling commands on state changes. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@849 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -234,9 +234,7 @@ VariableStringSlot::get() {
|
||||
if (!m_slotGet.is_valid())
|
||||
return m_cache = torrent::Object();
|
||||
|
||||
m_cache = m_slotGet();
|
||||
|
||||
return m_cache;
|
||||
return m_cache = m_slotGet();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -234,6 +234,12 @@ public:
|
||||
typedef rak::function0<string_type> slot_get_type;
|
||||
typedef rak::function1<void, const string_type&> slot_set_type;
|
||||
|
||||
template <typename SlotSet>
|
||||
VariableStringSlot(void* slotGet, SlotSet* slotSet) {
|
||||
m_slotGet.set(NULL);
|
||||
m_slotSet.set(rak::convert_fn<void, const string_type&>(slotSet));
|
||||
}
|
||||
|
||||
template <typename SlotGet, typename SlotSet>
|
||||
VariableStringSlot(SlotGet* slotGet, SlotSet* slotSet) {
|
||||
m_slotGet.set(rak::convert_fn<string_type>(slotGet));
|
||||
@@ -258,6 +264,12 @@ public:
|
||||
typedef rak::function1<string_type, core::Download*> slot_get_d_type;
|
||||
typedef rak::function2<void, core::Download*, const string_type&> slot_set_d_type;
|
||||
|
||||
template <typename SlotSetDownload>
|
||||
VariableDownloadStringSlot(void* slotGetDownload, SlotSetDownload* slotSetDownload) {
|
||||
m_slotGetDownload.set(NULL);
|
||||
m_slotSetDownload.set(rak::convert_fn<void, core::Download*, const string_type&>(slotSetDownload));
|
||||
}
|
||||
|
||||
template <typename SlotGetDownload, typename SlotSetDownload>
|
||||
VariableDownloadStringSlot(SlotGetDownload* slotGetDownload, SlotSetDownload* slotSetDownload) {
|
||||
m_slotGetDownload.set(rak::convert_fn<string_type, core::Download*>(slotGetDownload));
|
||||
|
||||
@@ -205,6 +205,35 @@ VariableMap::process_single(const char* first, const char* last) {
|
||||
return std::find_if(first, last, std::not1(variable_map_is_space()));
|
||||
}
|
||||
|
||||
const char*
|
||||
VariableMap::process_d_single(core::Download* download, const char* first, const char* last) {
|
||||
first = std::find_if(first, last, std::not1(variable_map_is_space()));
|
||||
|
||||
if (first == last || *first == '#')
|
||||
return last;
|
||||
|
||||
std::string key;
|
||||
first = parse_name(first, last, &key);
|
||||
first = std::find_if(first, last, std::not1(variable_map_is_space()));
|
||||
|
||||
if (first == last || *first != '=')
|
||||
throw torrent::input_error("Could not find '='.");
|
||||
|
||||
mapped_type args(mapped_type::TYPE_LIST);
|
||||
first = parse_args(first + 1, last, &args.as_list());
|
||||
|
||||
if (args.as_list().empty())
|
||||
set_d(download, key.c_str(), mapped_type());
|
||||
|
||||
else if (++args.as_list().begin() == args.as_list().end())
|
||||
set_d(download, key.c_str(), *args.as_list().begin());
|
||||
|
||||
else
|
||||
set_d(download, key.c_str(), args);
|
||||
|
||||
return std::find_if(first, last, std::not1(variable_map_is_space()));
|
||||
}
|
||||
|
||||
// void
|
||||
// VariableMap::process_command(const std::string& command) {
|
||||
// std::string::const_iterator pos = command.begin();
|
||||
|
||||
@@ -96,8 +96,9 @@ public:
|
||||
void set(key_type key, const mapped_type& arg);
|
||||
void set_d(core::Download* download, key_type key, const mapped_type& arg);
|
||||
|
||||
void set_string(key_type key, const std::string& arg) { set(key, mapped_type(arg)); }
|
||||
void set_d_string(core::Download* download, key_type key, const std::string& arg) { set_d(download, key, mapped_type(arg)); }
|
||||
void set_string(key_type key, const std::string& arg) { set(key, mapped_type(arg)); }
|
||||
void set_d_string(core::Download* download, key_type key, const std::string& arg) { set_d(download, key, mapped_type(arg)); }
|
||||
void set_d_std_string(core::Download* download, const std::string& key, const std::string& arg) { set_d(download, key.c_str(), mapped_type(arg)); }
|
||||
|
||||
void set_value(key_type key, mapped_value_type arg) { set(key, mapped_type(arg)); }
|
||||
void set_d_value(core::Download* download, key_type key, mapped_value_type arg) { set_d(download, key, mapped_type(arg)); }
|
||||
@@ -108,6 +109,9 @@ public:
|
||||
const char* process_single(const char* first, const char* last);
|
||||
void process_std_single(const std::string& cmd) { process_single(cmd.c_str(), cmd.c_str() + cmd.size()); }
|
||||
|
||||
const char* process_d_single(core::Download* download, const char* first, const char* last);
|
||||
void process_d_std_single(core::Download* download, const std::string& cmd) { process_d_single(download, cmd.c_str(), cmd.c_str() + cmd.size()); }
|
||||
|
||||
void process_multiple(const char* first);
|
||||
|
||||
void process_stream(std::istream* str);
|
||||
|
||||
Reference in New Issue
Block a user