mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 12:42:31 +00:00
Cleaned up option_handler_rules.*, it now uses the slot_map_* properly.
Erases the screen upon quit. Added option for checking the hash for completed downloads. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@471 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -39,6 +39,13 @@ Download::set_download(torrent::Download d) {
|
||||
m_connStorageError = m_download.signal_storage_error(sigc::mem_fun(*this, &Download::receive_tracker_msg));
|
||||
}
|
||||
|
||||
void
|
||||
Download::set_root_directory(const std::string& d) {
|
||||
m_download.set_root_dir(d +
|
||||
(!d.empty() && *d.rbegin() != '/' ? "/" : "") +
|
||||
(m_download.get_entry_size() > 1 ? m_download.get_name() : ""));
|
||||
}
|
||||
|
||||
void
|
||||
Download::release_download() {
|
||||
m_connTrackerSucceded.disconnect();
|
||||
|
||||
+12
-7
@@ -31,7 +31,7 @@ namespace core {
|
||||
class Download {
|
||||
public:
|
||||
bool is_open() { return m_download.is_open(); }
|
||||
bool is_done() { return m_download.get_chunks_done() == m_download.get_chunks_total(); }
|
||||
inline bool is_done();
|
||||
|
||||
void set_download(torrent::Download d);
|
||||
void release_download();
|
||||
@@ -41,15 +41,15 @@ public:
|
||||
|
||||
const std::string& get_message() { return m_message; }
|
||||
|
||||
void start() { m_download.start(); }
|
||||
void stop() { m_download.stop(); }
|
||||
void set_root_directory(const std::string& d);
|
||||
|
||||
void open() { m_download.open(); }
|
||||
void close() { m_download.close(); }
|
||||
template <typename Ret, Ret (torrent::Download::*func)()>
|
||||
void call() { (m_download.*func)(); }
|
||||
|
||||
void hash_resume_save() { m_download.hash_resume_save(); }
|
||||
template <typename Ret, typename Arg1, Ret (torrent::Download::*func)(Arg1)>
|
||||
void call(Arg1 a1) { (m_download.*func)(a1); }
|
||||
|
||||
bool operator == (const std::string& str) { return str == m_download.get_hash(); }
|
||||
bool operator == (const std::string& str) { return str == m_download.get_hash(); }
|
||||
|
||||
private:
|
||||
void receive_tracker_msg(std::string msg);
|
||||
@@ -64,6 +64,11 @@ private:
|
||||
sigc::connection m_connStorageError;
|
||||
};
|
||||
|
||||
inline bool
|
||||
Download::is_done() {
|
||||
return m_download.get_chunks_done() == m_download.get_chunks_total();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -57,6 +57,40 @@ DownloadList::erase(iterator itr) {
|
||||
return Base::erase(itr);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::open(Download* d) {
|
||||
if (d->get_download().is_open())
|
||||
return;
|
||||
|
||||
m_slotMapOpen.for_each(d);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::close(Download* d) {
|
||||
if (!d->get_download().is_open())
|
||||
return;
|
||||
|
||||
stop(d);
|
||||
m_slotMapClose.for_each(d);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::start(Download* d) {
|
||||
if (d->get_download().is_active())
|
||||
return;
|
||||
|
||||
open(d);
|
||||
m_slotMapStart.for_each(d);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::stop(Download* d) {
|
||||
if (!d->get_download().is_active())
|
||||
return;
|
||||
|
||||
m_slotMapStop.for_each(d);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::clear() {
|
||||
std::for_each(begin(), end(), rak::call_delete<Download>());
|
||||
|
||||
@@ -56,11 +56,11 @@ public:
|
||||
iterator insert(std::istream* str);
|
||||
iterator erase(iterator itr);
|
||||
|
||||
void open(Download* d) { m_slotMapOpen.for_each(d); }
|
||||
void close(Download* d) { m_slotMapClose.for_each(d); }
|
||||
void open(Download* d);
|
||||
void close(Download* d);
|
||||
|
||||
void start(Download* d) { m_slotMapStart.for_each(d); }
|
||||
void stop(Download* d) { m_slotMapStop.for_each(d); }
|
||||
void start(Download* d);
|
||||
void stop(Download* d);
|
||||
|
||||
DownloadSlotMap& slot_map_insert() { return m_slotMapInsert; }
|
||||
DownloadSlotMap& slot_map_erase() { return m_slotMapErase; }
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
typedef std::map<std::string, SlotDownload> Base;
|
||||
|
||||
void insert(const std::string& key, SlotDownload s) { Base::operator[](key) = s; }
|
||||
void erase(const std::string& key) {}
|
||||
|
||||
void for_each(Download* d);
|
||||
};
|
||||
|
||||
+9
-13
@@ -56,27 +56,26 @@ Manager::initialize() {
|
||||
|
||||
// Register slots to be called when a download is inserted/erased,
|
||||
// opened or closed.
|
||||
m_downloadList.slot_map_insert().insert("1_connect_network_log", sigc::bind(sigc::ptr_fun(&connect_signal_network_log), sigc::mem_fun(m_logComplete, &Log::push_front)));
|
||||
m_downloadList.slot_map_insert().insert("2_manager_start", sigc::mem_fun(*this, &Manager::start));
|
||||
m_downloadList.slot_map_insert().insert("3_store_save", sigc::mem_fun(m_downloadStore, &DownloadStore::save));
|
||||
m_downloadList.slot_map_insert().insert("2_connect_network_log", sigc::bind(sigc::ptr_fun(&connect_signal_network_log), sigc::mem_fun(m_logComplete, &Log::push_front)));
|
||||
m_downloadList.slot_map_insert().insert("3_manager_start", sigc::mem_fun(*this, &Manager::start));
|
||||
m_downloadList.slot_map_insert().insert("4_store_save", sigc::mem_fun(m_downloadStore, &DownloadStore::save));
|
||||
|
||||
m_downloadList.slot_map_erase().insert("1_hash_queue_remove", sigc::mem_fun(m_hashQueue, &HashQueue::remove));
|
||||
m_downloadList.slot_map_erase().insert("1_store_remove", sigc::mem_fun(m_downloadStore, &DownloadStore::remove));
|
||||
|
||||
m_downloadList.slot_map_open().insert("1_download_open", sigc::mem_fun(&Download::open));
|
||||
//m_downloadList.slot_map_open().insert("1_download_open", sigc::mem_fun(&Download::open));
|
||||
m_downloadList.slot_map_open().insert("1_download_open", sigc::mem_fun(&Download::call<void, &torrent::Download::open>));
|
||||
|
||||
// Currently does not call stop, might want to add a function that
|
||||
// checks if we're running, and if so stop?
|
||||
m_downloadList.slot_map_close().insert("1_download_close", sigc::mem_fun(&Download::close));
|
||||
m_downloadList.slot_map_close().insert("1_download_close", sigc::mem_fun(&Download::call<void, &torrent::Download::close>));
|
||||
m_downloadList.slot_map_close().insert("1_hash_queue_remove", sigc::mem_fun(m_hashQueue, &HashQueue::remove));
|
||||
|
||||
m_downloadList.slot_map_start().insert("1_download_start", sigc::mem_fun(&Download::start));
|
||||
m_downloadList.slot_map_start().insert("1_download_start", sigc::mem_fun(&Download::call<void, &torrent::Download::start>));
|
||||
|
||||
m_downloadList.slot_map_stop().insert("1_download_stop", sigc::mem_fun(&Download::stop));
|
||||
m_downloadList.slot_map_stop().insert("2_hash_resume_save", sigc::mem_fun(&Download::hash_resume_save));
|
||||
m_downloadList.slot_map_stop().insert("1_download_stop", sigc::mem_fun(&Download::call<void, &torrent::Download::stop>));
|
||||
m_downloadList.slot_map_stop().insert("2_hash_resume_save", sigc::mem_fun(&Download::call<void, &torrent::Download::hash_resume_save>));
|
||||
m_downloadList.slot_map_stop().insert("3_store_save", sigc::mem_fun(m_downloadStore, &DownloadStore::save));
|
||||
|
||||
//m_downloadList.slot_map_finished().insert("1_check_hash", sigc::mem_fun(*this, &Manager::check_hash));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -146,9 +145,6 @@ Manager::check_hash(Download* d) {
|
||||
bool restart = d->get_download().is_active();
|
||||
|
||||
try {
|
||||
if (d->get_download().is_active())
|
||||
m_downloadList.stop(d);
|
||||
|
||||
m_downloadList.close(d);
|
||||
d->get_download().hash_resume_clear();
|
||||
m_downloadList.open(d);
|
||||
|
||||
Reference in New Issue
Block a user