source: trunk/libtransmission/transmission.h @ 3885

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

added tr_global_stats prototypes for BentMyWookie?

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