* Moved some option string stuff to libtorrent.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1197 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2011-03-31 09:35:21 +00:00
parent 9ed7596daf
commit 386250bc87
+14 -41
View File
@@ -52,6 +52,7 @@
#include <torrent/data/file_list.h>
#include <torrent/peer/connection_list.h>
#include <torrent/peer/peer_list.h>
#include <torrent/utils/option_strings.h>
#include "core/download.h"
#include "core/download_store.h"
@@ -180,66 +181,38 @@ apply_d_directory(core::Download* download, const std::string& name) {
torrent::Object
apply_d_connection_type(core::Download* download, const std::string& name) {
torrent::Download::ConnectionType connType;
torrent::Download::ConnectionType t =
(torrent::Download::ConnectionType)torrent::option_find_string(torrent::OPTION_CONNECTION_TYPE, name.c_str());
if (name == "leech")
connType = torrent::Download::CONNECTION_LEECH;
else if (name == "seed")
connType = torrent::Download::CONNECTION_SEED;
else if (name == "initial_seed")
connType = torrent::Download::CONNECTION_INITIAL_SEED;
else
throw torrent::input_error("Unknown peer connection type selected.");
download->download()->set_connection_type(connType);
download->download()->set_connection_type(t);
return torrent::Object();
}
const char*
retrieve_d_connection_type(core::Download* download) {
switch (download->download()->connection_type()) {
case torrent::Download::CONNECTION_LEECH:
return "leech";
case torrent::Download::CONNECTION_SEED:
return "seed";
case torrent::Download::CONNECTION_INITIAL_SEED:
return "initial_seed";
default:
return "unknown";
}
return torrent::option_as_string(torrent::OPTION_CONNECTION_TYPE, download->download()->connection_type());
}
torrent::Object
apply_d_choke_heuristics(core::Download* download, const std::string& name, bool is_down) {
torrent::Download::HeuristicType connType;
if (name == "upload_leech")
connType = torrent::Download::HEURISTICS_UPLOAD_LEECH;
else if (name == "download_leech")
connType = torrent::Download::HEURISTICS_DOWNLOAD_LEECH;
else
throw torrent::input_error("Unknown peer heuristic selected.");
torrent::Download::HeuristicType t =
(torrent::Download::HeuristicType)torrent::option_find_string(torrent::OPTION_CHOKE_HEURISTICS, name.c_str());
if (is_down)
download->download()->set_download_choke_heuristic(connType);
download->download()->set_download_choke_heuristic(t);
else
download->download()->set_upload_choke_heuristic(connType);
download->download()->set_upload_choke_heuristic(t);
return torrent::Object();
}
const char*
retrieve_d_choke_heuristics(core::Download* download, bool is_down) {
switch (is_down ?
download->download()->download_choke_heuristic() :
download->download()->upload_choke_heuristic()) {
case torrent::Download::HEURISTICS_UPLOAD_LEECH:
return "upload_leech";
case torrent::Download::HEURISTICS_DOWNLOAD_LEECH:
return "download_leech";
default:
return "unknown";
}
torrent::Download::HeuristicType t = is_down ?
download->download()->download_choke_heuristic() :
download->download()->upload_choke_heuristic();
return torrent::option_as_string(torrent::OPTION_CHOKE_HEURISTICS, t);
}
const char*