Changeset 10937


Ignore:
Timestamp:
Jul 4, 2010, 6:07:21 AM (12 years ago)
Author:
charles
Message:

(trunk) #3045 "speed units" -- change the public API of libtransmission based on feedback from livings

Location:
trunk
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/cli.c

    r10931 r10937  
    158158        char ratioStr[80];
    159159
    160         tr_formatter_speed( upStr, st->pieceUploadSpeed_Bps, sizeof( upStr ) );
    161         tr_formatter_speed( dnStr, st->pieceDownloadSpeed_Bps, sizeof( dnStr ) );
     160        tr_formatter_speed_KBps( upStr, st->pieceUploadSpeed_KBps, sizeof( upStr ) );
     161        tr_formatter_speed_KBps( dnStr, st->pieceDownloadSpeed_KBps, sizeof( dnStr ) );
    162162        tr_strlratio( ratioStr, st->ratio, sizeof( ratioStr ) );
    163163
     
    177177        char ratioStr[80];
    178178
    179         tr_formatter_speed( upStr, st->pieceUploadSpeed_Bps, sizeof( upStr ) );
     179        tr_formatter_speed_KBps( upStr, st->pieceUploadSpeed_KBps, sizeof( upStr ) );
    180180        tr_strlratio( ratioStr, st->ratio, sizeof( ratioStr ) );
    181181
     
    359359            case 'B': tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, FALSE );
    360360                      break;
    361             case 'd': tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_Bps, atoi( optarg ) * SPEED_K );
     361            case 'd': tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_KBps, atoi( optarg ) );
    362362                      tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, TRUE );
    363363                      break;
     
    377377            case 't': tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_SOCKET_TOS, atoi( optarg ) );
    378378                      break;
    379             case 'u': tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_Bps, atoi( optarg ) * SPEED_K );
     379            case 'u': tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_KBps, atoi( optarg ) );
    380380                      tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED, TRUE );
    381381                      break;
  • trunk/daemon/remote.c

    r10931 r10937  
    141141
    142142static char*
    143 strlratio( char * buf, double numerator, double denominator, size_t buflen )
     143strlratio( char * buf, int64_t numerator, int64_t denominator, size_t buflen )
    144144{
    145145    double ratio;
    146146
    147     if( denominator )
    148         ratio = numerator / denominator;
    149     else if( numerator )
     147    if( denominator != 0 )
     148        ratio = numerator / (double)denominator;
     149    else if( numerator != 0 )
    150150        ratio = TR_RATIO_INF;
    151151    else
     
    161161        tr_strlcpy( buf, "None", buflen );
    162162    else
    163         tr_formatter_mem( buf, bytes, buflen );
     163        tr_formatter_mem_B( buf, bytes, buflen );
    164164
    165165    return buf;
     
    172172        tr_strlcpy( buf, "None", buflen );
    173173    else
    174         tr_formatter_size( buf, bytes, buflen );
    175 
    176     return buf;
    177 }
    178 
    179 static char*
    180 strlspeed( char * buf, int64_t bytes_per_second, size_t buflen )
    181 {
    182     if( !bytes_per_second )
    183         tr_strlcpy( buf, "None", buflen );
    184     else
    185         tr_formatter_speed( buf, bytes_per_second, buflen );
     174        tr_formatter_size_B( buf, bytes, buflen );
    186175
    187176    return buf;
     
    832821                printf( "  ETA: %s\n", tr_strltime( buf, i, sizeof( buf ) ) );
    833822            if( tr_bencDictFindInt( t, "rateDownload", &i ) )
    834                 printf( "  Download Speed: %s\n", strlspeed( buf, i, sizeof( buf ) ) );
     823                printf( "  Download Speed: %s\n", tr_formatter_speed_KBps( buf, i, sizeof( buf ) ) );
    835824            if( tr_bencDictFindInt( t, "rateUpload", &i ) )
    836                 printf( "  Upload Speed: %s\n", strlspeed( buf, i, sizeof( buf ) ) );
     825                printf( "  Upload Speed: %s\n", tr_formatter_speed_KBps( buf, i, sizeof( buf ) ) );
    837826            if( tr_bencDictFindInt( t, "haveUnchecked", &i )
    838827              && tr_bencDictFindInt( t, "haveValid", &j ) )
     
    11071096                printf( "  Download Limit: " );
    11081097                if( boolVal )
    1109                     printf( "%s\n", strlspeed( buf, i, sizeof( buf ) ) );
     1098                    printf( "%s\n", tr_formatter_speed_KBps( buf, i, sizeof( buf ) ) );
    11101099                else
    11111100                    printf( "Unlimited\n" );
     
    11161105                printf( "  Upload Limit: " );
    11171106                if( boolVal )
    1118                     printf( "%s\n", strlspeed( buf, i, sizeof( buf ) ) );
     1107                    printf( "%s\n", tr_formatter_speed_KBps( buf, i, sizeof( buf ) ) );
    11191108                else
    11201109                    printf( "Unlimited\n" );
     
    12411230            printf( "%-20s  %-12s  %-5.1f %6.1f  %6.1f  %s\n",
    12421231                    address, flagstr, (progress*100.0),
    1243                     rateToClient / (double)SPEED_K,
    1244                     rateToPeer / (double)SPEED_K,
     1232                    (double)rateToClient,
     1233                    (double)rateToPeer,
    12451234                    client );
    12461235        }
     
    14001389        if( tr_bencDictFindStr( args,  TR_PREFS_KEY_ENCRYPTION, &str ) )
    14011390            printf( "  Encryption: %s\n", str );
    1402         if( tr_bencDictFindInt( args, TR_PREFS_KEY_MAX_CACHE_SIZE, &i ) )
    1403             printf( "  Maximum memory cache size: %s\n", strlsize( buf, i, sizeof( buf ) ) );
     1391        if( tr_bencDictFindInt( args, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, &i ) )
     1392            printf( "  Maximum memory cache size: %s\n", tr_formatter_mem_MB( buf, i, sizeof( buf ) ) );
    14041393        printf( "\n" );
    14051394
     
    14091398            double seedRatioLimit;
    14101399
    1411             if( tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps, &altDown ) &&
     1400            if( tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, &altDown ) &&
    14121401                tr_bencDictFindBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, &altEnabled ) &&
    14131402                tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, &altBegin ) &&
     
    14151404                tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_TIME_END, &altEnd ) &&
    14161405                tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_TIME_DAY, &altDay ) &&
    1417                 tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_UP_Bps, &altUp ) &&
     1406                tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_UP_KBps, &altUp ) &&
    14181407                tr_bencDictFindInt ( args, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, &peerLimit ) &&
    1419                 tr_bencDictFindInt ( args, TR_PREFS_KEY_DSPEED_Bps, &downLimit ) &&
     1408                tr_bencDictFindInt ( args, TR_PREFS_KEY_DSPEED_KBps, &downLimit ) &&
    14201409                tr_bencDictFindBool( args, TR_PREFS_KEY_DSPEED_ENABLED, &downEnabled ) &&
    1421                 tr_bencDictFindInt ( args, TR_PREFS_KEY_USPEED_Bps, &upLimit ) &&
     1410                tr_bencDictFindInt ( args, TR_PREFS_KEY_USPEED_KBps, &upLimit ) &&
    14221411                tr_bencDictFindBool( args, TR_PREFS_KEY_USPEED_ENABLED, &upEnabled ) &&
    14231412                tr_bencDictFindReal( args, "seedRatioLimit", &seedRatioLimit ) &&
     
    14381427
    14391428                if( altEnabled )
    1440                     strlspeed( buf, altUp, sizeof( buf ) );
     1429                    tr_formatter_speed_KBps( buf, altUp, sizeof( buf ) );
    14411430                else if( upEnabled )
    1442                     strlspeed( buf, upLimit, sizeof( buf ) );
     1431                    tr_formatter_speed_KBps( buf, upLimit, sizeof( buf ) );
    14431432                else
    14441433                    tr_strlcpy( buf, "Unlimited", sizeof( buf ) );
     
    14461435                        buf,
    14471436                        upEnabled ? "Enabled" : "Disabled",
    1448                         strlspeed( buf2, upLimit, sizeof( buf2 ) ),
     1437                        tr_formatter_speed_KBps( buf2, upLimit, sizeof( buf2 ) ),
    14491438                        altEnabled ? "Enabled" : "Disabled",
    1450                         strlspeed( buf3, altUp, sizeof( buf3 ) ) );
     1439                        tr_formatter_speed_KBps( buf3, altUp, sizeof( buf3 ) ) );
    14511440
    14521441                if( altEnabled )
    1453                     strlspeed( buf, altDown, sizeof( buf ) );
     1442                    tr_formatter_speed_KBps( buf, altDown, sizeof( buf ) );
    14541443                else if( downEnabled )
    1455                     strlspeed( buf, downLimit, sizeof( buf ) );
     1444                    tr_formatter_speed_KBps( buf, downLimit, sizeof( buf ) );
    14561445                else
    14571446                    tr_strlcpy( buf, "Unlimited", sizeof( buf ) );
     
    14591448                        buf,
    14601449                        downEnabled ? "Enabled" : "Disabled",
    1461                         strlspeed( buf2, downLimit, sizeof( buf2 ) ),
     1450                        tr_formatter_speed_KBps( buf2, downLimit, sizeof( buf2 ) ),
    14621451                        altEnabled ? "Enabled" : "Disabled",
    1463                         strlspeed( buf2, altDown, sizeof( buf2 ) ) );
     1452                        tr_formatter_speed_KBps( buf2, altDown, sizeof( buf2 ) ) );
    14641453
    14651454                if( altTimeEnabled ) {
     
    18461835                case 971: tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, FALSE );
    18471836                          break;
    1848                 case 972: tr_bencDictAddInt( args, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps, numarg( optarg ) * SPEED_K );
    1849                           break;
    1850                 case 973: tr_bencDictAddInt( args, TR_PREFS_KEY_ALT_SPEED_UP_Bps, numarg( optarg ) * SPEED_K );
     1837                case 972: tr_bencDictAddInt( args, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, numarg( optarg ) );
     1838                          break;
     1839                case 973: tr_bencDictAddInt( args, TR_PREFS_KEY_ALT_SPEED_UP_KBps, numarg( optarg ) );
    18511840                          break;
    18521841                case 974: tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, TRUE );
     
    18651854                case 'C': tr_bencDictAddBool( args, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, FALSE );
    18661855                          break;
    1867                 case 'e': tr_bencDictAddReal( args, TR_PREFS_KEY_MAX_CACHE_SIZE, atof(optarg) * MEM_K * MEM_K );
     1856                case 'e': tr_bencDictAddReal( args, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, atof(optarg) );
    18681857                          break;
    18691858                case 910: tr_bencDictAddStr( args, TR_PREFS_KEY_ENCRYPTION, "required" );
     
    19231912            {
    19241913                case 'd': if( targs ) {
    1925                               tr_bencDictAddInt( targs, "downloadLimit", numarg( optarg ) * SPEED_K );
     1914                              tr_bencDictAddInt( targs, "downloadLimit", numarg( optarg ) );
    19261915                              tr_bencDictAddBool( targs, "downloadLimited", TRUE );
    19271916                          } else {
    1928                               tr_bencDictAddInt( sargs, TR_PREFS_KEY_DSPEED_Bps, numarg( optarg ) * SPEED_K );
     1917                              tr_bencDictAddInt( sargs, TR_PREFS_KEY_DSPEED_KBps, numarg( optarg ) );
    19291918                              tr_bencDictAddBool( sargs, TR_PREFS_KEY_DSPEED_ENABLED, TRUE );
    19301919                          }
     
    19361925                          break;
    19371926                case 'u': if( targs ) {
    1938                               tr_bencDictAddInt( targs, "uploadLimit", numarg( optarg ) * SPEED_K );
     1927                              tr_bencDictAddInt( targs, "uploadLimit", numarg( optarg ) );
    19391928                              tr_bencDictAddBool( targs, "uploadLimited", TRUE );
    19401929                          } else {
    1941                               tr_bencDictAddInt( sargs, TR_PREFS_KEY_USPEED_Bps, numarg( optarg ) * SPEED_K );
     1930                              tr_bencDictAddInt( sargs, TR_PREFS_KEY_USPEED_KBps, numarg( optarg ) );
    19421931                              tr_bencDictAddBool( sargs, TR_PREFS_KEY_USPEED_ENABLED, TRUE );
    19431932                          }
  • trunk/doc/rpc-spec.txt

    r10931 r10937  
    9090   ----------------------+-------------------------------------------------
    9191   "bandwidthPriority"   | number     this torrent's bandwidth tr_priority_t
    92    "downloadLimit"       | number     maximum download speed (bytes per second)
     92   "downloadLimit"       | number     maximum download speed (KBps)
    9393   "downloadLimited"     | boolean    true if "downloadLimit" is honored
    9494   "files-wanted"        | array      indices of file(s) to download
     
    106106   "trackerEdit"         | object     (see below)
    107107   "trackerRemove"       | object     (see below)
    108    "uploadLimit"         | number     maximum upload speed (bytes per second)
     108   "uploadLimit"         | number     maximum upload speed (KBps)
    109109   "uploadLimited"       | boolean    true if "uploadLimit" is honored
    110110                         |
     
    419419   string                        | value type & description
    420420   ------------------------------+-------------------------------------------------
    421    "alt-speed-down"              | number     max global download speed (in bytes per second)
     421   "alt-speed-down"              | number     max global download speed (KBps)
    422422   "alt-speed-enabled"           | boolean    true means use the alt speeds
    423423   "alt-speed-time-begin"        | number     when to turn on alt speeds (units: minutes after midnight)
     
    425425   "alt-speed-time-end"          | number     when to turn off alt speeds (units: same)
    426426   "alt-speed-time-day"          | number     what day(s) to turn on alt speeds (look at tr_sched_day)
    427    "alt-speed-up"                | number     max global upload speed (in bytes per second)
     427   "alt-speed-up"                | number     max global upload speed (KBps)
    428428   "blocklist-enabled"           | boolean    true means enabled
    429429   "blocklist-size"              | number     number of rules in the blocklist
    430    "cache-size"                  | number     maximum size (in bytes) of the disk cache
     430   "cache-size"                  | number     maximum size of the disk cache (MB)
    431431   "config-dir"                  | string     location of transmission's configuration directory
    432432   "download-dir"                | string     default path to download torrents
     
    449449   "seedRatioLimit"              | double     the default seed ratio for torrents to use
    450450   "seedRatioLimited"            | boolean    true if seedRatioLimit is honored by default
    451    "speed-limit-down"            | number     max global download speed (in bytes per second)
     451   "speed-limit-down"            | number     max global download speed (KBps)
    452452   "speed-limit-down-enabled"    | boolean    true means enabled
    453    "speed-limit-up"              | number     max global upload speed (in bytes per second)
     453   "speed-limit-up"              | number     max global upload speed (KBps)
    454454   "speed-limit-up-enabled"      | boolean    true means enabled
    455455   "start-added-torrents"        | boolean    true means added torrents will be started right away
     
    629629         |         | yes       | torrent-get    | new arg "isFinished"
    630630   ------+---------+-----------+----------------+-------------------------------
    631    10    | 2.10    |        NO | torrent-get    | arg "downloadLimit"    is now bytes per second
    632          |         |        NO | torrent-get    | arg "uploadLimit"      is now bytes per second
    633          |         |        NO | session-get    | arg "speed-limit-down" is now bytes per second
    634          |         |        NO | session-get    | arg "speed-limit-up"   is now bytes per second
    635          |         |        NO | session-get    | arg "alt-speed-up"     is now bytes per second
    636          |         |        NO | session-get    | arg "alt-speed-down"   is now bytes per second
    637          |         | yes       | session-get    | new arg "cache-size"
     631   10    | 2.10    | yes       | session-get    | new arg "cache-size"
    638632         |         | yes       | session-set    | new arg "trash-original-torrent-files"
    639633         |         | yes       | session-get    | new arg "start-added-torrents"
  • trunk/gtk/details.c

    r10931 r10937  
    220220    /* downLimitSpin */
    221221    if( n ) {
    222         const int baseline = tr_torrentGetSpeedLimit_Bps( torrents[0], TR_DOWN ) / speed_K;
     222        const int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_DOWN );
    223223        int i;
    224224        for( i=1; i<n; ++i )
    225             if( baseline != ( tr_torrentGetSpeedLimit_Bps( torrents[i], TR_DOWN )  / speed_K ) )
     225            if( baseline != ( tr_torrentGetSpeedLimit_KBps( torrents[i], TR_DOWN ) ) )
    226226                break;
    227227        if( i == n )
     
    244244    /* upLimitSpin */
    245245    if( n ) {
    246         const int baseline = tr_torrentGetSpeedLimit_Bps( torrents[0], TR_UP ) / speed_K;
     246        const int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_UP );
    247247        int i;
    248248        for( i=1; i<n; ++i )
    249             if( baseline != ( tr_torrentGetSpeedLimit_Bps( torrents[i], TR_UP ) / speed_K ) )
     249            if( baseline != ( tr_torrentGetSpeedLimit_KBps( torrents[i], TR_UP ) ) )
    250250                break;
    251251        if( i == n )
     
    601601    const char * stateString;
    602602    char buf[512];
    603     double available = 0;
    604     double sizeWhenDone = 0;
     603    uint64_t available = 0;
     604    uint64_t sizeWhenDone = 0;
    605605    const tr_stat ** stats = g_new( const tr_stat*, n );
    606606    const tr_info ** infos = g_new( const tr_info*, n );
     
    762762        else if( pieceSize >= 0 ) {
    763763            char piecebuf[128];
    764             tr_formatter_mem( piecebuf, pieceSize, sizeof( piecebuf ) );
     764            tr_formatter_mem_B( piecebuf, pieceSize, sizeof( piecebuf ) );
    765765            g_snprintf( buf, sizeof( buf ),
    766766                        ngettext( "%1$s (%2$'d piece @ %3$s)",
     
    783783        str = none;
    784784    else {
    785         double leftUntilDone = 0;
    786         double haveUnchecked = 0;
    787         double haveValid = 0;
    788         double verifiedPieces = 0;
     785        uint64_t leftUntilDone = 0;
     786        uint64_t haveUnchecked = 0;
     787        uint64_t haveValid = 0;
     788        uint32_t verifiedPieces = 0;
    789789        for( i=0; i<n; ++i ) {
    790790            const tr_stat * st = stats[i];
    791             const double v = st->haveValid;
    792791            haveUnchecked += st->haveUnchecked;
    793             haveValid += v;
    794             verifiedPieces += v / tr_torrentInfo(torrents[i])->pieceSize;
     792            haveValid += st->haveValid;
     793            verifiedPieces += st->haveValid / tr_torrentInfo(torrents[i])->pieceSize;
    795794            sizeWhenDone += st->sizeWhenDone;
    796795            leftUntilDone += st->leftUntilDone;
     
    10451044    WEBSEED_COL_WAS_UPDATED,
    10461045    WEBSEED_COL_URL,
    1047     WEBSEED_COL_DOWNLOAD_RATE_INT,
     1046    WEBSEED_COL_DOWNLOAD_RATE_DOUBLE,
    10481047    WEBSEED_COL_DOWNLOAD_RATE_STRING,
    10491048    N_WEBSEED_COLS
     
    10561055    {
    10571056        case WEBSEED_COL_URL: return _( "Webseeds" );
    1058         case WEBSEED_COL_DOWNLOAD_RATE_INT:
     1057        case WEBSEED_COL_DOWNLOAD_RATE_DOUBLE:
    10591058        case WEBSEED_COL_DOWNLOAD_RATE_STRING: return _( "Down" );
    10601059        default: return "";
     
    10791078    PEER_COL_ADDRESS,
    10801079    PEER_COL_ADDRESS_COLLATED,
    1081     PEER_COL_DOWNLOAD_RATE_INT,
     1080    PEER_COL_DOWNLOAD_RATE_DOUBLE,
    10821081    PEER_COL_DOWNLOAD_RATE_STRING,
    1083     PEER_COL_UPLOAD_RATE_INT,
     1082    PEER_COL_UPLOAD_RATE_DOUBLE,
    10841083    PEER_COL_UPLOAD_RATE_STRING,
    10851084    PEER_COL_CLIENT,
     
    11091108        case PEER_COL_ADDRESS: return _( "Address" );
    11101109        case PEER_COL_DOWNLOAD_RATE_STRING:
    1111         case PEER_COL_DOWNLOAD_RATE_INT: return _( "Down" );
     1110        case PEER_COL_DOWNLOAD_RATE_DOUBLE: return _( "Down" );
    11121111        case PEER_COL_UPLOAD_RATE_STRING:
    1113         case PEER_COL_UPLOAD_RATE_INT: return _( "Up" );
     1112        case PEER_COL_UPLOAD_RATE_DOUBLE: return _( "Up" );
    11141113        case PEER_COL_CLIENT: return _( "Client" );
    11151114        case PEER_COL_PROGRESS: return _( "%" );
     
    11391138                               G_TYPE_STRING,   /* address */
    11401139                               G_TYPE_STRING,   /* collated address */
    1141                                G_TYPE_INT,      /* download speed int */
     1140                               G_TYPE_DOUBLE,   /* download speed int */
    11421141                               G_TYPE_STRING,   /* download speed string */
    1143                                G_TYPE_INT,      /* upload speed int */
     1142                               G_TYPE_DOUBLE,   /* upload speed int */
    11441143                               G_TYPE_STRING,   /* upload speed string  */
    11451144                               G_TYPE_STRING,   /* client */
     
    12031202    char cancelled_by_client[64];
    12041203
    1205     if( peer->rateToPeer_Bps > 0 )
    1206         tr_formatter_speed( up_speed, peer->rateToPeer_Bps, sizeof( up_speed ) );
     1204    if( peer->rateToPeer_KBps > 0.01 )
     1205        tr_formatter_speed_KBps( up_speed, peer->rateToPeer_KBps, sizeof( up_speed ) );
    12071206    else
    12081207        *up_speed = '\0';
    12091208
    1210     if( peer->rateToClient_Bps > 0 )
    1211         tr_formatter_speed( down_speed, peer->rateToClient_Bps, sizeof( down_speed ) );
     1209    if( peer->rateToClient_KBps > 0 )
     1210        tr_formatter_speed_KBps( down_speed, peer->rateToClient_KBps, sizeof( down_speed ) );
    12121211    else
    12131212        *down_speed = '\0';
     
    12491248                        PEER_COL_DOWNLOAD_REQUEST_COUNT_INT, peer->pendingReqsToPeer,
    12501249                        PEER_COL_DOWNLOAD_REQUEST_COUNT_STRING, down_count,
    1251                         PEER_COL_DOWNLOAD_RATE_INT, peer->rateToClient_Bps,
     1250                        PEER_COL_DOWNLOAD_RATE_DOUBLE, peer->rateToClient_KBps,
    12521251                        PEER_COL_DOWNLOAD_RATE_STRING, down_speed,
    1253                         PEER_COL_UPLOAD_RATE_INT, peer->rateToPeer_Bps,
     1252                        PEER_COL_UPLOAD_RATE_DOUBLE, peer->rateToPeer_KBps,
    12541253                        PEER_COL_UPLOAD_RATE_STRING, up_speed,
    12551254                        PEER_COL_STATUS, peer->flagStr,
     
    13971396        const tr_torrent * tor = torrents[i];
    13981397        const tr_info * inf = tr_torrentInfo( tor );
    1399         int * speeds_Bps = tr_torrentWebSpeeds_Bps( tor );
     1398        double * speeds_KBps = tr_torrentWebSpeeds_KBps( tor );
    14001399        for( j=0; j<inf->webseedCount; ++j ) {
    14011400            char buf[128];
     
    14081407            p = gtk_tree_row_reference_get_path( ref );
    14091408            gtk_tree_model_get_iter( model, &iter, p );
    1410             if( speeds_Bps[j] > 0 )
    1411                 tr_formatter_speed( buf, speeds_Bps[j], sizeof( buf ) );
     1409            if( speeds_KBps[j] > 0 )
     1410                tr_formatter_speed_Bps( buf, speeds_KBps[j], sizeof( buf ) );
    14121411            else
    14131412                *buf = '\0';
    1414             gtk_list_store_set( store, &iter, WEBSEED_COL_DOWNLOAD_RATE_INT, speeds_Bps[j],
     1413            gtk_list_store_set( store, &iter, WEBSEED_COL_DOWNLOAD_RATE_DOUBLE, speeds_KBps[j],
    14151414                                              WEBSEED_COL_DOWNLOAD_RATE_STRING, buf,
    14161415                                              WEBSEED_COL_WAS_UPDATED, TRUE,
     
    14181417            gtk_tree_path_free( p );
    14191418        }
    1420         tr_free( speeds_Bps );
     1419        tr_free( speeds_KBps );
    14211420    }
    14221421
     
    16121611                g_object_set( G_OBJECT( r ), "xalign", 1.0f, NULL );
    16131612                c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
    1614                 sort_col = PEER_COL_DOWNLOAD_RATE_INT;
     1613                sort_col = PEER_COL_DOWNLOAD_RATE_DOUBLE;
    16151614                break;
    16161615            case PEER_COL_UPLOAD_RATE_STRING:
     
    16181617                g_object_set( G_OBJECT( r ), "xalign", 1.0f, NULL );
    16191618                c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
    1620                 sort_col = PEER_COL_UPLOAD_RATE_INT;
     1619                sort_col = PEER_COL_UPLOAD_RATE_DOUBLE;
    16211620                break;
    16221621
     
    16871686    r = gtk_cell_renderer_text_new( );
    16881687    c = gtk_tree_view_column_new_with_attributes( str, r, "text", WEBSEED_COL_DOWNLOAD_RATE_STRING, NULL );
    1689     gtk_tree_view_column_set_sort_column_id( c, WEBSEED_COL_DOWNLOAD_RATE_INT );
     1688    gtk_tree_view_column_set_sort_column_id( c, WEBSEED_COL_DOWNLOAD_RATE_DOUBLE );
    16901689    gtk_tree_view_append_column( GTK_TREE_VIEW( v ), c );
    16911690
  • trunk/gtk/main.c

    r10931 r10937  
    12041204        tr_sessionLimitSpeed( tr, TR_DOWN, pref_flag_get( key ) );
    12051205    }
    1206     else if( !strcmp( key, TR_PREFS_KEY_DSPEED_Bps ) )
    1207     {
    1208         tr_sessionSetSpeedLimit_Bps( tr, TR_DOWN, pref_int_get( key ) );
     1206    else if( !strcmp( key, TR_PREFS_KEY_DSPEED_KBps ) )
     1207    {
     1208        tr_sessionSetSpeedLimit_KBps( tr, TR_DOWN, pref_int_get( key ) );
    12091209    }
    12101210    else if( !strcmp( key, TR_PREFS_KEY_USPEED_ENABLED ) )
     
    12121212        tr_sessionLimitSpeed( tr, TR_UP, pref_flag_get( key ) );
    12131213    }
    1214     else if( !strcmp( key, TR_PREFS_KEY_USPEED_Bps ) )
    1215     {
    1216         tr_sessionSetSpeedLimit_Bps( tr, TR_UP, pref_int_get( key ) );
     1214    else if( !strcmp( key, TR_PREFS_KEY_USPEED_KBps ) )
     1215    {
     1216        tr_sessionSetSpeedLimit_KBps( tr, TR_UP, pref_int_get( key ) );
    12171217    }
    12181218    else if( !strcmp( key, TR_PREFS_KEY_RATIO_ENABLED ) )
     
    13001300        tr_sessionSetProxyPort( tr, pref_int_get( key ) );
    13011301    }
    1302     else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_UP_Bps ) )
    1303     {
    1304         tr_sessionSetAltSpeed_Bps( tr, TR_UP, pref_int_get( key ) );
    1305     }
    1306     else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps ) )
    1307     {
    1308         tr_sessionSetAltSpeed_Bps( tr, TR_DOWN, pref_int_get( key ) );
     1302    else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_UP_KBps ) )
     1303    {
     1304        tr_sessionSetAltSpeed_KBps( tr, TR_UP, pref_int_get( key ) );
     1305    }
     1306    else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps ) )
     1307    {
     1308        tr_sessionSetAltSpeed_KBps( tr, TR_DOWN, pref_int_get( key ) );
    13091309    }
    13101310    else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_ENABLED ) )
  • trunk/gtk/msgwin.c

    r10863 r10937  
    3838struct MsgData
    3939{
    40     TrCore *        core;
    41     GtkTreeView view;
    42     GtkListStore * store;
    43     GtkTreeModel * filter;
    44     GtkTreeModel * sort;
    45     int             maxLevel;
     40    TrCore        * core;
     41    GtkTreeView   * view;
     42    GtkListStore  * store;
     43    GtkTreeModel  * filter;
     44    GtkTreeModel  * sort;
     45    tr_msg_level    maxLevel;
    4646    gboolean        isPaused;
    4747    guint           refresh_tag;
  • trunk/gtk/torrent-cell-renderer.c

    r10931 r10937  
    155155getShortTransferString( const tr_torrent  * tor,
    156156                        const tr_stat     * torStat,
    157                         int                 uploadSpeed_Bps,
    158                         int                 downloadSpeed_Bps,
     157                        double              uploadSpeed_KBps,
     158                        double              downloadSpeed_KBps,
    159159                        char              * buf,
    160160                        size_t              buflen )
     
    166166
    167167    if( haveDown )
    168         tr_strlspeed( downStr, downloadSpeed_Bps, sizeof( downStr ) );
     168        tr_formatter_speed_KBps( downStr, downloadSpeed_KBps, sizeof( downStr ) );
    169169    if( haveUp )
    170         tr_strlspeed( upStr, uploadSpeed_Bps, sizeof( upStr ) );
     170        tr_formatter_speed_KBps( upStr, uploadSpeed_KBps, sizeof( upStr ) );
    171171
    172172    if( haveDown && haveUp )
     
    195195getShortStatusString( const tr_torrent  * tor,
    196196                      const tr_stat     * torStat,
    197                       int                 uploadSpeed_Bps,
    198                       int                 downloadSpeed_Bps )
     197                      double              uploadSpeed_KBps,
     198                      double              downloadSpeed_KBps )
    199199{
    200200    GString * gstr = g_string_new( NULL );
     
    229229                g_string_append( gstr, ", " );
    230230            }
    231             getShortTransferString( tor, torStat, uploadSpeed_Bps, downloadSpeed_Bps, buf, sizeof( buf ) );
     231            getShortTransferString( tor, torStat, uploadSpeed_KBps, downloadSpeed_KBps, buf, sizeof( buf ) );
    232232            g_string_append( gstr, buf );
    233233            break;
     
    244244getStatusString( const tr_torrent  * tor,
    245245                 const tr_stat     * torStat,
    246                  const int           uploadSpeed_Bps,
    247                  const int           downloadSpeed_Bps )
     246                 const double        uploadSpeed_KBps,
     247                 const double        downloadSpeed_KBps )
    248248{
    249249    const int isActive = torStat->activity != TR_STATUS_STOPPED;
     
    266266        case TR_STATUS_CHECK:
    267267        {
    268             char * pch = getShortStatusString( tor, torStat, uploadSpeed_Bps, downloadSpeed_Bps );
     268            char * pch = getShortStatusString( tor, torStat, uploadSpeed_KBps, downloadSpeed_KBps );
    269269            g_string_assign( gstr, pch );
    270270            g_free( pch );
     
    310310    {
    311311        char buf[256];
    312         getShortTransferString( tor, torStat, uploadSpeed_Bps, downloadSpeed_Bps, buf, sizeof( buf ) );
     312        getShortTransferString( tor, torStat, uploadSpeed_KBps, downloadSpeed_KBps, buf, sizeof( buf ) );
    313313        if( *buf )
    314314            g_string_append_printf( gstr, " - %s", buf );
     
    337337       the individual torrents' speeds and the status bar's overall speed
    338338       in sync even if they refresh at slightly different times */
    339     int upload_speed_Bps;
     339    double upload_speed_KBps;
    340340
    341341    /* @see upload_speed_Bps */
    342     int download_speed_Bps;
     342    double download_speed_KBps;
    343343
    344344    gboolean compact;
     
    398398    icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
    399399    name = tr_torrentInfo( tor )->name;
    400     status = getShortStatusString( tor, st, p->upload_speed_Bps, p->download_speed_Bps );
     400    status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    401401
    402402    /* get the idealized cell dimensions */
     
    456456    icon = get_icon( tor, FULL_ICON_SIZE, widget );
    457457    name = inf->name;
    458     status = getStatusString( tor, st, p->upload_speed_Bps, p->download_speed_Bps );
     458    status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    459459    progress = getProgressString( tor, inf, st );
    460460
     
    560560    icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
    561561    name = tr_torrentInfo( tor )->name;
    562     status = getShortStatusString( tor, st, p->upload_speed_Bps, p->download_speed_Bps );
     562    status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    563563
    564564    /* get the cell dimensions */
     
    664664    icon = get_icon( tor, FULL_ICON_SIZE, widget );
    665665    name = inf->name;
    666     status = getStatusString( tor, st, p->upload_speed_Bps, p->download_speed_Bps );
     666    status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    667667    progress = getProgressString( tor, inf, st );
    668668
     
    783783    switch( property_id )
    784784    {
    785         case P_TORRENT:        p->tor                = g_value_get_pointer( v ); break;
    786         case P_UPLOAD_SPEED:   p->upload_speed_Bps   = g_value_get_int( v ); break;
    787         case P_DOWNLOAD_SPEED: p->download_speed_Bps = g_value_get_int( v ); break;
    788         case P_BAR_HEIGHT:     p->bar_height         = g_value_get_int( v ); break;
    789         case P_COMPACT:        p->compact            = g_value_get_boolean( v ); break;
     785        case P_TORRENT:        p->tor                 = g_value_get_pointer( v ); break;
     786        case P_UPLOAD_SPEED:   p->upload_speed_KBps   = g_value_get_double( v ); break;
     787        case P_DOWNLOAD_SPEED: p->download_speed_KBps = g_value_get_double( v ); break;
     788        case P_BAR_HEIGHT:     p->bar_height          = g_value_get_int( v ); break;
     789        case P_COMPACT:        p->compact             = g_value_get_boolean( v ); break;
    790790        default: G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, pspec ); break;
    791791    }
     
    804804    {
    805805        case P_TORRENT:        g_value_set_pointer( v, p->tor ); break;
    806         case P_UPLOAD_SPEED:   g_value_set_int( v, p->upload_speed_Bps ); break;
    807         case P_DOWNLOAD_SPEED: g_value_set_int( v, p->download_speed_Bps ); break;
     806        case P_UPLOAD_SPEED:   g_value_set_double( v, p->upload_speed_KBps ); break;
     807        case P_DOWNLOAD_SPEED: g_value_set_double( v, p->download_speed_KBps ); break;
    808808        case P_BAR_HEIGHT:     g_value_set_int( v, p->bar_height ); break;
    809809        case P_COMPACT:        g_value_set_boolean( v, p->compact ); break;
     
    854854
    855855    g_object_class_install_property( gobject_class, P_UPLOAD_SPEED,
    856                                     g_param_spec_int( "piece-upload-speed", NULL,
    857                                                       "tr_stat.pieceUploadSpeed_Bps",
    858                                                       0, INT_MAX, 0,
    859                                                       G_PARAM_READWRITE ) );
     856                                    g_param_spec_double( "piece-upload-speed", NULL,
     857                                                         "tr_stat.pieceUploadSpeed_KBps",
     858                                                         0, INT_MAX, 0,
     859                                                         G_PARAM_READWRITE ) );
    860860
    861861    g_object_class_install_property( gobject_class, P_DOWNLOAD_SPEED,
    862                                     g_param_spec_int( "piece-download-speed", NULL,
    863                                                       "tr_stat.pieceDownloadSpeed_Bps",
    864                                                       0, INT_MAX, 0,
    865                                                       G_PARAM_READWRITE ) );
     862                                    g_param_spec_double( "piece-download-speed", NULL,
     863                                                         "tr_stat.pieceDownloadSpeed_KBps",
     864                                                         0, INT_MAX, 0,
     865                                                         G_PARAM_READWRITE ) );
    866866
    867867    g_object_class_install_property( gobject_class, P_BAR_HEIGHT,
  • trunk/gtk/tr-core.c

    r10931 r10937  
    777777                      TR_TORRENT_TYPE,  /* TrTorrent object */
    778778                      G_TYPE_POINTER,   /* tr_torrent* */
    779                       G_TYPE_INT,       /* tr_stat.pieceUploadSpeed_Bps */
    780                       G_TYPE_INT,       /* tr_stat.pieceDownloadSpeed_Bps */
     779                      G_TYPE_DOUBLE,    /* tr_stat.pieceUploadSpeed_KBps */
     780                      G_TYPE_DOUBLE,    /* tr_stat.pieceDownloadSpeed_KBps */
    781781                      G_TYPE_INT };     /* tr_stat.status */
    782782
     
    921921                                       MC_TORRENT,       gtor,
    922922                                       MC_TORRENT_RAW,   tor,
    923                                        MC_SPEED_UP,      st->pieceUploadSpeed_Bps,
    924                                        MC_SPEED_DOWN,    st->pieceDownloadSpeed_Bps,
     923                                       MC_SPEED_UP,      st->pieceUploadSpeed_KBps,
     924                                       MC_SPEED_DOWN,    st->pieceDownloadSpeed_KBps,
    925925                                       MC_ACTIVITY,      st->activity,
    926926                                       -1 );
     
    13231323{
    13241324    int oldActivity, newActivity;
    1325     int oldUpSpeed, newUpSpeed;
    1326     int oldDownSpeed, newDownSpeed;
     1325    double oldUpSpeed, newUpSpeed;
     1326    double oldDownSpeed, newDownSpeed;
    13271327    const tr_stat * st;
    13281328    TrTorrent * gtor;
     
    13391339    st = tr_torrentStat( tr_torrent_handle( gtor ) );
    13401340    newActivity = st->activity;
    1341     newUpSpeed = st->pieceUploadSpeed_Bps;
    1342     newDownSpeed = st->pieceDownloadSpeed_Bps;
     1341    newUpSpeed = st->pieceUploadSpeed_KBps;
     1342    newDownSpeed = st->pieceDownloadSpeed_KBps;
    13431343
    13441344    /* updating the model triggers off resort/refresh,
    13451345       so don't do it unless something's actually changed... */
    1346     if( ( newActivity  != oldActivity  ) ||
    1347         ( newUpSpeed   != oldUpSpeed   ) ||
    1348         ( newDownSpeed != oldDownSpeed ) )
     1346    if( ( newActivity  != oldActivity  )
     1347        || gtr_compare_double( newUpSpeed, oldUpSpeed, 3 )
     1348        || gtr_compare_double( newDownSpeed, oldDownSpeed, 3 ) )
    13491349    {
    13501350        gtk_list_store_set( GTK_LIST_STORE( model ), iter,
     
    15761576    const double oldval = pref_double_get( key );
    15771577
    1578     if( oldval != newval )
     1578    if( gtr_compare_double( oldval, newval, 4 ) )
    15791579    {
    15801580        pref_double_set( key, newval );
  • trunk/gtk/tr-icon.c

    r10931 r10937  
    6868tr_icon_refresh( gpointer vicon )
    6969{
    70     int Bps;
    71     int limit;
     70    double KBps;
     71    double limit;
    7272    char up[64];
    7373    char upLimit[64];
     
    8080
    8181    /* up */
    82     Bps = tr_sessionGetRawSpeed_Bps( session, TR_UP );
    83     if( Bps < 1 )
     82    KBps = tr_sessionGetRawSpeed_KBps( session, TR_UP );
     83    if( KBps < 0.001 )
    8484        g_strlcpy( up, idle, sizeof( up ) );
    8585    else
    86         tr_formatter_speed( up, Bps, sizeof( up ) );
     86        tr_formatter_speed_KBps( up, KBps, sizeof( up ) );
    8787
    8888    /* up limit */
    89     if( !tr_sessionGetActiveSpeedLimit_Bps( session, TR_UP, &limit ) )
     89    if( !tr_sessionGetActiveSpeedLimit_KBps( session, TR_UP, &limit ) )
    9090        *upLimit = '\0';
    9191    else {
    9292        char buf[64];
    93         tr_strlspeed( buf, limit, sizeof( buf ) );
     93        tr_formatter_speed_KBps( buf, limit, sizeof( buf ) );
    9494        g_snprintf( upLimit, sizeof( upLimit ), _( "(Limit: %s)" ), buf );
    9595    }
    9696
    9797    /* down */
    98     Bps = tr_sessionGetRawSpeed_Bps( session, TR_DOWN );
    99     if( Bps < 1 )
     98    KBps = tr_sessionGetRawSpeed_KBps( session, TR_DOWN );
     99    if( KBps < 0.001 )
    100100        g_strlcpy( down, idle, sizeof( down ) );
    101101    else
    102         tr_formatter_speed( down, Bps, sizeof( down ) );
     102        tr_formatter_speed_KBps( down, KBps, sizeof( down ) );
    103103
    104104    /* down limit */
    105     if( !tr_sessionGetActiveSpeedLimit_Bps( session, TR_DOWN, &limit ) )
     105    if( !tr_sessionGetActiveSpeedLimit_KBps( session, TR_DOWN, &limit ) )
    106106        *downLimit = '\0';
    107107    else {
    108108        char buf[64];
    109         tr_strlspeed( buf, limit, sizeof( buf ) );
     109        tr_formatter_speed_KBps( buf, limit, sizeof( buf ) );
    110110        g_snprintf( downLimit, sizeof( downLimit ), _( "(Limit: %s)" ), buf );
    111111    }
  • trunk/gtk/tr-prefs.c

    r10931 r10937  
    3131**/
    3232
    33 #define MULTIPLIER_KEY "multiplier-key"
    3433#define PREF_KEY "pref-key"
    3534
     
    107106        /* update the core */
    108107        const char * key = g_object_get_data( o, PREF_KEY );
    109         const int multiplier = GPOINTER_TO_INT( g_object_get_data( o, MULTIPLIER_KEY ) );
    110108
    111109        if (data->isDouble)
    112110        {
    113             const double value = gtk_spin_button_get_value( GTK_SPIN_BUTTON( spin ) ) * multiplier;
     111            const double value = gtk_spin_button_get_value( GTK_SPIN_BUTTON( spin ) );
    114112            tr_core_set_pref_double( TR_CORE( data->core ), key, value );
    115113        }
    116114        else
    117115        {
    118             const int value = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) ) * multiplier;
     116            const int value = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) );
    119117            tr_core_set_pref_int( TR_CORE( data->core ), key, value );
    120118        }
     
    165163new_spin_button( const char * key,
    166164                 gpointer     core,
    167                  int          multiplier,
    168165                 int          low,
    169166                 int          high,
     
    171168{
    172169    GtkWidget * w = gtk_spin_button_new_with_range( low, high, step );
    173     g_object_set_data( G_OBJECT( w ), MULTIPLIER_KEY, GINT_TO_POINTER( multiplier ) );
    174170    g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup( key ), g_free );
    175171    gtk_spin_button_set_digits( GTK_SPIN_BUTTON( w ), 0 );
    176     gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), pref_int_get( key ) / multiplier );
     172    gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), pref_int_get( key ) );
    177173    g_signal_connect( w, "value-changed", G_CALLBACK( spun_cb_int ), core );
    178174    return w;
     
    182178new_spin_button_double( const char * key,
    183179                       gpointer      core,
    184                        int           multiplier,
    185180                       double        low,
    186181                       double        high,
     
    188183{
    189184    GtkWidget * w = gtk_spin_button_new_with_range( low, high, step );
    190     g_object_set_data( G_OBJECT( w ), MULTIPLIER_KEY, GINT_TO_POINTER( multiplier ) );
    191185    g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup( key ), g_free );
    192186    gtk_spin_button_set_digits( GTK_SPIN_BUTTON( w ), 2 );
     
    330324    s = _( "_Seed torrent until its ratio reaches:" );
    331325    w = new_check_button( s, TR_PREFS_KEY_RATIO_ENABLED, core );
    332     w2 = new_spin_button_double( TR_PREFS_KEY_RATIO, core, 1, 0, INT_MAX, .05 );
     326    w2 = new_spin_button_double( TR_PREFS_KEY_RATIO, core, 0, INT_MAX, .05 );
    333327    gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_RATIO_ENABLED ) );
    334328    g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 );
     
    807801
    808802    /* port */
    809     w = new_spin_button( TR_PREFS_KEY_RPC_PORT, core, 1, 0, USHRT_MAX, 1 );
     803    w = new_spin_button( TR_PREFS_KEY_RPC_PORT, core, 0, USHRT_MAX, 1 );
    810804    page->widgets = g_slist_append( page->widgets, w );
    811805    w = hig_workarea_add_row( t, &row, _( "Listening _port:" ), w, NULL );
     
    10121006    page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    10131007
    1014     w = new_spin_button( TR_PREFS_KEY_PROXY_PORT, core, 1, 0, USHRT_MAX, 1 );
     1008    w = new_spin_button( TR_PREFS_KEY_PROXY_PORT, core, 0, USHRT_MAX, 1 );
    10151009    page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    10161010    w = hig_workarea_add_row( t, &row, _( "Proxy _port:" ), w, NULL );
     
    12201214        g_snprintf( buf, sizeof( buf ), _( "Limit _download speed (%s):" ), _(speed_K_str) );
    12211215        w = new_check_button( buf, TR_PREFS_KEY_DSPEED_ENABLED, core );
    1222         w2 = new_spin_button( TR_PREFS_KEY_DSPEED_Bps, core, speed_K, 0, INT_MAX, 5 );
     1216        w2 = new_spin_button( TR_PREFS_KEY_DSPEED_KBps, core, 0, INT_MAX, 5 );
    12231217        gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_DSPEED_ENABLED ) );
    12241218        g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 );
     
    12271221        g_snprintf( buf, sizeof( buf ), _( "Limit _upload speed (%s):" ), _(speed_K_str) );
    12281222        w = new_check_button( buf, TR_PREFS_KEY_USPEED_ENABLED, core );
    1229         w2 = new_spin_button( TR_PREFS_KEY_USPEED_Bps, core, speed_K, 0, INT_MAX, 5 );
     1223        w2 = new_spin_button( TR_PREFS_KEY_USPEED_KBps, core, 0, INT_MAX, 5 );
    12301224        gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_USPEED_ENABLED ) );
    12311225        g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 );
     
    12511245
    12521246        g_snprintf( buf, sizeof( buf ), _( "Limit do_wnload speed (%s):" ), _(speed_K_str) );
    1253         w = new_spin_button( TR_PREFS_KEY_ALT_SPEED_DOWN_Bps, core, speed_K, 0, INT_MAX, 5 );
     1247        w = new_spin_button( TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, core, 0, INT_MAX, 5 );
    12541248        hig_workarea_add_row( t, &row, buf, w, NULL );
    12551249
    12561250        g_snprintf( buf, sizeof( buf ), _( "Limit u_pload speed (%s):" ), _(speed_K_str) );
    1257         w = new_spin_button( TR_PREFS_KEY_ALT_SPEED_UP_Bps, core, speed_K, 0, INT_MAX, 5 );
     1251        w = new_spin_button( TR_PREFS_KEY_ALT_SPEED_UP_KBps, core, 0, INT_MAX, 5 );
    12581252        hig_workarea_add_row( t, &row, buf, w, NULL );
    12591253
     
    13701364
    13711365    s = _( "_Port for incoming connections:" );
    1372     w = data->portSpin = new_spin_button( TR_PREFS_KEY_PEER_PORT, core, 1, 1, USHRT_MAX, 1 );
     1366    w = data->portSpin = new_spin_button( TR_PREFS_KEY_PEER_PORT, core, 1, USHRT_MAX, 1 );
    13731367    hig_workarea_add_row( t, &row, s, w, NULL );
    13741368
     
    13951389    hig_workarea_add_section_title( t, &row, _( "Limits" ) );
    13961390
    1397     w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_TORRENT, core, 1, 1, 300, 5 );
     1391    w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_TORRENT, core, 1, 300, 5 );
    13981392    hig_workarea_add_row( t, &row, _( "Maximum peers per _torrent:" ), w, NULL );
    1399     w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_GLOBAL, core, 1, 1, 3000, 5 );
     1393    w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_GLOBAL, core, 1, 3000, 5 );
    14001394    hig_workarea_add_row( t, &row, _( "Maximum peers _overall:" ), w, NULL );
    14011395
  • trunk/gtk/tr-window.c

    r10931 r10937  
    206206    }
    207207    else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_ENABLED ) ||
    208              !strcmp( key, TR_PREFS_KEY_ALT_SPEED_UP_Bps ) ||
    209              !strcmp( key, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps ) )
     208             !strcmp( key, TR_PREFS_KEY_ALT_SPEED_UP_KBps ) ||
     209             !strcmp( key, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps ) )
    210210    {
    211211        syncAltSpeedButton( p );
     
    267267    GtkWidget * w = p->alt_speed_button;
    268268
    269     tr_strlspeed( u, pref_int_get( TR_PREFS_KEY_ALT_SPEED_UP_Bps ), sizeof( u ) );
    270     tr_strlspeed( d, pref_int_get( TR_PREFS_KEY_ALT_SPEED_DOWN_Bps ), sizeof( d ) );
     269    tr_formatter_speed_KBps( u, pref_int_get( TR_PREFS_KEY_ALT_SPEED_UP_KBps ), sizeof( u ) );
     270    tr_formatter_speed_KBps( d, pref_int_get( TR_PREFS_KEY_ALT_SPEED_DOWN_KBps ), sizeof( d ) );
    271271    fmt = b ? _( "Click to disable Temporary Speed Limits\n(%1$s down, %2$s up)" )
    272272            : _( "Click to enable Temporary Speed Limits\n(%1$s down, %2$s up)" );
     
    389389    PrivateData * p = vp;
    390390    GObject * o = G_OBJECT( check );
    391     const int Bps = GPOINTER_TO_INT( g_object_get_data( o, SPEED_KEY ) ) * speed_K;
     391    const int KBps = GPOINTER_TO_INT( g_object_get_data( o, SPEED_KEY ) );
    392392    tr_direction dir = GPOINTER_TO_INT( g_object_get_data( o, DIRECTION_KEY ) );
    393393
    394     key = dir==TR_UP ? TR_PREFS_KEY_USPEED_Bps : TR_PREFS_KEY_DSPEED_Bps;
    395     tr_core_set_pref_int( p->core, key, Bps );
     394    key = dir==TR_UP ? TR_PREFS_KEY_USPEED_KBps : TR_PREFS_KEY_DSPEED_KBps;
     395    tr_core_set_pref_int( p->core, key, KBps );
    396396
    397397    key = dir==TR_UP ? TR_PREFS_KEY_USPEED_ENABLED : TR_PREFS_KEY_DSPEED_ENABLED;
     
    542542
    543543    w = p->speedlimit_on_item[TR_DOWN];
    544     tr_strlspeed( buf1, pref_int_get( TR_PREFS_KEY_DSPEED_Bps ), sizeof( buf1 ) );
     544    tr_formatter_speed_KBps( buf1, pref_int_get( TR_PREFS_KEY_DSPEED_KBps ), sizeof( buf1 ) );
    545545    gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 );
    546546
     
    550550
    551551    w = p->speedlimit_on_item[TR_UP];
    552     tr_strlspeed( buf1, pref_int_get( TR_PREFS_KEY_USPEED_Bps ), sizeof( buf1 ) );
     552    tr_formatter_speed_KBps( buf1, pref_int_get( TR_PREFS_KEY_USPEED_KBps ), sizeof( buf1 ) );
    553553    gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 );
    554554
     
    843843    {
    844844        char buf[128];
    845         int up=0, down=0;
     845        double up=0, down=0;
    846846        GtkTreeIter iter;
    847847        GtkTreeModel * model = tr_core_model( p->core );
     
    849849        if( gtk_tree_model_get_iter_first( model, &iter ) ) do
    850850        {
    851             int u, d;
     851            double u, d;
    852852            gtk_tree_model_get( model, &iter, MC_SPEED_UP, &u,
    853853                                              MC_SPEED_DOWN, &d,
     
    858858        while( gtk_tree_model_iter_next( model, &iter ) );
    859859
    860         tr_strlspeed( buf, down, sizeof( buf ) );
     860        tr_formatter_speed_KBps( buf, down, sizeof( buf ) );
    861861        gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
    862862
    863         tr_strlspeed( buf, up, sizeof( buf ) );
     863        tr_formatter_speed_KBps( buf, up, sizeof( buf ) );
    864864        gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
    865865    }
  • trunk/gtk/tr-window.h

    r10863 r10937  
    2727
    2828#include <gtk/gtk.h>
     29#include <libtransmission/utils.h> /* tr_formatter_speed_KBps() */
    2930#include "tr-core.h"
    3031
  • trunk/gtk/util.c

    r10931 r10937  
    1313#include <ctype.h> /* isxdigit() */
    1414#include <errno.h>
     15#include <math.h> /* pow() */
    1516#include <stdlib.h> /* free() */
    1617#include <string.h> /* strcmp() */
     
    128129***/
    129130
     131int
     132gtr_compare_double( const double a, const double b, int decimal_places )
     133{
     134    const int64_t ia = (int64_t)(a * pow( 10, decimal_places ) );
     135    const int64_t ib = (int64_t)(b * pow( 10, decimal_places ) );
     136    if( ia < ib ) return -1;
     137    if( ia > ib ) return  1;
     138    return 0;
     139}
     140
     141/***
     142****
     143***/
     144
    130145const char*
    131146gtr_get_unicode_string( int i )
     
    157172        g_strlcpy( buf, _( "None" ), buflen );
    158173    else
    159         tr_formatter_size( buf, bytes, buflen );
     174        tr_formatter_size_B( buf, bytes, buflen );
    160175
    161176    return buf;
     
    168183        g_strlcpy( buf, _( "None" ), buflen );
    169184    else
    170         tr_formatter_speed( buf, bytes_per_second, buflen );
     185        tr_formatter_speed_Bps( buf, bytes_per_second, buflen );
    171186
    172187    return buf;
  • trunk/gtk/util.h

    r10931 r10937  
    7878char* gtr_localtime( time_t time );
    7979
     80
     81int gtr_compare_double( const double a, const double b, int decimal_places );
     82
     83
    8084/***
    8185****
  • trunk/libtransmission/cache.c

    r10932 r10937  
    226226    cache->max_blocks = getMaxBlocks( max_bytes );
    227227
    228     tr_formatter_mem( buf, cache->max_bytes, sizeof( buf ) );
     228    tr_formatter_mem_B( buf, cache->max_bytes, sizeof( buf ) );
    229229    tr_ndbg( MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks );
    230230
  • trunk/libtransmission/peer-mgr.c

    r10931 r10937  
    22702270
    22712271
    2272 int*
    2273 tr_peerMgrWebSpeeds_Bps( const tr_torrent * tor )
     2272double*
     2273tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor )
    22742274{
    22752275    const Torrent * t = tor->torrentPeers;
     
    22772277    int i;
    22782278    int webseedCount;
    2279     int * ret;
     2279    double * ret;
    22802280    uint64_t now;
    22812281
     
    22862286    webseedCount = tr_ptrArraySize( &t->webseeds );
    22872287    assert( webseedCount == tor->info.webseedCount );
    2288     ret = tr_new0( int, webseedCount );
     2288    ret = tr_new0( double, webseedCount );
    22892289    now = tr_date( );
    22902290
    2291     for( i=0; i<webseedCount; ++i )
    2292         if( !tr_webseedGetSpeed_Bps( webseeds[i], now, &ret[i] ) )
     2291    for( i=0; i<webseedCount; ++i ) {
     2292        int Bps;
     2293        if( tr_webseedGetSpeed_Bps( webseeds[i], now, &Bps ) )
     2294            ret[i] = Bps / (double)tr_speed_K;
     2295        else
    22932296            ret[i] = -1.0;
     2297    }
    22942298
    22952299    managerUnlock( t->manager );
     
    23372341        stat->progress            = peer->progress;
    23382342        stat->isEncrypted         = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
    2339         stat->rateToPeer_Bps      = tr_peerGetPieceSpeed_Bps( peer, now, TR_CLIENT_TO_PEER );
    2340         stat->rateToClient_Bps    = tr_peerGetPieceSpeed_Bps( peer, now, TR_PEER_TO_CLIENT );
     2343        stat->rateToPeer_KBps     = toSpeedKBps( tr_peerGetPieceSpeed_Bps( peer, now, TR_CLIENT_TO_PEER ) );
     2344        stat->rateToClient_KBps   = toSpeedKBps( tr_peerGetPieceSpeed_Bps( peer, now, TR_PEER_TO_CLIENT ) );
    23412345        stat->peerIsChoked        = peer->peerIsChoked;
    23422346        stat->peerIsInterested    = peer->peerIsInterested;
  • trunk/libtransmission/peer-mgr.h

    r10931 r10937  
    228228int tr_peerMgrGetWebseedSpeed_Bps( const tr_torrent * tor, uint64_t now );
    229229
    230 int* tr_peerMgrWebSpeeds_Bps( const tr_torrent * tor );
     230double* tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor );
    231231
    232232
  • trunk/libtransmission/rpcimpl.c

    r10931 r10937  
    443443        tr_bencDictAddInt ( d, "port", peer->port );
    444444        tr_bencDictAddReal( d, "progress", peer->progress );
    445         tr_bencDictAddInt ( d, "rateToClient", peer->rateToClient_Bps );
    446         tr_bencDictAddInt ( d, "rateToPeer", peer->rateToPeer_Bps );
     445        tr_bencDictAddReal( d, "rateToClient", peer->rateToClient_KBps );
     446        tr_bencDictAddReal( d, "rateToPeer", peer->rateToPeer_KBps );
    447447    }
    448448
     
    485485        tr_bencDictAddInt( d, key, st->downloadedEver );
    486486    else if( tr_streq( key, keylen, "downloadLimit" ) )
    487         tr_bencDictAddInt( d, key, tr_torrentGetSpeedLimit_Bps( tor, TR_DOWN ) );
     487        tr_bencDictAddReal( d, key, tr_torrentGetSpeedLimit_KBps( tor, TR_DOWN ) );
    488488    else if( tr_streq( key, keylen, "downloadLimited" ) )
    489489        tr_bencDictAddBool( d, key, tr_torrentUsesSpeedLimit( tor, TR_DOWN ) );
     
    570570    }
    571571    else if( tr_streq( key, keylen, "rateDownload" ) )
    572         tr_bencDictAddInt( d, key, st->pieceDownloadSpeed_Bps );
     572        tr_bencDictAddReal( d, key, st->pieceDownloadSpeed_KBps );
    573573    else if( tr_streq( key, keylen, "rateUpload" ) )
    574         tr_bencDictAddInt( d, key, st->pieceUploadSpeed_Bps );
     574        tr_bencDictAddReal( d, key, st->pieceUploadSpeed_KBps );
    575575    else if( tr_streq( key, keylen, "recheckProgress" ) )
    576576        tr_bencDictAddReal( d, key, st->recheckProgress );
     
    600600        tr_bencDictAddInt( d, key, st->uploadedEver );
    601601    else if( tr_streq( key, keylen, "uploadLimit" ) )
    602         tr_bencDictAddInt( d, key, tr_torrentGetSpeedLimit_Bps( tor, TR_UP ) );
     602        tr_bencDictAddInt( d, key, tr_torrentGetSpeedLimit_KBps( tor, TR_UP ) );
    603603    else if( tr_streq( key, keylen, "uploadLimited" ) )
    604604        tr_bencDictAddBool( d, key, tr_torrentUsesSpeedLimit( tor, TR_UP ) );
     
    10051005            errmsg = setFilePriorities( tor, TR_PRI_NORMAL, files );
    10061006        if( tr_bencDictFindInt( args_in, "downloadLimit", &tmp ) )
    1007             tr_torrentSetSpeedLimit_Bps( tor, TR_DOWN, tmp );
     1007            tr_torrentSetSpeedLimit_KBps( tor, TR_DOWN, tmp );
    10081008        if( tr_bencDictFindBool( args_in, "downloadLimited", &boolVal ) )
    10091009            tr_torrentUseSpeedLimit( tor, TR_DOWN, boolVal );
     
    10111011            tr_torrentUseSessionLimits( tor, boolVal );
    10121012        if( tr_bencDictFindInt( args_in, "uploadLimit", &tmp ) )
    1013             tr_torrentSetSpeedLimit_Bps( tor, TR_UP, tmp );
     1013            tr_torrentSetSpeedLimit_KBps( tor, TR_UP, tmp );
    10141014        if( tr_bencDictFindBool( args_in, "uploadLimited", &boolVal ) )
    10151015            tr_torrentUseSpeedLimit( tor, TR_UP, boolVal );
     
    14081408    assert( idle_data == NULL );
    14091409
    1410     if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_MAX_CACHE_SIZE, &i ) )
    1411         tr_sessionSetCacheLimit( session, d );
    1412     if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_ALT_SPEED_UP_Bps, &i ) )
    1413         tr_sessionSetAltSpeed_Bps( session, TR_UP, i );
    1414     if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps, &i ) )
    1415         tr_sessionSetAltSpeed_Bps( session, TR_DOWN, i );
     1410    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, &i ) )
     1411        tr_sessionSetCacheLimit_MB( session, i );
     1412    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_ALT_SPEED_UP_KBps, &i ) )
     1413        tr_sessionSetAltSpeed_KBps( session, TR_UP, i );
     1414    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, &i ) )
     1415        tr_sessionSetAltSpeed_KBps( session, TR_DOWN, i );
    14161416    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_ALT_SPEED_ENABLED, &boolVal ) )
    14171417        tr_sessionUseAltSpeed( session, boolVal );
     
    14621462    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_TRASH_ORIGINAL, &boolVal ) )
    14631463        tr_sessionSetDeleteSource( session, boolVal );
    1464     if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_DSPEED_Bps, &i ) )
    1465         tr_sessionSetSpeedLimit_Bps( session, TR_DOWN, i );
     1464    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_DSPEED_KBps, &i ) )
     1465        tr_sessionSetSpeedLimit_KBps( session, TR_DOWN, i );
    14661466    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_DSPEED_ENABLED, &boolVal ) )
    14671467        tr_sessionLimitSpeed( session, TR_DOWN, boolVal );
    1468     if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_USPEED_Bps, &i ) )
    1469         tr_sessionSetSpeedLimit_Bps( session, TR_UP, i );
     1468    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_USPEED_KBps, &i ) )
     1469        tr_sessionSetSpeedLimit_KBps( session, TR_UP, i );
    14701470    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_USPEED_ENABLED, &boolVal ) )
    14711471        tr_sessionLimitSpeed( session, TR_UP, boolVal );
     
    15081508    tr_sessionGetCumulativeStats( session, &cumulativeStats );
    15091509
    1510     tr_bencDictAddInt( args_out, "activeTorrentCount", running );
    1511     tr_bencDictAddInt( args_out, "downloadSpeed", tr_sessionGetPieceSpeed_Bps( session, TR_DOWN ) );
    1512     tr_bencDictAddInt( args_out, "pausedTorrentCount", total - running );
    1513     tr_bencDictAddInt( args_out, "torrentCount", total );
    1514     tr_bencDictAddInt( args_out, "uploadSpeed", tr_sessionGetPieceSpeed_Bps( session, TR_UP ) );
     1510    tr_bencDictAddInt ( args_out, "activeTorrentCount", running );
     1511    tr_bencDictAddReal( args_out, "downloadSpeed", tr_sessionGetPieceSpeed_KBps( session, TR_DOWN ) );
     1512    tr_bencDictAddInt ( args_out, "pausedTorrentCount", total - running );
     1513    tr_bencDictAddInt ( args_out, "torrentCount", total );
     1514    tr_bencDictAddReal( args_out, "uploadSpeed", tr_sessionGetPieceSpeed_KBps( session, TR_UP ) );
    15151515
    15161516    d = tr_bencDictAddDict( args_out, "cumulative-stats", 5 );
     
    15411541
    15421542    assert( idle_data == NULL );
    1543     tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP_Bps, tr_sessionGetAltSpeed_Bps(s,TR_UP) );
    1544     tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps, tr_sessionGetAltSpeed_Bps(s,TR_DOWN) );
     1543    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP_KBps, tr_sessionGetAltSpeed_KBps(s,TR_UP) );
     1544    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, tr_sessionGetAltSpeed_KBps(s,TR_DOWN) );
    15451545    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED, tr_sessionUsesAltSpeed(s) );
    15461546    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, tr_sessionGetAltSpeedBegin(s) );
     
    15491549    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, tr_sessionUsesAltSpeedTime(s) );
    15501550    tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, tr_blocklistIsEnabled( s ) );
    1551     tr_bencDictAddReal( d, TR_PREFS_KEY_MAX_CACHE_SIZE, tr_sessionGetCacheLimit( s ) );
     1551    tr_bencDictAddReal( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, tr_sessionGetCacheLimit_MB( s ) );
    15521552    tr_bencDictAddInt ( d, "blocklist-size", tr_blocklistGetRuleCount( s ) );
    15531553    tr_bencDictAddStr ( d, "config-dir", tr_sessionGetConfigDir( s ) );
     
    15701570    tr_bencDictAddBool( d, TR_PREFS_KEY_START, !tr_sessionGetPaused( s ) );
    15711571    tr_bencDictAddBool( d, TR_PREFS_KEY_TRASH_ORIGINAL, tr_sessionGetDeleteSource( s ) );
    1572     tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_Bps, tr_sessionGetSpeedLimit_Bps( s, TR_UP ) );
     1572    tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_KBps, tr_sessionGetSpeedLimit_KBps( s, TR_UP ) );
    15731573    tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_UP ) );
    1574     tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_Bps, tr_sessionGetSpeedLimit_Bps( s, TR_DOWN ) );
     1574    tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_KBps, tr_sessionGetSpeedLimit_KBps( s, TR_DOWN ) );
    15751575    tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_DOWN ) );
    15761576    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
  • trunk/libtransmission/session.c

    r10931 r10937  
    5656    SAVE_INTERVAL_SECS = 120,
    5757
    58     DEFAULT_CACHE_SIZE_BYTES = ( 2 * 1024 * 1024 ) /* 2 MiB */
     58    DEFAULT_CACHE_SIZE_MB = 2
    5959};
    6060
     
    242242#endif
    243243
    244 static tr_bool
    245 getSpeedFromDict( tr_benc * dict, const char * key_in, int64_t * Bps )
    246 {
    247     int64_t i;
    248     char key[256];
    249 
    250     /* 1. look for it ending in -Bps */
    251     tr_snprintf( key, sizeof( key ), "%s-Bps", key_in );
    252     if( tr_bencDictFindInt( dict, key, &i ) ) {
    253         *Bps = i;
    254         return TRUE;
    255     }
    256 
    257     /* 2. look for it an old entry without the -Bps suffix.
    258           if found, interpret that to be either kB/s or KiB/s
    259           based on the formatter settings in utils */
    260     if( tr_bencDictFindInt( dict, key_in, &i ) ) {
    261         *Bps = i * tr_formatter_speed_k( );
    262         return TRUE;
    263     }
    264 
    265     return FALSE;
    266 }
    267 
    268244void
    269245tr_sessionGetDefaultSettings( const char * configDir UNUSED, tr_benc * d )
    270246{
    271     const int speed_K = tr_formatter_speed_k( );
    272 
    273247    assert( tr_bencIsDict( d ) );
    274248
    275249    tr_bencDictReserve( d, 60 );
    276250    tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED,        FALSE );
    277     tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE,           DEFAULT_CACHE_SIZE_BYTES );
     251    tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB,        DEFAULT_CACHE_SIZE_MB );
    278252    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED,              TRUE );
    279253    tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED,              FALSE );
    280254    tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR,             tr_getDefaultDownloadDir( ) );
    281     tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_Bps,               100 * speed_K );
     255    tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_KBps,              100 );
    282256    tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED,           FALSE );
    283257    tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION,               TR_DEFAULT_ENCRYPTION );
     
    318292    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, FALSE );
    319293    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED,        FALSE );
    320     tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP_Bps,         50 * speed_K ); /* half the regular */
    321     tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps,       50 * speed_K ); /* half the regular */
     294    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP_KBps,        50 ); /* half the regular */
     295    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps,      50 ); /* half the regular */
    322296    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN,     540 ); /* 9am */
    323297    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED,   FALSE );
    324298    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_END,       1020 ); /* 5pm */
    325299    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_DAY,       TR_SCHED_ALL );
    326     tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_Bps,               100 * speed_K );
     300    tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_KBps,              100 );
    327301    tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED,           FALSE );
    328302    tr_bencDictAddInt ( d, TR_PREFS_KEY_UMASK,                    022 );
     
    341315    tr_bencDictReserve( d, 60 );
    342316    tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED,        tr_blocklistIsEnabled( s ) );
    343     tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE,           tr_cacheGetLimit( s->cache ) );
     317    tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB,        tr_cacheGetLimit( s->cache ) );
    344318    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED,              s->isDHTEnabled );
    345319    tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED,              s->isLPDEnabled );
    346320    tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR,             s->downloadDir );
    347     tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_Bps,               tr_sessionGetSpeedLimit_Bps( s, TR_DOWN ) );
     321    tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_KBps,              tr_sessionGetSpeedLimit_KBps( s, TR_DOWN ) );
    348322    tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED,           tr_sessionIsSpeedLimited( s, TR_DOWN ) );
    349323    tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION,               s->encryptionMode );
     
    386360    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
    387361    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED,        tr_sessionUsesAltSpeed( s ) );
    388     tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP_Bps,         tr_sessionGetAltSpeed_Bps( s, TR_UP ) );
    389     tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps,       tr_sessionGetAltSpeed_Bps( s, TR_DOWN ) );
     362    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP_KBps,         tr_sessionGetAltSpeed_KBps( s, TR_UP ) );
     363    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps,       tr_sessionGetAltSpeed_KBps( s, TR_DOWN ) );
    390364    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN,     tr_sessionGetAltSpeedBegin( s ) );
    391365    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED,   tr_sessionUsesAltSpeedTime( s ) );
    392366    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_END,       tr_sessionGetAltSpeedEnd( s ) );
    393367    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_DAY,       tr_sessionGetAltSpeedDay( s ) );
    394     tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_Bps,               tr_sessionGetSpeedLimit_Bps( s, TR_UP ) );
     368    tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_KBps,               tr_sessionGetSpeedLimit_KBps( s, TR_UP ) );
    395369    tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED,           tr_sessionIsSpeedLimited( s, TR_UP ) );
    396370    tr_bencDictAddInt ( d, TR_PREFS_KEY_UMASK,                    s->umask );
     
    539513    session->bandwidth = tr_bandwidthNew( session, NULL );
    540514    session->lock = tr_lockNew( );
    541     session->cache = tr_cacheNew( DEFAULT_CACHE_SIZE_BYTES );
     515    session->cache = tr_cacheNew( 1024*1024*2 );
    542516    session->tag = tr_strdup( tag );
    543517    session->magicNumber = SESSION_MAGIC_NUMBER;
     
    705679
    706680    /* misc features */
    707     if( tr_bencDictFindInt( settings, TR_PREFS_KEY_MAX_CACHE_SIZE, &i ) )
    708         tr_sessionSetCacheLimit( session, i );
     681    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, &i ) )
     682        tr_sessionSetCacheLimit_MB( session, i );
    709683    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_LAZY_BITFIELD, &boolVal ) )
    710684        tr_sessionSetLazyBitfieldEnabled( session, boolVal );
     
    806780        session->uploadSlotsPerTorrent = i;
    807781
    808     if( getSpeedFromDict( settings, "speed-limit-up", &i ) )
    809         tr_sessionSetSpeedLimit_Bps( session, TR_UP, i );
     782    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_USPEED_KBps, &i ) )
     783        tr_sessionSetSpeedLimit_KBps( session, TR_UP, i );
    810784    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_USPEED_ENABLED, &boolVal ) )
    811785        tr_sessionLimitSpeed( session, TR_UP, boolVal );
    812786
    813     if( getSpeedFromDict( settings, "speed-limit-down", &i ) )
    814         tr_sessionSetSpeedLimit_Bps( session, TR_DOWN, i );
     787    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_DSPEED_KBps, &i ) )
     788        tr_sessionSetSpeedLimit_KBps( session, TR_DOWN, i );
    815789    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_DSPEED_ENABLED, &boolVal ) )
    816790        tr_sessionLimitSpeed( session, TR_DOWN, boolVal );
     
    826800
    827801    /* update the turtle mode's fields */
    828     if( getSpeedFromDict( settings, "alt-speed-up", &i ) )
    829         turtle->speedLimit_Bps[TR_UP] = i;
    830     if( getSpeedFromDict( settings, "alt-speed-down", &i ) )
    831         turtle->speedLimit_Bps[TR_DOWN] = i;
     802    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_ALT_SPEED_UP_KBps, &i ) )
     803        turtle->speedLimit_Bps[TR_UP] = toSpeedBytes( i );
     804    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, &i ) )
     805        turtle->speedLimit_Bps[TR_DOWN] = toSpeedBytes( i );
    832806    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, &i ) )
    833807        turtle->beginMinute = i;
     
    11281102
    11291103tr_bool
    1130 tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, tr_direction dir, int * setme )
     1104tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, tr_direction dir, int * setme_Bps )
    11311105{
    11321106    int isLimited = TRUE;
     
    11361110
    11371111    if( tr_sessionUsesAltSpeed( session ) )
    1138         *setme = tr_sessionGetAltSpeed_Bps( session, dir );
     1112        *setme_Bps = tr_sessionGetAltSpeed_Bps( session, dir );
    11391113    else if( tr_sessionIsSpeedLimited( session, dir ) )
    1140         *setme = tr_sessionGetSpeedLimit_Bps( session, dir );
     1114        *setme_Bps = tr_sessionGetSpeedLimit_Bps( session, dir );
    11411115    else
    11421116        isLimited = FALSE;
    11431117
    11441118    return isLimited;
     1119}
     1120tr_bool
     1121tr_sessionGetActiveSpeedLimit_KBps( const tr_session  * session,
     1122                                    tr_direction        dir,
     1123                                    double            * setme_KBps )
     1124{
     1125    int Bps;
     1126    const tr_bool is_active = tr_sessionGetActiveSpeedLimit_Bps( session, dir, &Bps );
     1127    *setme_KBps = toSpeedKBps( Bps );
     1128    return is_active;
    11451129}
    11461130
     
    13051289    updateBandwidth( s, d );
    13061290}
     1291void
     1292tr_sessionSetSpeedLimit_KBps( tr_session * s, tr_direction d, int KBps )
     1293{
     1294    tr_sessionSetSpeedLimit_Bps( s, d, toSpeedBytes( KBps ) );
     1295}
    13071296
    13081297int
     
    13131302
    13141303    return s->speedLimit_Bps[d];
     1304}
     1305int
     1306tr_sessionGetSpeedLimit_KBps( const tr_session * s, tr_direction d )
     1307{
     1308    return toSpeedKBps( tr_sessionGetSpeedLimit_Bps( s, d ) );
    13151309}
    13161310
     
    13521346}
    13531347
     1348void
     1349tr_sessionSetAltSpeed_KBps( tr_session * s, tr_direction d, int KBps )
     1350{
     1351    tr_sessionSetAltSpeed_Bps( s, d, toSpeedBytes( KBps ) );
     1352}
     1353
    13541354int
    13551355tr_sessionGetAltSpeed_Bps( const tr_session * s, tr_direction d )
     
    13591359
    13601360    return s->turtle.speedLimit_Bps[d];
     1361}
     1362int
     1363tr_sessionGetAltSpeed_KBps( const tr_session * s, tr_direction d )
     1364{
     1365    return toSpeedKBps( tr_sessionGetAltSpeed_Bps( s, d ) );
    13611366}
    13621367
     
    15671572tr_sessionGetPieceSpeed_Bps( const tr_session * session, tr_direction dir )
    15681573{
    1569     return tr_isSession( session ) ? tr_bandwidthGetPieceSpeed_Bps( session->bandwidth, 0, dir ) : 0.0;
     1574    return tr_isSession( session ) ? tr_bandwidthGetPieceSpeed_Bps( session->bandwidth, 0, dir ) : 0;
     1575}
     1576double
     1577tr_sessionGetPieceSpeed_KBps( const tr_session * session, tr_direction dir )
     1578{
     1579    return toSpeedKBps( tr_sessionGetPieceSpeed_Bps( session, dir ) );
    15701580}
    15711581
     
    15731583tr_sessionGetRawSpeed_Bps( const tr_session * session, tr_direction dir )
    15741584{
    1575     return tr_isSession( session ) ? tr_bandwidthGetRawSpeed_Bps( session->bandwidth, 0, dir ) : 0.0;
    1576 }
     1585    return tr_isSession( session ) ? tr_bandwidthGetRawSpeed_Bps( session->bandwidth, 0, dir ) : 0;
     1586}
     1587double
     1588tr_sessionGetRawSpeed_KBps( const tr_session * session, tr_direction dir )
     1589{
     1590    return toSpeedKBps( tr_sessionGetRawSpeed_Bps( session, dir ) );
     1591}
     1592
    15771593
    15781594int
     
    18771893
    18781894void
    1879 tr_sessionSetCacheLimit( tr_session * session, int64_t max_bytes )
     1895tr_sessionSetCacheLimit_B( tr_session * session, uint64_t max_bytes )
    18801896{
    18811897    assert( tr_isSession( session ) );
     
    18831899    tr_cacheSetLimit( session->cache, max_bytes );
    18841900}
    1885 
    1886 int64_t
    1887 tr_sessionGetCacheLimit( const tr_session * session )
     1901void
     1902tr_sessionSetCacheLimit_MB( tr_session * session, int MB )
     1903{
     1904    tr_sessionSetCacheLimit_B( session, toMemBytes( MB ) );
     1905}
     1906
     1907uint64_t
     1908tr_sessionGetCacheLimit_B( const tr_session * session )
    18881909{
    18891910    assert( tr_isSession( session ) );
     
    18911912    return tr_cacheGetLimit( session->cache );
    18921913}
     1914int
     1915tr_sessionGetCacheLimit_MB( const tr_session * session )
     1916{
     1917    return toMemMB( tr_sessionGetCacheLimit_B( session ) );
     1918}
     1919
    18931920
    18941921/***
  • trunk/libtransmission/session.h

    r10931 r10937  
    3030#include "bencode.h"
    3131#include "bitfield.h"
     32#include "utils.h"
    3233
    3334typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t;
     
    249250}
    250251
     252/***
     253****
     254***/
     255
     256static inline unsigned int toSpeedBytes ( unsigned int KBps ) { return KBps * tr_speed_K; }
     257static inline double       toSpeedKBps  ( unsigned int Bps )  { return Bps / (double)tr_speed_K; }
     258
     259static inline uint64_t toMemBytes ( unsigned int MB ) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; }
     260static inline int      toMemMB    ( uint64_t B )      { return B / tr_mem_K; }
     261
     262/**
     263**/
     264
     265void     tr_sessionSetCacheLimit_B ( tr_session * session, uint64_t B );
     266uint64_t tr_sessionGetCacheLimit_B ( const tr_session * session );
     267
     268int  tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction );
     269int  tr_sessionGetAltSpeed_Bps  ( const tr_session *, tr_direction );
     270int  tr_sessionGetRawSpeed_Bps  ( const tr_session *, tr_direction );
     271int  tr_sessionGetPieceSpeed_Bps( const tr_session *, tr_direction );
     272
     273void tr_sessionSetSpeedLimit_Bps( tr_session *, tr_direction, int Bps );
     274void tr_sessionSetAltSpeed_Bps  ( tr_session *, tr_direction, int Bps );
     275
     276tr_bool  tr_sessionGetActiveSpeedLimit_Bps( const tr_session  * session,
     277                                            tr_direction        dir,
     278                                            int               * setme );
     279
     280
    251281#endif
  • trunk/libtransmission/torrent.c

    r10935 r10937  
    139139        tr_torrentSetDirty( tor );
    140140}
     141void
     142tr_torrentSetSpeedLimit_KBps( tr_torrent * tor, tr_direction dir, int KBps )
     143{
     144    tr_torrentSetSpeedLimit_Bps( tor, dir, toSpeedBytes( KBps ) );
     145}
    141146
    142147int
     
    147152
    148153    return tr_bandwidthGetDesiredSpeed_Bps( tor->bandwidth, dir );
     154}
     155int
     156tr_torrentGetSpeedLimit_KBps( const tr_torrent * tor, tr_direction dir )
     157{
     158    return toSpeedKBps( tr_torrentGetSpeedLimit_Bps( tor, dir ) );
    149159}
    150160
     
    969979    now = tr_date( );
    970980    d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );
    971     s->rawUploadSpeed_Bps     = tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_UP );
    972     s->pieceUploadSpeed_Bps   = tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP );
    973     s->rawDownloadSpeed_Bps   = d + tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_DOWN );
    974     s->pieceDownloadSpeed_Bps = d + tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN );
     981    s->rawUploadSpeed_KBps     = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_UP ) );
     982    s->pieceUploadSpeed_KBps   = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) );
     983    s->rawDownloadSpeed_KBps   = toSpeedKBps( d + tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_DOWN ) );
     984    s->pieceDownloadSpeed_KBps = toSpeedKBps( d + tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN ) );
    975985
    976986    usableSeeds += tor->info.webseedCount;
     
    10331043        case TR_STATUS_DOWNLOAD:
    10341044            if( ( tor->etaDLSpeedCalculatedAt + 800 ) < now ) {
    1035                 tor->etaDLSpeed_Bps = ( ( tor->etaDLSpeedCalculatedAt + 4000 ) < now )
    1036                     ? s->pieceDownloadSpeed_Bps /* if no recent previous speed, no need to smooth */
    1037                     : ((tor->etaDLSpeed_Bps*4) + s->pieceDownloadSpeed_Bps)/5; /* smooth across 5 readings */
     1045                tor->etaDLSpeed_KBps = ( ( tor->etaDLSpeedCalculatedAt + 4000 ) < now )
     1046                    ? s->pieceDownloadSpeed_KBps /* if no recent previous speed, no need to smooth */
     1047                    : ((tor->etaDLSpeed_KBps*4.0) + s->pieceDownloadSpeed_KBps)/5.0; /* smooth across 5 readings */
    10381048                tor->etaDLSpeedCalculatedAt = now;
    10391049            }
     
    10411051            if( s->leftUntilDone > s->desiredAvailable )
    10421052                s->eta = TR_ETA_NOT_AVAIL;
    1043             else if( s->pieceDownloadSpeed_Bps < 1 )
     1053            else if( tor->etaDLSpeed_KBps < 1 )
    10441054                s->eta = TR_ETA_UNKNOWN;
    10451055            else
    1046                 s->eta = s->leftUntilDone / tor->etaDLSpeed_Bps;
     1056                s->eta = s->leftUntilDone / toSpeedBytes(tor->etaDLSpeed_KBps);
    10471057            break;
    10481058
     
    10521062            else {
    10531063                if( ( tor->etaULSpeedCalculatedAt + 800 ) < now ) {
    1054                     tor->etaULSpeed_Bps = ( ( tor->etaULSpeedCalculatedAt + 4000 ) < now )
    1055                         ? s->pieceUploadSpeed_Bps /* if no recent previous speed, no need to smooth */
    1056                         : ((tor->etaULSpeed_Bps*4) + s->pieceUploadSpeed_Bps)/5; /* smooth across 5 readings */
     1064                    tor->etaULSpeed_KBps = ( ( tor->etaULSpeedCalculatedAt + 4000 ) < now )
     1065                        ? s->pieceUploadSpeed_KBps /* if no recent previous speed, no need to smooth */
     1066                        : ((tor->etaULSpeed_KBps*4.0) + s->pieceUploadSpeed_KBps)/5.0; /* smooth across 5 readings */
    10571067                    tor->etaULSpeedCalculatedAt = now;
    10581068                }
    1059                 if( s->pieceUploadSpeed_Bps < 1 )
     1069                if( tor->etaULSpeed_KBps < 1 )
    10601070                    s->eta = TR_ETA_UNKNOWN;
    10611071                else
    1062                     s->eta = seedRatioBytesLeft / tor->etaULSpeed_Bps;
     1072                    s->eta = seedRatioBytesLeft / toSpeedBytes(tor->etaULSpeed_KBps);
    10631073            }
    10641074            break;
     
    11941204***/
    11951205
    1196 int*
    1197 tr_torrentWebSpeeds_Bps( const tr_torrent * tor )
    1198 {
    1199     return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_Bps( tor ) : NULL;
     1206double*
     1207tr_torrentWebSpeeds_KBps( const tr_torrent * tor )
     1208{
     1209    return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_KBps( tor ) : NULL;
    12001210}
    12011211
  • trunk/libtransmission/torrent.h

    r10931 r10937  
    211211
    212212    uint64_t                   etaDLSpeedCalculatedAt;
    213     int                        etaDLSpeed_Bps;
     213    double                     etaDLSpeed_KBps;
    214214    uint64_t                   etaULSpeedCalculatedAt;
    215     int                        etaULSpeed_Bps;
     215    double                     etaULSpeed_KBps;
    216216
    217217    time_t                     addedDate;
     
    422422void tr_torrentGotNewInfoDict( tr_torrent * tor );
    423423
     424void tr_torrentSetSpeedLimit_Bps  ( tr_torrent *, tr_direction, int Bps );
     425int tr_torrentGetSpeedLimit_Bps  ( const tr_torrent *, tr_direction );
     426
     427
    424428#endif
  • trunk/libtransmission/transmission.h

    r10931 r10937  
    157157
    158158#define TR_PREFS_KEY_ALT_SPEED_ENABLED             "alt-speed-enabled"
    159 #define TR_PREFS_KEY_ALT_SPEED_UP_Bps              "alt-speed-up-Bps"
    160 #define TR_PREFS_KEY_ALT_SPEED_DOWN_Bps            "alt-speed-down-Bps"
     159#define TR_PREFS_KEY_ALT_SPEED_UP_KBps             "alt-speed-up"
     160#define TR_PREFS_KEY_ALT_SPEED_DOWN_KBps           "alt-speed-down"
    161161#define TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN          "alt-speed-time-begin"
    162162#define TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED        "alt-speed-time-enabled"
     
    166166#define TR_PREFS_KEY_BIND_ADDRESS_IPV6             "bind-address-ipv6"
    167167#define TR_PREFS_KEY_BLOCKLIST_ENABLED             "blocklist-enabled"
    168 #define TR_PREFS_KEY_MAX_CACHE_SIZE                "cache-size-bytes"
     168#define TR_PREFS_KEY_MAX_CACHE_SIZE_MB             "cache-size-mb"
    169169#define TR_PREFS_KEY_DHT_ENABLED                   "dht-enabled"
    170170#define TR_PREFS_KEY_LPD_ENABLED                   "lpd-enabled"
     
    207207#define TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED   "script-torrent-done-enabled"
    208208#define TR_PREFS_KEY_RPC_WHITELIST                 "rpc-whitelist"
    209 #define TR_PREFS_KEY_DSPEED_Bps                    "speed-limit-down-Bps"
     209#define TR_PREFS_KEY_DSPEED_KBps                   "speed-limit-down"
    210210#define TR_PREFS_KEY_DSPEED_ENABLED                "speed-limit-down-enabled"
    211 #define TR_PREFS_KEY_USPEED_Bps                    "speed-limit-up-Bps"
     211#define TR_PREFS_KEY_USPEED_KBps                   "speed-limit-up"
    212212#define TR_PREFS_KEY_USPEED_ENABLED                "speed-limit-up-enabled"
    213213#define TR_PREFS_KEY_UMASK                         "umask"
     
    599599void     tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled );
    600600
    601 void     tr_sessionSetCacheLimit( tr_session * session, int64_t bytes );
    602 int64_t  tr_sessionGetCacheLimit( const tr_session * session );
     601void     tr_sessionSetCacheLimit_MB( tr_session * session, int mb );
     602int      tr_sessionGetCacheLimit_MB( const tr_session * session );
    603603
    604604void     tr_sessionSetLazyBitfieldEnabled( tr_session * session, tr_bool enabled );
     
    658658***/
    659659
    660 void tr_sessionSetSpeedLimit_Bps( tr_session *, tr_direction, int Bps );
    661 int tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction );
     660void tr_sessionSetSpeedLimit_KBps( tr_session *, tr_direction, int Bps );
     661int tr_sessionGetSpeedLimit_KBps( const tr_session *, tr_direction );
    662662
    663663void     tr_sessionLimitSpeed         ( tr_session *, tr_direction, tr_bool );
     
    669669***/
    670670
    671 void tr_sessionSetAltSpeed_Bps( tr_session *, tr_direction, int Bps );
    672 int  tr_sessionGetAltSpeed_Bps( const tr_session *, tr_direction );
     671void tr_sessionSetAltSpeed_KBps( tr_session *, tr_direction, int Bps );
     672int  tr_sessionGetAltSpeed_KBps( const tr_session *, tr_direction );
    673673
    674674void     tr_sessionUseAltSpeed        ( tr_session *, tr_bool );
     
    707707
    708708
    709 tr_bool  tr_sessionGetActiveSpeedLimit_Bps( const tr_session  * session,
    710                                             tr_direction        dir,
    711                                             int               * setme );
     709tr_bool  tr_sessionGetActiveSpeedLimit_KBps( const tr_session  * session,
     710                                             tr_direction        dir,
     711                                             double            * setme );
    712712
    713713/***
     
    715715***/
    716716
    717 int        tr_sessionGetRawSpeed_Bps  ( const tr_session *, tr_direction );
    718 int        tr_sessionGetPieceSpeed_Bps( const tr_session *, tr_direction );
     717double     tr_sessionGetRawSpeed_KBps  ( const tr_session *, tr_direction );
     718double     tr_sessionGetPieceSpeed_KBps( const tr_session *, tr_direction );
    719719
    720720void       tr_sessionSetRatioLimited  ( tr_session *, tr_bool isLimited );
     
    11251125***/
    11261126
    1127 void     tr_torrentSetSpeedLimit_Bps  ( tr_torrent *, tr_direction, int KB_s );
    1128 int      tr_torrentGetSpeedLimit_Bps  ( const tr_torrent *, tr_direction );
     1127void     tr_torrentSetSpeedLimit_KBps  ( tr_torrent *, tr_direction, int KBps );
     1128int      tr_torrentGetSpeedLimit_KBps  ( const tr_torrent *, tr_direction );
    11291129
    11301130void     tr_torrentUseSpeedLimit      ( tr_torrent *, tr_direction, tr_bool );
     
    13811381
    13821382    float    progress;
    1383     int      rateToPeer_Bps;
    1384     int      rateToClient_Bps;
     1383    double   rateToPeer_KBps;
     1384    double   rateToClient_KBps;
    13851385
    13861386
     
    15451545 *         NOTE: always free this array with tr_free() when you're done with it.
    15461546 */
    1547 int*  tr_torrentWebSpeeds_Bps( const tr_torrent * torrent );
     1547double*  tr_torrentWebSpeeds_KBps( const tr_torrent * torrent );
    15481548
    15491549typedef struct tr_file_stat
     
    17471747    /** Speed all data being sent for this torrent.
    17481748        This includes piece data, protocol messages, and TCP overhead */
    1749     int rawUploadSpeed_Bps;
     1749    double rawUploadSpeed_KBps;
    17501750
    17511751    /** Speed all data being received for this torrent.
    17521752        This includes piece data, protocol messages, and TCP overhead */
    1753     int rawDownloadSpeed_Bps;
     1753    double rawDownloadSpeed_KBps;
    17541754
    17551755    /** Speed all piece being sent for this torrent.
    17561756        This ONLY counts piece data. */
    1757     int pieceUploadSpeed_Bps;
     1757    double pieceUploadSpeed_KBps;
    17581758
    17591759    /** Speed all piece being received for this torrent.
    17601760        This ONLY counts piece data. */
    1761     int pieceDownloadSpeed_Bps;
     1761    double pieceDownloadSpeed_KBps;
    17621762
    17631763#define TR_ETA_NOT_AVAIL -1
  • trunk/libtransmission/utils.c

    r10931 r10937  
    15831583
    15841584char*
    1585 tr_formatter_size( char * buf, uint64_t bytes, size_t buflen )
     1585tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen )
    15861586{
    15871587    return formatter_get_size_str( &size_units, buf, bytes, buflen );
     
    15891589
    15901590static struct formatter_units speed_units;
     1591
     1592unsigned int tr_speed_K = 0u;
    15911593
    15921594void
     
    15951597                         const char * mb, const char * gb )
    15961598{
     1599    tr_speed_K = kilo;
    15971600    formatter_init( &speed_units, kilo, b, kb, mb, gb );
    15981601}
    15991602
    16001603char*
    1601 tr_formatter_speed( char * buf, uint64_t bytes_per_second, size_t buflen )
    1602 {
    1603     return formatter_get_size_str( &speed_units, buf, bytes_per_second, buflen );
    1604 }
    1605 
    1606 unsigned int
    1607 tr_formatter_speed_k( void )
    1608 {
    1609     return speed_units.units[TR_FMT_KB].value;
     1604tr_formatter_speed_Bps( char * buf, uint64_t bytes_per_second, size_t buflen )
     1605{
     1606    formatter_get_size_str( &speed_units, buf, bytes_per_second, buflen );
     1607    return buf;
    16101608}
    16111609
    16121610static struct formatter_units mem_units;
    16131611
     1612unsigned int tr_mem_K = 0u;
     1613 
    16141614void
    16151615tr_formatter_mem_init( unsigned int kilo,
     
    16171617                       const char * mb, const char * gb )
    16181618{
     1619    tr_mem_K = kilo;
    16191620    formatter_init( &mem_units, kilo, b, kb, mb, gb );
    16201621}
    16211622
    16221623char*
    1623 tr_formatter_mem( char * buf, uint64_t bytes_per_second, size_t buflen )
     1624tr_formatter_mem_B( char * buf, uint64_t bytes_per_second, size_t buflen )
    16241625{
    16251626    return formatter_get_size_str( &mem_units, buf, bytes_per_second, buflen );
  • trunk/libtransmission/utils.h

    r10931 r10937  
    575575
    576576/* format a speed into a user-readable string. */
    577 char* tr_formatter_speed( char * buf, uint64_t bytes_per_second, size_t buflen );
     577extern unsigned int tr_speed_K;
     578char* tr_formatter_speed_Bps( char * buf, uint64_t Bps, size_t buflen );
     579static inline char* tr_formatter_speed_KBps( char * buf, double KBps, size_t buflen ) { return tr_formatter_speed_Bps( buf, KBps * tr_speed_K, buflen ); }
     580static inline char* tr_formatter_speed_MBps( char * buf, double MBps, size_t buflen ) { return tr_formatter_speed_Bps( buf, MBps * tr_speed_K * tr_speed_K, buflen ); }
     581static inline char* tr_formatter_speed_GBps( char * buf, double GBps, size_t buflen ) { return tr_formatter_speed_Bps( buf, GBps * tr_speed_K * tr_speed_K * tr_speed_K, buflen ); }
     582
     583/* format a memory size into a user-readable string. */
     584extern unsigned int tr_mem_K;
     585char* tr_formatter_mem_B( char * buf, uint64_t bytes, size_t buflen );
     586static inline char* tr_formatter_mem_KB( char * buf, double KBps, size_t buflen ) { return tr_formatter_mem_B( buf, KBps * tr_mem_K, buflen ); }
     587static inline char* tr_formatter_mem_MB( char * buf, double MBps, size_t buflen ) { return tr_formatter_mem_B( buf, MBps * tr_mem_K * tr_mem_K, buflen ); }
     588static inline char* tr_formatter_mem_GB( char * buf, double GBps, size_t buflen ) { return tr_formatter_mem_B( buf, GBps * tr_mem_K * tr_mem_K * tr_mem_K, buflen ); }
    578589
    579590/* format a file size into a user-readable string. */
    580 char* tr_formatter_size( char * buf, uint64_t bytes, size_t buflen );
    581 
    582 /* format a memory size into a user-readable string. */
    583 char* tr_formatter_mem( char * buf, uint64_t bytes, size_t buflen );
    584 
    585 unsigned int tr_formatter_speed_k( void );
     591extern unsigned int tr_size_K;
     592char* tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen );
     593static inline char* tr_formatter_size_KB( char * buf, double KBps, size_t buflen ) { return tr_formatter_size_B( buf, KBps * tr_size_K, buflen ); }
     594static inline char* tr_formatter_size_MB( char * buf, double MBps, size_t buflen ) { return tr_formatter_size_B( buf, MBps * tr_size_K * tr_size_K, buflen ); }
     595static inline char* tr_formatter_size_GB( char * buf, double GBps, size_t buflen ) { return tr_formatter_size_B( buf, GBps * tr_size_K * tr_size_K * tr_size_K, buflen ); }
    586596
    587597
  • trunk/qt/formatter.cc

    r10933 r10937  
    4545***/
    4646
     47Speed
     48Speed :: fromKBps( double KBps )
     49{
     50    return KBps * Formatter::speed_K;
     51}
     52
     53/***
     54****
     55***/
     56
    4757QString
    4858Formatter :: memToString( double bytes )
     
    5262    else {
    5363        char buf[128];
    54         tr_formatter_mem( buf, bytes, sizeof( buf ) );
     64        tr_formatter_mem_B( buf, bytes, sizeof( buf ) );
    5565        return buf;
    5666    }
     
    6474    else {
    6575        char buf[128];
    66         tr_formatter_size( buf, bytes, sizeof( buf ) );
     76        tr_formatter_size_B( buf, bytes, sizeof( buf ) );
    6777        return buf;
    6878    }
     
    7686    else {
    7787        char buf[128];
    78         tr_formatter_speed( buf, speed.Bps( ), sizeof( buf ) );
     88        tr_formatter_speed_KBps( buf, speed.Bps( ), sizeof( buf ) );
    7989        return buf;
    8090    }
  • trunk/qt/mainwin.cc

    r10933 r10937  
    550550        g->addAction( a );
    551551        connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) );
    552         a = myDlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( currentVal ) ) ) );
     552        a = myDlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( currentVal ) ) ) );
    553553        a->setCheckable( true );
    554554        a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::DSPEED << currentVal << Prefs::DSPEED_ENABLED << true );
     
    557557        sub->addSeparator( );
    558558        foreach( int i, stockSpeeds ) {
    559             const int Bps = i * Formatter::speed_K;
    560             a = sub->addAction( Formatter::speedToString( Speed::fromBps( Bps ) ) );
    561             a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::DSPEED << Bps << Prefs::DSPEED_ENABLED << true );
     559            a = sub->addAction( Formatter::speedToString( Speed::fromKBps( i ) ) );
     560            a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::DSPEED << i << Prefs::DSPEED_ENABLED << true );
    562561            connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs()));
    563562        }
     
    571570        g->addAction( a );
    572571        connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) );
    573         a = myUlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( currentVal ) ) ) );
     572        a = myUlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( currentVal ) ) ) );
    574573        a->setCheckable( true );
    575574        a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::USPEED << currentVal << Prefs::USPEED_ENABLED << true );
     
    578577        sub->addSeparator( );
    579578        foreach( int i, stockSpeeds ) {
    580             const int Bps = i * Formatter::speed_K;
    581             a = sub->addAction( Formatter::speedToString( Speed::fromBps( Bps ) ) );
    582             a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::USPEED << Bps << Prefs::USPEED_ENABLED << true );
     579            a = sub->addAction( Formatter::speedToString( Speed::fromKBps( i ) ) );
     580            a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::USPEED << i << Prefs::USPEED_ENABLED << true );
    583581            connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs()));
    584582        }
     
    10141012
    10151013        case Prefs::DSPEED:
    1016             myDlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( myPrefs.get<int>(key) ) ) ) );
     1014            myDlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( myPrefs.get<int>(key) ) ) ) );
    10171015            break;
    10181016
     
    10221020
    10231021        case Prefs::USPEED:
    1024             myUlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( myPrefs.get<int>(key) ) ) ) );
     1022            myUlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( myPrefs.get<int>(key) ) ) ) );
    10251023            break;
    10261024
     
    10881086            const QString fmt = b ? tr( "Click to disable Temporary Speed Limits\n(%1 down, %2 up)" )
    10891087                                  : tr( "Click to enable Temporary Speed Limits\n(%1 down, %2 up)" );
    1090             const Speed d = Speed::fromBps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_DOWN ) );
    1091             const Speed u = Speed::fromBps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_UP ) );
     1088            const Speed d = Speed::fromKBps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_DOWN ) );
     1089            const Speed u = Speed::fromKBps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_UP ) );
    10921090            myAltSpeedButton->setToolTip( fmt.arg( Formatter::speedToString( d ) )
    10931091                                             .arg( Formatter::speedToString( u ) ) );
  • trunk/qt/prefs-dialog.cc

    r10933 r10937  
    5252{
    5353    const char * PREF_KEY( "pref-key" );
    54     const char * MULTIPLIER_KEY( "multiplier-key" );
    5554};
    5655
     
    8584    const QObject * spin( sender()->property( "SPIN" ).value<QObject*>( ) );
    8685    const int key = spin->property( PREF_KEY ).toInt( );
    87     const int multiplier = spin->property( MULTIPLIER_KEY ).toInt( );
    8886
    8987    const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin );
    9088    if( d != 0 )
    91         myPrefs.set( key, multiplier * d->value( ) );
     89        myPrefs.set( key, d->value( ) );
    9290    else
    93         myPrefs.set( key, multiplier * qobject_cast<const QSpinBox*>(spin)->value( ) );
     91        myPrefs.set( key, qobject_cast<const QSpinBox*>(spin)->value( ) );
    9492}
    9593
     
    117115
    118116QSpinBox *
    119 PrefsDialog :: spinBoxNew( int key, int low, int high, int step, int multiplier )
     117PrefsDialog :: spinBoxNew( int key, int low, int high, int step )
    120118{
    121119    QSpinBox * spin = new QSpinBox( );
    122120    spin->setRange( low, high );
    123121    spin->setSingleStep( step );
    124     spin->setValue( myPrefs.getInt( key ) / multiplier );
     122    spin->setValue( myPrefs.getInt( key ) );
    125123    spin->setProperty( PREF_KEY, key );
    126     spin->setProperty( MULTIPLIER_KEY, multiplier );
    127124    connect( spin, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged(int)));
    128125    myWidgets.insert( key, spin );
     
    139136
    140137QDoubleSpinBox *
    141 PrefsDialog :: doubleSpinBoxNew( int key, double low, double high, double step, int decimals, int multiplier )
     138PrefsDialog :: doubleSpinBoxNew( int key, double low, double high, double step, int decimals )
    142139{
    143140    QDoubleSpinBox * spin = new QDoubleSpinBox( );
     
    145142    spin->setSingleStep( step );
    146143    spin->setDecimals( decimals );
    147     spin->setValue( myPrefs.getDouble( key ) / multiplier );
    148144    spin->setProperty( PREF_KEY, key );
    149     spin->setProperty( MULTIPLIER_KEY, multiplier );
    150145    connect( spin, SIGNAL(valueChanged(double)), this, SLOT(doubleSpinBoxChanged(double)));
    151146    myWidgets.insert( key, spin );
     
    274269
    275270        l = checkBoxNew( tr( "Limit &download speed (%1):" ).arg( Formatter::speed_K_str ), Prefs::DSPEED_ENABLED );
    276         r = spinBoxNew( Prefs::DSPEED, 0, INT_MAX, 5, Formatter::speed_K );
     271        r = spinBoxNew( Prefs::DSPEED, 0, INT_MAX, 5 );
    277272        hig->addRow( l, r );
    278273        enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r );
    279274
    280275        l = checkBoxNew( tr( "Limit &upload speed (%1):" ).arg( Formatter::speed_K_str ), Prefs::USPEED_ENABLED );
    281         r = spinBoxNew( Prefs::USPEED, 0, INT_MAX, 5, Formatter::speed_K );
     276        r = spinBoxNew( Prefs::USPEED, 0, INT_MAX, 5 );
    282277        hig->addRow( l, r );
    283278        enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r );
     
    300295
    301296        s = tr( "Limit d&ownload speed (%1):" ).arg( Formatter::speed_K_str );
    302         r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5, Formatter::speed_K );
     297        r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5 );
    303298        hig->addRow( s, r );
    304299
    305300        s = tr( "Limit u&pload speed (%1):" ).arg( Formatter::speed_K_str );
    306         r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5, Formatter::speed_K );
     301        r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5 );
    307302        hig->addRow( s, r );
    308303
  • trunk/qt/prefs-dialog.h

    r10931 r10937  
    6565
    6666    private:
    67         QDoubleSpinBox * doubleSpinBoxNew( int key, double low, double high, double step, int decimals, int multiplier=1 );
     67        QDoubleSpinBox * doubleSpinBoxNew( int key, double low, double high, double step, int decimals );
    6868        QCheckBox * checkBoxNew( const QString& text, int key );
    69         QSpinBox * spinBoxNew( int key, int low, int high, int step, int multiplier=1 );
     69        QSpinBox * spinBoxNew( int key, int low, int high, int step );
    7070        QTimeEdit * timeEditNew( int key );
    7171        QLineEdit * lineEditNew( int key, int mode = 0 );
  • trunk/qt/prefs.cc

    r10931 r10937  
    6565
    6666    /* libtransmission settings */
    67     { ALT_SPEED_LIMIT_UP, TR_PREFS_KEY_ALT_SPEED_UP_Bps, QVariant::Int },
    68     { ALT_SPEED_LIMIT_DOWN, TR_PREFS_KEY_ALT_SPEED_DOWN_Bps, QVariant::Int },
     67    { ALT_SPEED_LIMIT_UP, TR_PREFS_KEY_ALT_SPEED_UP_KBps, QVariant::Int },
     68    { ALT_SPEED_LIMIT_DOWN, TR_PREFS_KEY_ALT_SPEED_DOWN_KBps, QVariant::Int },
    6969    { ALT_SPEED_LIMIT_ENABLED, TR_PREFS_KEY_ALT_SPEED_ENABLED, QVariant::Bool },
    7070    { ALT_SPEED_LIMIT_TIME_BEGIN, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, QVariant::Int },
     
    7373    { ALT_SPEED_LIMIT_TIME_DAY, TR_PREFS_KEY_ALT_SPEED_TIME_DAY, QVariant::Int },
    7474    { BLOCKLIST_ENABLED, TR_PREFS_KEY_BLOCKLIST_ENABLED, QVariant::Bool },
    75     { DSPEED, TR_PREFS_KEY_DSPEED_Bps, QVariant::Int },
     75    { DSPEED, TR_PREFS_KEY_DSPEED_KBps, QVariant::Int },
    7676    { DSPEED_ENABLED, TR_PREFS_KEY_DSPEED_ENABLED, QVariant::Bool },
    7777    { DOWNLOAD_DIR, TR_PREFS_KEY_DOWNLOAD_DIR, QVariant::String },
     
    116116    { RPC_WHITELIST, TR_PREFS_KEY_RPC_WHITELIST, QVariant::String },
    117117    { USPEED_ENABLED, TR_PREFS_KEY_USPEED_ENABLED, QVariant::Bool },
    118     { USPEED, TR_PREFS_KEY_USPEED_Bps, QVariant::Int },
     118    { USPEED, TR_PREFS_KEY_USPEED_KBps, QVariant::Int },
    119119    { UPLOAD_SLOTS_PER_TORRENT, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, QVariant::Int }
    120120};
  • trunk/qt/session.h

    r10908 r10937  
    2323
    2424#include <libtransmission/transmission.h>
    25 
    26 #include "speed.h"
    2725
    2826extern "C"
  • trunk/qt/speed.h

    r10931 r10937  
    2424        int Bps( ) const { return _Bps; }
    2525        bool isZero( ) const { return _Bps == 0; }
    26         static Speed fromKiBps( double KiBps ) { return Speed( KiBps*1024 ); }
     26        static Speed fromKBps( double KBps );
    2727        static Speed fromBps( int Bps ) { return Speed( Bps ); }
    2828        void setKiBps( double KiBps ) { setBps( KiBps*1024 ); }
  • trunk/qt/torrent.cc

    r10872 r10937  
    5454{
    5555    { ID, "id", QVariant::Int, INFO, },
    56     { UPLOAD_SPEED, "rateUpload", QVariant::Int, STAT } /* B/s */,
    57     { DOWNLOAD_SPEED, "rateDownload", QVariant::Int, STAT }, /* B/s */
     56    { UPLOAD_SPEED, "rateUpload", QVariant::Double, STAT } /* KBps */,
     57    { DOWNLOAD_SPEED, "rateDownload", QVariant::Double, STAT }, /* KBps */
    5858    { DOWNLOAD_DIR, "downloadDir", QVariant::String, STAT },
    5959    { ACTIVITY, "status", QVariant::Int, STAT },
     
    9090    { SEED_RATIO_LIMIT, "seedRatioLimit", QVariant::Double, STAT },
    9191    { SEED_RATIO_MODE, "seedRatioMode", QVariant::Int, STAT },
    92     { DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* KiB/s */
     92    { DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */
    9393    { DOWN_LIMITED, "downloadLimited", QVariant::Bool, STAT_EXTRA },
    94     { UP_LIMIT, "uploadLimit", QVariant::Int, STAT_EXTRA }, /* KiB/s */
     94    { UP_LIMIT, "uploadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */
    9595    { UP_LIMITED, "uploadLimited", QVariant::Bool, STAT_EXTRA },
    9696    { HONORS_SESSION_LIMITS, "honorsSessionLimits", QVariant::Bool, STAT_EXTRA },
     
    654654            if( tr_bencDictFindReal( child, "progress", &d ) )
    655655                peer.progress = d;
    656             if( tr_bencDictFindInt( child, "rateToClient", &i ) )
    657                 peer.rateToClient = Speed::fromBps( i );
    658             if( tr_bencDictFindInt( child, "rateToPeer", &i ) )
    659                 peer.rateToPeer = Speed::fromBps( i );
     656            if( tr_bencDictFindReal( child, "rateToClient", &d ) )
     657                peer.rateToClient = Speed::fromKBps( d );
     658            if( tr_bencDictFindReal( child, "rateToPeer", &d ) )
     659                peer.rateToPeer = Speed::fromKBps( d );
    660660            peerList << peer;
    661661        }
  • trunk/qt/torrent.h

    r10931 r10937  
    280280        int connectedPeers( ) const { return getInt( PEERS_CONNECTED ); }
    281281        int connectedPeersAndWebseeds( ) const { return connectedPeers( ) + getInt( WEBSEEDS_SENDING_TO_US ); }
    282         Speed downloadSpeed( ) const { return Speed::fromBps( getInt( DOWNLOAD_SPEED ) ); }
    283         Speed uploadSpeed( ) const { return Speed::fromBps( getInt( UPLOAD_SPEED ) ); }
     282        Speed downloadSpeed( ) const { return Speed::fromKBps( getDouble( DOWNLOAD_SPEED ) ); }
     283        Speed uploadSpeed( ) const { return Speed::fromKBps( getDouble( UPLOAD_SPEED ) ); }
    284284        double getVerifyProgress( ) const { return getDouble( PERCENT_VERIFIED ); }
    285285        bool hasFileSubstring( const QString& substr ) const;
    286286        bool hasTrackerSubstring( const QString& substr ) const;
    287         Speed uploadLimit( ) const { return Speed::fromBps( getInt( UP_LIMIT ) ); }
    288         Speed downloadLimit( ) const { return Speed::fromBps( getInt( DOWN_LIMIT ) ); }
     287        Speed uploadLimit( ) const { return Speed::fromKBps( getInt( UP_LIMIT ) ); }
     288        Speed downloadLimit( ) const { return Speed::fromKBps( getInt( DOWN_LIMIT ) ); }
    289289        bool uploadIsLimited( ) const { return getBool( UP_LIMITED ); }
    290290        bool downloadIsLimited( ) const { return getBool( DOWN_LIMITED ); }
  • trunk/utils/show.c

    r10932 r10937  
    105105        printf( "  Comment: %s\n", inf->comment );
    106106    printf( "  Piece Count: %d\n", inf->pieceCount );
    107     printf( "  Piece Size: %s\n", tr_formatter_mem( buf, inf->pieceSize, sizeof( buf ) ) );
    108     printf( "  Total Size: %s\n", tr_formatter_size( buf, inf->totalSize, sizeof( buf ) ) );
     107    printf( "  Piece Size: %s\n", tr_formatter_mem_B( buf, inf->pieceSize, sizeof( buf ) ) );
     108    printf( "  Total Size: %s\n", tr_formatter_size_B( buf, inf->totalSize, sizeof( buf ) ) );
    109109    printf( "  Privacy: %s\n", inf->isPrivate ? "Private torrent" : "Public torrent" );
    110110
     
    131131    printf( "\nFILES\n\n" );
    132132    for( i=0; i<(int)inf->fileCount; ++i )
    133         printf( "  %s (%s)\n", inf->files[i].name, tr_formatter_size( buf, inf->files[i].length, sizeof( buf ) ) );
     133        printf( "  %s (%s)\n", inf->files[i].name, tr_formatter_size_B( buf, inf->files[i].length, sizeof( buf ) ) );
    134134}
    135135
Note: See TracChangeset for help on using the changeset viewer.