mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 22:52:31 +00:00
* Moved Bencode stream functions to object_stream.h and the Bencode
class to object.h. * torrent::download_add(...) now takes an torrent::Object*. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@653 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -65,8 +65,8 @@ Download::Download(torrent::Download d) :
|
||||
rak::mem_fn(this, &Download::set_connection_current)));
|
||||
m_variables.insert("connection_leech", new utils::VariableAny(connection_type_to_string(torrent::Download::CONNECTION_LEECH)));
|
||||
m_variables.insert("connection_seed", new utils::VariableAny(connection_type_to_string(torrent::Download::CONNECTION_SEED)));
|
||||
m_variables.insert("state", new utils::VariableBencode(&m_download.bencode(), "rtorrent", "state", torrent::Bencode::TYPE_STRING));
|
||||
m_variables.insert("tied_to_file", new utils::VariableBencode(&m_download.bencode(), "rtorrent", "tied_to_file", torrent::Bencode::TYPE_STRING));
|
||||
m_variables.insert("state", new utils::VariableObject(&m_download.bencode(), "rtorrent", "state", torrent::Object::TYPE_STRING));
|
||||
m_variables.insert("tied_to_file", new utils::VariableObject(&m_download.bencode(), "rtorrent", "tied_to_file", torrent::Object::TYPE_STRING));
|
||||
|
||||
m_variables.insert("directory", new utils::VariableSlotString<>(rak::mem_fn(&m_download, &torrent::Download::root_dir),
|
||||
rak::mem_fn(this, &Download::set_root_directory)));
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public:
|
||||
torrent::Download& get_download() { return m_download; }
|
||||
const torrent::Download& get_download() const { return m_download; }
|
||||
std::string get_hash() { return m_download.info_hash(); }
|
||||
torrent::Bencode& get_bencode() { return m_download.bencode(); }
|
||||
torrent::Object& get_bencode() { return m_download.bencode(); }
|
||||
|
||||
const std::string& get_message() { return m_message; }
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/bencode.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/rate.h>
|
||||
|
||||
@@ -149,7 +149,7 @@ DownloadFactory::receive_success() {
|
||||
return;
|
||||
}
|
||||
|
||||
torrent::Bencode& root = (*itr)->get_bencode();
|
||||
torrent::Object& root = (*itr)->get_bencode();
|
||||
|
||||
if (!m_session) {
|
||||
// We only allow session torrents to keep their
|
||||
@@ -160,9 +160,9 @@ DownloadFactory::receive_success() {
|
||||
|
||||
if (!root.has_key("rtorrent") ||
|
||||
!root.get_key("rtorrent").is_map())
|
||||
root.insert_key("rtorrent", torrent::Bencode(torrent::Bencode::TYPE_MAP));
|
||||
root.insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
|
||||
|
||||
torrent::Bencode& rtorrent = root.get_key("rtorrent");
|
||||
torrent::Object& rtorrent = root.get_key("rtorrent");
|
||||
|
||||
if (!rtorrent.has_key("state") ||
|
||||
!rtorrent.get_key("state").is_string() ||
|
||||
|
||||
@@ -37,8 +37,11 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sigc++/bind.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/object_stream.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "rak/functional.h"
|
||||
@@ -63,9 +66,17 @@ struct download_list_call {
|
||||
|
||||
DownloadList::iterator
|
||||
DownloadList::insert(std::istream* str, bool printLog) {
|
||||
torrent::Object* object = new torrent::Object;
|
||||
|
||||
try {
|
||||
|
||||
torrent::Download d = torrent::download_add(str);
|
||||
*str >> *object;
|
||||
|
||||
// Catch, delete.
|
||||
if (str->fail())
|
||||
throw torrent::input_error("Could not create download, the input is not a valid torrent.");
|
||||
|
||||
torrent::Download d = torrent::download_add(object);
|
||||
|
||||
iterator itr = Base::insert(end(), new Download(d));
|
||||
|
||||
@@ -75,6 +86,8 @@ DownloadList::insert(std::istream* str, bool printLog) {
|
||||
return itr;
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
delete object;
|
||||
|
||||
if (printLog)
|
||||
control->core()->push_log(e.what());
|
||||
|
||||
|
||||
@@ -43,10 +43,11 @@
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/bencode.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/object_stream.h>
|
||||
|
||||
#include "download.h"
|
||||
#include "download_store.h"
|
||||
@@ -112,7 +113,7 @@ DownloadStore::save(Download* d) {
|
||||
// Test the new file, to ensure it is a valid bencode string.
|
||||
f.open((create_filename(d) + ".new").c_str(), std::ios::in);
|
||||
|
||||
torrent::Bencode tmp;
|
||||
torrent::Object tmp;
|
||||
f >> tmp;
|
||||
|
||||
if (!f.good())
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <torrent/bencode.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user