Cleaned up the API.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@456 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-06-07 22:20:03 +00:00
parent 2e7333792f
commit 693ce38317
9 changed files with 52 additions and 31 deletions
+1
View File
@@ -3,6 +3,7 @@ SUBDIRS = src
EXTRA_DIST= \
autogen.sh \
doc/rtorrent.1.txt \
doc/rtorrent.rc \
rak/algorithm.h \
rak/functional.h \
scripts/checks.m4 \
+15 -9
View File
@@ -2,30 +2,36 @@
# ~/.rtorrent.rc and enable/modify the options as needed.
# Minumum amount of peers to connect per torrent, if available.
# min_peers = 40
#min_peers = 40
# Minumum amount of peers to connect per torrent.
# max_peers = 100
#max_peers = 100
# Maximum number of simultanious uploads per torrent.
# max_uploads = 15
#max_uploads = 15
# Global download rate in KiB. "0" for unlimited.
# download_rate = 0
#download_rate = 0
# Global upload rate in KiB. "0" for unlimited.
# upload_rate = 0
#upload_rate = 0
# Default directory to save downloaded files. Note it doesn't support
# space yet.
# directory = ./
#directory = ./
# The ip address reported to the tracker.
# ip = 127.0.0.1
#ip = 127.0.0.1
# The ip address the listening socket and outgoing connections is
# bound to.
# bind = 127.0.0.1
#bind = 127.0.0.1
# Port range to use for listening.
# port = 6890-6999
#port = 6890-6999
# Hash read-ahead controls how many MB to request the kernel to read
# ahead. If the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read
# pages in memory thus end up trashing.
#hash_read_ahead = 10
+1 -1
View File
@@ -55,7 +55,7 @@ Poll::poll(utils::Timer timeout) {
m_maxFd = std::max(m_maxFd, n);
}
timeval t = std::min(timeout, utils::Timer(torrent::get(torrent::TIME_SELECT))).tval();
timeval t = std::min(timeout, utils::Timer(torrent::get_next_timeout())).tval();
errno = 0;
m_maxFd = select(m_maxFd + 1, m_readSet, m_writeSet, m_exceptSet, &t);
+6 -6
View File
@@ -46,22 +46,22 @@ WindowStatusbar::redraw() {
int pos = 0;
char buf[128];
if (torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) == 0)
if (torrent::get_write_throttle() == 0)
pos = snprintf(buf, 128, "off/");
else
pos = snprintf(buf, 128, "%3i/", (int)torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) / 1024);
pos = snprintf(buf, 128, "%3i/", torrent::get_write_throttle() / 1024);
if (torrent::get(torrent::THROTTLE_READ_CONST_RATE) == 0)
if (torrent::get_read_throttle() == 0)
pos = snprintf(buf + pos, 128 - pos, "off");
else
pos = snprintf(buf + pos, 128 - pos, "%-3i", (int)torrent::get(torrent::THROTTLE_READ_CONST_RATE) / 1024);
pos = snprintf(buf + pos, 128 - pos, "%-3i", torrent::get_read_throttle() / 1024);
m_canvas->print(0, 0, "Throttle U/D: %s Listen: %s:%i%s Handshakes: %i",
buf,
!torrent::get_ip().empty() ? torrent::get_ip().c_str() : "<default>",
(int)torrent::get(torrent::LISTEN_PORT),
(int)torrent::get_listen_port(),
!torrent::get_bind().empty() ? (" Bind: " + torrent::get_bind()).c_str() : "",
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
torrent::get_total_handshakes());
}
}
+8 -7
View File
@@ -118,12 +118,13 @@ initialize_option_handler(ui::Control* c, OptionHandler* optionHandler) {
optionHandler->insert("max_peers", new OptionHandlerDownloadInt(dsm, &apply_download_max_peers, &validate_download_peers));
optionHandler->insert("max_uploads", new OptionHandlerDownloadInt(dsm, &apply_download_max_uploads, &validate_download_peers));
optionHandler->insert("download_rate", new OptionHandlerInt(c, &apply_global_download_rate, &validate_rate));
optionHandler->insert("upload_rate", new OptionHandlerInt(c, &apply_global_upload_rate, &validate_rate));
optionHandler->insert("download_rate", new OptionHandlerInt(c, &apply_global_download_rate, &validate_rate));
optionHandler->insert("upload_rate", new OptionHandlerInt(c, &apply_global_upload_rate, &validate_rate));
optionHandler->insert("hash_read_ahead", new OptionHandlerInt(c, &apply_hash_read_ahead, &validate_read_ahead));
optionHandler->insert("directory", new OptionHandlerDownloadString(dsm, &apply_download_directory, &validate_directory));
optionHandler->insert("ip", new OptionHandlerString(c, &apply_ip, &validate_ip));
optionHandler->insert("ip", new OptionHandlerString(c, &apply_ip, &validate_ip));
optionHandler->insert("bind", new OptionHandlerString(c, &apply_bind, &validate_ip));
optionHandler->insert("port", new OptionHandlerString(c, &apply_port_range, &validate_port_range));
}
@@ -132,10 +133,10 @@ void
load_option_file(const std::string& filename, OptionHandler* optionHandler, bool require = false) {
std::fstream f(filename.c_str(), std::ios::in);
if (!f.is_open())
if (!f.is_open()) {
std::cout << "Could not open option file \"" << filename << "\"" << std::endl;
return;
std::cout << "Loaded option file \"" << filename << "\"" << std::endl;
}
OptionFile optionFile;
@@ -208,7 +209,7 @@ main(int argc, char** argv) {
uiControl.get_display().adjust_layout();
while (!is_shutting_down || !torrent::get(torrent::SHUTDOWN_DONE)) {
while (!is_shutting_down || !torrent::is_inactive()) {
if (uiRoot.get_shutdown_received()) {
do_shutdown(&uiControl);
+13 -3
View File
@@ -55,7 +55,12 @@ validate_download_peers(int arg) {
bool
validate_rate(int arg) {
return arg >= 0 && arg < (1 << 24);
return arg >= 0 && arg < (1 << 20);
}
bool
validate_read_ahead(int arg) {
return arg >= 1 && arg < 64;
}
void
@@ -82,12 +87,17 @@ apply_download_directory(core::Download* d, const std::string& arg) {
void
apply_global_download_rate(ui::Control* m, int arg) {
torrent::set(torrent::THROTTLE_READ_CONST_RATE, arg * 1024);
torrent::set_read_throttle(arg * 1024);
}
void
apply_global_upload_rate(ui::Control* m, int arg) {
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, arg * 1024);
torrent::set_write_throttle(arg * 1024);
}
void
apply_hash_read_ahead(ui::Control* m, int arg) {
torrent::set_hash_read_ahead(arg << 20);
}
void
+3
View File
@@ -40,6 +40,7 @@ bool validate_port_range(const std::string& arg);
bool validate_download_peers(int arg);
bool validate_rate(int arg);
bool validate_read_ahead(int arg);
void apply_download_min_peers(core::Download* d, int arg);
void apply_download_max_peers(core::Download* d, int arg);
@@ -50,6 +51,8 @@ void apply_download_directory(core::Download* d, const std::string& arg);
void apply_global_download_rate(ui::Control* m, int arg);
void apply_global_upload_rate(ui::Control* m, int arg);
void apply_hash_read_ahead(ui::Control* m, int arg);
void apply_ip(ui::Control* m, const std::string& arg);
void apply_bind(ui::Control* m, const std::string& arg);
void apply_port_range(ui::Control* m, const std::string& arg);
+2 -2
View File
@@ -184,14 +184,14 @@ void
Download::receive_read_throttle(int t) {
m_windowMainStatus->mark_dirty();
torrent::set(torrent::THROTTLE_READ_CONST_RATE, torrent::get(torrent::THROTTLE_READ_CONST_RATE) + t * 1024);
torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024);
}
void
Download::receive_write_throttle(int t) {
m_windowMainStatus->mark_dirty();
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024);
}
void
+3 -3
View File
@@ -53,7 +53,7 @@ DownloadList::DownloadList(Control* c) :
m_window(c->get_display().end()),
m_windowTitle(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + torrent::get_version())),
m_windowStatus(new WStatus(&c->get_core())),
m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())),
@@ -172,14 +172,14 @@ void
DownloadList::receive_read_throttle(int t) {
m_windowStatus->mark_dirty();
torrent::set(torrent::THROTTLE_READ_CONST_RATE, torrent::get(torrent::THROTTLE_READ_CONST_RATE) + t * 1024);
torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024);
}
void
DownloadList::receive_write_throttle(int t) {
m_windowStatus->mark_dirty();
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024);
}
void