Changeset 10937
- Timestamp:
- Jul 4, 2010, 6:07:21 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/cli.c
r10931 r10937 158 158 char ratioStr[80]; 159 159 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 ) ); 162 162 tr_strlratio( ratioStr, st->ratio, sizeof( ratioStr ) ); 163 163 … … 177 177 char ratioStr[80]; 178 178 179 tr_formatter_speed ( upStr, st->pieceUploadSpeed_Bps, sizeof( upStr ) );179 tr_formatter_speed_KBps( upStr, st->pieceUploadSpeed_KBps, sizeof( upStr ) ); 180 180 tr_strlratio( ratioStr, st->ratio, sizeof( ratioStr ) ); 181 181 … … 359 359 case 'B': tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, FALSE ); 360 360 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 ) ); 362 362 tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, TRUE ); 363 363 break; … … 377 377 case 't': tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_SOCKET_TOS, atoi( optarg ) ); 378 378 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 ) ); 380 380 tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED, TRUE ); 381 381 break; -
trunk/daemon/remote.c
r10931 r10937 141 141 142 142 static char* 143 strlratio( char * buf, double numerator, doubledenominator, size_t buflen )143 strlratio( char * buf, int64_t numerator, int64_t denominator, size_t buflen ) 144 144 { 145 145 double ratio; 146 146 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 ) 150 150 ratio = TR_RATIO_INF; 151 151 else … … 161 161 tr_strlcpy( buf, "None", buflen ); 162 162 else 163 tr_formatter_mem ( buf, bytes, buflen );163 tr_formatter_mem_B( buf, bytes, buflen ); 164 164 165 165 return buf; … … 172 172 tr_strlcpy( buf, "None", buflen ); 173 173 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 ); 186 175 187 176 return buf; … … 832 821 printf( " ETA: %s\n", tr_strltime( buf, i, sizeof( buf ) ) ); 833 822 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 ) ) ); 835 824 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 ) ) ); 837 826 if( tr_bencDictFindInt( t, "haveUnchecked", &i ) 838 827 && tr_bencDictFindInt( t, "haveValid", &j ) ) … … 1107 1096 printf( " Download Limit: " ); 1108 1097 if( boolVal ) 1109 printf( "%s\n", strlspeed( buf, i, sizeof( buf ) ) );1098 printf( "%s\n", tr_formatter_speed_KBps( buf, i, sizeof( buf ) ) ); 1110 1099 else 1111 1100 printf( "Unlimited\n" ); … … 1116 1105 printf( " Upload Limit: " ); 1117 1106 if( boolVal ) 1118 printf( "%s\n", strlspeed( buf, i, sizeof( buf ) ) );1107 printf( "%s\n", tr_formatter_speed_KBps( buf, i, sizeof( buf ) ) ); 1119 1108 else 1120 1109 printf( "Unlimited\n" ); … … 1241 1230 printf( "%-20s %-12s %-5.1f %6.1f %6.1f %s\n", 1242 1231 address, flagstr, (progress*100.0), 1243 rateToClient / (double)SPEED_K,1244 rateToPeer / (double)SPEED_K,1232 (double)rateToClient, 1233 (double)rateToPeer, 1245 1234 client ); 1246 1235 } … … 1400 1389 if( tr_bencDictFindStr( args, TR_PREFS_KEY_ENCRYPTION, &str ) ) 1401 1390 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 ) ) ); 1404 1393 printf( "\n" ); 1405 1394 … … 1409 1398 double seedRatioLimit; 1410 1399 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 ) && 1412 1401 tr_bencDictFindBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, &altEnabled ) && 1413 1402 tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, &altBegin ) && … … 1415 1404 tr_bencDictFindInt ( args, TR_PREFS_KEY_ALT_SPEED_TIME_END, &altEnd ) && 1416 1405 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 ) && 1418 1407 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 ) && 1420 1409 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 ) && 1422 1411 tr_bencDictFindBool( args, TR_PREFS_KEY_USPEED_ENABLED, &upEnabled ) && 1423 1412 tr_bencDictFindReal( args, "seedRatioLimit", &seedRatioLimit ) && … … 1438 1427 1439 1428 if( altEnabled ) 1440 strlspeed( buf, altUp, sizeof( buf ) );1429 tr_formatter_speed_KBps( buf, altUp, sizeof( buf ) ); 1441 1430 else if( upEnabled ) 1442 strlspeed( buf, upLimit, sizeof( buf ) );1431 tr_formatter_speed_KBps( buf, upLimit, sizeof( buf ) ); 1443 1432 else 1444 1433 tr_strlcpy( buf, "Unlimited", sizeof( buf ) ); … … 1446 1435 buf, 1447 1436 upEnabled ? "Enabled" : "Disabled", 1448 strlspeed( buf2, upLimit, sizeof( buf2 ) ),1437 tr_formatter_speed_KBps( buf2, upLimit, sizeof( buf2 ) ), 1449 1438 altEnabled ? "Enabled" : "Disabled", 1450 strlspeed( buf3, altUp, sizeof( buf3 ) ) );1439 tr_formatter_speed_KBps( buf3, altUp, sizeof( buf3 ) ) ); 1451 1440 1452 1441 if( altEnabled ) 1453 strlspeed( buf, altDown, sizeof( buf ) );1442 tr_formatter_speed_KBps( buf, altDown, sizeof( buf ) ); 1454 1443 else if( downEnabled ) 1455 strlspeed( buf, downLimit, sizeof( buf ) );1444 tr_formatter_speed_KBps( buf, downLimit, sizeof( buf ) ); 1456 1445 else 1457 1446 tr_strlcpy( buf, "Unlimited", sizeof( buf ) ); … … 1459 1448 buf, 1460 1449 downEnabled ? "Enabled" : "Disabled", 1461 strlspeed( buf2, downLimit, sizeof( buf2 ) ),1450 tr_formatter_speed_KBps( buf2, downLimit, sizeof( buf2 ) ), 1462 1451 altEnabled ? "Enabled" : "Disabled", 1463 strlspeed( buf2, altDown, sizeof( buf2 ) ) );1452 tr_formatter_speed_KBps( buf2, altDown, sizeof( buf2 ) ) ); 1464 1453 1465 1454 if( altTimeEnabled ) { … … 1846 1835 case 971: tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, FALSE ); 1847 1836 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 ) ); 1851 1840 break; 1852 1841 case 974: tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, TRUE ); … … 1865 1854 case 'C': tr_bencDictAddBool( args, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, FALSE ); 1866 1855 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) ); 1868 1857 break; 1869 1858 case 910: tr_bencDictAddStr( args, TR_PREFS_KEY_ENCRYPTION, "required" ); … … 1923 1912 { 1924 1913 case 'd': if( targs ) { 1925 tr_bencDictAddInt( targs, "downloadLimit", numarg( optarg ) * SPEED_K);1914 tr_bencDictAddInt( targs, "downloadLimit", numarg( optarg ) ); 1926 1915 tr_bencDictAddBool( targs, "downloadLimited", TRUE ); 1927 1916 } 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 ) ); 1929 1918 tr_bencDictAddBool( sargs, TR_PREFS_KEY_DSPEED_ENABLED, TRUE ); 1930 1919 } … … 1936 1925 break; 1937 1926 case 'u': if( targs ) { 1938 tr_bencDictAddInt( targs, "uploadLimit", numarg( optarg ) * SPEED_K);1927 tr_bencDictAddInt( targs, "uploadLimit", numarg( optarg ) ); 1939 1928 tr_bencDictAddBool( targs, "uploadLimited", TRUE ); 1940 1929 } 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 ) ); 1942 1931 tr_bencDictAddBool( sargs, TR_PREFS_KEY_USPEED_ENABLED, TRUE ); 1943 1932 } -
trunk/doc/rpc-spec.txt
r10931 r10937 90 90 ----------------------+------------------------------------------------- 91 91 "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) 93 93 "downloadLimited" | boolean true if "downloadLimit" is honored 94 94 "files-wanted" | array indices of file(s) to download … … 106 106 "trackerEdit" | object (see below) 107 107 "trackerRemove" | object (see below) 108 "uploadLimit" | number maximum upload speed ( bytes per second)108 "uploadLimit" | number maximum upload speed (KBps) 109 109 "uploadLimited" | boolean true if "uploadLimit" is honored 110 110 | … … 419 419 string | value type & description 420 420 ------------------------------+------------------------------------------------- 421 "alt-speed-down" | number max global download speed ( in bytes per second)421 "alt-speed-down" | number max global download speed (KBps) 422 422 "alt-speed-enabled" | boolean true means use the alt speeds 423 423 "alt-speed-time-begin" | number when to turn on alt speeds (units: minutes after midnight) … … 425 425 "alt-speed-time-end" | number when to turn off alt speeds (units: same) 426 426 "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) 428 428 "blocklist-enabled" | boolean true means enabled 429 429 "blocklist-size" | number number of rules in the blocklist 430 "cache-size" | number maximum size (in bytes) of the disk cache430 "cache-size" | number maximum size of the disk cache (MB) 431 431 "config-dir" | string location of transmission's configuration directory 432 432 "download-dir" | string default path to download torrents … … 449 449 "seedRatioLimit" | double the default seed ratio for torrents to use 450 450 "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) 452 452 "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) 454 454 "speed-limit-up-enabled" | boolean true means enabled 455 455 "start-added-torrents" | boolean true means added torrents will be started right away … … 629 629 | | yes | torrent-get | new arg "isFinished" 630 630 ------+---------+-----------+----------------+------------------------------- 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" 638 632 | | yes | session-set | new arg "trash-original-torrent-files" 639 633 | | yes | session-get | new arg "start-added-torrents" -
trunk/gtk/details.c
r10931 r10937 220 220 /* downLimitSpin */ 221 221 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 ); 223 223 int i; 224 224 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 ) ) ) 226 226 break; 227 227 if( i == n ) … … 244 244 /* upLimitSpin */ 245 245 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 ); 247 247 int i; 248 248 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 ) ) ) 250 250 break; 251 251 if( i == n ) … … 601 601 const char * stateString; 602 602 char buf[512]; 603 doubleavailable = 0;604 doublesizeWhenDone = 0;603 uint64_t available = 0; 604 uint64_t sizeWhenDone = 0; 605 605 const tr_stat ** stats = g_new( const tr_stat*, n ); 606 606 const tr_info ** infos = g_new( const tr_info*, n ); … … 762 762 else if( pieceSize >= 0 ) { 763 763 char piecebuf[128]; 764 tr_formatter_mem ( piecebuf, pieceSize, sizeof( piecebuf ) );764 tr_formatter_mem_B( piecebuf, pieceSize, sizeof( piecebuf ) ); 765 765 g_snprintf( buf, sizeof( buf ), 766 766 ngettext( "%1$s (%2$'d piece @ %3$s)", … … 783 783 str = none; 784 784 else { 785 doubleleftUntilDone = 0;786 doublehaveUnchecked = 0;787 doublehaveValid = 0;788 doubleverifiedPieces = 0;785 uint64_t leftUntilDone = 0; 786 uint64_t haveUnchecked = 0; 787 uint64_t haveValid = 0; 788 uint32_t verifiedPieces = 0; 789 789 for( i=0; i<n; ++i ) { 790 790 const tr_stat * st = stats[i]; 791 const double v = st->haveValid;792 791 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; 795 794 sizeWhenDone += st->sizeWhenDone; 796 795 leftUntilDone += st->leftUntilDone; … … 1045 1044 WEBSEED_COL_WAS_UPDATED, 1046 1045 WEBSEED_COL_URL, 1047 WEBSEED_COL_DOWNLOAD_RATE_ INT,1046 WEBSEED_COL_DOWNLOAD_RATE_DOUBLE, 1048 1047 WEBSEED_COL_DOWNLOAD_RATE_STRING, 1049 1048 N_WEBSEED_COLS … … 1056 1055 { 1057 1056 case WEBSEED_COL_URL: return _( "Webseeds" ); 1058 case WEBSEED_COL_DOWNLOAD_RATE_ INT:1057 case WEBSEED_COL_DOWNLOAD_RATE_DOUBLE: 1059 1058 case WEBSEED_COL_DOWNLOAD_RATE_STRING: return _( "Down" ); 1060 1059 default: return ""; … … 1079 1078 PEER_COL_ADDRESS, 1080 1079 PEER_COL_ADDRESS_COLLATED, 1081 PEER_COL_DOWNLOAD_RATE_ INT,1080 PEER_COL_DOWNLOAD_RATE_DOUBLE, 1082 1081 PEER_COL_DOWNLOAD_RATE_STRING, 1083 PEER_COL_UPLOAD_RATE_ INT,1082 PEER_COL_UPLOAD_RATE_DOUBLE, 1084 1083 PEER_COL_UPLOAD_RATE_STRING, 1085 1084 PEER_COL_CLIENT, … … 1109 1108 case PEER_COL_ADDRESS: return _( "Address" ); 1110 1109 case PEER_COL_DOWNLOAD_RATE_STRING: 1111 case PEER_COL_DOWNLOAD_RATE_ INT: return _( "Down" );1110 case PEER_COL_DOWNLOAD_RATE_DOUBLE: return _( "Down" ); 1112 1111 case PEER_COL_UPLOAD_RATE_STRING: 1113 case PEER_COL_UPLOAD_RATE_ INT: return _( "Up" );1112 case PEER_COL_UPLOAD_RATE_DOUBLE: return _( "Up" ); 1114 1113 case PEER_COL_CLIENT: return _( "Client" ); 1115 1114 case PEER_COL_PROGRESS: return _( "%" ); … … 1139 1138 G_TYPE_STRING, /* address */ 1140 1139 G_TYPE_STRING, /* collated address */ 1141 G_TYPE_ INT,/* download speed int */1140 G_TYPE_DOUBLE, /* download speed int */ 1142 1141 G_TYPE_STRING, /* download speed string */ 1143 G_TYPE_ INT,/* upload speed int */1142 G_TYPE_DOUBLE, /* upload speed int */ 1144 1143 G_TYPE_STRING, /* upload speed string */ 1145 1144 G_TYPE_STRING, /* client */ … … 1203 1202 char cancelled_by_client[64]; 1204 1203 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 ) ); 1207 1206 else 1208 1207 *up_speed = '\0'; 1209 1208 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 ) ); 1212 1211 else 1213 1212 *down_speed = '\0'; … … 1249 1248 PEER_COL_DOWNLOAD_REQUEST_COUNT_INT, peer->pendingReqsToPeer, 1250 1249 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, 1252 1251 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, 1254 1253 PEER_COL_UPLOAD_RATE_STRING, up_speed, 1255 1254 PEER_COL_STATUS, peer->flagStr, … … 1397 1396 const tr_torrent * tor = torrents[i]; 1398 1397 const tr_info * inf = tr_torrentInfo( tor ); 1399 int * speeds_Bps = tr_torrentWebSpeeds_Bps( tor );1398 double * speeds_KBps = tr_torrentWebSpeeds_KBps( tor ); 1400 1399 for( j=0; j<inf->webseedCount; ++j ) { 1401 1400 char buf[128]; … … 1408 1407 p = gtk_tree_row_reference_get_path( ref ); 1409 1408 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 ) ); 1412 1411 else 1413 1412 *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], 1415 1414 WEBSEED_COL_DOWNLOAD_RATE_STRING, buf, 1416 1415 WEBSEED_COL_WAS_UPDATED, TRUE, … … 1418 1417 gtk_tree_path_free( p ); 1419 1418 } 1420 tr_free( speeds_ Bps );1419 tr_free( speeds_KBps ); 1421 1420 } 1422 1421 … … 1612 1611 g_object_set( G_OBJECT( r ), "xalign", 1.0f, NULL ); 1613 1612 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; 1615 1614 break; 1616 1615 case PEER_COL_UPLOAD_RATE_STRING: … … 1618 1617 g_object_set( G_OBJECT( r ), "xalign", 1.0f, NULL ); 1619 1618 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; 1621 1620 break; 1622 1621 … … 1687 1686 r = gtk_cell_renderer_text_new( ); 1688 1687 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 ); 1690 1689 gtk_tree_view_append_column( GTK_TREE_VIEW( v ), c ); 1691 1690 -
trunk/gtk/main.c
r10931 r10937 1204 1204 tr_sessionLimitSpeed( tr, TR_DOWN, pref_flag_get( key ) ); 1205 1205 } 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 ) ); 1209 1209 } 1210 1210 else if( !strcmp( key, TR_PREFS_KEY_USPEED_ENABLED ) ) … … 1212 1212 tr_sessionLimitSpeed( tr, TR_UP, pref_flag_get( key ) ); 1213 1213 } 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 ) ); 1217 1217 } 1218 1218 else if( !strcmp( key, TR_PREFS_KEY_RATIO_ENABLED ) ) … … 1300 1300 tr_sessionSetProxyPort( tr, pref_int_get( key ) ); 1301 1301 } 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 ) ); 1309 1309 } 1310 1310 else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_ENABLED ) ) -
trunk/gtk/msgwin.c
r10863 r10937 38 38 struct MsgData 39 39 { 40 TrCore *core;41 GtkTreeView *view;42 GtkListStore *store;43 GtkTreeModel *filter;44 GtkTreeModel *sort;45 intmaxLevel;40 TrCore * core; 41 GtkTreeView * view; 42 GtkListStore * store; 43 GtkTreeModel * filter; 44 GtkTreeModel * sort; 45 tr_msg_level maxLevel; 46 46 gboolean isPaused; 47 47 guint refresh_tag; -
trunk/gtk/torrent-cell-renderer.c
r10931 r10937 155 155 getShortTransferString( const tr_torrent * tor, 156 156 const tr_stat * torStat, 157 int uploadSpeed_Bps,158 int downloadSpeed_Bps,157 double uploadSpeed_KBps, 158 double downloadSpeed_KBps, 159 159 char * buf, 160 160 size_t buflen ) … … 166 166 167 167 if( haveDown ) 168 tr_ strlspeed( downStr, downloadSpeed_Bps, sizeof( downStr ) );168 tr_formatter_speed_KBps( downStr, downloadSpeed_KBps, sizeof( downStr ) ); 169 169 if( haveUp ) 170 tr_ strlspeed( upStr, uploadSpeed_Bps, sizeof( upStr ) );170 tr_formatter_speed_KBps( upStr, uploadSpeed_KBps, sizeof( upStr ) ); 171 171 172 172 if( haveDown && haveUp ) … … 195 195 getShortStatusString( const tr_torrent * tor, 196 196 const tr_stat * torStat, 197 int uploadSpeed_Bps,198 int downloadSpeed_Bps )197 double uploadSpeed_KBps, 198 double downloadSpeed_KBps ) 199 199 { 200 200 GString * gstr = g_string_new( NULL ); … … 229 229 g_string_append( gstr, ", " ); 230 230 } 231 getShortTransferString( tor, torStat, uploadSpeed_ Bps, downloadSpeed_Bps, buf, sizeof( buf ) );231 getShortTransferString( tor, torStat, uploadSpeed_KBps, downloadSpeed_KBps, buf, sizeof( buf ) ); 232 232 g_string_append( gstr, buf ); 233 233 break; … … 244 244 getStatusString( const tr_torrent * tor, 245 245 const tr_stat * torStat, 246 const int uploadSpeed_Bps,247 const int downloadSpeed_Bps )246 const double uploadSpeed_KBps, 247 const double downloadSpeed_KBps ) 248 248 { 249 249 const int isActive = torStat->activity != TR_STATUS_STOPPED; … … 266 266 case TR_STATUS_CHECK: 267 267 { 268 char * pch = getShortStatusString( tor, torStat, uploadSpeed_ Bps, downloadSpeed_Bps );268 char * pch = getShortStatusString( tor, torStat, uploadSpeed_KBps, downloadSpeed_KBps ); 269 269 g_string_assign( gstr, pch ); 270 270 g_free( pch ); … … 310 310 { 311 311 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 ) ); 313 313 if( *buf ) 314 314 g_string_append_printf( gstr, " - %s", buf ); … … 337 337 the individual torrents' speeds and the status bar's overall speed 338 338 in sync even if they refresh at slightly different times */ 339 int upload_speed_Bps;339 double upload_speed_KBps; 340 340 341 341 /* @see upload_speed_Bps */ 342 int download_speed_Bps;342 double download_speed_KBps; 343 343 344 344 gboolean compact; … … 398 398 icon = get_icon( tor, COMPACT_ICON_SIZE, widget ); 399 399 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 ); 401 401 402 402 /* get the idealized cell dimensions */ … … 456 456 icon = get_icon( tor, FULL_ICON_SIZE, widget ); 457 457 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 ); 459 459 progress = getProgressString( tor, inf, st ); 460 460 … … 560 560 icon = get_icon( tor, COMPACT_ICON_SIZE, widget ); 561 561 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 ); 563 563 564 564 /* get the cell dimensions */ … … 664 664 icon = get_icon( tor, FULL_ICON_SIZE, widget ); 665 665 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 ); 667 667 progress = getProgressString( tor, inf, st ); 668 668 … … 783 783 switch( property_id ) 784 784 { 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; 790 790 default: G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, pspec ); break; 791 791 } … … 804 804 { 805 805 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; 808 808 case P_BAR_HEIGHT: g_value_set_int( v, p->bar_height ); break; 809 809 case P_COMPACT: g_value_set_boolean( v, p->compact ); break; … … 854 854 855 855 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 ) ); 860 860 861 861 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 ) ); 866 866 867 867 g_object_class_install_property( gobject_class, P_BAR_HEIGHT, -
trunk/gtk/tr-core.c
r10931 r10937 777 777 TR_TORRENT_TYPE, /* TrTorrent object */ 778 778 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 */ 781 781 G_TYPE_INT }; /* tr_stat.status */ 782 782 … … 921 921 MC_TORRENT, gtor, 922 922 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, 925 925 MC_ACTIVITY, st->activity, 926 926 -1 ); … … 1323 1323 { 1324 1324 int oldActivity, newActivity; 1325 intoldUpSpeed, newUpSpeed;1326 intoldDownSpeed, newDownSpeed;1325 double oldUpSpeed, newUpSpeed; 1326 double oldDownSpeed, newDownSpeed; 1327 1327 const tr_stat * st; 1328 1328 TrTorrent * gtor; … … 1339 1339 st = tr_torrentStat( tr_torrent_handle( gtor ) ); 1340 1340 newActivity = st->activity; 1341 newUpSpeed = st->pieceUploadSpeed_ Bps;1342 newDownSpeed = st->pieceDownloadSpeed_ Bps;1341 newUpSpeed = st->pieceUploadSpeed_KBps; 1342 newDownSpeed = st->pieceDownloadSpeed_KBps; 1343 1343 1344 1344 /* updating the model triggers off resort/refresh, 1345 1345 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 ) ) 1349 1349 { 1350 1350 gtk_list_store_set( GTK_LIST_STORE( model ), iter, … … 1576 1576 const double oldval = pref_double_get( key ); 1577 1577 1578 if( oldval != newval)1578 if( gtr_compare_double( oldval, newval, 4 ) ) 1579 1579 { 1580 1580 pref_double_set( key, newval ); -
trunk/gtk/tr-icon.c
r10931 r10937 68 68 tr_icon_refresh( gpointer vicon ) 69 69 { 70 intBps;71 intlimit;70 double KBps; 71 double limit; 72 72 char up[64]; 73 73 char upLimit[64]; … … 80 80 81 81 /* 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 ) 84 84 g_strlcpy( up, idle, sizeof( up ) ); 85 85 else 86 tr_formatter_speed ( up,Bps, sizeof( up ) );86 tr_formatter_speed_KBps( up, KBps, sizeof( up ) ); 87 87 88 88 /* up limit */ 89 if( !tr_sessionGetActiveSpeedLimit_ Bps( session, TR_UP, &limit ) )89 if( !tr_sessionGetActiveSpeedLimit_KBps( session, TR_UP, &limit ) ) 90 90 *upLimit = '\0'; 91 91 else { 92 92 char buf[64]; 93 tr_ strlspeed( buf, limit, sizeof( buf ) );93 tr_formatter_speed_KBps( buf, limit, sizeof( buf ) ); 94 94 g_snprintf( upLimit, sizeof( upLimit ), _( "(Limit: %s)" ), buf ); 95 95 } 96 96 97 97 /* 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 ) 100 100 g_strlcpy( down, idle, sizeof( down ) ); 101 101 else 102 tr_formatter_speed ( down,Bps, sizeof( down ) );102 tr_formatter_speed_KBps( down, KBps, sizeof( down ) ); 103 103 104 104 /* down limit */ 105 if( !tr_sessionGetActiveSpeedLimit_ Bps( session, TR_DOWN, &limit ) )105 if( !tr_sessionGetActiveSpeedLimit_KBps( session, TR_DOWN, &limit ) ) 106 106 *downLimit = '\0'; 107 107 else { 108 108 char buf[64]; 109 tr_ strlspeed( buf, limit, sizeof( buf ) );109 tr_formatter_speed_KBps( buf, limit, sizeof( buf ) ); 110 110 g_snprintf( downLimit, sizeof( downLimit ), _( "(Limit: %s)" ), buf ); 111 111 } -
trunk/gtk/tr-prefs.c
r10931 r10937 31 31 **/ 32 32 33 #define MULTIPLIER_KEY "multiplier-key"34 33 #define PREF_KEY "pref-key" 35 34 … … 107 106 /* update the core */ 108 107 const char * key = g_object_get_data( o, PREF_KEY ); 109 const int multiplier = GPOINTER_TO_INT( g_object_get_data( o, MULTIPLIER_KEY ) );110 108 111 109 if (data->isDouble) 112 110 { 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 ) ); 114 112 tr_core_set_pref_double( TR_CORE( data->core ), key, value ); 115 113 } 116 114 else 117 115 { 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 ) ); 119 117 tr_core_set_pref_int( TR_CORE( data->core ), key, value ); 120 118 } … … 165 163 new_spin_button( const char * key, 166 164 gpointer core, 167 int multiplier,168 165 int low, 169 166 int high, … … 171 168 { 172 169 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 ) );174 170 g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup( key ), g_free ); 175 171 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 ) ); 177 173 g_signal_connect( w, "value-changed", G_CALLBACK( spun_cb_int ), core ); 178 174 return w; … … 182 178 new_spin_button_double( const char * key, 183 179 gpointer core, 184 int multiplier,185 180 double low, 186 181 double high, … … 188 183 { 189 184 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 ) );191 185 g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup( key ), g_free ); 192 186 gtk_spin_button_set_digits( GTK_SPIN_BUTTON( w ), 2 ); … … 330 324 s = _( "_Seed torrent until its ratio reaches:" ); 331 325 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 ); 333 327 gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_RATIO_ENABLED ) ); 334 328 g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 ); … … 807 801 808 802 /* 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 ); 810 804 page->widgets = g_slist_append( page->widgets, w ); 811 805 w = hig_workarea_add_row( t, &row, _( "Listening _port:" ), w, NULL ); … … 1012 1006 page->proxy_widgets = g_slist_append( page->proxy_widgets, w ); 1013 1007 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 ); 1015 1009 page->proxy_widgets = g_slist_append( page->proxy_widgets, w ); 1016 1010 w = hig_workarea_add_row( t, &row, _( "Proxy _port:" ), w, NULL ); … … 1220 1214 g_snprintf( buf, sizeof( buf ), _( "Limit _download speed (%s):" ), _(speed_K_str) ); 1221 1215 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 ); 1223 1217 gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_DSPEED_ENABLED ) ); 1224 1218 g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 ); … … 1227 1221 g_snprintf( buf, sizeof( buf ), _( "Limit _upload speed (%s):" ), _(speed_K_str) ); 1228 1222 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 ); 1230 1224 gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_USPEED_ENABLED ) ); 1231 1225 g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 ); … … 1251 1245 1252 1246 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 ); 1254 1248 hig_workarea_add_row( t, &row, buf, w, NULL ); 1255 1249 1256 1250 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 ); 1258 1252 hig_workarea_add_row( t, &row, buf, w, NULL ); 1259 1253 … … 1370 1364 1371 1365 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 ); 1373 1367 hig_workarea_add_row( t, &row, s, w, NULL ); 1374 1368 … … 1395 1389 hig_workarea_add_section_title( t, &row, _( "Limits" ) ); 1396 1390 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 ); 1398 1392 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 ); 1400 1394 hig_workarea_add_row( t, &row, _( "Maximum peers _overall:" ), w, NULL ); 1401 1395 -
trunk/gtk/tr-window.c
r10931 r10937 206 206 } 207 207 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 ) ) 210 210 { 211 211 syncAltSpeedButton( p ); … … 267 267 GtkWidget * w = p->alt_speed_button; 268 268 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 ) ); 271 271 fmt = b ? _( "Click to disable Temporary Speed Limits\n(%1$s down, %2$s up)" ) 272 272 : _( "Click to enable Temporary Speed Limits\n(%1$s down, %2$s up)" ); … … 389 389 PrivateData * p = vp; 390 390 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 ) ); 392 392 tr_direction dir = GPOINTER_TO_INT( g_object_get_data( o, DIRECTION_KEY ) ); 393 393 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 ); 396 396 397 397 key = dir==TR_UP ? TR_PREFS_KEY_USPEED_ENABLED : TR_PREFS_KEY_DSPEED_ENABLED; … … 542 542 543 543 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 ) ); 545 545 gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 ); 546 546 … … 550 550 551 551 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 ) ); 553 553 gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 ); 554 554 … … 843 843 { 844 844 char buf[128]; 845 intup=0, down=0;845 double up=0, down=0; 846 846 GtkTreeIter iter; 847 847 GtkTreeModel * model = tr_core_model( p->core ); … … 849 849 if( gtk_tree_model_get_iter_first( model, &iter ) ) do 850 850 { 851 intu, d;851 double u, d; 852 852 gtk_tree_model_get( model, &iter, MC_SPEED_UP, &u, 853 853 MC_SPEED_DOWN, &d, … … 858 858 while( gtk_tree_model_iter_next( model, &iter ) ); 859 859 860 tr_ strlspeed( buf, down, sizeof( buf ) );860 tr_formatter_speed_KBps( buf, down, sizeof( buf ) ); 861 861 gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf ); 862 862 863 tr_ strlspeed( buf, up, sizeof( buf ) );863 tr_formatter_speed_KBps( buf, up, sizeof( buf ) ); 864 864 gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf ); 865 865 } -
trunk/gtk/tr-window.h
r10863 r10937 27 27 28 28 #include <gtk/gtk.h> 29 #include <libtransmission/utils.h> /* tr_formatter_speed_KBps() */ 29 30 #include "tr-core.h" 30 31 -
trunk/gtk/util.c
r10931 r10937 13 13 #include <ctype.h> /* isxdigit() */ 14 14 #include <errno.h> 15 #include <math.h> /* pow() */ 15 16 #include <stdlib.h> /* free() */ 16 17 #include <string.h> /* strcmp() */ … … 128 129 ***/ 129 130 131 int 132 gtr_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 130 145 const char* 131 146 gtr_get_unicode_string( int i ) … … 157 172 g_strlcpy( buf, _( "None" ), buflen ); 158 173 else 159 tr_formatter_size ( buf, bytes, buflen );174 tr_formatter_size_B( buf, bytes, buflen ); 160 175 161 176 return buf; … … 168 183 g_strlcpy( buf, _( "None" ), buflen ); 169 184 else 170 tr_formatter_speed ( buf, bytes_per_second, buflen );185 tr_formatter_speed_Bps( buf, bytes_per_second, buflen ); 171 186 172 187 return buf; -
trunk/gtk/util.h
r10931 r10937 78 78 char* gtr_localtime( time_t time ); 79 79 80 81 int gtr_compare_double( const double a, const double b, int decimal_places ); 82 83 80 84 /*** 81 85 **** -
trunk/libtransmission/cache.c
r10932 r10937 226 226 cache->max_blocks = getMaxBlocks( max_bytes ); 227 227 228 tr_formatter_mem ( buf, cache->max_bytes, sizeof( buf ) );228 tr_formatter_mem_B( buf, cache->max_bytes, sizeof( buf ) ); 229 229 tr_ndbg( MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks ); 230 230 -
trunk/libtransmission/peer-mgr.c
r10931 r10937 2270 2270 2271 2271 2272 int*2273 tr_peerMgrWebSpeeds_ Bps( const tr_torrent * tor )2272 double* 2273 tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor ) 2274 2274 { 2275 2275 const Torrent * t = tor->torrentPeers; … … 2277 2277 int i; 2278 2278 int webseedCount; 2279 int* ret;2279 double * ret; 2280 2280 uint64_t now; 2281 2281 … … 2286 2286 webseedCount = tr_ptrArraySize( &t->webseeds ); 2287 2287 assert( webseedCount == tor->info.webseedCount ); 2288 ret = tr_new0( int, webseedCount );2288 ret = tr_new0( double, webseedCount ); 2289 2289 now = tr_date( ); 2290 2290 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 2293 2296 ret[i] = -1.0; 2297 } 2294 2298 2295 2299 managerUnlock( t->manager ); … … 2337 2341 stat->progress = peer->progress; 2338 2342 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 ) ); 2341 2345 stat->peerIsChoked = peer->peerIsChoked; 2342 2346 stat->peerIsInterested = peer->peerIsInterested; -
trunk/libtransmission/peer-mgr.h
r10931 r10937 228 228 int tr_peerMgrGetWebseedSpeed_Bps( const tr_torrent * tor, uint64_t now ); 229 229 230 int* tr_peerMgrWebSpeeds_Bps( const tr_torrent * tor );230 double* tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor ); 231 231 232 232 -
trunk/libtransmission/rpcimpl.c
r10931 r10937 443 443 tr_bencDictAddInt ( d, "port", peer->port ); 444 444 tr_bencDictAddReal( d, "progress", peer->progress ); 445 tr_bencDictAdd Int ( d, "rateToClient", peer->rateToClient_Bps );446 tr_bencDictAdd Int ( d, "rateToPeer", peer->rateToPeer_Bps );445 tr_bencDictAddReal( d, "rateToClient", peer->rateToClient_KBps ); 446 tr_bencDictAddReal( d, "rateToPeer", peer->rateToPeer_KBps ); 447 447 } 448 448 … … 485 485 tr_bencDictAddInt( d, key, st->downloadedEver ); 486 486 else if( tr_streq( key, keylen, "downloadLimit" ) ) 487 tr_bencDictAdd Int( d, key, tr_torrentGetSpeedLimit_Bps( tor, TR_DOWN ) );487 tr_bencDictAddReal( d, key, tr_torrentGetSpeedLimit_KBps( tor, TR_DOWN ) ); 488 488 else if( tr_streq( key, keylen, "downloadLimited" ) ) 489 489 tr_bencDictAddBool( d, key, tr_torrentUsesSpeedLimit( tor, TR_DOWN ) ); … … 570 570 } 571 571 else if( tr_streq( key, keylen, "rateDownload" ) ) 572 tr_bencDictAdd Int( d, key, st->pieceDownloadSpeed_Bps );572 tr_bencDictAddReal( d, key, st->pieceDownloadSpeed_KBps ); 573 573 else if( tr_streq( key, keylen, "rateUpload" ) ) 574 tr_bencDictAdd Int( d, key, st->pieceUploadSpeed_Bps );574 tr_bencDictAddReal( d, key, st->pieceUploadSpeed_KBps ); 575 575 else if( tr_streq( key, keylen, "recheckProgress" ) ) 576 576 tr_bencDictAddReal( d, key, st->recheckProgress ); … … 600 600 tr_bencDictAddInt( d, key, st->uploadedEver ); 601 601 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 ) ); 603 603 else if( tr_streq( key, keylen, "uploadLimited" ) ) 604 604 tr_bencDictAddBool( d, key, tr_torrentUsesSpeedLimit( tor, TR_UP ) ); … … 1005 1005 errmsg = setFilePriorities( tor, TR_PRI_NORMAL, files ); 1006 1006 if( tr_bencDictFindInt( args_in, "downloadLimit", &tmp ) ) 1007 tr_torrentSetSpeedLimit_ Bps( tor, TR_DOWN, tmp );1007 tr_torrentSetSpeedLimit_KBps( tor, TR_DOWN, tmp ); 1008 1008 if( tr_bencDictFindBool( args_in, "downloadLimited", &boolVal ) ) 1009 1009 tr_torrentUseSpeedLimit( tor, TR_DOWN, boolVal ); … … 1011 1011 tr_torrentUseSessionLimits( tor, boolVal ); 1012 1012 if( tr_bencDictFindInt( args_in, "uploadLimit", &tmp ) ) 1013 tr_torrentSetSpeedLimit_ Bps( tor, TR_UP, tmp );1013 tr_torrentSetSpeedLimit_KBps( tor, TR_UP, tmp ); 1014 1014 if( tr_bencDictFindBool( args_in, "uploadLimited", &boolVal ) ) 1015 1015 tr_torrentUseSpeedLimit( tor, TR_UP, boolVal ); … … 1408 1408 assert( idle_data == NULL ); 1409 1409 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 ); 1416 1416 if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_ALT_SPEED_ENABLED, &boolVal ) ) 1417 1417 tr_sessionUseAltSpeed( session, boolVal ); … … 1462 1462 if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_TRASH_ORIGINAL, &boolVal ) ) 1463 1463 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 ); 1466 1466 if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_DSPEED_ENABLED, &boolVal ) ) 1467 1467 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 ); 1470 1470 if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_USPEED_ENABLED, &boolVal ) ) 1471 1471 tr_sessionLimitSpeed( session, TR_UP, boolVal ); … … 1508 1508 tr_sessionGetCumulativeStats( session, &cumulativeStats ); 1509 1509 1510 tr_bencDictAddInt ( args_out, "activeTorrentCount", running );1511 tr_bencDictAdd Int( 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_bencDictAdd Int( 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 ) ); 1515 1515 1516 1516 d = tr_bencDictAddDict( args_out, "cumulative-stats", 5 ); … … 1541 1541 1542 1542 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) ); 1545 1545 tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED, tr_sessionUsesAltSpeed(s) ); 1546 1546 tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, tr_sessionGetAltSpeedBegin(s) ); … … 1549 1549 tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, tr_sessionUsesAltSpeedTime(s) ); 1550 1550 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 ) ); 1552 1552 tr_bencDictAddInt ( d, "blocklist-size", tr_blocklistGetRuleCount( s ) ); 1553 1553 tr_bencDictAddStr ( d, "config-dir", tr_sessionGetConfigDir( s ) ); … … 1570 1570 tr_bencDictAddBool( d, TR_PREFS_KEY_START, !tr_sessionGetPaused( s ) ); 1571 1571 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 ) ); 1573 1573 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 ) ); 1575 1575 tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_DOWN ) ); 1576 1576 tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) ); -
trunk/libtransmission/session.c
r10931 r10937 56 56 SAVE_INTERVAL_SECS = 120, 57 57 58 DEFAULT_CACHE_SIZE_ BYTES = ( 2 * 1024 * 1024 ) /* 2 MiB */58 DEFAULT_CACHE_SIZE_MB = 2 59 59 }; 60 60 … … 242 242 #endif 243 243 244 static tr_bool245 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/s259 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 268 244 void 269 245 tr_sessionGetDefaultSettings( const char * configDir UNUSED, tr_benc * d ) 270 246 { 271 const int speed_K = tr_formatter_speed_k( );272 273 247 assert( tr_bencIsDict( d ) ); 274 248 275 249 tr_bencDictReserve( d, 60 ); 276 250 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 ); 278 252 tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, TRUE ); 279 253 tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, FALSE ); 280 254 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 ); 282 256 tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, FALSE ); 283 257 tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION, TR_DEFAULT_ENCRYPTION ); … … 318 292 tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, FALSE ); 319 293 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 */ 322 296 tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, 540 ); /* 9am */ 323 297 tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, FALSE ); 324 298 tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_END, 1020 ); /* 5pm */ 325 299 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 ); 327 301 tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED, FALSE ); 328 302 tr_bencDictAddInt ( d, TR_PREFS_KEY_UMASK, 022 ); … … 341 315 tr_bencDictReserve( d, 60 ); 342 316 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 ) ); 344 318 tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, s->isDHTEnabled ); 345 319 tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, s->isLPDEnabled ); 346 320 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 ) ); 348 322 tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_DOWN ) ); 349 323 tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION, s->encryptionMode ); … … 386 360 tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) ); 387 361 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 ) ); 390 364 tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, tr_sessionGetAltSpeedBegin( s ) ); 391 365 tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, tr_sessionUsesAltSpeedTime( s ) ); 392 366 tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_TIME_END, tr_sessionGetAltSpeedEnd( s ) ); 393 367 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 ) ); 395 369 tr_bencDictAddBool( d, TR_PREFS_KEY_USPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_UP ) ); 396 370 tr_bencDictAddInt ( d, TR_PREFS_KEY_UMASK, s->umask ); … … 539 513 session->bandwidth = tr_bandwidthNew( session, NULL ); 540 514 session->lock = tr_lockNew( ); 541 session->cache = tr_cacheNew( DEFAULT_CACHE_SIZE_BYTES);515 session->cache = tr_cacheNew( 1024*1024*2 ); 542 516 session->tag = tr_strdup( tag ); 543 517 session->magicNumber = SESSION_MAGIC_NUMBER; … … 705 679 706 680 /* 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 ); 709 683 if( tr_bencDictFindBool( settings, TR_PREFS_KEY_LAZY_BITFIELD, &boolVal ) ) 710 684 tr_sessionSetLazyBitfieldEnabled( session, boolVal ); … … 806 780 session->uploadSlotsPerTorrent = i; 807 781 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 ); 810 784 if( tr_bencDictFindBool( settings, TR_PREFS_KEY_USPEED_ENABLED, &boolVal ) ) 811 785 tr_sessionLimitSpeed( session, TR_UP, boolVal ); 812 786 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 ); 815 789 if( tr_bencDictFindBool( settings, TR_PREFS_KEY_DSPEED_ENABLED, &boolVal ) ) 816 790 tr_sessionLimitSpeed( session, TR_DOWN, boolVal ); … … 826 800 827 801 /* 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 ); 832 806 if( tr_bencDictFindInt( settings, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, &i ) ) 833 807 turtle->beginMinute = i; … … 1128 1102 1129 1103 tr_bool 1130 tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, tr_direction dir, int * setme )1104 tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, tr_direction dir, int * setme_Bps ) 1131 1105 { 1132 1106 int isLimited = TRUE; … … 1136 1110 1137 1111 if( tr_sessionUsesAltSpeed( session ) ) 1138 *setme = tr_sessionGetAltSpeed_Bps( session, dir );1112 *setme_Bps = tr_sessionGetAltSpeed_Bps( session, dir ); 1139 1113 else if( tr_sessionIsSpeedLimited( session, dir ) ) 1140 *setme = tr_sessionGetSpeedLimit_Bps( session, dir );1114 *setme_Bps = tr_sessionGetSpeedLimit_Bps( session, dir ); 1141 1115 else 1142 1116 isLimited = FALSE; 1143 1117 1144 1118 return isLimited; 1119 } 1120 tr_bool 1121 tr_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; 1145 1129 } 1146 1130 … … 1305 1289 updateBandwidth( s, d ); 1306 1290 } 1291 void 1292 tr_sessionSetSpeedLimit_KBps( tr_session * s, tr_direction d, int KBps ) 1293 { 1294 tr_sessionSetSpeedLimit_Bps( s, d, toSpeedBytes( KBps ) ); 1295 } 1307 1296 1308 1297 int … … 1313 1302 1314 1303 return s->speedLimit_Bps[d]; 1304 } 1305 int 1306 tr_sessionGetSpeedLimit_KBps( const tr_session * s, tr_direction d ) 1307 { 1308 return toSpeedKBps( tr_sessionGetSpeedLimit_Bps( s, d ) ); 1315 1309 } 1316 1310 … … 1352 1346 } 1353 1347 1348 void 1349 tr_sessionSetAltSpeed_KBps( tr_session * s, tr_direction d, int KBps ) 1350 { 1351 tr_sessionSetAltSpeed_Bps( s, d, toSpeedBytes( KBps ) ); 1352 } 1353 1354 1354 int 1355 1355 tr_sessionGetAltSpeed_Bps( const tr_session * s, tr_direction d ) … … 1359 1359 1360 1360 return s->turtle.speedLimit_Bps[d]; 1361 } 1362 int 1363 tr_sessionGetAltSpeed_KBps( const tr_session * s, tr_direction d ) 1364 { 1365 return toSpeedKBps( tr_sessionGetAltSpeed_Bps( s, d ) ); 1361 1366 } 1362 1367 … … 1567 1572 tr_sessionGetPieceSpeed_Bps( const tr_session * session, tr_direction dir ) 1568 1573 { 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 } 1576 double 1577 tr_sessionGetPieceSpeed_KBps( const tr_session * session, tr_direction dir ) 1578 { 1579 return toSpeedKBps( tr_sessionGetPieceSpeed_Bps( session, dir ) ); 1570 1580 } 1571 1581 … … 1573 1583 tr_sessionGetRawSpeed_Bps( const tr_session * session, tr_direction dir ) 1574 1584 { 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 } 1587 double 1588 tr_sessionGetRawSpeed_KBps( const tr_session * session, tr_direction dir ) 1589 { 1590 return toSpeedKBps( tr_sessionGetRawSpeed_Bps( session, dir ) ); 1591 } 1592 1577 1593 1578 1594 int … … 1877 1893 1878 1894 void 1879 tr_sessionSetCacheLimit ( tr_session * session,int64_t max_bytes )1895 tr_sessionSetCacheLimit_B( tr_session * session, uint64_t max_bytes ) 1880 1896 { 1881 1897 assert( tr_isSession( session ) ); … … 1883 1899 tr_cacheSetLimit( session->cache, max_bytes ); 1884 1900 } 1885 1886 int64_t 1887 tr_sessionGetCacheLimit( const tr_session * session ) 1901 void 1902 tr_sessionSetCacheLimit_MB( tr_session * session, int MB ) 1903 { 1904 tr_sessionSetCacheLimit_B( session, toMemBytes( MB ) ); 1905 } 1906 1907 uint64_t 1908 tr_sessionGetCacheLimit_B( const tr_session * session ) 1888 1909 { 1889 1910 assert( tr_isSession( session ) ); … … 1891 1912 return tr_cacheGetLimit( session->cache ); 1892 1913 } 1914 int 1915 tr_sessionGetCacheLimit_MB( const tr_session * session ) 1916 { 1917 return toMemMB( tr_sessionGetCacheLimit_B( session ) ); 1918 } 1919 1893 1920 1894 1921 /*** -
trunk/libtransmission/session.h
r10931 r10937 30 30 #include "bencode.h" 31 31 #include "bitfield.h" 32 #include "utils.h" 32 33 33 34 typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t; … … 249 250 } 250 251 252 /*** 253 **** 254 ***/ 255 256 static inline unsigned int toSpeedBytes ( unsigned int KBps ) { return KBps * tr_speed_K; } 257 static inline double toSpeedKBps ( unsigned int Bps ) { return Bps / (double)tr_speed_K; } 258 259 static inline uint64_t toMemBytes ( unsigned int MB ) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; } 260 static inline int toMemMB ( uint64_t B ) { return B / tr_mem_K; } 261 262 /** 263 **/ 264 265 void tr_sessionSetCacheLimit_B ( tr_session * session, uint64_t B ); 266 uint64_t tr_sessionGetCacheLimit_B ( const tr_session * session ); 267 268 int tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction ); 269 int tr_sessionGetAltSpeed_Bps ( const tr_session *, tr_direction ); 270 int tr_sessionGetRawSpeed_Bps ( const tr_session *, tr_direction ); 271 int tr_sessionGetPieceSpeed_Bps( const tr_session *, tr_direction ); 272 273 void tr_sessionSetSpeedLimit_Bps( tr_session *, tr_direction, int Bps ); 274 void tr_sessionSetAltSpeed_Bps ( tr_session *, tr_direction, int Bps ); 275 276 tr_bool tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, 277 tr_direction dir, 278 int * setme ); 279 280 251 281 #endif -
trunk/libtransmission/torrent.c
r10935 r10937 139 139 tr_torrentSetDirty( tor ); 140 140 } 141 void 142 tr_torrentSetSpeedLimit_KBps( tr_torrent * tor, tr_direction dir, int KBps ) 143 { 144 tr_torrentSetSpeedLimit_Bps( tor, dir, toSpeedBytes( KBps ) ); 145 } 141 146 142 147 int … … 147 152 148 153 return tr_bandwidthGetDesiredSpeed_Bps( tor->bandwidth, dir ); 154 } 155 int 156 tr_torrentGetSpeedLimit_KBps( const tr_torrent * tor, tr_direction dir ) 157 { 158 return toSpeedKBps( tr_torrentGetSpeedLimit_Bps( tor, dir ) ); 149 159 } 150 160 … … 969 979 now = tr_date( ); 970 980 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 ) ); 975 985 976 986 usableSeeds += tor->info.webseedCount; … … 1033 1043 case TR_STATUS_DOWNLOAD: 1034 1044 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 */ 1038 1048 tor->etaDLSpeedCalculatedAt = now; 1039 1049 } … … 1041 1051 if( s->leftUntilDone > s->desiredAvailable ) 1042 1052 s->eta = TR_ETA_NOT_AVAIL; 1043 else if( s->pieceDownloadSpeed_Bps < 1 )1053 else if( tor->etaDLSpeed_KBps < 1 ) 1044 1054 s->eta = TR_ETA_UNKNOWN; 1045 1055 else 1046 s->eta = s->leftUntilDone / to r->etaDLSpeed_Bps;1056 s->eta = s->leftUntilDone / toSpeedBytes(tor->etaDLSpeed_KBps); 1047 1057 break; 1048 1058 … … 1052 1062 else { 1053 1063 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 */ 1057 1067 tor->etaULSpeedCalculatedAt = now; 1058 1068 } 1059 if( s->pieceUploadSpeed_Bps < 1 )1069 if( tor->etaULSpeed_KBps < 1 ) 1060 1070 s->eta = TR_ETA_UNKNOWN; 1061 1071 else 1062 s->eta = seedRatioBytesLeft / to r->etaULSpeed_Bps;1072 s->eta = seedRatioBytesLeft / toSpeedBytes(tor->etaULSpeed_KBps); 1063 1073 } 1064 1074 break; … … 1194 1204 ***/ 1195 1205 1196 int*1197 tr_torrentWebSpeeds_ Bps( const tr_torrent * tor )1198 { 1199 return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_ Bps( tor ) : NULL;1206 double* 1207 tr_torrentWebSpeeds_KBps( const tr_torrent * tor ) 1208 { 1209 return tr_isTorrent( tor ) ? tr_peerMgrWebSpeeds_KBps( tor ) : NULL; 1200 1210 } 1201 1211 -
trunk/libtransmission/torrent.h
r10931 r10937 211 211 212 212 uint64_t etaDLSpeedCalculatedAt; 213 int etaDLSpeed_Bps;213 double etaDLSpeed_KBps; 214 214 uint64_t etaULSpeedCalculatedAt; 215 int etaULSpeed_Bps;215 double etaULSpeed_KBps; 216 216 217 217 time_t addedDate; … … 422 422 void tr_torrentGotNewInfoDict( tr_torrent * tor ); 423 423 424 void tr_torrentSetSpeedLimit_Bps ( tr_torrent *, tr_direction, int Bps ); 425 int tr_torrentGetSpeedLimit_Bps ( const tr_torrent *, tr_direction ); 426 427 424 428 #endif -
trunk/libtransmission/transmission.h
r10931 r10937 157 157 158 158 #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" 161 161 #define TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN "alt-speed-time-begin" 162 162 #define TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED "alt-speed-time-enabled" … … 166 166 #define TR_PREFS_KEY_BIND_ADDRESS_IPV6 "bind-address-ipv6" 167 167 #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" 169 169 #define TR_PREFS_KEY_DHT_ENABLED "dht-enabled" 170 170 #define TR_PREFS_KEY_LPD_ENABLED "lpd-enabled" … … 207 207 #define TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED "script-torrent-done-enabled" 208 208 #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" 210 210 #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" 212 212 #define TR_PREFS_KEY_USPEED_ENABLED "speed-limit-up-enabled" 213 213 #define TR_PREFS_KEY_UMASK "umask" … … 599 599 void tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled ); 600 600 601 void tr_sessionSetCacheLimit ( tr_session * session, int64_t bytes);602 int 64_t tr_sessionGetCacheLimit( const tr_session * session );601 void tr_sessionSetCacheLimit_MB( tr_session * session, int mb ); 602 int tr_sessionGetCacheLimit_MB( const tr_session * session ); 603 603 604 604 void tr_sessionSetLazyBitfieldEnabled( tr_session * session, tr_bool enabled ); … … 658 658 ***/ 659 659 660 void tr_sessionSetSpeedLimit_ Bps( tr_session *, tr_direction, int Bps );661 int tr_sessionGetSpeedLimit_ Bps( const tr_session *, tr_direction );660 void tr_sessionSetSpeedLimit_KBps( tr_session *, tr_direction, int Bps ); 661 int tr_sessionGetSpeedLimit_KBps( const tr_session *, tr_direction ); 662 662 663 663 void tr_sessionLimitSpeed ( tr_session *, tr_direction, tr_bool ); … … 669 669 ***/ 670 670 671 void tr_sessionSetAltSpeed_ Bps( tr_session *, tr_direction, int Bps );672 int tr_sessionGetAltSpeed_ Bps( const tr_session *, tr_direction );671 void tr_sessionSetAltSpeed_KBps( tr_session *, tr_direction, int Bps ); 672 int tr_sessionGetAltSpeed_KBps( const tr_session *, tr_direction ); 673 673 674 674 void tr_sessionUseAltSpeed ( tr_session *, tr_bool ); … … 707 707 708 708 709 tr_bool tr_sessionGetActiveSpeedLimit_ Bps( const tr_session * session,710 tr_direction dir,711 int* setme );709 tr_bool tr_sessionGetActiveSpeedLimit_KBps( const tr_session * session, 710 tr_direction dir, 711 double * setme ); 712 712 713 713 /*** … … 715 715 ***/ 716 716 717 int tr_sessionGetRawSpeed_Bps ( const tr_session *, tr_direction );718 int tr_sessionGetPieceSpeed_Bps( const tr_session *, tr_direction );717 double tr_sessionGetRawSpeed_KBps ( const tr_session *, tr_direction ); 718 double tr_sessionGetPieceSpeed_KBps( const tr_session *, tr_direction ); 719 719 720 720 void tr_sessionSetRatioLimited ( tr_session *, tr_bool isLimited ); … … 1125 1125 ***/ 1126 1126 1127 void tr_torrentSetSpeedLimit_ Bps ( tr_torrent *, tr_direction, int KB_s );1128 int tr_torrentGetSpeedLimit_ Bps ( const tr_torrent *, tr_direction );1127 void tr_torrentSetSpeedLimit_KBps ( tr_torrent *, tr_direction, int KBps ); 1128 int tr_torrentGetSpeedLimit_KBps ( const tr_torrent *, tr_direction ); 1129 1129 1130 1130 void tr_torrentUseSpeedLimit ( tr_torrent *, tr_direction, tr_bool ); … … 1381 1381 1382 1382 float progress; 1383 int rateToPeer_Bps;1384 int rateToClient_Bps;1383 double rateToPeer_KBps; 1384 double rateToClient_KBps; 1385 1385 1386 1386 … … 1545 1545 * NOTE: always free this array with tr_free() when you're done with it. 1546 1546 */ 1547 int* tr_torrentWebSpeeds_Bps( const tr_torrent * torrent );1547 double* tr_torrentWebSpeeds_KBps( const tr_torrent * torrent ); 1548 1548 1549 1549 typedef struct tr_file_stat … … 1747 1747 /** Speed all data being sent for this torrent. 1748 1748 This includes piece data, protocol messages, and TCP overhead */ 1749 int rawUploadSpeed_Bps;1749 double rawUploadSpeed_KBps; 1750 1750 1751 1751 /** Speed all data being received for this torrent. 1752 1752 This includes piece data, protocol messages, and TCP overhead */ 1753 int rawDownloadSpeed_Bps;1753 double rawDownloadSpeed_KBps; 1754 1754 1755 1755 /** Speed all piece being sent for this torrent. 1756 1756 This ONLY counts piece data. */ 1757 int pieceUploadSpeed_Bps;1757 double pieceUploadSpeed_KBps; 1758 1758 1759 1759 /** Speed all piece being received for this torrent. 1760 1760 This ONLY counts piece data. */ 1761 int pieceDownloadSpeed_Bps;1761 double pieceDownloadSpeed_KBps; 1762 1762 1763 1763 #define TR_ETA_NOT_AVAIL -1 -
trunk/libtransmission/utils.c
r10931 r10937 1583 1583 1584 1584 char* 1585 tr_formatter_size ( char * buf, uint64_t bytes, size_t buflen )1585 tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen ) 1586 1586 { 1587 1587 return formatter_get_size_str( &size_units, buf, bytes, buflen ); … … 1589 1589 1590 1590 static struct formatter_units speed_units; 1591 1592 unsigned int tr_speed_K = 0u; 1591 1593 1592 1594 void … … 1595 1597 const char * mb, const char * gb ) 1596 1598 { 1599 tr_speed_K = kilo; 1597 1600 formatter_init( &speed_units, kilo, b, kb, mb, gb ); 1598 1601 } 1599 1602 1600 1603 char* 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; 1604 tr_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; 1610 1608 } 1611 1609 1612 1610 static struct formatter_units mem_units; 1613 1611 1612 unsigned int tr_mem_K = 0u; 1613 1614 1614 void 1615 1615 tr_formatter_mem_init( unsigned int kilo, … … 1617 1617 const char * mb, const char * gb ) 1618 1618 { 1619 tr_mem_K = kilo; 1619 1620 formatter_init( &mem_units, kilo, b, kb, mb, gb ); 1620 1621 } 1621 1622 1622 1623 char* 1623 tr_formatter_mem ( char * buf, uint64_t bytes_per_second, size_t buflen )1624 tr_formatter_mem_B( char * buf, uint64_t bytes_per_second, size_t buflen ) 1624 1625 { 1625 1626 return formatter_get_size_str( &mem_units, buf, bytes_per_second, buflen ); -
trunk/libtransmission/utils.h
r10931 r10937 575 575 576 576 /* format a speed into a user-readable string. */ 577 char* tr_formatter_speed( char * buf, uint64_t bytes_per_second, size_t buflen ); 577 extern unsigned int tr_speed_K; 578 char* tr_formatter_speed_Bps( char * buf, uint64_t Bps, size_t buflen ); 579 static inline char* tr_formatter_speed_KBps( char * buf, double KBps, size_t buflen ) { return tr_formatter_speed_Bps( buf, KBps * tr_speed_K, buflen ); } 580 static 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 ); } 581 static 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. */ 584 extern unsigned int tr_mem_K; 585 char* tr_formatter_mem_B( char * buf, uint64_t bytes, size_t buflen ); 586 static inline char* tr_formatter_mem_KB( char * buf, double KBps, size_t buflen ) { return tr_formatter_mem_B( buf, KBps * tr_mem_K, buflen ); } 587 static 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 ); } 588 static 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 ); } 578 589 579 590 /* 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 ); 591 extern unsigned int tr_size_K; 592 char* tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen ); 593 static inline char* tr_formatter_size_KB( char * buf, double KBps, size_t buflen ) { return tr_formatter_size_B( buf, KBps * tr_size_K, buflen ); } 594 static 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 ); } 595 static 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 ); } 586 596 587 597 -
trunk/qt/formatter.cc
r10933 r10937 45 45 ***/ 46 46 47 Speed 48 Speed :: fromKBps( double KBps ) 49 { 50 return KBps * Formatter::speed_K; 51 } 52 53 /*** 54 **** 55 ***/ 56 47 57 QString 48 58 Formatter :: memToString( double bytes ) … … 52 62 else { 53 63 char buf[128]; 54 tr_formatter_mem ( buf, bytes, sizeof( buf ) );64 tr_formatter_mem_B( buf, bytes, sizeof( buf ) ); 55 65 return buf; 56 66 } … … 64 74 else { 65 75 char buf[128]; 66 tr_formatter_size ( buf, bytes, sizeof( buf ) );76 tr_formatter_size_B( buf, bytes, sizeof( buf ) ); 67 77 return buf; 68 78 } … … 76 86 else { 77 87 char buf[128]; 78 tr_formatter_speed ( buf, speed.Bps( ), sizeof( buf ) );88 tr_formatter_speed_KBps( buf, speed.Bps( ), sizeof( buf ) ); 79 89 return buf; 80 90 } -
trunk/qt/mainwin.cc
r10933 r10937 550 550 g->addAction( a ); 551 551 connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) ); 552 a = myDlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::from Bps( currentVal ) ) ) );552 a = myDlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( currentVal ) ) ) ); 553 553 a->setCheckable( true ); 554 554 a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::DSPEED << currentVal << Prefs::DSPEED_ENABLED << true ); … … 557 557 sub->addSeparator( ); 558 558 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 ); 562 561 connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs())); 563 562 } … … 571 570 g->addAction( a ); 572 571 connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) ); 573 a = myUlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::from Bps( currentVal ) ) ) );572 a = myUlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( currentVal ) ) ) ); 574 573 a->setCheckable( true ); 575 574 a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::USPEED << currentVal << Prefs::USPEED_ENABLED << true ); … … 578 577 sub->addSeparator( ); 579 578 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 ); 583 581 connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs())); 584 582 } … … 1014 1012 1015 1013 case Prefs::DSPEED: 1016 myDlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::from Bps( myPrefs.get<int>(key) ) ) ) );1014 myDlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( myPrefs.get<int>(key) ) ) ) ); 1017 1015 break; 1018 1016 … … 1022 1020 1023 1021 case Prefs::USPEED: 1024 myUlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::from Bps( myPrefs.get<int>(key) ) ) ) );1022 myUlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromKBps( myPrefs.get<int>(key) ) ) ) ); 1025 1023 break; 1026 1024 … … 1088 1086 const QString fmt = b ? tr( "Click to disable Temporary Speed Limits\n(%1 down, %2 up)" ) 1089 1087 : tr( "Click to enable Temporary Speed Limits\n(%1 down, %2 up)" ); 1090 const Speed d = Speed::from Bps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_DOWN ) );1091 const Speed u = Speed::from Bps( 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 ) ); 1092 1090 myAltSpeedButton->setToolTip( fmt.arg( Formatter::speedToString( d ) ) 1093 1091 .arg( Formatter::speedToString( u ) ) ); -
trunk/qt/prefs-dialog.cc
r10933 r10937 52 52 { 53 53 const char * PREF_KEY( "pref-key" ); 54 const char * MULTIPLIER_KEY( "multiplier-key" );55 54 }; 56 55 … … 85 84 const QObject * spin( sender()->property( "SPIN" ).value<QObject*>( ) ); 86 85 const int key = spin->property( PREF_KEY ).toInt( ); 87 const int multiplier = spin->property( MULTIPLIER_KEY ).toInt( );88 86 89 87 const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin ); 90 88 if( d != 0 ) 91 myPrefs.set( key, multiplier *d->value( ) );89 myPrefs.set( key, d->value( ) ); 92 90 else 93 myPrefs.set( key, multiplier *qobject_cast<const QSpinBox*>(spin)->value( ) );91 myPrefs.set( key, qobject_cast<const QSpinBox*>(spin)->value( ) ); 94 92 } 95 93 … … 117 115 118 116 QSpinBox * 119 PrefsDialog :: spinBoxNew( int key, int low, int high, int step , int multiplier)117 PrefsDialog :: spinBoxNew( int key, int low, int high, int step ) 120 118 { 121 119 QSpinBox * spin = new QSpinBox( ); 122 120 spin->setRange( low, high ); 123 121 spin->setSingleStep( step ); 124 spin->setValue( myPrefs.getInt( key ) / multiplier);122 spin->setValue( myPrefs.getInt( key ) ); 125 123 spin->setProperty( PREF_KEY, key ); 126 spin->setProperty( MULTIPLIER_KEY, multiplier );127 124 connect( spin, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged(int))); 128 125 myWidgets.insert( key, spin ); … … 139 136 140 137 QDoubleSpinBox * 141 PrefsDialog :: doubleSpinBoxNew( int key, double low, double high, double step, int decimals , int multiplier)138 PrefsDialog :: doubleSpinBoxNew( int key, double low, double high, double step, int decimals ) 142 139 { 143 140 QDoubleSpinBox * spin = new QDoubleSpinBox( ); … … 145 142 spin->setSingleStep( step ); 146 143 spin->setDecimals( decimals ); 147 spin->setValue( myPrefs.getDouble( key ) / multiplier );148 144 spin->setProperty( PREF_KEY, key ); 149 spin->setProperty( MULTIPLIER_KEY, multiplier );150 145 connect( spin, SIGNAL(valueChanged(double)), this, SLOT(doubleSpinBoxChanged(double))); 151 146 myWidgets.insert( key, spin ); … … 274 269 275 270 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 ); 277 272 hig->addRow( l, r ); 278 273 enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r ); 279 274 280 275 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 ); 282 277 hig->addRow( l, r ); 283 278 enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r ); … … 300 295 301 296 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 ); 303 298 hig->addRow( s, r ); 304 299 305 300 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 ); 307 302 hig->addRow( s, r ); 308 303 -
trunk/qt/prefs-dialog.h
r10931 r10937 65 65 66 66 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 ); 68 68 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 ); 70 70 QTimeEdit * timeEditNew( int key ); 71 71 QLineEdit * lineEditNew( int key, int mode = 0 ); -
trunk/qt/prefs.cc
r10931 r10937 65 65 66 66 /* 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 }, 69 69 { ALT_SPEED_LIMIT_ENABLED, TR_PREFS_KEY_ALT_SPEED_ENABLED, QVariant::Bool }, 70 70 { ALT_SPEED_LIMIT_TIME_BEGIN, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, QVariant::Int }, … … 73 73 { ALT_SPEED_LIMIT_TIME_DAY, TR_PREFS_KEY_ALT_SPEED_TIME_DAY, QVariant::Int }, 74 74 { 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 }, 76 76 { DSPEED_ENABLED, TR_PREFS_KEY_DSPEED_ENABLED, QVariant::Bool }, 77 77 { DOWNLOAD_DIR, TR_PREFS_KEY_DOWNLOAD_DIR, QVariant::String }, … … 116 116 { RPC_WHITELIST, TR_PREFS_KEY_RPC_WHITELIST, QVariant::String }, 117 117 { 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 }, 119 119 { UPLOAD_SLOTS_PER_TORRENT, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, QVariant::Int } 120 120 }; -
trunk/qt/session.h
r10908 r10937 23 23 24 24 #include <libtransmission/transmission.h> 25 26 #include "speed.h"27 25 28 26 extern "C" -
trunk/qt/speed.h
r10931 r10937 24 24 int Bps( ) const { return _Bps; } 25 25 bool isZero( ) const { return _Bps == 0; } 26 static Speed fromK iBps( double KiBps ) { return Speed( KiBps*1024 ); }26 static Speed fromKBps( double KBps ); 27 27 static Speed fromBps( int Bps ) { return Speed( Bps ); } 28 28 void setKiBps( double KiBps ) { setBps( KiBps*1024 ); } -
trunk/qt/torrent.cc
r10872 r10937 54 54 { 55 55 { 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 */ 58 58 { DOWNLOAD_DIR, "downloadDir", QVariant::String, STAT }, 59 59 { ACTIVITY, "status", QVariant::Int, STAT }, … … 90 90 { SEED_RATIO_LIMIT, "seedRatioLimit", QVariant::Double, STAT }, 91 91 { SEED_RATIO_MODE, "seedRatioMode", QVariant::Int, STAT }, 92 { DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* K iB/s */92 { DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */ 93 93 { DOWN_LIMITED, "downloadLimited", QVariant::Bool, STAT_EXTRA }, 94 { UP_LIMIT, "uploadLimit", QVariant::Int, STAT_EXTRA }, /* K iB/s */94 { UP_LIMIT, "uploadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */ 95 95 { UP_LIMITED, "uploadLimited", QVariant::Bool, STAT_EXTRA }, 96 96 { HONORS_SESSION_LIMITS, "honorsSessionLimits", QVariant::Bool, STAT_EXTRA }, … … 654 654 if( tr_bencDictFindReal( child, "progress", &d ) ) 655 655 peer.progress = d; 656 if( tr_bencDictFind Int( child, "rateToClient", &i) )657 peer.rateToClient = Speed::from Bps( i);658 if( tr_bencDictFind Int( child, "rateToPeer", &i) )659 peer.rateToPeer = Speed::from Bps( 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 ); 660 660 peerList << peer; 661 661 } -
trunk/qt/torrent.h
r10931 r10937 280 280 int connectedPeers( ) const { return getInt( PEERS_CONNECTED ); } 281 281 int connectedPeersAndWebseeds( ) const { return connectedPeers( ) + getInt( WEBSEEDS_SENDING_TO_US ); } 282 Speed downloadSpeed( ) const { return Speed::from Bps( getInt( DOWNLOAD_SPEED ) ); }283 Speed uploadSpeed( ) const { return Speed::from Bps( getInt( UPLOAD_SPEED ) ); }282 Speed downloadSpeed( ) const { return Speed::fromKBps( getDouble( DOWNLOAD_SPEED ) ); } 283 Speed uploadSpeed( ) const { return Speed::fromKBps( getDouble( UPLOAD_SPEED ) ); } 284 284 double getVerifyProgress( ) const { return getDouble( PERCENT_VERIFIED ); } 285 285 bool hasFileSubstring( const QString& substr ) const; 286 286 bool hasTrackerSubstring( const QString& substr ) const; 287 Speed uploadLimit( ) const { return Speed::from Bps( getInt( UP_LIMIT ) ); }288 Speed downloadLimit( ) const { return Speed::from Bps( getInt( DOWN_LIMIT ) ); }287 Speed uploadLimit( ) const { return Speed::fromKBps( getInt( UP_LIMIT ) ); } 288 Speed downloadLimit( ) const { return Speed::fromKBps( getInt( DOWN_LIMIT ) ); } 289 289 bool uploadIsLimited( ) const { return getBool( UP_LIMITED ); } 290 290 bool downloadIsLimited( ) const { return getBool( DOWN_LIMITED ); } -
trunk/utils/show.c
r10932 r10937 105 105 printf( " Comment: %s\n", inf->comment ); 106 106 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 ) ) ); 109 109 printf( " Privacy: %s\n", inf->isPrivate ? "Private torrent" : "Public torrent" ); 110 110 … … 131 131 printf( "\nFILES\n\n" ); 132 132 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 ) ) ); 134 134 } 135 135
Note: See TracChangeset
for help on using the changeset viewer.