From d3ac3b27e0e9911c1048c36cc1abc6d9d840ca95 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 20 Apr 2010 01:48:40 +0000 Subject: [PATCH] (trunk) #2960 "add torrent availability to web interface and remote" -- implemented via a patch from Longinus00 --- daemon/remote.c | 21 ++++++++++++++++----- web/index.html | 4 ++++ web/javascript/torrent.js | 3 ++- web/javascript/transmission.js | 5 +++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 68a0cc8ae..666078c0d 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -324,6 +324,7 @@ static const char * details_keys[] = { "corruptEver", "creator", "dateCreated", + "desiredAvailable", "doneDate", "downloadDir", "downloadedEver", @@ -1275,12 +1276,22 @@ printDetails( tr_benc * top ) printf( " Have: %s (%s verified)\n", buf, buf2 ); } - if( tr_bencDictFindInt( t, "sizeWhenDone", &i ) - && tr_bencDictFindInt( t, "totalSize", &j ) ) + if( tr_bencDictFindInt( t, "sizeWhenDone", &i ) ) { - strlsize( buf, j, sizeof( buf ) ); - strlsize( buf2, i, sizeof( buf2 ) ); - printf( " Total size: %s (%s wanted)\n", buf, buf2 ); + if( i < 1 ) + printf( " Availability: None\n" ); + if( tr_bencDictFindInt( t, "desiredAvailable", &j) + && tr_bencDictFindInt( t, "leftUntilDone", &k) ) + { + j += i - k; + printf( " Availability: %.1f%%\n", ( 100 * j ) / (double) i ); + } + if( tr_bencDictFindInt( t, "totalSize", &j ) ) + { + strlsize( buf2, i, sizeof( buf2 ) ); + strlsize( buf, j, sizeof( buf ) ); + printf( " Total size: %s (%s wanted)\n", buf, buf2 ); + } } if( tr_bencDictFindInt( t, "downloadedEver", &i ) && tr_bencDictFindInt( t, "uploadedEver", &j ) ) diff --git a/web/index.html b/web/index.html index 082e0d096..5e8e07ba1 100755 --- a/web/index.html +++ b/web/index.html @@ -135,6 +135,10 @@
Have:
N/A
+
+
Availability:
+
N/A
+
Downloaded:
N/A
diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index 11ce3e116..beb65be11 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -41,7 +41,7 @@ Torrent._MetaDataFields = [ 'addedDate', 'comment', 'creator', 'dateCreated', Torrent._DynamicFields = [ 'downloadedEver', 'error', 'errorString', 'eta', 'haveUnchecked', 'haveValid', 'leftUntilDone', 'metadataPercentComplete', 'peersConnected', 'peersGettingFromUs', 'peersSendingToUs', 'rateDownload', 'rateUpload', - 'recheckProgress', 'sizeWhenDone', 'status', 'trackerStats', + 'recheckProgress', 'sizeWhenDone', 'status', 'trackerStats', 'desiredAvailable', 'uploadedEver', 'uploadRatio', 'seedRatioLimit', 'seedRatioMode', 'downloadDir', 'isFinished' ] Torrent.prototype = @@ -393,6 +393,7 @@ Torrent.prototype = this._download_dir = data.downloadDir; this._metadataPercentComplete = data.metadataPercentComplete; this._isFinishedSeeding = data.isFinished; + this._desiredAvailable = data.desiredAvailable; if (data.fileStats) this.refreshFileModel( data ); diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 795af4afb..9e3b3f58d 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -90,6 +90,7 @@ Transmission.prototype = var ti = '#torrent_inspector_'; this._inspector = { }; this._inspector._info_tab = { }; + this._inspector._info_tab.availability = $(ti+'availability')[0]; this._inspector._info_tab.comment = $(ti+'comment')[0]; this._inspector._info_tab.creator_date = $(ti+'creator_date')[0]; this._inspector._info_tab.creator = $(ti+'creator')[0]; @@ -1147,6 +1148,7 @@ Transmission.prototype = var total_download = 0; var total_download_peers = 0; var total_download_speed = 0; + var total_availability = 0; var total_have = 0; var total_size = 0; var total_state = null; @@ -1171,6 +1173,7 @@ Transmission.prototype = setInnerHTML( tab.upload_speed, na ); setInnerHTML( tab.uploaded, na ); setInnerHTML( tab.downloaded, na ); + setInnerHTML( tab.availability, na ); setInnerHTML( tab.ratio, na ); setInnerHTML( tab.have, na ); setInnerHTML( tab.upload_to, na ); @@ -1222,6 +1225,7 @@ Transmission.prototype = total_download_speed += t.downloadSpeed(); total_upload_peers += t.peersGettingFromUs(); total_download_peers += t.peersSendingToUs(); + total_availability += t._sizeWhenDone - t._leftUntilDone + t._desiredAvailable; if( total_state == null ) total_state = t.stateStr(); else if ( total_state.search ( t.stateStr() ) == -1 ) @@ -1246,6 +1250,7 @@ Transmission.prototype = setInnerHTML( tab.upload_speed, torrents.length ? Math.formatBytes( total_upload_speed ) + '/s' : na ); setInnerHTML( tab.uploaded, torrents.length ? Math.formatBytes( total_upload ) : na ); setInnerHTML( tab.downloaded, torrents.length ? Math.formatBytes( total_download ) : na ); + setInnerHTML( tab.availability, torrents.length ? Math.ratio( total_availability*100, sizeWhenDone ) + '%' : na ); setInnerHTML( tab.ratio, torrents.length ? Math.ratio( total_upload, total_download ) : na ); setInnerHTML( tab.have, torrents.length ? Math.formatBytes(total_completed) + ' (' + Math.formatBytes(total_verified) + ' verified)' : na ); setInnerHTML( tab.upload_to, torrents.length ? total_upload_peers : na );