Changeset 11228


Ignore:
Timestamp:
Sep 18, 2010, 11:06:03 PM (12 years ago)
Author:
charles
Message:

(trunk) #3547 "Wrong speed display in web UI" -- fixed

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/extras/rpc-spec.txt

    r11209 r11228  
    4014014.1.  Session Arguments
    402402
    403    string                           | value type & description
    404    ---------------------------------+-------------------------------------------------
    405    "alt-speed-down"                 | number     max global download speed (KBps)
    406    "alt-speed-enabled"              | boolean    true means use the alt speeds
    407    "alt-speed-time-begin"           | number     when to turn on alt speeds (units: minutes after midnight)
    408    "alt-speed-time-enabled"         | boolean    true means the scheduled on/off times are used
    409    "alt-speed-time-end"             | number     when to turn off alt speeds (units: same)
    410    "alt-speed-time-day"             | number     what day(s) to turn on alt speeds (look at tr_sched_day)
    411    "alt-speed-up"                   | number     max global upload speed (KBps)
    412    "blocklist-enabled"              | boolean    true means enabled
    413    "blocklist-size"                 | number     number of rules in the blocklist
    414    "cache-size"                     | number     maximum size of the disk cache (MB)
    415    "config-dir"                     | string     location of transmission's configuration directory
    416    "download-dir"                   | string     default path to download torrents
    417    "dht-enabled"                    | boolean    true means allow dht in public torrents
    418    "encryption"                     | string     "required", "preferred", "tolerated"
    419    "idle-seeding-limit"             | number     the default seed inactivity limit for torrents to use
    420    "idle-seeding-limit-enabled"     | boolean    true if the seeding inactivity limit is honored by default
    421    "incomplete-dir"                 | string     path for incomplete torrents, when enabled
    422    "incomplete-dir-enabled"         | boolean    true means keep torrents in incomplete-dir until done
    423    "lpd-enabled"                    | boolean    true means allow Local Peer Discovery in public torrents
    424    "peer-limit-global"              | number     maximum global number of peers
    425    "peer-limit-per-torrent"         | number     maximum global number of peers
    426    "pex-enabled"                    | boolean    true means allow pex in public torrents
    427    "peer-port"                      | number     port number
    428    "peer-port-random-on-start"      | boolean    true means pick a random peer port on launch
    429    "port-forwarding-enabled"        | boolean    true means enabled
    430    "rename-partial-files"           | boolean    true means append ".part" to incomplete files
    431    "rpc-version"                    | number     the current RPC API version
    432    "rpc-version-minimum"            | number     the minimum RPC API version supported
    433    "script-torrent-done-filename"   | string     filename of the script to run
    434    "script-torrent-done-enabled"    | boolean    whether or not to call the "done" script
    435    "seedRatioLimit"                 | double     the default seed ratio for torrents to use
    436    "seedRatioLimited"               | boolean    true if seedRatioLimit is honored by default
    437    "speed-limit-down"               | number     max global download speed (KBps)
    438    "speed-limit-down-enabled"       | boolean    true means enabled
    439    "speed-limit-up"                 | number     max global upload speed (KBps)
    440    "speed-limit-up-enabled"         | boolean    true means enabled
    441    "start-added-torrents"           | boolean    true means added torrents will be started right away
    442    "trash-original-torrent-files"   | boolean    true means the .torrent file of added torrents will be deleted
    443    "version"                        | string     long version string "$version ($revision)"
     403   string                           | value type | description
     404   ---------------------------------+------------+-------------------------------------
     405   "alt-speed-down"                 | number     | max global download speed (KBps)
     406   "alt-speed-enabled"              | boolean    | true means use the alt speeds
     407   "alt-speed-time-begin"           | number     | when to turn on alt speeds (units: minutes after midnight)
     408   "alt-speed-time-enabled"         | boolean    | true means the scheduled on/off times are used
     409   "alt-speed-time-end"             | number     | when to turn off alt speeds (units: same)
     410   "alt-speed-time-day"             | number     | what day(s) to turn on alt speeds (look at tr_sched_day)
     411   "alt-speed-up"                   | number     | max global upload speed (KBps)
     412   "blocklist-enabled"              | boolean    | true means enabled
     413   "blocklist-size"                 | number     | number of rules in the blocklist
     414   "cache-size"                     | number     | maximum size of the disk cache (MB)
     415   "config-dir"                     | string     | location of transmission's configuration directory
     416   "download-dir"                   | string     | default path to download torrents
     417   "dht-enabled"                    | boolean    | true means allow dht in public torrents
     418   "encryption"                     | string     | "required", "preferred", "tolerated"
     419   "idle-seeding-limit"             | number     | the default seed inactivity limit for torrents to use
     420   "idle-seeding-limit-enabled"     | boolean    | true if the seeding inactivity limit is honored by default
     421   "incomplete-dir"                 | string     | path for incomplete torrents, when enabled
     422   "incomplete-dir-enabled"         | boolean    | true means keep torrents in incomplete-dir until done
     423   "lpd-enabled"                    | boolean    | true means allow Local Peer Discovery in public torrents
     424   "peer-limit-global"              | number     | maximum global number of peers
     425   "peer-limit-per-torrent"         | number     | maximum global number of peers
     426   "pex-enabled"                    | boolean    | true means allow pex in public torrents
     427   "peer-port"                      | number     | port number
     428   "peer-port-random-on-start"      | boolean    | true means pick a random peer port on launch
     429   "port-forwarding-enabled"        | boolean    | true means enabled
     430   "rename-partial-files"           | boolean    | true means append ".part" to incomplete files
     431   "rpc-version"                    | number     | the current RPC API version
     432   "rpc-version-minimum"            | number     | the minimum RPC API version supported
     433   "script-torrent-done-filename"   | string     | filename of the script to run
     434   "script-torrent-done-enabled"    | boolean    | whether or not to call the "done" script
     435   "seedRatioLimit"                 | double     | the default seed ratio for torrents to use
     436   "seedRatioLimited"               | boolean    | true if seedRatioLimit is honored by default
     437   "speed-limit-down"               | number     | max global download speed (KBps)
     438   "speed-limit-down-enabled"       | boolean    | true means enabled
     439   "speed-limit-up"                 | number     | max global upload speed (KBps)
     440   "speed-limit-up-enabled"         | boolean    | true means enabled
     441   "start-added-torrents"           | boolean    | true means added torrents will be started right away
     442   "trash-original-torrent-files"   | boolean    | true means the .torrent file of added torrents will be deleted
     443   "units"                          | object     | see below
     444   "version"                        | string     | long version string "$version ($revision)"
     445   ---------------------------------+------------+-----------------------------+
     446   units                            | object containing:                       |
     447                                    +--------------+--------+------------------+
     448                                    | speed-units  | array  | 4 strings: KB/s, MB/s, GB/s, TB/s
     449                                    | speed-bytes  | number | number of bytes in a KB (1000 for kB; 1024 for KiB)
     450                                    | size-units   | array  | 4 strings: KB/s, MB/s, GB/s, TB/s
     451                                    | size-bytes   | number | number of bytes in a KB (1000 for kB; 1024 for KiB)
     452                                    | memory-units | array  | 4 strings: KB/s, MB/s, GB/s, TB/s
     453                                    | memory-bytes | number | number of bytes in a KB (1000 for kB; 1024 for KiB)
     454                                    +--------------+--------+------------------+
    444455
    445456   "rpc-version" indicates the RPC interface version supported by the RPC server.
     
    623634         |         | yes       | session-get    | new arg "idle-seeding-limit"
    624635         |         | yes       | session-get    | new arg "idle-seeding-limit-enabled"
     636         |         | yes       | session-get    | new arg "units"
    625637         |         | yes       | torrent-set    | new arg "seedIdleLimit"
    626638         |         | yes       | torrent-set    | new arg "seedIdleMode"
  • trunk/libtransmission/rpcimpl.c

    r11212 r11228  
    15211521{
    15221522    const char * str;
    1523     tr_benc *    d = args_out;
     1523    tr_benc * d = args_out;
    15241524
    15251525    assert( idle_data == NULL );
     
    15611561    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
    15621562    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, tr_sessionIsTorrentDoneScriptEnabled( s ) );
     1563    tr_formatter_get_units( tr_bencDictAddDict( d, "units", 0 ) );
    15631564    tr_bencDictAddStr ( d, "version", LONG_VERSION_STRING );
    15641565    switch( tr_sessionGetEncryption( s ) ) {
  • trunk/libtransmission/utils.c

    r11209 r11228  
    5151
    5252#include "transmission.h"
     53#include "bencode.h"
    5354#include "fdlimit.h"
    5455#include "ConvertUTF.h"
     
    16871688    return formatter_get_size_str( &mem_units, buf, bytes_per_second, buflen );
    16881689}
     1690
     1691void
     1692tr_formatter_get_units( tr_benc * d )
     1693{
     1694    int i;
     1695    tr_benc * l;
     1696
     1697    tr_bencDictReserve( d, 6 );
     1698
     1699    tr_bencDictAddInt( d, "memory-bytes", mem_units.units[TR_FMT_KB].value );
     1700    l = tr_bencDictAddList( d, "memory-units", 4 );
     1701    for( i=0; i<4; i++ ) tr_bencListAddStr( l, mem_units.units[i].name );
     1702
     1703    tr_bencDictAddInt( d, "size-bytes",   size_units.units[TR_FMT_KB].value );
     1704    l = tr_bencDictAddList( d, "size-units", 4 );
     1705    for( i=0; i<4; i++ ) tr_bencListAddStr( l, size_units.units[i].name );
     1706
     1707    tr_bencDictAddInt( d, "speed-bytes",  speed_units.units[TR_FMT_KB].value );
     1708    l = tr_bencDictAddList( d, "speed-units", 4 );
     1709    for( i=0; i<4; i++ ) tr_bencListAddStr( l, speed_units.units[i].name );
     1710}
     1711
  • trunk/libtransmission/utils.h

    r11209 r11228  
    591591char* tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen );
    592592
     593void tr_formatter_get_units( struct tr_benc * dict );
    593594
    594595/***
  • trunk/web/javascript/formatter.js

    r11202 r11228  
    1010        var speed_K = 1000;
    1111        var speed_B_str = 'B';
    12         var speed_K_str = 'kB/s';
     12        var speed_K_str = 'KB/s';
    1313        var speed_M_str = 'MB/s';
    1414        var speed_G_str = 'GB/s';
     
    1717        var size_K = 1024;
    1818        var size_B_str = 'B';
    19         var size_K_str = 'KiB';
    20         var size_M_str = 'MiB';
    21         var size_G_str = 'GiB';
    22         var size_T_str = 'TiB';
     19        var size_K_str = 'KB';
     20        var size_M_str = 'MB';
     21        var size_G_str = 'GB';
     22        var size_T_str = 'TB';
    2323
    2424        var mem_K = 1024;
    2525        var mem_B_str = 'B';
    26         var mem_K_str = 'KiB';
    27         var mem_M_str = 'MiB';
    28         var mem_G_str = 'GiB';
    29         var mem_T_str = 'TiB';
     26        var mem_K_str = 'KB';
     27        var mem_M_str = 'MB';
     28        var mem_G_str = 'GB';
     29        var mem_T_str = 'TB';
    3030
    3131        return {
    3232
     33                updateUnits: function( u )
     34                {
     35                        speed_K     = u['speed-bytes'];
     36                        speed_K_str = u['speed-units'][0];
     37                        speed_M_str = u['speed-units'][1];
     38                        speed_G_str = u['speed-units'][2];
     39                        speed_T_str = u['speed-units'][3];
     40
     41                        size_K     = u['size-bytes'];
     42                        size_K_str = u['size-units'][0];
     43                        size_M_str = u['size-units'][1];
     44                        size_G_str = u['size-units'][2];
     45                        size_T_str = u['size-units'][3];
     46
     47                        mem_K     = u['memory-bytes'];
     48                        mem_K_str = u['memory-units'][0];
     49                        mem_M_str = u['memory-units'][1];
     50                        mem_G_str = u['memory-units'][2];
     51                        mem_T_str = u['memory-units'][3];
     52                },
    3353
    3454                /*
  • trunk/web/javascript/transmission.js

    r11202 r11228  
    988988                var turtle_dn_limit_k = prefs[RPC._TurtleDownSpeedLimit];
    989989
     990                if( prefs.units )
     991                    Transmission.fmt.updateUnits( prefs.units );
     992
    990993                $('div.download_location input')[0].value = prefs[RPC._DownloadDir];
    991994                $('div.port input')[0].value              = prefs[RPC._PeerPort];
     
    10561059                //this._stats = stats;
    10571060
     1061                var fmt = Transmission.fmt;
    10581062                var session = stats["current-stats"];
    10591063                var total = stats["cumulative-stats"];
    10601064
    1061                 setInnerHTML( $('#stats_session_uploaded')[0], Transmission.fmt.size(session["uploadedBytes"]) );
    1062                 setInnerHTML( $('#stats_session_downloaded')[0], Transmission.fmt.size(session["downloadedBytes"]) );
    1063                 setInnerHTML( $('#stats_session_ratio')[0], Transmission.fmt.ratioString(Math.ratio(session["uploadedBytes"],session["downloadedBytes"])));
    1064                 setInnerHTML( $('#stats_session_duration')[0], Transmission.fmt.timeInterval(session["secondsActive"]) );
     1065                setInnerHTML( $('#stats_session_uploaded')[0], fmt.size(session["uploadedBytes"]) );
     1066                setInnerHTML( $('#stats_session_downloaded')[0], fmt.size(session["downloadedBytes"]) );
     1067                setInnerHTML( $('#stats_session_ratio')[0], fmt.ratioString(Math.ratio(session["uploadedBytes"],session["downloadedBytes"])));
     1068                setInnerHTML( $('#stats_session_duration')[0], fmt.timeInterval(session["secondsActive"]) );
    10651069                setInnerHTML( $('#stats_total_count')[0], total["sessionCount"] + " times" );
    1066                 setInnerHTML( $('#stats_total_uploaded')[0], Transmission.fmt.size(total["uploadedBytes"]) );
    1067                 setInnerHTML( $('#stats_total_downloaded')[0], Transmission.fmt.size(total["downloadedBytes"]) );
    1068                 setInnerHTML( $('#stats_total_ratio')[0], Transmission.fmt.ratioString(Math.ratio(total["uploadedBytes"],total["downloadedBytes"])));
    1069                 setInnerHTML( $('#stats_total_duration')[0], Transmission.fmt.timeInterval(total["secondsActive"]) );
     1070                setInnerHTML( $('#stats_total_uploaded')[0], fmt.size(total["uploadedBytes"]) );
     1071                setInnerHTML( $('#stats_total_downloaded')[0], fmt.size(total["downloadedBytes"]) );
     1072                setInnerHTML( $('#stats_total_ratio')[0], fmt.ratioString(Math.ratio(total["uploadedBytes"],total["downloadedBytes"])));
     1073                setInnerHTML( $('#stats_total_duration')[0], fmt.timeInterval(total["secondsActive"]) );
    10701074        },
    10711075
     
    13121316
    13131317                var private_string = '';
     1318                var fmt = Transmission.fmt;
    13141319                if( have_private && have_public ) private_string = 'Mixed';
    13151320                else if( have_private ) private_string = 'Private Torrent';
     
    13171322
    13181323                setInnerHTML( tab.name, name );
    1319                 setInnerHTML( tab.size, torrents.length ? Transmission.fmt.size( total_size ) : na );
     1324                setInnerHTML( tab.size, torrents.length ? fmt.size( total_size ) : na );
    13201325                setInnerHTML( tab.pieces, pieces );
    13211326                setInnerHTML( tab.hash, hash );
    13221327                setInnerHTML( tab.state, total_state );
    1323                 setInnerHTML( tab.download_speed, torrents.length ? Transmission.fmt.speedBps( total_download_speed ) : na );
    1324                 setInnerHTML( tab.upload_speed, torrents.length ? Transmission.fmt.speedBps( total_upload_speed ) : na );
    1325                 setInnerHTML( tab.uploaded, torrents.length ? Transmission.fmt.size( total_upload ) : na );
    1326                 setInnerHTML( tab.downloaded, torrents.length ? Transmission.fmt.size( total_download ) : na );
    1327                 setInnerHTML( tab.availability, torrents.length ? Transmission.fmt.percentString(Math.ratio( total_availability*100, sizeWhenDone )) + '%' : na );
    1328                 setInnerHTML( tab.ratio, torrents.length ? Transmission.fmt.ratioString(Math.ratio( total_upload, total_download )) : na );
    1329                 setInnerHTML( tab.have, torrents.length ? Transmission.fmt.size(total_completed) + ' (' + Transmission.fmt.size(total_verified) + ' verified)' : na );
     1328                setInnerHTML( tab.download_speed, torrents.length ? fmt.speedBps( total_download_speed ) : na );
     1329                setInnerHTML( tab.upload_speed, torrents.length ? fmt.speedBps( total_upload_speed ) : na );
     1330                setInnerHTML( tab.uploaded, torrents.length ? fmt.size( total_upload ) : na );
     1331                setInnerHTML( tab.downloaded, torrents.length ? fmt.size( total_download ) : na );
     1332                setInnerHTML( tab.availability, torrents.length ? fmt.percentString(Math.ratio( total_availability*100, sizeWhenDone )) + '%' : na );
     1333                setInnerHTML( tab.ratio, torrents.length ? fmt.ratioString(Math.ratio( total_upload, total_download )) : na );
     1334                setInnerHTML( tab.have, torrents.length ? fmt.size(total_completed) + ' (' + fmt.size(total_verified) + ' verified)' : na );
    13301335                setInnerHTML( tab.upload_to, torrents.length ? total_upload_peers : na );
    13311336                setInnerHTML( tab.download_from, torrents.length ? total_download_peers : na );
    13321337                setInnerHTML( tab.secure, private_string );
    13331338                setInnerHTML( tab.creator_date, date_created );
    1334                 setInnerHTML( tab.progress, torrents.length ? Transmission.fmt.percentString(Math.ratio( sizeDone*100, sizeWhenDone )) + '%' : na );
     1339                setInnerHTML( tab.progress, torrents.length ? fmt.percentString(Math.ratio( sizeDone*100, sizeWhenDone )) + '%' : na );
    13351340                setInnerHTML( tab.comment, comment == na ? comment : comment.replace(/\//g, '/&#8203;') );
    13361341                setInnerHTML( tab.creator, creator );
     
    13671372                var tr = this;
    13681373                var html = [ ];
     1374                var fmt = Transmission.fmt;
    13691375                var torrents = this.getSelectedTorrents( );
    13701376                if( $(this._inspector_peers_list).is(':visible') ) {
     
    13921398                                        html.push( '<tr class="inspector_peer_entry ', parity, '">',
    13931399                                                   '<td>', (peer.isEncrypted ? '<img src="images/graphics/lock_icon.png" alt="Encrypted"/>' : ''), '</td>',
    1394                                                    '<td>', ( peer.rateToPeer ? Transmission.fmt.speedBps(peer.rateToPeer) : '' ), '</td>',
    1395                                                    '<td>', ( peer.rateToClient ? Transmission.fmt.speedBps(peer.rateToClient) : '' ), '</td>',
     1400                                                   '<td>', ( peer.rateToPeer ? fmt.speedBps(peer.rateToPeer) : '' ), '</td>',
     1401                                                   '<td>', ( peer.rateToClient ? fmt.speedBps(peer.rateToClient) : '' ), '</td>',
    13961402                                                   '<td class="percentCol">', Math.floor(peer.progress*100), '%', '</td>',
    13971403                                                   '<td>', peer.flagStr, '</td>',
Note: See TracChangeset for help on using the changeset viewer.