Added "-d" to change the default root dir.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@388 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-04-09 21:48:59 +00:00
parent 472c19fe67
commit f8bbf8bfad
7 changed files with 35 additions and 16 deletions
-3
View File
@@ -31,6 +31,3 @@ Bug: Add the same torrent while it is hash checking.
RELEASE:
Enable change of default download path.
Make sure we show better messages for signal_storage_error.
+9 -1
View File
@@ -48,7 +48,15 @@ Download::release_download() {
void
Download::receive_tracker_msg(std::string msg) {
m_trackerMsg = msg;
if (msg.empty())
m_message = "";
else
m_message = "Tracker: [" + msg + "]";
}
void
Download::receive_storage_error(std::string msg) {
m_message = "Storage error: [" + msg + "]";
}
}
+3 -2
View File
@@ -39,7 +39,7 @@ public:
torrent::Download& get_download() { return m_download; }
std::string get_hash() { return m_download.get_hash(); }
const std::string& get_tracker_msg() { return m_trackerMsg; }
const std::string& get_message() { return m_message; }
void start() { m_download.start(); }
void stop() { m_download.stop(); }
@@ -51,10 +51,11 @@ public:
private:
void receive_tracker_msg(std::string msg);
void receive_storage_error(std::string msg);
torrent::Download m_download;
std::string m_trackerMsg;
std::string m_message;
sigc::connection m_connTrackerSucceded;
sigc::connection m_connTrackerFailed;
+3
View File
@@ -170,6 +170,9 @@ Manager::create_final(std::istream* s) {
(*itr)->get_download().set_ip(m_dns);
if (!m_defaultRoot.empty())
(*itr)->get_download().set_root_dir(m_defaultRoot + ((*itr)->get_download().get_entry_size() ? (*itr)->get_download().get_name() : ""));
start(*itr);
m_downloadStore.save(*itr);
+12
View File
@@ -68,6 +68,8 @@ public:
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
void set_listen_ip(const std::string& ip) { m_listenIp = ip; }
void set_default_root(const std::string& path);
void debug_tracker() { m_debugTracker = 0; }
private:
@@ -95,9 +97,19 @@ private:
int m_portLast;
std::string m_listenIp;
std::string m_defaultRoot;
int m_debugTracker;
};
inline void
Manager::set_default_root(const std::string& path) {
m_defaultRoot = path;
if (!m_defaultRoot.empty() && *m_defaultRoot.rbegin() != '/')
m_defaultRoot.push_back('/');
}
}
#endif
+6 -10
View File
@@ -35,25 +35,21 @@ namespace display {
std::string
print_download_status(core::Download* d) {
std::stringstream str;
if (d->get_download().is_hash_checking()) {
str << "Checking hash";
return "Checking hash";
} else if (d->get_download().is_tracker_busy()) {
str << "Tracker: Connecting";
return "Tracker: Connecting";
} else if (!d->get_download().is_active()) {
str << "Inactive";
return "Inactive";
} else if (!d->get_tracker_msg().empty()) {
str << "Tracker: [" << d->get_tracker_msg() << ']';
} else if (!d->get_message().empty()) {
return d->get_message();
} else {
//str << "---";
return "";
}
return str.str();
}
std::string
+2
View File
@@ -94,6 +94,7 @@ parse_options(ui::Control* c, int argc, char** argv) {
optionParser.insert_flag('h', sigc::ptr_fun(&print_help));
optionParser.insert_option('b', sigc::mem_fun(c->get_core(), &core::Manager::set_listen_ip));
optionParser.insert_option('d', sigc::mem_fun(c->get_core(), &core::Manager::set_default_root));
optionParser.insert_option('i', sigc::mem_fun(c->get_core(), &core::Manager::set_dns));
optionParser.insert_option('p', sigc::bind(sigc::ptr_fun(OptionParser::call_int_pair),
@@ -230,6 +231,7 @@ print_help() {
std::cout << " -b <a.b.c.d> Bind the listening socket to this IP" << std::endl;
std::cout << " -i <a.b.c.d> Change the IP that is sent to the tracker" << std::endl;
std::cout << " -p <int>-<int> Set port range for incoming connections" << std::endl;
std::cout << " -d <directory> Save torrents to this directory by default" << std::endl;
std::cout << " -s <directory> Set the session directory" << std::endl;
std::cout << std::endl;
std::cout << "Main view keys:" << std::endl;