|
|
|
|
#ifndef _TR_TEST_SESSION_CONTEXT_HPP_
|
|
|
|
|
#define _TR_TEST_SESSION_CONTEXT_HPP_
|
|
|
|
|
|
|
|
|
|
#include <TorrentContext.hpp>
|
|
|
|
|
#include <libtorrent/magnet_uri.hpp>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
class TestSessionSettings {
|
|
|
|
|
public:
|
|
|
|
|
int download_rate_limit = 1;
|
|
|
|
|
int upload_rate_limit = 2;
|
|
|
|
|
int listen_interfaces = 3;
|
|
|
|
|
int enable_dht = 4;
|
|
|
|
|
bool enable_dht_ = true;
|
|
|
|
|
int download_rate_limit_ = 0;
|
|
|
|
|
int upload_rate_limit_ = 0;
|
|
|
|
|
std::string listen_interfaces_ = "0.0.0.0:0";
|
|
|
|
|
void set_bool(int type, int value);
|
|
|
|
|
void set_int(int type, int value);
|
|
|
|
|
void set_str(int type, std::string value);
|
|
|
|
|
int get_int(int type) const;
|
|
|
|
|
bool get_bool(int type);
|
|
|
|
|
std::string get_str(int type);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TestSession {
|
|
|
|
|
public:
|
|
|
|
|
bool valid = false;
|
|
|
|
|
bool paused = false;
|
|
|
|
|
std::vector<TestTorrent> torrents_;
|
|
|
|
|
TestSessionSettings settings_;
|
|
|
|
|
bool is_valid();
|
|
|
|
|
TestSessionSettings get_settings();
|
|
|
|
|
bool is_paused() const;
|
|
|
|
|
void pause();
|
|
|
|
|
void resume();
|
|
|
|
|
int listen_port();
|
|
|
|
|
bool is_dht_running() const;
|
|
|
|
|
std::vector<TestTorrent> &get_torrents();
|
|
|
|
|
TestTorrent find_torrent(const libtorrent::sha1_hash &hash);
|
|
|
|
|
void remove_torrent(const TestTorrent &torrent);
|
|
|
|
|
void apply_settings(TestSessionSettings settings);
|
|
|
|
|
void async_add_torrent(const libtorrent::add_torrent_params ¶ms);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|