2006-07-16 19:39:23 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-01-01 17:20:20 +00:00
|
|
|
* Copyright (c) 2005-2008 Transmission authors and contributors
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef TR_TRANSMISSION_H
|
|
|
|
#define TR_TRANSMISSION_H 1
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-10-24 18:36:53 +00:00
|
|
|
#include "version.h"
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
#include <inttypes.h> /* uintN_t */
|
2007-05-09 07:00:08 +00:00
|
|
|
#ifndef PRId64
|
|
|
|
# define PRId64 "lld"
|
|
|
|
#endif
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifndef PRIu64
|
2007-05-09 07:00:08 +00:00
|
|
|
# define PRIu64 "llu"
|
2006-07-16 19:39:23 +00:00
|
|
|
#endif
|
2008-01-15 22:00:58 +00:00
|
|
|
#include <time.h> /* time_t */
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
#define SHA_DIGEST_LENGTH 20
|
|
|
|
#ifdef __BEOS__
|
|
|
|
# include <StorageDefs.h>
|
|
|
|
# define MAX_PATH_LENGTH B_FILE_NAME_LENGTH
|
|
|
|
#else
|
|
|
|
# define MAX_PATH_LENGTH 1024
|
|
|
|
#endif
|
|
|
|
|
2008-03-22 18:10:59 +00:00
|
|
|
typedef uint32_t tr_file_index_t;
|
|
|
|
typedef uint32_t tr_piece_index_t;
|
|
|
|
typedef uint64_t tr_block_index_t;
|
|
|
|
|
2007-09-26 01:55:04 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TR_PEER_FROM_INCOMING = 0, /* connections made to the listening port */
|
|
|
|
TR_PEER_FROM_TRACKER = 1, /* peers received from a tracker */
|
|
|
|
TR_PEER_FROM_CACHE = 2, /* peers read from the peer cache */
|
|
|
|
TR_PEER_FROM_PEX = 3, /* peers discovered via PEX */
|
|
|
|
TR_PEER_FROM__MAX
|
|
|
|
};
|
2007-03-23 08:28:01 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_init
|
|
|
|
***********************************************************************
|
2008-01-15 22:00:58 +00:00
|
|
|
* Initializes and returns an opaque libtransmission handle
|
2007-11-19 17:29:17 +00:00
|
|
|
* to be passed to functions below. The tag argument is a short string
|
2007-03-13 06:56:50 +00:00
|
|
|
* unique to the program invoking tr_init(), it is currently used as
|
|
|
|
* part of saved torrent files' names to prevent one frontend from
|
|
|
|
* deleting a torrent used by another. The following tags are used:
|
2008-01-15 22:00:58 +00:00
|
|
|
* beos cli daemon gtk macosx wx
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_handle tr_handle;
|
|
|
|
|
2008-04-05 20:12:11 +00:00
|
|
|
const char* tr_getDefaultConfigDir( void );
|
|
|
|
|
2008-04-12 00:29:49 +00:00
|
|
|
#define TR_DEFAULT_CONFIG_DIR tr_getDefaultConfigDir()
|
|
|
|
#define TR_DEFAULT_PEX_ENABLED 1
|
|
|
|
#define TR_DEFAULT_PORT_FORWARDING_ENABLED 0
|
|
|
|
#define TR_DEFAULT_PORT 51413
|
|
|
|
#define TR_DEFAULT_GLOBAL_PEER_LIMIT 200
|
|
|
|
#define TR_DEFAULT_PEER_SOCKET_TOS 8
|
|
|
|
|
2008-04-05 20:12:11 +00:00
|
|
|
tr_handle * tr_initFull( const char * configDir,
|
|
|
|
const char * tag,
|
2007-12-24 07:02:40 +00:00
|
|
|
int isPexEnabled,
|
2008-04-12 00:29:49 +00:00
|
|
|
int isPortForwardingEnabled,
|
2007-12-24 07:02:40 +00:00
|
|
|
int publicPort,
|
|
|
|
int encryptionMode,
|
|
|
|
int isUploadLimitEnabled,
|
|
|
|
int uploadLimit,
|
|
|
|
int isDownloadLimitEnabled,
|
|
|
|
int downloadLimit,
|
2007-12-24 16:02:36 +00:00
|
|
|
int globalPeerLimit,
|
2007-12-24 16:12:23 +00:00
|
|
|
int messageLevel,
|
2008-03-29 23:12:34 +00:00
|
|
|
int isMessageQueueingEnabled,
|
2008-04-12 00:29:49 +00:00
|
|
|
int isBlocklistEnabled,
|
|
|
|
int peerSocketTOS );
|
2007-12-24 07:02:40 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
/**
|
|
|
|
* Like tr_initFull() but with default values supplied.
|
|
|
|
*/
|
2008-04-05 20:12:11 +00:00
|
|
|
tr_handle * tr_init( const char * configDir,
|
|
|
|
const char * tag );
|
2008-01-15 22:00:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shut down a libtransmission instance created by tr_init*()
|
|
|
|
*/
|
|
|
|
void tr_close( tr_handle * );
|
|
|
|
|
2007-11-19 17:29:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2007-11-19 20:07:21 +00:00
|
|
|
typedef struct tr_session_stats
|
2007-11-19 17:29:17 +00:00
|
|
|
{
|
2007-11-26 20:20:46 +00:00
|
|
|
uint64_t uploadedBytes; /* total up */
|
|
|
|
uint64_t downloadedBytes; /* total down */
|
2008-01-04 19:13:30 +00:00
|
|
|
double ratio; /* TR_RATIO_INF, TR_RATIO_NA, or total up/down */
|
2007-11-19 17:29:17 +00:00
|
|
|
uint64_t filesAdded; /* number of files added */
|
|
|
|
uint64_t sessionCount; /* program started N times */
|
2007-11-19 19:30:24 +00:00
|
|
|
uint64_t secondsActive; /* how long Transmisson's been running */
|
2007-11-19 17:29:17 +00:00
|
|
|
}
|
2007-11-19 20:07:21 +00:00
|
|
|
tr_session_stats;
|
2007-11-19 17:29:17 +00:00
|
|
|
|
2007-11-20 03:11:50 +00:00
|
|
|
/* stats from the current session. */
|
2007-11-19 20:07:21 +00:00
|
|
|
void tr_getSessionStats( const tr_handle * handle,
|
|
|
|
tr_session_stats * setme );
|
2007-11-19 17:29:17 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
/* stats from the current and past sessions. */
|
|
|
|
void tr_getCumulativeSessionStats( const tr_handle * handle,
|
|
|
|
tr_session_stats * setme );
|
|
|
|
|
2008-04-22 14:07:42 +00:00
|
|
|
void tr_clearSessionStats( tr_handle * handle );
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2007-11-08 21:20:08 +00:00
|
|
|
TR_PLAINTEXT_PREFERRED,
|
2007-09-20 16:32:01 +00:00
|
|
|
TR_ENCRYPTION_PREFERRED,
|
|
|
|
TR_ENCRYPTION_REQUIRED
|
|
|
|
}
|
|
|
|
tr_encryption_mode;
|
|
|
|
|
|
|
|
tr_encryption_mode tr_getEncryptionMode( tr_handle * handle );
|
|
|
|
|
|
|
|
void tr_setEncryptionMode( tr_handle * handle, tr_encryption_mode mode );
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2006-08-20 18:15:25 +00:00
|
|
|
/***********************************************************************
|
2008-01-15 22:00:58 +00:00
|
|
|
* tr_getPrefsDirectory
|
2006-08-20 18:15:25 +00:00
|
|
|
***********************************************************************
|
2008-01-15 22:00:58 +00:00
|
|
|
* Returns the full path to a directory which can be used to store
|
|
|
|
* preferences. The string belongs to libtransmission, do not free it.
|
2006-08-20 18:15:25 +00:00
|
|
|
**********************************************************************/
|
2008-04-05 20:12:11 +00:00
|
|
|
const char * tr_getConfigDir( const tr_handle * );
|
2008-01-15 22:00:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
** Message Logging
|
|
|
|
*/
|
|
|
|
|
2008-04-01 19:20:21 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TR_MSG_ERR = 1,
|
|
|
|
TR_MSG_INF = 2,
|
|
|
|
TR_MSG_DBG = 3
|
|
|
|
};
|
2006-08-20 18:15:25 +00:00
|
|
|
void tr_setMessageLevel( int );
|
|
|
|
int tr_getMessageLevel( void );
|
2006-07-16 23:40:22 +00:00
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
typedef struct tr_msg_list
|
|
|
|
{
|
2008-03-13 03:53:18 +00:00
|
|
|
/* TR_MSG_ERR, TR_MSG_INF, or TR_MSG_DBG */
|
|
|
|
uint8_t level;
|
|
|
|
|
|
|
|
/* Time the message was generated */
|
|
|
|
time_t when;
|
|
|
|
|
|
|
|
/* The torrent associated with this message,
|
|
|
|
* or a module name such as "Port Forwarding" for non-torrent messages,
|
|
|
|
* or NULL. */
|
|
|
|
char * name;
|
|
|
|
|
|
|
|
/* The message */
|
|
|
|
char * message;
|
|
|
|
|
|
|
|
/* The source file where this message originated */
|
|
|
|
const char * file;
|
|
|
|
|
|
|
|
/* The line number in the source file where this message originated */
|
|
|
|
int line;
|
|
|
|
|
|
|
|
/* linked list of messages */
|
2008-02-21 07:29:39 +00:00
|
|
|
struct tr_msg_list * next;
|
|
|
|
}
|
|
|
|
tr_msg_list;
|
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
void tr_setMessageQueuing( int enable );
|
2006-08-22 02:12:58 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_msg_list * tr_getQueuedMessages( void );
|
2008-01-15 22:00:58 +00:00
|
|
|
void tr_freeMessageList( tr_msg_list * freeme );
|
2006-08-22 02:12:58 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
2008-01-15 22:00:58 +00:00
|
|
|
** Incoming Peer Connections Port
|
|
|
|
*/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_setBindPort( tr_handle *, int );
|
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
void tr_natTraversalEnable( tr_handle *, int enable );
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
int tr_getPublicPort( const tr_handle * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_NAT_TRAVERSAL_ERROR,
|
2008-04-12 21:47:10 +00:00
|
|
|
TR_NAT_TRAVERSAL_UNMAPPED,
|
|
|
|
TR_NAT_TRAVERSAL_UNMAPPING,
|
|
|
|
TR_NAT_TRAVERSAL_MAPPING,
|
|
|
|
TR_NAT_TRAVERSAL_MAPPED
|
2008-01-15 22:00:58 +00:00
|
|
|
}
|
|
|
|
tr_nat_traversal_status;
|
|
|
|
|
|
|
|
typedef struct tr_handle_status
|
|
|
|
{
|
|
|
|
tr_nat_traversal_status natTraversalStatus;
|
|
|
|
int publicPort;
|
|
|
|
}
|
|
|
|
tr_handle_status;
|
2006-09-25 18:37:45 +00:00
|
|
|
|
2008-01-21 18:24:37 +00:00
|
|
|
const tr_handle_status * tr_handleStatus( tr_handle * );
|
2006-09-25 18:37:45 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2008-01-15 22:00:58 +00:00
|
|
|
***
|
|
|
|
*** TORRENTS
|
|
|
|
**/
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_torrent tr_torrent;
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
int tr_torrentCount( const tr_handle * h );
|
|
|
|
|
2007-07-20 03:24:04 +00:00
|
|
|
/***********************************************************************
|
|
|
|
*** Speed Limits
|
2007-07-18 05:27:45 +00:00
|
|
|
**/
|
|
|
|
|
2007-07-20 08:33:59 +00:00
|
|
|
enum { TR_UP, TR_DOWN };
|
|
|
|
|
2007-07-20 03:24:04 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2007-08-03 15:55:32 +00:00
|
|
|
TR_SPEEDLIMIT_GLOBAL, /* only follow the overall speed limit */
|
|
|
|
TR_SPEEDLIMIT_SINGLE, /* only follow the per-torrent limit */
|
2007-07-20 03:24:04 +00:00
|
|
|
TR_SPEEDLIMIT_UNLIMITED /* no limits at all */
|
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_speedlimit;
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentSetSpeedMode( tr_torrent * tor,
|
|
|
|
int up_or_down,
|
|
|
|
tr_speedlimit mode );
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_speedlimit tr_torrentGetSpeedMode( const tr_torrent * tor,
|
|
|
|
int up_or_down);
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentSetSpeedLimit( tr_torrent * tor,
|
|
|
|
int up_or_down,
|
|
|
|
int single_KiB_sec );
|
2007-07-18 05:27:45 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
int tr_torrentGetSpeedLimit( const tr_torrent * tor,
|
|
|
|
int up_or_down );
|
2007-01-08 21:53:55 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_setUseGlobalSpeedLimit( tr_handle * handle,
|
2007-07-20 08:33:59 +00:00
|
|
|
int up_or_down,
|
|
|
|
int use_flag );
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_setGlobalSpeedLimit( tr_handle * handle,
|
2007-07-20 08:33:59 +00:00
|
|
|
int up_or_down,
|
|
|
|
int global_KiB_sec );
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_getGlobalSpeedLimit( tr_handle * handle,
|
2007-07-20 08:33:59 +00:00
|
|
|
int up_or_down,
|
|
|
|
int * setme_is_enabled,
|
|
|
|
int * setme_KiBsec );
|
|
|
|
|
2007-12-20 21:44:16 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*** Peer Limits
|
|
|
|
**/
|
|
|
|
|
2007-12-22 04:11:17 +00:00
|
|
|
void tr_torrentSetMaxConnectedPeers( tr_torrent * tor,
|
|
|
|
uint16_t maxConnectedPeers);
|
2007-12-22 04:00:19 +00:00
|
|
|
|
2007-12-22 04:11:17 +00:00
|
|
|
uint16_t tr_torrentGetMaxConnectedPeers( const tr_torrent * tor );
|
2007-12-20 21:44:16 +00:00
|
|
|
|
|
|
|
void tr_setGlobalPeerLimit( tr_handle * handle,
|
|
|
|
uint16_t maxGlobalPeers );
|
|
|
|
|
|
|
|
uint16_t tr_getGlobalPeerLimit( const tr_handle * handle );
|
|
|
|
|
|
|
|
|
2008-03-29 18:37:07 +00:00
|
|
|
/**
|
|
|
|
* Specify a range of IPs for Transmission to block.
|
|
|
|
*
|
|
|
|
* filename must be an uncompressed ascii file,
|
|
|
|
* using the same format as the bluetack level1 file.
|
|
|
|
*
|
|
|
|
* libtransmission does not keep a handle to `filename'
|
|
|
|
* after this call returns, so the caller is free to
|
|
|
|
* keep or delete `filename' as it wishes.
|
|
|
|
* libtransmission makes its own copy of the file
|
|
|
|
* massaged into a format easier to search.
|
|
|
|
*
|
|
|
|
* The caller only needs to invoke this when the blocklist
|
|
|
|
* has changed.
|
|
|
|
*
|
|
|
|
* Passing NULL for a filename will clear the blocklist.
|
|
|
|
*/
|
2008-03-30 00:00:28 +00:00
|
|
|
int tr_blocklistSetContent( tr_handle * handle,
|
|
|
|
const char * filename );
|
|
|
|
|
|
|
|
int tr_blocklistGetRuleCount( tr_handle * handle );
|
2008-03-29 18:37:07 +00:00
|
|
|
|
2008-03-29 22:16:33 +00:00
|
|
|
int tr_blocklistExists( const tr_handle * handle );
|
|
|
|
|
2008-03-29 23:12:34 +00:00
|
|
|
int tr_blocklistIsEnabled( const tr_handle * handle );
|
|
|
|
|
|
|
|
void tr_blocklistSetEnabled( tr_handle * handle,
|
|
|
|
int isEnabled );
|
|
|
|
|
2008-04-01 19:20:21 +00:00
|
|
|
struct in_addr;
|
|
|
|
|
|
|
|
int tr_blocklistHasAddress( tr_handle * handle,
|
|
|
|
const struct in_addr * addr);
|
2007-12-20 21:44:16 +00:00
|
|
|
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* Torrent Priorities
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TR_PRI_LOW = -1,
|
|
|
|
TR_PRI_NORMAL = 0, /* since NORMAL is 0, memset initializes nicely */
|
|
|
|
TR_PRI_HIGH = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef int8_t tr_priority_t;
|
|
|
|
|
2007-10-19 23:44:01 +00:00
|
|
|
/* set a batch of files to a particular priority.
|
|
|
|
* priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentSetFilePriorities( tr_torrent * tor,
|
2008-03-22 18:10:59 +00:00
|
|
|
tr_file_index_t * files,
|
|
|
|
tr_file_index_t fileCount,
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_priority_t priority );
|
2007-07-13 00:27:47 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/* returns a malloc()ed array of tor->info.fileCount items,
|
2007-07-10 03:12:46 +00:00
|
|
|
* each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
|
2007-06-18 03:40:41 +00:00
|
|
|
free the array when done. */
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
|
|
|
/* single-file form of tr_torrentGetFilePriorities.
|
2007-07-10 03:12:46 +00:00
|
|
|
* returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
|
2008-03-22 18:10:59 +00:00
|
|
|
tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, tr_file_index_t file );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-07-10 03:12:46 +00:00
|
|
|
/* returns true if the file's `download' flag is set */
|
2008-03-22 18:10:59 +00:00
|
|
|
int tr_torrentGetFileDL( const tr_torrent *, tr_file_index_t file );
|
2007-07-10 03:12:46 +00:00
|
|
|
|
2007-07-13 01:17:21 +00:00
|
|
|
/* set a batch of files to be downloaded or not. */
|
2008-03-22 18:10:59 +00:00
|
|
|
void tr_torrentSetFileDLs ( tr_torrent * tor,
|
|
|
|
tr_file_index_t * files,
|
|
|
|
tr_file_index_t fileCount,
|
|
|
|
int do_download );
|
2007-07-10 03:12:46 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentRates
|
|
|
|
***********************************************************************
|
|
|
|
* Gets the total download and upload rates
|
|
|
|
**********************************************************************/
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentRates( tr_handle *, float *, float * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-07-21 18:46:54 +00:00
|
|
|
|
|
|
|
|
2007-12-21 16:51:42 +00:00
|
|
|
/**
|
|
|
|
* Torrent Instantiation
|
|
|
|
*
|
2008-01-15 22:00:58 +00:00
|
|
|
* Instantiating a tr_torrent had gotten more complicated as features were
|
|
|
|
* added. At one point there were four functions to check metainfo and five
|
|
|
|
* to create tr_torrent.
|
2007-12-21 16:51:42 +00:00
|
|
|
*
|
2007-12-21 22:18:40 +00:00
|
|
|
* To remedy this, a Torrent Constructor (struct tr_ctor) has been introduced:
|
|
|
|
* + Simplifies the API down to two (non-deprecated) functions.
|
|
|
|
* + You can set the fields you want; the system sets defaults for the rest.
|
|
|
|
* + You can specify whether or not your fields should supercede fastresume's.
|
|
|
|
* + We can add new features to tr_ctor without breaking tr_torrentNew()'s API.
|
2007-12-21 16:51:42 +00:00
|
|
|
*
|
2007-12-21 22:18:40 +00:00
|
|
|
* All the tr_ctor{Get,Set}*() functions with a return value return
|
|
|
|
* an error number, or zero if no error occurred.
|
2007-12-21 16:51:42 +00:00
|
|
|
*
|
2007-12-21 22:18:40 +00:00
|
|
|
* You must call one of the SetMetainfo() functions before creating
|
|
|
|
* a torrent with a tr_ctor. The other functions are optional.
|
|
|
|
*
|
|
|
|
* You can reuse a single tr_ctor to create a batch of torrents --
|
|
|
|
* just call one of the SetMetainfo() functions between each
|
|
|
|
* tr_torrentNew() call.
|
2007-12-21 16:51:42 +00:00
|
|
|
*
|
2007-12-21 22:18:40 +00:00
|
|
|
* Every call to tr_ctorSetMetainfo*() frees the previous metainfo.
|
2007-12-21 16:51:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_FALLBACK, /* indicates the ctor value should be used only
|
|
|
|
in case of missing fastresume settings */
|
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
TR_FORCE, /* indicates the ctor value should be used
|
|
|
|
regardless of what's in the fastresume settings */
|
2007-12-21 16:51:42 +00:00
|
|
|
}
|
|
|
|
tr_ctorMode;
|
|
|
|
|
|
|
|
typedef struct tr_ctor tr_ctor;
|
2008-02-26 21:58:58 +00:00
|
|
|
struct tr_benc;
|
2007-12-21 16:51:42 +00:00
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
tr_ctor* tr_ctorNew ( const tr_handle * handle);
|
2007-12-21 16:51:42 +00:00
|
|
|
|
|
|
|
void tr_ctorFree ( tr_ctor * ctor );
|
|
|
|
|
2007-12-22 17:30:31 +00:00
|
|
|
void tr_ctorSetSave ( tr_ctor * ctor,
|
2008-01-15 22:00:58 +00:00
|
|
|
int saveMetadataInOurTorrentsDir );
|
2007-12-22 17:30:31 +00:00
|
|
|
|
2008-02-13 02:24:12 +00:00
|
|
|
void tr_ctorSetDeleteSource ( tr_ctor * ctor,
|
|
|
|
uint8_t doDelete );
|
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
int tr_ctorSetMetainfo ( tr_ctor * ctor,
|
|
|
|
const uint8_t * metainfo,
|
2007-12-21 16:51:42 +00:00
|
|
|
size_t len );
|
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
int tr_ctorSetMetainfoFromFile ( tr_ctor * ctor,
|
2007-12-21 16:51:42 +00:00
|
|
|
const char * filename );
|
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
int tr_ctorSetMetainfoFromHash ( tr_ctor * ctor,
|
2007-12-21 16:51:42 +00:00
|
|
|
const char * hashString );
|
|
|
|
|
|
|
|
void tr_ctorSetMaxConnectedPeers ( tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
uint16_t maxConnectedPeers );
|
|
|
|
|
|
|
|
void tr_ctorSetDestination ( tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
const char * directory );
|
|
|
|
|
|
|
|
void tr_ctorSetPaused ( tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
2007-12-21 22:18:40 +00:00
|
|
|
uint8_t isPaused );
|
2007-12-21 16:51:42 +00:00
|
|
|
|
|
|
|
int tr_ctorGetMaxConnectedPeers ( const tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
uint16_t * setmeCount );
|
|
|
|
|
2008-02-13 02:24:12 +00:00
|
|
|
int tr_ctorGetPaused ( const tr_ctor * ctor,
|
2007-12-21 16:51:42 +00:00
|
|
|
tr_ctorMode mode,
|
2007-12-21 22:18:40 +00:00
|
|
|
uint8_t * setmeIsPaused );
|
2007-12-21 16:51:42 +00:00
|
|
|
|
|
|
|
int tr_ctorGetDestination ( const tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
const char ** setmeDestination );
|
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
int tr_ctorGetMetainfo ( const tr_ctor * ctor,
|
2008-02-26 21:58:58 +00:00
|
|
|
const struct tr_benc ** setme );
|
2007-12-21 16:51:42 +00:00
|
|
|
|
2007-12-22 17:30:31 +00:00
|
|
|
int tr_ctorGetSave ( const tr_ctor * ctor );
|
2008-02-13 02:24:12 +00:00
|
|
|
|
|
|
|
int tr_ctorGetDeleteSource ( const tr_ctor * ctor,
|
|
|
|
uint8_t * setmeDoDelete );
|
|
|
|
|
|
|
|
/* returns NULL if tr_ctorSetMetainfoFromFile() wasn't used */
|
|
|
|
const char* tr_ctorGetSourceFile ( const tr_ctor * ctor );
|
|
|
|
|
2007-12-22 17:30:31 +00:00
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
typedef struct tr_info tr_info;
|
|
|
|
|
2007-12-21 16:51:42 +00:00
|
|
|
/**
|
|
|
|
* Parses the specified metainfo.
|
|
|
|
* Returns TR_OK if it parsed and can be added to Transmission.
|
2008-02-27 20:11:04 +00:00
|
|
|
* Returns TR_EINVALID if it couldn't be parsed.
|
2007-12-21 16:51:42 +00:00
|
|
|
* Returns TR_EDUPLICATE if it parsed but can't be added.
|
|
|
|
* "destination" must be set to test for TR_EDUPLICATE.
|
|
|
|
*
|
2008-03-18 16:26:45 +00:00
|
|
|
* If setme_info is non-NULL and parsing is successful
|
|
|
|
* (that is, if TR_EINVALID is not returned), then the parsed
|
|
|
|
* metainfo is stored in setme_info and should be freed by the
|
|
|
|
* caller via tr_metainfoFree().
|
2007-12-21 16:51:42 +00:00
|
|
|
*/
|
2007-12-22 18:00:47 +00:00
|
|
|
int tr_torrentParse( const tr_handle * handle,
|
|
|
|
const tr_ctor * ctor,
|
2008-01-15 22:00:58 +00:00
|
|
|
tr_info * setme_info_or_NULL );
|
2007-12-21 16:51:42 +00:00
|
|
|
|
|
|
|
/**
|
2007-12-21 22:18:40 +00:00
|
|
|
* Instantiate a single torrent.
|
2007-12-21 16:51:42 +00:00
|
|
|
*/
|
|
|
|
#define TR_EINVALID 1
|
|
|
|
#define TR_EUNSUPPORTED 2
|
|
|
|
#define TR_EDUPLICATE 3
|
|
|
|
#define TR_EOTHER 666
|
|
|
|
tr_torrent * tr_torrentNew( tr_handle * handle,
|
|
|
|
const tr_ctor * ctor,
|
|
|
|
int * setmeError );
|
|
|
|
|
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
/**
|
2008-04-05 20:12:11 +00:00
|
|
|
* Load all the torrents in tr_getTorrentDir().
|
2007-12-21 22:18:40 +00:00
|
|
|
* This can be used at startup to kickstart all the torrents
|
|
|
|
* from the previous session.
|
|
|
|
*/
|
|
|
|
tr_torrent ** tr_loadTorrents ( tr_handle * h,
|
|
|
|
tr_ctor * ctor,
|
|
|
|
int * setmeCount );
|
|
|
|
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-12-24 05:03:40 +00:00
|
|
|
/**
|
|
|
|
* Set whether or not torrents are allowed to do peer exchanges.
|
|
|
|
* PEX is always disabled in private torrents regardless of this.
|
2008-01-15 22:00:58 +00:00
|
|
|
* In public torrents, PEX is enabled by default.
|
2007-12-24 05:03:40 +00:00
|
|
|
*/
|
|
|
|
void tr_setPexEnabled( tr_handle *, int isEnabled );
|
|
|
|
|
|
|
|
int tr_isPexEnabled( const tr_handle * );
|
2007-03-31 19:19:09 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
const tr_info * tr_torrentInfo( const tr_torrent * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
void tr_torrentSetFolder( tr_torrent *, const char * );
|
2007-12-24 05:03:40 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
const char * tr_torrentGetFolder( const tr_torrent * );
|
2007-05-11 18:56:59 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
void tr_torrentStart( tr_torrent * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentStop( tr_torrent * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-09-28 14:51:34 +00:00
|
|
|
/**
|
2008-01-18 19:13:32 +00:00
|
|
|
***
|
2007-09-28 14:51:34 +00:00
|
|
|
**/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_CP_INCOMPLETE, /* doesn't have all the desired pieces */
|
|
|
|
TR_CP_DONE, /* has all the pieces but the DND ones */
|
|
|
|
TR_CP_COMPLETE /* has every piece */
|
|
|
|
}
|
|
|
|
cp_status_t;
|
|
|
|
|
|
|
|
typedef void (tr_torrent_status_func)(tr_torrent * torrent,
|
|
|
|
cp_status_t status,
|
|
|
|
void * user_data );
|
|
|
|
|
2008-01-18 19:13:32 +00:00
|
|
|
/**
|
|
|
|
* Register to be notified whenever a torrent's state changes.
|
|
|
|
*
|
|
|
|
* func is invoked FROM LIBTRANSMISSION'S THREAD!
|
|
|
|
* This means func must be fast (to avoid blocking peers),
|
|
|
|
* shouldn't call libtransmission functions (to avoid deadlock),
|
|
|
|
* and shouldn't modify client-level memory without using a mutex!
|
|
|
|
*/
|
2007-09-28 14:51:34 +00:00
|
|
|
void tr_torrentSetStatusCallback( tr_torrent * torrent,
|
|
|
|
tr_torrent_status_func func,
|
|
|
|
void * user_data );
|
|
|
|
|
|
|
|
void tr_torrentClearStatusCallback( tr_torrent * torrent );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-01-18 19:13:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
|
|
|
typedef void (tr_torrent_active_func)(tr_torrent * torrent,
|
|
|
|
int isRunning,
|
|
|
|
void * user_data );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register to be notified whenever a torrent starts or stops.
|
|
|
|
*
|
|
|
|
* func is invoked FROM LIBTRANSMISSION'S THREAD!
|
|
|
|
* This means func must be fast (to avoid blocking peers),
|
|
|
|
* shouldn't call libtransmission functions (to avoid deadlock),
|
|
|
|
* and shouldn't modify client-level memory without using a mutex!
|
|
|
|
*/
|
|
|
|
void tr_torrentSetActiveCallback( tr_torrent * torrent,
|
|
|
|
tr_torrent_active_func func,
|
|
|
|
void * user_data );
|
|
|
|
|
|
|
|
void tr_torrentClearActiveCallback( tr_torrent * torrent );
|
|
|
|
|
|
|
|
|
2007-07-30 17:11:00 +00:00
|
|
|
/**
|
|
|
|
* MANUAL ANNOUNCE
|
|
|
|
*
|
|
|
|
* Trackers usually set an announce interval of 15 or 30 minutes.
|
|
|
|
* Users can send one-time announce requests that override this
|
|
|
|
* interval by calling tr_manualUpdate().
|
|
|
|
*
|
|
|
|
* The wait interval for tr_manualUpdate() is much smaller.
|
|
|
|
* You can test whether or not a manual update is possible
|
|
|
|
* (for example, to desensitize the button) by calling
|
|
|
|
* tr_torrentCanManualUpdate().
|
|
|
|
*/
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_manualUpdate( tr_torrent * );
|
2006-12-26 18:40:51 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
int tr_torrentCanManualUpdate( const tr_torrent * );
|
2007-07-30 17:11:00 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentStat
|
|
|
|
***********************************************************************
|
2007-09-20 16:32:01 +00:00
|
|
|
* Returns a pointer to an tr_stat structure with updated information
|
2006-07-16 19:39:23 +00:00
|
|
|
* on the torrent. The structure belongs to libtransmission (do not
|
|
|
|
* free it) and is guaranteed to be unchanged until the next call to
|
|
|
|
* tr_torrentStat.
|
|
|
|
* The interface should call this function every second or so in order
|
|
|
|
* to update itself.
|
|
|
|
**********************************************************************/
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_stat tr_stat;
|
|
|
|
const tr_stat * tr_torrentStat( tr_torrent * );
|
2007-12-21 22:18:40 +00:00
|
|
|
const tr_stat * tr_torrentStatCached( tr_torrent * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-08-13 21:16:18 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentPeers
|
|
|
|
***********************************************************************/
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_peer_stat tr_peer_stat;
|
|
|
|
tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
|
|
|
|
void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_file_stat tr_file_stat;
|
2008-03-22 18:10:59 +00:00
|
|
|
tr_file_stat * tr_torrentFiles( const tr_torrent *, tr_file_index_t * fileCount );
|
|
|
|
void tr_torrentFilesFree( tr_file_stat *, tr_file_index_t fileCount );
|
2007-07-15 20:05:32 +00:00
|
|
|
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentAvailability
|
|
|
|
***********************************************************************
|
|
|
|
* Use this to draw an advanced progress bar which is 'size' pixels
|
|
|
|
* wide. Fills 'tab' which you must have allocated: each byte is set
|
|
|
|
* to either -1 if we have the piece, otherwise it is set to the number
|
|
|
|
* of connected peers who have the piece.
|
|
|
|
**********************************************************************/
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentAvailability( const tr_torrent *, int8_t * tab, int size );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
|
2006-10-12 23:34:20 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentRemoveSaved
|
|
|
|
***********************************************************************
|
2008-01-23 17:06:36 +00:00
|
|
|
* delete's Transmission's copy of the torrent's metadata from
|
2008-04-05 20:12:11 +00:00
|
|
|
* tr_getTorrentDir().
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentRemoveSaved( tr_torrent * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-02-27 17:38:39 +00:00
|
|
|
void tr_torrentVerify( tr_torrent * );
|
2007-04-28 01:34:39 +00:00
|
|
|
|
2007-12-21 22:18:40 +00:00
|
|
|
/**
|
|
|
|
* Frees memory allocated by tr_torrentNew().
|
|
|
|
* Running torrents are stopped first.
|
|
|
|
*/
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_torrentClose( tr_torrent * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-02-19 05:03:56 +00:00
|
|
|
/**
|
|
|
|
* Like tr_torrentClose() but also deletes
|
|
|
|
* the fastresume file and our copy of the
|
|
|
|
* torrent file
|
|
|
|
*/
|
|
|
|
void tr_torrentDelete( tr_torrent * );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
2007-09-20 16:32:01 +00:00
|
|
|
* tr_info
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_file
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2008-03-22 18:10:59 +00:00
|
|
|
uint64_t length; /* Length of the file, in bytes */
|
|
|
|
char * name; /* Path to the file */
|
|
|
|
int8_t priority; /* TR_PRI_HIGH, _NORMAL, or _LOW */
|
|
|
|
int8_t dnd; /* nonzero if the file shouldn't be downloaded */
|
|
|
|
tr_piece_index_t firstPiece; /* We need pieces [firstPiece... */
|
|
|
|
tr_piece_index_t lastPiece; /* ...lastPiece] to dl this file */
|
|
|
|
uint64_t offset; /* file begins at the torrent's nth byte */
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_file;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_piece
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH]; /* pieces hash */
|
2007-07-10 03:12:46 +00:00
|
|
|
int8_t priority; /* TR_PRI_HIGH, _NORMAL, or _LOW */
|
2007-07-25 01:59:46 +00:00
|
|
|
int8_t dnd; /* nonzero if the piece shouldn't be downloaded */
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_piece;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-11-19 17:29:17 +00:00
|
|
|
typedef struct tr_tracker_info
|
|
|
|
{
|
2008-04-24 01:42:53 +00:00
|
|
|
int tier;
|
2007-11-19 17:29:17 +00:00
|
|
|
char * announce;
|
|
|
|
char * scrape;
|
|
|
|
}
|
|
|
|
tr_tracker_info;
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_info
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
|
|
|
/* Path to torrent */
|
2008-03-23 03:15:05 +00:00
|
|
|
char * torrent;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* General info */
|
2006-12-17 16:36:27 +00:00
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH];
|
|
|
|
char hashString[2*SHA_DIGEST_LENGTH+1];
|
2008-03-23 03:15:05 +00:00
|
|
|
char * name;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Flags */
|
2007-10-15 20:58:39 +00:00
|
|
|
unsigned int isPrivate : 1;
|
|
|
|
unsigned int isMultifile : 1;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-04-24 01:42:53 +00:00
|
|
|
/* these trackers are sorted by tier */
|
|
|
|
tr_tracker_info * trackers;
|
|
|
|
int trackerCount;
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2006-11-23 01:38:18 +00:00
|
|
|
/* Torrent info */
|
2008-02-14 01:12:00 +00:00
|
|
|
char * comment;
|
|
|
|
char * creator;
|
2008-04-03 21:38:32 +00:00
|
|
|
time_t dateCreated;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Pieces info */
|
2008-03-22 18:10:59 +00:00
|
|
|
uint32_t pieceSize;
|
|
|
|
tr_piece_index_t pieceCount;
|
2006-12-17 16:36:27 +00:00
|
|
|
uint64_t totalSize;
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_piece * pieces;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Files info */
|
2008-03-22 18:10:59 +00:00
|
|
|
tr_file_index_t fileCount;
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_file * files;
|
2006-07-16 19:39:23 +00:00
|
|
|
};
|
|
|
|
|
2007-06-26 18:45:03 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_STATUS_CHECK_WAIT = (1<<0), /* Waiting in queue to check files */
|
|
|
|
TR_STATUS_CHECK = (1<<1), /* Checking files */
|
|
|
|
TR_STATUS_DOWNLOAD = (1<<2), /* Downloading */
|
2008-03-31 17:59:16 +00:00
|
|
|
TR_STATUS_SEED = (1<<3), /* Seeding */
|
|
|
|
TR_STATUS_STOPPED = (1<<4) /* Torrent is stopped */
|
2007-06-26 18:45:03 +00:00
|
|
|
}
|
2007-10-20 21:07:11 +00:00
|
|
|
tr_torrent_status;
|
2007-06-26 18:45:03 +00:00
|
|
|
|
2007-10-20 22:07:21 +00:00
|
|
|
#define TR_STATUS_IS_ACTIVE(s) ((s) != TR_STATUS_STOPPED)
|
2007-06-26 18:45:03 +00:00
|
|
|
|
2008-01-18 19:13:32 +00:00
|
|
|
/**
|
|
|
|
* Transmission error codes
|
|
|
|
* errors are always negative, and 0 refers to no error.
|
|
|
|
*/
|
|
|
|
typedef enum tr_errno
|
|
|
|
{
|
|
|
|
TR_OK = 0,
|
|
|
|
|
|
|
|
/* general errors */
|
|
|
|
TR_ERROR = -100,
|
|
|
|
TR_ERROR_ASSERT,
|
|
|
|
|
|
|
|
/* io errors */
|
|
|
|
TR_ERROR_IO_PARENT = -200,
|
|
|
|
TR_ERROR_IO_PERMISSIONS,
|
|
|
|
TR_ERROR_IO_SPACE,
|
|
|
|
TR_ERROR_IO_FILE_TOO_BIG,
|
|
|
|
TR_ERROR_IO_OPEN_FILES,
|
|
|
|
TR_ERROR_IO_DUP_DOWNLOAD,
|
2008-03-18 17:02:08 +00:00
|
|
|
TR_ERROR_IO_CHECKSUM,
|
2008-01-18 19:13:32 +00:00
|
|
|
TR_ERROR_IO_OTHER,
|
|
|
|
|
|
|
|
/* tracker errors */
|
|
|
|
TR_ERROR_TC_ERROR = -300,
|
2008-03-02 23:44:34 +00:00
|
|
|
TR_ERROR_TC_WARNING,
|
|
|
|
|
|
|
|
/* peer errors */
|
|
|
|
TR_ERROR_PEER_MESSAGE = -400
|
2008-01-18 19:13:32 +00:00
|
|
|
}
|
|
|
|
tr_errno;
|
|
|
|
|
|
|
|
#define TR_ERROR_IS_IO(e) (TR_ERROR_IO_PARENT<=(e) && (e)<=TR_ERROR_IO_OTHER)
|
|
|
|
#define TR_ERROR_IS_TC(e) (TR_ERROR_TC_ERROR<=(e) && (e)<=TR_ERROR_TC_WARNING)
|
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
struct tr_tracker_stat
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2008-02-22 02:39:15 +00:00
|
|
|
/* This is the unmodified string returned by the tracker in response
|
|
|
|
* to the torrent's most recent scrape request. If no request was
|
|
|
|
* sent or there was no response, this string is empty. */
|
2008-03-31 19:34:20 +00:00
|
|
|
char scrapeResponse[256];
|
2008-02-22 02:39:15 +00:00
|
|
|
|
|
|
|
/* The unmodified string returned by the tracker in response
|
|
|
|
* to the torrent's most recent scrape request. If no request was
|
|
|
|
* sent or there was no response, this string is empty. */
|
2008-03-31 19:34:20 +00:00
|
|
|
char announceResponse[256];
|
2008-02-22 02:39:15 +00:00
|
|
|
|
|
|
|
/* Time the most recent scrape request was sent,
|
|
|
|
* or zero if one hasn't been sent yet. */
|
2008-02-21 07:29:39 +00:00
|
|
|
time_t lastScrapeTime;
|
2008-02-22 02:39:15 +00:00
|
|
|
|
|
|
|
/* Time when the next scrape request will be sent.
|
|
|
|
* This value is always a valid time. */
|
2008-02-21 07:29:39 +00:00
|
|
|
time_t nextScrapeTime;
|
2008-02-22 02:39:15 +00:00
|
|
|
|
|
|
|
/* Time the most recent announce request was sent,
|
|
|
|
* or zero if one hasn't been sent yet. */
|
|
|
|
time_t lastAnnounceTime;
|
|
|
|
|
|
|
|
/* Time when the next reannounce request will be sent,
|
|
|
|
* or zero if the torrent is stopped. */
|
2008-02-21 07:29:39 +00:00
|
|
|
time_t nextAnnounceTime;
|
2008-02-22 02:39:15 +00:00
|
|
|
|
|
|
|
/* When the tracker will allow a human-driven "manual" announce to be sent,
|
|
|
|
* derived from the "min interval" field given by the tracker.
|
|
|
|
* This value is 0 when the torrent is stopped.
|
|
|
|
* This value is ~(time_t)0 if the tracker returned a serious error.
|
|
|
|
* Otherwise, the value is a valid time.
|
|
|
|
* @see tr_manualUpdate( tr_torrent * );
|
|
|
|
* @see tr_torrentCanManualUpdate( const tr_torrent * ); */
|
2008-02-21 07:29:39 +00:00
|
|
|
time_t nextManualAnnounceTime;
|
|
|
|
};
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-04-01 02:35:04 +00:00
|
|
|
tr_torrent_status tr_torrentGetStatus( tr_torrent * );
|
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
struct tr_stat
|
|
|
|
{
|
|
|
|
tr_torrent_status status;
|
2007-02-27 04:00:38 +00:00
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
struct tr_tracker_stat tracker_stat;
|
2007-09-20 16:32:01 +00:00
|
|
|
const tr_tracker_info * tracker;
|
2006-08-13 19:43:15 +00:00
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
tr_errno error;
|
|
|
|
char errorString[128];
|
|
|
|
|
2008-04-06 14:42:47 +00:00
|
|
|
/* [0..1] */
|
2008-02-21 07:29:39 +00:00
|
|
|
float recheckProgress;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
|
|
|
/* [0..1] */
|
2008-02-21 07:29:39 +00:00
|
|
|
float percentComplete;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
|
|
|
/* [0..1] */
|
2008-02-21 07:29:39 +00:00
|
|
|
float percentDone;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
|
|
|
/* KiB/s */
|
2008-02-21 07:29:39 +00:00
|
|
|
float rateDownload;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
|
|
|
/* KiB/s */
|
2008-02-21 07:29:39 +00:00
|
|
|
float rateUpload;
|
|
|
|
|
2008-04-06 14:42:47 +00:00
|
|
|
#define TR_ETA_NOT_AVAIL -1
|
|
|
|
#define TR_ETA_UNKNOWN -2
|
2008-04-09 20:50:14 +00:00
|
|
|
/* seconds */
|
|
|
|
int eta;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
int peersKnown;
|
|
|
|
int peersConnected;
|
|
|
|
int peersFrom[TR_PEER_FROM__MAX];
|
|
|
|
int peersSendingToUs;
|
|
|
|
int peersGettingFromUs;
|
|
|
|
int seeders;
|
|
|
|
int leechers;
|
|
|
|
int completedFromTracker;
|
2006-08-13 19:43:15 +00:00
|
|
|
|
2008-02-09 17:07:30 +00:00
|
|
|
/* if the torrent is running, this is the time at which
|
|
|
|
* the client can manually ask the torrent's tracker
|
|
|
|
* for more peers. otherwise, the value is zero. */
|
2008-02-21 07:29:39 +00:00
|
|
|
time_t manualAnnounceTime;
|
2008-02-09 17:07:30 +00:00
|
|
|
|
2008-04-12 15:56:21 +00:00
|
|
|
/* Byte count of all the piece data we'll have downloaded when we're done.
|
|
|
|
* whether or not we have it yet. [0...tr_info.totalSize] */
|
|
|
|
uint64_t sizeWhenDone;
|
|
|
|
|
2007-09-26 01:55:04 +00:00
|
|
|
/* Byte count of how much data is left to be downloaded until
|
2008-04-12 15:56:21 +00:00
|
|
|
* we're done -- that is, until we've got all the pieces we wanted.
|
|
|
|
* [0...tr_info.sizeWhenDone] */
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t leftUntilDone;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-04-12 15:56:21 +00:00
|
|
|
/* Byte count of all the piece data we want and don't have yet,
|
|
|
|
* but that a connected peer does have. [0...leftUntilDone] */
|
|
|
|
uint64_t desiredAvailable;
|
|
|
|
|
2007-09-26 01:55:04 +00:00
|
|
|
/* Byte count of all the corrupt data you've ever downloaded for
|
|
|
|
* this torrent. If you're on a poisoned torrent, this number can
|
|
|
|
* grow very large. */
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t corruptEver;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
|
|
|
/* Byte count of all data you've ever uploaded for this torrent. */
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t uploadedEver;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
|
|
|
/* Byte count of all the non-corrupt data you've ever downloaded
|
|
|
|
* for this torrent. If you deleted the files and downloaded a second time,
|
|
|
|
* this will be 2*totalSize.. */
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t downloadedEver;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
|
|
|
/* Byte count of all the checksum-verified data we have for this torrent. */
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t haveValid;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
|
|
|
/* Byte count of all the partial piece data we have for this torrent.
|
|
|
|
* As pieces become complete, this value may decrease as portions of it are
|
|
|
|
* moved to `corrupt' or `haveValid'. */
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t haveUnchecked;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
float swarmspeed;
|
2006-12-30 19:24:09 +00:00
|
|
|
|
|
|
|
#define TR_RATIO_NA -1
|
2007-12-13 04:31:38 +00:00
|
|
|
#define TR_RATIO_INF -2
|
2008-01-04 19:13:30 +00:00
|
|
|
/* TR_RATIO_INF, TR_RATIO_NA, or a regular ratio */
|
2008-02-21 07:29:39 +00:00
|
|
|
float ratio;
|
2007-05-25 19:14:42 +00:00
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
uint64_t startDate;
|
|
|
|
uint64_t activityDate;
|
2006-07-16 19:39:23 +00:00
|
|
|
};
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_file_stat
|
2007-07-15 20:05:32 +00:00
|
|
|
{
|
|
|
|
uint64_t bytesCompleted;
|
|
|
|
float progress;
|
|
|
|
};
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_peer_stat
|
2006-08-13 21:16:18 +00:00
|
|
|
{
|
2008-01-15 22:00:58 +00:00
|
|
|
char addr[16];
|
2007-11-17 23:43:33 +00:00
|
|
|
char client[80];
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2008-01-10 00:52:02 +00:00
|
|
|
unsigned int isEncrypted : 1;
|
|
|
|
unsigned int isDownloadingFrom : 1;
|
|
|
|
unsigned int isUploadingTo : 1;
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-01-09 17:33:43 +00:00
|
|
|
unsigned int peerIsChoked : 1;
|
|
|
|
unsigned int peerIsInterested : 1;
|
|
|
|
unsigned int clientIsChoked : 1;
|
|
|
|
unsigned int clientIsInterested : 1;
|
|
|
|
unsigned int isIncoming : 1;
|
|
|
|
|
|
|
|
char flagStr[32];
|
2007-11-17 23:43:33 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
uint8_t from;
|
|
|
|
uint16_t port;
|
2006-12-18 05:04:35 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
float progress;
|
|
|
|
float downloadFromRate;
|
|
|
|
float uploadToRate;
|
2006-08-13 21:16:18 +00:00
|
|
|
};
|
|
|
|
|
2007-02-06 04:26:40 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifdef __TRANSMISSION__
|
2008-04-11 17:01:13 +00:00
|
|
|
# include "session.h"
|
2006-07-16 19:39:23 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|