source: branches/0.9x/libtransmission/transmission.h @ 3925

Last change on this file since 3925 was 3925, checked in by charles, 15 years ago

Change the default port from 9090 to 51413 to get in compliance with IANA's port number assignment scheme. (1024 through 49151 are reserved)

  • Property svn:keywords set to Date Rev Author Id
File size: 27.8 KB
Line 
1/******************************************************************************
2 * $Id: transmission.h 3925 2007-11-22 04:15:21Z charles $
3 *
4 * Copyright (c) 2005-2007 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>
35#ifndef PRId64
36# define PRId64 "lld"
37#endif
38#ifndef PRIu64
39# define PRIu64 "llu"
40#endif
41#include <time.h>
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#ifndef INET_ADDRSTRLEN
52#define INET_ADDRSTRLEN 16
53#endif
54
55#if defined(WIN32)
56#define TR_PATH_DELIMITER '\\'
57#define TR_PATH_DELIMITER_STR "\\"
58#else
59#define TR_PATH_DELIMITER '/'
60#define TR_PATH_DELIMITER_STR "/"
61#endif
62
63#define TR_DEFAULT_PORT 51413
64
65enum
66{
67    TR_PEER_FROM_INCOMING  = 0,  /* connections made to the listening port */
68    TR_PEER_FROM_TRACKER   = 1,  /* peers received from a tracker */
69    TR_PEER_FROM_CACHE     = 2,  /* peers read from the peer cache */
70    TR_PEER_FROM_PEX       = 3,  /* peers discovered via PEX */
71    TR_PEER_FROM__MAX
72};
73
74/***********************************************************************
75 * Error codes
76 **********************************************************************/
77/* General errors */
78#define TR_OK                       0x00000000
79#define TR_ERROR                    0x81000000
80#define TR_ERROR_ASSERT             0x82000000
81/* I/O errors */
82#define TR_ERROR_IO_MASK            0x000000FF
83#define TR_ERROR_IO_PERMISSIONS     0x80000002
84#define TR_ERROR_IO_SPACE           0x80000004
85#define TR_ERROR_IO_FILE_TOO_BIG    0x80000008
86#define TR_ERROR_IO_OPEN_FILES      0x80000010
87#define TR_ERROR_IO_DUP_DOWNLOAD    0x80000020
88#define TR_ERROR_IO_OTHER           0x80000040
89/* Misc */
90#define TR_ERROR_TC_MASK            0x00000F00
91#define TR_ERROR_TC_ERROR           0x80000100
92#define TR_ERROR_TC_WARNING         0x80000200
93
94#define TR_ERROR_ISSET( num, code ) ( (code) == ( (code) & (num) ) )
95
96/***********************************************************************
97 * tr_init
98 ***********************************************************************
99 * Initializes a libtransmission instance and returns an opaque handle
100 * to be passed to functions below. The tag argument is a short string
101 * unique to the program invoking tr_init(), it is currently used as
102 * part of saved torrent files' names to prevent one frontend from
103 * deleting a torrent used by another. The following tags are used:
104 *   beos cli daemon gtk macosx
105 **********************************************************************/
106
107typedef struct tr_handle tr_handle;
108
109tr_handle * tr_init( const char * tag );
110
111/* shut down a libtransmission instance created by tr_init(). */
112void tr_close( tr_handle * );
113
114
115/**
116***
117**/
118
119typedef struct tr_session_stats
120{
121    uint64_t downloadedGigs;  /* total down / GiB */
122    uint64_t downloadedBytes; /* total down % GiB */
123    uint64_t uploadedGigs;    /* total up / GiB */
124    uint64_t uploadedBytes;   /* total up % GiB */
125    double ratio;             /* total up / total down */
126    uint64_t filesAdded;      /* number of files added */
127    uint64_t sessionCount;    /* program started N times */
128    uint64_t secondsActive;   /* how long Transmisson's been running */
129}
130tr_session_stats;
131
132/* stats from the current and past sessions. */
133void tr_getCumulativeSessionStats( const tr_handle   * handle,
134                                   tr_session_stats  * setme );
135
136/* stats from the current session. */
137void tr_getSessionStats( const tr_handle   * handle,
138                         tr_session_stats  * setme );
139
140
141/**
142***
143**/
144
145typedef enum
146{
147    TR_PLAINTEXT_PREFERRED,
148    TR_ENCRYPTION_PREFERRED,
149    TR_ENCRYPTION_REQUIRED
150}
151tr_encryption_mode;
152
153tr_encryption_mode tr_getEncryptionMode( tr_handle * handle );
154
155void tr_setEncryptionMode( tr_handle * handle, tr_encryption_mode mode );
156
157/***********************************************************************
158 * tr_setMessageLevel
159 ***********************************************************************
160 * Set the level of messages to be output or queued
161 **********************************************************************/
162#define TR_MSG_ERR 1
163#define TR_MSG_INF 2
164#define TR_MSG_DBG 3
165void tr_setMessageLevel( int );
166int tr_getMessageLevel( void );
167
168/***********************************************************************
169 * tr_setMessageQueuing
170 ***********************************************************************
171 * Enable or disable message queuing
172 **********************************************************************/
173typedef struct tr_msg_list tr_msg_list;
174void tr_setMessageQueuing( int );
175
176/***********************************************************************
177 * tr_getQueuedMessages
178 ***********************************************************************
179 * Return a list of queued messages
180 **********************************************************************/
181tr_msg_list * tr_getQueuedMessages( void );
182void tr_freeMessageList( tr_msg_list * list );
183
184/***********************************************************************
185 * tr_getPrefsDirectory
186 ***********************************************************************
187 * Returns the full path to a directory which can be used to store
188 * preferences. The string belongs to libtransmission, do not free it.
189 **********************************************************************/
190const char * tr_getPrefsDirectory( void );
191
192/***********************************************************************
193 * tr_setBindPort
194 ***********************************************************************
195 * Sets the port to listen for incoming peer connections.
196 * This can be safely called even with active torrents.
197 **********************************************************************/
198void tr_setBindPort( tr_handle *, int );
199
200int tr_getPublicPort( const tr_handle * );
201
202/***********************************************************************
203 * tr_natTraversalEnable
204 * tr_natTraversalDisable
205 ***********************************************************************
206 * Enable or disable NAT traversal using NAT-PMP or UPnP IGD.
207 **********************************************************************/
208void tr_natTraversalEnable( tr_handle *, int enable );
209
210/***********************************************************************
211 * tr_handleStatus
212 ***********************************************************************
213 * Returns some status info for the given handle.
214 **********************************************************************/
215typedef struct tr_handle_status tr_handle_status;
216tr_handle_status * tr_handleStatus( tr_handle * );
217
218
219/***********************************************************************
220 * tr_torrentCount
221 ***********************************************************************
222 * Returns the count of open torrents
223 **********************************************************************/
224int tr_torrentCount( tr_handle * h );
225
226
227/***********************************************************************
228 * tr_torrentIterate
229 ***********************************************************************
230 * Iterates on open torrents
231 **********************************************************************/
232typedef struct tr_torrent tr_torrent;
233typedef void (*tr_callback_t) ( tr_torrent *, void * );
234void tr_torrentIterate( tr_handle *, tr_callback_t, void * );
235
236
237/***********************************************************************
238*** Speed Limits
239**/
240
241enum { TR_UP, TR_DOWN };
242
243typedef enum
244{
245    TR_SPEEDLIMIT_GLOBAL,    /* only follow the overall speed limit */
246    TR_SPEEDLIMIT_SINGLE,    /* only follow the per-torrent limit */
247    TR_SPEEDLIMIT_UNLIMITED  /* no limits at all */
248}
249tr_speedlimit;
250
251void tr_torrentSetSpeedMode( tr_torrent   * tor,
252                             int            up_or_down,
253                             tr_speedlimit  mode );
254
255tr_speedlimit tr_torrentGetSpeedMode( const tr_torrent  * tor,
256                                      int                 up_or_down);
257
258void tr_torrentSetSpeedLimit( tr_torrent   * tor,
259                              int            up_or_down,
260                              int            single_KiB_sec );
261
262int tr_torrentGetSpeedLimit( const tr_torrent  * tor,
263                             int                 up_or_down );
264
265void tr_setUseGlobalSpeedLimit( tr_handle * handle,
266                                int           up_or_down,
267                                int           use_flag );
268
269void tr_setGlobalSpeedLimit( tr_handle * handle,
270                             int           up_or_down,
271                             int           global_KiB_sec );
272
273void tr_getGlobalSpeedLimit( tr_handle * handle,
274                             int           up_or_down,
275                             int         * setme_is_enabled,
276                             int         * setme_KiBsec );
277
278/***********************************************************************
279 * Torrent Priorities
280 **********************************************************************/
281
282enum
283{
284    TR_PRI_LOW    = -1,
285    TR_PRI_NORMAL =  0, /* since NORMAL is 0, memset initializes nicely */
286    TR_PRI_HIGH   =  1
287};
288
289typedef int8_t tr_priority_t;
290
291/* set a batch of files to a particular priority.
292 * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
293void tr_torrentSetFilePriorities( tr_torrent        * tor,
294                                  int               * files,
295                                  int                 fileCount,
296                                  tr_priority_t       priority );
297
298/* returns a malloc()ed array of tor->info.fileCount items,
299 * each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
300   free the array when done. */
301tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
302
303/* single-file form of tr_torrentGetFilePriorities.
304 * returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
305tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, int file );
306
307/* returns true if the file's `download' flag is set */
308int tr_torrentGetFileDL( const tr_torrent *, int file );
309
310/* set a batch of files to be downloaded or not. */
311void tr_torrentSetFileDLs ( tr_torrent   * tor,
312                            int          * files,
313                            int            fileCount,
314                            int            do_download );
315
316/***********************************************************************
317 * tr_torrentRates
318 ***********************************************************************
319 * Gets the total download and upload rates
320 **********************************************************************/
321void tr_torrentRates( tr_handle *, float *, float * );
322
323
324
325/**
326 *  Load all the torrents in tr_getTorrentsDirectory().
327 *  This can be used at startup to kickstart all the torrents
328 *  from the previous session.
329 */
330tr_torrent ** tr_loadTorrents ( tr_handle  * h,
331                                const char   * fallback_destination,
332                                int            isPaused,
333                                int          * setmeCount );
334
335
336/***********************************************************************
337 * tr_torrentInit
338 ***********************************************************************
339 * Opens and parses torrent file at 'path'. If the file exists and is
340 * a valid torrent file, returns an handle and adds it to the list of
341 * torrents (but doesn't start it). Returns NULL and sets *error
342 * otherwise. If hash is not NULL and the torrent is already loaded
343 * then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag
344 * is passed then a copy of the torrent file will be saved.
345 **********************************************************************/
346#define TR_EINVALID     1
347#define TR_EUNSUPPORTED 2
348#define TR_EDUPLICATE   3
349#define TR_EOTHER       666
350tr_torrent * tr_torrentInit( tr_handle    * handle,
351                             const char   * metainfo_filename,
352                             const char   * destination,
353                             int            isPaused,
354                             int          * setme_error );
355
356/* This is a stupid hack to fix #415.  Probably I should fold all
357 * these torrent constructors into a single function that takes
358 * a function object to hold all these esoteric arguments. */
359tr_torrent * tr_torrentLoad( tr_handle    * handle,
360                             const char   * metainfo_filename,
361                             const char   * fallback_destination,
362                             int            isPaused,
363                             int          * setme_error );
364
365typedef struct tr_info tr_info;
366
367/**
368 * Parses the specified metainfo file.
369 *
370 * Returns TR_OK if it parsed and can be added to Transmission.
371 * Returns TR_INVALID if it couldn't be parsed.
372 * Returns TR_EDUPLICATE if it parsed but can't be added.
373 *
374 * "destination" can be NULL if you don't need to know whether
375 * or not the torrent can be added.
376 *
377 " "setme_info" can be NULL if you don't need the information.
378 * If the metainfo can be parsed and setme_info is non-NULL,
379 * it will be filled with the metadata's info.  You'll need to
380 * call tr_metainfoFree( setme_info ) when done with it.
381 */
382int tr_torrentParse( const tr_handle  * handle,
383                     const char       * metainfo_filename,
384                     const char       * destination,
385                     tr_info          * setme_info );
386
387/**
388 * Parses the cached metainfo file that matches the given hash string.
389 * See tr_torrentParse() for a description of the arguments
390 */
391int
392tr_torrentParseHash( const tr_handle  * h,
393                     const char       * hashStr,
394                     const char       * destination,
395                     tr_info          * setme_info );
396
397
398/***********************************************************************
399 * tr_torrentInitData
400 ***********************************************************************
401 * Like tr_torrentInit, except the actual torrent data is passed in
402 * instead of the filename.
403 **********************************************************************/
404tr_torrent * tr_torrentInitData( tr_handle *,
405                                 const uint8_t * data, size_t size,
406                                 const char * destination,
407                                 int isPaused,
408                                 int * error );
409
410/***********************************************************************
411 * tr_torrentInitSaved
412 ***********************************************************************
413 * Opens and parses a torrent file as with tr_torrentInit, only taking
414 * the hash string of a saved torrent file instead of a filename. There
415 * are currently no valid flags for this function.
416 **********************************************************************/
417tr_torrent * tr_torrentInitSaved( tr_handle *,
418                                  const char * hashStr,
419                                  const char * destination,
420                                  int isPaused,
421                                  int * error );
422
423/***********************************************************************
424 * tr_torrentDisablePex
425 ***********************************************************************
426 * Disable or enable peer exchange for this torrent. Peer exchange is
427 * enabled by default, except for private torrents where pex is
428 * disabled and cannot be enabled.
429 **********************************************************************/
430void tr_torrentDisablePex( tr_torrent *, int disable );
431int tr_torrentIsPexEnabled( const tr_torrent * );
432
433const tr_info * tr_torrentInfo( const tr_torrent * );
434
435void   tr_torrentSetFolder( tr_torrent *, const char * );
436const char * tr_torrentGetFolder( const tr_torrent * );
437
438/***********************************************************************
439 * tr_torrentStart
440 ***********************************************************************
441 * Starts downloading. The download is launched in a seperate thread,
442 * therefore tr_torrentStart returns immediately.
443 **********************************************************************/
444void   tr_torrentStart( tr_torrent * );
445
446/***********************************************************************
447 * tr_torrentStop
448 ***********************************************************************
449 * Stops downloading and notices the tracker that we are leaving. The
450 * thread keeps running while doing so.
451 * The thread will eventually be joined, either:
452 * - by tr_torrentStat when the tracker has been successfully noticed,
453 * - by tr_torrentStat if the tracker could not be noticed within 60s,
454 * - by tr_torrentClose if you choose to remove the torrent without
455 *   waiting any further.
456 **********************************************************************/
457void tr_torrentStop( tr_torrent * );
458
459
460/**
461***  Register to be notified whenever a torrent's state changes.
462**/
463
464typedef enum
465{
466    TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
467    TR_CP_DONE,         /* has all the pieces but the DND ones */
468    TR_CP_COMPLETE      /* has every piece */
469}
470cp_status_t;
471
472typedef void (tr_torrent_status_func)(tr_torrent   * torrent,
473                                      cp_status_t    status,
474                                      void         * user_data );
475
476void tr_torrentSetStatusCallback( tr_torrent             * torrent,
477                                  tr_torrent_status_func   func,
478                                  void                   * user_data );
479
480void tr_torrentClearStatusCallback( tr_torrent * torrent );
481
482/**
483 * MANUAL ANNOUNCE
484 *
485 * Trackers usually set an announce interval of 15 or 30 minutes.
486 * Users can send one-time announce requests that override this
487 * interval by calling tr_manualUpdate().
488 *
489 * The wait interval for tr_manualUpdate() is much smaller.
490 * You can test whether or not a manual update is possible
491 * (for example, to desensitize the button) by calling
492 * tr_torrentCanManualUpdate().
493 */
494
495void tr_manualUpdate( tr_torrent * );
496
497int tr_torrentCanManualUpdate( const tr_torrent * );
498
499/***********************************************************************
500 * tr_torrentStat
501 ***********************************************************************
502 * Returns a pointer to an tr_stat structure with updated information
503 * on the torrent. The structure belongs to libtransmission (do not
504 * free it) and is guaranteed to be unchanged until the next call to
505 * tr_torrentStat.
506 * The interface should call this function every second or so in order
507 * to update itself.
508 **********************************************************************/
509typedef struct tr_stat tr_stat;
510const tr_stat * tr_torrentStat( tr_torrent * );
511
512/***********************************************************************
513 * tr_torrentPeers
514 ***********************************************************************/
515typedef struct tr_peer_stat tr_peer_stat;
516tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
517void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
518
519typedef struct tr_file_stat tr_file_stat;
520tr_file_stat * tr_torrentFiles( const tr_torrent *, int * fileCount );
521void tr_torrentFilesFree( tr_file_stat *, int fileCount );
522
523
524/***********************************************************************
525 * tr_torrentAvailability
526 ***********************************************************************
527 * Use this to draw an advanced progress bar which is 'size' pixels
528 * wide. Fills 'tab' which you must have allocated: each byte is set
529 * to either -1 if we have the piece, otherwise it is set to the number
530 * of connected peers who have the piece.
531 **********************************************************************/
532void tr_torrentAvailability( const tr_torrent *, int8_t * tab, int size );
533
534void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
535
536/***********************************************************************
537 * tr_torrentRemoveSaved
538 ***********************************************************************
539 * Removes the saved copy of a torrent file for torrents which the
540 * TR_FLAG_SAVE flag is set.
541 **********************************************************************/
542void tr_torrentRemoveSaved( tr_torrent * );
543
544void tr_torrentRecheck( tr_torrent * );
545
546/***********************************************************************
547 * tr_torrentClose
548 ***********************************************************************
549 * Frees memory allocated by tr_torrentInit. If the torrent was running,
550 * it is stopped first.
551 **********************************************************************/
552void tr_torrentClose( tr_torrent * );
553
554/***********************************************************************
555 * tr_info
556 **********************************************************************/
557
558typedef struct tr_file
559{
560    uint64_t length;                /* Length of the file, in bytes */
561    char     name[MAX_PATH_LENGTH]; /* Path to the file */
562    int8_t   priority;              /* TR_PRI_HIGH, _NORMAL, or _LOW */
563    int8_t   dnd;                   /* nonzero if the file shouldn't be downloaded */
564    int      firstPiece;            /* We need pieces [firstPiece... */
565    int      lastPiece;             /* ...lastPiece] to dl this file */
566    uint64_t offset;                /* file begins at the torrent's nth byte */
567}
568tr_file;
569
570typedef struct tr_piece
571{
572    uint8_t  hash[SHA_DIGEST_LENGTH];  /* pieces hash */
573    int8_t   priority;                 /* TR_PRI_HIGH, _NORMAL, or _LOW */
574    int8_t   dnd;                      /* nonzero if the piece shouldn't be downloaded */
575}
576tr_piece;
577   
578typedef struct tr_tracker_info
579{
580    char * address;
581    int    port;
582    char * announce;
583    char * scrape;
584}
585tr_tracker_info;
586
587struct tr_info
588{
589    /* Path to torrent */
590    char                 torrent[MAX_PATH_LENGTH];
591
592    /* General info */
593    uint8_t              hash[SHA_DIGEST_LENGTH];
594    char                 hashString[2*SHA_DIGEST_LENGTH+1];
595    char                 name[MAX_PATH_LENGTH];
596
597    /* Flags */
598    unsigned int isPrivate : 1;
599    unsigned int isMultifile : 1;
600
601    /* Tracker info */
602    struct
603    {
604        tr_tracker_info  * list;
605        int                 count;
606    }                  * trackerList;
607    int                  trackerTiers;
608    char               * primaryAddress;
609
610    /* Torrent info */
611    char                 comment[MAX_PATH_LENGTH];
612    char                 creator[MAX_PATH_LENGTH];
613    int                  dateCreated;
614
615    /* Pieces info */
616    int                  pieceSize;
617    int                  pieceCount;
618    uint64_t             totalSize;
619    tr_piece           * pieces;
620
621    /* Files info */
622    int                  fileCount;
623    tr_file            * files;
624};
625
626typedef enum
627{
628    TR_STATUS_CHECK_WAIT   = (1<<0), /* Waiting in queue to check files */
629    TR_STATUS_CHECK        = (1<<1), /* Checking files */
630    TR_STATUS_DOWNLOAD     = (1<<2), /* Downloading */
631    TR_STATUS_DONE         = (1<<3), /* not at 100% so can't tell the tracker
632                                        we're a seeder, but due to DND files
633                                        there's nothing we want right now */
634    TR_STATUS_SEED         = (1<<4), /* Seeding */
635    TR_STATUS_STOPPED      = (1<<5)  /* Torrent is stopped */
636}
637tr_torrent_status;
638
639#define TR_STATUS_IS_ACTIVE(s) ((s) != TR_STATUS_STOPPED)
640
641/***********************************************************************
642 * tr_stat
643 **********************************************************************/
644struct tr_stat
645{
646    tr_torrent_status   status;
647
648    int                 error;
649    char                errorString[128];
650
651    const tr_tracker_info * tracker;
652
653    float               recheckProgress;
654    float               percentComplete;
655    float               percentDone;
656    float               rateDownload;
657    float               rateUpload;
658    int                 eta;
659    int                 peersKnown;
660    int                 peersConnected;
661    int                 peersFrom[TR_PEER_FROM__MAX];
662    int                 peersSendingToUs;
663    int                 peersGettingFromUs;
664    int                 seeders;
665    int                 leechers;
666    int                 completedFromTracker;
667
668    /* Byte count of how much data is left to be downloaded until
669     * we're done -- that is, until we've got all the pieces we wanted. */
670    uint64_t            leftUntilDone;
671
672    /* Byte count of all the corrupt data you've ever downloaded for
673     * this torrent.  If you're on a poisoned torrent, this number can
674     * grow very large. */
675    uint64_t            corruptEver;
676
677    /* Byte count of all data you've ever uploaded for this torrent. */
678    uint64_t            uploadedEver;
679
680    /* Byte count of all the non-corrupt data you've ever downloaded
681     * for this torrent.  If you deleted the files and downloaded a second time,
682     * this will be 2*totalSize.. */
683    uint64_t            downloadedEver;
684
685    /* Byte count of all the checksum-verified data we have for this torrent. */
686    uint64_t            haveValid;
687
688    /* Byte count of all the partial piece data we have for this torrent.
689     * As pieces become complete, this value may decrease as portions of it are
690     * moved to `corrupt' or `haveValid'. */
691    uint64_t            haveUnchecked;
692
693    /* Byte count of all the non-DND piece data that either we already have,
694     * or that a peer we're connected to has. [0...desiredSize] */
695    uint64_t            desiredAvailable;
696
697    /* Byte count of all the piece data we want, whether we currently
698     * have it nor not. [0...tr_info.totalSize] */
699    uint64_t            desiredSize;
700
701    float               swarmspeed;
702
703#define TR_RATIO_NA  -1
704    float               ratio;
705   
706    uint64_t            startDate;
707    uint64_t            activityDate;
708};
709
710struct tr_file_stat
711{
712    uint64_t bytesCompleted;
713    float progress;
714};
715
716typedef enum
717{
718    TR_PEER_STATUS_HANDSHAKE,
719    TR_PEER_STATUS_PEER_IS_CHOKED,
720    TR_PEER_STATUS_CLIENT_IS_CHOKED,
721    TR_PEER_STATUS_CLIENT_IS_INTERESTED,
722    TR_PEER_STATUS_READY,
723    TR_PEER_STATUS_ACTIVE_AND_CHOKED,
724    TR_PEER_STATUS_REQUEST_SENT,
725    TR_PEER_STATUS_ACTIVE
726}
727tr_peer_status;
728
729struct tr_peer_stat
730{
731    char addr[INET_ADDRSTRLEN];
732    char client[80];
733   
734    unsigned int isEncrypted   : 1;
735    unsigned int isDownloading : 1;
736    unsigned int isUploading   : 1;
737
738    tr_peer_status status;
739
740    uint8_t  from;
741    uint16_t port;
742   
743    float progress;
744    float downloadFromRate;
745    float uploadToRate;
746};
747
748struct tr_msg_list
749{
750    uint8_t              level;
751    time_t               when;
752    char               * message;
753    struct tr_msg_list * next;
754};
755
756struct tr_handle_status
757{
758#define TR_NAT_TRAVERSAL_MAPPING        1
759#define TR_NAT_TRAVERSAL_MAPPED         2
760#define TR_NAT_TRAVERSAL_NOTFOUND       3
761#define TR_NAT_TRAVERSAL_ERROR          4
762#define TR_NAT_TRAVERSAL_UNMAPPING      5
763#define TR_NAT_TRAVERSAL_DISABLED       6
764#define TR_NAT_TRAVERSAL_IS_DISABLED( st ) \
765  ( TR_NAT_TRAVERSAL_DISABLED == (st) || TR_NAT_TRAVERSAL_UNMAPPING == (st) )
766    int natTraversalStatus;
767    int publicPort;
768};
769
770#ifdef __TRANSMISSION__
771#  include "internal.h"
772#endif
773
774#ifdef __cplusplus
775}
776#endif
777
778#endif
Note: See TracBrowser for help on using the repository browser.