diff --git a/doc/rtorrent.rc b/doc/rtorrent.rc index 9c70d424..78186a79 100644 --- a/doc/rtorrent.rc +++ b/doc/rtorrent.rc @@ -3,59 +3,74 @@ # uncomment the options you wish to enable. # Maximum and minimum number of peers to connect to per torrent. +# #throttle.min_peers.normal.set = 40 #throttle.max_peers.normal.set = 100 # Same as above but for seeding completed torrents (-1 = same as downloading) +# #throttle.min_peers.seed.set = 10 #throttle.max_peers.seed.set = 50 # Maximum number of simultanious uploads per torrent. +# #throttle.max_uploads.set = 15 # Global upload and download rate in KiB. "0" for unlimited. +# #throttle.global_down.max_rate.set_kb = 0 #throttle.global_up.max_rate.set_kb = 0 # Default directory to save the downloaded torrents. +# #directory.default.set = ./ # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a # relative path? +# #session.path.set = ./session # Watch a directory for new torrents, and stop those that have been # deleted. +# #schedule2 = watch_directory,5,5,load.start=./watch/*.torrent #schedule2 = untied_directory,5,5,stop_untied= # Close torrents when diskspace is low. +# #schedule2 = low_diskspace,5,60,close_low_diskspace=100M # The ip address reported to the tracker. +# #network.local_address.set = 127.0.0.1 #network.local_address.set = rakshasa.no # The ip address the listening socket and outgoing connections is # bound to. +# #network.bind_address.set = 127.0.0.1 #network.bind_address.set = rakshasa.no # Port range to use for listening. +# #network.port_range.set = 6890-6999 # Start opening ports at a random position within the port range. +# #network.port_random.set = no # Check hash for finished torrents. Might be usefull until the bug is # fixed that causes lack of diskspace not to be properly reported. +# #pieces.hash.on_completion.set = no # Set whether the client should try to connect to UDP trackers. +# #trackers.use_udp.set = yes # Alternative calls to bind and ip that should handle dynamic ip's. +# #schedule2 = ip_tick,0,1800,ip=rakshasa #schedule2 = bind_tick,0,1800,bind=rakshasa @@ -76,9 +91,13 @@ # dht.mode.set = auto # UDP port to use for DHT. -# -# dht.port.set = 6881 +# +#dht.port.set = 6881 # Enable peer exchange (for torrents not marked private) # -# protocol.pex.set = yes +#protocol.pex.set = yes + +# Set downlad list layout style (default - 0, compact - 1) +# +#download_list_layout = 1 diff --git a/src/command_ui.cc b/src/command_ui.cc index bc9124dc..88a2f873 100644 --- a/src/command_ui.cc +++ b/src/command_ui.cc @@ -523,6 +523,8 @@ void initialize_command_ui() { CMD2_VAR_STRING("keys.layout", "qwerty"); + CMD2_VAR_VALUE("download.list.layout", 0); + CMD2_ANY_STRING("view.add", object_convert_void(std::bind(&core::ViewManager::insert_throw, control->view_manager(), std::placeholders::_2))); CMD2_ANY_L ("view.list", std::bind(&apply_view_list)); diff --git a/src/display/utils.cc b/src/display/utils.cc index 2ab4c1a7..640a7226 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -182,6 +182,110 @@ print_download_info(char* first, char* last, core::Download* d) { return first; } +char* +print_download_info2(char* first, char* last, core::Download* d) { + //Name + std::string name = "Name"; + if(d) name = d->info()->name(); + name.resize(64,' '); + first = print_buffer(first, last, " %s", name.c_str()); + + //Status + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Status "); + else if (!d->download()->info()->is_open()) + first = print_buffer(first, last, " CLOSED "); + else if (!d->download()->info()->is_active()) + first = print_buffer(first, last, " OPEN "); + else + first = print_buffer(first, last, " "); + + //Downloaded + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Downloaded "); + else + first = print_buffer(first, last, " %7.1f MB ", (double)d->download()->bytes_done() / (double)(1 << 20)); + + //Size + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Size "); + else + first = print_buffer(first, last, " %7.1f MB ", (double)d->download()->file_list()->size_bytes() / (double)(1 << 20)); + + //Done + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Done "); + else if (d->is_done()) + first = print_buffer(first, last, " 100%% "); + else if (d->is_open()) + first = print_buffer(first, last, " %2u%% ",(d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks()); + else + first = print_buffer(first, last, " "); + + //Rate Up + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Up Rate "); + else + first = print_buffer(first, last, " %6.1f KB ", (double)d->info()->up_rate()->rate() / (1 << 10)); + + //Rate Down + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Down Rate "); + else + first = print_buffer(first, last, " %6.1f KB ", (double)d->info()->down_rate()->rate() / (1 << 10)); + + //Uploaded + first = print_buffer(first, last, "|"); + if (!d) + first = print_buffer(first, last, " Uploaded "); + else + first = print_buffer(first, last, " %7.1f MB ", (double)d->info()->up_rate()->total() / (1 << 20)); + + //ETA + first = print_buffer(first, last, "| "); + if (!d) + first = print_buffer(first, last, " ETA "); + else if (d->download()->info()->is_active() && !d->is_done()) + first = print_download_time_left(first, last, d); + else + first = print_buffer(first, last, " "); + + //Ratio + first = print_buffer(first, last, " |"); + if (!d) + first = print_buffer(first, last, " Ratio"); + else + first = print_buffer(first, last, " %4.2f ", (double)rpc::call_command_value("d.ratio", rpc::make_target(d)) / 1000.0); + + //Misc + first = print_buffer(first, last, "|"); + if (!d) { + first = print_buffer(first, last, " Misc "); + } else { + first = print_buffer(first, last, " %c%c", + rpc::call_command_string("d.tied_to_file", rpc::make_target(d)).empty() ? ' ' : 'T', + rpc::call_command_value("d.ignore_commands", rpc::make_target(d)) == 0 ? ' ' : 'I', + (double)rpc::call_command_value("d.ratio", rpc::make_target(d)) / 1000.0); + + if (d->priority() != 2) + first = print_buffer(first, last, " %s", rpc::call_command_string("d.priority_str", rpc::make_target(d)).c_str()); + + if (!d->bencode()->get_key("rtorrent").get_key_string("throttle_name").empty()) + first = print_buffer(first, last , " %s", rpc::call_command_string("d.throttle_name", rpc::make_target(d)).c_str()); + } + + if (first > last) + throw torrent::internal_error("print_download_info(...) wrote past end of the buffer."); + + return first; +} + char* print_download_status(char* first, char* last, core::Download* d) { if (d->is_active()) diff --git a/src/display/utils.h b/src/display/utils.h index 7f75425c..ccb392d1 100644 --- a/src/display/utils.h +++ b/src/display/utils.h @@ -67,6 +67,7 @@ char* print_ddmmyyyy(char* first, char* last, time_t t); char* print_download_title(char* first, char* last, core::Download* d); char* print_download_info(char* first, char* last, core::Download* d); +char* print_download_info2(char* first, char* last, core::Download* d); char* print_download_status(char* first, char* last, core::Download* d); char* print_download_time_left(char* first, char* last, core::Download* d); char* print_download_percentage_done(char* first, char* last, core::Download* d); diff --git a/src/display/window_download_list.cc b/src/display/window_download_list.cc index 138ea8c9..b490c557 100644 --- a/src/display/window_download_list.cc +++ b/src/display/window_download_list.cc @@ -40,6 +40,7 @@ #include "core/download.h" #include "core/view.h" +#include "rpc/parse_commands.h" #include "canvas.h" #include "globals.h" @@ -73,6 +74,8 @@ WindowDownloadList::set_view(core::View* l) { void WindowDownloadList::redraw() { + const int layout = rpc::call_command_value("download.list.layout"); + m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds()); m_canvas->erase(); @@ -90,7 +93,7 @@ WindowDownloadList::redraw() { Range range = rak::advance_bidirectional(m_view->begin_visible(), m_view->focus() != m_view->end_visible() ? m_view->focus() : m_view->begin_visible(), m_view->end_visible(), - m_canvas->height() / 3); + m_canvas->height()/(layout ? 1 : 3)); // Make sure we properly fill out the last lines so it looks like // there are more torrents, yet don't hide it if we got the last one @@ -99,20 +102,30 @@ WindowDownloadList::redraw() { ++range.second; int pos = 1; + char buffer[m_canvas->width() + 1]; + char* last = buffer + m_canvas->width() - 2 + 1; + + if(layout) { + print_download_info2(buffer, last, NULL); + m_canvas->set_default_attributes(A_BOLD); + m_canvas->print(0, pos++, " %s", buffer); + } while (range.first != range.second) { - char buffer[m_canvas->width() + 1]; - char* last = buffer + m_canvas->width() - 2 + 1; + if(layout) { + print_download_info2(buffer, last, *range.first); + m_canvas->set_default_attributes(range.first == m_view->focus() ? A_REVERSE : A_NORMAL); + m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); + } else { + print_download_title(buffer, last, *range.first); + m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); - print_download_title(buffer, last, *range.first); - m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); - - print_download_info(buffer, last, *range.first); - m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); - - print_download_status(buffer, last, *range.first); - m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); + print_download_info(buffer, last, *range.first); + m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); + print_download_status(buffer, last, *range.first); + m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer); + } ++range.first; } } diff --git a/src/main.cc b/src/main.cc index c66247d0..2735dc84 100644 --- a/src/main.cc +++ b/src/main.cc @@ -416,6 +416,11 @@ main(int argc, char** argv) { CMD2_REDIRECT_GENERIC("to_xb", "convert.xb"); CMD2_REDIRECT_GENERIC("to_throttle", "convert.throttle"); + // TODO: Rename to something with 'ui.fooobar.....' and put + // together with the other ui options. In fact, add redirect for + // that other new ui option. + CMD2_REDIRECT ("download_list_layout", "download.list.layout.set"); + // Deprecated commands. Don't use these anymore. if (rpc::call_command_value("method.use_intermediate") == 1) { diff --git a/src/ui/element_download_list.cc b/src/ui/element_download_list.cc index bc40e7e2..5a782751 100644 --- a/src/ui/element_download_list.cc +++ b/src/ui/element_download_list.cc @@ -99,6 +99,8 @@ ElementDownloadList::ElementDownloadList() : m_bindings[KEY_UP] = m_bindings['P' - '@'] = std::bind(&ElementDownloadList::receive_prev, this); m_bindings[KEY_DOWN] = m_bindings['N' - '@'] = std::bind(&ElementDownloadList::receive_next, this); + + m_bindings['L'] = std::bind(&ElementDownloadList::toggle_layout, this); } void @@ -221,4 +223,8 @@ ElementDownloadList::receive_change_view(const std::string& name) { set_view(*itr); } +void +ElementDownloadList::toggle_layout() { + rpc::call_command("download.list.layout.set", (rpc::call_command_value("download.list.layout") + 1)%2); +} } diff --git a/src/ui/element_download_list.h b/src/ui/element_download_list.h index 20185b50..5bf4f08f 100644 --- a/src/ui/element_download_list.h +++ b/src/ui/element_download_list.h @@ -77,6 +77,8 @@ public: void receive_change_view(const std::string& name); + void toggle_layout(); + private: WDownloadList* m_window; core::View* m_view;