mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-08 03:02:30 +00:00
* Added 'd.get_hash' and 'get_hostname' commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@958 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+12
-2
@@ -41,6 +41,7 @@
|
||||
#include <rak/file_stat.h>
|
||||
#include <rak/error_number.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/data/file.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
@@ -202,7 +203,7 @@ retrieve_d_priority_str(core::Download* download) {
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_d_ratio(core::Download* download) {
|
||||
retrieve_d_ratio(core::Download* download) {
|
||||
if (download->is_hash_checking())
|
||||
return int64_t();
|
||||
|
||||
@@ -212,6 +213,13 @@ apply_d_ratio(core::Download* download) {
|
||||
return bytesDone > 0 ? (1000 * upTotal) / bytesDone : 0;
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
retrieve_d_hash(core::Download* download) {
|
||||
const torrent::HashString* hashString = &download->download()->info_hash();
|
||||
|
||||
return torrent::Object(rak::transform_hex(hashString->begin(), hashString->end()));
|
||||
}
|
||||
|
||||
#define ADD_CD_SLOT(key, function, slot, parm, doc) \
|
||||
commandDownloadSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_download(key, commandDownloadSlotsItr++, &rpc::CommandDownloadSlot::function, rpc::CommandMap::flag_dont_delete, parm, doc);
|
||||
@@ -276,6 +284,7 @@ add_copy_to_download(const char* src, const char* dest) {
|
||||
|
||||
void
|
||||
initialize_command_download() {
|
||||
ADD_CD_VOID("hash", &retrieve_d_hash);
|
||||
ADD_CD_VOID("base_path", &retrieve_d_base_path);
|
||||
ADD_CD_VOID("base_filename", &retrieve_d_base_filename);
|
||||
ADD_CD_STRING_UNI("name", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::name)));
|
||||
@@ -313,6 +322,7 @@ initialize_command_download() {
|
||||
// 0 - Not hashing
|
||||
// 1 - Normal hashing
|
||||
// 2 - Download finished, hashing
|
||||
// 3 - Rehashing
|
||||
ADD_CD_VARIABLE_VALUE("hashing", "rtorrent", "hashing");
|
||||
ADD_CD_VARIABLE_STRING("tied_to_file", "rtorrent", "tied_to_file");
|
||||
|
||||
@@ -352,7 +362,7 @@ initialize_command_download() {
|
||||
ADD_CD_VALUE_MEM_UNI("skip_total", &torrent::Download::mutable_skip_rate, &torrent::Rate::total);
|
||||
|
||||
ADD_CD_VALUE_UNI("bytes_done", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::bytes_done)));
|
||||
ADD_CD_VALUE_UNI("ratio", std::ptr_fun(&apply_d_ratio));
|
||||
ADD_CD_VALUE_UNI("ratio", std::ptr_fun(&retrieve_d_ratio));
|
||||
ADD_CD_VALUE_UNI("chunks_hashed", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::chunks_hashed)));
|
||||
ADD_CD_VALUE_UNI("free_diskspace", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::free_diskspace)));
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <functional>
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/chunk_manager.h>
|
||||
@@ -78,6 +79,19 @@ apply_execute_log(const torrent::Object& rawArgs) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_get_hostname() {
|
||||
char buffer[1024];
|
||||
|
||||
if (gethostname(buffer, 1023) == -1)
|
||||
throw torrent::input_error("Unable to read hostname.");
|
||||
|
||||
// if (shorten)
|
||||
// *std::find(buffer, buffer + 1023, '.') = '\0';
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_local() {
|
||||
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
|
||||
@@ -87,6 +101,8 @@ initialize_command_local() {
|
||||
ADD_VARIABLE_C_STRING("client_version", PACKAGE_VERSION);
|
||||
ADD_VARIABLE_C_STRING("library_version", torrent::version());
|
||||
|
||||
ADD_COMMAND_VOID("get_hostname", rak::ptr_fun(&apply_get_hostname));
|
||||
|
||||
ADD_VARIABLE_VALUE("max_file_size", -1);
|
||||
ADD_VARIABLE_VALUE("split_file_size", -1);
|
||||
ADD_VARIABLE_STRING("split_suffix", ".part");
|
||||
|
||||
@@ -270,6 +270,7 @@ initialize_command_network() {
|
||||
|
||||
ADD_VARIABLE_BOOL("use_udp_trackers", true);
|
||||
|
||||
// Isn't port_open used?
|
||||
ADD_VARIABLE_BOOL("port_open", true);
|
||||
ADD_VARIABLE_BOOL("port_random", true);
|
||||
ADD_VARIABLE_STRING("port_range", "6881-6999");
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <rak/functional_fun.h>
|
||||
#include <sigc++/bind.h>
|
||||
|
||||
// #include "core/download_list.h"
|
||||
#include "core/manager.h"
|
||||
#include "core/view_manager.h"
|
||||
#include "rpc/command_slot.h"
|
||||
|
||||
Reference in New Issue
Block a user