diff --git a/daemon/remote.c b/daemon/remote.c index 1e4039970..9c4404519 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -58,71 +58,38 @@ getUsage( void ) static tr_option opts[] = { - { 'a', "add", "Add torrent files", - "a", 0, NULL }, - { 'b', "debug", "Print debugging information", - "b", 0, NULL }, - { 'd', "downlimit", "Set the maximum global download speed in KB/s", - "d", 1, "" }, - { 'D', "no-downlimit", "Don't limit the global download speed", - "D", 0, NULL }, - { 910, "encryption-required", "Encrypt all peer connections", - "er", 0, NULL }, - { 911, "encryption-preferred", "Prefer encrypted peer connections", - "ep", 0, NULL }, - { 912, "encryption-tolerated", "Prefer unencrypted peer connections", - "et", 0, NULL }, - { 'f', "files", "List the current torrent's files", - "f", 0, NULL }, - { 'g', "get", "Mark files for download", - "g", 1, "" }, - { 'G', "no-get", "Mark files for not downloading", - "G", 1, "" }, - { 'i', "info", "Show details of the current torrent(s)", - "i", 0, NULL }, - { 'l', "list", "List all torrents", - "l", 0, NULL }, - { 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", - "m", 0, NULL }, - { 'M', "no-portmap", "Disable portmapping", - "M", 0, NULL }, - { 'n', "auth", "Set authentication info", - "n", 1, "" }, - { 'p', "port", - "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", - "p", 1, "" }, - { 900, "priority-high", "Set the files' priorities as high", - "ph", 1, "" }, - { 901, "priority-normal", "Set the files' priorities as normal", - "pn", 1, "" }, - { 902, "priority-low", "Set the files' priorities as low", - "pl", 1, "" }, - { 'r', "remove", "Remove the current torrent(s)", - "r", 0, NULL }, - { 'R', "remove-and-delete", "Remove the current torrent(s) and delete local data", - NULL, 0, NULL }, - { 's', "start", "Start the current torrent(s)", - "s", 0, NULL }, - { 'S', "stop", "Stop the current torrent(s)", - "S", 0, NULL }, - { 't', "torrent", "Set the current torrent(s)", - "t", 1, "" }, - { 'u', "uplimit", "Set the maximum global upload speed in KB/s", - "u", 1, "" }, - { 'U', "no-uplimit", "Don't limit the global upload speed", - "U", 0, NULL }, - { 'v', "verify", "Verify the current torrent(s)", - "v", 0, NULL }, - { 'w', "download-dir", "Set the default download folder", - "w", 1, "" }, - { 'x', "pex", "Enable peer exchange (PEX)", - "x", 0, NULL }, - { 'X', "no-pex", "Disable peer exchange (PEX)", - "X", 0, NULL }, - { 'z', "peers", "List the current torrent's peers", - "z", 0, NULL }, - { 0, NULL, NULL, - NULL, 0, NULL } + { 'a', "add", "Add torrent files", "a", 0, NULL }, + { 'b', "debug", "Print debugging information", "b", 0, NULL }, + { 'd', "downlimit", "Set the maximum global download speed in KB/s", "d", 1, "" }, + { 'D', "no-downlimit", "Don't limit the global download speed", "D", 0, NULL }, + { 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL }, + { 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL }, + { 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL }, + { 'f', "files", "List the current torrent's files", "f", 0, NULL }, + { 'g', "get", "Mark files for download", "g", 1, "" }, + { 'G', "no-get", "Mark files for not downloading", "G", 1, "" }, + { 'i', "info", "Show details of the current torrent(s)", "i", 0, NULL }, + { 'l', "list", "List all torrents", "l", 0, NULL }, + { 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL }, + { 'M', "no-portmap", "Disable portmapping", "M", 0, NULL }, + { 'n', "auth", "Set authentication info", "n", 1, "" }, + { 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "" }, + { 900, "priority-high", "Set the files' priorities as high", "ph", 1, "" }, + { 901, "priority-normal", "Set the files' priorities as normal", "pn", 1, "" }, + { 902, "priority-low", "Set the files' priorities as low", "pl", 1, "" }, + { 'r', "remove", "Remove the current torrent(s)", "r", 0, NULL }, + { 'R', "remove-and-delete", "Remove the current torrent(s) and delete local data", NULL, 0, NULL }, + { 's', "start", "Start the current torrent(s)", "s", 0, NULL }, + { 'S', "stop", "Stop the current torrent(s)", "S", 0, NULL }, + { 't', "torrent", "Set the current torrent(s)", "t", 1, "" }, + { 'u', "uplimit", "Set the maximum global upload speed in KB/s", "u", 1, "" }, + { 'U', "no-uplimit", "Don't limit the global upload speed", "U", 0, NULL }, + { 'v', "verify", "Verify the current torrent(s)", "v", 0, NULL }, + { 'w', "download-dir", "Set the default download folder", "w", 1, "" }, + { 'x', "pex", "Enable peer exchange (PEX)", "x", 0, NULL }, + { 'X', "no-pex", "Disable peer exchange (PEX)", "X", 0, NULL }, + { 'z', "peers", "List the current torrent's peers", "z", 0, NULL }, + { 0, NULL, NULL, NULL, 0, NULL } }; static void @@ -234,28 +201,56 @@ addFiles( tr_benc * args, #define TR_N_ELEMENTS( ary ) ( sizeof( ary ) / sizeof( *ary ) ) static const char * files_keys[] = { - "files", "name", "priorities", "wanted" + "files", + "name", + "priorities", + "wanted" }; static const char * details_keys[] = { - "activityDate", "addedDate", "announceResponse", + "activityDate", + "addedDate", + "announceResponse", "announceURL", - "comment", "corruptEver", "creator", - "dateCreated", "doneDate", - "downloadedEver", "errorString", "eta", - "hashString", "haveUnchecked", - "haveValid", "id", "isPrivate", - "lastAnnounceTime", "lastScrapeTime", - "leechers", "leftUntilDone", "name", - "nextAnnounceTime", "nextScrapeTime", - "peersConnected", "peersGettingFromUs", "peersSendingToUs", - "pieceCount", "pieceSize", "rateDownload", - "rateUpload", "recheckProgress", - "scrapeResponse", "seeders", - "sizeWhenDone", "startDate", - "status", "timesCompleted", "totalSize", + "comment", + "corruptEver", + "creator", + "dateCreated", + "doneDate", + "downloadDir", + "downloadedEver", + "errorString", + "eta", + "hashString", + "haveUnchecked", + "haveValid", + "id", + "isPrivate", + "lastAnnounceTime", + "lastScrapeTime", + "leechers", + "leftUntilDone", + "name", + "nextAnnounceTime", + "nextScrapeTime", + "peersConnected", + "peersGettingFromUs", + "peersSendingToUs", + "pieceCount", + "pieceSize", + "rateDownload", + "rateUpload", + "recheckProgress", + "scrapeResponse", + "seeders", + "sizeWhenDone", + "startDate", + "status", + "timesCompleted", + "totalSize", "uploadedEver", - "webseeds", "webseedsSendingToUs" + "webseeds", + "webseedsSendingToUs" }; static const char * list_keys[] = { @@ -753,6 +748,9 @@ printDetails( tr_benc * top ) getStatusString( t, buf, sizeof( buf ) ); printf( " State: %s\n", buf ); + if( tr_bencDictFindStr( t, "downloadDir", &str ) ) + printf( " Location: %s\n", str ); + if( tr_bencDictFindInt( t, "sizeWhenDone", &i ) && tr_bencDictFindInt( t, "leftUntilDone", &j ) ) { diff --git a/doc/rpc-spec.txt b/doc/rpc-spec.txt index b35a13c3e..e02df64a2 100644 --- a/doc/rpc-spec.txt +++ b/doc/rpc-spec.txt @@ -131,6 +131,7 @@ dateCreated | number | tr_info desiredAvailable | number | tr_stat doneDate | number | tr_stat + downloadDir | string | tr_torrent downloadedEver | number | tr_stat downloaders | number | tr_stat downloadLimitMode | number | tr_torrent @@ -381,5 +382,6 @@ ------+---------+-----------+----------------+------------------------------- 4 | 1.50 | yes | session-get | new arg "rpc-version" | | | session-get | new arg "rpc-version-minimum" + | | | torrent-get | new arg "downloadDir" ------+---------+-----------+----------------+------------------------------- diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index db52e9f53..e7fa50ac6 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -293,6 +293,8 @@ addField( const tr_torrent * tor, tr_bencDictAddInt( d, key, st->desiredAvailable ); else if( !strcmp( key, "doneDate" ) ) tr_bencDictAddInt( d, key, st->doneDate ); + else if( !strcmp( key, "downloadDir" ) ) + tr_bencDictAddStr( d, key, tr_torrentGetDownloadDir( tor ) ); else if( !strcmp( key, "downloadedEver" ) ) tr_bencDictAddInt( d, key, st->downloadedEver ); else if( !strcmp( key, "downloaders" ) )