2014-01-19 01:09:44 +00:00
|
|
|
/*
|
2022-01-20 18:27:56 +00:00
|
|
|
* This file Copyright © Transmission authors and contributors.
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2014-01-19 01:09:44 +00:00
|
|
|
* It may be used under the 3-Clause BSD License, the GNU Public License v2,
|
|
|
|
* or v3, or any future license endorsed by Mnemosyne LLC.
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2014-01-19 01:09:44 +00:00
|
|
|
*/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/*
|
|
|
|
* This file defines the public API for the libtransmission library.
|
2020-11-02 15:16:12 +00:00
|
|
|
* The other public API headers are variant.h and utils.h.
|
|
|
|
* Most of the remaining headers in libtransmission are private.
|
2008-05-30 15:19:07 +00:00
|
|
|
*/
|
2014-01-19 01:09:44 +00:00
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/***
|
|
|
|
**** Basic Types
|
|
|
|
***/
|
|
|
|
|
2017-05-24 19:53:06 +00:00
|
|
|
#include <stdbool.h> /* bool */
|
2017-06-18 12:34:21 +00:00
|
|
|
#include <stddef.h> /* size_t */
|
|
|
|
#include <stdint.h> /* uintN_t */
|
2009-05-29 19:17:12 +00:00
|
|
|
#include <time.h> /* time_t */
|
|
|
|
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#endif
|
|
|
|
|
2017-06-18 12:34:21 +00:00
|
|
|
#include "tr-macros.h"
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_file_index_t = uint32_t;
|
|
|
|
using tr_piece_index_t = uint32_t;
|
2022-04-15 05:38:59 +00:00
|
|
|
/* Assuming a 16 KiB block (tr_block_info::BlockSize), a 32-bit block index gives us a maximum torrent size of 64 TiB.
|
|
|
|
* When we ever need to grow past that, change tr_block_index_t and tr_piece_index_t to uint64_t. */
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_block_index_t = uint32_t;
|
2021-11-10 02:42:18 +00:00
|
|
|
using tr_tracker_tier_t = uint32_t;
|
2021-12-14 20:59:40 +00:00
|
|
|
using tr_tracker_id_t = uint32_t;
|
2021-12-24 06:39:55 +00:00
|
|
|
using tr_byte_index_t = uint64_t;
|
2022-04-29 02:35:47 +00:00
|
|
|
using tr_torrent_id_t = int;
|
2021-12-14 20:59:40 +00:00
|
|
|
|
2021-11-25 18:26:51 +00:00
|
|
|
struct tr_block_span_t
|
2021-11-19 18:37:38 +00:00
|
|
|
{
|
2021-11-25 18:26:51 +00:00
|
|
|
tr_block_index_t begin;
|
|
|
|
tr_block_index_t end;
|
2021-11-19 18:37:38 +00:00
|
|
|
};
|
|
|
|
|
2021-12-26 18:43:27 +00:00
|
|
|
struct tr_byte_span_t
|
|
|
|
{
|
|
|
|
uint64_t begin;
|
|
|
|
uint64_t end;
|
|
|
|
};
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_ctor;
|
2015-10-23 04:09:40 +00:00
|
|
|
struct tr_error;
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_session;
|
|
|
|
struct tr_torrent;
|
2021-12-26 03:12:32 +00:00
|
|
|
struct tr_torrent_metainfo;
|
2012-12-14 04:34:42 +00:00
|
|
|
struct tr_variant;
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_priority_t = int8_t;
|
2009-05-29 19:17:12 +00:00
|
|
|
|
|
|
|
#define TR_RPC_SESSION_ID_HEADER "X-Transmission-Session-Id"
|
2008-04-05 20:12:11 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_preallocation_mode
|
2009-01-16 16:38:16 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_PREALLOCATE_NONE = 0,
|
2009-01-16 16:38:16 +00:00
|
|
|
TR_PREALLOCATE_SPARSE = 1,
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_PREALLOCATE_FULL = 2
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-01-16 16:38:16 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_encryption_mode
|
2008-08-12 13:51:11 +00:00
|
|
|
{
|
|
|
|
TR_CLEAR_PREFERRED,
|
|
|
|
TR_ENCRYPTION_PREFERRED,
|
|
|
|
TR_ENCRYPTION_REQUIRED
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2022-01-17 23:16:37 +00:00
|
|
|
#define TR_RATIO_NA -1
|
|
|
|
#define TR_RATIO_INF -2
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
**** Startup & Shutdown
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup tr_session Session
|
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* A libtransmission session is created by calling tr_sessionInit().
|
2009-05-29 19:17:12 +00:00
|
|
|
* libtransmission creates a thread for itself so that it can operate
|
2010-12-27 19:18:17 +00:00
|
|
|
* independently of the caller's event loop. The session will continue
|
2017-04-21 07:40:57 +00:00
|
|
|
* until tr_sessionClose() is called.
|
2009-05-29 19:17:12 +00:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2022-08-17 00:28:57 +00:00
|
|
|
* @brief get Transmission's default configuration file directory.
|
2022-07-23 01:10:02 +00:00
|
|
|
*
|
2009-05-29 19:17:12 +00:00
|
|
|
* The default configuration directory is determined this way:
|
|
|
|
* -# If the TRANSMISSION_HOME environment variable is set, its value is used.
|
|
|
|
* -# On Darwin, "${HOME}/Library/Application Support/${appname}" is used.
|
|
|
|
* -# On Windows, "${CSIDL_APPDATA}/${appname}" is used.
|
|
|
|
* -# If XDG_CONFIG_HOME is set, "${XDG_CONFIG_HOME}/${appname}" is used.
|
|
|
|
* -# ${HOME}/.config/${appname}" is used as a last resort.
|
|
|
|
*/
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
[[nodiscard]] std::string tr_getDefaultConfigDir(std::string_view appname);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @brief buffer variant of tr_getDefaultConfigDir(). See tr_strvToBuf(). */
|
|
|
|
size_t tr_getDefaultConfigDirToBuf(char const* appname, char* buf, size_t buflen);
|
2009-05-29 19:17:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief returns Transmisson's default download directory.
|
|
|
|
*
|
|
|
|
* The default download directory is determined this way:
|
|
|
|
* -# If the HOME environment variable is set, "${HOME}/Downloads" is used.
|
|
|
|
* -# On Windows, "${CSIDL_MYDOCUMENTS}/Downloads" is used.
|
2017-04-21 07:40:57 +00:00
|
|
|
* -# Otherwise, getpwuid(getuid())->pw_dir + "/Downloads" is used.
|
2009-05-29 19:17:12 +00:00
|
|
|
*/
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
[[nodiscard]] std::string tr_getDefaultDownloadDir();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @brief buffer variant of tr_getDefaultDownloadDir(). See tr_strvToBuf(). */
|
|
|
|
size_t tr_getDefaultDownloadDirToBuf(char* buf, size_t buflen);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2017-01-28 20:18:38 +00:00
|
|
|
#define TR_DEFAULT_RPC_WHITELIST "127.0.0.1,::1"
|
2017-04-19 12:04:45 +00:00
|
|
|
#define TR_DEFAULT_RPC_PORT_STR "9091"
|
2020-07-27 04:30:58 +00:00
|
|
|
#define TR_DEFAULT_RPC_PORT 9091
|
2017-04-19 12:04:45 +00:00
|
|
|
#define TR_DEFAULT_RPC_URL_STR "/transmission/"
|
|
|
|
#define TR_DEFAULT_PEER_PORT_STR "51413"
|
2022-02-10 21:35:28 +00:00
|
|
|
#define TR_DEFAULT_PEER_SOCKET_TOS_STR "le"
|
2017-04-19 12:04:45 +00:00
|
|
|
#define TR_DEFAULT_PEER_LIMIT_GLOBAL_STR "200"
|
|
|
|
#define TR_DEFAULT_PEER_LIMIT_TORRENT_STR "50"
|
2021-11-25 18:26:51 +00:00
|
|
|
#define TR_DEFAULT_PEER_LIMIT_TORRENT 50
|
2010-05-08 22:42:28 +00:00
|
|
|
|
2008-12-13 23:17:36 +00:00
|
|
|
/**
|
|
|
|
* Add libtransmission's default settings to the benc dictionary.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
2012-12-14 04:34:42 +00:00
|
|
|
* tr_variant settings;
|
2008-12-13 23:17:36 +00:00
|
|
|
* int64_t i;
|
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* tr_variantInitDict(&settings, 0);
|
|
|
|
* tr_sessionGetDefaultSettings(&settings);
|
|
|
|
* if (tr_variantDictFindInt(&settings, TR_PREFS_KEY_PEER_PORT, &i))
|
|
|
|
* fprintf(stderr, "the default peer port is %d\n", (int)i);
|
2022-08-18 01:25:42 +00:00
|
|
|
* tr_variantClear(&settings);
|
2008-12-13 23:17:36 +00:00
|
|
|
* @endcode
|
|
|
|
*
|
2016-03-29 03:04:54 +00:00
|
|
|
* @param setme_dictionary pointer to a tr_variant dictionary
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionLoadSettings()
|
|
|
|
* @see tr_sessionInit()
|
|
|
|
* @see tr_getDefaultConfigDir()
|
2008-12-13 23:17:36 +00:00
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionGetDefaultSettings(struct tr_variant* setme_dictionary);
|
2008-12-13 23:17:36 +00:00
|
|
|
|
|
|
|
/**
|
2009-05-29 19:17:12 +00:00
|
|
|
* Add the session's current configuration settings to the benc dictionary.
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
2020-09-11 21:07:45 +00:00
|
|
|
* TODO: if we ever make libtransmissionapp, this would go there.
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
2016-03-29 03:04:54 +00:00
|
|
|
* @param session the session to query
|
|
|
|
* @param setme_dictionary the dictionary to populate
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionGetDefaultSettings()
|
2008-12-13 23:17:36 +00:00
|
|
|
*/
|
2021-12-17 05:47:51 +00:00
|
|
|
void tr_sessionGetSettings(tr_session const* session, struct tr_variant* setme_dictionary);
|
2008-12-13 23:17:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load settings from the configuration directory's settings.json file,
|
|
|
|
* using libtransmission's default settings as fallbacks for missing keys.
|
|
|
|
*
|
2020-09-11 21:07:45 +00:00
|
|
|
* TODO: if we ever make libtransmissionapp, this would go there.
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
2012-12-14 04:34:42 +00:00
|
|
|
* @param dictionary pointer to an uninitialized tr_variant
|
2008-12-13 23:17:36 +00:00
|
|
|
* @param configDir the configuration directory to find settings.json
|
2009-05-29 19:17:12 +00:00
|
|
|
* @param appName if configDir is empty, appName is used to find the default dir.
|
2011-03-22 15:19:54 +00:00
|
|
|
* @return success true if the settings were loaded, false otherwise
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionGetDefaultSettings()
|
|
|
|
* @see tr_sessionInit()
|
|
|
|
* @see tr_sessionSaveSettings()
|
2008-12-13 23:17:36 +00:00
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
bool tr_sessionLoadSettings(struct tr_variant* dictionary, char const* config_dir, char const* appName);
|
2008-12-13 23:17:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the session's configuration settings to the benc dictionary
|
|
|
|
* and save it to the configuration directory's settings.json file.
|
|
|
|
*
|
2020-09-11 21:07:45 +00:00
|
|
|
* TODO: if we ever make libtransmissionapp, this would go there.
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
2016-03-29 03:04:54 +00:00
|
|
|
* @param session the session to save
|
|
|
|
* @param configDir the directory to write to
|
|
|
|
* @param dictionary the dictionary to save
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionLoadSettings()
|
2008-12-13 23:17:36 +00:00
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSaveSettings(tr_session* session, char const* config_dir, struct tr_variant const* client_settings);
|
2008-12-13 23:17:36 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/**
|
2009-05-29 19:17:12 +00:00
|
|
|
* @brief Initialize a libtransmission session.
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
|
|
|
* For example, this will instantiate a session with all the default values:
|
|
|
|
* @code
|
2012-12-14 04:34:42 +00:00
|
|
|
* tr_variant settings;
|
2017-04-20 16:02:19 +00:00
|
|
|
* tr_session* session;
|
|
|
|
* char const* configDir;
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* tr_variantInitDict(&settings, 0);
|
|
|
|
* tr_sessionGetDefaultSettings(&settings);
|
|
|
|
* configDir = tr_getDefaultConfigDir("Transmission");
|
|
|
|
* session = tr_sessionInit(configDir, true, &settings);
|
2008-12-13 23:17:36 +00:00
|
|
|
*
|
2022-08-18 01:25:42 +00:00
|
|
|
* tr_variantClear(&settings);
|
2009-05-29 19:17:12 +00:00
|
|
|
* @endcode
|
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
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionGetDefaultSettings()
|
|
|
|
* @see tr_sessionLoadSettings()
|
|
|
|
* @see tr_getDefaultConfigDir()
|
2008-05-22 20:44:41 +00:00
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
tr_session* tr_sessionInit(char const* config_dir, bool message_queueing_enabled, struct tr_variant* settings);
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2011-03-21 16:26:45 +00:00
|
|
|
/** @brief Update a session's settings from a benc dictionary
|
2017-04-21 07:40:57 +00:00
|
|
|
like to the one used in tr_sessionInit() */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSet(tr_session* session, struct tr_variant* settings);
|
2009-10-23 03:41:36 +00:00
|
|
|
|
2011-03-21 16:26:45 +00:00
|
|
|
/** @brief Rescan the blocklists directory and
|
|
|
|
reload whatever blocklist files are found there */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionReloadBlocklists(tr_session* session);
|
2009-12-01 00:07:18 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** @brief End a libtransmission session
|
2017-04-21 07:40:57 +00:00
|
|
|
@see tr_sessionInit() */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionClose(tr_session*);
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2022-07-22 05:52:48 +00:00
|
|
|
/**
|
|
|
|
* @brief Return the session's configuration directory.
|
|
|
|
*
|
|
|
|
* This is where transmission stores its torrent files, .resume files,
|
|
|
|
* blocklists, etc. It's set in tr_transmissionInit() and is immutable
|
|
|
|
* during the session.
|
|
|
|
*/
|
|
|
|
char const* tr_sessionGetConfigDir(tr_session const*);
|
|
|
|
|
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.
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionInit()
|
|
|
|
* @see tr_sessionGetDownloadDir()
|
|
|
|
* @see tr_ctorSetDownloadDir()
|
2008-05-22 20:44:41 +00:00
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_sessionSetDownloadDir(tr_session* session, char const* 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
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* This is set by tr_sessionInit() or tr_sessionSetDownloadDir(),
|
|
|
|
* and can be overridden on a per-torrent basis by tr_ctorSetDownloadDir().
|
2008-05-26 12:14:35 +00:00
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_sessionGetDownloadDir(tr_session const* session);
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2010-02-02 07:48:03 +00:00
|
|
|
/**
|
|
|
|
* @brief Set the torrent's bandwidth priority.
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_ctorSetBandwidthPriority(tr_ctor* ctor, tr_priority_t priority);
|
2010-02-02 07:48:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the torrent's bandwidth priority.
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_priority_t tr_ctorGetBandwidthPriority(tr_ctor const* ctor);
|
2010-02-02 07:48:03 +00:00
|
|
|
|
2009-10-19 05:05:00 +00:00
|
|
|
/**
|
2010-01-19 19:37:00 +00:00
|
|
|
* @brief set the per-session incomplete download folder.
|
2009-10-20 03:14:44 +00:00
|
|
|
*
|
|
|
|
* When you add a new torrent and the session's incomplete directory is enabled,
|
|
|
|
* the new torrent will start downloading into that directory, and then be moved
|
|
|
|
* to tr_torrent.downloadDir when the torrent is finished downloading.
|
|
|
|
*
|
2011-03-21 16:26:45 +00:00
|
|
|
* Torrents aren't moved as a result of changing the session's incomplete dir --
|
2009-10-20 03:14:44 +00:00
|
|
|
* it's applied to new torrents, not existing ones.
|
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* tr_torrentSetLocation() overrules the incomplete dir: when a user specifies
|
2009-10-20 03:14:44 +00:00
|
|
|
* a new location, that becomes the torrent's new downloadDir and the torrent
|
|
|
|
* is moved there immediately regardless of whether or not it's complete.
|
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionInit()
|
|
|
|
* @see tr_sessionGetIncompleteDir()
|
|
|
|
* @see tr_sessionSetIncompleteDirEnabled()
|
|
|
|
* @see tr_sessionGetIncompleteDirEnabled()
|
2009-10-19 05:05:00 +00:00
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_sessionSetIncompleteDir(tr_session* session, char const* dir);
|
2009-10-19 05:05:00 +00:00
|
|
|
|
2010-01-19 19:37:00 +00:00
|
|
|
/** @brief get the per-session incomplete download folder */
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_sessionGetIncompleteDir(tr_session const* session);
|
2009-10-19 05:05:00 +00:00
|
|
|
|
2010-01-19 19:37:00 +00:00
|
|
|
/** @brief enable or disable use of the incomplete download folder */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetIncompleteDirEnabled(tr_session* session, bool);
|
2009-10-19 05:05:00 +00:00
|
|
|
|
2010-01-19 19:37:00 +00:00
|
|
|
/** @brief get whether or not the incomplete download folder is enabled */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsIncompleteDirEnabled(tr_session const* session);
|
2009-10-20 03:14:44 +00:00
|
|
|
|
|
|
|
/**
|
2009-10-20 04:43:51 +00:00
|
|
|
* @brief When enabled, newly-created files will have ".part" appended
|
|
|
|
* to their filename until the file is fully downloaded
|
2009-10-20 03:14:44 +00:00
|
|
|
*
|
|
|
|
* This is not retroactive -- toggling this will not rename existing files.
|
|
|
|
* It only applies to new files created by Transmission after this API call.
|
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* @see tr_sessionIsIncompleteFileNamingEnabled()
|
2009-10-20 03:14:44 +00:00
|
|
|
*/
|
2022-08-15 00:33:28 +00:00
|
|
|
void tr_sessionSetIncompleteFileNamingEnabled(tr_session* session, bool enabled);
|
2009-10-20 03:14:44 +00:00
|
|
|
|
2011-03-21 16:26:45 +00:00
|
|
|
/** @brief return true if files will end in ".part" until they're complete */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsIncompleteFileNamingEnabled(tr_session const* session);
|
2009-10-19 05:05:00 +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
|
2022-02-21 16:39:58 +00:00
|
|
|
* for incoming http RPC requests as described in docs/rpc-spec.md.
|
2008-05-26 12:14:35 +00:00
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* This is intially set by tr_sessionInit() and can be
|
|
|
|
* queried by tr_sessionIsRPCEnabled().
|
2008-05-26 12:14:35 +00:00
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetRPCEnabled(tr_session* session, bool is_enabled);
|
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.
|
2017-04-21 07:40:57 +00:00
|
|
|
@see tr_sessionInit()
|
|
|
|
@see tr_sessionSetRPCEnabled() */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsRPCEnabled(tr_session const* 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.
|
2017-04-21 07:40:57 +00:00
|
|
|
@see tr_sessionInit()
|
2008-05-26 12:14:35 +00:00
|
|
|
@see tr_sessionGetRPCPort */
|
2022-04-21 15:58:13 +00:00
|
|
|
void tr_sessionSetRPCPort(tr_session* session, uint16_t 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.
|
2017-04-21 07:40:57 +00:00
|
|
|
@see tr_sessionInit()
|
2008-05-26 12:14:35 +00:00
|
|
|
@see tr_sessionSetRPCPort */
|
2022-04-21 15:58:13 +00:00
|
|
|
uint16_t tr_sessionGetRPCPort(tr_session const* 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
|
2010-12-27 19:18:17 +00:00
|
|
|
* to be allowed. Wildmat notation is supported, meaning that
|
2008-10-01 20:23:57 +00:00
|
|
|
* '?' is interpreted as a single-character wildcard and
|
|
|
|
* '*' is interprted as a multi-character wildcard.
|
2008-01-15 22:00:58 +00:00
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_sessionSetRPCWhitelist(tr_session* session, char const* 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.
|
2009-04-16 19:14:37 +00:00
|
|
|
@return a comma-separated string of whitelist domains.
|
2008-12-13 23:17:36 +00:00
|
|
|
@see tr_sessionInit
|
2008-10-01 20:23:57 +00:00
|
|
|
@see tr_sessionSetRPCWhitelist */
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_sessionGetRPCWhitelist(tr_session const*);
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetRPCWhitelistEnabled(tr_session* session, bool isEnabled);
|
2008-10-01 22:59:29 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionGetRPCWhitelistEnabled(tr_session const* session);
|
2008-10-01 22:59:29 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_sessionSetRPCPassword(tr_session* session, char const* password);
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_sessionSetRPCUsername(tr_session* session, char const* username);
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2021-11-15 03:54:48 +00:00
|
|
|
// TODO(ckerr): rename function to indicate it returns the salted value
|
|
|
|
/** @brief get the salted version of the password used to restrict RPC requests.
|
2009-04-16 19:14:37 +00:00
|
|
|
@return the password string.
|
2017-04-21 07:40:57 +00:00
|
|
|
@see tr_sessionInit()
|
|
|
|
@see tr_sessionSetRPCPassword() */
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_sessionGetRPCPassword(tr_session const* session);
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_sessionGetRPCUsername(tr_session const* session);
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetRPCPasswordEnabled(tr_session* session, bool isEnabled);
|
2008-06-05 16:23:03 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsRPCPasswordEnabled(tr_session const* session);
|
2009-04-15 21:05:58 +00:00
|
|
|
|
2022-02-20 17:54:20 +00:00
|
|
|
void tr_sessionSetDefaultTrackers(tr_session* session, char const* trackers);
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_rpc_callback_type
|
2008-05-18 16:44:30 +00:00
|
|
|
{
|
|
|
|
TR_RPC_TORRENT_ADDED,
|
|
|
|
TR_RPC_TORRENT_STARTED,
|
|
|
|
TR_RPC_TORRENT_STOPPED,
|
2008-05-20 23:58:59 +00:00
|
|
|
TR_RPC_TORRENT_REMOVING,
|
2011-02-06 17:30:46 +00:00
|
|
|
TR_RPC_TORRENT_TRASHING, /* _REMOVING + delete local data */
|
2008-10-20 17:54:56 +00:00
|
|
|
TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
|
2009-10-21 14:02:02 +00:00
|
|
|
TR_RPC_TORRENT_MOVED,
|
2011-01-15 18:12:45 +00:00
|
|
|
TR_RPC_SESSION_CHANGED,
|
2011-08-27 23:54:10 +00:00
|
|
|
TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED, /* catch potentially multiple torrents being moved in the queue */
|
2011-01-15 18:12:45 +00:00
|
|
|
TR_RPC_SESSION_CLOSE
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_rpc_callback_status
|
2008-08-14 02:12:29 +00:00
|
|
|
{
|
|
|
|
/* no special handling is needed by the caller */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_RPC_OK = 0,
|
2008-08-14 02:12:29 +00:00
|
|
|
/* indicates to the caller that the client will take care of
|
2010-12-27 19:18:17 +00:00
|
|
|
* removing the torrent itself. For example the client may
|
2008-08-14 02:12:29 +00:00
|
|
|
* need to keep the torrent alive long enough to cleanly close
|
|
|
|
* some resources in another thread. */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_RPC_NOREMOVE = (1 << 1)
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-08-14 02:12:29 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_rpc_func = tr_rpc_callback_status (*)( //
|
2021-08-15 09:41:48 +00:00
|
|
|
tr_session* session,
|
|
|
|
tr_rpc_callback_type type,
|
|
|
|
struct tr_torrent* tor_or_null,
|
2017-04-19 12:04:45 +00:00
|
|
|
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!
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
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
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Used by tr_sessionGetStats() and tr_sessionGetCumulativeStats() */
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_session_stats
|
2007-11-19 17:29:17 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +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 */
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2007-11-19 17:29:17 +00:00
|
|
|
|
2011-03-21 16:26:45 +00:00
|
|
|
/** @brief Get bandwidth use statistics for the current session */
|
2022-07-28 23:56:40 +00:00
|
|
|
tr_session_stats tr_sessionGetStats(tr_session const* session);
|
2007-11-19 17:29:17 +00:00
|
|
|
|
2011-03-21 16:26:45 +00:00
|
|
|
/** @brief Get cumulative bandwidth statistics for current and past sessions */
|
2022-07-28 23:56:40 +00:00
|
|
|
tr_session_stats tr_sessionGetCumulativeStats(tr_session const* session);
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionClearStats(tr_session* session);
|
2008-04-22 14:07:42 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
/**
|
2010-01-19 19:37:00 +00:00
|
|
|
* @brief Set whether or not torrents are allowed to do peer exchanges.
|
|
|
|
*
|
2008-05-22 12:31:47 +00:00
|
|
|
* PEX is always disabled in private torrents regardless of this.
|
|
|
|
* In public torrents, PEX is enabled by default.
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetPexEnabled(tr_session* session, bool isEnabled);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsPexEnabled(tr_session const* session);
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsDHTEnabled(tr_session const* session);
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetDHTEnabled(tr_session* session, bool);
|
2011-02-18 00:33:11 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsUTPEnabled(tr_session const* session);
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetUTPEnabled(tr_session* session, bool);
|
2009-05-19 18:38:26 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsLPDEnabled(tr_session const* session);
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetLPDEnabled(tr_session* session, bool enabled);
|
2009-05-21 00:15:54 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetCacheLimit_MB(tr_session* session, int mb);
|
2017-04-20 16:02:19 +00:00
|
|
|
int tr_sessionGetCacheLimit_MB(tr_session const* session);
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2022-06-15 22:19:24 +00:00
|
|
|
tr_encryption_mode tr_sessionGetEncryption(tr_session const* session);
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetEncryption(tr_session* session, tr_encryption_mode mode);
|
2008-01-15 22:00:58 +00:00
|
|
|
|
2008-05-22 12:31:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
** Incoming Peer Connections Port
|
|
|
|
*/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetPortForwardingEnabled(tr_session* session, bool enabled);
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsPortForwardingEnabled(tr_session const* session);
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2022-04-21 15:58:13 +00:00
|
|
|
void tr_sessionSetPeerPort(tr_session* session, uint16_t port);
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2022-04-21 15:58:13 +00:00
|
|
|
uint16_t tr_sessionGetPeerPort(tr_session const* session);
|
2009-04-03 04:29:27 +00:00
|
|
|
|
2022-04-21 15:58:13 +00:00
|
|
|
uint16_t tr_sessionSetPeerPortRandom(tr_session* session);
|
2008-12-11 04:41:23 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetPeerPortRandomOnStart(tr_session* session, bool random);
|
2009-04-03 04:29:27 +00:00
|
|
|
|
2022-06-15 22:19:24 +00:00
|
|
|
bool tr_sessionGetPeerPortRandomOnStart(tr_session const* session);
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_port_forwarding
|
2008-05-22 12:31:47 +00:00
|
|
|
{
|
|
|
|
TR_PORT_ERROR,
|
|
|
|
TR_PORT_UNMAPPED,
|
|
|
|
TR_PORT_UNMAPPING,
|
|
|
|
TR_PORT_MAPPING,
|
|
|
|
TR_PORT_MAPPED
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_port_forwarding tr_sessionGetPortForwarding(tr_session const* session);
|
2008-05-22 12:31:47 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_direction
|
2008-09-17 19:44:24 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_CLIENT_TO_PEER = 0,
|
|
|
|
TR_UP = 0,
|
|
|
|
TR_PEER_TO_CLIENT = 1,
|
|
|
|
TR_DOWN = 1
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-09-17 19:44:24 +00:00
|
|
|
|
2009-03-25 19:18:00 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
/***
|
2009-03-28 16:47:01 +00:00
|
|
|
**** Primary session speed limits
|
2009-03-25 19:18:00 +00:00
|
|
|
***/
|
|
|
|
|
2022-08-15 17:48:05 +00:00
|
|
|
void tr_sessionSetSpeedLimit_Bps(tr_session*, tr_direction, unsigned int Bps);
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetSpeedLimit_KBps(tr_session*, tr_direction, unsigned int KBps);
|
2017-04-20 16:02:19 +00:00
|
|
|
unsigned int tr_sessionGetSpeedLimit_KBps(tr_session const*, tr_direction);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionLimitSpeed(tr_session*, tr_direction, bool);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsSpeedLimited(tr_session const*, tr_direction);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2009-03-28 16:47:01 +00:00
|
|
|
/***
|
2009-08-12 14:40:32 +00:00
|
|
|
**** Alternative speed limits that are used during scheduled times
|
2009-03-28 16:47:01 +00:00
|
|
|
***/
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetAltSpeed_KBps(tr_session*, tr_direction, unsigned int Bps);
|
2017-04-20 16:02:19 +00:00
|
|
|
unsigned int tr_sessionGetAltSpeed_KBps(tr_session const*, tr_direction);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionUseAltSpeed(tr_session*, bool);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionUsesAltSpeed(tr_session const*);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionUseAltSpeedTime(tr_session*, bool);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionUsesAltSpeedTime(tr_session const*);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetAltSpeedBegin(tr_session*, int minutes_since_midnight);
|
2017-04-20 16:02:19 +00:00
|
|
|
int tr_sessionGetAltSpeedBegin(tr_session const*);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetAltSpeedEnd(tr_session*, int minutes_since_midnight);
|
2017-04-20 16:02:19 +00:00
|
|
|
int tr_sessionGetAltSpeedEnd(tr_session const*);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_sched_day
|
2009-04-04 02:17:39 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_SCHED_SUN = (1 << 0),
|
|
|
|
TR_SCHED_MON = (1 << 1),
|
|
|
|
TR_SCHED_TUES = (1 << 2),
|
|
|
|
TR_SCHED_WED = (1 << 3),
|
|
|
|
TR_SCHED_THURS = (1 << 4),
|
|
|
|
TR_SCHED_FRI = (1 << 5),
|
|
|
|
TR_SCHED_SAT = (1 << 6),
|
|
|
|
TR_SCHED_WEEKDAY = (TR_SCHED_MON | TR_SCHED_TUES | TR_SCHED_WED | TR_SCHED_THURS | TR_SCHED_FRI),
|
|
|
|
TR_SCHED_WEEKEND = (TR_SCHED_SUN | TR_SCHED_SAT),
|
|
|
|
TR_SCHED_ALL = (TR_SCHED_WEEKDAY | TR_SCHED_WEEKEND)
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-04-04 02:17:39 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetAltSpeedDay(tr_session*, tr_sched_day day);
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_sched_day tr_sessionGetAltSpeedDay(tr_session const*);
|
2011-03-21 17:08:10 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_altSpeedFunc = void (*)(tr_session*, bool active, bool userDriven, void*);
|
2009-03-25 19:18:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetAltSpeedFunc(tr_session*, tr_altSpeedFunc, void*);
|
2009-06-30 18:08:50 +00:00
|
|
|
|
2009-03-25 19:18:00 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
double tr_sessionGetRawSpeed_KBps(tr_session const*, tr_direction);
|
2009-02-14 21:15:57 +00:00
|
|
|
|
2022-08-15 17:48:05 +00:00
|
|
|
void tr_sessionSetRatioLimited(tr_session*, bool is_limited);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsRatioLimited(tr_session const*);
|
2008-12-13 22:52:15 +00:00
|
|
|
|
2022-08-15 00:33:28 +00:00
|
|
|
void tr_sessionSetRatioLimit(tr_session*, double desired_ratio);
|
2017-04-20 16:02:19 +00:00
|
|
|
double tr_sessionGetRatioLimit(tr_session const*);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2022-08-15 00:33:28 +00:00
|
|
|
void tr_sessionSetIdleLimited(tr_session*, bool is_limited);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionIsIdleLimited(tr_session const*);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2022-08-15 17:48:05 +00:00
|
|
|
void tr_sessionSetIdleLimit(tr_session*, uint16_t idle_minutes);
|
2017-04-20 16:02:19 +00:00
|
|
|
uint16_t tr_sessionGetIdleLimit(tr_session const*);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetPeerLimit(tr_session*, uint16_t max_global_peers);
|
2017-04-20 16:02:19 +00:00
|
|
|
uint16_t tr_sessionGetPeerLimit(tr_session const*);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetPeerLimitPerTorrent(tr_session*, uint16_t max_peers);
|
2017-04-20 16:02:19 +00:00
|
|
|
uint16_t tr_sessionGetPeerLimitPerTorrent(tr_session const*);
|
2008-12-14 22:57:08 +00:00
|
|
|
|
2022-08-14 01:04:36 +00:00
|
|
|
void tr_sessionSetPaused(tr_session*, bool is_paused);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionGetPaused(tr_session const*);
|
2010-03-17 19:23:03 +00:00
|
|
|
|
2022-08-14 01:04:36 +00:00
|
|
|
void tr_sessionSetDeleteSource(tr_session*, bool delete_source);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionGetDeleteSource(tr_session const*);
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_priority_t tr_torrentGetPriority(tr_torrent const*);
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentSetPriority(tr_torrent*, tr_priority_t);
|
2011-03-21 17:08:10 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetAntiBruteForceThreshold(tr_session*, int max_bad_requests);
|
2020-11-14 18:43:42 +00:00
|
|
|
int tr_sessionGetAntiBruteForceThreshold(tr_session const*);
|
|
|
|
|
|
|
|
void tr_sessionSetAntiBruteForceEnabled(tr_session*, bool enabled);
|
|
|
|
bool tr_sessionGetAntiBruteForceEnabled(tr_session const*);
|
|
|
|
|
|
|
|
/**
|
|
|
|
**/
|
|
|
|
|
2011-08-01 22:24:24 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
**** Torrent Queueing
|
|
|
|
****
|
|
|
|
**** There are independent queues for seeding (TR_UP) and leeching (TR_DOWN).
|
|
|
|
****
|
|
|
|
**** If the session already has enough non-stalled seeds/leeches when
|
2017-04-21 07:40:57 +00:00
|
|
|
**** tr_torrentStart() is called, the torrent will be moved into the
|
2011-08-01 22:24:24 +00:00
|
|
|
**** appropriate queue and its state will be TR_STATUS_{DOWNLOAD,SEED}_WAIT.
|
|
|
|
****
|
|
|
|
**** To bypass the queue and unconditionally start the torrent use
|
2017-04-21 07:40:57 +00:00
|
|
|
**** tr_torrentStartNow().
|
2011-08-01 22:24:24 +00:00
|
|
|
****
|
|
|
|
**** Torrents can be moved in the queue using the simple functions
|
|
|
|
**** tr_torrentQueueMove{Top,Up,Down,Bottom}. They can be moved to
|
2017-04-21 07:40:57 +00:00
|
|
|
**** arbitrary points in the queue with tr_torrentSetQueuePosition().
|
2012-02-03 16:44:07 +00:00
|
|
|
****
|
2011-08-01 22:24:24 +00:00
|
|
|
***/
|
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Like tr_torrentStart(), but resumes right away regardless of the queues. */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentStartNow(tr_torrent*);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/** @brief Return the queued torrent's position in the queue it's in. [0...n) */
|
2017-04-20 16:02:19 +00:00
|
|
|
int tr_torrentGetQueuePosition(tr_torrent const*);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/** @brief Set the queued torrent's position in the queue it's in.
|
|
|
|
* Special cases: pos <= 0 moves to the front; pos >= queue length moves to the back */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentSetQueuePosition(tr_torrent*, int queue_position);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
**/
|
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Convenience function for moving a batch of torrents to the front of their queue(s) */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentsQueueMoveTop(tr_torrent* const* torrents, size_t torrent_count);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Convenience function for moving a batch of torrents ahead one step in their queue(s) */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentsQueueMoveUp(tr_torrent* const* torrents, size_t torrent_count);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Convenience function for moving a batch of torrents back one step in their queue(s) */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentsQueueMoveDown(tr_torrent* const* torrents, size_t torrent_count);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Convenience function for moving a batch of torrents to the back of their queue(s) */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentsQueueMoveBottom(tr_torrent* const* torrents, size_t torrent_count);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
**/
|
|
|
|
|
|
|
|
/** @brief Set the number of torrents allowed to download (if direction is TR_DOWN) or seed (if direction is TR_UP) at the same time */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetQueueSize(tr_session*, tr_direction, int max_simultaneous_seed_torrents);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/** @brief Return the number of torrents allowed to download (if direction is TR_DOWN) or seed (if direction is TR_UP) at the same time */
|
2017-04-20 16:02:19 +00:00
|
|
|
int tr_sessionGetQueueSize(tr_session const*, tr_direction);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/** @brief Set whether or not to limit how many torrents can download (TR_DOWN) or seed (TR_UP) at the same time */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetQueueEnabled(tr_session*, tr_direction, bool do_limit_simultaneous_seed_torrents);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/** @brief Return true if we're limiting how many torrents can concurrently download (TR_DOWN) or seed (TR_UP) at the same time */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionGetQueueEnabled(tr_session const*, tr_direction);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2011-08-07 19:24:33 +00:00
|
|
|
/**
|
|
|
|
**/
|
|
|
|
|
2011-08-01 22:24:24 +00:00
|
|
|
/** @brief Consider torrent as 'stalled' when it's been inactive for N minutes.
|
2017-04-21 07:40:57 +00:00
|
|
|
Stalled torrents are left running but are not counted by tr_sessionGetQueueSize(). */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetQueueStalledMinutes(tr_session*, int minutes);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/** @return the number of minutes a torrent can be idle before being considered as stalled */
|
2017-04-20 16:02:19 +00:00
|
|
|
int tr_sessionGetQueueStalledMinutes(tr_session const*);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2011-08-07 19:24:33 +00:00
|
|
|
/** @brief Set whether or not to count torrents idle for over N minutes as 'stalled' */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_sessionSetQueueStalledEnabled(tr_session*, bool);
|
2011-08-07 19:24:33 +00:00
|
|
|
|
|
|
|
/** @return true if we're torrents idle for over N minutes will be flagged as 'stalled' */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_sessionGetQueueStalledEnabled(tr_session const*);
|
2011-08-07 19:24:33 +00:00
|
|
|
|
2011-08-03 03:14:57 +00:00
|
|
|
/** @brief Set a callback that is invoked when the queue starts a torrent */
|
2022-07-23 06:04:34 +00:00
|
|
|
void tr_sessionSetQueueStartCallback(tr_session*, void (*callback)(tr_session*, tr_torrent*, void*), void* user_data);
|
2011-08-01 22:24:24 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/**
|
2022-08-18 14:14:12 +00:00
|
|
|
* Load all the torrents in the session's torrent folder.
|
|
|
|
* This can be used at startup to kickstart all the torrents
|
|
|
|
* from the previous session.
|
|
|
|
*
|
|
|
|
* @return the number of torrents in the session
|
|
|
|
*/
|
|
|
|
size_t tr_sessionLoadTorrents(tr_session* session, tr_ctor* ctor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get pointers to all the torrents in a session.
|
|
|
|
*
|
|
|
|
* Iff `buflen` is large enough to hold the torrents pointers,
|
|
|
|
* then all of them are copied into `buf`.
|
|
|
|
*
|
|
|
|
* @return the number of torrents in the session
|
2008-05-22 20:44:41 +00:00
|
|
|
*/
|
2022-08-18 14:14:12 +00:00
|
|
|
size_t tr_sessionGetAllTorrents(tr_session* session, tr_torrent** buf, size_t buflen);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2010-05-08 22:42:28 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2021-10-13 03:46:12 +00:00
|
|
|
enum TrScript
|
|
|
|
{
|
|
|
|
TR_SCRIPT_ON_TORRENT_ADDED,
|
|
|
|
TR_SCRIPT_ON_TORRENT_DONE,
|
2022-02-14 04:07:12 +00:00
|
|
|
TR_SCRIPT_ON_TORRENT_DONE_SEEDING,
|
2021-10-12 21:32:32 +00:00
|
|
|
|
2021-10-13 03:46:12 +00:00
|
|
|
TR_SCRIPT_N_TYPES
|
|
|
|
};
|
2021-10-12 21:32:32 +00:00
|
|
|
|
2021-10-13 03:46:12 +00:00
|
|
|
void tr_sessionSetScript(tr_session*, TrScript, char const* script_filename);
|
2010-05-08 22:42:28 +00:00
|
|
|
|
2021-10-13 03:46:12 +00:00
|
|
|
char const* tr_sessionGetScript(tr_session const*, TrScript);
|
2010-05-08 22:42:28 +00:00
|
|
|
|
2021-10-13 03:46:12 +00:00
|
|
|
void tr_sessionSetScriptEnabled(tr_session*, TrScript, bool enabled);
|
2010-05-08 22:42:28 +00:00
|
|
|
|
2021-10-13 03:46:12 +00:00
|
|
|
bool tr_sessionIsScriptEnabled(tr_session const*, TrScript);
|
2010-05-08 22:42:28 +00:00
|
|
|
|
2008-05-22 20:44:41 +00:00
|
|
|
/** @} */
|
2008-05-22 12:31:47 +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.
|
|
|
|
*
|
2010-10-31 17:16:12 +00:00
|
|
|
* Filename must be an uncompressed ascii file.
|
2008-05-22 20:44:41 +00:00
|
|
|
*
|
|
|
|
* 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
|
2010-10-31 17:16:12 +00:00
|
|
|
* massaged into a binary format easier to search.
|
2008-05-22 20:44:41 +00:00
|
|
|
*
|
|
|
|
* The caller only needs to invoke this when the blocklist
|
|
|
|
* has changed.
|
|
|
|
*
|
2021-10-06 16:32:17 +00:00
|
|
|
* Passing nullptr for a filename will clear the blocklist.
|
2008-05-22 20:44:41 +00:00
|
|
|
*/
|
2022-08-15 17:48:05 +00:00
|
|
|
size_t tr_blocklistSetContent(tr_session* session, char const* content_filename);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2022-05-14 05:31:24 +00:00
|
|
|
size_t tr_blocklistGetRuleCount(tr_session const* session);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_blocklistExists(tr_session const* session);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_blocklistIsEnabled(tr_session const* session);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_blocklistSetEnabled(tr_session* session, bool isEnabled);
|
2008-05-22 20:44:41 +00:00
|
|
|
|
2010-10-31 17:16:12 +00:00
|
|
|
/** @brief The blocklist that ges updated when an RPC client
|
|
|
|
invokes the "blocklist-update" method */
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_blocklistSetURL(tr_session*, char const* url);
|
2010-10-31 17:16:12 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_blocklistGetURL(tr_session const*);
|
2010-10-31 17:16:12 +00:00
|
|
|
|
2010-11-01 00:12:30 +00:00
|
|
|
/** @brief the file in the $config/blocklists/ directory that's
|
2017-04-21 07:40:57 +00:00
|
|
|
used by tr_blocklistSetContent() and "blocklist-update" */
|
2010-11-01 00:12:30 +00:00
|
|
|
#define DEFAULT_BLOCKLIST_FILENAME "blocklist.bin"
|
2008-05-22 20:44:41 +00:00
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
2021-12-26 16:25:07 +00:00
|
|
|
/**
|
2022-03-21 14:15:48 +00:00
|
|
|
* Instantiating tr_torrents and wrangling torrent file metadata
|
2021-12-26 16:25:07 +00:00
|
|
|
*
|
|
|
|
* 1. Torrent metadata is handled in the tr_torrent_metadata class.
|
|
|
|
*
|
|
|
|
* 2. Torrents should be instantiated using a torrent builder (tr_ctor).
|
|
|
|
* Calling one of the tr_ctorSetMetainfo*() functions is required.
|
|
|
|
* Other settings, e.g. torrent priority, are optional.
|
|
|
|
* When ready, pass the builder object to tr_torrentNew().
|
2008-05-23 20:04:41 +00:00
|
|
|
*/
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_ctorMode
|
2008-05-23 20:04:41 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
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 */
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2011-03-21 17:08:10 +00:00
|
|
|
/** @brief Create a torrent constructor object used to instantiate a tr_torrent
|
2021-12-26 16:25:07 +00:00
|
|
|
@param session the tr_session. */
|
|
|
|
tr_ctor* tr_ctorNew(tr_session const* session);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Free a torrent constructor object */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_ctorFree(tr_ctor* ctor);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
/** @brief Set whether or not to delete the source torrent file
|
2011-03-21 17:08:10 +00:00
|
|
|
when the torrent is added. (Default: False) */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_ctorSetDeleteSource(tr_ctor* ctor, bool delete_source);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2010-02-02 22:45:22 +00:00
|
|
|
/** @brief Set the constructor's metainfo from a magnet link */
|
2021-12-26 16:25:07 +00:00
|
|
|
bool tr_ctorSetMetainfoFromMagnetLink(tr_ctor* ctor, char const* magnet, tr_error** error);
|
2009-11-24 02:16:31 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Set the constructor's metainfo from a raw benc already in memory */
|
2021-12-26 16:25:07 +00:00
|
|
|
bool tr_ctorSetMetainfo(tr_ctor* ctor, char const* metainfo, size_t len, tr_error** error);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
/** @brief Set the constructor's metainfo from a local torrent file */
|
2021-12-26 16:25:07 +00:00
|
|
|
bool tr_ctorSetMetainfoFromFile(tr_ctor* ctor, char const* filename, tr_error** error);
|
|
|
|
|
|
|
|
tr_torrent_metainfo const* tr_ctorGetMetainfo(tr_ctor const* ctor);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2011-03-21 17:08:10 +00:00
|
|
|
/** @brief Set how many peers this torrent can connect to. (Default: 50) */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_ctorSetPeerLimit(tr_ctor* ctor, tr_ctorMode mode, uint16_t limit);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Set the download folder for the torrent being added with this ctor.
|
2017-04-21 07:40:57 +00:00
|
|
|
@see tr_ctorSetDownloadDir()
|
|
|
|
@see tr_sessionInit() */
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_ctorSetDownloadDir(tr_ctor* ctor, tr_ctorMode mode, char const* directory);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2009-10-21 05:03:10 +00:00
|
|
|
/**
|
|
|
|
* @brief Set the incompleteDir for this torrent.
|
|
|
|
*
|
|
|
|
* This is not a supported API call.
|
|
|
|
* It only exists so the mac client can migrate
|
|
|
|
* its older incompleteDir settings, and that's
|
|
|
|
* the only place where it should be used.
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_ctorSetIncompleteDir(tr_ctor* ctor, char const* directory);
|
2010-01-05 23:47:50 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
/** Set whether or not the torrent begins downloading/seeding when created.
|
2012-12-05 17:29:46 +00:00
|
|
|
(Default: not paused) */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_ctorSetPaused(tr_ctor* ctor, tr_ctorMode mode, bool isPaused);
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Set the priorities for files in a torrent */
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_ctorSetFilePriorities(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t fileCount, tr_priority_t priority);
|
2009-04-02 20:43:42 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Set the download flag for files in a torrent */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_ctorSetFilesWanted(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t fileCount, bool wanted);
|
2009-04-02 20:43:42 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Get this peer constructor's peer limit */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_ctorGetPeerLimit(tr_ctor const* ctor, tr_ctorMode mode, uint16_t* setmeCount);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Get the "isPaused" flag from this peer constructor */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_ctorGetPaused(tr_ctor const* ctor, tr_ctorMode mode, bool* setmeIsPaused);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2010-01-01 22:13:27 +00:00
|
|
|
/** @brief Get the download path from this peer constructor */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_ctorGetDownloadDir(tr_ctor const* ctor, tr_ctorMode mode, char const** setmeDownloadDir);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
/** @brief Get the "delete torrent file" flag from this peer constructor */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_ctorGetDeleteSource(tr_ctor const* ctor, bool* setmeDoDelete);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
/** @brief Get the torrent file that this ctor's metainfo came from,
|
2021-10-06 16:32:17 +00:00
|
|
|
or nullptr if tr_ctorSetMetainfoFromFile() wasn't used */
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_ctorGetSourceFile(tr_ctor const* ctor);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2021-12-26 16:25:07 +00:00
|
|
|
// TODO(ckerr) remove
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_parse_result
|
2009-08-05 01:59:16 +00:00
|
|
|
{
|
|
|
|
TR_PARSE_OK,
|
|
|
|
TR_PARSE_ERR,
|
|
|
|
TR_PARSE_DUPLICATE
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2013-05-22 20:35:38 +00:00
|
|
|
/**
|
|
|
|
* Instantiate a single torrent.
|
|
|
|
*
|
2021-10-06 16:32:17 +00:00
|
|
|
* Returns a pointer to the torrent on success, or nullptr on failure.
|
2013-05-22 20:35:38 +00:00
|
|
|
*
|
2016-03-29 03:04:54 +00:00
|
|
|
* @param ctor the builder struct
|
2021-12-24 22:05:17 +00:00
|
|
|
* @param setme_duplicate_of If the torrent couldn't be created because it's a duplicate,
|
|
|
|
* this is set to point to the original torrent.
|
2013-05-22 20:35:38 +00:00
|
|
|
*/
|
2022-01-15 19:33:57 +00:00
|
|
|
tr_torrent* tr_torrentNew(tr_ctor* ctor, tr_torrent** setme_duplicate_of);
|
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
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_fileFunc = bool (*)(char const* filename, struct tr_error** error);
|
2010-12-16 03:38:07 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
/** @brief Removes our torrent and .resume files for this torrent */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentRemove(tr_torrent* torrent, bool delete_flag, tr_fileFunc delete_func);
|
2008-05-30 15:19:07 +00:00
|
|
|
|
|
|
|
/** @brief Start a torrent */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentStart(tr_torrent* torrent);
|
2008-05-30 15:19:07 +00:00
|
|
|
|
|
|
|
/** @brief Stop (pause) a torrent */
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentStop(tr_torrent* torrent);
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_torrent_rename_done_func = void (*)( //
|
2021-08-15 09:41:48 +00:00
|
|
|
tr_torrent* torrent,
|
|
|
|
char const* oldpath,
|
|
|
|
char const* newname,
|
|
|
|
int error,
|
2017-04-19 12:04:45 +00:00
|
|
|
void* user_data);
|
2013-01-19 08:43:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Rename a file or directory in a torrent.
|
|
|
|
*
|
2016-03-29 03:04:54 +00:00
|
|
|
* @param tor the torrent whose path will be renamed
|
|
|
|
* @param oldpath the path to the file or folder that will be renamed
|
|
|
|
* @param newname the file or folder's new name
|
2021-10-06 16:32:17 +00:00
|
|
|
* @param callback the callback invoked when the renaming finishes, or nullptr
|
2016-03-29 03:04:54 +00:00
|
|
|
* @param callback_data the pointer to pass in the callback's user_data arg
|
2013-01-19 08:43:26 +00:00
|
|
|
*
|
2013-01-23 03:44:47 +00:00
|
|
|
* As a special case, renaming the root file in a torrent will also
|
2021-12-14 21:59:44 +00:00
|
|
|
* update tr_torrentName().
|
2013-01-22 00:25:42 +00:00
|
|
|
*
|
2013-01-19 08:43:26 +00:00
|
|
|
* EXAMPLES
|
|
|
|
*
|
2013-01-19 08:50:57 +00:00
|
|
|
* Consider a tr_torrent where its
|
2021-12-07 04:18:17 +00:00
|
|
|
* tr_torrentFile(tor, 0).name is "frobnitz-linux/checksum" and
|
|
|
|
* tr_torrentFile(tor, 1).name is "frobnitz-linux/frobnitz.iso".
|
2013-01-19 08:43:26 +00:00
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* 1. tr_torrentRenamePath(tor, "frobnitz-linux", "foo") will rename
|
2021-12-07 04:18:17 +00:00
|
|
|
* the "frotbnitz-linux" folder as "foo", and update both
|
|
|
|
* tr_torrentName(tor) and tr_torrentFile(tor, *).name.
|
2013-01-19 08:43:26 +00:00
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* 2. tr_torrentRenamePath(tor, "frobnitz-linux/checksum", "foo") will
|
2013-01-19 08:43:26 +00:00
|
|
|
* rename the "frobnitz-linux/checksum" file as "foo" and update
|
2013-01-19 08:50:57 +00:00
|
|
|
* files[0].name to "frobnitz-linux/foo".
|
2013-01-19 08:43:26 +00:00
|
|
|
*
|
|
|
|
* RETURN
|
|
|
|
*
|
2021-12-14 21:59:44 +00:00
|
|
|
* Changing the torrent's internal fields requires a session thread lock,
|
|
|
|
* so this function returns asynchronously to avoid blocking. If you don't
|
|
|
|
* want to be notified when the function has finished, you can pass nullptr
|
|
|
|
* as the callback arg.
|
2013-01-19 08:43:26 +00:00
|
|
|
*
|
|
|
|
* On success, the callback's error argument will be 0.
|
|
|
|
*
|
2013-01-19 08:50:57 +00:00
|
|
|
* If oldpath can't be found in files[*].name, or if newname is already
|
2021-10-06 16:32:17 +00:00
|
|
|
* in files[*].name, or contains a directory separator, or is nullptr, "",
|
2013-01-19 08:43:26 +00:00
|
|
|
* ".", or "..", the error argument will be EINVAL.
|
|
|
|
*
|
|
|
|
* If the path exists on disk but can't be renamed, the error argument
|
|
|
|
* will be the errno set by rename().
|
|
|
|
*/
|
2021-08-15 09:41:48 +00:00
|
|
|
void tr_torrentRenamePath(
|
|
|
|
tr_torrent* tor,
|
|
|
|
char const* oldpath,
|
|
|
|
char const* newname,
|
|
|
|
tr_torrent_rename_done_func callback,
|
2022-08-03 06:15:37 +00:00
|
|
|
void* callback_user_data);
|
2013-01-19 08:43:26 +00:00
|
|
|
|
2009-05-20 16:02:12 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TR_LOC_MOVING,
|
|
|
|
TR_LOC_DONE,
|
|
|
|
TR_LOC_ERROR
|
|
|
|
};
|
|
|
|
|
2010-03-06 22:33:45 +00:00
|
|
|
/**
|
2022-04-21 14:28:38 +00:00
|
|
|
* @brief Tell transmission where to find this torrent's local data.
|
2010-03-17 17:07:40 +00:00
|
|
|
*
|
2010-03-06 22:33:45 +00:00
|
|
|
* if move_from_previous_location is `true', the torrent's incompleteDir
|
2022-04-21 14:28:38 +00:00
|
|
|
* will be clobbered s.t. additional files being added will be saved
|
2010-03-06 22:33:45 +00:00
|
|
|
* to the torrent's downloadDir.
|
|
|
|
*/
|
2021-08-15 09:41:48 +00:00
|
|
|
void tr_torrentSetLocation(
|
|
|
|
tr_torrent* torrent,
|
|
|
|
char const* location,
|
2022-08-03 06:15:37 +00:00
|
|
|
bool move_from_old_path,
|
2021-08-15 09:41:48 +00:00
|
|
|
double volatile* setme_progress,
|
|
|
|
int volatile* setme_state);
|
2009-05-13 15:54:04 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
uint64_t tr_torrentGetBytesLeftToAllocate(tr_torrent const* torrent);
|
2008-11-05 05:56:06 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/**
|
|
|
|
* @brief Returns this torrent's unique ID.
|
|
|
|
*
|
2021-12-14 21:59:44 +00:00
|
|
|
* IDs are fast lookup keys, but are not persistent between sessions.
|
|
|
|
* If you need that, use tr_torrentView().hash_string.
|
2008-05-30 15:19:07 +00:00
|
|
|
*/
|
2022-06-17 15:43:04 +00:00
|
|
|
tr_torrent_id_t tr_torrentId(tr_torrent const* torrent);
|
2008-05-23 20:04:41 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_torrent* tr_torrentFindFromId(tr_session* session, int id);
|
2009-04-24 01:37:04 +00:00
|
|
|
|
2021-12-26 03:12:32 +00:00
|
|
|
tr_torrent* tr_torrentFindFromMetainfo(tr_session*, tr_torrent_metainfo const*);
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_torrent* tr_torrentFindFromMagnetLink(tr_session* session, char const* link);
|
2009-11-13 16:41:00 +00:00
|
|
|
|
2022-06-21 21:47:57 +00:00
|
|
|
/**
|
|
|
|
* @brief Set metainfo if possible.
|
|
|
|
* @return True if given metainfo was set.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool tr_torrentSetMetainfoFromFile(tr_torrent* torrent, tr_torrent_metainfo* metainfo, char const* filename);
|
|
|
|
|
2011-02-15 15:18:51 +00:00
|
|
|
/**
|
|
|
|
* @return this torrent's name.
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_torrentName(tr_torrent const*);
|
2009-04-24 01:37:04 +00:00
|
|
|
|
2021-12-14 21:59:44 +00:00
|
|
|
uint64_t tr_torrentTotalSize(tr_torrent const*);
|
|
|
|
|
2009-10-19 13:55:42 +00:00
|
|
|
/**
|
|
|
|
* @brief find the location of a torrent's file by looking with and without
|
|
|
|
* the ".part" suffix, looking in downloadDir and incompleteDir, etc.
|
2022-08-17 00:28:57 +00:00
|
|
|
* @return the path of this file, or an empty string if no file exists yet.
|
2009-10-19 13:55:42 +00:00
|
|
|
* @param tor the torrent whose file we're looking for
|
2021-12-06 21:26:04 +00:00
|
|
|
* @param fileNum the fileIndex, in [0...tr_torrentFileCount())
|
2009-10-19 13:55:42 +00:00
|
|
|
*/
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
[[nodiscard]] std::string tr_torrentFindFile(tr_torrent const* tor, tr_file_index_t file_num);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @brief buffer variant of tr_torrentFindFile(). See tr_strvToBuf(). */
|
|
|
|
size_t tr_torrentFindFileToBuf(tr_torrent const* tor, tr_file_index_t file_num, char* buf, size_t buflen);
|
2009-10-19 13:55:42 +00:00
|
|
|
|
2009-03-28 16:47:01 +00:00
|
|
|
/***
|
|
|
|
**** Torrent speed limits
|
|
|
|
****
|
|
|
|
***/
|
2009-03-04 19:52:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentSetSpeedLimit_KBps(tr_torrent*, tr_direction, unsigned int KBps);
|
2017-04-20 16:02:19 +00:00
|
|
|
unsigned int tr_torrentGetSpeedLimit_KBps(tr_torrent const*, tr_direction);
|
2009-03-04 19:52:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentUseSpeedLimit(tr_torrent*, tr_direction, bool);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_torrentUsesSpeedLimit(tr_torrent const*, tr_direction);
|
2009-03-04 19:52:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentUseSessionLimits(tr_torrent*, bool);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_torrentUsesSessionLimits(tr_torrent const*);
|
2009-03-04 19:52:57 +00:00
|
|
|
|
|
|
|
/****
|
|
|
|
***** Ratio Limits
|
|
|
|
****/
|
2007-07-20 03:24:04 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_ratiolimit
|
2009-02-13 18:23:56 +00:00
|
|
|
{
|
2011-03-21 17:08:10 +00:00
|
|
|
/* follow the global settings */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_RATIOLIMIT_GLOBAL = 0,
|
2011-03-21 17:08:10 +00:00
|
|
|
/* override the global settings, seeding until a certain ratio */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_RATIOLIMIT_SINGLE = 1,
|
2011-03-21 17:08:10 +00:00
|
|
|
/* override the global settings, seeding regardless of ratio */
|
|
|
|
TR_RATIOLIMIT_UNLIMITED = 2
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-02-13 18:23:56 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentSetRatioMode(tr_torrent* tor, tr_ratiolimit mode);
|
2009-02-13 18:23:56 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_ratiolimit tr_torrentGetRatioMode(tr_torrent const* tor);
|
2009-02-13 18:23:56 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentSetRatioLimit(tr_torrent* tor, double ratio);
|
2009-02-13 18:23:56 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
double tr_torrentGetRatioLimit(tr_torrent const* tor);
|
2009-03-28 16:47:01 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_torrentGetSeedRatio(tr_torrent const*, double* ratio);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
|
|
|
/****
|
2010-07-24 02:57:39 +00:00
|
|
|
***** Idle Time Limits
|
2010-07-16 03:12:57 +00:00
|
|
|
****/
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_idlelimit
|
2010-07-16 03:12:57 +00:00
|
|
|
{
|
2011-03-21 17:08:10 +00:00
|
|
|
/* follow the global settings */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_IDLELIMIT_GLOBAL = 0,
|
2011-03-21 17:08:10 +00:00
|
|
|
/* override the global settings, seeding until a certain idle time */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_IDLELIMIT_SINGLE = 1,
|
2011-03-21 17:08:10 +00:00
|
|
|
/* override the global settings, seeding regardless of activity */
|
|
|
|
TR_IDLELIMIT_UNLIMITED = 2
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentSetIdleMode(tr_torrent* tor, tr_idlelimit mode);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_idlelimit tr_torrentGetIdleMode(tr_torrent const* tor);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentSetIdleLimit(tr_torrent* tor, uint16_t idleMinutes);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
uint16_t tr_torrentGetIdleLimit(tr_torrent const* tor);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_torrentGetSeedIdle(tr_torrent const*, uint16_t* minutes);
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/****
|
|
|
|
***** Peer Limits
|
|
|
|
****/
|
2007-12-20 21:44:16 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentSetPeerLimit(tr_torrent* tor, uint16_t max_connected_peers);
|
2007-12-22 04:00:19 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
uint16_t tr_torrentGetPeerLimit(tr_torrent const* 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
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_PRI_LOW = -1,
|
2021-10-16 14:04:19 +00:00
|
|
|
TR_PRI_NORMAL = 0, /* since Normal is 0, memset initializes nicely */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_PRI_HIGH = 1
|
2009-05-29 19:17:12 +00:00
|
|
|
};
|
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 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
|
|
|
*/
|
2021-08-15 09:41:48 +00:00
|
|
|
void tr_torrentSetFilePriorities(
|
|
|
|
tr_torrent* torrent,
|
|
|
|
tr_file_index_t const* files,
|
|
|
|
tr_file_index_t fileCount,
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_priority_t priority);
|
2007-07-13 00:27:47 +00:00
|
|
|
|
2008-05-30 15:19:07 +00:00
|
|
|
/** @brief Set a batch of files to be downloaded or not. */
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentSetFileDLs(tr_torrent* torrent, tr_file_index_t const* files, tr_file_index_t n_files, bool wanted);
|
2007-07-10 03:12:46 +00:00
|
|
|
|
2009-05-13 15:54:04 +00:00
|
|
|
/* Raw function to change the torrent's downloadDir field.
|
|
|
|
This should only be used by libtransmission or to bootstrap
|
|
|
|
a newly-instantiated tr_torrent object. */
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_torrentSetDownloadDir(tr_torrent* torrent, char const* path);
|
2007-12-24 05:03:40 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_torrentGetDownloadDir(tr_torrent const* torrent);
|
2007-05-11 18:56:59 +00:00
|
|
|
|
2009-10-21 05:03:10 +00:00
|
|
|
/**
|
2009-11-30 01:31:05 +00:00
|
|
|
* Returns the root directory of where the torrent is.
|
2009-10-21 05:03:10 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +00:00
|
|
|
* This will usually be the downloadDir. However if the torrent
|
2009-10-21 05:03:10 +00:00
|
|
|
* has an incompleteDir enabled and hasn't finished downloading
|
|
|
|
* yet, that will be returned instead.
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_torrentGetCurrentDir(tr_torrent const* tor);
|
2009-11-29 08:27:55 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-17 00:28:57 +00:00
|
|
|
* Returns a the magnet link to the torrent.
|
2009-11-29 08:27:55 +00:00
|
|
|
*/
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
[[nodiscard]] std::string tr_torrentGetMagnetLink(tr_torrent const* tor);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @brief buffer variant of tr_torrentGetMagnetLink(). See tr_strvToBuf(). */
|
|
|
|
size_t tr_torrentGetMagnetLinkToBuf(tr_torrent const* tor, char* buf, size_t buflen);
|
2009-11-29 08:27:55 +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
|
|
|
/**
|
2022-08-17 00:28:57 +00:00
|
|
|
* Returns a string listing its tracker's announce URLs.
|
2022-02-20 19:33:53 +00:00
|
|
|
* One URL per line, with a blank line between tiers.
|
|
|
|
*
|
|
|
|
* NOTE: this only includes the trackers included in the torrent and,
|
|
|
|
* along with tr_torrentSetTrackerList(), is intended for import/export
|
|
|
|
* and user editing. It does *not* include the "default trackers" that
|
|
|
|
* are applied to all public torrents. If you want a full display of all
|
2022-02-21 03:25:49 +00:00
|
|
|
* trackers, use tr_torrentTracker() and tr_torrentTrackerCount()
|
2022-02-18 17:52:01 +00:00
|
|
|
*/
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
[[nodiscard]] std::string tr_torrentGetTrackerList(tr_torrent const* tor);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @brief buffer variant of tr_torrentGetTrackerList(). See tr_strvToBuf(). */
|
|
|
|
size_t tr_torrentGetTrackerListToBuf(tr_torrent const* tor, char* buf, size_t buflen);
|
2022-02-18 17:52:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a torrent's tracker list from a list of announce URLs with one
|
|
|
|
* URL per line and a blank line between tiers.
|
2008-06-01 01:40:32 +00:00
|
|
|
*
|
2008-06-01 01:55:05 +00:00
|
|
|
* This updates both the `torrent' object's tracker list
|
2022-07-22 05:52:48 +00:00
|
|
|
* and the metainfo file in tr_sessionGetConfigDir()'s torrent subdirectory.
|
2008-06-01 01:40:32 +00:00
|
|
|
*/
|
2022-02-18 17:52:01 +00:00
|
|
|
bool tr_torrentSetTrackerList(tr_torrent* tor, char const* text);
|
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
|
|
|
**/
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_completeness
|
2007-09-28 14:51:34 +00:00
|
|
|
{
|
2017-04-19 12:04: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 */
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2007-09-28 14:51:34 +00:00
|
|
|
|
2022-05-16 18:48:43 +00:00
|
|
|
/**
|
|
|
|
* @param wasRunning whether or not the torrent was running when
|
|
|
|
* it changed its completeness state
|
|
|
|
*/
|
|
|
|
using tr_torrent_completeness_func = void (*)( //
|
|
|
|
tr_torrent* torrent,
|
|
|
|
tr_completeness completeness,
|
|
|
|
bool wasRunning,
|
|
|
|
void* user_data);
|
|
|
|
|
2022-07-23 06:04:34 +00:00
|
|
|
using tr_session_ratio_limit_hit_func = void (*)(tr_session*, tr_torrent* torrent, void* user_data);
|
2022-05-16 18:48:43 +00:00
|
|
|
|
2022-07-23 06:04:34 +00:00
|
|
|
using tr_session_idle_limit_hit_func = void (*)(tr_session*, tr_torrent* torrent, void* user_data);
|
2022-05-16 18:48:43 +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"
|
2010-12-27 19:18:17 +00:00
|
|
|
* 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
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetCompletenessCallback(tr_session* session, tr_torrent_completeness_func callback, void* user_data);
|
2009-11-26 17:58:44 +00:00
|
|
|
|
2022-07-23 06:04:34 +00:00
|
|
|
using tr_session_metadata_func = void (*)(tr_session* session, tr_torrent* torrent, void* user_data);
|
2021-10-06 14:26:07 +00:00
|
|
|
|
2009-11-26 17:58:44 +00:00
|
|
|
/**
|
|
|
|
* Register to be notified whenever a torrent changes from
|
|
|
|
* having incomplete metadata to having complete metadata.
|
|
|
|
* This happens when a magnet link finishes downloading
|
|
|
|
* metadata from its peers.
|
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetMetadataCallback(tr_session* session, tr_session_metadata_func callback, void* user_data);
|
2009-11-26 17:58:44 +00:00
|
|
|
|
2009-02-13 18:23:56 +00:00
|
|
|
/**
|
|
|
|
* Register to be notified whenever a torrent's ratio limit
|
|
|
|
* has been hit. This will be called when the torrent's
|
|
|
|
* ul/dl ratio has met or exceeded the designated ratio limit.
|
|
|
|
*
|
2022-07-23 06:04:34 +00:00
|
|
|
* Has the same restrictions as tr_sessionSetCompletenessCallback
|
2009-02-13 18:23:56 +00:00
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetRatioLimitHitCallback(tr_session* session, tr_session_ratio_limit_hit_func callback, void* user_data);
|
2009-02-13 18:23:56 +00:00
|
|
|
|
2010-07-16 03:12:57 +00:00
|
|
|
/**
|
2010-07-24 03:19:41 +00:00
|
|
|
* Register to be notified whenever a torrent's idle limit
|
2010-07-16 03:12:57 +00:00
|
|
|
* has been hit. This will be called when the seeding torrent's
|
2010-07-24 03:19:41 +00:00
|
|
|
* idle time has met or exceeded the designated idle limit.
|
2010-07-16 03:12:57 +00:00
|
|
|
*
|
2022-07-23 06:04:34 +00:00
|
|
|
* Has the same restrictions as tr_sessionSetCompletenessCallback
|
2010-07-16 03:12:57 +00:00
|
|
|
*/
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_sessionSetIdleLimitHitCallback(tr_session* session, tr_session_idle_limit_hit_func callback, void* user_data);
|
2010-07-16 03:12:57 +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
|
2017-04-21 07:40:57 +00:00
|
|
|
* interval by calling tr_torrentManualUpdate().
|
2007-07-30 17:11:00 +00:00
|
|
|
*
|
2017-04-21 07:40:57 +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
|
2017-04-21 07:40:57 +00:00
|
|
|
* tr_torrentCanManualUpdate().
|
2007-07-30 17:11:00 +00:00
|
|
|
*/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentManualUpdate(tr_torrent* torrent);
|
2006-12-26 18:40:51 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_torrentCanManualUpdate(tr_torrent const* torrent);
|
2007-07-30 17:11:00 +00:00
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
/***
|
|
|
|
**** tr_peer_stat
|
|
|
|
***/
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_peer_stat
|
2008-05-30 15:19:07 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
bool isUTP;
|
|
|
|
|
|
|
|
bool isEncrypted;
|
|
|
|
bool isDownloadingFrom;
|
|
|
|
bool isUploadingTo;
|
|
|
|
bool isSeed;
|
|
|
|
|
|
|
|
bool peerIsChoked;
|
|
|
|
bool peerIsInterested;
|
|
|
|
bool clientIsChoked;
|
|
|
|
bool clientIsInterested;
|
|
|
|
bool isIncoming;
|
|
|
|
|
|
|
|
uint8_t from;
|
2022-04-21 15:58:13 +00:00
|
|
|
uint16_t port;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
char addr[TR_INET6_ADDRSTRLEN];
|
|
|
|
char flagStr[32];
|
2021-12-23 17:16:05 +00:00
|
|
|
char const* client;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
float progress;
|
|
|
|
double rateToPeer_KBps;
|
|
|
|
double rateToClient_KBps;
|
|
|
|
|
|
|
|
/***
|
|
|
|
**** THESE NEXT FOUR FIELDS ARE EXPERIMENTAL.
|
|
|
|
**** Don't rely on them; they'll probably go away
|
|
|
|
***/
|
2010-03-08 04:29:58 +00:00
|
|
|
/* how many blocks we've sent to this peer in the last 120 seconds */
|
2017-04-19 12:04:45 +00:00
|
|
|
uint32_t blocksToPeer;
|
2010-03-08 04:29:58 +00:00
|
|
|
/* how many blocks this client's sent to us in the last 120 seconds */
|
2017-04-19 12:04:45 +00:00
|
|
|
uint32_t blocksToClient;
|
2010-03-08 04:29:58 +00:00
|
|
|
/* how many requests to this peer that we've cancelled in the last 120 seconds */
|
2017-04-19 12:04:45 +00:00
|
|
|
uint32_t cancelsToPeer;
|
2010-03-08 04:29:58 +00:00
|
|
|
/* how many requests this peer made of us, then cancelled, in the last 120 seconds */
|
2017-04-19 12:04:45 +00:00
|
|
|
uint32_t cancelsToClient;
|
2010-03-08 04:29:58 +00:00
|
|
|
|
2009-12-16 18:20:01 +00:00
|
|
|
/* how many requests the peer has made that we haven't responded to yet */
|
2022-06-29 01:48:39 +00:00
|
|
|
int activeReqsToClient;
|
2009-12-16 18:20:01 +00:00
|
|
|
|
|
|
|
/* how many requests we've made and are currently awaiting a response for */
|
2022-06-29 01:48:39 +00:00
|
|
|
int activeReqsToPeer;
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, int* peerCount);
|
2008-05-30 15:19:07 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_torrentPeersFree(tr_peer_stat* peerStats, int peerCount);
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
/***
|
|
|
|
**** tr_tracker_stat
|
|
|
|
***/
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_tracker_state
|
2009-10-09 21:30:34 +00:00
|
|
|
{
|
|
|
|
/* we won't (announce,scrape) this torrent to this tracker because
|
|
|
|
* the torrent is stopped, or because of an error, or whatever */
|
2010-09-01 20:54:04 +00:00
|
|
|
TR_TRACKER_INACTIVE = 0,
|
2009-10-09 21:30:34 +00:00
|
|
|
/* we will (announce,scrape) this torrent to this tracker, and are
|
|
|
|
* waiting for enough time to pass to satisfy the tracker's interval */
|
2010-09-01 20:54:04 +00:00
|
|
|
TR_TRACKER_WAITING = 1,
|
2009-10-09 21:30:34 +00:00
|
|
|
/* it's time to (announce,scrape) this torrent, and we're waiting on a
|
2022-04-21 14:28:38 +00:00
|
|
|
* free slot to open up in the announce manager */
|
2010-09-01 20:54:04 +00:00
|
|
|
TR_TRACKER_QUEUED = 2,
|
2009-10-09 21:30:34 +00:00
|
|
|
/* we're (announcing,scraping) this torrent right now */
|
2010-09-01 20:54:04 +00:00
|
|
|
TR_TRACKER_ACTIVE = 3
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-10-09 21:30:34 +00:00
|
|
|
|
2021-12-08 16:55:52 +00:00
|
|
|
/*
|
|
|
|
* Unlike other _view structs, it is safe to keep a tr_tracker_view copy.
|
|
|
|
* The announce, scrape, and host strings are interned & never go out-of-scope.
|
|
|
|
*/
|
|
|
|
struct tr_tracker_view
|
2009-09-25 21:05:59 +00:00
|
|
|
{
|
2021-12-08 16:55:52 +00:00
|
|
|
char const* announce; // full announce URL
|
|
|
|
char const* scrape; // full scrape URL
|
2022-02-12 17:30:27 +00:00
|
|
|
char const* host; // uniquely-identifying tracker name (`${host}:${port}`)
|
|
|
|
|
|
|
|
// The tracker site's name. Uses the first label before the public suffix
|
|
|
|
// (https://publicsuffix.org/) in the announce URL's host.
|
|
|
|
// e.g. "https://www.example.co.uk/announce/"'s sitename is "example"
|
|
|
|
// RFC 1034 says labels must be less than 64 chars
|
|
|
|
char sitename[64];
|
2021-12-08 16:55:52 +00:00
|
|
|
|
|
|
|
char lastAnnounceResult[128]; // if hasAnnounced, the human-readable result of latest announce
|
|
|
|
char lastScrapeResult[128]; // if hasScraped, the human-readable result of the latest scrape
|
|
|
|
|
|
|
|
time_t lastAnnounceStartTime; // if hasAnnounced, when the latest announce request was sent
|
|
|
|
time_t lastAnnounceTime; // if hasAnnounced, when the latest announce reply was received
|
|
|
|
time_t nextAnnounceTime; // if announceState == TR_TRACKER_WAITING, time of next announce
|
|
|
|
|
|
|
|
time_t lastScrapeStartTime; // if hasScraped, when the latest scrape request was sent
|
|
|
|
time_t lastScrapeTime; // if hasScraped, when the latest scrape reply was received
|
|
|
|
time_t nextScrapeTime; // if scrapeState == TR_TRACKER_WAITING, time of next scrape
|
|
|
|
|
|
|
|
int downloadCount; // number of times this torrent's been downloaded, or -1 if unknown
|
|
|
|
int lastAnnouncePeerCount; // if hasAnnounced, the number of peers the tracker gave us
|
|
|
|
int leecherCount; // number of leechers the tracker knows of, or -1 if unknown
|
2022-05-14 05:31:24 +00:00
|
|
|
int seederCount; // number of seeders the tracker knows of, or -1 if unknown
|
2021-12-08 16:55:52 +00:00
|
|
|
|
|
|
|
int tier; // which tier this tracker is in
|
2022-06-17 15:43:04 +00:00
|
|
|
tr_torrent_id_t id; // unique transmission-generated ID for use in libtransmission API
|
2021-12-08 16:55:52 +00:00
|
|
|
|
|
|
|
tr_tracker_state announceState; // whether we're announcing, waiting to announce, etc.
|
|
|
|
tr_tracker_state scrapeState; // whether we're scraping, waiting to scrape, etc.
|
|
|
|
|
|
|
|
bool hasAnnounced; // true iff we've announced to this tracker during this session
|
|
|
|
bool hasScraped; // true iff we've scraped this tracker during this session
|
|
|
|
bool isBackup; // only one tracker per tier is used; the others are kept as backups
|
|
|
|
bool lastAnnounceSucceeded; // if hasAnnounced, whether or not the latest announce succeeded
|
|
|
|
bool lastAnnounceTimedOut; // true iff the latest announce request timed out
|
|
|
|
bool lastScrapeSucceeded; // if hasScraped, whether or not the latest scrape succeeded
|
|
|
|
bool lastScrapeTimedOut; // true iff the latest scrape request timed out
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2021-12-08 16:55:52 +00:00
|
|
|
struct tr_tracker_view tr_torrentTracker(tr_torrent const* torrent, size_t i);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2022-02-20 19:33:53 +00:00
|
|
|
/**
|
|
|
|
* Count all the trackers (both active and backup) this torrent is using.
|
|
|
|
*
|
|
|
|
* NOTE: this is for a status display only and may include trackers from
|
|
|
|
* the default tracker list if this is a public torrent. If you want a
|
|
|
|
* list of trackers the user can edit, see tr_torrentGetTrackerList().
|
|
|
|
*/
|
2021-12-08 16:55:52 +00:00
|
|
|
size_t tr_torrentTrackerCount(tr_torrent const* torrent);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2021-12-07 04:18:17 +00:00
|
|
|
/*
|
|
|
|
* This view structure is intended for short-term use. Its pointers are owned
|
|
|
|
* by the torrent and may be invalidated if the torrent is edited or removed.
|
|
|
|
*/
|
2021-11-28 03:17:47 +00:00
|
|
|
struct tr_file_view
|
2008-05-29 03:24:26 +00:00
|
|
|
{
|
2021-12-07 04:18:17 +00:00
|
|
|
char const* name; // This file's name. Includes the full subpath in the torrent.
|
|
|
|
uint64_t have; // the current size of the file, i.e. how much we've downloaded
|
|
|
|
uint64_t length; // the total size of the file
|
|
|
|
double progress; // have / length
|
|
|
|
tr_priority_t priority; // the file's priority
|
|
|
|
bool wanted; // do we want to download this file?
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2021-11-28 03:17:47 +00:00
|
|
|
tr_file_view tr_torrentFile(tr_torrent const* torrent, tr_file_index_t file);
|
|
|
|
|
|
|
|
size_t tr_torrentFileCount(tr_torrent const* torrent);
|
2007-07-15 20:05:32 +00:00
|
|
|
|
2021-12-07 18:11:28 +00:00
|
|
|
/*
|
|
|
|
* This view structure is intended for short-term use. Its pointers are owned
|
|
|
|
* by the torrent and may be invalidated if the torrent is edited or removed.
|
|
|
|
*/
|
|
|
|
struct tr_webseed_view
|
|
|
|
{
|
|
|
|
char const* url; // the url to download from
|
|
|
|
bool is_downloading; // can be true even if speed is 0, e.g. slow download
|
|
|
|
unsigned download_bytes_per_second; // current download speed
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tr_webseed_view tr_torrentWebseed(tr_torrent const* torrent, size_t nth);
|
|
|
|
|
|
|
|
size_t tr_torrentWebseedCount(tr_torrent const* torrent);
|
|
|
|
|
2021-12-14 21:59:44 +00:00
|
|
|
/*
|
|
|
|
* This view structure is intended for short-term use. Its pointers are owned
|
|
|
|
* by the torrent and may be invalidated if the torrent is edited or removed.
|
|
|
|
*/
|
|
|
|
struct tr_torrent_view
|
|
|
|
{
|
|
|
|
char const* name;
|
|
|
|
char const* hash_string;
|
|
|
|
|
|
|
|
char const* comment; // optional; may be nullptr
|
|
|
|
char const* creator; // optional; may be nullptr
|
|
|
|
char const* source; // optional; may be nullptr
|
|
|
|
|
|
|
|
uint64_t total_size; // total size of the torrent, in bytes
|
|
|
|
|
|
|
|
time_t date_created;
|
|
|
|
|
|
|
|
uint32_t piece_size;
|
|
|
|
tr_piece_index_t n_pieces;
|
|
|
|
|
|
|
|
bool is_private;
|
|
|
|
bool is_folder;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tr_torrent_view tr_torrentView(tr_torrent const* tor);
|
|
|
|
|
2022-01-18 05:14:00 +00:00
|
|
|
/*
|
2022-03-21 14:15:48 +00:00
|
|
|
* Get the filename of Transmission's internal copy of the torrent file.
|
2022-01-18 05:14:00 +00:00
|
|
|
*/
|
2022-08-17 00:28:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
[[nodiscard]] std::string tr_torrentFilename(tr_torrent const* tor);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @brief buffer variant of tr_torrentFilename(). See tr_strvToBuf(). */
|
|
|
|
size_t tr_torrentFilenameToBuf(tr_torrent const* tor, char* buf, size_t buflen);
|
2022-01-18 05:14:00 +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.
|
|
|
|
**********************************************************************/
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_torrentAvailability(tr_torrent const* torrent, int8_t* tab, int size);
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
void tr_torrentAmountFinished(tr_torrent const* torrent, float* tab, int n_tabs);
|
2006-10-12 23:34:20 +00:00
|
|
|
|
2013-01-31 21:58:25 +00:00
|
|
|
/**
|
|
|
|
* Queue a torrent for verification.
|
|
|
|
*/
|
2022-02-09 18:02:59 +00:00
|
|
|
void tr_torrentVerify(tr_torrent* torrent);
|
2007-04-28 01:34:39 +00:00
|
|
|
|
2021-12-14 21:59:44 +00:00
|
|
|
bool tr_torrentHasMetadata(tr_torrent const* tor);
|
2009-11-24 15:51:16 +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
|
|
|
|
*/
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_torrent_activity
|
2007-06-26 18:45:03 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_STATUS_STOPPED = 0, /* Torrent is stopped */
|
|
|
|
TR_STATUS_CHECK_WAIT = 1, /* Queued to check files */
|
|
|
|
TR_STATUS_CHECK = 2, /* Checking files */
|
|
|
|
TR_STATUS_DOWNLOAD_WAIT = 3, /* Queued to download */
|
|
|
|
TR_STATUS_DOWNLOAD = 4, /* Downloading */
|
|
|
|
TR_STATUS_SEED_WAIT = 5, /* Queued to seed */
|
|
|
|
TR_STATUS_SEED = 6 /* Seeding */
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-05-22 20:44:41 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_PEER_FROM_INCOMING = 0, /* connections made to the listening port */
|
|
|
|
TR_PEER_FROM_LPD, /* peers found by local announcements */
|
|
|
|
TR_PEER_FROM_TRACKER, /* peers found from a tracker */
|
|
|
|
TR_PEER_FROM_DHT, /* peers found from the DHT */
|
|
|
|
TR_PEER_FROM_PEX, /* peers found from PEX */
|
|
|
|
TR_PEER_FROM_RESUME, /* peers found in the .resume file */
|
|
|
|
TR_PEER_FROM_LTEP, /* peer address provided in an LTEP handshake */
|
2008-05-22 20:44:41 +00:00
|
|
|
TR_PEER_FROM__MAX
|
|
|
|
};
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_stat_errtype
|
2009-08-05 01:25:36 +00:00
|
|
|
{
|
2009-08-31 16:41:54 +00:00
|
|
|
/* everything's fine */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_STAT_OK = 0,
|
2022-04-21 14:28:38 +00:00
|
|
|
/* when we announced to the tracker, we got a warning in the response */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_STAT_TRACKER_WARNING = 1,
|
2022-04-21 14:28:38 +00:00
|
|
|
/* when we announced to the tracker, we got an error in the response */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_STAT_TRACKER_ERROR = 2,
|
2009-08-31 16:41:54 +00:00
|
|
|
/* local trouble, such as disk full or permissions error */
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_STAT_LOCAL_ERROR = 3
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-10-03 04:57:06 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** @brief Used by tr_torrentStat() to tell clients about a torrent's state and statistics */
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_stat
|
2008-02-21 07:29:39 +00:00
|
|
|
{
|
2009-08-05 01:25:36 +00:00
|
|
|
/** A warning or error message regarding the torrent.
|
|
|
|
@see error */
|
2021-10-05 17:23:07 +00:00
|
|
|
char const* errorString;
|
2008-02-21 07:29:39 +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,
|
2021-12-14 21:59:44 +00:00
|
|
|
whether or not we have it yet. This may be less than tr_torrentTotalSize()
|
2008-11-30 01:52:45 +00:00
|
|
|
if only some of the torrent's files are wanted.
|
2021-12-14 21:59:44 +00:00
|
|
|
[0...tr_torrentTotalSize()] */
|
2017-04-19 12:04:45 +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
|
2021-12-14 21:59:44 +00:00
|
|
|
all the pieces that we want. [0...tr_stat.sizeWhenDone] */
|
2017-04-19 12:04:45 +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] */
|
2017-04-19 12:04:45 +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
|
2010-12-27 19:18:17 +00:00
|
|
|
this torrent. If you're on a poisoned torrent, this number can
|
2008-05-23 20:04:41 +00:00
|
|
|
grow very large. */
|
2017-04-19 12:04:45 +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. */
|
2017-04-19 12:04:45 +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
|
2010-12-27 19:18:17 +00:00
|
|
|
for this torrent. If you deleted the files and downloaded a second
|
2008-05-23 20:04:41 +00:00
|
|
|
time, this will be 2*totalSize.. */
|
2017-04-19 12:04:45 +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.
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
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'. */
|
2017-04-19 12:04:45 +00:00
|
|
|
uint64_t haveUnchecked;
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-06-02 04:41:55 +00:00
|
|
|
/** When the torrent was first added. */
|
2017-04-19 12:04:45 +00:00
|
|
|
time_t addedDate;
|
2008-06-03 19:16:12 +00:00
|
|
|
|
|
|
|
/** When the torrent finished downloading. */
|
2017-04-19 12:04:45 +00:00
|
|
|
time_t doneDate;
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
/** When the torrent was last started. */
|
2017-04-19 12:04:45 +00:00
|
|
|
time_t startDate;
|
2008-05-23 20:04:41 +00:00
|
|
|
|
|
|
|
/** The last time we uploaded or downloaded piece data on this torrent. */
|
2017-04-19 12:04:45 +00:00
|
|
|
time_t activityDate;
|
2010-12-12 16:43:19 +00:00
|
|
|
|
2019-11-12 23:13:42 +00:00
|
|
|
/** The last time during this session that a rarely-changing field
|
2022-01-15 19:33:57 +00:00
|
|
|
changed -- e.g. any tr_torrent_metainfo field (trackers, filenames, name)
|
2019-11-12 23:13:42 +00:00
|
|
|
or download directory. RPC clients can monitor this to know when
|
|
|
|
to reload fields that rarely change. */
|
|
|
|
time_t editDate;
|
|
|
|
|
2022-04-28 01:06:51 +00:00
|
|
|
/** When tr_stat.activity 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.activity */
|
|
|
|
float recheckProgress;
|
|
|
|
|
|
|
|
/** How much has been downloaded of the entire torrent.
|
|
|
|
Range is [0..1] */
|
|
|
|
float percentComplete;
|
|
|
|
|
|
|
|
/** How much of the metadata the torrent has.
|
|
|
|
For torrents added from a torrent this will always be 1.
|
|
|
|
For magnet links, this number will from from 0 to 1 as the metadata is downloaded.
|
|
|
|
Range is [0..1] */
|
|
|
|
float metadataPercentComplete;
|
|
|
|
|
|
|
|
/** 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 */
|
|
|
|
float percentDone;
|
|
|
|
|
|
|
|
/** How much has been uploaded to satisfy the seed ratio.
|
|
|
|
This is 1 if the ratio is reached or the torrent is set to seed forever.
|
|
|
|
Range is [0..1] */
|
|
|
|
float seedRatioPercentDone;
|
|
|
|
|
|
|
|
/** Speed all piece being sent for this torrent.
|
|
|
|
This ONLY counts piece data. */
|
|
|
|
float pieceUploadSpeed_KBps;
|
|
|
|
|
|
|
|
/** Speed all piece being received for this torrent.
|
|
|
|
This ONLY counts piece data. */
|
|
|
|
float pieceDownloadSpeed_KBps;
|
|
|
|
|
|
|
|
/** Total uploaded bytes / sizeWhenDone.
|
|
|
|
NB: In Transmission 3.00 and earlier, this was total upload / download,
|
|
|
|
which caused edge cases when total download was less than sizeWhenDone. */
|
|
|
|
float ratio;
|
|
|
|
|
|
|
|
/** The torrent's unique Id.
|
|
|
|
@see tr_torrentId() */
|
2022-06-17 15:43:04 +00:00
|
|
|
tr_torrent_id_t id;
|
2022-04-28 01:06:51 +00:00
|
|
|
|
2010-07-11 21:02:30 +00:00
|
|
|
/** Number of seconds since the last activity (or since started).
|
|
|
|
-1 if activity is not seeding or downloading. */
|
2017-04-19 12:04:45 +00:00
|
|
|
int idleSecs;
|
2010-07-16 03:12:57 +00:00
|
|
|
|
2010-12-23 19:32:59 +00:00
|
|
|
/** Cumulative seconds the torrent's ever spent downloading */
|
2017-04-19 12:04:45 +00:00
|
|
|
int secondsDownloading;
|
2010-12-23 19:32:59 +00:00
|
|
|
|
|
|
|
/** Cumulative seconds the torrent's ever spent seeding */
|
2017-04-19 12:04:45 +00:00
|
|
|
int secondsSeeding;
|
2010-12-23 19:32:59 +00:00
|
|
|
|
2011-08-02 03:59:54 +00:00
|
|
|
/** This torrent's queue position.
|
|
|
|
All torrents have a queue position, even if it's not queued. */
|
2011-08-01 22:24:24 +00:00
|
|
|
int queuePosition;
|
2011-08-01 23:27:11 +00:00
|
|
|
|
2022-04-28 01:06:51 +00:00
|
|
|
#define TR_ETA_NOT_AVAIL (-1)
|
|
|
|
#define TR_ETA_UNKNOWN (-2)
|
|
|
|
/** If downloading, estimated number of seconds left until the torrent is done.
|
|
|
|
If seeding, estimated number of seconds left until seed ratio is reached. */
|
|
|
|
int eta;
|
|
|
|
|
|
|
|
/** If seeding, number of seconds left until the idle time limit is reached. */
|
|
|
|
int etaIdle;
|
|
|
|
|
|
|
|
/** What is this torrent doing right now? */
|
|
|
|
tr_torrent_activity activity;
|
|
|
|
|
|
|
|
/** Defines what kind of text is in errorString.
|
|
|
|
@see errorString */
|
|
|
|
tr_stat_errtype error;
|
|
|
|
|
|
|
|
/** Number of peers that we're connected to */
|
|
|
|
uint16_t peersConnected;
|
|
|
|
|
|
|
|
/** How many peers we found out about from the tracker, or from pex,
|
|
|
|
or from incoming connections, or from our resume file. */
|
|
|
|
uint16_t peersFrom[TR_PEER_FROM__MAX];
|
|
|
|
|
|
|
|
/** Number of peers that are sending data to us. */
|
|
|
|
uint16_t peersSendingToUs;
|
|
|
|
|
|
|
|
/** Number of peers that we're sending data to */
|
|
|
|
uint16_t peersGettingFromUs;
|
|
|
|
|
|
|
|
/** Number of webseeds that are sending data to us. */
|
|
|
|
uint16_t webseedsSendingToUs;
|
|
|
|
|
2021-12-14 21:59:44 +00:00
|
|
|
/** A torrent is considered finished if it has met its seed ratio.
|
|
|
|
As a result, only paused torrents can be finished. */
|
|
|
|
bool finished;
|
|
|
|
|
2011-08-01 23:27:11 +00:00
|
|
|
/** True if the torrent is running, but has been idle for long enough
|
2017-04-21 07:40:57 +00:00
|
|
|
to be considered stalled. @see tr_sessionGetQueueStalledMinutes() */
|
2011-08-01 23:27:11 +00:00
|
|
|
bool isStalled;
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
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
|
2010-12-27 19:18:17 +00:00
|
|
|
on the torrent. This is typically called by the GUI clients every
|
2008-05-30 15:19:07 +00:00
|
|
|
second or so to get a new snapshot of the torrent's status. */
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_stat const* tr_torrentStat(tr_torrent* torrent);
|
2007-11-17 23:43:33 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/** Like tr_torrentStat(), but only recalculates the statistics if it's
|
2010-12-27 19:18:17 +00:00
|
|
|
been longer than a second since they were last calculated. This can
|
2017-04-21 07:40:57 +00:00
|
|
|
reduce the CPU load if you're calling tr_torrentStat() frequently. */
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_stat const* tr_torrentStatCached(tr_torrent* torrent);
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/** @} */
|
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 */
|
2021-10-06 22:24:04 +00:00
|
|
|
constexpr bool tr_isDirection(tr_direction d)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
return d == TR_UP || d == TR_DOWN;
|
|
|
|
}
|