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.

56 lines
1.3 KiB

#ifndef _TR_TEST_TORRENT_CONTEXT_HPP_
#define _TR_TEST_TORRENT_CONTEXT_HPP_
#include <string>
#include <libtorrent/magnet_uri.hpp>
class InfoHash {
private:
std::string hash;
public:
InfoHash(const std::string &h) : hash(h) {}
std::string to_string() { return hash; }
};
class TorrentStatus {
public:
bool paused = false;
bool is_seeding = false;
bool announcing_to_dht = true;
int state = 0;
int priority = 0;
std::string name = "Arch";
std::string save_path;
};
class TestTorrent {
public:
TestTorrent(const libtorrent::add_torrent_params &params) : hash(params.info_hash.to_string()) {
auto paused = (params.flags & libtorrent::add_torrent_params::flag_paused) == libtorrent::add_torrent_params::flag_paused;
status_.paused = paused;
status_.save_path = params.save_path;
status_.name = params.name;
upload_limit_ = params.upload_limit;
download_limit_ = params.download_limit;
}
TestTorrent() : hash("12a") {}
bool is_valid();
InfoHash info_hash();
TorrentStatus status(int type = 0);
int query_name = 1;
int query_save_path = 2;
bool valid = true;
int upload_limit_ = 0;
int upload_limit(){
return upload_limit_;
}
int download_limit_ = 0;
int download_limit(){
return download_limit_;
}
InfoHash hash;
TorrentStatus status_;
};
#endif