1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

individual download/upload speed caps accessible under options in the inspector

This commit is contained in:
Mitchell Livingston 2006-12-27 02:57:55 +00:00
parent ca2c729abd
commit b31ee4f03c
7 changed files with 211 additions and 19 deletions

View file

@ -1154,7 +1154,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{ {
Torrent * torrent = [notification object]; Torrent * torrent = [notification object];
[fInfoController updateInfoSettings]; [fInfoController updateInfoStats];
[self applyFilter: nil]; [self applyFilter: nil];
[self checkToStartWaiting: torrent]; [self checkToStartWaiting: torrent];
@ -1648,7 +1648,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{ {
[self applyFilter: nil]; [self applyFilter: nil];
[fInfoController updateInfoStats]; [fInfoController updateInfoStats];
[fInfoController updateInfoSettings];
if ([fDefaults boolForKey: @"PlaySeedingSound"]) if ([fDefaults boolForKey: @"PlaySeedingSound"])
{ {

View file

@ -12,8 +12,10 @@
revealDataFile = id; revealDataFile = id;
revealFile = id; revealFile = id;
revealTorrentFile = id; revealTorrentFile = id;
setLimitCheck = id;
setRatioCheck = id; setRatioCheck = id;
setRatioLimit = id; setRatioLimit = id;
setSpeedLimit = id;
}; };
CLASS = InfoWindowController; CLASS = InfoWindowController;
LANGUAGE = ObjC; LANGUAGE = ObjC;
@ -25,6 +27,8 @@
fDataLocationField = NSTextField; fDataLocationField = NSTextField;
fDateCreatedField = NSTextField; fDateCreatedField = NSTextField;
fDateStartedField = NSTextField; fDateStartedField = NSTextField;
fDownloadLimitCheck = NSButton;
fDownloadLimitField = NSTextField;
fDownloadedTotalField = NSTextField; fDownloadedTotalField = NSTextField;
fDownloadedValidField = NSTextField; fDownloadedValidField = NSTextField;
fDownloadingFromField = NSTextField; fDownloadingFromField = NSTextField;
@ -51,6 +55,8 @@
fTabView = NSTabView; fTabView = NSTabView;
fTorrentLocationField = NSTextField; fTorrentLocationField = NSTextField;
fTrackerField = NSTextField; fTrackerField = NSTextField;
fUploadLimitCheck = NSButton;
fUploadLimitField = NSTextField;
fUploadedTotalField = NSTextField; fUploadedTotalField = NSTextField;
fUploadingToField = NSTextField; fUploadingToField = NSTextField;
}; };

View file

@ -56,13 +56,13 @@
IBOutlet NSTableView * fFileTable; IBOutlet NSTableView * fFileTable;
IBOutlet NSTextField * fFileTableStatusField; IBOutlet NSTextField * fFileTableStatusField;
IBOutlet NSButton * fUploadLimitCheck, * fDownloadLimitCheck;
IBOutlet NSMatrix * fRatioMatrix; IBOutlet NSMatrix * fRatioMatrix;
IBOutlet NSTextField * fRatioLimitField; IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField;
} }
- (void) updateInfoForTorrents: (NSArray *) torrents; - (void) updateInfoForTorrents: (NSArray *) torrents;
- (void) updateInfoStats; - (void) updateInfoStats;
- (void) updateInfoSettings;
- (void) setNextTab; - (void) setNextTab;
- (void) setPreviousTab; - (void) setPreviousTab;
@ -71,6 +71,9 @@
- (void) revealDataFile: (id) sender; - (void) revealDataFile: (id) sender;
- (void) revealFile: (id) sender; - (void) revealFile: (id) sender;
- (void) setLimitCheck: (id) sender;
- (void) setSpeedLimit: (id) sender;
- (void) setRatioCheck: (id) sender; - (void) setRatioCheck: (id) sender;
- (void) setRatioLimit: (id) sender; - (void) setRatioLimit: (id) sender;

View file

