mirror of
https://github.com/transmission/transmission
synced 2025-03-13 15:39:01 +00:00
(trunk libT) #2846 "Priority Selection in `Add' Window" -- added RPC hooks for doing this via remote client
This commit is contained in:
parent
803225bf10
commit
094f76d9ca
5 changed files with 58 additions and 13 deletions
|
@ -331,12 +331,13 @@
|
|||
Request arguments:
|
||||
|
||||
key | value type & description
|
||||
-------------------+-------------------------------------------------
|
||||
---------------------+-------------------------------------------------
|
||||
"download-dir" | string path to download the torrent to
|
||||
"filename" | string filename or URL of the .torrent file
|
||||
"metainfo" | string base64-encoded .torrent content
|
||||
"paused" | boolean if true, don't start the torrent
|
||||
"peer-limit" | number maximum number of peers
|
||||
"bandwidthPriority" | number torrent's bandwidth tr_priority_t
|
||||
"files-wanted" | array indices of file(s) to download
|
||||
"files-unwanted" | array indices of file(s) to not download
|
||||
"priority-high" | array indices of high-priority file(s)
|
||||
|
@ -576,4 +577,4 @@
|
|||
------+---------+-----------+----------------+-------------------------------
|
||||
8 | 1.90 | yes | session-set | new arg "rename-partial-files"
|
||||
| | yes | session-get | new arg "rename-partial-files"
|
||||
|
||||
| | yes | torrent-add | new arg "bandwidthPriority"
|
||||
|
|
|
@ -1061,6 +1061,9 @@ torrentAdd( tr_session * session,
|
|||
if( tr_bencDictFindInt( args_in, "peer-limit", &i ) )
|
||||
tr_ctorSetPeerLimit( ctor, TR_FORCE, i );
|
||||
|
||||
if( tr_bencDictFindInt( args_in, "bandwidthPriority", &i ) )
|
||||
tr_ctorSetBandwidthPriority( ctor, i );
|
||||
|
||||
if( tr_bencDictFindList( args_in, "files-unwanted", &l ) ) {
|
||||
tr_file_index_t fileCount;
|
||||
tr_file_index_t * files = fileListFromList( l, &fileCount );
|
||||
|
|
|
@ -38,6 +38,7 @@ struct tr_ctor
|
|||
tr_bool saveInOurTorrentsDir;
|
||||
tr_bool doDelete;
|
||||
|
||||
tr_priority_t bandwidthPriority;
|
||||
tr_bool isSet_metainfo;
|
||||
tr_bool isSet_delete;
|
||||
tr_benc metainfo;
|
||||
|
@ -425,12 +426,38 @@ tr_ctorGetSession( const tr_ctor * ctor )
|
|||
****
|
||||
***/
|
||||
|
||||
static tr_bool
|
||||
isPriority( int i )
|
||||
{
|
||||
return (i==TR_PRI_LOW) || (i==TR_PRI_NORMAL) || (i==TR_PRI_HIGH);
|
||||
}
|
||||
|
||||
void
|
||||
tr_ctorSetBandwidthPriority( tr_ctor * ctor, tr_priority_t priority )
|
||||
{
|
||||
fprintf( stderr, "in tr_ctorSetPriority with %d\n", (int)priority );
|
||||
if( isPriority( priority ) )
|
||||
ctor->bandwidthPriority = priority;
|
||||
}
|
||||
|
||||
tr_priority_t
|
||||
tr_ctorGetBandwidthPriority( const tr_ctor * ctor )
|
||||
{
|
||||
fprintf( stderr, "got priority with %d\n", (int)ctor->bandwidthPriority );
|
||||
return ctor->bandwidthPriority;
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
tr_ctor*
|
||||
tr_ctorNew( const tr_session * session )
|
||||
{
|
||||
tr_ctor * ctor = tr_new0( struct tr_ctor, 1 );
|
||||
|
||||
ctor->session = session;
|
||||
ctor->bandwidthPriority = TR_PRI_NORMAL;
|
||||
tr_ctorSetPaused( ctor, TR_FALLBACK, FALSE );
|
||||
if( session != NULL ) {
|
||||
tr_ctorSetPeerLimit( ctor, TR_FALLBACK, session->peerLimitPerTorrent );
|
||||
|
|
|
@ -634,6 +634,8 @@ torrentInit( tr_torrent * tor, const tr_ctor * ctor )
|
|||
|
||||
tor->bandwidth = tr_bandwidthNew( session, session->bandwidth );
|
||||
|
||||
tor->bandwidth->priority = tr_ctorGetBandwidthPriority( ctor );
|
||||
|
||||
tor->error = TR_STAT_OK;
|
||||
|
||||
tr_peerMgrAddTorrent( session->peerMgr, tor );
|
||||
|
|
|
@ -339,6 +339,18 @@ void tr_sessionSetDownloadDir( tr_session * session, const char * downloadDir );
|
|||
*/
|
||||
const char * tr_sessionGetDownloadDir( const tr_session * session );
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the torrent's bandwidth priority.
|
||||
*/
|
||||
void tr_ctorSetBandwidthPriority( tr_ctor * ctor, tr_priority_t priority );
|
||||
|
||||
/**
|
||||
* @brief Get the torrent's bandwidth priority.
|
||||
*/
|
||||
tr_priority_t tr_ctorGetBandwidthPriority( const tr_ctor * ctor );
|
||||
|
||||
|
||||
/**
|
||||
* @brief set the per-session incomplete download folder.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue