mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
individual download/upload speed caps accessible under options in the inspector
This commit is contained in:
parent
ca2c729abd
commit
b31ee4f03c
7 changed files with 211 additions and 19 deletions
|
@ -1154,7 +1154,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
Torrent * torrent = [notification object];
|
||||
|
||||
[fInfoController updateInfoSettings];
|
||||
[fInfoController updateInfoStats];
|
||||
|
||||
[self applyFilter: nil];
|
||||
[self checkToStartWaiting: torrent];
|
||||
|
@ -1648,7 +1648,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
[self applyFilter: nil];
|
||||
[fInfoController updateInfoStats];
|
||||
[fInfoController updateInfoSettings];
|
||||
|
||||
if ([fDefaults boolForKey: @"PlaySeedingSound"])
|
||||
{
|
||||
|
|
6
macosx/English.lproj/InfoWindow.nib/classes.nib
generated
6
macosx/English.lproj/InfoWindow.nib/classes.nib
generated
|
@ -12,8 +12,10 @@
|
|||
revealDataFile = id;
|
||||
revealFile = id;
|
||||
revealTorrentFile = id;
|
||||
setLimitCheck = id;
|
||||
setRatioCheck = id;
|
||||
setRatioLimit = id;
|
||||
setSpeedLimit = id;
|
||||
};
|
||||
CLASS = InfoWindowController;
|
||||
LANGUAGE = ObjC;
|
||||
|
@ -25,6 +27,8 @@
|
|||
fDataLocationField = NSTextField;
|
||||
fDateCreatedField = NSTextField;
|
||||
fDateStartedField = NSTextField;
|
||||
fDownloadLimitCheck = NSButton;
|
||||
fDownloadLimitField = NSTextField;
|
||||
fDownloadedTotalField = NSTextField;
|
||||
fDownloadedValidField = NSTextField;
|
||||
fDownloadingFromField = NSTextField;
|
||||
|
@ -51,6 +55,8 @@
|
|||
fTabView = NSTabView;
|
||||
fTorrentLocationField = NSTextField;
|
||||
fTrackerField = NSTextField;
|
||||
fUploadLimitCheck = NSButton;
|
||||
fUploadLimitField = NSTextField;
|
||||
fUploadedTotalField = NSTextField;
|
||||
fUploadingToField = NSTextField;
|
||||
};
|
||||
|
|
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -56,13 +56,13 @@
|
|||
IBOutlet NSTableView * fFileTable;
|
||||
IBOutlet NSTextField * fFileTableStatusField;
|
||||
|
||||
IBOutlet NSButton * fUploadLimitCheck, * fDownloadLimitCheck;
|
||||
IBOutlet NSMatrix * fRatioMatrix;
|
||||
IBOutlet NSTextField * fRatioLimitField;
|
||||
IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField;
|
||||
}
|
||||
|
||||
- (void) updateInfoForTorrents: (NSArray *) torrents;
|
||||
- (void) updateInfoStats;
|
||||
- (void) updateInfoSettings;
|
||||
|
||||
- (void) setNextTab;
|
||||
- (void) setPreviousTab;
|
||||
|
@ -71,6 +71,9 @@
|
|||
- (void) revealDataFile: (id) sender;
|
||||
- (void) revealFile: (id) sender;
|
||||
|
||||
- (void) setLimitCheck: (id) sender;
|
||||
- (void) setSpeedLimit: (id) sender;
|
||||
|
||||
- (void) setRatioCheck: (id) sender;
|
||||
- (void) setRatioLimit: (id) sender;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define TAB_ACTIVITY_HEIGHT 170.0
|
||||
#define TAB_PEERS_HEIGHT 268.0
|
||||
#define TAB_FILES_HEIGHT 268.0
|
||||
#define TAB_OPTIONS_HEIGHT 83.0
|
||||
#define TAB_OPTIONS_HEIGHT 147.0
|
||||
|
||||
#define INVALID -99
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
|||
- (void) updateInfoGeneral;
|
||||
- (void) updateInfoActivity;
|
||||
- (void) updateInfoPeers;
|
||||
- (void) updateInfoSettings;
|
||||
|
||||
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
|
||||
- (NSArray *) peerSortDescriptors;
|
||||
|
@ -293,9 +294,14 @@
|
|||
return;
|
||||
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
||||
NSString * tracker = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressAnnounce]];
|
||||
[fTrackerField setStringValue: tracker];
|
||||
[fTrackerField setToolTip: tracker];
|
||||
|
||||
NSString * location = [torrent dataLocation];
|
||||
[fDataLocationField setStringValue: [location stringByAbbreviatingWithTildeInPath]];
|
||||
[fDataLocationField setToolTip: location];
|
||||
}
|
||||
|
||||
- (void) updateInfoActivity
|
||||
|
@ -374,15 +380,56 @@
|
|||
{
|
||||
Torrent * torrent;
|
||||
|
||||
if (numberSelected == 1)
|
||||
//set bandwidth limits
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
torrent = [enumerator nextObject]; //first torrent
|
||||
|
||||
int checkUpload = [torrent checkUpload] ? 1 : 0,
|
||||
checkDownload = [torrent checkDownload] ? 1 : 0,
|
||||
uploadLimit = [torrent uploadLimit],
|
||||
downloadLimit = [torrent downloadLimit];
|
||||
|
||||
while ((checkUpload != INVALID || uploadLimit != INVALID
|
||||
|| checkDownload != INVALID || downloadLimit != INVALID)
|
||||
&& (torrent = [enumerator nextObject]))
|
||||
{
|
||||
torrent = [fTorrents objectAtIndex: 0];
|
||||
[fDataLocationField setStringValue: [[torrent dataLocation] stringByAbbreviatingWithTildeInPath]];
|
||||
[fDataLocationField setToolTip: [torrent dataLocation]];
|
||||
if (checkUpload != INVALID && checkUpload != ([torrent checkUpload] ? 1 : 0))
|
||||
checkUpload = INVALID;
|
||||
|
||||
if (uploadLimit != INVALID && uploadLimit != [torrent uploadLimit])
|
||||
uploadLimit = INVALID;
|
||||
|
||||
if (checkDownload != INVALID && checkDownload != ([torrent checkDownload] ? 1 : 0))
|
||||
checkDownload = INVALID;
|
||||
|
||||
if (downloadLimit != INVALID && downloadLimit != [torrent downloadLimit])
|
||||
downloadLimit = INVALID;
|
||||
}
|
||||
|
||||
[fUploadLimitCheck setEnabled: YES];
|
||||
[fDownloadLimitCheck setEnabled: YES];
|
||||
|
||||
[fUploadLimitField setEnabled: checkUpload != 0];
|
||||
[fDownloadLimitField setEnabled: checkDownload != 0];
|
||||
|
||||
[fUploadLimitCheck setState: checkUpload == INVALID ? NSMixedState
|
||||
: (checkUpload == 1 ? NSOnState : NSOffState)];
|
||||
|
||||
if (uploadLimit != INVALID)
|
||||
[fUploadLimitField setIntValue: uploadLimit];
|
||||
else
|
||||
[fUploadLimitField setStringValue: @""];
|
||||
|
||||
[fDownloadLimitCheck setState: checkDownload == INVALID ? NSMixedState
|
||||
: (checkDownload == 1 ? NSOnState : NSOffState)];
|
||||
|
||||
if (downloadLimit != INVALID)
|
||||
[fDownloadLimitField setIntValue: downloadLimit];
|
||||
else
|
||||
[fDownloadLimitField setStringValue: @""];
|
||||
|
||||
//set ratio settings
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
enumerator = [fTorrents objectEnumerator];
|
||||
torrent = [enumerator nextObject]; //first torrent
|
||||
|
||||
int ratioSetting = [torrent stopRatioSetting];
|
||||
|
@ -429,6 +476,16 @@
|
|||
|
||||
[fRatioLimitField setEnabled: NO];
|
||||
[fRatioLimitField setStringValue: @""];
|
||||
|
||||
[fUploadLimitCheck setState: NSOffState];
|
||||
[fUploadLimitCheck setEnabled: NO];
|
||||
[fUploadLimitField setEnabled: NO];
|
||||
[fUploadLimitField setStringValue: @""];
|
||||
|
||||
[fDownloadLimitCheck setState: NSOffState];
|
||||
[fDownloadLimitCheck setEnabled: NO];
|
||||
[fDownloadLimitField setEnabled: NO];
|
||||
[fDownloadLimitField setStringValue: @""];
|
||||
}
|
||||
|
||||
[self updateInfoStats];
|
||||
|
@ -470,9 +527,7 @@
|
|||
[fPiecesView updateView: YES];
|
||||
}
|
||||
else if ([identifier isEqualToString: TAB_PEERS_IDENT])
|
||||
{
|
||||
height = TAB_PEERS_HEIGHT;
|
||||
}
|
||||
else if ([identifier isEqualToString: TAB_FILES_IDENT])
|
||||
height = TAB_FILES_HEIGHT;
|
||||
else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
|
||||
|
@ -636,6 +691,58 @@
|
|||
inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
||||
- (void) setLimitCheck: (id) sender
|
||||
{
|
||||
BOOL upload = sender == fUploadLimitCheck,
|
||||
limit = [sender state] != NSOffState;
|
||||
|
||||
if (limit)
|
||||
[sender setState: NSOnState];
|
||||
|
||||
Torrent * torrent;
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
upload ? [torrent setLimitUpload: limit] : [torrent setLimitDownload: limit];
|
||||
|
||||
NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
|
||||
|
||||
if (![[field stringValue] isEqualToString: @""])
|
||||
[self setSpeedLimit: field];
|
||||
|
||||
[field setEnabled: limit];
|
||||
}
|
||||
|
||||
- (void) setSpeedLimit: (id) sender
|
||||
{
|
||||
BOOL upload = sender == fUploadLimitField;
|
||||
|
||||
Torrent * torrent;
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
|
||||
int limit = [sender intValue];
|
||||
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%i", limit]] || limit < 0)
|
||||
{
|
||||
NSBeep();
|
||||
|
||||
torrent = [enumerator nextObject]; //use first torrent
|
||||
|
||||
limit = upload ? [torrent uploadLimit] : [torrent downloadLimit];
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
if (limit != upload ? [torrent uploadLimit] : [torrent downloadLimit])
|
||||
{
|
||||
[sender setStringValue: @""];
|
||||
return;
|
||||
}
|
||||
|
||||
[sender setIntValue: limit];
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
upload ? [torrent setUploadLimit: limit] : [torrent setDownloadLimit: limit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setRatioCheck: (id) sender
|
||||
{
|
||||
int ratioSetting, tag = [[fRatioMatrix selectedCell] tag];
|
||||
|
|
|
@ -50,9 +50,10 @@
|
|||
NSImage * fIcon, * fIconFlipped, * fIconSmall;
|
||||
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
|
||||
|
||||
int fStopRatioSetting;
|
||||
|
||||
int fUploadLimit, fDownloadLimit, fStopRatioSetting;
|
||||
float fRatioLimit;
|
||||
BOOL fFinishedSeeding, fWaitToStart, fError;
|
||||
BOOL fCheckUpload, fCheckDownload, fFinishedSeeding, fWaitToStart, fError;
|
||||
|
||||
int fOrderValue;
|
||||
|
||||
|
@ -89,6 +90,15 @@
|
|||
- (float) ratioLimit;
|
||||
- (void) setRatioLimit: (float) limit;
|
||||
|
||||
- (void) setLimitUpload: (BOOL) limit;
|
||||
- (void) setUploadLimit: (int) limit;
|
||||
- (void) setLimitDownload: (BOOL) limit;
|
||||
- (void) setDownloadLimit: (int) limit;
|
||||
- (BOOL) checkUpload;
|
||||
- (int) uploadLimit;
|
||||
- (BOOL) checkDownload;
|
||||
- (int) downloadLimit;
|
||||
|
||||
- (void) setWaitToStart: (BOOL) wait;
|
||||
- (BOOL) waitingToStart;
|
||||
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
|
||||
publicTorrent: (NSNumber *) publicTorrent
|
||||
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
|
||||
ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart
|
||||
orderValue: (NSNumber *) orderValue;
|
||||
ratioLimit: (NSNumber *) ratioLimit
|
||||
checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
|
||||
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
|
||||
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
|
||||
|
||||
- (NSImage *) advancedBar;
|
||||
|
||||
|
@ -62,7 +64,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
{
|
||||
self = [self initWithHash: nil path: path lib: lib
|
||||
publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
|
||||
date: nil stopRatioSetting: nil ratioLimit: nil waitToStart: nil orderValue: nil];
|
||||
date: nil stopRatioSetting: nil ratioLimit: nil
|
||||
checkUpload: nil uploadLimit: nil
|
||||
checkDownload: nil downloadLimit: nil
|
||||
waitToStart: nil orderValue: nil];
|
||||
|
||||
if (self)
|
||||
{
|
||||
|
@ -83,6 +88,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
date: [history objectForKey: @"Date"]
|
||||
stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
|
||||
ratioLimit: [history objectForKey: @"RatioLimit"]
|
||||
checkUpload: [history objectForKey: @"CheckUpload"]
|
||||
uploadLimit: [history objectForKey: @"UploadLimit"]
|
||||
checkDownload: [history objectForKey: @"CheckDownload"]
|
||||
downloadLimit: [history objectForKey: @"DownloadLimit"]
|
||||
waitToStart: [history objectForKey: @"WaitToStart"]
|
||||
orderValue: [history objectForKey: @"OrderValue"]];
|
||||
|
||||
|
@ -132,6 +141,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
[self date], @"Date",
|
||||
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
|
||||
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
|
||||
[NSNumber numberWithBool: fCheckUpload], @"CheckUpload",
|
||||
[NSNumber numberWithInt: fUploadLimit], @"UploadLimit",
|
||||
[NSNumber numberWithBool: fCheckDownload], @"CheckDownload",
|
||||
[NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit",
|
||||
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
||||
[self orderValue], @"OrderValue", nil];
|
||||
|
||||
|
@ -506,6 +519,50 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
fRatioLimit = limit;
|
||||
}
|
||||
|
||||
- (void) setLimitUpload: (BOOL) limit
|
||||
{
|
||||
fCheckUpload = limit;
|
||||
tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
|
||||
}
|
||||
|
||||
- (void) setUploadLimit: (int) limit
|
||||
{
|
||||
fUploadLimit = limit;
|
||||
tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
|
||||
}
|
||||
|
||||
- (void) setLimitDownload: (BOOL) limit
|
||||
{
|
||||
fCheckDownload = limit;
|
||||
tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
|
||||
}
|
||||
|
||||
- (void) setDownloadLimit: (int) limit
|
||||
{
|
||||
fDownloadLimit = limit;
|
||||
tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
|
||||
}
|
||||
|
||||
- (BOOL) checkUpload
|
||||
{
|
||||
return fCheckUpload;
|
||||
}
|
||||
|
||||
- (int) uploadLimit
|
||||
{
|
||||
return fUploadLimit;
|
||||
}
|
||||
|
||||
- (BOOL) checkDownload
|
||||
{
|
||||
return fCheckDownload;
|
||||
}
|
||||
|
||||
- (int) downloadLimit
|
||||
{
|
||||
return fDownloadLimit;
|
||||
}
|
||||
|
||||
- (void) setWaitToStart: (BOOL) wait
|
||||
{
|
||||
fWaitToStart = wait;
|
||||
|
@ -1037,8 +1094,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
|
||||
publicTorrent: (NSNumber *) publicTorrent
|
||||
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
|
||||
ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart
|
||||
orderValue: (NSNumber *) orderValue
|
||||
ratioLimit: (NSNumber *) ratioLimit
|
||||
checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
|
||||
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
|
||||
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
@ -1071,6 +1130,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
|
||||
fFinishedSeeding = NO;
|
||||
|
||||
fCheckUpload = checkUpload && [checkUpload boolValue];
|
||||
fUploadLimit = uploadLimit ? [uploadLimit intValue] : 10;
|
||||
tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
|
||||
|
||||
fCheckDownload = checkDownload && [checkDownload boolValue];
|
||||
fDownloadLimit = downloadLimit ? [downloadLimit intValue] : 10;
|
||||
tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
|
||||
|
||||
fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"AutoStartDownload"];
|
||||
fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
|
||||
fError = NO;
|
||||
|
|
Loading…
Reference in a new issue