~ubuntu-branches/ubuntu/maverick/transmission/maverick-updates

« back to all changes in this revision

Viewing changes to libtransmission/torrent.h

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda
  • Date: 2009-12-08 10:49:11 UTC
  • mfrom: (1.1.29 upstream) (2.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20091208104911-06gio45n2nla3vpg
Tags: 1.80~b1-0ubuntu1
* New upstream release (LP: #460620), rebased on debian unstable
  remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
      Can be removed in lucid+1
    + Added quilt, liblaunchpad-integration-dev and lsb-release to Build-Depends
  - debian/rules:
    + create a po template during package build.
  - debian/patches/01_lpi.patch:
    + integrate transmission with launchpad
  - debian/patches/20_add_x-ubuntu-gettext-domain.diff:
    + add x-ubuntu-gettext-domain to .desktop file.
  - debian/transmission-daemon.default:
    - remove --auth from OPTIONS
* Fixes bugs:
  - tray menu shows wrong status for "main window" when started minimized
    (LP: #451415)
* Refreshed patches:
  - dont_build_libevent.patch
  - 99_autoreconf.patch
* Removed patches:
  - 21_onPortTested.diff, 23_tr_torrentNext.diff and
    24_tr_torrentDeleteLocalData_do_move.diff
* debian/patches/21_fix_inhibition.patch:
  - The right value for suspend inhibition is 4
* debian/control:
  - Build-Depend on libgconf2-dev to enable magnet link registration and on
    libcanberra-gtk-dev for notification sound.
* debian/watch:
  - make it detect beta versions, to be removed after 1.80 is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
 
2
 * This file Copyright (C) 2009 Mnemosyne LLC
3
3
 *
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)
7
7
 * This exemption does not extend to derived works not owned by
8
8
 * the Transmission project.
9
9
 *
10
 
 * $Id: torrent.h 8915 2009-08-13 17:50:41Z charles $
 
10
 * $Id: torrent.h 9671 2009-12-05 02:19:24Z charles $
11
11
 */
12
12
 
13
13
#ifndef __TRANSMISSION__
24
24
 
25
25
struct tr_bandwidth;
26
26
struct tr_ratecontrol;
27
 
struct tr_torrent_peers;
 
27
struct tr_torrent_tiers;
 
28
struct tr_magnet_info;
28
29
 
29
30
/**
30
31
***  Package-visible ctor API
35
36
 
36
37
int         tr_ctorGetSave( const tr_ctor * ctor );
37
38
 
 
39
int         tr_ctorGetMagnet( const tr_ctor * ctor, const struct tr_magnet_info ** setme );
 
40
 
38
41
void        tr_ctorInitTorrentPriorities( const tr_ctor * ctor, tr_torrent * tor );
39
42
 
40
43
void        tr_ctorInitTorrentWanted( const tr_ctor * ctor, tr_torrent * tor );
51
54
 
52
55
void        tr_torrentRecheckCompleteness( tr_torrent * );
53
56
 
54
 
void        tr_torrentResetTransferStats( tr_torrent * );
55
 
 
56
57
void        tr_torrentSetHasPiece( tr_torrent *     tor,
57
58
                                   tr_piece_index_t pieceIndex,
58
59
                                   tr_bool          has );
59
60
 
60
61
void        tr_torrentChangeMyPort( tr_torrent * session );
61
62
 
62
 
tr_torrent* tr_torrentFindFromHash( tr_session *    session,
63
 
                                    const uint8_t * hash );
64
 
 
65
63
tr_torrent* tr_torrentFindFromHashString( tr_session * session,
66
64
                                          const char * hashString );
67
65
 
136
134
void             tr_torrentSetVerifyState( tr_torrent      * tor,
137
135
                                           tr_verify_state   state );
138
136
 
 
137
struct tr_incomplete_metadata;
 
138
 
139
139
struct tr_torrent
140
140
{
141
141
    tr_session *             session;
142
142
    tr_info                  info;
143
143
 
144
 
    struct tr_ratecontrol    swarmSpeed;
145
 
 
146
144
    int                      magicNumber;
147
145
 
148
146
    tr_stat_errtype          error;
150
148
 
151
149
    uint8_t                  obfuscatedHash[SHA_DIGEST_LENGTH];
152
150
 
 
151
    /* Used when the torrent has been created with a magnet link
 
152
     * and we're in the process of downloading the metainfo from
 
153
     * other peers */
 
154
    struct tr_incomplete_metadata  * incompleteMetadata;
 
155
 
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
159
162
     */
160
163
    uint8_t * peer_id;
161
164
 
162
 
    /* Where to download */
 
165
    /* Where the files will be when it's complete */
163
166
    char * downloadDir;
164
167
 
 
168
    /* Where the files are when the torrent is incomplete */
 
169
    char * incompleteDir;
 
170
 
 
171
    /* Length, in bytes, of the "info" dict in the .torrent file */
 
172
    int infoDictLength;
 
173
 
 
174
    /* Offset, in bytes, of the beginning of the "info" dict in the .torrent file */
 
175
    int infoDictOffset;
 
176
 
 
177
    /* Where the files are now.
 
178
     * This pointer will be equal to downloadDir or incompleteDir */
 
179
    const char * currentDir;
 
180
 
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;
179
195
 
180
 
    struct tr_tracker *        tracker;
181
 
    struct tr_publisher_tag *  trackerSubscription;
 
196
    struct tr_torrent_tiers  * tiers;
 
197
    struct tr_publisher_tag  * tiersSubscription;
182
198
 
183
199
    time_t                     dhtAnnounceAt;
 
200
    time_t                     dhtAnnounce6At;
184
201
    tr_bool                    dhtAnnounceInProgress;
 
202
    tr_bool                    dhtAnnounce6InProgress;
185
203
 
186
204
    uint64_t                   downloadedCur;
187
205
    uint64_t                   downloadedPrev;
190
208
    uint64_t                   corruptCur;
191
209
    uint64_t                   corruptPrev;
192
210
 
193
 
    uint64_t                   etaSpeedCalculatedAt;
194
 
    double                     etaSpeed;
 
211
    uint64_t                   etaDLSpeedCalculatedAt;
 
212
    double                     etaDLSpeed;
 
213
    uint64_t                   etaULSpeedCalculatedAt;
 
214
    double                     etaULSpeed;
195
215
 
196
216
    time_t                     addedDate;
197
217
    time_t                     activityDate;
199
219
    time_t                     startDate;
200
220
    time_t                     anyDate;
201
221
 
202
 
    tr_torrent_completeness_func *   completeness_func;
203
 
    void *                     completeness_func_user_data;
204
 
 
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;
 
224
 
 
225
    tr_torrent_completeness_func  * completeness_func;
 
226
    void                          *  completeness_func_user_data;
 
227
 
 
228
    tr_torrent_ratio_limit_hit_func  * ratio_limit_hit_func;
 
229
    void                             * ratio_limit_hit_func_user_data;
207
230
 
208
231
    tr_bool                    isRunning;
209
232
    tr_bool                    isDeleting;
326
349
    TORRENT_MAGIC_NUMBER = 95549
327
350
};
328
351
 
329
 
static inline tr_bool tr_isTorrent( const tr_torrent * tor )
 
352
static TR_INLINE tr_bool tr_isTorrent( const tr_torrent * tor )
330
353
{
331
354
    return ( tor != NULL )
332
355
        && ( tor->magicNumber == TORRENT_MAGIC_NUMBER )
335
358
 
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 )
 
361
static TR_INLINE
 
362
void tr_torrentSetDirty( tr_torrent * tor )
339
363
{
340
364
    assert( tr_isTorrent( tor ) );
341
365
 
342
366
    tor->isDirty = TRUE;
343
367
}
344
368
 
 
369
static TR_INLINE
 
370
const char * tr_torrentName( const tr_torrent * tor )
 
371
{
 
372
    assert( tr_isTorrent( tor ) );
 
373
 
 
374
    return tor->info.name;
 
375
}
 
376
 
 
377
/**
 
378
 * Tell the tr_torrent that one of its files has become complete
 
379
 */
 
380
void tr_torrentFileCompleted( tr_torrent * tor, tr_file_index_t fileNo );
 
381
 
 
382
 
 
383
/**
 
384
 * @brief Like tr_torrentFindFile(), but splits the filename into base and subpath;
 
385
 *
 
386
 * If the file is found, "tr_buildPath( base, subpath, NULL )"
 
387
 * will generate the complete filename.
 
388
 *
 
389
 * @return true if the file is found, false otherwise.
 
390
 *
 
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.
 
395
 */
 
396
tr_bool tr_torrentFindFile2( const tr_torrent *, tr_file_index_t fileNo,
 
397
                             const char ** base, char ** subpath );
 
398
 
 
399
 
 
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"
 
403
 * a la Firefox. */
 
404
char* tr_torrentBuildPartial( const tr_torrent *, tr_file_index_t fileNo );
 
405
 
 
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 );
 
409
 
345
410
#endif