source: trunk/libtransmission/transmission.h @ 3976

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

work on the stats a little bit.

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