mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
* Allow a list of commands to be called on a newly created download
before it is started. * The "load_*" commands now allow a list of commands to be appended. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@941 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -230,6 +230,8 @@ DownloadFactory::receive_success() {
|
||||
return;
|
||||
}
|
||||
|
||||
std::for_each(m_commands.begin(), m_commands.end(), rak::bind1st(std::ptr_fun(&rpc::parse_command_d_multiple_std), download));
|
||||
|
||||
// When a download scheduler is implemented, this is handled by the
|
||||
// above insertion into download list.
|
||||
if (m_session) {
|
||||
|
||||
@@ -55,6 +55,7 @@ class Manager;
|
||||
class DownloadFactory {
|
||||
public:
|
||||
typedef sigc::slot<void> Slot;
|
||||
typedef std::vector<std::string> command_list_type;
|
||||
|
||||
// Do not destroy this object while it is in a HttpQueue.
|
||||
DownloadFactory(const std::string& uri, Manager* m);
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
void load();
|
||||
void commit();
|
||||
|
||||
command_list_type& commands() { return m_commands; }
|
||||
torrent::Object::map_type& variables() { return m_variables; }
|
||||
|
||||
bool get_session() const { return m_session; }
|
||||
@@ -99,6 +101,7 @@ private:
|
||||
bool m_start;
|
||||
bool m_printLog;
|
||||
|
||||
command_list_type m_commands;
|
||||
torrent::Object::map_type m_variables;
|
||||
|
||||
Slot m_slotFinished;
|
||||
|
||||
+9
-8
@@ -395,14 +395,15 @@ Manager::receive_http_failed(std::string msg) {
|
||||
}
|
||||
|
||||
void
|
||||
Manager::try_create_download(const std::string& uri, bool start, bool printLog, bool tied) {
|
||||
Manager::try_create_download(const std::string& uri, int flags, const command_list_type& commands) {
|
||||
// Adding download.
|
||||
DownloadFactory* f = new DownloadFactory(uri, this);
|
||||
|
||||
f->variables()["tied_to_file"] = (int64_t)tied;
|
||||
f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied);
|
||||
f->commands().insert(f->commands().end(), commands.begin(), commands.end());
|
||||
|
||||
f->set_start(start);
|
||||
f->set_print_log(printLog);
|
||||
f->set_start(flags & create_start);
|
||||
f->set_print_log(!(flags & create_quiet));
|
||||
f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f));
|
||||
f->load();
|
||||
f->commit();
|
||||
@@ -463,13 +464,13 @@ manager_equal_tied(const std::string& path, Download* download) {
|
||||
}
|
||||
|
||||
void
|
||||
Manager::try_create_download_expand(const std::string& uri, bool start, bool printLog, bool tied) {
|
||||
Manager::try_create_download_expand(const std::string& uri, int flags, command_list_type commands) {
|
||||
std::vector<std::string> paths;
|
||||
paths.reserve(256);
|
||||
|
||||
path_expand(&paths, uri);
|
||||
|
||||
if (tied)
|
||||
if (flags & create_tied)
|
||||
for (std::vector<std::string>::iterator itr = paths.begin(); itr != paths.end(); )
|
||||
if (std::find_if(m_downloadList->begin(), m_downloadList->end(), rak::bind1st(std::ptr_fun(&manager_equal_tied), *itr))
|
||||
!= m_downloadList->end())
|
||||
@@ -479,10 +480,10 @@ Manager::try_create_download_expand(const std::string& uri, bool start, bool pri
|
||||
|
||||
if (!paths.empty())
|
||||
for (std::vector<std::string>::iterator itr = paths.begin(); itr != paths.end(); ++itr)
|
||||
try_create_download(*itr, start, printLog, tied);
|
||||
try_create_download(*itr, flags, commands);
|
||||
|
||||
else
|
||||
try_create_download(uri, start, printLog, tied);
|
||||
try_create_download(uri, flags, commands);
|
||||
}
|
||||
|
||||
// DownloadList's hashing related functions don't actually start the
|
||||
|
||||
+9
-2
@@ -38,6 +38,7 @@
|
||||
#define RTORRENT_CORE_MANAGER_H
|
||||
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
#include "download_list.h"
|
||||
#include "poll_manager.h"
|
||||
@@ -98,9 +99,15 @@ public:
|
||||
|
||||
void handshake_log(const sockaddr* sa, int msg, int err, const torrent::HashString* hash);
|
||||
|
||||
static const int create_start = 0x1;
|
||||
static const int create_tied = 0x2;
|
||||
static const int create_quiet = 0x4;
|
||||
|
||||
typedef std::vector<std::string> command_list_type;
|
||||
|
||||
// Temporary, find a better place for this.
|
||||
void try_create_download(const std::string& uri, bool start, bool printLog = true, bool tied = false);
|
||||
void try_create_download_expand(const std::string& uri, bool start, bool printLog = true, bool tied = false);
|
||||
void try_create_download(const std::string& uri, int flags, const command_list_type& commands);
|
||||
void try_create_download_expand(const std::string& uri, int flags, command_list_type commands = command_list_type());
|
||||
|
||||
private:
|
||||
void create_http(const std::string& uri);
|
||||
|
||||
Reference in New Issue
Block a user