* Bump to version 0.11.2/0.7.2.

* Allow the user to collapse the directories with the '/' key.

* Cleanup of core::Manager::receive_hashing_changed().


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@841 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-01-05 13:27:56 +00:00
parent 3b38c4ab9c
commit 2be918261e
8 changed files with 153 additions and 101 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(rtorrent, 0.7.1, jaris@ifi.uio.no) AC_INIT(rtorrent, 0.7.2, jaris@ifi.uio.no)
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
@@ -23,7 +23,7 @@ TORRENT_WITHOUT_NCURSESW()
TORRENT_WITHOUT_STATVFS() TORRENT_WITHOUT_STATVFS()
TORRENT_WITHOUT_STATFS() TORRENT_WITHOUT_STATFS()
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.11.1, PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.11.2,
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS"; CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS") LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
+2 -1
View File
@@ -221,7 +221,8 @@ Toggle whether torrent ignores ratio settings.
<term>-></term> <term>-></term>
<listitem><para> <listitem><para>
View torrent file list. Use the space-bar to change the file priority View torrent file list. Use the space-bar to change the file priority
and <emphasis>*</emphasis> to change the priority of all files. and <emphasis>*</emphasis> to change the priority of all
files. Use <emphasis>/</emphasis> to collapse the directories. OUTDATED
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
+2 -1
View File
@@ -315,7 +315,8 @@ DownloadList::resume(Download* download) {
return; return;
} }
open_throw(download); // This will never actually do anything due to the above hash check.
// open_throw(download);
download->variable()->set("state_changed", cachedTime.seconds()); download->variable()->set("state_changed", cachedTime.seconds());
+42 -49
View File
@@ -491,65 +491,58 @@ Manager::receive_hashing_changed() {
// Try quick hashing all those with hashing == initial, set them to // Try quick hashing all those with hashing == initial, set them to
// something else when failed. // something else when failed.
for (View::iterator itr = m_hashingView->begin_visible(), last = m_hashingView->end_visible(); itr != last; ++itr) for (View::iterator itr = m_hashingView->begin_visible(), last = m_hashingView->end_visible(); itr != last; ++itr) {
try { if ((*itr)->is_hash_checked())
throw torrent::internal_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
if ((*itr)->is_hash_checking()) {
foundHashing = true;
continue;
}
if ((*itr)->is_hash_checked())
throw torrent::internal_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
if ((*itr)->is_hash_failed() || if ((*itr)->is_hash_checking()) {
(*itr)->variable()->get_value("hashing") != Download::variable_hashing_initial || foundHashing = true;
(*itr)->download()->chunks_hashed() != 0) continue;
continue; }
if ((*itr)->is_hash_failed())
continue;
bool tryQuick =
(*itr)->variable()->get_value("hashing") == Download::variable_hashing_initial &&
(*itr)->download()->file_list()->bitfield()->empty();
if (!tryQuick && foundHashing)
continue;
try {
m_downloadList->open_throw(*itr); m_downloadList->open_throw(*itr);
torrent::resume_load_progress(*(*itr)->download(), (*itr)->download()->bencode()->get_key("libtorrent_resume"));
if ((*itr)->download()->hash_check(true)) { // Since the bitfield is allocated on loading of resume load or
// Set this to exit the function so that the delayed hash done // hash start, and unallocated on close, we know that if it it
// signal gets triggered before we try any real hashing. // not empty then we have loaded any existing resume data.
foundHashing = true; if ((*itr)->download()->file_list()->bitfield()->empty())
torrent::resume_load_progress(*(*itr)->download(), (*itr)->download()->bencode()->get_key("libtorrent_resume"));
// Need to clean up the below.
if (tryQuick) {
if (!(*itr)->download()->hash_check(true))
// Temporary hack.
(*itr)->download()->hash_stop();
// Make sure we don't repeat the quick hashing.
(*itr)->variable()->set_value("hashing", Download::variable_hashing_rehash);
} else { } else {
// Temporary hack. (*itr)->download()->hash_check(false);
(*itr)->download()->hash_stop();
} }
(*itr)->variable()->set_value("hashing", Download::variable_hashing_rehash);
} catch (torrent::local_error& e) { } catch (torrent::local_error& e) {
(*itr)->set_hash_failed(true); if (tryQuick) {
push_log(e.what()); // Make sure we don't repeat the quick hashing.
} (*itr)->variable()->set_value("hashing", Download::variable_hashing_rehash);
if (foundHashing) } else {
return; (*itr)->set_hash_failed(true);
push_log(e.what());
for (View::iterator itr = m_hashingView->begin_visible(), last = m_hashingView->end_visible(); itr != last; ++itr) }
try {
if ((*itr)->is_hash_checked() || (*itr)->is_hash_checking())
throw torrent::internal_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
if ((*itr)->is_hash_failed())
continue;
m_downloadList->open_throw(*itr);
torrent::resume_load_progress(*(*itr)->download(), (*itr)->download()->bencode()->get_key("libtorrent_resume"));
(*itr)->download()->hash_check(false);
return;
} catch (torrent::local_error& e) {
(*itr)->set_hash_failed(true);
push_log(e.what());
} }
}
} }
} }
+46 -12
View File
@@ -36,23 +36,24 @@
#include "config.h" #include "config.h"
#include <stdexcept>
#include <rak/algorithm.h>
#include <torrent/path.h> #include <torrent/path.h>
#include <torrent/data/file.h> #include <torrent/data/file.h>
#include <torrent/data/file_list.h> #include <torrent/data/file_list.h>
#include <torrent/data/file_list_iterator.h> #include <torrent/data/file_list_iterator.h>
#include "core/download.h" #include "core/download.h"
#include "ui/element_file_list.h"
#include "window_file_list.h" #include "window_file_list.h"
namespace display { namespace display {
WindowFileList::WindowFileList(core::Download* d, iterator* selected) : // Don't really like the direction of the element dependency, but
// don't really feel like making a seperate class for containing the
// necessary information.
WindowFileList::WindowFileList(const ui::ElementFileList* element) :
Window(new Canvas, 0, 0, 0, extent_full, extent_full), Window(new Canvas, 0, 0, 0, extent_full, extent_full),
m_download(d), m_element(element) {
m_selected(selected) {
} }
/* /*
@@ -77,17 +78,50 @@ WindowFileList::redraw() {
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds()); m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
m_canvas->erase(); m_canvas->erase();
torrent::FileList* fl = m_download->download()->file_list(); torrent::FileList* fl = m_element->download()->download()->file_list();
if (fl->size_files() == 0 || m_canvas->height() < 2) if (fl->size_files() == 0 || m_canvas->height() < 2)
return; return;
unsigned int pos = 0; iterator entries[m_canvas->height() - 1];
iterator itr = rak::advance_bidirectional<iterator>(iterator(fl->begin()), *m_selected, iterator(fl->end()), m_canvas->height() - 1).first;
unsigned int last = 0;
for (iterator itr = m_element->selected(); last != m_canvas->height() - 1; ) {
if (m_element->is_collapsed())
itr.forward_current_depth();
else
++itr;
entries[last++] = itr;
if (itr == iterator(fl->end()))
break;
}
unsigned int first = m_canvas->height() - 1;
for (iterator itr = m_element->selected(); first >= last || first > (m_canvas->height() - 1) / 2; ) {
entries[--first] = itr;
if (itr == iterator(fl->begin()))
break;
if (m_element->is_collapsed())
itr.backward_current_depth();
else
--itr;
}
unsigned int pos = 0;
m_canvas->print(0, pos++, "Cmp Pri Size Filename"); m_canvas->print(0, pos++, "Cmp Pri Size Filename");
while (pos != m_canvas->height() && itr != iterator(fl->end())) { while (pos != m_canvas->height()) {
iterator itr = entries[first];
if (itr == iterator(fl->end()))
break;
if (itr.is_empty()) { if (itr.is_empty()) {
m_canvas->print(16, pos, "EMPTY"); m_canvas->print(16, pos, "EMPTY");
@@ -136,11 +170,11 @@ WindowFileList::redraw() {
m_canvas->print(0, pos, "BORK BORK"); m_canvas->print(0, pos, "BORK BORK");
} }
if (itr == *m_selected) if (itr == m_element->selected())
m_canvas->set_attr(0, pos, m_canvas->width(), is_focused() ? A_REVERSE : A_BOLD, COLOR_PAIR(0)); m_canvas->set_attr(0, pos, m_canvas->width(), is_focused() ? A_REVERSE : A_BOLD, COLOR_PAIR(0));
++itr; pos++;
++pos; first = (first + 1) % (m_canvas->height() - 1);
} }
} }
+9 -10
View File
@@ -37,34 +37,33 @@
#ifndef RTORRENT_DISPLAY_FILE_LIST_H #ifndef RTORRENT_DISPLAY_FILE_LIST_H
#define RTORRENT_DISPLAY_FILE_LIST_H #define RTORRENT_DISPLAY_FILE_LIST_H
#include <list>
#include "window.h" #include "window.h"
namespace ui {
class ElementFileList;
}
namespace torrent { namespace torrent {
class File; class File;
class FileListIterator; class FileListIterator;
} class file_list_collapsed_iterator;
namespace core {
class Download;
} }
namespace display { namespace display {
class WindowFileList : public Window { class WindowFileList : public Window {
public: public:
typedef torrent::FileListIterator iterator; typedef torrent::FileListIterator iterator;
typedef torrent::file_list_collapsed_iterator collapsed_iterator;
WindowFileList(core::Download* d, iterator* selected); WindowFileList(const ui::ElementFileList* element);
virtual void redraw(); virtual void redraw();
private: private:
int done_percentage(torrent::File* e); int done_percentage(torrent::File* e);
core::Download* m_download; const ui::ElementFileList* m_element;
iterator* m_selected;
}; };
} }
+40 -24
View File
@@ -62,13 +62,15 @@ ElementFileList::ElementFileList(core::Download* d) :
m_window(NULL), m_window(NULL),
m_elementInfo(NULL), m_elementInfo(NULL),
m_selected(iterator(d->download()->file_list()->begin())) { m_selected(iterator(d->download()->file_list()->begin())),
m_collapsed(false) {
m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = sigc::mem_fun(&m_slotExit, &slot_type::operator()); m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = sigc::mem_fun(&m_slotExit, &slot_type::operator());
m_bindings[KEY_RIGHT] = m_bindings['F' - '@'] = sigc::bind(sigc::mem_fun(this, &ElementFileList::activate_display), DISPLAY_INFO); m_bindings[KEY_RIGHT] = m_bindings['F' - '@'] = sigc::mem_fun(*this, &ElementFileList::receive_select);
m_bindings[' '] = sigc::mem_fun(*this, &ElementFileList::receive_priority); m_bindings[' '] = sigc::mem_fun(*this, &ElementFileList::receive_priority);
m_bindings['*'] = sigc::mem_fun(*this, &ElementFileList::receive_change_all); m_bindings['*'] = sigc::mem_fun(*this, &ElementFileList::receive_change_all);
m_bindings['/'] = sigc::mem_fun(*this, &ElementFileList::receive_collapse);
m_bindings[KEY_NPAGE] = sigc::mem_fun(*this, &ElementFileList::receive_pagenext); m_bindings[KEY_NPAGE] = sigc::mem_fun(*this, &ElementFileList::receive_pagenext);
m_bindings[KEY_PPAGE] = sigc::mem_fun(*this, &ElementFileList::receive_pageprev); m_bindings[KEY_PPAGE] = sigc::mem_fun(*this, &ElementFileList::receive_pageprev);
@@ -119,7 +121,7 @@ ElementFileList::activate(display::Frame* frame, bool focus) {
if (focus) if (focus)
control->input()->push_back(&m_bindings); control->input()->push_back(&m_bindings);
m_window = new WFileList(m_download, &m_selected); m_window = new WFileList(this);
m_window->set_active(true); m_window->set_active(true);
m_window->set_focused(focus); m_window->set_focused(focus);
@@ -193,7 +195,12 @@ void
ElementFileList::receive_next() { ElementFileList::receive_next() {
torrent::FileList* fl = m_download->download()->file_list(); torrent::FileList* fl = m_download->download()->file_list();
if (m_selected == iterator(fl->end()) || ++m_selected == iterator(fl->end())) if (is_collapsed())
m_selected.forward_current_depth();
else
m_selected++;
if (m_selected == iterator(fl->end()))
m_selected = iterator(fl->begin()); m_selected = iterator(fl->begin());
update_itr(); update_itr();
@@ -206,7 +213,11 @@ ElementFileList::receive_prev() {
if (m_selected == iterator(fl->begin())) if (m_selected == iterator(fl->begin()))
m_selected = iterator(fl->end()); m_selected = iterator(fl->end());
m_selected--; if (is_collapsed())
m_selected.backward_current_depth();
else
m_selected--;
update_itr(); update_itr();
} }
@@ -230,7 +241,7 @@ ElementFileList::receive_pagenext() {
void void
ElementFileList::receive_pageprev() { ElementFileList::receive_pageprev() {
if (m_window == NULL) if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_pageprev(...) called on a disabled object"); return;
torrent::FileList* fl = m_download->download()->file_list(); torrent::FileList* fl = m_download->download()->file_list();
@@ -242,33 +253,29 @@ ElementFileList::receive_pageprev() {
update_itr(); update_itr();
} }
// Take a range as input and return the next entry at the same void
// directory depth as first. If the returned iterator equals 'last' or ElementFileList::receive_select() {
// is_leaving() == true then the search failed. UHM... wrong... if (m_window == NULL || m_state != DISPLAY_LIST)
return;
torrent::FileListIterator if (is_collapsed() && !m_selected.is_file()) {
next_current_depth(torrent::FileListIterator first, torrent::FileListIterator last) { m_selected++;
if (first == last) m_window->mark_dirty();
return first; } else {
activate_display(DISPLAY_INFO);
uint32_t depth = (first++).depth(); }
while (first != last && (first.depth() > depth || first.is_leaving()))
++first;
return first;
} }
void void
ElementFileList::receive_priority() { ElementFileList::receive_priority() {
if (m_window == NULL) if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object"); return;
torrent::FileList* fl = m_download->download()->file_list();
torrent::priority_t priority = torrent::priority_t((m_selected.file()->priority() + 2) % 3); torrent::priority_t priority = torrent::priority_t((m_selected.file()->priority() + 2) % 3);
iterator first = m_selected; iterator first = m_selected;
iterator last = next_current_depth(m_selected, iterator(fl->end())); iterator last = m_selected;
last.forward_current_depth();
while (first != last) { while (first != last) {
if (first.is_file()) if (first.is_file())
@@ -284,7 +291,7 @@ ElementFileList::receive_priority() {
void void
ElementFileList::receive_change_all() { ElementFileList::receive_change_all() {
if (m_window == NULL) if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object"); return;
torrent::FileList* fl = m_download->download()->file_list(); torrent::FileList* fl = m_download->download()->file_list();
torrent::priority_t priority = torrent::priority_t((m_selected.file()->priority() + 2) % 3); torrent::priority_t priority = torrent::priority_t((m_selected.file()->priority() + 2) % 3);
@@ -296,6 +303,15 @@ ElementFileList::receive_change_all() {
update_itr(); update_itr();
} }
void
ElementFileList::receive_collapse() {
if (m_window == NULL)
return;
set_collapsed(!is_collapsed());
m_window->mark_dirty();
}
void void
ElementFileList::update_itr() { ElementFileList::update_itr() {
m_window->mark_dirty(); m_window->mark_dirty();
+10 -2
View File
@@ -44,8 +44,6 @@
#include "element_base.h" #include "element_base.h"
class Control;
namespace display { namespace display {
class WindowFileList; class WindowFileList;
} }
@@ -72,14 +70,23 @@ public:
void activate_display(Display display); void activate_display(Display display);
bool is_collapsed() const { return m_collapsed; }
void set_collapsed(bool s) { m_collapsed = s; }
iterator selected() const { return m_selected; }
core::Download* download() const { return m_download; }
private: private:
void receive_next(); void receive_next();
void receive_prev(); void receive_prev();
void receive_pagenext(); void receive_pagenext();
void receive_pageprev(); void receive_pageprev();
void receive_select();
void receive_priority(); void receive_priority();
void receive_change_all(); void receive_change_all();
void receive_collapse();
void update_itr(); void update_itr();
@@ -91,6 +98,7 @@ private:
// Change to unsigned, please. // Change to unsigned, please.
iterator m_selected; iterator m_selected;
bool m_collapsed;
}; };
} }