You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB

#include <SessionContext.hpp>
#include <sstream>
#include <vector>
std::string TestResponse::string() {
buffer = str();
return buffer;
}
std::string TestResponse::message() {
if (buffer.empty())
string();
auto msg = buffer.substr(13, buffer.find('\r') - 13);
return msg;
}
std::string TestResponse::code() {
if (buffer.empty())
string();
return buffer.substr(9, 3);
}
void TestSessionSettings::set_int(int type, int value) {
if (type == download_rate_limit) {
download_rate_limit_ = value;
}
if (type == upload_rate_limit) {
upload_rate_limit_ = value;
}
if (type == enable_dht) {
enable_dht_ = value;
}
}
void TestSessionSettings::set_bool(int type, int value) {
set_int(type, value);
}
int TestSessionSettings::get_int(int type) const {
if (type == download_rate_limit) {
return download_rate_limit_;
}
if (type == upload_rate_limit) {
return upload_rate_limit_;
}
if (type == enable_dht) {
return enable_dht_;
}
return 0;
};
bool TestSessionSettings::get_bool(int type) { return get_int(type); }
std::string TestSessionSettings::get_str(int type) {
if (type == listen_interfaces) {
return listen_interfaces_;
}
}
void TestSessionSettings::set_str(int type, std::string value) {
if (type == listen_interfaces) {
listen_interfaces_ = value;
}
}
bool TestTorrentSession::is_valid() {
return valid;
}
TestSessionSettings TestTorrentSession::get_settings() {
return settings_;
}
bool TestTorrentSession::is_paused() const {
return paused;
}
void TestTorrentSession::pause() {
paused = true;
}
void TestTorrentSession::resume() {
paused = false;
}
int TestTorrentSession::listen_port() {
return std::stoi(settings_.listen_interfaces_.substr(8, settings_.listen_interfaces_.size() - 8));
}
bool TestTorrentSession::is_dht_running() const {
return settings_.enable_dht_;
}
std::vector<TestTorrent> TestTorrentSession::get_torrents() const {
return std::vector<TestTorrent>();
}
void TestTorrentSession::apply_settings(TestSessionSettings settings) {
settings_ = settings;
};