42
#include <torrent/common.h>
43
43
#include <torrent/download.h>
45
#include <sys/types.h>
46
#include <sys/select.h>
50
45
namespace torrent {
55
class ConnectionManager;
58
47
// Make sure you seed srandom and srand48 if available.
59
void initialize(Poll* poll);
48
void initialize(Poll* poll) LIBTORRENT_EXPORT;
61
50
// Clean up and close stuff. Stopping all torrents and waiting for
62
51
// them to finish is not required, but recommended.
52
void cleanup() LIBTORRENT_EXPORT;
65
int64_t next_timeout();
54
int64_t next_timeout() LIBTORRENT_EXPORT;
67
56
// Calls this function when get_next_timeout() is zero or at
68
57
// semi-regular intervals when socket events accure. It updates the
69
58
// cached time and performs scheduled tasks.
71
60
// Bad name, find something better.
76
ChunkManager* chunk_manager();
77
ConnectionManager* connection_manager();
79
uint32_t total_handshakes();
61
void perform() LIBTORRENT_EXPORT;
63
bool is_inactive() LIBTORRENT_EXPORT;
65
ChunkManager* chunk_manager() LIBTORRENT_EXPORT;
66
ClientList* client_list() LIBTORRENT_EXPORT;
67
ConnectionManager* connection_manager() LIBTORRENT_EXPORT;
69
uint32_t total_handshakes() LIBTORRENT_EXPORT;
81
71
// These should really be unsigned, but there was a bug in the
82
72
// client. ;( Fix this later.
85
int32_t down_throttle();
86
void set_down_throttle(int32_t bytes);
88
int32_t up_throttle();
89
void set_up_throttle(int32_t bytes);
91
uint32_t currently_unchoked();
92
uint32_t max_unchoked();
93
void set_max_unchoked(uint32_t count);
95
const Rate* down_rate();
96
const Rate* up_rate();
98
const char* version();
75
int32_t down_throttle() LIBTORRENT_EXPORT;
76
void set_down_throttle(int32_t bytes) LIBTORRENT_EXPORT;
78
int32_t up_throttle() LIBTORRENT_EXPORT;
79
void set_up_throttle(int32_t bytes) LIBTORRENT_EXPORT;
81
uint32_t currently_unchoked() LIBTORRENT_EXPORT;
82
uint32_t max_unchoked() LIBTORRENT_EXPORT;
83
void set_max_unchoked(uint32_t count) LIBTORRENT_EXPORT;
85
uint32_t download_unchoked() LIBTORRENT_EXPORT;
86
uint32_t max_download_unchoked() LIBTORRENT_EXPORT;
87
void set_max_download_unchoked(uint32_t count) LIBTORRENT_EXPORT;
89
const Rate* down_rate() LIBTORRENT_EXPORT;
90
const Rate* up_rate() LIBTORRENT_EXPORT;
92
const char* version() LIBTORRENT_EXPORT;
100
94
// Disk access tuning.
101
uint32_t hash_read_ahead();
102
void set_hash_read_ahead(uint32_t bytes);
104
uint32_t hash_interval();
105
void set_hash_interval(uint32_t usec);
107
uint32_t hash_max_tries();
108
void set_hash_max_tries(uint32_t tries);
110
uint32_t open_files();
111
uint32_t max_open_files();
112
void set_max_open_files(uint32_t size);
114
uint32_t open_sockets();
115
uint32_t max_open_sockets();
116
void set_max_open_sockets(uint32_t size);
95
uint32_t hash_read_ahead() LIBTORRENT_EXPORT;
96
void set_hash_read_ahead(uint32_t bytes) LIBTORRENT_EXPORT;
98
uint32_t hash_interval() LIBTORRENT_EXPORT;
99
void set_hash_interval(uint32_t usec) LIBTORRENT_EXPORT;
101
uint32_t hash_max_tries() LIBTORRENT_EXPORT;
102
void set_hash_max_tries(uint32_t tries) LIBTORRENT_EXPORT;
104
uint32_t open_files() LIBTORRENT_EXPORT;
105
uint32_t max_open_files() LIBTORRENT_EXPORT;
106
void set_max_open_files(uint32_t size) LIBTORRENT_EXPORT;
118
108
typedef std::list<Download> DList;
119
109
typedef std::list<std::string> EncodingList;
121
EncodingList* encoding_list();
111
EncodingList* encoding_list() LIBTORRENT_EXPORT;
123
113
// Will always return a valid Download. On errors it
124
114
// throws. 'encodingList' contains a list of prefered encodings to use
129
119
// is done by 'download_remove'.
131
121
// Might consider redesigning that...
132
Download download_add(Object* s);
133
void download_remove(Download d);
122
Download download_add(Object* s) LIBTORRENT_EXPORT;
123
void download_remove(Download d) LIBTORRENT_EXPORT;
135
125
// Add all downloads to dlist. The client is responsible for clearing
136
126
// it before the call.
137
void download_list(DList& dlist);
127
void download_list(DList& dlist) LIBTORRENT_EXPORT;
139
129
// Make sure you check the returned Download's is_valid().
140
Download download_find(const std::string& infohash);
130
Download download_find(const std::string& infohash) LIBTORRENT_EXPORT;
142
uint32_t download_priority(Download d);
143
void download_set_priority(Download d, uint32_t pri);
132
uint32_t download_priority(Download d) LIBTORRENT_EXPORT;
133
void download_set_priority(Download d, uint32_t pri) LIBTORRENT_EXPORT;