-
Notifications
You must be signed in to change notification settings - Fork 21
/
daemon.hpp
60 lines (52 loc) · 1.3 KB
/
daemon.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __DAEMON_HPP__
#define __DAEMON_HPP__
#include <atomic>
#include <string>
#include <vector>
#include <libtorrent/libtorrent.hpp>
#include <boost/core/noncopyable.hpp>
#include "service.hpp"
namespace ezio
{
struct torrent_status {
std::string hash;
std::string name;
double progress;
int64_t download_rate;
int64_t upload_rate;
int64_t active_time;
bool is_finished;
int64_t num_peers;
int64_t state;
int64_t total_done;
int64_t total;
int64_t num_pieces;
int64_t finished_time;
int64_t seeding_time;
int64_t total_payload_download;
int64_t total_payload_upload;
bool is_paused;
std::string save_path;
int64_t last_upload;
int64_t last_download;
};
class ezio : boost::noncopyable
{
public:
ezio(lt::session &);
~ezio() = default;
void stop();
void wait(int interval_second);
void add_torrent(std::string torrent_body, std::string save_path, bool seeding_mode, int max_uploads, int max_connections, bool sequential_download);
std::map<std::string, torrent_status> get_torrent_status(std::vector<std::string> hashes);
void pause_torrent(std::string hash);
void resume_torrent(std::string hash);
bool get_shutdown();
void pop_alerts(std::vector<lt::alert *> *);
std::string get_version();
private:
lt::session &session_;
std::atomic_bool shutdown_;
};
} // namespace ezio
#endif