Skip to content

Commit

Permalink
Merge pull request #3 from rakshasa/master
Browse files Browse the repository at this point in the history
Merge mainline master with fork master
  • Loading branch information
Speeddymon committed Aug 6, 2016
2 parents aac0ea4 + 51c5190 commit 9d7398d
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 444 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before_install:
# prevent `macro `AM_PATH_CPPUNIT' not found in library` in `autogen.sh`
- sudo apt-get install libcppunit-dev

- git clone https://github.com/rakshasa/libtorrent.git && cd libtorrent && ./autogen.sh && configure && make -j12 && sudo make install && cd ..
- git clone https://github.com/rakshasa/libtorrent.git && cd libtorrent && ./autogen.sh && ./configure && make -j12 && sudo make install && cd ..

# Figure out how to fix the issue running 'make check'.
script: ./autogen.sh && ./configure && make -j12 && sudo make install
73 changes: 46 additions & 27 deletions doc/rtorrent.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,76 @@
# uncomment the options you wish to enable.

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100
#
#throttle.min_peers.normal.set = 40
#throttle.max_peers.normal.set = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
#max_peers_seed = 50
#
#throttle.min_peers.seed.set = 10
#throttle.max_peers.seed.set = 50

# Maximum number of simultanious uploads per torrent.
#max_uploads = 15
#
#throttle.max_uploads.set = 15

# Global upload and download rate in KiB. "0" for unlimited.
#download_rate = 0
#upload_rate = 0
#
#throttle.global_down.max_rate.set_kb = 0
#throttle.global_up.max_rate.set_kb = 0

# Default directory to save the downloaded torrents.
#directory = ./
#
#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 = ./session
#
#session.path.set = ./session

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load.start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=
#
#schedule2 = watch_directory,5,5,load.start=./watch/*.torrent
#schedule2 = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.
#schedule = low_diskspace,5,60,close_low_diskspace=100M
#
#schedule2 = low_diskspace,5,60,close_low_diskspace=100M

# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no
#
#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.
#bind = 127.0.0.1
#bind = rakshasa.no
#
#network.bind_address.set = 127.0.0.1
#network.bind_address.set = rakshasa.no

# Port range to use for listening.
#port_range = 6890-6999
#
#network.port_range.set = 6890-6999

# Start opening ports at a random position within the port range.
#port_random = no
#
#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.
#check_hash = no
#
#pieces.hash.on_completion.set = no

# Set whether the client should try to connect to UDP trackers.
#use_udp_trackers = yes
#
#trackers.use_udp.set = yes

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa
#
#schedule2 = ip_tick,0,1800,ip=rakshasa
#schedule2 = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
Expand All @@ -66,19 +81,23 @@
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# encryption = allow_incoming,enable_retry,prefer_plaintext
# protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
# dht = auto
# dht.mode.set = auto

# UDP port to use for DHT.
#
# dht_port = 6881
#
#dht.port.set = 6881

# Enable peer exchange (for torrents not marked private)
#
# peer_exchange = yes
#protocol.pex.set = yes

