* Fix TextElement* to use rpc::target_type.

* Moved most of src/ui/download.cc to use commands for TextElements.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@967 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-08-30 16:33:52 +00:00
parent 32b74ffc48
commit 73c41074ec
28 changed files with 476 additions and 115 deletions
+9
View File
@@ -228,6 +228,15 @@ copy_escape_html(InputIterator first1, InputIterator last1, OutputIterator first
return first2;
}
template <typename Iterator>
inline std::string
copy_escape_html(Iterator first, Iterator last) {
std::string dest;
copy_escape_html(first, last, std::back_inserter(dest));
return dest;
}
template <typename Sequence>
Sequence
copy_escape_html(const Sequence& src) {
+28 -11
View File
@@ -221,6 +221,20 @@ retrieve_d_hash(core::Download* download) {
return torrent::Object(rak::transform_hex(hashString->begin(), hashString->end()));
}
torrent::Object
retrieve_d_local_id(core::Download* download) {
const torrent::HashString* hashString = &download->download()->local_id();
return torrent::Object(rak::transform_hex(hashString->begin(), hashString->end()));
}
torrent::Object
retrieve_d_local_id_html(core::Download* download) {
const torrent::HashString* hashString = &download->download()->local_id();
return torrent::Object(rak::copy_escape_html(hashString->begin(), hashString->end()));
}
torrent::Object
f_multicall(core::Download* download, const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
@@ -349,6 +363,8 @@ add_copy_to_download(const char* src, const char* dest) {
void
initialize_command_download() {
ADD_CD_VOID("hash", &retrieve_d_hash);
ADD_CD_VOID("local_id", &retrieve_d_local_id);
ADD_CD_VOID("local_id_html", &retrieve_d_local_id_html);
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)));
@@ -438,20 +454,21 @@ initialize_command_download() {
ADD_CD_VALUE_MEM_UNI("skip_rate", &torrent::Download::mutable_skip_rate, &torrent::Rate::rate);
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(&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)));
ADD_CD_VALUE_UNI("creation_date", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::creation_date)));
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(&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)));
ADD_CD_VALUE_UNI("size_files", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_files)));
ADD_CD_VALUE_UNI("size_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_bytes)));
ADD_CD_VALUE_UNI("size_chunks", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_chunks)));
ADD_CD_VALUE_UNI("size_files", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_files)));
ADD_CD_VALUE_UNI("size_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_bytes)));
ADD_CD_VALUE_UNI("size_chunks", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_chunks)));
ADD_CD_VALUE_UNI("completed_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::completed_bytes)));
ADD_CD_VALUE_UNI("completed_chunks", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::completed_chunks)));
ADD_CD_VALUE_UNI("left_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::left_bytes)));
ADD_CD_VALUE_UNI("completed_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::completed_bytes)));
ADD_CD_VALUE_UNI("completed_chunks", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::completed_chunks)));
ADD_CD_VALUE_UNI("left_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::left_bytes)));
ADD_CD_VALUE_UNI("chunk_size", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::chunk_size)));
ADD_CD_VALUE_UNI("chunk_size", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::chunk_size)));
ADD_CD_VALUE_MEM_BI("tracker_numwant", &core::Download::tracker_list, &torrent::TrackerList::set_numwant, &torrent::TrackerList::numwant);
ADD_CD_VALUE_UNI("tracker_focus", rak::on(std::mem_fun(&core::Download::tracker_list), std::mem_fun(&torrent::TrackerList::focus)));
+3
View File
@@ -42,6 +42,7 @@
#include "rpc/command_variable.h"
#include "rpc/command_download_slot.h"
#include "rpc/command_file_slot.h"
#include "rpc/command_file_itr_slot.h"
#include "rpc/command_peer_slot.h"
#include "rpc/command_tracker_slot.h"
@@ -57,6 +58,8 @@ rpc::CommandDownloadSlot commandDownloadSlots[COMMAND_DOWNLOAD_SLOTS_SIZE];
rpc::CommandDownloadSlot* commandDownloadSlotsItr = commandDownloadSlots;
rpc::CommandFileSlot commandFileSlots[COMMAND_FILE_SLOTS_SIZE];
rpc::CommandFileSlot* commandFileSlotsItr = commandFileSlots;
rpc::CommandFileItrSlot commandFileItrSlots[COMMAND_FILE_ITR_SLOTS_SIZE];
rpc::CommandFileItrSlot* commandFileItrSlotsItr = commandFileItrSlots;
rpc::CommandPeerSlot commandPeerSlots[COMMAND_PEER_SLOTS_SIZE];
rpc::CommandPeerSlot* commandPeerSlotsItr = commandPeerSlots;
rpc::CommandTrackerSlot commandTrackerSlots[COMMAND_TRACKER_SLOTS_SIZE];
+4
View File
@@ -44,6 +44,7 @@ namespace rpc {
class CommandVariable;
class CommandDownloadSlot;
class CommandFileSlot;
class CommandFileItrSlot;
class CommandPeerSlot;
class CommandTrackerSlot;
}
@@ -54,6 +55,7 @@ namespace rpc {
#define COMMAND_VARIABLES_SIZE 100
#define COMMAND_DOWNLOAD_SLOTS_SIZE 100
#define COMMAND_FILE_SLOTS_SIZE 20
#define COMMAND_FILE_ITR_SLOTS_SIZE 10
#define COMMAND_PEER_SLOTS_SIZE 20
#define COMMAND_TRACKER_SLOTS_SIZE 15
@@ -67,6 +69,8 @@ extern rpc::CommandDownloadSlot commandDownloadSlots[COMMAND_DOWNLOAD_SLOTS_SIZ
extern rpc::CommandDownloadSlot* commandDownloadSlotsItr;
extern rpc::CommandFileSlot commandFileSlots[COMMAND_FILE_SLOTS_SIZE];
extern rpc::CommandFileSlot* commandFileSlotsItr;
extern rpc::CommandFileItrSlot commandFileItrSlots[COMMAND_FILE_ITR_SLOTS_SIZE];
extern rpc::CommandFileItrSlot* commandFileItrSlotsItr;
extern rpc::CommandPeerSlot commandPeerSlots[COMMAND_PEER_SLOTS_SIZE];
extern rpc::CommandPeerSlot* commandPeerSlotsItr;
extern rpc::CommandTrackerSlot commandTrackerSlots[COMMAND_TRACKER_SLOTS_SIZE];
+5
View File
@@ -136,8 +136,10 @@ initialize_command_local() {
ADD_VARIABLE_VALUE("split_file_size", -1);
ADD_VARIABLE_STRING("split_suffix", ".part");
ADD_COMMAND_VOID("get_memory_usage", rak::make_mem_fun(chunkManager, &CM_t::memory_usage));
ADD_COMMAND_VALUE_TRI("max_memory_usage", rak::make_mem_fun(chunkManager, &CM_t::set_max_memory_usage), rak::make_mem_fun(chunkManager, &CM_t::max_memory_usage));
ADD_COMMAND_VALUE_TRI("safe_sync", rak::make_mem_fun(chunkManager, &CM_t::set_safe_sync), rak::make_mem_fun(chunkManager, &CM_t::safe_sync));
ADD_COMMAND_VOID("get_safe_free_diskspace", rak::make_mem_fun(chunkManager, &CM_t::safe_free_diskspace));
ADD_COMMAND_VALUE_TRI("timeout_sync", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_sync), rak::make_mem_fun(chunkManager, &CM_t::timeout_sync));
ADD_COMMAND_VALUE_TRI("timeout_safe_sync", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_safe_sync), rak::make_mem_fun(chunkManager, &CM_t::timeout_safe_sync));
@@ -145,6 +147,9 @@ initialize_command_local() {
ADD_COMMAND_VALUE_TRI("preload_min_size", rak::make_mem_fun(chunkManager, &CM_t::set_preload_min_size), rak::make_mem_fun(chunkManager, &CM_t::preload_min_size));
ADD_COMMAND_VALUE_TRI_KB("preload_required_rate", rak::make_mem_fun(chunkManager, &CM_t::set_preload_required_rate), rak::make_mem_fun(chunkManager, &CM_t::preload_required_rate));
ADD_COMMAND_VOID("get_stats_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_preloaded));
ADD_COMMAND_VOID("get_stats_not_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_not_preloaded));
ADD_VARIABLE_STRING("directory", "./");
ADD_COMMAND_STRING_TRI("session", rak::make_mem_fun(dStore, &core::DownloadStore::set_path), rak::make_mem_fun(dStore, &core::DownloadStore::path));
+2 -1
View File
@@ -41,6 +41,7 @@
#include <inttypes.h>
#include "display/canvas.h"
#include "rpc/command_map.h"
namespace display {
@@ -56,7 +57,7 @@ public:
// The last element must point to a valid memory location into which
// the caller must write a '\0' to terminate the c string. The
// attributes must contain at least one attribute.
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object) = 0;
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) = 0;
virtual extent_type max_length() = 0;
+15 -15
View File
@@ -50,11 +50,11 @@ public:
m_slot(slot), m_branch1(branch1), m_branch2(branch2) {}
~TextElementBranchVoid() { delete m_branch1; delete m_branch2; }
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) {
if (m_slot())
return m_branch1 != NULL ? m_branch1->print(first, last, attributes, object) : first;
return m_branch1 != NULL ? m_branch1->print(first, last, attributes, target) : first;
else
return m_branch2 != NULL ? m_branch2->print(first, last, attributes, object) : first;
return m_branch2 != NULL ? m_branch2->print(first, last, attributes, target) : first;
}
virtual extent_type max_length() {
@@ -79,14 +79,14 @@ public:
m_slot(slot), m_branch1(branch1), m_branch2(branch2) {}
~TextElementBranch() { delete m_branch1; delete m_branch2; }
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
if (object == NULL)
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) {
if (target.second == NULL)
return first;
if (m_slot(reinterpret_cast<arg1_type>(object)))
return m_branch1 != NULL ? m_branch1->print(first, last, attributes, object) : first;
if (m_slot(reinterpret_cast<arg1_type>(target.second)))
return m_branch1 != NULL ? m_branch1->print(first, last, attributes, target) : first;
else
return m_branch2 != NULL ? m_branch2->print(first, last, attributes, object) : first;
return m_branch2 != NULL ? m_branch2->print(first, last, attributes, target) : first;
}
virtual extent_type max_length() {
@@ -111,16 +111,16 @@ public:
m_slot1(slot1), m_slot2(slot2), m_branch1(branch1), m_branch2(branch2), m_branch3(branch3) {}
~TextElementBranch3() { delete m_branch1; delete m_branch2; delete m_branch3; }
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
if (object == NULL)
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) {
if (target.second == NULL)
return first;
if (m_slot1(reinterpret_cast<arg1_type>(object)))
return m_branch1 != NULL ? m_branch1->print(first, last, attributes, object) : first;
else if (m_slot2(reinterpret_cast<arg1_type>(object)))
return m_branch2 != NULL ? m_branch2->print(first, last, attributes, object) : first;
if (m_slot1(reinterpret_cast<arg1_type>(target.second)))
return m_branch1 != NULL ? m_branch1->print(first, last, attributes, target) : first;
else if (m_slot2(reinterpret_cast<arg1_type>(target.second)))
return m_branch2 != NULL ? m_branch2->print(first, last, attributes, target) : first;
else
return m_branch3 != NULL ? m_branch3->print(first, last, attributes, object) : first;
return m_branch3 != NULL ? m_branch3->print(first, last, attributes, target) : first;
}
virtual extent_type max_length() {
+3 -3
View File
@@ -51,7 +51,7 @@ TextElementList::clear() {
}
char*
TextElementList::print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
TextElementList::print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) {
int column = m_columnWidth != NULL ? m_column : 0;
// Call print for each element even if first == last so that any
@@ -63,7 +63,7 @@ TextElementList::print(char* first, char* last, Canvas::attributes_list* attribu
if (columnEnd < first || columnEnd > last)
throw torrent::internal_error("TextElementList::print(...) columnEnd < first || columnEnd > last.");
first = (*itr)->print(first, columnEnd, attributes, object);
first = (*itr)->print(first, columnEnd, attributes, target);
if (first > columnEnd)
throw torrent::internal_error("TextElementList::print(...) first > columnEnd.");
@@ -72,7 +72,7 @@ TextElementList::print(char* first, char* last, Canvas::attributes_list* attribu
first = columnEnd;
} else {
first = (*itr)->print(first, last, attributes, object);
first = (*itr)->print(first, last, attributes, target);
}
return first;
+1 -1
View File
@@ -69,7 +69,7 @@ public:
void set_column(unsigned int column) { m_column = column; }
void set_column_width(extent_type* width) { m_columnWidth = width; }
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object);
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target);
virtual extent_type max_length();
+6 -6
View File
@@ -43,7 +43,7 @@
namespace display {
char*
TextElementStringBase::print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
TextElementStringBase::print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) {
Attributes baseAttribute = attributes->back();
push_attribute(attributes, Attributes(first, m_attributes, Attributes::color_invalid));
@@ -52,18 +52,18 @@ TextElementStringBase::print(char* first, char* last, Canvas::attributes_list* a
if (m_flags & flag_escape_hex) {
char buffer[last - first];
char* bufferLast = copy_string(buffer, buffer + (last - first), object);
char* bufferLast = copy_string(buffer, buffer + (last - first), target);
first = rak::transform_hex(buffer, bufferLast, first, last);
} else if (m_flags & flag_escape_html) {
char buffer[last - first];
char* bufferLast = copy_string(buffer, buffer + (last - first), object);
char* bufferLast = copy_string(buffer, buffer + (last - first), target);
first = rak::copy_escape_html(buffer, bufferLast, first, last);
} else {
first = copy_string(first, last, object);
first = copy_string(first, last, target);
}
push_attribute(attributes, Attributes(first, baseAttribute));
@@ -72,7 +72,7 @@ TextElementStringBase::print(char* first, char* last, Canvas::attributes_list* a
}
char*
TextElementString::copy_string(char* first, char* last, void* object) {
TextElementString::copy_string(char* first, char* last, rpc::target_type target) {
extent_type length = std::min<extent_type>(last - first, m_string.size());
std::memcpy(first, m_string.c_str(), length);
@@ -81,7 +81,7 @@ TextElementString::copy_string(char* first, char* last, void* object) {
}
char*
TextElementCString::copy_string(char* first, char* last, void* object) {
TextElementCString::copy_string(char* first, char* last, rpc::target_type target) {
extent_type length = std::min<extent_type>(last - first, m_length);
std::memcpy(first, m_string, length);
+7 -7
View File
@@ -59,10 +59,10 @@ public:
int attributes() const { return m_attributes; }
void set_attributes(int a) { m_attributes = a; }
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object);
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target);
protected:
virtual char* copy_string(char* first, char* last, void* object) = 0;
virtual char* copy_string(char* first, char* last, rpc::target_type target) = 0;
int m_flags;
int m_attributes;
@@ -81,7 +81,7 @@ public:
virtual extent_type max_length() { return m_string.size(); }
private:
virtual char* copy_string(char* first, char* last, void* object);
virtual char* copy_string(char* first, char* last, rpc::target_type target);
std::string m_string;
};
@@ -96,7 +96,7 @@ public:
virtual extent_type max_length() { return m_length; }
private:
virtual char* copy_string(char* first, char* last, void* object);
virtual char* copy_string(char* first, char* last, rpc::target_type target);
extent_type m_length;
const char* m_string;
@@ -116,11 +116,11 @@ public:
virtual extent_type max_length() { return m_length; }
private:
virtual char* copy_string(char* first, char* last, void* object) {
if (object == NULL)
virtual char* copy_string(char* first, char* last, rpc::target_type target) {
if (target.second == NULL)
return first;
result_type result = m_slot(reinterpret_cast<arg1_type>(object));
result_type result = m_slot(reinterpret_cast<arg1_type>(target.second));
extent_type length = std::min<extent_type>(result_length(&result), last - first);
std::memcpy(first, result_buffer(&result), length);
+2 -2
View File
@@ -59,11 +59,11 @@ TextElement::push_attribute(Canvas::attributes_list* attributes, Attributes valu
}
char*
TextElementValueBase::print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
TextElementValueBase::print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target) {
Attributes baseAttribute = attributes->back();
push_attribute(attributes, Attributes(first, m_attributes, Attributes::color_invalid));
int64_t val = value(object);
int64_t val = value(target.second);
// Transform the value if needed.
if (m_flags & flag_elapsed)
+1 -1
View File
@@ -65,7 +65,7 @@ public:
int attributes() const { return m_attributes; }
void set_attributes(int a) { m_attributes = a; }
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object);
virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, rpc::target_type target);
protected:
virtual int64_t value(void* object) = 0;
+3 -3
View File
@@ -45,9 +45,9 @@
namespace display {
WindowText::WindowText(void* object, extent_type margin) :
WindowText::WindowText(rpc::target_type target, extent_type margin) :
Window(new Canvas, 0, 0, 0, extent_static, extent_static),
m_object(object),
m_target(target),
m_margin(margin),
m_interval(0) {
}
@@ -95,7 +95,7 @@ WindowText::redraw() {
Canvas::attributes_list attributes;
attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
char* last = (*itr)->print(buffer, buffer + m_canvas->width(), &attributes, m_object);
char* last = (*itr)->print(buffer, buffer + m_canvas->width(), &attributes, m_target);
m_canvas->print_attributes(0, position, buffer, last, &attributes);
}
+4 -4
View File
@@ -62,13 +62,13 @@ public:
using base_type::rbegin;
using base_type::rend;
WindowText(void* object = NULL, extent_type margin = 0);
WindowText(rpc::target_type target = rpc::make_target(), extent_type margin = 0);
~WindowText() { clear(); }
void clear();
void* object() const { return m_object; }
void set_object(void* object) { m_object = object; }
rpc::target_type target() const { return m_target; }
void set_target(rpc::target_type target) { m_target = target; }
uint32_t interval() const { return m_interval; }
void set_interval(uint32_t i) { m_interval = i; }
@@ -78,7 +78,7 @@ public:
virtual void redraw();
private:
void* m_object;
rpc::target_type m_target;
extent_type m_margin;
uint32_t m_interval;
+2
View File
@@ -6,6 +6,8 @@ libsub_rpc_a_SOURCES = \
command_download_slot.h \
command_file_slot.cc \
command_file_slot.h \
command_file_itr_slot.cc \
command_file_itr_slot.h \
command_peer_slot.cc \
command_peer_slot.h \
command_tracker_slot.cc \
+123
View File
@@ -0,0 +1,123 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2007, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <torrent/data/file.h>
#include "parse.h"
#include "command_file_itr_slot.h"
namespace rpc {
const torrent::Object
CommandFileItrSlot::call_unknown(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& rawArgs) {
CommandFileItrSlot* command = static_cast<CommandFileItrSlot*>(rawCommand);
return command->m_slot(file, rawArgs);
}
const torrent::Object
CommandFileItrSlot::call_list(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& rawArgs) {
CommandFileItrSlot* command = static_cast<CommandFileItrSlot*>(rawCommand);
switch (rawArgs.type()) {
case torrent::Object::TYPE_LIST:
return command->m_slot(file, rawArgs);
case torrent::Object::TYPE_VALUE:
case torrent::Object::TYPE_STRING:
{
torrent::Object tmpList(torrent::Object::TYPE_LIST);
tmpList.as_list().push_back(rawArgs);
return command->m_slot(file, tmpList);
}
default:
throw torrent::input_error("Not a list.");
}
}
const torrent::Object
CommandFileItrSlot::call_value_base(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& rawArgs, int base, int unit) {
CommandFileItrSlot* command = static_cast<CommandFileItrSlot*>(rawCommand);
const torrent::Object& arg = convert_to_single_argument(rawArgs);
switch (arg.type()) {
case torrent::Object::TYPE_VALUE:
// Should shift this one too, so it gives the right unit.
return command->m_slot(file, arg);
case torrent::Object::TYPE_STRING:
{
torrent::Object argValue(torrent::Object::TYPE_VALUE);
if (!parse_whole_value_nothrow(arg.as_string().c_str(), &argValue.as_value(), base, unit))
throw torrent::input_error("Not a value.");
return command->m_slot(file, argValue);
}
default:
throw torrent::input_error("Not a value.");
}
}
const torrent::Object
CommandFileItrSlot::call_string(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& rawArgs) {
CommandFileItrSlot* command = static_cast<CommandFileItrSlot*>(rawCommand);
const torrent::Object& arg = convert_to_single_argument(rawArgs);
switch (arg.type()) {
case torrent::Object::TYPE_STRING:
return command->m_slot(file, arg);
// case torrent::Object::TYPE_NONE:
// throw torrent::input_error("CDS: void.");
// case torrent::Object::TYPE_VALUE:
// throw torrent::input_error("CDS: value.");
// case torrent::Object::TYPE_LIST:
// throw torrent::input_error("CDS: list.");
default:
throw torrent::input_error("Not a string.");
}
}
}
+176
View File
@@ -0,0 +1,176 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2007, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_RPC_COMMAND_FILE_ITR_SLOT_H
#define RTORRENT_RPC_COMMAND_FILE_ITR_SLOT_H
#include <limits>
#include <inttypes.h>
#include <torrent/object.h>
#include <rak/functional_fun.h>
#include "command.h"
namespace torrent {
class FileListIterator;
}
namespace rpc {
class CommandFileItrSlot : public Command {
public:
typedef rak::function2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> slot_type;
CommandFileItrSlot() {}
CommandFileItrSlot(slot_type::base_type* s) {
m_slot.set(s);
}
void set_slot(slot_type::base_type* s) { m_slot.set(s); }
static const torrent::Object call_unknown(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args);
static const torrent::Object call_list(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args);
static const torrent::Object call_string(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args);
static const torrent::Object call_value_base(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args, int base, int unit);
static const torrent::Object call_value(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args) { return call_value_base(rawCommand, file, args, 0, 1); }
static const torrent::Object call_value_kb(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args) { return call_value_base(rawCommand, file, args, 0, 1 << 10); }
template <int base, int unit>
static const torrent::Object call_value(Command* rawCommand, torrent::FileListIterator* file, const torrent::Object& args) { return call_value_base(rawCommand, file, args, base, unit); }
// static const torrent::Object& get_list(Command* rawCommand, const torrent::Object& args);
private:
slot_type m_slot;
};
// Some slots that convert torrent::Object arguments to proper
// function calls.
template <typename Func, typename Result = typename Func::result_type>
class object_void_fi_fn_t : public rak::function_base2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> {
public:
object_void_fi_fn_t(Func func) : m_func(func) {}
virtual torrent::Object operator () (torrent::FileListIterator* file, const torrent::Object& arg1) { return torrent::Object(m_func(file)); }
private:
Func m_func;
};
template <typename Func>
class object_void_fi_fn_t<Func, void> : public rak::function_base2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> {
public:
object_void_fi_fn_t(Func func) : m_func(func) {}
virtual torrent::Object operator () (torrent::FileListIterator* file, const torrent::Object& arg1) {
m_func(file);
return torrent::Object();
}
private:
Func m_func;
};
template <typename Func, typename Result = typename Func::result_type>
class object_value_fi_fn1_t : public rak::function_base2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> {
public:
object_value_fi_fn1_t(Func func) : m_func(func) {}
virtual torrent::Object operator () (torrent::FileListIterator* file, const torrent::Object& arg1) {
return torrent::Object((int64_t)m_func(file, arg1.as_value()));
}
private:
Func m_func;
};
template <typename Func>
class object_value_fi_fn1_t<Func, void> : public rak::function_base2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> {
public:
object_value_fi_fn1_t(Func func) : m_func(func) {}
virtual torrent::Object operator () (torrent::FileListIterator* file, const torrent::Object& arg1) {
m_func(file, arg1.as_value());
return torrent::Object();
}
private:
Func m_func;
};
template <typename Func, typename Result = typename Func::result_type>
class object_string_fi_fn1_t : public rak::function_base2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> {
public:
object_string_fi_fn1_t(Func func) : m_func(func) {}
virtual torrent::Object operator () (torrent::FileListIterator* file, const torrent::Object& arg1) { return torrent::Object(m_func(file, arg1.as_string())); }
private:
Func m_func;
};
template <typename Func>
class object_string_fi_fn1_t<Func, void> : public rak::function_base2<torrent::Object, torrent::FileListIterator*, const torrent::Object&> {
public:
object_string_fi_fn1_t(Func func) : m_func(func) {}
virtual torrent::Object operator () (torrent::FileListIterator* file, const torrent::Object& arg1) {
m_func(file, arg1.as_string());
return torrent::Object();
}
private:
Func m_func;
};
template <typename Return> object_void_fi_fn_t<Return (*)(torrent::FileListIterator*), Return>*
object_fi_fn(Return (*func)(torrent::FileListIterator*)) {
return new object_void_fi_fn_t<Return (*)(torrent::FileListIterator*), Return>(func);
}
template <typename Func> object_void_fi_fn_t<Func>* object_void_fi_fn(Func func) { return new object_void_fi_fn_t<Func>(func); }
template <typename Func> object_value_fi_fn1_t<Func>* object_value_fi_fn(Func func) { return new object_value_fi_fn1_t<Func>(func); }
template <typename Func> object_string_fi_fn1_t<Func>* object_string_fi_fn(Func func) { return new object_string_fi_fn1_t<Func>(func); }
}
#endif
+26 -16
View File
@@ -76,14 +76,6 @@ CommandMap::insert_download(key_type key, Command* variable, download_slot targe
itr->second.m_downloadSlot = targetSlot;
}
void
CommandMap::insert_file(key_type key, Command* variable, file_slot targetSlot, int flags, const char* parm, const char* doc) {
iterator itr = insert(key, variable, flags, parm, doc);
itr->second.m_target = target_file;
itr->second.m_fileSlot = targetSlot;
}
void
CommandMap::insert_peer(key_type key, Command* variable, peer_slot targetSlot, int flags, const char* parm, const char* doc) {
iterator itr = insert(key, variable, flags, parm, doc);
@@ -100,6 +92,22 @@ CommandMap::insert_tracker(key_type key, Command* variable, tracker_slot targetS
itr->second.m_trackerSlot = targetSlot;
}
void
CommandMap::insert_file(key_type key, Command* variable, file_slot targetSlot, int flags, const char* parm, const char* doc) {
iterator itr = insert(key, variable, flags, parm, doc);
itr->second.m_target = target_file;
itr->second.m_fileSlot = targetSlot;
}
void
CommandMap::insert_file_itr(key_type key, Command* variable, file_itr_slot targetSlot, int flags, const char* parm, const char* doc) {
iterator itr = insert(key, variable, flags, parm, doc);
itr->second.m_target = target_file_itr;
itr->second.m_fileItrSlot = targetSlot;
}
void
CommandMap::insert(key_type key, const command_map_data_type src) {
iterator itr = base_type::find(key);
@@ -135,11 +143,12 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe
// This _should_ be optimized int just two calls.
switch (itr->second.m_target) {
case target_generic: return itr->second.m_genericSlot(itr->second.m_variable, arg);
case target_generic: return itr->second.m_genericSlot (itr->second.m_variable, arg);
case target_download: return itr->second.m_downloadSlot(itr->second.m_variable, (core::Download*)target.second, arg);
case target_file: return itr->second.m_fileSlot(itr->second.m_variable, (torrent::File*)target.second, arg);
case target_peer: return itr->second.m_peerSlot(itr->second.m_variable, (torrent::Peer*)target.second, arg);
case target_tracker: return itr->second.m_trackerSlot(itr->second.m_variable, (torrent::Tracker*)target.second, arg);
case target_peer: return itr->second.m_peerSlot (itr->second.m_variable, (torrent::Peer*)target.second, arg);
case target_tracker: return itr->second.m_trackerSlot (itr->second.m_variable, (torrent::Tracker*)target.second, arg);
case target_file: return itr->second.m_fileSlot (itr->second.m_variable, (torrent::File*)target.second, arg);
case target_file_itr: return itr->second.m_fileItrSlot (itr->second.m_variable, (torrent::FileListIterator*)target.second, arg);
default: throw torrent::internal_error("CommandMap::call_command(...) Invalid target.");
}
}
@@ -152,11 +161,12 @@ CommandMap::call_command(const_iterator itr, const mapped_type& arg, target_type
// This _should_ be optimized int just two calls.
switch (itr->second.m_target) {
case target_generic: return itr->second.m_genericSlot(itr->second.m_variable, arg);
case target_generic: return itr->second.m_genericSlot (itr->second.m_variable, arg);
case target_download: return itr->second.m_downloadSlot(itr->second.m_variable, (core::Download*)target.second, arg);
case target_file: return itr->second.m_fileSlot(itr->second.m_variable, (torrent::File*)target.second, arg);
case target_peer: return itr->second.m_peerSlot(itr->second.m_variable, (torrent::Peer*)target.second, arg);
case target_tracker: return itr->second.m_trackerSlot(itr->second.m_variable, (torrent::Tracker*)target.second, arg);
case target_peer: return itr->second.m_peerSlot (itr->second.m_variable, (torrent::Peer*)target.second, arg);
case target_tracker: return itr->second.m_trackerSlot (itr->second.m_variable, (torrent::Tracker*)target.second, arg);
case target_file: return itr->second.m_fileSlot (itr->second.m_variable, (torrent::File*)target.second, arg);
case target_file_itr: return itr->second.m_fileItrSlot (itr->second.m_variable, (torrent::FileListIterator*)target.second, arg);
default: throw torrent::internal_error("CommandMap::call_command(...) Invalid target.");
}
}
+28 -10
View File
@@ -48,6 +48,7 @@ namespace core {
namespace torrent {
class File;
class FileListIterator;
class Peer;
class Tracker;
}
@@ -64,11 +65,12 @@ struct command_map_data_type {
// Some commands will need to share data, like get/set a variable. So
// instead of using a single virtual member function, each command
// will register a member function pointer to be used instead.
typedef const torrent::Object (*generic_slot) (Command*, const torrent::Object&);
typedef const torrent::Object (*download_slot)(Command*, core::Download*, const torrent::Object&);
typedef const torrent::Object (*file_slot) (Command*, torrent::File*, const torrent::Object&);
typedef const torrent::Object (*peer_slot) (Command*, torrent::Peer*, const torrent::Object&);
typedef const torrent::Object (*tracker_slot) (Command*, torrent::Tracker*, const torrent::Object&);
typedef const torrent::Object (*generic_slot) (Command*, const torrent::Object&);
typedef const torrent::Object (*download_slot) (Command*, core::Download*, const torrent::Object&);
typedef const torrent::Object (*file_slot) (Command*, torrent::File*, const torrent::Object&);
typedef const torrent::Object (*file_itr_slot) (Command*, torrent::FileListIterator*, const torrent::Object&);
typedef const torrent::Object (*peer_slot) (Command*, torrent::Peer*, const torrent::Object&);
typedef const torrent::Object (*tracker_slot) (Command*, torrent::Tracker*, const torrent::Object&);
command_map_data_type(Command* variable, int flags, const char* parm, const char* doc) :
m_variable(variable), m_flags(flags), m_parm(parm), m_doc(doc) {}
@@ -81,6 +83,7 @@ struct command_map_data_type {
generic_slot m_genericSlot;
download_slot m_downloadSlot;
file_slot m_fileSlot;
file_itr_slot m_fileItrSlot;
peer_slot m_peerSlot;
tracker_slot m_trackerSlot;
};
@@ -99,6 +102,7 @@ public:
typedef command_map_data_type::generic_slot generic_slot;
typedef command_map_data_type::download_slot download_slot;
typedef command_map_data_type::file_slot file_slot;
typedef command_map_data_type::file_itr_slot file_itr_slot;
typedef command_map_data_type::peer_slot peer_slot;
typedef command_map_data_type::tracker_slot tracker_slot;
@@ -118,9 +122,10 @@ public:
static const int target_generic = 0;
static const int target_download = 1;
static const int target_file = 2;
static const int target_peer = 3;
static const int target_tracker = 4;
static const int target_peer = 2;
static const int target_tracker = 3;
static const int target_file = 4;
static const int target_file_itr = 5;
static const int flag_dont_delete = 0x1;
static const int flag_public_xmlrpc = 0x2;
@@ -135,9 +140,10 @@ public:
void insert_generic (key_type key, Command* variable, generic_slot targetSlot, int flags, const char* parm, const char* doc);
void insert_download(key_type key, Command* variable, download_slot targetSlot, int flags, const char* parm, const char* doc);
void insert_file (key_type key, Command* variable, file_slot targetSlot, int flags, const char* parm, const char* doc);
void insert_peer (key_type key, Command* variable, peer_slot targetSlot, int flags, const char* parm, const char* doc);
void insert_tracker (key_type key, Command* variable, tracker_slot targetSlot, int flags, const char* parm, const char* doc);
void insert_file (key_type key, Command* variable, file_slot targetSlot, int flags, const char* parm, const char* doc);
void insert_file_itr(key_type key, Command* variable, file_itr_slot targetSlot, int flags, const char* parm, const char* doc);
void insert(key_type key, const command_map_data_type src);
@@ -145,15 +151,27 @@ public:
const mapped_type call_command (const_iterator itr, const mapped_type& arg, target_type target = target_type((int)target_generic, NULL));
const mapped_type call_command_d(key_type key, core::Download* download, const mapped_type& arg) { return call_command(key, arg, target_type((int)target_download, download)); }
const mapped_type call_command_f(key_type key, torrent::File* file, const mapped_type& arg) { return call_command(key, arg, target_type((int)target_file, file)); }
const mapped_type call_command_p(key_type key, torrent::Peer* peer, const mapped_type& arg) { return call_command(key, arg, target_type((int)target_peer, peer)); }
const mapped_type call_command_t(key_type key, torrent::Tracker* tracker, const mapped_type& arg) { return call_command(key, arg, target_type((int)target_tracker, tracker)); }
const mapped_type call_command_f(key_type key, torrent::File* file, const mapped_type& arg) { return call_command(key, arg, target_type((int)target_file, file)); }
private:
CommandMap(const CommandMap&);
void operator = (const CommandMap&);
};
// Since it gets used so many places we might as well put it in the
// rpc namespace.
typedef CommandMap::target_type target_type;
inline target_type make_target() { return target_type((int)CommandMap::target_generic, NULL); }
inline target_type make_target(core::Download* target) { return target_type((int)CommandMap::target_download, target); }
inline target_type make_target(torrent::Peer* target) { return target_type((int)CommandMap::target_peer, target); }
inline target_type make_target(torrent::Tracker* target) { return target_type((int)CommandMap::target_tracker, target); }
inline target_type make_target(torrent::File* target) { return target_type((int)CommandMap::target_file, target); }
inline target_type make_target(torrent::FileListIterator* target) { return target_type((int)CommandMap::target_file_itr, target); }
inline target_type make_target(int type, void* target) { return target_type(type, target); }
}
#endif
-9
View File
@@ -50,20 +50,11 @@ namespace core {
namespace rpc {
typedef CommandMap::target_type target_type;
// Move to another file?
extern CommandMap commands;
extern XmlRpc xmlrpc;
extern ExecFile execFile;
inline target_type make_target() { return target_type((int)CommandMap::target_generic, NULL); }
inline target_type make_target(core::Download* target) { return target_type((int)CommandMap::target_download, target); }
inline target_type make_target(torrent::File* target) { return target_type((int)CommandMap::target_file, target); }
inline target_type make_target(torrent::Peer* target) { return target_type((int)CommandMap::target_peer, target); }
inline target_type make_target(torrent::Tracker* target) { return target_type((int)CommandMap::target_tracker, target); }
inline target_type make_target(int type, void* target) { return target_type(type, target); }
typedef std::pair<torrent::Object, const char*> parse_command_type;
// The generic parse command function, used by the rest. At some point
+3 -1
View File
@@ -65,8 +65,10 @@ public:
// These need to match CommandMap type values.
static const int call_generic = 0;
static const int call_download = 1;
static const int call_file = 2;
static const int call_peer = 2;
static const int call_tracker = 3;
static const int call_file = 4;
static const int call_file_itr = 5;
XmlRpc() : m_env(NULL), m_registry(NULL), m_dialect(dialect_i8) {}
+15 -15
View File
@@ -140,48 +140,48 @@ inline ElementBase*
Download::create_info() {
using namespace display::helpers;
ElementText* element = new ElementText(m_download);
ElementText* element = new ElementText(rpc::make_target(m_download));
element->set_column(1);
element->set_interval(1);
// Get these bindings with some kind of string map.
element->push_column("Name:", te_string(&torrent::Download::name));
element->push_column("Local id:", te_string(&torrent::Download::local_id, string_base::flag_escape_html));
element->push_column("Info hash:", te_string(&torrent::Download::info_hash, string_base::flag_escape_hex));
element->push_column("Created:", te_value(&torrent::Download::creation_date, value_base::flag_date), " ", te_value(&torrent::Download::creation_date, value_base::flag_time));
element->push_column("Name:", te_variable_string("d.get_name"));
element->push_column("Local id:", te_variable_string("d.get_local_id_html"));
element->push_column("Info hash:", te_variable_string("d.get_hash"));
element->push_column("Created:", te_variable_value("d.get_creation_date", value_base::flag_date), " ", te_variable_value("d.get_creation_date", value_base::flag_time));
element->push_back("");
element->push_column("Directory:", te_string(&torrent::FileList::root_dir));
element->push_column("Directory:", te_variable_string("d.get_base_path"));
element->push_column("Tied to file:", te_variable_string("d.get_tied_to_file"));
element->push_column("File stats:",
te_branch(&core::Download::c_file_list, &torrent::FileList::is_multi_file, te_string("multi"), te_string("single")),
" ", te_value(&torrent::FileList::size_files), " files");
" ", te_variable_value("d.get_size_files"), " files");
element->push_back("");
element->push_column("Chunks:", te_value(&torrent::FileList::completed_chunks), " / ", te_value(&torrent::FileList::size_chunks), " * ", te_value(&torrent::FileList::chunk_size));
element->push_column("Chunks:", te_variable_value("d.get_completed_chunks"), " / ", te_variable_value("d.get_size_chunks"), " * ", te_variable_value("d.get_chunk_size"));
element->push_column("Priority:", te_variable_value("d.get_priority"));
element->push_column("State changed:", te_variable_value("d.get_state_changed", value_base::flag_timer | value_base::flag_elapsed));
element->push_back("");
element->push_column("Memory usage:", te_value(&torrent::ChunkManager::memory_usage, value_base::flag_mb), " MB");
element->push_column("Max memory usage:", te_value(&torrent::ChunkManager::max_memory_usage, value_base::flag_mb), " MB");
element->push_column("Free diskspace:", te_value(&torrent::FileList::free_diskspace, value_base::flag_mb), " MB");
element->push_column("Safe diskspace:", te_value(&torrent::ChunkManager::safe_free_diskspace, value_base::flag_mb), " MB");
element->push_column("Memory usage:", te_variable_value("get_memory_usage", value_base::flag_mb), " MB");
element->push_column("Max memory usage:", te_variable_value("get_max_memory_usage", value_base::flag_mb), " MB");
element->push_column("Free diskspace:", te_variable_value("d.get_free_diskspace", value_base::flag_mb), " MB");
element->push_column("Safe diskspace:", te_variable_value("get_safe_free_diskspace", value_base::flag_mb), " MB");
element->push_back("");
element->push_column("Connection type:", te_variable_string("d.get_connection_current"));
element->push_column("Safe sync:", te_branch(&torrent::ChunkManager::safe_sync, torrent::chunk_manager(), te_string("yes"), te_string("no")));
element->push_column("Send buffer:", te_value(&torrent::ConnectionManager::send_buffer_size, value_base::flag_kb), " KB");
element->push_column("Receive buffer:", te_value(&torrent::ConnectionManager::receive_buffer_size, value_base::flag_kb), " KB");
element->push_column("Send buffer:", te_variable_value("get_send_buffer_size", value_base::flag_kb), " KB");
element->push_column("Receive buffer:", te_variable_value("get_receive_buffer_size", value_base::flag_kb), " KB");
element->push_back("");
element->push_column("Upload:", te_variable_value("d.get_up_rate", value_base::flag_kb), " KB / ", te_variable_value("d.get_up_total", value_base::flag_xb));
element->push_column("Download:", te_variable_value("d.get_down_rate", value_base::flag_kb), " KB / ", te_variable_value("d.get_down_total", value_base::flag_xb));
element->push_column("Skipped:", te_variable_value("d.get_skip_rate", value_base::flag_kb), " KB / ", te_variable_value("d.get_skip_total", value_base::flag_xb));
element->push_column("Preload:", te_value(&torrent::ChunkManager::preload_type), " / ", te_value(&torrent::ChunkManager::stats_preloaded), " / ", te_value(&torrent::ChunkManager::stats_not_preloaded));
element->push_column("Preload:", te_variable_value("get_preload_type"), " / ", te_variable_value("get_stats_preloaded"), " / ", te_variable_value("get_stats_not_preloaded"));
element->set_column_width(element->column_width() + 1);
+2 -2
View File
@@ -93,7 +93,7 @@ inline ElementText*
element_file_list_create_info() {
using namespace display::helpers;
ElementText* element = new ElementText(NULL);
ElementText* element = new ElementText(rpc::make_target());
element->set_column(1);
element->set_interval(1);
@@ -127,7 +127,7 @@ ElementFileList::activate(display::Frame* frame, bool focus) {
m_elementInfo = element_file_list_create_info();
m_elementInfo->slot_exit(sigc::bind(sigc::mem_fun(this, &ElementFileList::activate_display), DISPLAY_LIST));
m_elementInfo->set_object(&m_selected);
m_elementInfo->set_target(rpc::make_target(&m_selected));
m_frame = frame;
+1 -1
View File
@@ -68,7 +68,7 @@ ElementMenu::unfocus_entry(size_type idx) {
}
ElementMenu::ElementMenu() :
m_window(new WindowText(NULL, 2)),
m_window(new WindowText(rpc::make_target(), 2)),
m_entry(entry_invalid) {
// Move bindings into a function that defines default bindings.
+2 -2
View File
@@ -101,7 +101,7 @@ inline ElementText*
ElementPeerList::create_info() {
using namespace display::helpers;
ElementText* element = new ElementText(NULL);
ElementText* element = new ElementText(rpc::make_target());
element->set_column(1);
element->set_interval(1);
@@ -263,7 +263,7 @@ ElementPeerList::receive_snub_peer() {
void
ElementPeerList::update_itr() {
m_windowList->mark_dirty();
m_elementInfo->set_object(m_listItr != m_list.end() ? &*m_listItr : NULL);
m_elementInfo->set_target(m_listItr != m_list.end() ? rpc::make_target(&*m_listItr) : rpc::make_target());
}
}
+2 -2
View File
@@ -48,8 +48,8 @@
namespace ui {
ElementText::ElementText(void *object) :
m_window(new WindowText(object)),
ElementText::ElementText(rpc::target_type target) :
m_window(new WindowText(target)),
m_column(0),
m_columnWidth(0) {
+3 -3
View File
@@ -60,11 +60,11 @@ public:
typedef uint32_t size_type;
typedef uint32_t extent_type;
ElementText(void *object);
ElementText(rpc::target_type target);
~ElementText();
void* object() const { return m_window->object(); }
void set_object(void* object) { m_window->set_object(object); m_window->mark_dirty(); }
rpc::target_type target() const { return m_window->target(); }
void set_target(rpc::target_type target) { m_window->set_target(target); m_window->mark_dirty(); }
uint32_t interval() const { return m_window->interval(); }
void set_interval(uint32_t i) { m_window->set_interval(i); m_window->mark_dirty(); }