2
* This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
2
* This file Copyright (C) 2009 Mnemosyne LLC
4
4
* This file is licensed by the GPL version 2. Works owned by the
5
5
* Transmission project are granted a special exemption to clause 2(b)
36
37
int tr_ctorGetSave( const tr_ctor * ctor );
39
int tr_ctorGetMagnet( const tr_ctor * ctor, const struct tr_magnet_info ** setme );
38
41
void tr_ctorInitTorrentPriorities( const tr_ctor * ctor, tr_torrent * tor );
40
43
void tr_ctorInitTorrentWanted( const tr_ctor * ctor, tr_torrent * tor );
52
55
void tr_torrentRecheckCompleteness( tr_torrent * );
54
void tr_torrentResetTransferStats( tr_torrent * );
56
57
void tr_torrentSetHasPiece( tr_torrent * tor,
57
58
tr_piece_index_t pieceIndex,
60
61
void tr_torrentChangeMyPort( tr_torrent * session );
62
tr_torrent* tr_torrentFindFromHash( tr_session * session,
63
const uint8_t * hash );
65
63
tr_torrent* tr_torrentFindFromHashString( tr_session * session,
66
64
const char * hashString );
151
149
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
151
/* Used when the torrent has been created with a magnet link
152
* and we're in the process of downloading the metainfo from
154
struct tr_incomplete_metadata * incompleteMetadata;
153
156
/* If the initiator of the connection receives a handshake in which the
154
157
* peer_id does not match the expected peerid, then the initiator is
155
158
* expected to drop the connection. Note that the initiator presumably
160
163
uint8_t * peer_id;
162
/* Where to download */
165
/* Where the files will be when it's complete */
163
166
char * downloadDir;
168
/* Where the files are when the torrent is incomplete */
169
char * incompleteDir;
171
/* Length, in bytes, of the "info" dict in the .torrent file */
174
/* Offset, in bytes, of the beginning of the "info" dict in the .torrent file */
177
/* Where the files are now.
178
* This pointer will be equal to downloadDir or incompleteDir */
179
const char * currentDir;
165
181
/* How many bytes we ask for per request */
166
182
uint32_t blockSize;
167
183
tr_block_index_t blockCount;
177
193
struct tr_bitfield checkedPieces;
178
194
tr_completeness completeness;
180
struct tr_tracker * tracker;
181
struct tr_publisher_tag * trackerSubscription;
196
struct tr_torrent_tiers * tiers;
197
struct tr_publisher_tag * tiersSubscription;
183
199
time_t dhtAnnounceAt;
200
time_t dhtAnnounce6At;
184
201
tr_bool dhtAnnounceInProgress;
202
tr_bool dhtAnnounce6InProgress;
186
204
uint64_t downloadedCur;
187
205
uint64_t downloadedPrev;
199
219
time_t startDate;
202
tr_torrent_completeness_func * completeness_func;
203
void * completeness_func_user_data;
205
tr_torrent_ratio_limit_hit_func * ratio_limit_hit_func;
206
void * ratio_limit_hit_func_user_data;
222
tr_torrent_metadata_func * metadata_func;
223
void * metadata_func_user_data;
225
tr_torrent_completeness_func * completeness_func;
226
void * completeness_func_user_data;
228
tr_torrent_ratio_limit_hit_func * ratio_limit_hit_func;
229
void * ratio_limit_hit_func_user_data;
208
231
tr_bool isRunning;
209
232
tr_bool isDeleting;
336
359
/* set a flag indicating that the torrent's .resume file
337
360
* needs to be saved when the torrent is closed */
338
static inline void tr_torrentSetDirty( tr_torrent * tor )
362
void tr_torrentSetDirty( tr_torrent * tor )
340
364
assert( tr_isTorrent( tor ) );
342
366
tor->isDirty = TRUE;
370
const char * tr_torrentName( const tr_torrent * tor )
372
assert( tr_isTorrent( tor ) );
374
return tor->info.name;
378
* Tell the tr_torrent that one of its files has become complete
380
void tr_torrentFileCompleted( tr_torrent * tor, tr_file_index_t fileNo );
384
* @brief Like tr_torrentFindFile(), but splits the filename into base and subpath;
386
* If the file is found, "tr_buildPath( base, subpath, NULL )"
387
* will generate the complete filename.
389
* @return true if the file is found, false otherwise.
391
* @param base if the torrent is found, this will be either
392
* tor->downloadDir or tor->incompleteDir
393
* @param subpath on success, this pointer is assigned a newly-allocated
394
* string holding the second half of the filename.
396
tr_bool tr_torrentFindFile2( const tr_torrent *, tr_file_index_t fileNo,
397
const char ** base, char ** subpath );
400
/* Returns a newly-allocated version of the tr_file.name string
401
* that's been modified to denote that it's not a complete file yet.
402
* In the current implementation this is done by appending ".part"
404
char* tr_torrentBuildPartial( const tr_torrent *, tr_file_index_t fileNo );
406
/* for when the info dict has been fundamentally changed wrt files,
407
* piece size, etc. such as in BEP 9 where peers exchange metadata */
408
void tr_torrentGotNewInfoDict( tr_torrent * tor );