# Set downlad list layout style. ("full", "compact")
#
#torrent_list_layout = "full"
1 change: 1 addition & 0 deletions src/command_download.cc
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ initialize_command_download() {
CMD2_DL ("d.is_pex_active", CMD2_ON_INFO(is_pex_active));
CMD2_DL ("d.is_partially_done", CMD2_ON_DATA(is_partially_done));
CMD2_DL ("d.is_not_partially_done", CMD2_ON_DATA(is_not_partially_done));
CMD2_DL ("d.is_meta", CMD2_ON_INFO(is_meta_download));

CMD2_DL_V ("d.resume", std::bind(&core::DownloadList::resume_default, control->core()->download_list(), std::placeholders::_1));
CMD2_DL_V ("d.pause", std::bind(&core::DownloadList::pause_default, control->core()->download_list(), std::placeholders::_1));
Expand Down
2 changes: 1 addition & 1 deletion src/command_local.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ initialize_command_local() {
CMD2_VAR_C_STRING("system.client_version", PACKAGE_VERSION);
CMD2_VAR_C_STRING("system.library_version", torrent::version());
CMD2_VAR_VALUE ("system.file.allocate", 0);
CMD2_VAR_VALUE ("system.file.max_size", (int64_t)128 << 30);
CMD2_VAR_VALUE ("system.file.max_size", (int64_t)512 << 30);
CMD2_VAR_VALUE ("system.file.split_size", -1);
CMD2_VAR_STRING ("system.file.split_suffix", ".part");

Expand Down
3 changes: 3 additions & 0 deletions src/command_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ initialize_command_ui() {
CMD2_ANY ("ui.current_view", std::bind(&cmd_ui_current_view));
CMD2_ANY_STRING("ui.current_view.set", std::bind(&cmd_ui_set_view, std::placeholders::_2));

// TODO: Add 'option_string' for rtorrent-specific options.
CMD2_VAR_STRING("ui.torrent_list.layout", "full");

// Move.
CMD2_ANY("print", &apply_print);
CMD2_ANY("cat", &apply_cat);
Expand Down
4 changes: 4 additions & 0 deletions src/core/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ View::sort() {

void
View::filter() {
// Do NOT allow filter STARTED and STOPPED views: they are special
if (m_name == "started" || m_name == "stopped")
return;

// Parition the list in two steps so we know which elements changed.
iterator splitVisible = std::stable_partition(begin_visible(), end_visible(), view_downloads_filter(m_filter));
iterator splitFiltered = std::stable_partition(begin_filtered(), end_filtered(), view_downloads_filter(m_filter));
Expand Down
66 changes: 64 additions & 2 deletions src/display/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ print_download_title(char* first, char* last, core::Download* d) {
}

char*
print_download_info(char* first, char* last, core::Download* d) {
print_download_info_full(char* first, char* last, core::Download* d) {
if (!d->download()->info()->is_open())
first = print_buffer(first, last, "[CLOSED] ");
else if (!d->download()->info()->is_active())
Expand Down Expand Up @@ -177,7 +177,7 @@ print_download_info(char* first, char* last, core::Download* d) {
first = print_buffer(first, last , "]");

if (first > last)
throw torrent::internal_error("print_download_info(...) wrote past end of the buffer.");
throw torrent::internal_error("print_download_info_full(...) wrote past end of the buffer.");

return first;
}
Expand Down Expand Up @@ -218,6 +218,68 @@ print_download_status(char* first, char* last, core::Download* d) {
return first;
}

char*
print_download_column_compact(char* first, char* last) {
first = print_buffer(first, last, " %-64.64s", "Name");
first = print_buffer(first, last, "| Status | Downloaded | Size | Done | Up Rate | Down Rate | Uploaded | ETA | Ratio| Misc ");

if (first > last)
throw torrent::internal_error("print_download_column_compact(...) wrote past end of the buffer.");

return first;
}

char*
print_download_info_compact(char* first, char* last, core::Download* d) {
first = print_buffer(first, last, " %-64.64s", d->info()->name().c_str());
first = print_buffer(first, last, "|");

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, " ");

first = print_buffer(first, last, "| %7.1f MB ", (double)d->download()->bytes_done() / (double)(1 << 20));
first = print_buffer(first, last, "| %7.1f MB ", (double)d->download()->file_list()->size_bytes() / (double)(1 << 20));
first = print_buffer(first, last, "|");

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, " ");

first = print_buffer(first, last, "| %6.1f KB ", (double)d->info()->up_rate()->rate() / (1 << 10));
first = print_buffer(first, last, "| %6.1f KB ", (double)d->info()->down_rate()->rate() / (1 << 10));
first = print_buffer(first, last, "| %7.1f MB ", (double)d->info()->up_rate()->total() / (1 << 20));
first = print_buffer(first, last, "| ");

if (d->download()->info()->is_active() && !d->is_done())
first = print_download_time_left(first, last, d);
else
first = print_buffer(first, last, " ");

first = print_buffer(first, last, "| %4.2f ", (double)rpc::call_command_value("d.ratio", rpc::make_target(d)) / 1000.0);
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_compact(...) wrote past end of the buffer.");

return first;
}

char*
print_download_time_left(char* first, char* last, core::Download* d) {
uint32_t rate = d->info()->down_rate()->rate();
Expand Down
6 changes: 5 additions & 1 deletion src/display/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ char* print_ddhhmm(char* first, char* last, time_t t);
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_info_full(char* first, char* last, core::Download* d);
char* print_download_status(char* first, char* last, core::Download* d);

char* print_download_column_compact(char* first, char* last);
char* print_download_info_compact(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);

Expand Down
63 changes: 46 additions & 17 deletions src/display/window_download_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "core/download.h"
#include "core/view.h"
#include "rpc/parse_commands.h"

#include "canvas.h"
#include "globals.h"
Expand Down Expand Up @@ -85,12 +86,24 @@ WindowDownloadList::redraw() {
if (m_view->empty_visible() || m_canvas->width() < 5 || m_canvas->height() < 2)
return;

int layout_height;
const std::string layout_name = rpc::call_command_string("ui.torrent_list.layout");

if (layout_name == "full") {
layout_height = 3;
} else if (layout_name == "compact") {
layout_height = 1;
} else {
m_canvas->print(0, 0, "INVALID ui.torrent_list.layout '%s'", layout_name.c_str());
return;
}

typedef std::pair<core::View::iterator, core::View::iterator> Range;

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_height);

// 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
Expand All @@ -99,22 +112,38 @@ WindowDownloadList::redraw() {
++range.second;

int pos = 1;

while (range.first != range.second) {
char buffer[m_canvas->width() + 1];
char* last = buffer + m_canvas->width() - 2 + 1;

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);

++range.first;
}
char buffer[m_canvas->width() + 1];
char* last = buffer + m_canvas->width() - 2 + 1;

// Add a proper 'column info' method.
if (layout_name == "compact") {
print_download_column_compact(buffer, last);

m_canvas->set_default_attributes(A_BOLD);
m_canvas->print(0, pos++, " %s", buffer);
}

if (layout_name == "full") {
while (range.first != range.second) {
print_download_title(buffer, last, *range.first);
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
print_download_info_full(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++;
}

} else {
while (range.first != range.second) {
print_download_info_compact(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);

range.first++;
}
}
}

}
2 changes: 1 addition & 1 deletion src/display/window_download_statusbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ WindowDownloadStatusbar::redraw() {
char buffer[m_canvas->width()];
char* last = buffer + m_canvas->width() - 2;

print_download_info(buffer, last, m_download);
print_download_info_full(buffer, last, m_download);
m_canvas->print(0, 0, "%s", buffer);

snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Slots: U:%i/%i D:%i/%i U/I/C/A: %i/%i/%i/%i Unchoked: %u/%u Failed: %i",
Expand Down
Loading

0 comments on commit 9d7398d

Please sign in to comment.