Add preference option to disable PEX in Mac frontend.
This commit is contained in:
parent
4d7b4b536f
commit
1bb5140467
|
@ -8,6 +8,7 @@
|
|||
revealFile = id;
|
||||
revealTorrentFile = id;
|
||||
setLimitSetting = id;
|
||||
setPex = id;
|
||||
setRatioLimit = id;
|
||||
setRatioSetting = id;
|
||||
setSpeedLimit = id;
|
||||
|
@ -36,6 +37,7 @@
|
|||
fLeechersField = NSTextField;
|
||||
fNameField = NSTextField;
|
||||
fPeerTable = NSTableView;
|
||||
fPexCheck = NSButton;
|
||||
fPiecesField = NSTextField;
|
||||
fPiecesView = PiecesView;
|
||||
fRatioField = NSTextField;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>29 56 356 240 0 0 1024 746 </string>
|
||||
<string>47 71 356 240 0 0 1440 878 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>549</key>
|
||||
|
@ -24,6 +24,6 @@
|
|||
<integer>5</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8L127</string>
|
||||
<string>8P2137</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Binary file not shown.
|
@ -58,6 +58,7 @@
|
|||
IBOutlet NSPopUpButton * fRatioPopUp, * fUploadLimitPopUp, * fDownloadLimitPopUp;
|
||||
IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField,
|
||||
* fUploadLimitLabel, * fDownloadLimitLabel;
|
||||
IBOutlet NSButton * fPexCheck;
|
||||
}
|
||||
|
||||
- (void) updateInfoForTorrents: (NSArray *) torrents;
|
||||
|
@ -76,4 +77,6 @@
|
|||
- (void) setRatioSetting: (id) sender;
|
||||
- (void) setRatioLimit: (id) sender;
|
||||
|
||||
- (void) setPex: (id) sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define TAB_ACTIVITY_HEIGHT 170.0
|
||||
#define TAB_PEERS_HEIGHT 279.0
|
||||
#define TAB_FILES_HEIGHT 279.0
|
||||
#define TAB_OPTIONS_HEIGHT 117.0
|
||||
#define TAB_OPTIONS_HEIGHT 156.0
|
||||
|
||||
#define OPTION_POPUP_GLOBAL 0
|
||||
#define OPTION_POPUP_NO_LIMIT 1
|
||||
|
@ -508,6 +508,26 @@
|
|||
[fRatioLimitField setFloatValue: ratioLimit];
|
||||
else
|
||||
[fRatioLimitField setStringValue: @""];
|
||||
|
||||
//set pex check
|
||||
enumerator = [fTorrents objectEnumerator];
|
||||
torrent = [enumerator nextObject]; //first torrent
|
||||
|
||||
BOOL pexEnabled = ![torrent privateTorrent];
|
||||
int pexState = [torrent pex] ? NSOnState : NSOffState;
|
||||
|
||||
while ((pexEnabled || pexState != NSMixedState)
|
||||
&& (torrent = [enumerator nextObject]))
|
||||
{
|
||||
if (pexEnabled)
|
||||
pexEnabled = ![torrent privateTorrent];
|
||||
|
||||
if (pexState != NSMixedState && pexState != ([torrent pex] ? NSOnState : NSOffState))
|
||||
pexState = NSMixedState;
|
||||
}
|
||||
|
||||
[fPexCheck setEnabled: pexEnabled];
|
||||
[fPexCheck setState: pexState];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -527,6 +547,8 @@
|
|||
[fRatioPopUp selectItemAtIndex: -1];
|
||||
[fRatioLimitField setHidden: YES];
|
||||
[fRatioLimitField setStringValue: @""];
|
||||
|
||||
[fPexCheck setEnabled: NO];
|
||||
}
|
||||
|
||||
[self updateInfoStats];
|
||||
|
@ -942,4 +964,20 @@
|
|||
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: nil];
|
||||
}
|
||||
|
||||
- (void) setPex: (id) sender
|
||||
{
|
||||
int state = [sender state];
|
||||
if (state == NSMixedState)
|
||||
{
|
||||
state = NSOnState;
|
||||
[sender setState: state];
|
||||
}
|
||||
|
||||
Torrent * torrent;
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
[torrent setPex: state == NSOnState];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
BOOL fPublicTorrent;
|
||||
NSString * fPublicTorrentLocation;
|
||||
|
||||
BOOL fPex;
|
||||
|
||||
NSUserDefaults * fDefaults;
|
||||
|
||||
|
@ -179,6 +181,9 @@
|
|||
- (uint64_t) uploadedTotal;
|
||||
- (float) swarmSpeed;
|
||||
|
||||
- (BOOL) pex;
|
||||
- (void) setPex: (BOOL) set;
|
||||
|
||||
- (NSNumber *) orderValue;
|
||||
- (void) setOrderValue: (int) orderValue;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
limitSpeedCustom: (NSNumber *) limitCustom
|
||||
checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
|
||||
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
|
||||
pex: (NSNumber *) pex
|
||||
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
|
||||
|
||||
- (void) createFileList;
|
||||
|
@ -73,6 +74,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
limitSpeedCustom: nil
|
||||
checkUpload: nil uploadLimit: nil
|
||||
checkDownload: nil downloadLimit: nil
|
||||
pex: nil
|
||||
waitToStart: nil orderValue: nil];
|
||||
|
||||
if (self)
|
||||
|
@ -100,6 +102,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
uploadLimit: [history objectForKey: @"UploadLimit"]
|
||||
checkDownload: [history objectForKey: @"CheckDownload"]
|
||||
downloadLimit: [history objectForKey: @"DownloadLimit"]
|
||||
pex: [history objectForKey: @"Pex"]
|
||||
waitToStart: [history objectForKey: @"WaitToStart"]
|
||||
orderValue: [history objectForKey: @"OrderValue"]];
|
||||
|
||||
|
@ -171,6 +174,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
if (fPublicTorrent)
|
||||
[history setObject: [self publicTorrentLocation] forKey: @"TorrentPath"];
|
||||
|
||||
if (![self privateTorrent])
|
||||
[history setObject: [NSNumber numberWithBool: fPex] forKey: @"Pex"];
|
||||
|
||||
if (fDateCompleted)
|
||||
[history setObject: [self dateAdded] forKey: @"DateCompleted"];
|
||||
|
||||
|
@ -1086,6 +1092,20 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
return fStat->swarmspeed;
|
||||
}
|
||||
|
||||
- (BOOL) pex
|
||||
{
|
||||
return fPex;
|
||||
}
|
||||
|
||||
- (void) setPex: (BOOL) pex
|
||||
{
|
||||
if (![self privateTorrent])
|
||||
{
|
||||
fPex = pex;
|
||||
tr_torrentDisablePex(fHandle, pex);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSNumber *) orderValue
|
||||
{
|
||||
return [NSNumber numberWithInt: fOrderValue];
|
||||
|
@ -1236,6 +1256,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
limitSpeedCustom: (NSNumber *) limitCustom
|
||||
checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
|
||||
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
|
||||
pex: (NSNumber *) pex
|
||||
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
|
@ -1280,6 +1301,12 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
fCheckDownload = checkDownload ? [checkDownload intValue] : NSMixedState;
|
||||
fDownloadLimit = downloadLimit ? [downloadLimit intValue] : [fDefaults integerForKey: @"DownloadLimit"];
|
||||
[self updateSpeedSetting];
|
||||
|
||||
if ([self privateTorrent])
|
||||
fPex = NO;
|
||||
else
|
||||
fPex = pex ? [pex boolValue] : YES;
|
||||
tr_torrentDisablePex(fHandle, !fPex);
|
||||
|
||||
fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"AutoStartDownload"];
|
||||
fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
|
||||
|
|
Loading…
Reference in New Issue