diff --git a/src/core/download.cc b/src/core/download.cc index cf6158b1..fff2e5f7 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -227,7 +227,7 @@ Download::priority_to_string(uint32_t p) { float Download::distributed_copies() const { const uint8_t* avail = m_download.chunks_seen(); - const uint8_t* end = avail + m_download.chunks_total(); + const uint8_t* end = avail + m_download.file_list()->size_chunks(); if (avail == NULL) return 0; @@ -243,7 +243,7 @@ Download::distributed_copies() const { num = 1; } - return minAvail + 1 - (float)num / m_download.chunks_total(); + return minAvail + 1 - (float)num / m_download.file_list()->size_chunks(); } void diff --git a/src/core/download.h b/src/core/download.h index a42fae42..17417823 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -43,6 +43,7 @@ #include #include #include +#include #include "utils/variable_map.h" @@ -66,7 +67,7 @@ public: bool is_open() const { return m_download.is_open(); } bool is_active() const { return m_download.is_active(); } - bool is_done() const { return m_download.chunks_done() == m_download.chunks_total(); } + bool is_done() const { return m_download.file_list()->is_done(); } bool is_downloading() const { return is_active() && !is_done(); } bool is_seeding() const { return is_active() && is_done(); } diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index 535e4ac5..0c6076d9 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -296,7 +296,7 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre download->download()->up_rate()->set_total(rtorrent->get_key_value("total_uploaded")); if (rtorrent->has_key_value("chunks_done")) - download->download()->set_chunks_done(std::min(rtorrent->get_key_value("chunks_done"), download->download()->chunks_total())); + download->download()->set_chunks_done(std::min(rtorrent->get_key_value("chunks_done"), download->download()->file_list()->completed_chunks())); if (!rtorrent->has_key_value("ignore_commands")) rtorrent->insert_key("ignore_commands", (int64_t)0); diff --git a/src/core/download_store.cc b/src/core/download_store.cc index 54d75ad7..dcc774bf 100644 --- a/src/core/download_store.cc +++ b/src/core/download_store.cc @@ -107,7 +107,7 @@ DownloadStore::save(Download* d) { // Move this somewhere else? d->bencode()->get_key("rtorrent").insert_key("total_uploaded", d->download()->up_rate()->total()); - d->bencode()->get_key("rtorrent").insert_key("chunks_done", d->download()->chunks_done()); + d->bencode()->get_key("rtorrent").insert_key("chunks_done", d->download()->file_list()->completed_chunks()); torrent::Object& resumeObject = d->download()->bencode()->get_key("libtorrent_resume"); diff --git a/src/display/utils.cc b/src/display/utils.cc index c097d555..11b01253 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -181,7 +181,7 @@ print_download_status(char* first, char* last, core::Download* d) { if (d->is_hash_checking()) { first = print_buffer(first, last, "Checking hash [%2i%%]", - (d->download()->chunks_hashed() * 100) / d->download()->chunks_total()); + (d->download()->chunks_hashed() * 100) / d->download()->file_list()->size_chunks()); } else if (d->tracker_list()->is_busy() && d->tracker_list()->focus() < d->tracker_list()->size()) { torrent::TrackerList* tl = d->tracker_list(); @@ -220,7 +220,7 @@ print_download_percentage_done(char* first, char* last, core::Download* d) { //return print_buffer(first, last, "[--%%]"); return print_buffer(first, last, " "); else - return print_buffer(first, last, "[%2u%%]", (d->download()->chunks_done() * 100) / d->download()->chunks_total()); + return print_buffer(first, last, "[%2u%%]", (d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks()); } char* diff --git a/src/display/window_download_chunks_seen.cc b/src/display/window_download_chunks_seen.cc index 9f61de8e..a447d488 100644 --- a/src/display/window_download_chunks_seen.cc +++ b/src/display/window_download_chunks_seen.cc @@ -73,7 +73,7 @@ WindowDownloadChunksSeen::redraw() { const uint8_t* seen = m_download->download()->chunks_seen(); - if (seen == NULL || m_download->download()->bitfield()->empty()) { + if (seen == NULL || m_download->download()->file_list()->bitfield()->empty()) { m_canvas->print(2, 2, "Not available."); return; } @@ -88,9 +88,9 @@ WindowDownloadChunksSeen::redraw() { *m_focus = std::min(*m_focus, max_focus()); const uint8_t* chunk = seen + *m_focus * chunks_per_row(); - const uint8_t* last = seen + m_download->download()->chunks_total(); + const uint8_t* last = seen + m_download->download()->file_list()->size_chunks(); - const torrent::Bitfield* bitfield = m_download->download()->bitfield(); + const torrent::Bitfield* bitfield = m_download->download()->file_list()->bitfield(); const torrent::TransferList* transfers = m_download->download()->transfer_list(); std::vector transferChunks(transfers->size(), 0); @@ -138,7 +138,7 @@ WindowDownloadChunksSeen::rows() const { if (m_canvas->width() < 18) return 0; - return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row(); + return (m_download->download()->file_list()->size_chunks() + chunks_per_row() - 1) / chunks_per_row(); } } diff --git a/src/display/window_file_list.cc b/src/display/window_file_list.cc index 7a6bd771..d1e0f627 100644 --- a/src/display/window_file_list.cc +++ b/src/display/window_file_list.cc @@ -98,7 +98,7 @@ WindowFileList::redraw() { Range range = rak::advance_bidirectional(0, *m_focus, fl->size_files(), m_canvas->height() - pos); while (range.first != range.second) { - torrent::File* e = fl->at_index(range.first); + torrent::File* e = *(fl->begin() + range.first); std::string path = e->path()->as_string(); diff --git a/src/display/window_peer_list.cc b/src/display/window_peer_list.cc index dd29471d..912c4a20 100644 --- a/src/display/window_peer_list.cc +++ b/src/display/window_peer_list.cc @@ -91,7 +91,7 @@ WindowPeerList::redraw() { m_list->end(), m_canvas->height() - y); - if (m_download->download()->chunks_total() <= 0) + if (m_download->download()->file_list()->size_chunks() <= 0) throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value"); while (range.first != range.second) { @@ -151,7 +151,7 @@ WindowPeerList::redraw() { int WindowPeerList::done_percentage(torrent::Peer& p) { - int chunks = m_download->download()->chunks_total(); + int chunks = m_download->download()->file_list()->size_chunks(); return chunks ? (100 * p.chunks_done()) / chunks : 0; } diff --git a/src/ui/download.cc b/src/ui/download.cc index a7dd62d4..79f59743 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -157,7 +157,7 @@ Download::create_info() { element->push_column("Tied to file:", te_variable_string("tied_to_file")); element->push_back(""); - element->push_column("Chunks:", te_value(&torrent::Download::chunks_done), " / ", te_value(&torrent::Download::chunks_total), " * ", te_value(&torrent::Download::chunks_size)); + element->push_column("Chunks:", te_value(&torrent::FileList::completed_chunks), " / ", te_value(&torrent::FileList::size_chunks), " * ", te_value(&torrent::FileList::chunk_size)); element->push_column("Priority:", te_variable_value("priority")); element->push_column("State changed:", te_variable_value("state_changed", value_base::flag_timer | value_base::flag_elapsed)); diff --git a/src/ui/element_file_list.cc b/src/ui/element_file_list.cc index 6166a000..f8131a55 100644 --- a/src/ui/element_file_list.cc +++ b/src/ui/element_file_list.cc @@ -181,7 +181,7 @@ ElementFileList::receive_priority() { if (m_focus >= fl->size_files()) return; - torrent::File* file = fl->at_index(m_focus); + torrent::File* file = *(fl->begin() + m_focus); file->set_priority(next_priority(file->priority())); @@ -199,10 +199,10 @@ ElementFileList::receive_change_all() { if (m_focus >= fl->size_files()) return; - Priority p = next_priority(fl->at_index(m_focus)->priority()); + Priority p = next_priority((*(fl->begin() + m_focus))->priority()); - for (int i = 0, last = fl->size_files(); i != last; ++i) - fl->at_index(i)->set_priority(p); + for (torrent::FileList::iterator itr = fl->begin(), last = fl->end(); itr != last; ++itr) + (*itr)->set_priority(p); m_download->download()->update_priorities(); m_window->mark_dirty();