* Fixed 'd.group.set' for the mainline version.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1264 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2011-08-06 08:01:09 +00:00
parent ce16621707
commit ea192b342c
4 changed files with 37 additions and 13 deletions
+13 -12
View File
@@ -599,10 +599,8 @@ d_list_remove(core::Download* download, const torrent::Object& rawArgs, const ch
std::placeholders::_1, std::placeholders::_2, \
first_key, second_key));
torrent::choke_group* cg_get_group(const torrent::Object& raw_args);
int64_t cg_get_index(const torrent::Object& raw_args);
#define CG_GROUP_INDEX() std::bind(&cg_get_index, std::placeholders::_2)
int64_t cg_d_group(core::Download* download);
void cg_d_group_set(core::Download* download, const torrent::Object& arg);
void
initialize_command_download() {
@@ -808,15 +806,18 @@ initialize_command_download() {
CMD2_DL ("d.priority_str", std::bind(&retrieve_d_priority_str, std::placeholders::_1));
CMD2_DL_VALUE_V ("d.priority.set", std::bind(&core::Download::set_priority, std::placeholders::_1, std::placeholders::_2));
CMD2_DL ("d.group", std::bind(&torrent::resource_manager_entry::group,
std::bind(&torrent::ResourceManager::entry_at, torrent::resource_manager(),
std::bind(&core::Download::main, std::placeholders::_1))));
// CMD2_DL ("d.group", std::bind(&torrent::resource_manager_entry::group,
// std::bind(&torrent::ResourceManager::entry_at, torrent::resource_manager(),
// std::bind(&core::Download::main, std::placeholders::_1))));
CMD2_DL_V ("d.group.set", std::bind(&torrent::ResourceManager::set_group,
torrent::resource_manager(),
std::bind(&torrent::ResourceManager::find_throw, torrent::resource_manager(),
std::bind(&core::Download::main, std::placeholders::_1)),
CG_GROUP_INDEX()));
// CMD2_DL_V ("d.group.set", std::bind(&torrent::ResourceManager::set_group,
// torrent::resource_manager(),
// std::bind(&torrent::ResourceManager::find_throw, torrent::resource_manager(),
// std::bind(&core::Download::main, std::placeholders::_1)),
// CG_GROUP_INDEX()));
CMD2_DL ("d.group", std::bind(&cg_d_group, std::placeholders::_1));;
CMD2_DL_V ("d.group.set", std::bind(&cg_d_group_set, std::placeholders::_1, std::placeholders::_2));
CMD2_DL ("d.initialize_logs", std::bind(&cmd_d_initialize_logs, std::placeholders::_1));
+16
View File
@@ -49,6 +49,9 @@
#include "control.h"
#include "command_helpers.h"
// For cg_d_group.
#include "core/download.h"
// A hack to allow testing of the new choke_group API without the
// working parts present.
#define USE_CHOKE_GROUP 0
@@ -80,6 +83,16 @@ cg_get_group(const torrent::Object& raw_args) {
return torrent::resource_manager()->group_at(cg_get_index(raw_args));
}
int64_t
cg_d_group(core::Download* download) {
return torrent::resource_manager()->entry_at(download->main())->group();
}
void
cg_d_group_set(core::Download* download, const torrent::Object& arg) {
torrent::resource_manager::set_group(torrent::resource_manager()->find_throw(download->main()), cg_get_index(arg));
}
torrent::Object
apply_cg_list() {
torrent::Object::list_type result;
@@ -151,6 +164,9 @@ cg_get_group(const torrent::Object& raw_args) {
return cg_list_hack.at(index);
}
int64_t cg_d_group(core::Download* download) { return download->group(); }
void cg_d_group_set(core::Download* download, const torrent::Object& arg) { download->set_group(cg_get_index(arg)); }
torrent::Object
apply_cg_list() {
torrent::Object::list_type result;
+2 -1
View File
@@ -61,7 +61,8 @@ Download::Download(download_type d) :
m_hashFailed(false),
m_chunksFailed(0),
m_resumeFlags(~uint32_t()) {
m_resumeFlags(~uint32_t()),
m_group(0) {
m_connTrackerSucceeded = m_download.info()->signal_tracker_success().connect(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
m_connTrackerFailed = m_download.info()->signal_tracker_failed().connect(sigc::mem_fun(*this, &Download::receive_tracker_msg));
+6
View File
@@ -129,6 +129,10 @@ public:
float distributed_copies() const;
// HACK: Choke group setting.
unsigned int group() const { return m_group; }
void set_group(unsigned int g) { m_group = g; }
private:
Download(const Download&);
void operator () (const Download&);
@@ -151,6 +155,8 @@ private:
sigc::connection m_connTrackerSucceeded;
sigc::connection m_connTrackerFailed;
sigc::connection m_connStorageError;
unsigned int m_group;
};
inline bool