mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-14 13:16:17 +00:00
Added changing of the file priorities.
Seperated the algorithm extensions from functional. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@326 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -40,7 +40,7 @@ In torrent view:
|
|||||||
|
|
||||||
Left - Back to main
|
Left - Back to main
|
||||||
|
|
||||||
Right - View peer
|
Right - View files
|
||||||
|
|
||||||
1 - Decrease max uploads
|
1 - Decrease max uploads
|
||||||
2 - Increase max uploads
|
2 - Increase max uploads
|
||||||
@@ -51,4 +51,12 @@ In torrent view:
|
|||||||
5 - Decrease max peers connected
|
5 - Decrease max peers connected
|
||||||
6 - Increase max peers connected
|
6 - Increase max peers connected
|
||||||
|
|
||||||
T - Query tracker
|
T - Query tracker
|
||||||
|
|
||||||
|
In file view:
|
||||||
|
|
||||||
|
Up/Down - Select file
|
||||||
|
|
||||||
|
Left - Back to torrent view
|
||||||
|
|
||||||
|
SpaceBar - Change file priority
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ CurlStack::perform() {
|
|||||||
CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &t);
|
CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &t);
|
||||||
|
|
||||||
CurlGetList::iterator itr = std::find_if(m_getList.begin(), m_getList.end(),
|
CurlGetList::iterator itr = std::find_if(m_getList.begin(), m_getList.end(),
|
||||||
func::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
utils::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
||||||
|
|
||||||
if (itr == m_getList.end())
|
if (itr == m_getList.end())
|
||||||
throw torrent::client_error("Could not find CurlGet with the right easy_handle");
|
throw torrent::client_error("Could not find CurlGet with the right easy_handle");
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ DownloadList::erase(iterator itr) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::clear() {
|
DownloadList::clear() {
|
||||||
std::for_each(begin(), end(), func::call_delete<Download>());
|
std::for_each(begin(), end(), utils::call_delete<Download>());
|
||||||
|
|
||||||
Base::clear();
|
Base::clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ HashQueue::insert(Download* d, Slot s) {
|
|||||||
if (d->get_download().is_hash_checking())
|
if (d->get_download().is_hash_checking())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (std::find_if(begin(), end(), func::equal(d, std::mem_fun(&HashQueueNode::get_download))) != end())
|
if (std::find_if(begin(), end(), utils::equal(d, std::mem_fun(&HashQueueNode::get_download))) != end())
|
||||||
throw std::logic_error("core::HashQueue::insert(...) received a Download that is already queued");
|
throw std::logic_error("core::HashQueue::insert(...) received a Download that is already queued");
|
||||||
|
|
||||||
if (d->get_download().is_hash_checked()) {
|
if (d->get_download().is_hash_checked()) {
|
||||||
@@ -32,7 +32,7 @@ HashQueue::insert(Download* d, Slot s) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
HashQueue::remove(Download* d) {
|
HashQueue::remove(Download* d) {
|
||||||
iterator itr = std::find_if(begin(), end(), func::equal(d, std::mem_fun(&HashQueueNode::get_download)));
|
iterator itr = std::find_if(begin(), end(), utils::equal(d, std::mem_fun(&HashQueueNode::get_download)));
|
||||||
|
|
||||||
if (itr == end())
|
if (itr == end())
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ Log::push_front(const std::string& msg) {
|
|||||||
Log::iterator
|
Log::iterator
|
||||||
Log::find_older(utils::Timer t) {
|
Log::find_older(utils::Timer t) {
|
||||||
return std::find_if(begin(), end(),
|
return std::find_if(begin(), end(),
|
||||||
func::on(func::mem_ptr_ref(&Type::first), std::bind2nd(std::less_equal<utils::Timer>(), t)));
|
utils::on(utils::mem_ptr_ref(&Type::first), std::bind2nd(std::less_equal<utils::Timer>(), t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ Manager::adjust_layout() {
|
|||||||
int countDynamic = 0;
|
int countDynamic = 0;
|
||||||
int staticHeight = 0;
|
int staticHeight = 0;
|
||||||
|
|
||||||
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), func::accumulate(staticHeight, std::mem_fun(&Window::get_min_height))));
|
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), utils::accumulate(staticHeight, std::mem_fun(&Window::get_min_height))));
|
||||||
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), func::accumulate(countDynamic, std::mem_fun(&Window::is_dynamic))));
|
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), utils::accumulate(countDynamic, std::mem_fun(&Window::is_dynamic))));
|
||||||
|
|
||||||
int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight);
|
int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight);
|
||||||
int height = 0, h;
|
int height = 0, h;
|
||||||
@@ -56,9 +56,9 @@ void
|
|||||||
Manager::do_update() {
|
Manager::do_update() {
|
||||||
Canvas::refresh_std();
|
Canvas::refresh_std();
|
||||||
|
|
||||||
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), func::if_then(std::mem_fun(&Window::is_dirty),
|
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), utils::if_then(std::mem_fun(&Window::is_dirty),
|
||||||
std::mem_fun(&Window::redraw))));
|
std::mem_fun(&Window::redraw))));
|
||||||
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
||||||
|
|
||||||
Canvas::do_update();
|
Canvas::do_update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowFileList::WindowFileList(core::Download* d, int* focus) :
|
WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, true),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_focus(focus) {
|
m_focus(focus) {
|
||||||
@@ -27,8 +27,8 @@ WindowFileList::redraw() {
|
|||||||
|
|
||||||
++y1;
|
++y1;
|
||||||
|
|
||||||
int files = m_download->get_download().get_entry_size();
|
unsigned int files = m_download->get_download().get_entry_size();
|
||||||
int index = std::min<unsigned>(std::max<signed>(*m_focus - (y2 - y1) / 2, 0), files - (y2 - y1));
|
unsigned int index = std::min<unsigned>(std::max((int)*m_focus - (y2 - y1) / 2, 0), (int)files - (y2 - y1));
|
||||||
|
|
||||||
while (index < files && y1 < y2) {
|
while (index < files && y1 < y2) {
|
||||||
torrent::Entry e = m_download->get_download().get_entry(index);
|
torrent::Entry e = m_download->get_download().get_entry(index);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace display {
|
|||||||
|
|
||||||
class WindowFileList : public Window {
|
class WindowFileList : public Window {
|
||||||
public:
|
public:
|
||||||
WindowFileList(core::Download* d, int* focus);
|
WindowFileList(core::Download* d, unsigned int* focus);
|
||||||
|
|
||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ private:
|
|||||||
|
|
||||||
core::Download* m_download;
|
core::Download* m_download;
|
||||||
|
|
||||||
int* m_focus;
|
unsigned int* m_focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ WindowHttpQueue::receive_insert(core::CurlGet* h) {
|
|||||||
void
|
void
|
||||||
WindowHttpQueue::receive_erase(core::CurlGet* h) {
|
WindowHttpQueue::receive_erase(core::CurlGet* h) {
|
||||||
Container::iterator itr = std::find_if(m_container.begin(), m_container.end(),
|
Container::iterator itr = std::find_if(m_container.begin(), m_container.end(),
|
||||||
func::equal(h, std::mem_fun_ref(&Node::get_http)));
|
utils::equal(h, std::mem_fun_ref(&Node::get_http)));
|
||||||
|
|
||||||
if (itr == m_container.end())
|
if (itr == m_container.end())
|
||||||
throw std::logic_error("WindowHttpQueue::receive_erase(...) tried to remove an object we don't have");
|
throw std::logic_error("WindowHttpQueue::receive_erase(...) tried to remove an object we don't have");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "core/download.h"
|
#include "core/download.h"
|
||||||
|
#include "utils/algorithm.h"
|
||||||
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "window_peer_list.h"
|
#include "window_peer_list.h"
|
||||||
|
|||||||
+4
-1
@@ -193,7 +193,8 @@ void
|
|||||||
print_help() {
|
print_help() {
|
||||||
std::cout << "Rakshasa's Torrent client. <Neko-Mimi Mode-o!>" << std::endl;
|
std::cout << "Rakshasa's Torrent client. <Neko-Mimi Mode-o!>" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << "All value pairs (f.ex rate and queue size) will be in the UP/DOWN order." << std::endl;
|
std::cout << "All value pairs (f.ex rate and queue size) will be in the UP/DOWN" << std::endl;
|
||||||
|
std::cout << "order. Use the up/down/left/right arrow keys to move between screens." << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << "Usage: rtorrent [OPTIONS]... [FILE]... [URL]..." << std::endl;
|
std::cout << "Usage: rtorrent [OPTIONS]... [FILE]... [URL]..." << std::endl;
|
||||||
std::cout << " -h Display this very helpful text" << std::endl;
|
std::cout << " -h Display this very helpful text" << std::endl;
|
||||||
@@ -209,9 +210,11 @@ print_help() {
|
|||||||
std::cout << " a,s,d,z,x,c Adjust throttle" << std::endl;
|
std::cout << " a,s,d,z,x,c Adjust throttle" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << "Download view keys:" << std::endl;
|
std::cout << "Download view keys:" << std::endl;
|
||||||
|
std::cout << " spacebar Depends on the current view" << std::endl;
|
||||||
std::cout << " 1,2 Adjust max uploads" << std::endl;
|
std::cout << " 1,2 Adjust max uploads" << std::endl;
|
||||||
std::cout << " 3,4,5,6 Adjust min/max connected peers" << std::endl;
|
std::cout << " 3,4,5,6 Adjust min/max connected peers" << std::endl;
|
||||||
std::cout << " t Query tracker for more peers" << std::endl;
|
std::cout << " t Query tracker for more peers" << std::endl;
|
||||||
|
std::cout << " p View peer information" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::cout << "Report bugs to <jaris@ifi.uio.no>." << std::endl;
|
std::cout << "Report bugs to <jaris@ifi.uio.no>." << std::endl;
|
||||||
|
|||||||
+3
-4
@@ -104,8 +104,8 @@ Download::activate_display(Display d) {
|
|||||||
case DISPLAY_MAIN:
|
case DISPLAY_MAIN:
|
||||||
*m_window = wpl = new WPeerList(m_download, &m_peers, &m_focus);
|
*m_window = wpl = new WPeerList(m_download, &m_peers, &m_focus);
|
||||||
|
|
||||||
(*m_bindings)[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER);
|
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER);
|
||||||
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_FILE_LIST);
|
(*m_bindings)[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_FILE_LIST);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DISPLAY_PEER:
|
case DISPLAY_PEER:
|
||||||
@@ -116,8 +116,8 @@ Download::activate_display(Display d) {
|
|||||||
|
|
||||||
case DISPLAY_FILE_LIST:
|
case DISPLAY_FILE_LIST:
|
||||||
m_uiFileList->activate(m_window);
|
m_uiFileList->activate(m_window);
|
||||||
|
m_uiFileList->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_MAIN);
|
||||||
|
|
||||||
(*m_bindings)[' '] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_MAIN);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -145,7 +145,6 @@ Download::disable_display() {
|
|||||||
|
|
||||||
case DISPLAY_FILE_LIST:
|
case DISPLAY_FILE_LIST:
|
||||||
m_uiFileList->disable();
|
m_uiFileList->disable();
|
||||||
m_bindings->erase(' ');
|
|
||||||
*m_window = NULL;
|
*m_window = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
+40
-3
@@ -15,6 +15,7 @@ FileList::FileList(Control* c, core::Download* d) :
|
|||||||
m_control(c),
|
m_control(c),
|
||||||
m_focus(0) {
|
m_focus(0) {
|
||||||
|
|
||||||
|
m_bindings[' '] = sigc::mem_fun(*this, &FileList::receive_priority);
|
||||||
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &FileList::receive_next);
|
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &FileList::receive_next);
|
||||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &FileList::receive_prev);
|
m_bindings[KEY_UP] = sigc::mem_fun(*this, &FileList::receive_prev);
|
||||||
}
|
}
|
||||||
@@ -45,7 +46,7 @@ FileList::receive_next() {
|
|||||||
if (m_window == NULL)
|
if (m_window == NULL)
|
||||||
throw std::logic_error("ui::FileList::receive_next(...) called on a disabled object");
|
throw std::logic_error("ui::FileList::receive_next(...) called on a disabled object");
|
||||||
|
|
||||||
if (++m_focus >= (int)m_download->get_download().get_entry_size())
|
if (++m_focus >= m_download->get_download().get_entry_size())
|
||||||
m_focus = 0;
|
m_focus = 0;
|
||||||
|
|
||||||
m_window->mark_dirty();
|
m_window->mark_dirty();
|
||||||
@@ -56,8 +57,44 @@ FileList::receive_prev() {
|
|||||||
if (m_window == NULL)
|
if (m_window == NULL)
|
||||||
throw std::logic_error("ui::FileList::receive_prev(...) called on a disabled object");
|
throw std::logic_error("ui::FileList::receive_prev(...) called on a disabled object");
|
||||||
|
|
||||||
if (--m_focus < 0)
|
if (m_download->get_download().get_entry_size() == 0)
|
||||||
m_focus = std::max(0, (int)m_download->get_download().get_entry_size() - 1);
|
return;
|
||||||
|
|
||||||
|
if (m_focus != 0)
|
||||||
|
--m_focus;
|
||||||
|
else
|
||||||
|
m_focus = m_download->get_download().get_entry_size() - 1;
|
||||||
|
|
||||||
|
m_window->mark_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileList::receive_priority() {
|
||||||
|
if (m_window == NULL)
|
||||||
|
throw std::logic_error("ui::FileList::receive_prev(...) called on a disabled object");
|
||||||
|
|
||||||
|
if (m_focus >= m_download->get_download().get_entry_size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
torrent::Entry e = m_download->get_download().get_entry(m_focus);
|
||||||
|
|
||||||
|
switch (e.get_priority()) {
|
||||||
|
case torrent::Entry::STOPPED:
|
||||||
|
e.set_priority(torrent::Entry::HIGH);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case torrent::Entry::NORMAL:
|
||||||
|
e.set_priority(torrent::Entry::STOPPED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case torrent::Entry::HIGH:
|
||||||
|
e.set_priority(torrent::Entry::NORMAL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
e.set_priority(torrent::Entry::NORMAL);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
m_window->mark_dirty();
|
m_window->mark_dirty();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -23,10 +23,14 @@ public:
|
|||||||
void activate(MItr mItr);
|
void activate(MItr mItr);
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
|
input::Bindings& get_bindings() { return m_bindings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void receive_next();
|
void receive_next();
|
||||||
void receive_prev();
|
void receive_prev();
|
||||||
|
|
||||||
|
void receive_priority();
|
||||||
|
|
||||||
core::Download* m_download;
|
core::Download* m_download;
|
||||||
WFileList* m_window;
|
WFileList* m_window;
|
||||||
|
|
||||||
@@ -34,7 +38,7 @@ private:
|
|||||||
input::Bindings m_bindings;
|
input::Bindings m_bindings;
|
||||||
|
|
||||||
// Change to unsigned, please.
|
// Change to unsigned, please.
|
||||||
int m_focus;
|
unsigned int m_focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
noinst_LIBRARIES = libsub_utils.a
|
noinst_LIBRARIES = libsub_utils.a
|
||||||
|
|
||||||
libsub_utils_a_SOURCES = \
|
libsub_utils_a_SOURCES = \
|
||||||
|
algorithm.h \
|
||||||
directory.cc \
|
directory.cc \
|
||||||
directory.h \
|
directory.h \
|
||||||
functional.h \
|
functional.h \
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef RTORRENT_UTILS_ALGORITHM_H
|
||||||
|
#define RTORRENT_UTILS_ALGORITHM_H
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace utils {
|
||||||
|
|
||||||
|
template <typename _InputIter, typename _Function>
|
||||||
|
_Function for_each_pre(_InputIter __first, _InputIter __last, _Function __f) {
|
||||||
|
_InputIter __tmp;
|
||||||
|
|
||||||
|
while (__first != __last) {
|
||||||
|
__tmp = first++;
|
||||||
|
|
||||||
|
__f(*__tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return __f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+3
-14
@@ -1,20 +1,9 @@
|
|||||||
#ifndef RTORRENT_FUNCTIONAL_H
|
#ifndef RTORRENT_UTILS_FUNCTIONAL_H
|
||||||
#define RTORRENT_FUNCTIONAL_H
|
#define RTORRENT_UTILS_FUNCTIONAL_H
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace func {
|
namespace utils {
|
||||||
|
|
||||||
template <typename Iterator, typename Ftor>
|
|
||||||
inline void for_each(Iterator first, Iterator last, Ftor ftor) {
|
|
||||||
Iterator tmp;
|
|
||||||
|
|
||||||
while (first != last) {
|
|
||||||
tmp = first++;
|
|
||||||
|
|
||||||
ftor(*tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Type, typename Ftor>
|
template <typename Type, typename Ftor>
|
||||||
struct _accumulate {
|
struct _accumulate {
|
||||||
|
|||||||
Reference in New Issue
Block a user