@ -43,7 +43,7 @@
#define TAB_ACTIVITY_HEIGHT 170.0 #define TAB_ACTIVITY_HEIGHT 170.0
#define TAB_PEERS_HEIGHT 268.0 #define TAB_PEERS_HEIGHT 268.0
#define TAB_FILES_HEIGHT 268.0 #define TAB_FILES_HEIGHT 268.0
#define TAB_OPTIONS_HEIGHT 83.0 #define TAB_OPTIONS_HEIGHT 147.0
#define INVALID -99 #define INVALID -99
@ -52,6 +52,7 @@
- (void) updateInfoGeneral; - (void) updateInfoGeneral;
- (void) updateInfoActivity; - (void) updateInfoActivity;
- (void) updateInfoPeers; - (void) updateInfoPeers;
- (void) updateInfoSettings;
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate; - (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
- (NSArray *) peerSortDescriptors; - (NSArray *) peerSortDescriptors;
@ -293,9 +294,14 @@
return; return;
Torrent * torrent = [fTorrents objectAtIndex: 0]; Torrent * torrent = [fTorrents objectAtIndex: 0];
NSString * tracker = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressAnnounce]]; NSString * tracker = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressAnnounce]];
[fTrackerField setStringValue: tracker]; [fTrackerField setStringValue: tracker];
[fTrackerField setToolTip: tracker]; [fTrackerField setToolTip: tracker];
NSString * location = [torrent dataLocation];
[fDataLocationField setStringValue: [location stringByAbbreviatingWithTildeInPath]];
[fDataLocationField setToolTip: location];
} }
- (void) updateInfoActivity - (void) updateInfoActivity
@ -374,15 +380,56 @@
{ {
Torrent * torrent; 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]; if (checkUpload != INVALID && checkUpload != ([torrent checkUpload] ? 1 : 0))
[fDataLocationField setStringValue: [[torrent dataLocation] stringByAbbreviatingWithTildeInPath]]; checkUpload = INVALID;
[fDataLocationField setToolTip: [torrent dataLocation]];
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 //set ratio settings
NSEnumerator * enumerator = [fTorrents objectEnumerator]; enumerator = [fTorrents objectEnumerator];
torrent = [enumerator nextObject]; //first torrent torrent = [enumerator nextObject]; //first torrent
int ratioSetting = [torrent stopRatioSetting]; int ratioSetting = [torrent stopRatioSetting];
@ -429,6 +476,16 @@
[fRatioLimitField setEnabled: NO]; [fRatioLimitField setEnabled: NO];
[fRatioLimitField setStringValue: @""]; [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]; [self updateInfoStats];
@ -470,9 +527,7 @@
[fPiecesView updateView: YES]; [fPiecesView updateView: YES];
} }
else if ([identifier isEqualToString: TAB_PEERS_IDENT]) else if ([identifier isEqualToString: TAB_PEERS_IDENT])
{
height = TAB_PEERS_HEIGHT; height = TAB_PEERS_HEIGHT;
}
else if ([identifier isEqualToString: TAB_FILES_IDENT]) else if ([identifier isEqualToString: TAB_FILES_IDENT])
height = TAB_FILES_HEIGHT; height = TAB_FILES_HEIGHT;
else if ([identifier isEqualToString: TAB_OPTIONS_IDENT]) else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
@ -636,6 +691,58 @@
inFileViewerRootedAtPath: nil]; 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 - (void) setRatioCheck: (id) sender
{ {
int ratioSetting, tag = [[fRatioMatrix selectedCell] tag]; int ratioSetting, tag = [[fRatioMatrix selectedCell] tag];

View file

@ -50,9 +50,10 @@
NSImage * fIcon, * fIconFlipped, * fIconSmall; NSImage * fIcon, * fIconFlipped, * fIconSmall;
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString; NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
int fStopRatioSetting;
int fUploadLimit, fDownloadLimit, fStopRatioSetting;
float fRatioLimit; float fRatioLimit;
BOOL fFinishedSeeding, fWaitToStart, fError; BOOL fCheckUpload, fCheckDownload, fFinishedSeeding, fWaitToStart, fError;
int fOrderValue; int fOrderValue;
@ -89,6 +90,15 @@
- (float) ratioLimit; - (float) ratioLimit;
- (void) setRatioLimit: (float) limit; - (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; - (void) setWaitToStart: (BOOL) wait;
- (BOOL) waitingToStart; - (BOOL) waitingToStart;

View file

@ -35,8 +35,10 @@
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib - (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
publicTorrent: (NSNumber *) publicTorrent publicTorrent: (NSNumber *) publicTorrent
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart ratioLimit: (NSNumber *) ratioLimit
orderValue: (NSNumber *) orderValue; checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
- (NSImage *) advancedBar; - (NSImage *) advancedBar;
@ -62,7 +64,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
{ {
self = [self initWithHash: nil path: path lib: lib self = [self initWithHash: nil path: path lib: lib
publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil 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) if (self)
{ {
@ -83,6 +88,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
date: [history objectForKey: @"Date"] date: [history objectForKey: @"Date"]
stopRatioSetting: [history objectForKey: @"StopRatioSetting"] stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
ratioLimit: [history objectForKey: @"RatioLimit"] ratioLimit: [history objectForKey: @"RatioLimit"]
checkUpload: [history objectForKey: @"CheckUpload"]
uploadLimit: [history objectForKey: @"UploadLimit"]
checkDownload: [history objectForKey: @"CheckDownload"]
downloadLimit: [history objectForKey: @"DownloadLimit"]
waitToStart: [history objectForKey: @"WaitToStart"] waitToStart: [history objectForKey: @"WaitToStart"]
orderValue: [history objectForKey: @"OrderValue"]]; orderValue: [history objectForKey: @"OrderValue"]];
@ -132,6 +141,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[self date], @"Date", [self date], @"Date",
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting", [NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit", [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
[NSNumber numberWithBool: fCheckUpload], @"CheckUpload",
[NSNumber numberWithInt: fUploadLimit], @"UploadLimit",
[NSNumber numberWithBool: fCheckDownload], @"CheckDownload",
[NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit",
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart", [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
[self orderValue], @"OrderValue", nil]; [self orderValue], @"OrderValue", nil];
@ -506,6 +519,50 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
fRatioLimit = limit; 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 - (void) setWaitToStart: (BOOL) wait
{ {
fWaitToStart = 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 - (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
publicTorrent: (NSNumber *) publicTorrent publicTorrent: (NSNumber *) publicTorrent
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart ratioLimit: (NSNumber *) ratioLimit
orderValue: (NSNumber *) orderValue checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
{ {
if (!(self = [super init])) if (!(self = [super init]))
return nil; return nil;
@ -1071,6 +1130,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"]; fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
fFinishedSeeding = NO; 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"]; fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"AutoStartDownload"];
fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1; fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
fError = NO; fError = NO;