source: trunk/libtransmission/transmission.h @ 5014

Last change on this file since 5014 was 5014, checked in by charles, 14 years ago

add tr_ctor{Set,Get}DeleteSource?()

  • Property svn:keywords set to Date Rev Author Id
File size: 26.8 KB
Line 
1/******************************************************************************
2 * $Id: transmission.h 5014 2008-02-13 02:24:12Z charles $
3 *
4 * Copyright (c) 2005-2008 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#ifndef TR_TRANSMISSION_H
26#define TR_TRANSMISSION_H 1
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include "version.h"
33
34#include <inttypes.h> /* uintN_t */
35#ifndef PRId64
36# define PRId64 "lld"
37#endif
38#ifndef PRIu64
39# define PRIu64 "llu"
40#endif
41#include <time.h> /* time_t */
42
43#define SHA_DIGEST_LENGTH 20
44#ifdef __BEOS__
45# include <StorageDefs.h>
46# define MAX_PATH_LENGTH  B_FILE_NAME_LENGTH
47#else
48# define MAX_PATH_LENGTH  1024
49#endif
50
51#define TR_DEFAULT_PORT   51413
52
53enum
54{
55    TR_PEER_FROM_INCOMING  = 0,  /* connections made to the listening port */
56    TR_PEER_FROM_TRACKER   = 1,  /* peers received from a tracker */
57    TR_PEER_FROM_CACHE     = 2,  /* peers read from the peer cache */
58    TR_PEER_FROM_PEX       = 3,  /* peers discovered via PEX */
59    TR_PEER_FROM__MAX
60};
61
62/***********************************************************************
63 * tr_init
64 ***********************************************************************
65 * Initializes and returns an opaque libtransmission handle
66 * to be passed to functions below. The tag argument is a short string
67 * unique to the program invoking tr_init(), it is currently used as
68 * part of saved torrent files' names to prevent one frontend from
69 * deleting a torrent used by another. The following tags are used:
70 *   beos cli daemon gtk macosx wx
71 **********************************************************************/
72
73typedef struct tr_handle tr_handle;
74
75tr_handle * tr_initFull( const char * tag,
76                         int          isPexEnabled,
77                         int          isNatEnabled,
78                         int          publicPort,
79                         int          encryptionMode,
80                         int          isUploadLimitEnabled,
81                         int          uploadLimit,
82                         int          isDownloadLimitEnabled,
83                         int          downloadLimit,
84                         int          globalPeerLimit,
85                         int          messageLevel,
86                         int          isMessageQueueingEnabled );
87
88/**
89 * Like tr_initFull() but with default values supplied.
90 */ 
91tr_handle * tr_init( const char * tag );
92
93/**
94 * Shut down a libtransmission instance created by tr_init*()
95 */
96void tr_close( tr_handle * );
97
98
99/**
100***
101**/
102
103typedef struct tr_session_stats
104{
105    uint64_t uploadedBytes;   /* total up */
106    uint64_t downloadedBytes; /* total down */
107    double ratio;             /* TR_RATIO_INF, TR_RATIO_NA, or total up/down */
108    uint64_t filesAdded;      /* number of files added */
109    uint64_t sessionCount;    /* program started N times */
110    uint64_t secondsActive;   /* how long Transmisson's been running */
111}
112tr_session_stats;
113
114/* stats from the current session. */
115void tr_getSessionStats( const tr_handle   * handle,
116                         tr_session_stats  * setme );
117
118/* stats from the current and past sessions. */
119void tr_getCumulativeSessionStats( const tr_handle   * handle,
120                                   tr_session_stats  * setme );
121
122
123/**
124***
125**/
126
127typedef enum
128{
129    TR_PLAINTEXT_PREFERRED,
130    TR_ENCRYPTION_PREFERRED,
131    TR_ENCRYPTION_REQUIRED
132}
133tr_encryption_mode;
134
135tr_encryption_mode tr_getEncryptionMode( tr_handle * handle );
136
137void tr_setEncryptionMode( tr_handle * handle, tr_encryption_mode mode );
138
139/***********************************************************************
140 * tr_getPrefsDirectory
141 ***********************************************************************
142 * Returns the full path to a directory which can be used to store
143 * preferences. The string belongs to libtransmission, do not free it.
144 **********************************************************************/
145const char * tr_getPrefsDirectory( void );
146
147
148
149
150/***********************************************************************
151** Message Logging
152*/
153
154#define TR_MSG_ERR 1
155#define TR_MSG_INF 2
156#define TR_MSG_DBG 3
157void tr_setMessageLevel( int );
158int tr_getMessageLevel( void );
159
160void tr_setMessageQueuing( int enable );
161
162typedef struct tr_msg_list tr_msg_list;
163tr_msg_list * tr_getQueuedMessages( void );
164void tr_freeMessageList( tr_msg_list * freeme );
165
166/***********************************************************************
167** Incoming Peer Connections Port
168*/
169
170void tr_setBindPort( tr_handle *, int );
171
172void tr_natTraversalEnable( tr_handle *, int enable );
173
174int tr_getPublicPort( const tr_handle * );
175
176typedef enum
177{
178    TR_NAT_TRAVERSAL_MAPPING,
179    TR_NAT_TRAVERSAL_MAPPED,
180    TR_NAT_TRAVERSAL_UNMAPPING,
181    TR_NAT_TRAVERSAL_UNMAPPED,
182    TR_NAT_TRAVERSAL_ERROR,
183}
184tr_nat_traversal_status;
185
186typedef struct tr_handle_status
187{
188    tr_nat_traversal_status natTraversalStatus;
189    int publicPort;
190}
191tr_handle_status;
192
193const tr_handle_status * tr_handleStatus( tr_handle * );
194
195
196/***********************************************************************
197***
198***  TORRENTS
199**/
200
201typedef struct tr_torrent tr_torrent;
202
203int tr_torrentCount( const tr_handle * h );
204
205/***********************************************************************
206*** Speed Limits
207**/
208
209enum { TR_UP, TR_DOWN };
210
211typedef enum
212{
213    TR_SPEEDLIMIT_GLOBAL,    /* only follow the overall speed limit */
214    TR_SPEEDLIMIT_SINGLE,    /* only follow the per-torrent limit */
215    TR_SPEEDLIMIT_UNLIMITED  /* no limits at all */
216}
217tr_speedlimit;
218
219void tr_torrentSetSpeedMode( tr_torrent   * tor,
220                             int            up_or_down,
221                             tr_speedlimit  mode );
222
223tr_speedlimit tr_torrentGetSpeedMode( const tr_torrent  * tor,
224                                      int                 up_or_down);
225
226void tr_torrentSetSpeedLimit( tr_torrent   * tor,
227                              int            up_or_down,
228                              int            single_KiB_sec );
229
230int tr_torrentGetSpeedLimit( const tr_torrent  * tor,
231                             int                 up_or_down );
232
233void tr_setUseGlobalSpeedLimit( tr_handle * handle,
234                                int           up_or_down,
235                                int           use_flag );
236
237void tr_setGlobalSpeedLimit( tr_handle * handle,
238                             int           up_or_down,
239                             int           global_KiB_sec );
240
241void tr_getGlobalSpeedLimit( tr_handle * handle,
242                             int           up_or_down,
243                             int         * setme_is_enabled,
244                             int         * setme_KiBsec );
245
246
247/***********************************************************************
248***  Peer Limits
249**/
250
251void tr_torrentSetMaxConnectedPeers( tr_torrent  * tor,
252                                     uint16_t      maxConnectedPeers);
253
254uint16_t tr_torrentGetMaxConnectedPeers( const tr_torrent  * tor );
255
256void tr_setGlobalPeerLimit( tr_handle * handle,
257                            uint16_t    maxGlobalPeers );
258
259uint16_t tr_getGlobalPeerLimit( const tr_handle * handle );
260
261
262
263
264/***********************************************************************
265 * Torrent Priorities
266 **********************************************************************/
267
268enum
269{
270    TR_PRI_LOW    = -1,
271    TR_PRI_NORMAL =  0, /* since NORMAL is 0, memset initializes nicely */
272    TR_PRI_HIGH   =  1
273};
274
275typedef int8_t tr_priority_t;
276
277/* set a batch of files to a particular priority.
278 * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
279void tr_torrentSetFilePriorities( tr_torrent        * tor,
280                                  int               * files,
281                                  int                 fileCount,
282                                  tr_priority_t       priority );
283
284/* returns a malloc()ed array of tor->info.fileCount items,
285 * each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
286   free the array when done. */
287tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
288
289/* single-file form of tr_torrentGetFilePriorities.
290 * returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
291tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, int file );
292
293/* returns true if the file's `download' flag is set */
294int tr_torrentGetFileDL( const tr_torrent *, int file );
295
296/* set a batch of files to be downloaded or not. */
297void tr_torrentSetFileDLs ( tr_torrent   * tor,
298                            int          * files,
299                            int            fileCount,
300                            int            do_download );
301
302/***********************************************************************
303 * tr_torrentRates
304 ***********************************************************************
305 * Gets the total download and upload rates
306 **********************************************************************/
307void tr_torrentRates( tr_handle *, float *, float * );
308
309
310
311/**
312 *  Torrent Instantiation
313 *
314 *  Instantiating a tr_torrent had gotten more complicated as features were
315 *  added.  At one point there were four functions to check metainfo and five
316 *  to create tr_torrent.
317 *
318 *  To remedy this, a Torrent Constructor (struct tr_ctor) has been introduced:
319 *  + Simplifies the API down to two (non-deprecated) functions.
320 *  + You can set the fields you want; the system sets defaults for the rest.
321 *  + You can specify whether or not your fields should supercede fastresume's.
322 *  + We can add new features to tr_ctor without breaking tr_torrentNew()'s API.
323 *
324 *  All the tr_ctor{Get,Set}*() functions with a return value return
325 *  an error number, or zero if no error occurred.
326 *
327 *  You must call one of the SetMetainfo() functions before creating
328 *  a torrent with a tr_ctor.  The other functions are optional.
329 *
330 *  You can reuse a single tr_ctor to create a batch of torrents --
331 *  just call one of the SetMetainfo() functions between each
332 *  tr_torrentNew() call.
333 *
334 *  Every call to tr_ctorSetMetainfo*() frees the previous metainfo.
335 */
336
337typedef enum
338{
339    TR_FALLBACK, /* indicates the ctor value should be used only
340                    in case of missing fastresume settings */
341
342    TR_FORCE, /* indicates the ctor value should be used
343                 regardless of what's in the fastresume settings */
344}
345tr_ctorMode;
346
347typedef struct tr_ctor tr_ctor;
348struct benc_val_s;
349
350tr_ctor* tr_ctorNew                    ( const tr_handle  * handle);
351
352void     tr_ctorFree                   ( tr_ctor        * ctor );
353
354void     tr_ctorSetSave                ( tr_ctor        * ctor,
355                                         int     saveMetadataInOurTorrentsDir );
356
357void     tr_ctorSetDeleteSource       ( tr_ctor        * ctor,
358                                         uint8_t          doDelete );
359
360int      tr_ctorSetMetainfo            ( tr_ctor        * ctor,
361                                         const uint8_t  * metainfo,
362                                         size_t           len );
363
364int      tr_ctorSetMetainfoFromFile    ( tr_ctor        * ctor,
365                                         const char     * filename );
366
367int      tr_ctorSetMetainfoFromHash    ( tr_ctor        * ctor,
368                                         const char     * hashString );
369
370void     tr_ctorSetMaxConnectedPeers   ( tr_ctor        * ctor,
371                                         tr_ctorMode      mode,
372                                         uint16_t         maxConnectedPeers );
373
374void     tr_ctorSetDestination         ( tr_ctor        * ctor,
375                                         tr_ctorMode      mode,
376                                         const char     * directory );
377
378void     tr_ctorSetPaused              ( tr_ctor        * ctor,
379                                         tr_ctorMode      mode,
380                                         uint8_t          isPaused );
381
382int      tr_ctorGetMaxConnectedPeers   ( const tr_ctor  * ctor,
383                                         tr_ctorMode      mode,
384                                         uint16_t       * setmeCount );
385
386int      tr_ctorGetPaused              ( const tr_ctor  * ctor,
387                                         tr_ctorMode      mode,
388                                         uint8_t        * setmeIsPaused );
389
390int      tr_ctorGetDestination         ( const tr_ctor  * ctor,
391                                         tr_ctorMode      mode,
392                                         const char    ** setmeDestination );
393
394int      tr_ctorGetMetainfo            ( const tr_ctor  * ctor,
395                                         const struct benc_val_s ** setme );
396
397int      tr_ctorGetSave                ( const tr_ctor  * ctor );
398 
399int      tr_ctorGetDeleteSource        ( const tr_ctor  * ctor,
400                                         uint8_t        * setmeDoDelete );
401
402/* returns NULL if tr_ctorSetMetainfoFromFile() wasn't used */
403const char* tr_ctorGetSourceFile       ( const tr_ctor  * ctor );
404
405
406typedef struct tr_info tr_info;
407
408/**
409 * Parses the specified metainfo.
410 * Returns TR_OK if it parsed and can be added to Transmission.
411 * Returns TR_INVALID if it couldn't be parsed.
412 * Returns TR_EDUPLICATE if it parsed but can't be added.
413 *     "destination" must be set to test for TR_EDUPLICATE.
414 *
415 * If "setme_info" is non-NULL, the parsed metainfo is stored there
416 * and will need to be freed by the caller via tr_metainfoFree().
417 */
418int tr_torrentParse( const tr_handle  * handle,
419                     const tr_ctor    * ctor,
420                     tr_info          * setme_info_or_NULL );
421
422/**
423 * Instantiate a single torrent.
424 */
425#define TR_EINVALID     1
426#define TR_EUNSUPPORTED 2
427#define TR_EDUPLICATE   3
428#define TR_EOTHER       666
429tr_torrent * tr_torrentNew( tr_handle      * handle,
430                            const tr_ctor  * ctor,
431                            int            * setmeError );
432
433
434/**
435 *  Load all the torrents in tr_getTorrentsDirectory().
436 *  This can be used at startup to kickstart all the torrents
437 *  from the previous session.
438 */
439tr_torrent ** tr_loadTorrents ( tr_handle  * h,
440                                tr_ctor    * ctor,
441                                int        * setmeCount );
442
443
444
445/**
446 * Set whether or not torrents are allowed to do peer exchanges.
447 * PEX is always disabled in private torrents regardless of this.
448 * In public torrents, PEX is enabled by default.
449 */
450void tr_setPexEnabled( tr_handle *, int isEnabled );
451
452int tr_isPexEnabled( const tr_handle * );
453
454const tr_info * tr_torrentInfo( const tr_torrent * );
455
456void tr_torrentSetFolder( tr_torrent *, const char * );
457
458const char * tr_torrentGetFolder( const tr_torrent * );
459
460void tr_torrentStart( tr_torrent * );
461
462void tr_torrentStop( tr_torrent * );
463
464
465/**
466***
467**/
468
469typedef enum
470{
471    TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
472    TR_CP_DONE,         /* has all the pieces but the DND ones */
473    TR_CP_COMPLETE      /* has every piece */
474}
475cp_status_t;
476
477typedef void (tr_torrent_status_func)(tr_torrent   * torrent,
478                                      cp_status_t    status,
479                                      void         * user_data );
480
481/**
482 * Register to be notified whenever a torrent's state changes.
483 *
484 * func is invoked FROM LIBTRANSMISSION'S THREAD!
485 * This means func must be fast (to avoid blocking peers),
486 * shouldn't call libtransmission functions (to avoid deadlock),
487 * and shouldn't modify client-level memory without using a mutex!
488 */
489void tr_torrentSetStatusCallback( tr_torrent             * torrent,
490                                  tr_torrent_status_func   func,
491                                  void                   * user_data );
492
493void tr_torrentClearStatusCallback( tr_torrent * torrent );
494
495
496
497/**
498***
499**/
500
501typedef void (tr_torrent_active_func)(tr_torrent   * torrent,
502                                      int            isRunning,
503                                      void         * user_data );
504
505/**
506 * Register to be notified whenever a torrent starts or stops.
507 *
508 * func is invoked FROM LIBTRANSMISSION'S THREAD!
509 * This means func must be fast (to avoid blocking peers),
510 * shouldn't call libtransmission functions (to avoid deadlock),
511 * and shouldn't modify client-level memory without using a mutex!
512 */
513void tr_torrentSetActiveCallback( tr_torrent             * torrent,
514                                  tr_torrent_active_func   func,
515                                  void                   * user_data );
516
517void tr_torrentClearActiveCallback( tr_torrent * torrent );
518
519
520/**
521 * MANUAL ANNOUNCE
522 *
523 * Trackers usually set an announce interval of 15 or 30 minutes.
524 * Users can send one-time announce requests that override this
525 * interval by calling tr_manualUpdate().
526 *
527 * The wait interval for tr_manualUpdate() is much smaller.
528 * You can test whether or not a manual update is possible
529 * (for example, to desensitize the button) by calling
530 * tr_torrentCanManualUpdate().
531 */
532
533void tr_manualUpdate( tr_torrent * );
534
535int tr_torrentCanManualUpdate( const tr_torrent * );
536
537/***********************************************************************
538 * tr_torrentStat
539 ***********************************************************************
540 * Returns a pointer to an tr_stat structure with updated information
541 * on the torrent. The structure belongs to libtransmission (do not
542 * free it) and is guaranteed to be unchanged until the next call to
543 * tr_torrentStat.
544 * The interface should call this function every second or so in order
545 * to update itself.
546 **********************************************************************/
547typedef struct tr_stat tr_stat;
548const tr_stat * tr_torrentStat( tr_torrent * );
549const tr_stat * tr_torrentStatCached( tr_torrent * );
550
551/***********************************************************************
552 * tr_torrentPeers
553 ***********************************************************************/
554typedef struct tr_peer_stat tr_peer_stat;
555tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
556void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
557
558typedef struct tr_file_stat tr_file_stat;
559tr_file_stat * tr_torrentFiles( const tr_torrent *, int * fileCount );
560void tr_torrentFilesFree( tr_file_stat *, int fileCount );
561
562
563/***********************************************************************
564 * tr_torrentAvailability
565 ***********************************************************************
566 * Use this to draw an advanced progress bar which is 'size' pixels
567 * wide. Fills 'tab' which you must have allocated: each byte is set
568 * to either -1 if we have the piece, otherwise it is set to the number
569 * of connected peers who have the piece.
570 **********************************************************************/
571void tr_torrentAvailability( const tr_torrent *, int8_t * tab, int size );
572
573void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
574
575/***********************************************************************
576 * tr_torrentRemoveSaved
577 ***********************************************************************
578 * delete's Transmission's copy of the torrent's metadata from
579 * tr_getTorrentsDirectory().
580 **********************************************************************/
581void tr_torrentRemoveSaved( tr_torrent * );
582
583void tr_torrentRecheck( tr_torrent * );
584
585/**
586 * Frees memory allocated by tr_torrentNew().
587 * Running torrents are stopped first.
588 */
589void tr_torrentClose( tr_torrent * );
590
591/***********************************************************************
592 * tr_info
593 **********************************************************************/
594
595typedef struct tr_file
596{
597    uint64_t length;                /* Length of the file, in bytes */
598    char     name[MAX_PATH_LENGTH]; /* Path to the file */
599    int8_t   priority;              /* TR_PRI_HIGH, _NORMAL, or _LOW */
600    int8_t   dnd;                   /* nonzero if the file shouldn't be downloaded */
601    int      firstPiece;            /* We need pieces [firstPiece... */
602    int      lastPiece;             /* ...lastPiece] to dl this file */
603    uint64_t offset;                /* file begins at the torrent's nth byte */
604}
605tr_file;
606
607typedef struct tr_piece
608{
609    uint8_t  hash[SHA_DIGEST_LENGTH];  /* pieces hash */
610    int8_t   priority;                 /* TR_PRI_HIGH, _NORMAL, or _LOW */
611    int8_t   dnd;                      /* nonzero if the piece shouldn't be downloaded */
612}
613tr_piece;
614   
615typedef struct tr_tracker_info
616{
617    char * address;
618    int    port;
619    char * announce;
620    char * scrape;
621}
622tr_tracker_info;
623
624struct tr_info
625{
626    /* Path to torrent */
627    char                 torrent[MAX_PATH_LENGTH];
628
629    /* General info */
630    uint8_t              hash[SHA_DIGEST_LENGTH];
631    char                 hashString[2*SHA_DIGEST_LENGTH+1];
632    char                 name[MAX_PATH_LENGTH];
633
634    /* Flags */
635    unsigned int isPrivate : 1;
636    unsigned int isMultifile : 1;
637
638    /* Tracker info */
639    struct
640    {
641        tr_tracker_info  * list;
642        int                 count;
643    }                  * trackerList;
644    int                  trackerTiers;
645    char               * primaryAddress;
646
647    /* Torrent info */
648    char                 comment[MAX_PATH_LENGTH];
649    char                 creator[MAX_PATH_LENGTH];
650    int                  dateCreated;
651
652    /* Pieces info */
653    int                  pieceSize;
654    int                  pieceCount;
655    uint64_t             totalSize;
656    tr_piece           * pieces;
657
658    /* Files info */
659    int                  fileCount;
660    tr_file            * files;
661};
662
663typedef enum
664{
665    TR_STATUS_CHECK_WAIT   = (1<<0), /* Waiting in queue to check files */
666    TR_STATUS_CHECK        = (1<<1), /* Checking files */
667    TR_STATUS_DOWNLOAD     = (1<<2), /* Downloading */
668    TR_STATUS_DONE         = (1<<3), /* not at 100% so can't tell the tracker
669                                        we're a seeder, but due to DND files
670                                        there's nothing we want right now */
671    TR_STATUS_SEED         = (1<<4), /* Seeding */
672    TR_STATUS_STOPPED      = (1<<5)  /* Torrent is stopped */
673}
674tr_torrent_status;
675
676#define TR_STATUS_IS_ACTIVE(s) ((s) != TR_STATUS_STOPPED)
677
678/**
679 * Transmission error codes
680 * errors are always negative, and 0 refers to no error.
681 */
682typedef enum tr_errno
683{
684    TR_OK = 0,
685
686    /* general errors */
687    TR_ERROR = -100,
688    TR_ERROR_ASSERT,
689
690    /* io errors */
691    TR_ERROR_IO_PARENT = -200,
692    TR_ERROR_IO_PERMISSIONS,
693    TR_ERROR_IO_SPACE,
694    TR_ERROR_IO_FILE_TOO_BIG,
695    TR_ERROR_IO_OPEN_FILES,
696    TR_ERROR_IO_DUP_DOWNLOAD,
697    TR_ERROR_IO_OTHER,
698
699    /* tracker errors */
700    TR_ERROR_TC_ERROR = -300,
701    TR_ERROR_TC_WARNING
702}
703tr_errno;
704
705#define TR_ERROR_IS_IO(e) (TR_ERROR_IO_PARENT<=(e) && (e)<=TR_ERROR_IO_OTHER)
706#define TR_ERROR_IS_TC(e) (TR_ERROR_TC_ERROR<=(e) && (e)<=TR_ERROR_TC_WARNING)
707
708struct tr_stat
709{
710    tr_torrent_status   status;
711
712    tr_errno            error;
713    char                errorString[128];
714
715    const tr_tracker_info * tracker;
716
717    float               recheckProgress;
718    float               percentComplete;
719    float               percentDone;
720    float               rateDownload;
721    float               rateUpload;
722    int                 eta;
723    int                 peersKnown;
724    int                 peersConnected;
725    int                 peersFrom[TR_PEER_FROM__MAX];
726    int                 peersSendingToUs;
727    int                 peersGettingFromUs;
728    int                 seeders;
729    int                 leechers;
730    int                 completedFromTracker;
731
732    /* if the torrent is running, this is the time at which
733     * the client can manually ask the torrent's tracker
734     * for more peers.  otherwise, the value is zero. */
735    time_t              manualAnnounceTime;
736
737    /* Byte count of how much data is left to be downloaded until
738     * we're done -- that is, until we've got all the pieces we wanted. */
739    uint64_t            leftUntilDone;
740
741    /* Byte count of all the corrupt data you've ever downloaded for
742     * this torrent.  If you're on a poisoned torrent, this number can
743     * grow very large. */
744    uint64_t            corruptEver;
745
746    /* Byte count of all data you've ever uploaded for this torrent. */
747    uint64_t            uploadedEver;
748
749    /* Byte count of all the non-corrupt data you've ever downloaded
750     * for this torrent.  If you deleted the files and downloaded a second time,
751     * this will be 2*totalSize.. */
752    uint64_t            downloadedEver;
753
754    /* Byte count of all the checksum-verified data we have for this torrent. */
755    uint64_t            haveValid;
756
757    /* Byte count of all the partial piece data we have for this torrent.
758     * As pieces become complete, this value may decrease as portions of it are
759     * moved to `corrupt' or `haveValid'. */
760    uint64_t            haveUnchecked;
761
762    /* Byte count of all the non-DND piece data that either we already have,
763     * or that a peer we're connected to has. [0...desiredSize] */
764    uint64_t            desiredAvailable;
765
766    /* Byte count of all the piece data we want, whether we currently
767     * have it nor not. [0...tr_info.totalSize] */
768    uint64_t            desiredSize;
769
770    float               swarmspeed;
771
772#define TR_RATIO_NA  -1
773#define TR_RATIO_INF -2
774    /* TR_RATIO_INF, TR_RATIO_NA, or a regular ratio */
775    float               ratio;
776   
777    uint64_t            startDate;
778    uint64_t            activityDate;
779};
780
781struct tr_file_stat
782{
783    uint64_t bytesCompleted;
784    float progress;
785};
786
787struct tr_peer_stat
788{
789    char addr[16];
790    char client[80];
791   
792    unsigned int isEncrypted : 1;
793    unsigned int isDownloadingFrom : 1;
794    unsigned int isUploadingTo : 1;
795
796    unsigned int peerIsChoked : 1;
797    unsigned int peerIsInterested : 1;
798    unsigned int clientIsChoked : 1;
799    unsigned int clientIsInterested : 1;
800    unsigned int isIncoming : 1;
801
802    char flagStr[32];
803
804    uint8_t  from;
805    uint16_t port;
806   
807    float progress;
808    float downloadFromRate;
809    float uploadToRate;
810};
811
812struct tr_msg_list
813{
814    uint8_t              level;
815    time_t               when;
816    char               * message;
817    const char         * file;
818    int                  line;
819    struct tr_msg_list * next;
820};
821
822
823#ifdef __TRANSMISSION__
824#  include "internal.h"
825#endif
826
827#ifdef __cplusplus
828}
829#endif
830
831#endif
Note: See TracBrowser for help on using the repository browser.