* Added support for XMLRPC_TYPE_BASE64.

* Added 'load_raw*' commands for loading torrents directly from the
data passed through the first argument.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@964 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-08-24 12:30:29 +00:00
parent 85d14f0e96
commit c6a43429a2
7 changed files with 58 additions and 17 deletions
+14 -4
View File
@@ -61,13 +61,12 @@
namespace core {
DownloadFactory::DownloadFactory(const std::string& uri, Manager* m) :
DownloadFactory::DownloadFactory(Manager* m) :
m_manager(m),
m_stream(NULL),
m_commited(false),
m_loaded(false),
m_uri(uri),
m_session(false),
m_start(false),
m_printLog(true) {
@@ -90,10 +89,21 @@ DownloadFactory::~DownloadFactory() {
}
void
DownloadFactory::load() {
DownloadFactory::load(const std::string& uri) {
m_uri = uri;
priority_queue_insert(&taskScheduler, &m_taskLoad, cachedTime);
}
// This function must be called before DownloadFactory::commit().
void
DownloadFactory::load_raw_data(const std::string& input) {
if (m_stream)
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
m_stream = new std::stringstream(input);
m_loaded = true;
}
void
DownloadFactory::commit() {
priority_queue_insert(&taskScheduler, &m_taskCommit, cachedTime);
@@ -102,7 +112,7 @@ DownloadFactory::commit() {
void
DownloadFactory::receive_load() {
if (m_stream)
throw torrent::internal_error("DownloadFactory::load() called on an object with m_stream != NULL");
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
if (std::strncmp(m_uri.c_str(), "http://", 7) == 0 ||
std::strncmp(m_uri.c_str(), "https://", 8) == 0 ||
+3 -2
View File
@@ -58,13 +58,14 @@ public:
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);
DownloadFactory(Manager* m);
~DownloadFactory();
// Calling of receive_load() is delayed so you can change whatever
// you want without fear of the slots being triggered as you call
// load() or commit().
void load();
void load(const std::string& uri);
void load_raw_data(const std::string& input);
void commit();
command_list_type& commands() { return m_commands; }
+12 -2
View File
@@ -397,7 +397,7 @@ Manager::receive_http_failed(std::string msg) {
void
Manager::try_create_download(const std::string& uri, int flags, const command_list_type& commands) {
// Adding download.
DownloadFactory* f = new DownloadFactory(uri, this);
DownloadFactory* f = new DownloadFactory(this);
f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied);
f->commands().insert(f->commands().end(), commands.begin(), commands.end());
@@ -405,7 +405,12 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
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();
if (flags & create_raw_data)
f->load_raw_data(uri);
else
f->load(uri);
f->commit();
}
@@ -465,6 +470,11 @@ manager_equal_tied(const std::string& path, Download* download) {
void
Manager::try_create_download_expand(const std::string& uri, int flags, command_list_type commands) {
if (flags & create_raw_data) {
try_create_download(uri, flags, commands);
return;
}
std::vector<std::string> paths;
paths.reserve(256);
+4 -3
View File
@@ -99,9 +99,10 @@ 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;
static const int create_start = 0x1;
static const int create_tied = 0x2;
static const int create_quiet = 0x4;
static const int create_raw_data = 0x8;
typedef std::vector<std::string> command_list_type;