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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/*
|
|
|
|
* This file defines the public API for the libtransmission library.
|
|
|
|
*
|
|
|
|
* Other headers suitable for public consumption are bencode.h
|
|
|
|
* and utils.h. Most of the remaining headers in libtransmission
|
|
|
|
* should be considered private to libtransmission.
|
|
|
|
*/
|
2006-07-16 19:39:23 +00:00
|
|
|
#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
|
2008-09-23 19:11:04 +00:00
|
|
|
#define PRId64 "lld"
|
2007-05-09 07:00:08 +00:00
|
|
|
#endif
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifndef PRIu64
|
2008-09-23 19:11:04 +00:00
|
|
|
#define PRIu64 "llu"
|
2006-07-16 19:39:23 +00:00
|
|
|
#endif
|
2008-11-23 16:30:09 +00:00
|
|
|
#ifndef PRIu32
|
|
|
|
#define PRIu32 "lu"
|
|
|
|
#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
|
2008-12-09 20:56:24 +00:00
|
|
|
#define TR_INET6_ADDRSTRLEN 46
|
2008-05-30 15:19:07 +00:00
|
|
|
|
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;
|
2008-12-01 20:51:01 +00:00
|
|
|
typedef uint16_t tr_port;
|
2008-11-28 22:11:41 +00:00
|
|
|
typedef uint8_t tr_bool;
|
2008-03-22 18:10:59 +00:00
|
|
|
|
2008-05-26 12:14:35 +00:00
|
|
|
/**
|
|
|
|
* @brief returns Transmission's default configuration file directory.
|
|
|
|
*
|
|
|
|
* The default configuration directory is determined this way:
|
2008-11-15 17:39:54 +00:00
|
|
|
* 1. If the TRANSMISSION_HOME environmental variable is set, its value is used.
|
2008-12-13 23:17:36 +00:00
|
|
|
* 2. On Darwin, "${HOME}/Library/Application Support/${appname}" is used.
|
|
|
|
* 3. On Windows, "${CSIDL_APPDATA}/${appname}" is used.
|
|
|
|
* 4. If XDG_CONFIG_HOME is set, "${XDG_CONFIG_HOME}/${appname}" is used.
|
|
|
|
* 5. ${HOME}/.config/${appname}" is used as a last resort.
|
2008-05-26 12:14:35 +00:00
|
|
|
*/
|
2008-12-13 23:17:36 +00:00
|
|
|
const char* tr_getDefaultConfigDir( const char * appname );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-11-15 17:39:54 +00:00
|
|
|
/**
|
|
|
|
* @brief returns Transmisson's default download directory.
|
|
|
|
*
|
|
|
|
* The default download directory is determined this way:
|
|
|
|
* 1. If the HOME environmental variable is set, "${HOME}/Downloads" is used.
|
|
|
|
* 2. On Windows, "${CSIDL_MYDOCUMENTS}/Downloads" is used.
|
|
|
|
* 3. Otherwise, getpwuid(getuid())->pw_dir + "/Downloads" is used.
|
|
|
|
*/
|
|
|
|
const char* tr_getDefaultDownloadDir( void );
|
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
typedef struct tr_ctor tr_ctor;
|
|
|
|
typedef struct tr_info tr_info;
|
2008-05-22 20:44:41 +00:00
|
|
|
typedef struct tr_torrent tr_torrent;
|
2008-12-22 19:14:43 +00:00
|
|
|
typedef struct tr_session tr_session;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup tr_session Session
|
|
|
|
*
|
2008-12-14 00:31:33 +00:00
|
|
|
* A libtransmission session is created by calling tr_sessionInit().
|
|
|
|
* libtransmission creates a thread for itself so that it can operate
|
2008-12-14 00:50:41 +00:00
|
|
|
* independently of the caller's event loop. The session will continue
|
2008-12-14 00:31:33 +00:00
|
|
|
* until tr_sessionClose() is called.
|
2008-05-22 20:44:41 +00:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2008-04-05 20:12:11 +00:00
|
|
|
|
2008-06-11 20:45:53 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
TR_PROXY_HTTP,
|
|
|
|
TR_PROXY_SOCKS4,
|
|
|
|
TR_PROXY_SOCKS5
|
2008-06-11 20:45:53 +00:00
|
|
|
}
|
|
|
|
tr_proxy_type;
|
|
|
|
|
2008-08-12 13:51:11 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_CLEAR_PREFERRED,
|
|
|
|
TR_ENCRYPTION_PREFERRED,
|
|
|
|
TR_ENCRYPTION_REQUIRED
|
|
|
|
}
|
|
|
|
tr_encryption_mode;
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
#define TR_DEFAULT_RPC_WHITELIST "127.0.0.1"
|
|
|
|
#define TR_DEFAULT_RPC_PORT_STR "9091"
|
|
|
|
#define TR_DEFAULT_PEER_PORT_STR "51413"
|
|
|
|
#define TR_DEFAULT_PEER_SOCKET_TOS_STR "8"
|
|
|
|
|
|
|
|
#define TR_PREFS_KEY_BLOCKLIST_ENABLED "blocklist-enabled"
|
|
|
|
#define TR_PREFS_KEY_DOWNLOAD_DIR "download-dir"
|
|
|
|
#define TR_PREFS_KEY_DSPEED "download-limit"
|
|
|
|
#define TR_PREFS_KEY_DSPEED_ENABLED "download-limit-enabled"
|
|
|
|
#define TR_PREFS_KEY_ENCRYPTION "encryption"
|
|
|
|
#define TR_PREFS_KEY_LAZY_BITFIELD "lazy-bitfield-enabled"
|
|
|
|
#define TR_PREFS_KEY_MSGLEVEL "message-level"
|
|
|
|
#define TR_PREFS_KEY_PEER_LIMIT_GLOBAL "peer-limit-global"
|
|
|
|
#define TR_PREFS_KEY_PEER_LIMIT_TORRENT "peer-limit-per-torrent"
|
|
|
|
#define TR_PREFS_KEY_PEER_PORT "peer-port"
|
|
|
|
#define TR_PREFS_KEY_PEER_PORT_RANDOM_ENABLED "peer-port-random-enabled"
|
|
|
|
#define TR_PREFS_KEY_PEER_PORT_RANDOM_LOW "peer-port-random-low"
|
|
|
|
#define TR_PREFS_KEY_PEER_PORT_RANDOM_HIGH "peer-port-random-high"
|
|
|
|
#define TR_PREFS_KEY_PEER_SOCKET_TOS "peer-socket-tos"
|
|
|
|
#define TR_PREFS_KEY_PEX_ENABLED "pex-enabled"
|
|
|
|
#define TR_PREFS_KEY_PORT_FORWARDING "port-forwarding-enabled"
|
|
|
|
#define TR_PREFS_KEY_PROXY_AUTH_ENABLED "proxy-auth-enabled"
|
|
|
|
#define TR_PREFS_KEY_PROXY_ENABLED "proxy-enabled"
|
|
|
|
#define TR_PREFS_KEY_PROXY_PASSWORD "proxy-auth-password"
|
|
|
|
#define TR_PREFS_KEY_PROXY_PORT "proxy-port"
|
|
|
|
#define TR_PREFS_KEY_PROXY "proxy"
|
|
|
|
#define TR_PREFS_KEY_PROXY_TYPE "proxy-type"
|
|
|
|
#define TR_PREFS_KEY_PROXY_USERNAME "proxy-auth-username"
|
|
|
|
#define TR_PREFS_KEY_RPC_AUTH_REQUIRED "rpc-authentication-required"
|
|
|
|
#define TR_PREFS_KEY_RPC_ENABLED "rpc-enabled"
|
|
|
|
#define TR_PREFS_KEY_RPC_PASSWORD "rpc-password"
|
|
|
|
#define TR_PREFS_KEY_RPC_PORT "rpc-port"
|
|
|
|
#define TR_PREFS_KEY_RPC_USERNAME "rpc-username"
|
|
|
|
#define TR_PREFS_KEY_RPC_WHITELIST_ENABLED "rpc-whitelist-enabled"
|
|
|
|
#define TR_PREFS_KEY_RPC_WHITELIST "rpc-whitelist"
|
|
|
|
#define TR_PREFS_KEY_USPEED_ENABLED "upload-limit-enabled"
|
|
|
|
#define TR_PREFS_KEY_USPEED "upload-limit"
|
|
|
|
|
|
|
|
struct tr_benc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add libtransmission's default settings to the benc dictionary.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* tr_benc settings;
|
|
|
|
* int64_t i;
|
|
|
|
*
|
|
|
|
* tr_bencInitDict( &settings, 0 );
|
|
|
|
* tr_sessionGetDefaultSettings( &settings );
|
|
|
|
* if( tr_bencDictFindInt( &settings, TR_PREFS_KEY_PEER_PORT, &i ) )
|
|
|
|
* fprintf( stderr, "the default peer port is %d\n", (int)i );
|
|
|
|
* tr_bencFree( &settings );
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* @param initme pointer to a tr_benc dictionary
|
|
|
|
* @see tr_sessionLoadSettings()
|
|
|
|
* @see tr_sessionInit()
|
|
|
|
* @see tr_getDefaultConfigDir()
|
|
|
|
*/
|
|
|
|
void tr_sessionGetDefaultSettings( struct tr_benc * dictionary );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the session's configuration settings to the benc dictionary.
|
|
|
|
*
|
|
|
|
* FIXME: this probably belongs in libtransmissionapp
|
|
|
|
*
|
|
|
|
* @param session
|
|
|
|
* @param dictionary
|
|
|
|
* @see tr_sessionGetDefaultSettings()
|
|
|
|
*/
|
|
|
|
void tr_sessionGetSettings( tr_session *, struct tr_benc * dictionary );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load settings from the configuration directory's settings.json file,
|
|
|
|
* using libtransmission's default settings as fallbacks for missing keys.
|
|
|
|
*
|
|
|
|
* FIXME: this belongs in libtransmissionapp
|
|
|
|
*
|
|
|
|
* @param configDir the configuration directory to find settings.json
|
|
|
|
* @param initme pointer to an uninitialized tr_benc
|
|
|
|
* @param appName examples: Transmission, transmission-daemon
|
|
|
|
* @see tr_sessionGetDefaultSettings()
|
|
|
|
* @see tr_sessionInit()
|
|
|
|
* @see tr_sessionSaveSettings()
|
|
|
|
*/
|
|
|
|
void tr_sessionLoadSettings( struct tr_benc * dictionary,
|
|
|
|
const char * configDir,
|
|
|
|
const char * appName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the session's configuration settings to the benc dictionary
|
|
|
|
* and save it to the configuration directory's settings.json file.
|
|
|
|
*
|
|
|
|
* FIXME: this belongs in libtransmissionapp
|
|
|
|
*
|
|
|
|
* @param session
|
|
|
|
* @param dictionary
|
|
|
|
* @see tr_sessionLoadSettings()
|
|
|
|
*/
|
|
|
|
void tr_sessionSaveSettings( tr_session * session,
|
|
|
|
const char * configDir,
|
|
|
|
struct tr_benc * dictonary );
|
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/**
|
2008-12-13 23:17:36 +00:00
|
|
|
* Initialize a libtransmission session.
|
|
|
|
*
|
|
|
|
* For example, this will instantiate a session with all the default values:
|
|
|
|
* @code
|
|
|
|
* tr_benc settings;
|
|
|
|
* tr_session * session;
|
|
|
|
* const char * configDir;
|
|
|
|
*
|
|
|
|
* tr_bencInitDict( &settings, 0 );
|
|
|
|
* tr_sessionGetDefaultSettings( &settings );
|
|
|
|
* configDir = tr_getDefaultConfigDir( "Transmission" );
|
|
|
|
* session = tr_sessionInit( "mac", configDir, true, &settings );
|
|
|
|
*
|
|
|
|
* tr_bencFree( &settings );
|
|
|
|
* @encode
|
|
|
|
*
|
2008-12-14 00:31:33 +00:00
|
|
|
* @param tag "gtk", "macosx", "daemon", etc... this is only for pre-1.30 resume files
|
2008-12-13 23:17:36 +00:00
|
|
|
* @param configDir where Transmission will look for resume files, blocklists, etc.
|
|
|
|
* @param messageQueueingEnabled if false, messages will be dumped to stderr
|
|
|
|
* @param settings libtransmission settings
|
|
|
|
* @see tr_sessionGetDefaultSettings()
|
|
|
|
* @see tr_sessionLoadSettings()
|
|
|
|
* @see tr_getDefaultConfigDir()
|
2008-05-22 20:44:41 +00:00
|
|
|
*/
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_session * tr_sessionInit( const char * tag,
|
|
|
|
const char * configDir,
|
|
|
|
tr_bool messageQueueingEnabled,
|
|
|
|
struct tr_benc * settings );
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** @brief End a libtransmission session
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit() */
|
|
|
|
void tr_sessionClose( tr_session * );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief Return the session's configuration directory
|
|
|
|
*
|
2008-05-22 23:11:21 +00:00
|
|
|
* This is where transmission stores its .torrent files, .resume files,
|
|
|
|
* blocklists, etc.
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
const char * tr_sessionGetConfigDir( const tr_session * );
|
2008-05-22 23:11:21 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief Set the per-session default download folder for new torrents.
|
2008-12-13 23:17:36 +00:00
|
|
|
* @see tr_sessionInit()
|
2008-05-26 12:14:35 +00:00
|
|
|
* @see tr_sessionGetDownloadDir()
|
2008-05-22 20:44:41 +00:00
|
|
|
* @see tr_ctorSetDownloadDir()
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetDownloadDir( tr_session * session,
|
|
|
|
const char * downloadDir );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief Get the default download folder for new torrents.
|
2008-05-26 12:14:35 +00:00
|
|
|
*
|
2008-12-13 23:17:36 +00:00
|
|
|
* This is set by tr_sessionInit() or tr_sessionSetDownloadDir(),
|
2008-05-26 12:14:35 +00:00
|
|
|
* and can be overridden on a per-torrent basis by tr_ctorSetDownloadDir().
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
const char * tr_sessionGetDownloadDir( const tr_session * session );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-05-26 12:14:35 +00:00
|
|
|
/**
|
|
|
|
* @brief Set whether or not RPC calls are allowed in this session.
|
|
|
|
*
|
2008-09-23 19:11:04 +00:00
|
|
|
* @details If true, libtransmission will open a server socket to listen
|
2008-05-26 12:14:35 +00:00
|
|
|
* for incoming http RPC requests as described in docs/rpc-spec.txt.
|
|
|
|
*
|
2008-12-13 23:17:36 +00:00
|
|
|
* This is intially set by tr_sessionInit() and can be
|
2008-05-26 12:14:35 +00:00
|
|
|
* queried by tr_sessionIsRPCEnabled().
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetRPCEnabled( tr_session * session,
|
2008-12-13 23:39:12 +00:00
|
|
|
tr_bool isEnabled );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-05-26 12:14:35 +00:00
|
|
|
/** @brief Get whether or not RPC calls are allowed in this session.
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit()
|
2008-05-26 12:14:35 +00:00
|
|
|
@see tr_sessionSetRPCEnabled() */
|
2008-12-13 23:39:12 +00:00
|
|
|
tr_bool tr_sessionIsRPCEnabled( const tr_session * session );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-05-26 12:14:35 +00:00
|
|
|
/** @brief Specify which port to listen for RPC requests on.
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit()
|
2008-05-26 12:14:35 +00:00
|
|
|
@see tr_sessionGetRPCPort */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetRPCPort( tr_session * session,
|
2008-12-01 20:51:01 +00:00
|
|
|
tr_port port );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-05-26 12:14:35 +00:00
|
|
|
/** @brief Get which port to listen for RPC requests on.
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit()
|
2008-05-26 12:14:35 +00:00
|
|
|
@see tr_sessionSetRPCPort */
|
2008-12-01 20:51:01 +00:00
|
|
|
tr_port tr_sessionGetRPCPort( const tr_session * session );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-06-04 17:14:58 +00:00
|
|
|
/**
|
2008-10-01 20:23:57 +00:00
|
|
|
* @brief Specify a whitelist for remote RPC access
|
2008-05-26 12:14:35 +00:00
|
|
|
*
|
2008-10-01 20:23:57 +00:00
|
|
|
* The whitelist is a comma-separated list of dotted-quad IP addresses
|
|
|
|
* to be allowed. Wildmat notation is supported, meaning that
|
|
|
|
* '?' is interpreted as a single-character wildcard and
|
|
|
|
* '*' is interprted as a multi-character wildcard.
|
2008-01-15 22:00:58 +00:00
|
|
|
*/
|
2008-10-01 20:23:57 +00:00
|
|
|
void tr_sessionSetRPCWhitelist( tr_session * session,
|
|
|
|
const char * whitelist );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-06-05 16:23:03 +00:00
|
|
|
/** @brief get the Access Control List for allowing/denying RPC requests.
|
2008-10-01 20:23:57 +00:00
|
|
|
@return a comma-separated string of whitelist domains. tr_free() when done.
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit
|
2008-10-01 20:23:57 +00:00
|
|
|
@see tr_sessionSetRPCWhitelist */
|
|
|
|
char* tr_sessionGetRPCWhitelist( const tr_session * );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2008-10-01 22:59:29 +00:00
|
|
|
void tr_sessionSetRPCWhitelistEnabled( tr_session * session,
|
2008-12-13 23:39:12 +00:00
|
|
|
tr_bool isEnabled );
|
2008-10-01 22:59:29 +00:00
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_bool tr_sessionGetRPCWhitelistEnabled( const tr_session * session );
|
2008-10-01 22:59:29 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_sessionSetRPCPassword( tr_session * session,
|
|
|
|
const char * password );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_sessionSetRPCUsername( tr_session * session,
|
|
|
|
const char * username );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
|
|
|
/** @brief get the password used to restrict RPC requests.
|
|
|
|
@return the password string. tr_free() when done.
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit()
|
2008-06-05 16:23:03 +00:00
|
|
|
@see tr_sessionSetRPCPassword() */
|
2008-06-10 16:16:31 +00:00
|
|
|
char* tr_sessionGetRPCPassword( const tr_session * session );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2008-06-10 16:16:31 +00:00
|
|
|
char* tr_sessionGetRPCUsername( const tr_session * session );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2008-06-10 16:16:31 +00:00
|
|
|
void tr_sessionSetRPCPasswordEnabled( tr_session * session,
|
2008-12-13 23:39:12 +00:00
|
|
|
tr_bool isEnabled );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_bool tr_sessionIsRPCPasswordEnabled( const tr_session * session );
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2008-05-18 16:44:30 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_RPC_TORRENT_ADDED,
|
|
|
|
TR_RPC_TORRENT_STARTED,
|
|
|
|
TR_RPC_TORRENT_STOPPED,
|
2008-05-20 23:58:59 +00:00
|
|
|
TR_RPC_TORRENT_REMOVING,
|
2008-10-20 17:54:56 +00:00
|
|
|
TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
|
2008-05-18 16:44:30 +00:00
|
|
|
TR_RPC_SESSION_CHANGED
|
|
|
|
}
|
|
|
|
tr_rpc_callback_type;
|
|
|
|
|
2008-08-14 02:12:29 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/* no special handling is needed by the caller */
|
|
|
|
TR_RPC_OK = 0,
|
|
|
|
|
|
|
|
/* indicates to the caller that the client will take care of
|
|
|
|
* removing the torrent itself. For example the client may
|
|
|
|
* need to keep the torrent alive long enough to cleanly close
|
|
|
|
* some resources in another thread. */
|
2008-09-23 19:11:04 +00:00
|
|
|
TR_RPC_NOREMOVE = ( 1 << 1 )
|
2008-08-14 02:12:29 +00:00
|
|
|
}
|
|
|
|
tr_rpc_callback_status;
|
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
typedef tr_rpc_callback_status (*tr_rpc_func)(tr_session * session,
|
|
|
|
tr_rpc_callback_type type,
|
|
|
|
struct tr_torrent * tor_or_null,
|
|
|
|
void * user_data );
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
/**
|
|
|
|
* Register to be notified whenever something is changed via RPC,
|
|
|
|
* such as a torrent being added, removed, started, stopped, etc.
|
|
|
|
*
|
|
|
|
* 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_sessionSetRPCCallback( tr_session * session,
|
|
|
|
tr_rpc_func func,
|
|
|
|
void * user_data );
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2008-06-10 16:16:31 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_bool tr_sessionIsProxyEnabled( const tr_session * );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_bool tr_sessionIsProxyAuthEnabled( const tr_session * );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
const char* tr_sessionGetProxy( const tr_session * );
|
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_port tr_sessionGetProxyPort( const tr_session * );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
tr_proxy_type tr_sessionGetProxyType( const tr_session * );
|
|
|
|
|
|
|
|
const char* tr_sessionGetProxyUsername( const tr_session * );
|
|
|
|
|
|
|
|
const char* tr_sessionGetProxyPassword( const tr_session * );
|
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxyEnabled( tr_session * session,
|
|
|
|
tr_bool isEnabled );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxyAuthEnabled( tr_session * session,
|
|
|
|
tr_bool isEnabled );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxy( tr_session * session,
|
|
|
|
const char * proxy );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxyPort( tr_session * session,
|
|
|
|
tr_port port );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxyType( tr_session * session,
|
|
|
|
tr_proxy_type proxy_type );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxyUsername( tr_session * session,
|
|
|
|
const char * username );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_sessionSetProxyPassword( tr_session * session,
|
|
|
|
const char * password );
|
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
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
float ratio; /* TR_RATIO_INF, TR_RATIO_NA, or total up/down */
|
|
|
|
uint64_t uploadedBytes; /* total up */
|
|
|
|
uint64_t downloadedBytes; /* total down */
|
|
|
|
uint64_t filesAdded; /* number of files added */
|
|
|
|
uint64_t sessionCount; /* program started N times */
|
|
|
|
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. */
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_sessionGetStats( const tr_session * session,
|
|
|
|
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. */
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_sessionGetCumulativeStats( const tr_session * session,
|
|
|
|
tr_session_stats * setme );
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_sessionClearStats( tr_session * session );
|
2008-04-22 14:07:42 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
/**
|
2008-05-22 12:31:47 +00:00
|
|
|
* Set whether or not torrents are allowed to do peer exchanges.
|
|
|
|
* PEX is always disabled in private torrents regardless of this.
|
|
|
|
* In public torrents, PEX is enabled by default.
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetPexEnabled( tr_session * session,
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool isEnabled );
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool tr_sessionIsPexEnabled( const tr_session * session );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetLazyBitfieldEnabled( tr_session * session,
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool enabled );
|
2008-08-16 21:06:57 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool tr_sessionIsLazyBitfieldEnabled( const tr_session * session );
|
2008-08-16 21:06:57 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_encryption_mode tr_sessionGetEncryption( tr_session * session );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetEncryption( tr_session * session,
|
|
|
|
tr_encryption_mode mode );
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2008-05-22 12:31:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
** Incoming Peer Connections Port
|
|
|
|
*/
|
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetPortForwardingEnabled( tr_session * session,
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool enabled );
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool tr_sessionIsPortForwardingEnabled( const tr_session * session );
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetPeerPort( tr_session * session,
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_port port);
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2008-12-11 04:41:23 +00:00
|
|
|
tr_port tr_sessionSetPeerPortRandom( tr_session * session );
|
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_port tr_sessionGetPeerPort( const tr_session * session );
|
2008-05-22 12:31:47 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_PORT_ERROR,
|
|
|
|
TR_PORT_UNMAPPED,
|
|
|
|
TR_PORT_UNMAPPING,
|
|
|
|
TR_PORT_MAPPING,
|
|
|
|
TR_PORT_MAPPED
|
|
|
|
}
|
|
|
|
tr_port_forwarding;
|
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_port_forwarding tr_sessionGetPortForwarding( const tr_session * session );
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
int tr_sessionCountTorrents( const tr_session * session );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-09-17 19:44:24 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_CLIENT_TO_PEER = 0, TR_UP = 0,
|
|
|
|
TR_PEER_TO_CLIENT = 1, TR_DOWN = 1
|
|
|
|
}
|
|
|
|
tr_direction;
|
|
|
|
|
2008-12-13 22:52:15 +00:00
|
|
|
void tr_sessionSetSpeedLimitEnabled ( tr_session * session,
|
|
|
|
tr_direction direction,
|
|
|
|
tr_bool isEnabled );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-13 22:52:15 +00:00
|
|
|
tr_bool tr_sessionIsSpeedLimitEnabled ( const tr_session * session,
|
|
|
|
tr_direction direction );
|
2008-11-08 02:49:04 +00:00
|
|
|
|
2008-12-13 22:52:15 +00:00
|
|
|
void tr_sessionSetSpeedLimit ( tr_session * session,
|
|
|
|
tr_direction direction,
|
|
|
|
int KiB_sec );
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2008-12-13 22:52:15 +00:00
|
|
|
int tr_sessionGetSpeedLimit ( const tr_session * session,
|
|
|
|
tr_direction direction );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-13 22:52:15 +00:00
|
|
|
double tr_sessionGetRawSpeed ( const tr_session * session,
|
|
|
|
tr_direction direction );
|
|
|
|
|
|
|
|
double tr_sessionGetPieceSpeed ( const tr_session * session,
|
|
|
|
tr_direction direction );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_sessionSetPeerLimit( tr_session * session,
|
|
|
|
uint16_t maxGlobalPeers );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
uint16_t tr_sessionGetPeerLimit( const tr_session * session );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-14 22:57:08 +00:00
|
|
|
void tr_sessionSetPeerLimitPerTorrent( tr_session * session,
|
|
|
|
uint16_t maxGlobalPeers );
|
|
|
|
|
|
|
|
uint16_t tr_sessionGetPeerLimitPerTorrent( const tr_session * session );
|
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/**
|
|
|
|
* Load all the torrents in tr_getTorrentDir().
|
|
|
|
* This can be used at startup to kickstart all the torrents
|
|
|
|
* from the previous session.
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_torrent ** tr_sessionLoadTorrents( tr_session * session,
|
|
|
|
tr_ctor * ctor,
|
|
|
|
int * setmeCount );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
|
|
|
/** @} */
|
2008-05-22 12:31:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
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 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
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 */
|
2008-11-02 22:21:59 +00:00
|
|
|
uint8_t level;
|
2008-03-13 03:53:18 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/* The line number in the source file where this message originated */
|
2008-11-02 22:21:59 +00:00
|
|
|
int line;
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-03-13 03:53:18 +00:00
|
|
|
/* Time the message was generated */
|
2008-11-02 22:21:59 +00:00
|
|
|
time_t when;
|
2008-03-13 03:53:18 +00:00
|
|
|
|
|
|
|
/* The torrent associated with this message,
|
|
|
|
* or a module name such as "Port Forwarding" for non-torrent messages,
|
|
|
|
* or NULL. */
|
2008-09-23 19:11:04 +00:00
|
|
|
char * name;
|
2008-03-13 03:53:18 +00:00
|
|
|
|
|
|
|
/* The message */
|
2008-09-23 19:11:04 +00:00
|
|
|
char * message;
|
2008-03-13 03:53:18 +00:00
|
|
|
|
|
|
|
/* The source file where this message originated */
|
2008-11-02 22:21:59 +00:00
|
|
|
const char * file;
|
2008-03-13 03:53:18 +00:00
|
|
|
|
|
|
|
/* linked list of messages */
|
2008-02-21 07:29:39 +00:00
|
|
|
struct tr_msg_list * next;
|
|
|
|
}
|
|
|
|
tr_msg_list;
|
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
void tr_setMessageQueuing( tr_bool isEnabled );
|
2008-10-21 19:40:12 +00:00
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
tr_bool tr_getMessageQueuing( void );
|
2006-08-22 02:12:58 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_msg_list * tr_getQueuedMessages( void );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
void tr_freeMessageList( tr_msg_list * freeme );
|
2006-08-22 02:12:58 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/** @addtogroup Blocklists
|
|
|
|
@{ */
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-05-22 20:44:41 +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-12-03 07:10:09 +00:00
|
|
|
int tr_blocklistSetContent ( tr_session * session,
|
|
|
|
const char * filename );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
int tr_blocklistGetRuleCount ( const tr_session * session );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool tr_blocklistExists ( const tr_session * session );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
tr_bool tr_blocklistIsEnabled ( const tr_session * session );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2008-12-03 07:10:09 +00:00
|
|
|
void tr_blocklistSetEnabled ( tr_session * session,
|
|
|
|
tr_bool isEnabled );
|
2008-05-22 20:44:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** @addtogroup tr_ctor Torrent Instantiation
|
2008-09-23 19:11:04 +00:00
|
|
|
@{
|
2008-05-23 20:04:41 +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.
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
To remedy this, a Torrent Constructor (struct tr_ctor) has been introduced:
|
|
|
|
- Simplifies the API to two functions: tr_torrentParse() and tr_torrentNew()
|
|
|
|
- You can set the fields you want; the system sets defaults for the rest.
|
|
|
|
- You can specify whether or not your fields should supercede resume's.
|
|
|
|
- We can add new features to tr_ctor without breaking tr_torrentNew()'s API.
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
All the tr_ctor{Get,Set}*() functions with a return value return
|
2008-05-23 20:04:41 +00:00
|
|
|
an error number, or zero if no error occurred.
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
You must call one of the SetMetainfo() functions before creating
|
|
|
|
a torrent with a tr_ctor. The other functions are optional.
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
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.
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
Every call to tr_ctorSetMetainfo*() frees the previous metainfo.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_FALLBACK, /* indicates the ctor value should be used only
|
|
|
|
in case of missing resume settings */
|
|
|
|
|
|
|
|
TR_FORCE, /* indicates the ctor value should be used
|
|
|
|
regardless of what's in the resume settings */
|
|
|
|
}
|
|
|
|
tr_ctorMode;
|
|
|
|
|
|
|
|
struct tr_benc;
|
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_ctor* tr_ctorNew( const tr_session * session );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_ctorFree( tr_ctor * ctor );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_ctorSetDeleteSource( tr_ctor * ctor,
|
2008-12-03 04:55:10 +00:00
|
|
|
tr_bool doDelete );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
int tr_ctorSetMetainfo( tr_ctor * ctor,
|
|
|
|
const uint8_t * metainfo,
|
|
|
|
size_t len );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
int tr_ctorSetMetainfoFromFile( tr_ctor * ctor,
|
|
|
|
const char * filename );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
int tr_ctorSetMetainfoFromHash( tr_ctor * ctor,
|
|
|
|
const char * hashString );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Set the maximum number of peers this torrent can connect to.
|
|
|
|
(Default: 50) */
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_ctorSetPeerLimit( tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
uint16_t peerLimit );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/** Set the download folder for the torrent being added with this ctor.
|
2008-05-23 20:04:41 +00:00
|
|
|
@see tr_ctorSetDownloadDir()
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit() */
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_ctorSetDownloadDir( tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
const char * directory );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Set whether or not the torrent begins downloading/seeding when created.
|
|
|
|
(Default: not paused) */
|
2008-12-03 04:55:10 +00:00
|
|
|
void tr_ctorSetPaused( tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
tr_bool isPaused );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
int tr_ctorGetPeerLimit( const tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
uint16_t * setmeCount );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
int tr_ctorGetPaused( const tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
2008-12-03 04:55:10 +00:00
|
|
|
tr_bool * setmeIsPaused );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_ctorGetDownloadDir( const tr_ctor * ctor,
|
|
|
|
tr_ctorMode mode,
|
|
|
|
const char ** setmeDownloadDir );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_ctorGetMetainfo( const tr_ctor * ctor,
|
2008-09-23 19:11:04 +00:00
|
|
|
const struct tr_benc ** setme );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_ctorGetDeleteSource( const tr_ctor * ctor,
|
2008-12-03 04:55:10 +00:00
|
|
|
tr_bool * setmeDoDelete );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/* returns NULL if tr_ctorSetMetainfoFromFile() wasn't used */
|
2008-09-23 19:11:04 +00:00
|
|
|
const char* tr_ctorGetSourceFile( const tr_ctor * ctor );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
#define TR_EINVALID 1
|
|
|
|
#define TR_EDUPLICATE 2
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses the specified metainfo.
|
2008-10-03 04:49:06 +00:00
|
|
|
* Returns 0 if it parsed successfully and can be added to Transmission.
|
2008-05-23 20:04:41 +00:00
|
|
|
* Returns TR_EINVALID if it couldn't be parsed.
|
2008-09-23 19:11:04 +00:00
|
|
|
* Returns TR_EDUPLICATE if it parsed but can't be added.
|
2008-05-23 20:04:41 +00:00
|
|
|
* "download-dir" must be set to test for TR_EDUPLICATE.
|
|
|
|
*
|
|
|
|
* 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().
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_torrentParse( const tr_session * session,
|
|
|
|
const tr_ctor * ctor,
|
|
|
|
tr_info * setme_info_or_NULL );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
/** @brief free a metainfo
|
|
|
|
@see tr_torrentParse */
|
|
|
|
void tr_metainfoFree( tr_info * inf );
|
|
|
|
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/** Instantiate a single torrent.
|
2008-05-23 20:04:41 +00:00
|
|
|
@return 0 on success,
|
|
|
|
TR_EINVALID if the torrent couldn't be parsed, or
|
|
|
|
TR_EDUPLICATE if there's already a matching torrent object. */
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_torrent * tr_torrentNew( tr_session * session,
|
|
|
|
const tr_ctor * ctor,
|
|
|
|
int * setmeError );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
2008-09-23 19:11:04 +00:00
|
|
|
***
|
|
|
|
*** TORRENTS
|
|
|
|
**/
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/** @addtogroup tr_torrent Torrents
|
|
|
|
@{ */
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** @brief Frees memory allocated by tr_torrentNew().
|
|
|
|
Running torrents are stopped first. */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentFree( tr_torrent * torrent );
|
2008-05-10 00:19:00 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** @brief Removes our .torrent and .resume files for
|
|
|
|
this torrent, then calls tr_torrentFree(). */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentRemove( tr_torrent * torrent );
|
2008-05-30 15:19:07 +00:00
|
|
|
|
|
|
|
/** @brief Start a torrent */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentStart( tr_torrent * torrent );
|
2008-05-30 15:19:07 +00:00
|
|
|
|
|
|
|
/** @brief Stop (pause) a torrent */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentStop( tr_torrent * torrent );
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2008-12-23 16:04:11 +00:00
|
|
|
typedef int tr_fileFunc( const char * filename );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Deletes the torrent's local data.
|
|
|
|
* @param torrent
|
|
|
|
* @param fileFunc Pass in "unlink" to destroy the files or, on platforms with
|
|
|
|
* recycle bins, pass in a function that uses it instead.
|
|
|
|
* tr_torrentDeleteLocalData() ignores fileFunc's return value.
|
|
|
|
*/
|
|
|
|
void tr_torrentDeleteLocalData( tr_torrent * torrent, tr_fileFunc fileFunc );
|
2008-12-09 17:01:49 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/**
|
|
|
|
* @brief Iterate through the torrents.
|
|
|
|
*
|
|
|
|
* Pass in a NULL pointer to get the first torrent.
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_torrent* tr_torrentNext( tr_session * session,
|
|
|
|
tr_torrent * current );
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2008-11-05 05:56:06 +00:00
|
|
|
|
|
|
|
uint64_t tr_torrentGetBytesLeftToAllocate( const tr_torrent * torrent );
|
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/**
|
|
|
|
* @brief Returns this torrent's unique ID.
|
|
|
|
*
|
|
|
|
* IDs are good as simple lookup keys, but are not persistent
|
|
|
|
* between sessions. If you need that, use tr_info.hash or
|
|
|
|
* tr_info.hashString.
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_torrentId( const tr_torrent * torrent );
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/****
|
|
|
|
***** Speed Limits
|
|
|
|
****/
|
2007-07-18 05:27:45 +00:00
|
|
|
|
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
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetSpeedMode( tr_torrent * tor,
|
|
|
|
tr_direction up_or_down,
|
|
|
|
tr_speedlimit mode );
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_speedlimit tr_torrentGetSpeedMode( const tr_torrent * tor,
|
|
|
|
tr_direction direction );
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetSpeedLimit( tr_torrent * tor,
|
|
|
|
tr_direction up_or_down,
|
|
|
|
int KiB_sec );
|
2007-07-18 05:27:45 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_torrentGetSpeedLimit( const tr_torrent * tor,
|
|
|
|
tr_direction direction );
|
2007-01-08 21:53:55 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/****
|
|
|
|
***** Peer Limits
|
|
|
|
****/
|
2007-12-20 21:44:16 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_torrentSetPeerLimit( tr_torrent * tor,
|
|
|
|
uint16_t peerLimit );
|
2007-12-22 04:00:19 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
uint16_t tr_torrentGetPeerLimit( const tr_torrent * tor );
|
2007-12-20 21:44:16 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/****
|
|
|
|
***** File Priorities
|
|
|
|
****/
|
2007-06-18 03:40:41 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2008-05-22 23:11:21 +00:00
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief Set a batch of files to a particular priority.
|
|
|
|
*
|
|
|
|
* @param priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW
|
2008-05-22 23:11:21 +00:00
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetFilePriorities( tr_torrent * torrent,
|
|
|
|
tr_file_index_t * files,
|
|
|
|
tr_file_index_t fileCount,
|
|
|
|
tr_priority_t priority );
|
2007-07-13 00:27:47 +00:00
|
|
|
|
2008-05-22 23:11:21 +00:00
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief Get this torrent's file priorities.
|
2008-05-22 23:11:21 +00:00
|
|
|
*
|
|
|
|
* @return A malloc()ed array of tor->info.fileCount items,
|
2008-05-30 15:19:07 +00:00
|
|
|
* each holding a TR_PRI_NORMAL, TR_PRI_HIGH, or TR_PRI_LOW.
|
|
|
|
* It's the caller's responsibility to free() this.
|
2008-05-22 23:11:21 +00:00
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * torrent );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-05-22 23:11:21 +00:00
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief Single-file form of tr_torrentGetFilePriorities.
|
|
|
|
* @return TR_PRI_NORMAL, TR_PRI_HIGH, or TR_PRI_LOW.
|
2008-05-22 23:11:21 +00:00
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_priority_t tr_torrentGetFilePriority( const tr_torrent * torrent,
|
|
|
|
tr_file_index_t file );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-05-22 23:11:21 +00:00
|
|
|
/**
|
2008-05-30 15:19:07 +00:00
|
|
|
* @brief See if a file's `download' flag is set.
|
|
|
|
* @return true if the file's `download' flag is set.
|
2008-05-22 23:11:21 +00:00
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_torrentGetFileDL( const tr_torrent * torrent,
|
|
|
|
tr_file_index_t file );
|
2007-07-10 03:12:46 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** @brief Set a batch of files to be downloaded or not. */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetFileDLs( tr_torrent * torrent,
|
|
|
|
tr_file_index_t * files,
|
|
|
|
tr_file_index_t fileCount,
|
2008-12-13 23:39:12 +00:00
|
|
|
tr_bool do_download );
|
2007-07-10 03:12:46 +00:00
|
|
|
|
2007-07-21 18:46:54 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
const tr_info * tr_torrentInfo( const tr_torrent * torrent );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetDownloadDir( tr_torrent * torrent,
|
|
|
|
const char * path );
|
2007-12-24 05:03:40 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
const char * tr_torrentGetDownloadDir( const tr_torrent * torrent );
|
2007-05-11 18:56:59 +00:00
|
|
|
|
2008-06-01 01:40:32 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-06-01 01:40:32 +00:00
|
|
|
typedef struct tr_tracker_info
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int tier;
|
|
|
|
char * announce;
|
|
|
|
char * scrape;
|
2008-06-01 01:40:32 +00:00
|
|
|
}
|
|
|
|
tr_tracker_info;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Modify a torrent's tracker list.
|
|
|
|
*
|
2008-06-01 01:55:05 +00:00
|
|
|
* This updates both the `torrent' object's tracker list
|
|
|
|
* and the metainfo file in tr_sessionGetConfigDir()'s torrent subdirectory.
|
2008-06-01 01:40:32 +00:00
|
|
|
*
|
2008-06-01 01:55:05 +00:00
|
|
|
* @param torrent The torrent whose tracker list is to be modified
|
2008-06-01 01:40:32 +00:00
|
|
|
* @param trackers An array of trackers, sorted by tier from first to last.
|
|
|
|
* NOTE: only the `tier' and `announce' fields are used.
|
|
|
|
* libtransmission derives `scrape' from `announce'.
|
2008-06-01 01:55:05 +00:00
|
|
|
* @param trackerCount size of the `trackers' array
|
2008-06-01 01:40:32 +00:00
|
|
|
*/
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_torrentSetAnnounceList( tr_torrent * torrent,
|
|
|
|
const tr_tracker_info * trackers,
|
|
|
|
int trackerCount );
|
2008-06-01 01:40:32 +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
|
|
|
|
{
|
2008-11-30 01:52:45 +00:00
|
|
|
TR_LEECH, /* doesn't have all the desired pieces */
|
|
|
|
TR_SEED, /* has the entire torrent */
|
|
|
|
TR_PARTIAL_SEED /* has the desired pieces, but not the entire torrent */
|
2007-09-28 14:51:34 +00:00
|
|
|
}
|
2008-10-20 17:54:56 +00:00
|
|
|
tr_completeness;
|
2007-09-28 14:51:34 +00:00
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
typedef void ( tr_torrent_completeness_func )( tr_torrent * torrent,
|
|
|
|
tr_completeness completeness,
|
|
|
|
void * user_data );
|
2007-09-28 14:51:34 +00:00
|
|
|
|
2008-01-18 19:13:32 +00:00
|
|
|
/**
|
2008-10-20 17:54:56 +00:00
|
|
|
* Register to be notified whenever a torrent's "completeness"
|
|
|
|
* changes. This will be called, for example, when a torrent
|
2008-11-30 01:52:45 +00:00
|
|
|
* finishes downloading and changes from TR_LEECH to
|
|
|
|
* either TR_SEED or TR_PARTIAL_SEED.
|
2008-01-18 19:13:32 +00:00
|
|
|
*
|
|
|
|
* 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!
|
2008-10-20 17:54:56 +00:00
|
|
|
*
|
|
|
|
* @see tr_completeness
|
2008-01-18 19:13:32 +00:00
|
|
|
*/
|
2008-10-20 17:54:56 +00:00
|
|
|
void tr_torrentSetCompletenessCallback(
|
|
|
|
tr_torrent * torrent,
|
|
|
|
tr_torrent_completeness_func func,
|
|
|
|
void * user_data );
|
2007-09-28 14:51:34 +00:00
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
void tr_torrentClearCompletenessCallback( tr_torrent * torrent );
|
2008-01-18 19:13:32 +00:00
|
|
|
|
|
|
|
|
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
|
2008-05-22 20:44:41 +00:00
|
|
|
* interval by calling tr_torrentManualUpdate().
|
2007-07-30 17:11:00 +00:00
|
|
|
*
|
2008-05-22 20:44:41 +00:00
|
|
|
* The wait interval for tr_torrentManualUpdate() is much smaller.
|
2007-07-30 17:11:00 +00:00
|
|
|
* You can test whether or not a manual update is possible
|
|
|
|
* (for example, to desensitize the button) by calling
|
|
|
|
* tr_torrentCanManualUpdate().
|
|
|
|
*/
|
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentManualUpdate( tr_torrent * torrent );
|
2006-12-26 18:40:51 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
int tr_torrentCanManualUpdate( const tr_torrent * torrent );
|
2007-07-30 17:11:00 +00:00
|
|
|
|
2006-08-13 21:16:18 +00:00
|
|
|
/***********************************************************************
|
2008-09-23 19:11:04 +00:00
|
|
|
* tr_torrentPeers
|
|
|
|
***********************************************************************/
|
2008-05-30 15:19:07 +00:00
|
|
|
|
|
|
|
typedef struct tr_peer_stat
|
|
|
|
{
|
2008-11-28 22:11:41 +00:00
|
|
|
tr_bool isEncrypted;
|
|
|
|
tr_bool isDownloadingFrom;
|
|
|
|
tr_bool isUploadingTo;
|
2008-12-02 23:16:01 +00:00
|
|
|
tr_bool isSeed;
|
2008-11-28 22:11:41 +00:00
|
|
|
|
|
|
|
tr_bool peerIsChoked;
|
|
|
|
tr_bool peerIsInterested;
|
|
|
|
tr_bool clientIsChoked;
|
|
|
|
tr_bool clientIsInterested;
|
|
|
|
tr_bool isIncoming;
|
|
|
|
|
|
|
|
uint8_t from;
|
2008-12-01 20:51:01 +00:00
|
|
|
tr_port port;
|
2008-11-28 22:11:41 +00:00
|
|
|
|
2008-12-09 20:56:24 +00:00
|
|
|
char addr[TR_INET6_ADDRSTRLEN];
|
2008-11-28 22:11:41 +00:00
|
|
|
char client[80];
|
|
|
|
char flagStr[32];
|
|
|
|
|
|
|
|
float progress;
|
|
|
|
float rateToPeer;
|
|
|
|
float rateToClient;
|
2008-05-30 15:19:07 +00:00
|
|
|
}
|
|
|
|
tr_peer_stat;
|
|
|
|
|
|
|
|
tr_peer_stat * tr_torrentPeers( const tr_torrent * torrent,
|
2008-09-23 19:11:04 +00:00
|
|
|
int * peerCount );
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_torrentPeersFree( tr_peer_stat * peerStats,
|
|
|
|
int peerCount );
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2008-06-10 01:38:12 +00:00
|
|
|
/**
|
|
|
|
* @brief get the download speeds for each of this torrent's webseed sources.
|
|
|
|
*
|
|
|
|
* @return an array of tor->info.webseedCount floats giving download speeds.
|
|
|
|
* Each speed in the array corresponds to the webseed at the same
|
|
|
|
* array index in tor->info.webseeds.
|
2008-06-10 01:46:36 +00:00
|
|
|
* To differentiate "idle" and "stalled" status, idle webseeds will
|
|
|
|
* return -1 instead of 0 KiB/s.
|
2008-06-10 01:38:12 +00:00
|
|
|
* NOTE: always free this array with tr_free() when you're done with it.
|
|
|
|
*/
|
2008-11-02 22:21:59 +00:00
|
|
|
float* tr_torrentWebSpeeds( const tr_torrent * torrent );
|
2008-06-10 01:38:12 +00:00
|
|
|
|
2008-05-29 03:24:26 +00:00
|
|
|
typedef struct tr_file_stat
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
uint64_t bytesCompleted;
|
|
|
|
float progress;
|
2008-05-29 03:24:26 +00:00
|
|
|
}
|
|
|
|
tr_file_stat;
|
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
tr_file_stat * tr_torrentFiles( const tr_torrent * torrent,
|
|
|
|
tr_file_index_t * fileCount );
|
2008-05-29 03:24:26 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentFilesFree( tr_file_stat * files,
|
|
|
|
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.
|
|
|
|
**********************************************************************/
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentAvailability( const tr_torrent * torrent,
|
|
|
|
int8_t * tab,
|
|
|
|
int size );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentAmountFinished( const tr_torrent * torrent,
|
|
|
|
float * tab,
|
|
|
|
int size );
|
2006-10-12 23:34:20 +00:00
|
|
|
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentVerify( tr_torrent * torrent );
|
2007-04-28 01:34:39 +00:00
|
|
|
|
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-09-23 19:11:04 +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
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH]; /* pieces hash */
|
|
|
|
int8_t priority; /* TR_PRI_HIGH, _NORMAL, or _LOW */
|
|
|
|
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-11-19 17:29:17 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_info
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2008-05-26 12:52:38 +00:00
|
|
|
/* Flags */
|
2008-11-28 22:11:41 +00:00
|
|
|
tr_bool isPrivate;
|
|
|
|
tr_bool isMultifile;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* General info */
|
2008-10-20 16:04:26 +00:00
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH];
|
|
|
|
char hashString[2 * SHA_DIGEST_LENGTH + 1];
|
|
|
|
char * name;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-10-20 16:04:26 +00:00
|
|
|
/* Path to torrent Transmission's internal copy of the .torrent file.
|
|
|
|
This field exists for compatability reasons in the Mac OS X client
|
|
|
|
and should not be used in new code. */
|
|
|
|
char * torrent;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-04-24 01:42:53 +00:00
|
|
|
/* these trackers are sorted by tier */
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_tracker_info * trackers;
|
|
|
|
int trackerCount;
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2008-10-20 16:04:26 +00:00
|
|
|
char ** webseeds;
|
2008-09-23 19:11:04 +00:00
|
|
|
int webseedCount;
|
2008-06-07 21:26:41 +00:00
|
|
|
|
2006-11-23 01:38:18 +00:00
|
|
|
/* Torrent info */
|
2008-10-20 16:04:26 +00:00
|
|
|
char * comment;
|
|
|
|
char * creator;
|
|
|
|
time_t dateCreated;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Pieces info */
|
2008-10-20 16:04:26 +00:00
|
|
|
uint32_t pieceSize;
|
|
|
|
tr_piece_index_t pieceCount;
|
|
|
|
uint64_t totalSize;
|
|
|
|
tr_piece * pieces;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Files info */
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_file_index_t fileCount;
|
|
|
|
tr_file * files;
|
2006-07-16 19:39:23 +00:00
|
|
|
};
|
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
/**
|
|
|
|
* What the torrent is doing right now.
|
|
|
|
*
|
|
|
|
* Note: these values will become a straight enum at some point in the future.
|
|
|
|
* Do not rely on their current `bitfield' implementation
|
|
|
|
*/
|
2007-06-26 18:45:03 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
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 */
|
|
|
|
TR_STATUS_SEED = ( 1 << 3 ), /* Seeding */
|
|
|
|
TR_STATUS_STOPPED = ( 1 << 4 ) /* Torrent is stopped */
|
2007-06-26 18:45:03 +00:00
|
|
|
}
|
2008-10-20 17:54:56 +00:00
|
|
|
tr_torrent_activity;
|
2007-06-26 18:45:03 +00:00
|
|
|
|
2008-11-08 02:49:04 +00:00
|
|
|
tr_torrent_activity tr_torrentGetActivity( tr_torrent * );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#define TR_STATUS_IS_ACTIVE( s ) ( ( s ) != TR_STATUS_STOPPED )
|
2007-06-26 18:45:03 +00:00
|
|
|
|
2008-08-17 12:39:26 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
TR_LOCKFILE_SUCCESS = 0,
|
|
|
|
TR_LOCKFILE_EOPEN,
|
|
|
|
TR_LOCKFILE_ELOCK
|
2008-10-03 04:49:06 +00:00
|
|
|
}
|
|
|
|
tr_lockfile_state_t;
|
2008-08-17 12:39:26 +00:00
|
|
|
|
2008-05-22 20:44:41 +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
|
|
|
|
};
|
|
|
|
|
2008-10-03 04:57:06 +00:00
|
|
|
/** Can be used as a mnemonic for "no error" errno */
|
|
|
|
#define TR_OK 0
|
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/**
|
|
|
|
* The current status of a torrent.
|
|
|
|
* @see tr_torrentStat()
|
|
|
|
*/
|
2008-05-30 15:19:07 +00:00
|
|
|
typedef struct tr_stat
|
2008-02-21 07:29:39 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
/** The torrent's unique Id.
|
2008-05-23 20:04:41 +00:00
|
|
|
@see tr_torrentId() */
|
2008-09-23 19:11:04 +00:00
|
|
|
int id;
|
2008-05-22 16:59:51 +00:00
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
/** What is this torrent doing right now? */
|
|
|
|
tr_torrent_activity activity;
|
2007-02-27 04:00:38 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Our current announce URL, or NULL if none.
|
|
|
|
This URL may change during the session if the torrent's
|
|
|
|
metainfo has multiple trackers and the current one
|
|
|
|
becomes unreachable. */
|
2008-09-23 19:11:04 +00:00
|
|
|
char * announceURL;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Our current scrape URL, or NULL if none.
|
|
|
|
This URL may change during the session if the torrent's
|
|
|
|
metainfo has multiple trackers and the current one
|
|
|
|
becomes unreachable. */
|
2008-09-23 19:11:04 +00:00
|
|
|
char * scrapeURL;
|
2006-08-13 19:43:15 +00:00
|
|
|
|
2008-10-03 04:49:06 +00:00
|
|
|
/** The errno status for this torrent. 0 means everything's fine. */
|
|
|
|
int error;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Typically an error string returned from the tracker. */
|
2008-09-23 19:11:04 +00:00
|
|
|
char errorString[128];
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** When tr_stat.status is TR_STATUS_CHECK or TR_STATUS_CHECK_WAIT,
|
|
|
|
this is the percentage of how much of the files has been
|
|
|
|
verified. When it gets to 1, the verify process is done.
|
|
|
|
Range is [0..1]
|
|
|
|
@see tr_stat.status */
|
2008-09-23 19:11:04 +00:00
|
|
|
float recheckProgress;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** How much has been downloaded of the entire torrent.
|
|
|
|
Range is [0..1] */
|
2008-09-23 19:11:04 +00:00
|
|
|
float percentComplete;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** How much has been downloaded of the files the user wants. This differs
|
|
|
|
from percentComplete if the user wants only some of the torrent's files.
|
|
|
|
Range is [0..1]
|
|
|
|
@see tr_stat.leftUntilDone */
|
2008-09-23 19:11:04 +00:00
|
|
|
float percentDone;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
2008-11-08 02:49:04 +00:00
|
|
|
/** Speed all data being sent for this torrent. (KiB/s)
|
|
|
|
This includes piece data, protocol messages, and TCP overhead */
|
|
|
|
double rawUploadSpeed;
|
|
|
|
|
|
|
|
/** Speed all data being received for this torrent. (KiB/s)
|
|
|
|
This includes piece data, protocol messages, and TCP overhead */
|
|
|
|
double rawDownloadSpeed;
|
|
|
|
|
|
|
|
/** Speed all piece being sent for this torrent. (KiB/s)
|
|
|
|
This ONLY counts piece data. */
|
|
|
|
double pieceUploadSpeed;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
2008-11-08 02:49:04 +00:00
|
|
|
/** Speed all piece being received for this torrent. (KiB/s)
|
|
|
|
This ONLY counts piece data. */
|
|
|
|
double pieceDownloadSpeed;
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#define TR_ETA_NOT_AVAIL -1
|
|
|
|
#define TR_ETA_UNKNOWN -2
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Estimated number of seconds left until the torrent is done,
|
|
|
|
or TR_ETA_NOT_AVAIL or TR_ETA_UNKNOWN */
|
2008-09-23 19:11:04 +00:00
|
|
|
int eta;
|
2008-04-06 14:42:47 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Number of peers that the tracker says this torrent has */
|
2008-09-23 19:11:04 +00:00
|
|
|
int peersKnown;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Number of peers that we're connected to */
|
2008-09-23 19:11:04 +00:00
|
|
|
int peersConnected;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** How many peers we found out about from the tracker, or from pex,
|
|
|
|
or from incoming connections, or from our resume file. */
|
2008-09-23 19:11:04 +00:00
|
|
|
int peersFrom[TR_PEER_FROM__MAX];
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Number of peers that are sending data to us. */
|
2008-09-23 19:11:04 +00:00
|
|
|
int peersSendingToUs;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Number of peers that we're sending data to */
|
2008-09-23 19:11:04 +00:00
|
|
|
int peersGettingFromUs;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-06-10 02:36:52 +00:00
|
|
|
/** Number of webseeds that are sending data to us. */
|
2008-09-23 19:11:04 +00:00
|
|
|
int webseedsSendingToUs;
|
2008-06-10 02:36:52 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Number of seeders that the tracker says this torrent has */
|
2008-09-23 19:11:04 +00:00
|
|
|
int seeders;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** Number of leechers that the tracker says this torrent has */
|
2008-09-23 19:11:04 +00:00
|
|
|
int leechers;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2008-12-02 19:46:51 +00:00
|
|
|
/** Number of downloaders that the tracker says this torrent has.
|
|
|
|
This is a new key introduced in BEP 21 and may not be supported by some trackers.
|
|
|
|
If the tracker doesn't support this key, the value here will be -1. */
|
|
|
|
int downloaders;
|
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Number of finished downloads that the tracker says torrent has */
|
2008-09-23 19:11:04 +00:00
|
|
|
int timesCompleted;
|
2006-08-13 19:43:15 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Byte count of all the piece data we'll have downloaded when we're done,
|
2008-11-30 01:52:45 +00:00
|
|
|
whether or not we have it yet. This may be less than tr_info.totalSize
|
|
|
|
if only some of the torrent's files are wanted.
|
|
|
|
[0...tr_info.totalSize] */
|
2008-09-23 19:11:04 +00:00
|
|
|
uint64_t sizeWhenDone;
|
2008-04-12 15:56:21 +00:00
|
|
|
|
2008-11-30 01:52:45 +00:00
|
|
|
/** Byte count of how much data is left to be downloaded until we've got
|
|
|
|
all the pieces that we want. [0...tr_info.sizeWhenDone] */
|
2008-09-23 19:11:04 +00:00
|
|
|
uint64_t leftUntilDone;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +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] */
|
2008-09-23 19:11:04 +00:00
|
|
|
uint64_t desiredAvailable;
|
2008-04-12 15:56:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +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-09-23 19:11:04 +00:00
|
|
|
uint64_t corruptEver;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Byte count of all data you've ever uploaded for this torrent. */
|
2008-09-23 19:11:04 +00:00
|
|
|
uint64_t uploadedEver;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +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-09-23 19:11:04 +00:00
|
|
|
uint64_t downloadedEver;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/** Byte count of all the checksum-verified data we have for this torrent.
|
|
|
|
*/
|
|
|
|
uint64_t haveValid;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +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-09-23 19:11:04 +00:00
|
|
|
uint64_t haveUnchecked;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +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-09-23 19:11:04 +00:00
|
|
|
char scrapeResponse[64];
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +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-09-23 19:11:04 +00:00
|
|
|
char announceResponse[64];
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Time the most recent scrape request was sent,
|
|
|
|
or zero if one hasn't been sent yet. */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t lastScrapeTime;
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-07-11 11:51:15 +00:00
|
|
|
/** Time when the next scrape request will be sent,
|
|
|
|
or 0 if an error has occured that stops scraping,
|
|
|
|
or 1 if a scrape is currently in progress s.t.
|
|
|
|
we haven't set a timer for the next one yet. */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t nextScrapeTime;
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Time the most recent announce request was sent,
|
|
|
|
or zero if one hasn't been sent yet. */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t lastAnnounceTime;
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Time when the next reannounce request will be sent,
|
2008-07-11 11:51:15 +00:00
|
|
|
or 0 if the torrent is stopped,
|
|
|
|
or 1 if an announce is currently in progress s.t.
|
|
|
|
we haven't set a timer for the next one yet */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t nextAnnounceTime;
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** If the torrent is running, this is the time at which
|
|
|
|
the client can manually ask the torrent's tracker
|
2008-07-11 11:51:15 +00:00
|
|
|
for more peers,
|
|
|
|
or 0 if the torrent is stopped or doesn't allow manual,
|
|
|
|
or 1 if an announce is currently in progress s.t.
|
|
|
|
we haven't set a timer for the next one yet */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t manualAnnounceTime;
|
2008-05-22 23:11:21 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** A very rough estimate in KiB/s of how quickly data is being
|
2008-09-23 19:11:04 +00:00
|
|
|
passed around between all the peers we're connected to.
|
2008-05-23 20:04:41 +00:00
|
|
|
Don't put too much weight in this number. */
|
2008-09-23 19:11:04 +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-05-23 20:04:41 +00:00
|
|
|
/** TR_RATIO_INF, TR_RATIO_NA, or a regular ratio */
|
2008-09-23 19:11:04 +00:00
|
|
|
float ratio;
|
2008-06-02 04:41:55 +00:00
|
|
|
|
|
|
|
/** When the torrent was first added. */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t addedDate;
|
2008-06-03 19:16:12 +00:00
|
|
|
|
|
|
|
/** When the torrent finished downloading. */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t doneDate;
|
|
|
|
|
|
|
|
/** When the torrent was last started. */
|
|
|
|
time_t startDate;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** The last time we uploaded or downloaded piece data on this torrent. */
|
2008-09-23 19:11:04 +00:00
|
|
|
time_t activityDate;
|
2008-05-30 15:19:07 +00:00
|
|
|
}
|
|
|
|
tr_stat;
|
2008-01-09 17:33:43 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** Return a pointer to an tr_stat structure with updated information
|
|
|
|
on the torrent. This is typically called by the GUI clients every
|
|
|
|
second or so to get a new snapshot of the torrent's status. */
|
2008-11-02 22:21:59 +00:00
|
|
|
const tr_stat * tr_torrentStat( tr_torrent * torrent );
|
2007-11-17 23:43:33 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** Like tr_torrentStat(), but only recalculates the statistics if it's
|
|
|
|
been longer than a second since they were last calculated. This can
|
|
|
|
reduce the CPU load if you're calling tr_torrentStat() frequently. */
|
2008-11-02 22:21:59 +00:00
|
|
|
const tr_stat * tr_torrentStatCached( tr_torrent * torrent );
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2008-06-03 19:22:22 +00:00
|
|
|
/** @deprecated this method will be removed in 1.40 */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetAddedDate( tr_torrent * torrent,
|
|
|
|
time_t addedDate );
|
2008-06-03 19:22:22 +00:00
|
|
|
|
|
|
|
/** @deprecated this method will be removed in 1.40 */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetActivityDate( tr_torrent * torrent,
|
|
|
|
time_t activityDate );
|
2008-06-03 19:22:22 +00:00
|
|
|
|
2008-06-03 19:42:54 +00:00
|
|
|
/** @deprecated this method will be removed in 1.40 */
|
2008-11-02 22:21:59 +00:00
|
|
|
void tr_torrentSetDoneDate( tr_torrent * torrent,
|
|
|
|
time_t doneDate );
|
2008-06-03 19:42:54 +00:00
|
|
|
|
2008-12-21 18:15:00 +00:00
|
|
|
/** @brief Sanity checker to test that the direction is TR_UP or TR_DOWN */
|
|
|
|
tr_bool tr_isDirection( tr_direction );
|
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/** @} */
|
2007-02-06 04:26:40 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|