mirror of
https://github.com/transmission/transmission
synced 2025-03-19 02:05:32 +00:00
the Mac build works with the new speed limit libT code - still a bit quirky
This commit is contained in:
parent
f1d92708e7
commit
453e4a3f72
7 changed files with 118 additions and 157 deletions
|
@ -2207,6 +2207,7 @@
|
||||||
INFOPLIST_PREFIX_HEADER = "$(SRCROOT)/libtransmission/version.h";
|
INFOPLIST_PREFIX_HEADER = "$(SRCROOT)/libtransmission/version.h";
|
||||||
INFOPLIST_PREPROCESS = YES;
|
INFOPLIST_PREPROCESS = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
OTHER_CFLAGS = "$(inherited)";
|
OTHER_CFLAGS = "$(inherited)";
|
||||||
OTHER_LDFLAGS = "";
|
OTHER_LDFLAGS = "";
|
||||||
PREBINDING = NO;
|
PREBINDING = NO;
|
||||||
|
|
|
@ -101,8 +101,6 @@ typedef enum
|
||||||
Badger * fBadger;
|
Badger * fBadger;
|
||||||
IBOutlet NSMenu * fDockMenu;
|
IBOutlet NSMenu * fDockMenu;
|
||||||
|
|
||||||
NSTimer * fSpeedLimitTimer;
|
|
||||||
|
|
||||||
NSMutableArray * fAutoImportedNames;
|
NSMutableArray * fAutoImportedNames;
|
||||||
NSTimer * fAutoImportTimer;
|
NSTimer * fAutoImportTimer;
|
||||||
|
|
||||||
|
@ -213,9 +211,7 @@ typedef enum
|
||||||
|
|
||||||
- (void) toggleSpeedLimit: (id) sender;
|
- (void) toggleSpeedLimit: (id) sender;
|
||||||
- (void) speedLimitChanged: (id) sender;
|
- (void) speedLimitChanged: (id) sender;
|
||||||
- (void) autoSpeedLimitChange: (NSNotification *) notification;
|
- (void) altSpeedToggledCallbackIsLimited: (NSNumber *) limited;
|
||||||
- (void) autoSpeedLimit: (NSTimer *) timer;
|
|
||||||
- (void) setAutoSpeedLimitTimer: (BOOL) nextIsLimit;
|
|
||||||
|
|
||||||
- (void) setLimitGlobalEnabled: (id) sender;
|
- (void) setLimitGlobalEnabled: (id) sender;
|
||||||
- (void) setQuickLimitGlobal: (id) sender;
|
- (void) setQuickLimitGlobal: (id) sender;
|
||||||
|
|
|
@ -143,6 +143,12 @@ typedef enum
|
||||||
#define TRAC_URL @"http://trac.transmissionbt.com/"
|
#define TRAC_URL @"http://trac.transmissionbt.com/"
|
||||||
#define DONATE_URL @"http://www.transmissionbt.com/donate.php"
|
#define DONATE_URL @"http://www.transmissionbt.com/donate.php"
|
||||||
|
|
||||||
|
static void altSpeedToggledCallback(tr_session * handle UNUSED, tr_bool active, void * controller)
|
||||||
|
{
|
||||||
|
[(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
|
||||||
|
withObject: [[NSNumber alloc] initWithBool: active] waitUntilDone: NO];
|
||||||
|
}
|
||||||
|
|
||||||
static tr_rpc_callback_status rpcCallback(tr_session * handle UNUSED, tr_rpc_callback_type type, struct tr_torrent * torrentStruct, void * controller)
|
static tr_rpc_callback_status rpcCallback(tr_session * handle UNUSED, tr_rpc_callback_type type, struct tr_torrent * torrentStruct, void * controller)
|
||||||
{
|
{
|
||||||
[(Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
|
[(Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
|
||||||
|
@ -200,10 +206,40 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
{
|
{
|
||||||
fDefaults = [NSUserDefaults standardUserDefaults];
|
fDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
//checks for old version speeds of -1
|
||||||
|
if ([fDefaults integerForKey: @"UploadLimit"] < 0)
|
||||||
|
{
|
||||||
|
[fDefaults removeObjectForKey: @"UploadLimit"];
|
||||||
|
[fDefaults setBool: NO forKey: @"CheckUpload"];
|
||||||
|
}
|
||||||
|
if ([fDefaults integerForKey: @"DownloadLimit"] < 0)
|
||||||
|
{
|
||||||
|
[fDefaults removeObjectForKey: @"DownloadLimit"];
|
||||||
|
[fDefaults setBool: NO forKey: @"CheckDownload"];
|
||||||
|
}
|
||||||
|
|
||||||
tr_benc settings;
|
tr_benc settings;
|
||||||
tr_bencInitDict(&settings, 22);
|
tr_bencInitDict(&settings, 28);
|
||||||
tr_sessionGetDefaultSettings(&settings);
|
tr_sessionGetDefaultSettings(&settings);
|
||||||
|
|
||||||
|
#warning how to work with schedule?
|
||||||
|
if (![fDefaults boolForKey: @"SpeedLimitAuto"])
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_ALT_SPEED_ENABLED, [fDefaults boolForKey: @"SpeedLimit"]);
|
||||||
|
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_ALT_SPEED_UP, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_ALT_SPEED_DOWN, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
|
||||||
|
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, [fDefaults boolForKey: @"SpeedLimitAuto"]);
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, [PrefsController dateToTimeSum:
|
||||||
|
[fDefaults objectForKey: @"SpeedLimitAutoOnDate"]]);
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_ALT_SPEED_TIME_END, [PrefsController dateToTimeSum:
|
||||||
|
[fDefaults objectForKey: @"SpeedLimitAutoOffDate"]]);
|
||||||
|
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_DSPEED, [fDefaults integerForKey: @"DownloadLimit"]);
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_DSPEED_ENABLED, [fDefaults boolForKey: @"CheckDownload"]);
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_USPEED, [fDefaults integerForKey: @"UploadLimit"]);
|
||||||
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_USPEED_ENABLED, [fDefaults boolForKey: @"CheckUpload"]);
|
||||||
|
|
||||||
tr_bencDictAddInt(&settings, TR_PREFS_KEY_BLOCKLIST_ENABLED, [fDefaults boolForKey: @"Blocklist"]);
|
tr_bencDictAddInt(&settings, TR_PREFS_KEY_BLOCKLIST_ENABLED, [fDefaults boolForKey: @"Blocklist"]);
|
||||||
|
|
||||||
#warning update when changing in prefs
|
#warning update when changing in prefs
|
||||||
|
@ -256,6 +292,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
fSoundPlaying = NO;
|
fSoundPlaying = NO;
|
||||||
|
|
||||||
|
#warning needs to set before init
|
||||||
|
tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, self);
|
||||||
|
|
||||||
tr_sessionSetRPCCallback(fLib, rpcCallback, self);
|
tr_sessionSetRPCCallback(fLib, rpcCallback, self);
|
||||||
|
|
||||||
[GrowlApplicationBridge setGrowlDelegate: self];
|
[GrowlApplicationBridge setGrowlDelegate: self];
|
||||||
|
@ -423,9 +462,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
[nc addObserver: self selector: @selector(torrentTableViewSelectionDidChange:)
|
[nc addObserver: self selector: @selector(torrentTableViewSelectionDidChange:)
|
||||||
name: NSOutlineViewSelectionDidChangeNotification object: fTableView];
|
name: NSOutlineViewSelectionDidChangeNotification object: fTableView];
|
||||||
|
|
||||||
[nc addObserver: self selector: @selector(autoSpeedLimitChange:)
|
|
||||||
name: @"AutoSpeedLimitChange" object: nil];
|
|
||||||
|
|
||||||
[nc addObserver: self selector: @selector(changeAutoImport)
|
[nc addObserver: self selector: @selector(changeAutoImport)
|
||||||
name: @"AutoImportSettingChange" object: nil];
|
name: @"AutoImportSettingChange" object: nil];
|
||||||
|
|
||||||
|
@ -474,9 +510,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"InfoVisible"])
|
if ([fDefaults boolForKey: @"InfoVisible"])
|
||||||
[self showInfo: nil];
|
[self showInfo: nil];
|
||||||
|
|
||||||
//set up the speed limit
|
|
||||||
[self autoSpeedLimitChange: nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) applicationDidFinishLaunching: (NSNotification *) notification
|
- (void) applicationDidFinishLaunching: (NSNotification *) notification
|
||||||
|
@ -552,7 +585,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
[fTimer invalidate];
|
[fTimer invalidate];
|
||||||
[fSpeedLimitTimer invalidate];
|
|
||||||
|
|
||||||
if (fAutoImportTimer)
|
if (fAutoImportTimer)
|
||||||
{
|
{
|
||||||
|
@ -2284,96 +2316,26 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
- (void) speedLimitChanged: (id) sender
|
- (void) speedLimitChanged: (id) sender
|
||||||
{
|
{
|
||||||
[fPrefsController applySpeedSettings: nil];
|
tr_sessionUseAltSpeed(fLib, [fDefaults boolForKey: @"SpeedLimit"]);
|
||||||
|
[self updateSpeedFieldsToolTips];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) autoSpeedLimitChange: (NSNotification *) notification
|
//limited has been retained
|
||||||
|
- (void) altSpeedToggledCallbackIsLimited: (NSNumber *) limited
|
||||||
{
|
{
|
||||||
//clear timer here in case it's not being reset
|
const BOOL isLimited = [limited boolValue];
|
||||||
[fSpeedLimitTimer invalidate];
|
|
||||||
fSpeedLimitTimer = nil;
|
|
||||||
|
|
||||||
if (![fDefaults boolForKey: @"SpeedLimitAuto"])
|
|
||||||
return;
|
|
||||||
|
|
||||||
NSCalendar * calendar = [NSCalendar currentCalendar];
|
|
||||||
NSDateComponents * nowComponents = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: [NSDate date]],
|
|
||||||
* onComponents = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit
|
|
||||||
fromDate: [fDefaults objectForKey: @"SpeedLimitAutoOnDate"]],
|
|
||||||
* offComponents = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit
|
|
||||||
fromDate: [fDefaults objectForKey: @"SpeedLimitAutoOffDate"]];
|
|
||||||
|
|
||||||
//check if should be on if within range
|
|
||||||
NSInteger onTime = [onComponents hour] * 60 + [onComponents minute],
|
|
||||||
offTime = [offComponents hour] * 60 + [offComponents minute],
|
|
||||||
nowTime = [nowComponents hour] * 60 + [nowComponents minute];
|
|
||||||
|
|
||||||
BOOL shouldBeOn = NO;
|
|
||||||
if (onTime < offTime)
|
|
||||||
shouldBeOn = onTime <= nowTime && nowTime < offTime;
|
|
||||||
else if (onTime > offTime)
|
|
||||||
shouldBeOn = onTime <= nowTime || nowTime < offTime;
|
|
||||||
else;
|
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"SpeedLimit"] != shouldBeOn)
|
|
||||||
[self toggleSpeedLimit: nil];
|
|
||||||
|
|
||||||
//no need to set the timer if both times are equal
|
|
||||||
if (onTime == offTime)
|
|
||||||
return;
|
|
||||||
|
|
||||||
[self setAutoSpeedLimitTimer: !shouldBeOn];
|
|
||||||
}
|
|
||||||
|
|
||||||
//only called by fSpeedLimitTimer
|
[fDefaults setBool: isLimited forKey: @"SpeedLimit"];
|
||||||
- (void) autoSpeedLimit: (NSTimer *) timer
|
[self updateSpeedFieldsToolTips];
|
||||||
{
|
|
||||||
BOOL shouldLimit = [[timer userInfo] boolValue];
|
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"SpeedLimit"] != shouldLimit)
|
#warning don't show on startup or on manual changed
|
||||||
{
|
[GrowlApplicationBridge notifyWithTitle: isLimited
|
||||||
[self toggleSpeedLimit: nil];
|
? NSLocalizedString(@"Speed Limit Auto Enabled", "Growl notification title")
|
||||||
|
: NSLocalizedString(@"Speed Limit Auto Disabled", "Growl notification title")
|
||||||
[GrowlApplicationBridge notifyWithTitle: [fDefaults boolForKey: @"SpeedLimit"]
|
description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description")
|
||||||
? NSLocalizedString(@"Speed Limit Auto Enabled", "Growl notification title")
|
notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||||
: NSLocalizedString(@"Speed Limit Auto Disabled", "Growl notification title")
|
|
||||||
description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description")
|
|
||||||
notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setAutoSpeedLimitTimer: !shouldLimit];
|
[limited release];
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setAutoSpeedLimitTimer: (BOOL) nextIsLimit
|
|
||||||
{
|
|
||||||
NSDate * timerDate = [fDefaults objectForKey: nextIsLimit ? @"SpeedLimitAutoOnDate" : @"SpeedLimitAutoOffDate"];
|
|
||||||
|
|
||||||
//create date with combination of the current date and the date to go off
|
|
||||||
NSCalendar * calendar = [NSCalendar currentCalendar];
|
|
||||||
NSDateComponents * nowComponents = [calendar components: NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit
|
|
||||||
| NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: [NSDate date]],
|
|
||||||
* timerComponents = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: timerDate];
|
|
||||||
|
|
||||||
//check if should be the next day
|
|
||||||
NSInteger nowTime = [nowComponents hour] * 60 + [nowComponents minute],
|
|
||||||
timerTime = [timerComponents hour] * 60 + [timerComponents minute];
|
|
||||||
if (timerTime < nowTime)
|
|
||||||
[nowComponents setDay: [nowComponents day] + 1]; //properly goes to next month when appropriate
|
|
||||||
|
|
||||||
[nowComponents setHour: [timerComponents hour]];
|
|
||||||
[nowComponents setMinute: [timerComponents minute]];
|
|
||||||
[nowComponents setSecond: 0];
|
|
||||||
|
|
||||||
NSDate * dateToUse = [calendar dateFromComponents: nowComponents];
|
|
||||||
|
|
||||||
fSpeedLimitTimer = [[NSTimer alloc] initWithFireDate: dateToUse interval: 0 target: self selector: @selector(autoSpeedLimit:)
|
|
||||||
userInfo: [NSNumber numberWithBool: nextIsLimit] repeats: NO];
|
|
||||||
|
|
||||||
NSRunLoop * loop = [NSRunLoop mainRunLoop];
|
|
||||||
[loop addTimer: fSpeedLimitTimer forMode: NSDefaultRunLoopMode];
|
|
||||||
[loop addTimer: fSpeedLimitTimer forMode: NSModalPanelRunLoopMode];
|
|
||||||
[loop addTimer: fSpeedLimitTimer forMode: NSEventTrackingRunLoopMode];
|
|
||||||
[fSpeedLimitTimer release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setLimitGlobalEnabled: (id) sender
|
- (void) setLimitGlobalEnabled: (id) sender
|
||||||
|
@ -3774,7 +3736,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
case kIOMessageSystemHasPoweredOn:
|
case kIOMessageSystemHasPoweredOn:
|
||||||
//resume sleeping transfers after we wake up
|
//resume sleeping transfers after we wake up
|
||||||
[fTorrents makeObjectsPerformSelector: @selector(wakeUp)];
|
[fTorrents makeObjectsPerformSelector: @selector(wakeUp)];
|
||||||
[self autoSpeedLimitChange: nil];
|
#warning check speed limit timer?
|
||||||
|
//[self autoSpeedLimitChange: nil];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,12 +107,15 @@
|
||||||
- (void) setRatioStop: (id) sender;
|
- (void) setRatioStop: (id) sender;
|
||||||
|
|
||||||
- (void) applySpeedSettings: (id) sender;
|
- (void) applySpeedSettings: (id) sender;
|
||||||
|
- (void) applyAltSpeedSettings;
|
||||||
|
|
||||||
- (void) updateLimitFields;
|
- (void) updateLimitFields;
|
||||||
- (void) setGlobalLimit: (id) sender;
|
- (void) setGlobalLimit: (id) sender;
|
||||||
|
|
||||||
- (void) setSpeedLimit: (id) sender;
|
- (void) setSpeedLimit: (id) sender;
|
||||||
- (void) setAutoSpeedLimit: (id) sender;
|
- (void) setAutoSpeedLimit: (id) sender;
|
||||||
|
- (void) setAutoSpeedLimitTime: (id) sender;
|
||||||
|
+ (NSInteger) dateToTimeSum: (NSDate *) date;
|
||||||
|
|
||||||
- (void) setAutoImport: (id) sender;
|
- (void) setAutoImport: (id) sender;
|
||||||
- (void) importFolderSheetShow: (id) sender;
|
- (void) importFolderSheetShow: (id) sender;
|
||||||
|
|
|
@ -90,18 +90,6 @@ tr_session * fHandle;
|
||||||
{
|
{
|
||||||
fDefaults = [NSUserDefaults standardUserDefaults];
|
fDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
//checks for old version speeds of -1
|
|
||||||
if ([fDefaults integerForKey: @"UploadLimit"] < 0)
|
|
||||||
{
|
|
||||||
[fDefaults removeObjectForKey: @"UploadLimit"];
|
|
||||||
[fDefaults setBool: NO forKey: @"CheckUpload"];
|
|
||||||
}
|
|
||||||
if ([fDefaults integerForKey: @"DownloadLimit"] < 0)
|
|
||||||
{
|
|
||||||
[fDefaults removeObjectForKey: @"DownloadLimit"];
|
|
||||||
[fDefaults setBool: NO forKey: @"CheckDownload"];
|
|
||||||
}
|
|
||||||
|
|
||||||
//check for old version download location (before 1.1)
|
//check for old version download location (before 1.1)
|
||||||
NSString * choice;
|
NSString * choice;
|
||||||
if ((choice = [fDefaults stringForKey: @"DownloadChoice"]))
|
if ((choice = [fDefaults stringForKey: @"DownloadChoice"]))
|
||||||
|
@ -127,9 +115,6 @@ tr_session * fHandle;
|
||||||
//set encryption
|
//set encryption
|
||||||
[self setEncryptionMode: nil];
|
[self setEncryptionMode: nil];
|
||||||
|
|
||||||
//actually set bandwidth limits
|
|
||||||
[self applySpeedSettings: nil];
|
|
||||||
|
|
||||||
//set proxy type
|
//set proxy type
|
||||||
[self updateProxyType];
|
[self updateProxyType];
|
||||||
[self updateProxyPassword];
|
[self updateProxyPassword];
|
||||||
|
@ -547,23 +532,20 @@ tr_session * fHandle;
|
||||||
|
|
||||||
- (void) applySpeedSettings: (id) sender
|
- (void) applySpeedSettings: (id) sender
|
||||||
{
|
{
|
||||||
if ([fDefaults boolForKey: @"SpeedLimit"])
|
tr_sessionLimitSpeed(fHandle, TR_UP, [fDefaults boolForKey: @"CheckUpload"]);
|
||||||
{
|
tr_sessionSetSpeedLimit(fHandle, TR_UP, [fDefaults integerForKey: @"UploadLimit"]);
|
||||||
tr_sessionSetSpeedLimitEnabled(fHandle, TR_UP, 1);
|
|
||||||
tr_sessionSetSpeedLimit(fHandle, TR_UP, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
|
|
||||||
|
|
||||||
tr_sessionSetSpeedLimitEnabled(fHandle, TR_DOWN, 1);
|
|
||||||
tr_sessionSetSpeedLimit(fHandle, TR_DOWN, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tr_sessionSetSpeedLimitEnabled(fHandle, TR_UP, [fDefaults boolForKey: @"CheckUpload"]);
|
|
||||||
tr_sessionSetSpeedLimit(fHandle, TR_UP, [fDefaults integerForKey: @"UploadLimit"]);
|
|
||||||
|
|
||||||
tr_sessionSetSpeedLimitEnabled(fHandle, TR_DOWN, [fDefaults boolForKey: @"CheckDownload"]);
|
|
||||||
tr_sessionSetSpeedLimit(fHandle, TR_DOWN, [fDefaults integerForKey: @"DownloadLimit"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
tr_sessionLimitSpeed(fHandle, TR_DOWN, [fDefaults boolForKey: @"CheckDownload"]);
|
||||||
|
tr_sessionSetSpeedLimit(fHandle, TR_DOWN, [fDefaults integerForKey: @"DownloadLimit"]);
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"SpeedLimitUpdate" object: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) applyAltSpeedSettings
|
||||||
|
{
|
||||||
|
tr_sessionSetAltSpeed(fHandle, TR_UP, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
|
||||||
|
tr_sessionSetAltSpeed(fHandle, TR_DOWN, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"SpeedLimitUpdate" object: nil];
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"SpeedLimitUpdate" object: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,12 +590,25 @@ tr_session * fHandle;
|
||||||
{
|
{
|
||||||
[fDefaults setInteger: [sender intValue] forKey: sender == fSpeedLimitUploadField
|
[fDefaults setInteger: [sender intValue] forKey: sender == fSpeedLimitUploadField
|
||||||
? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
|
? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
|
||||||
[self applySpeedSettings: self];
|
[self applyAltSpeedSettings];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAutoSpeedLimit: (id) sender
|
- (void) setAutoSpeedLimit: (id) sender
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
|
tr_sessionUseAltSpeedTime(fHandle, [fDefaults boolForKey: @"SpeedLimitAuto"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setAutoSpeedLimitTime: (id) sender
|
||||||
|
{
|
||||||
|
tr_sessionSetAltSpeedBegin(fHandle, [PrefsController dateToTimeSum: [fDefaults objectForKey: @"SpeedLimitAutoOnDate"]]);
|
||||||
|
tr_sessionSetAltSpeedEnd(fHandle, [PrefsController dateToTimeSum: [fDefaults objectForKey: @"SpeedLimitAutoOffDate"]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSInteger) dateToTimeSum: (NSDate *) date
|
||||||
|
{
|
||||||
|
NSCalendar * calendar = [NSCalendar currentCalendar];
|
||||||
|
NSDateComponents * components = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: date];
|
||||||
|
return [components hour] * 60 + [components minute];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
|
- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
|
||||||
|
@ -1048,6 +1043,7 @@ tr_session * fHandle;
|
||||||
inBook: [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"]];
|
inBook: [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#warning probably needs to be updated
|
||||||
- (void) rpcUpdatePrefs
|
- (void) rpcUpdatePrefs
|
||||||
{
|
{
|
||||||
//encryption
|
//encryption
|
||||||
|
@ -1079,14 +1075,14 @@ tr_session * fHandle;
|
||||||
[self updatePortStatus];
|
[self updatePortStatus];
|
||||||
|
|
||||||
//speed limit - down
|
//speed limit - down
|
||||||
BOOL downLimitEnabled = tr_sessionIsSpeedLimitEnabled(fHandle, TR_DOWN);
|
BOOL downLimitEnabled = tr_sessionIsSpeedLimited(fHandle, TR_DOWN);
|
||||||
[fDefaults setBool: downLimitEnabled forKey: @"CheckDownload"];
|
[fDefaults setBool: downLimitEnabled forKey: @"CheckDownload"];
|
||||||
|
|
||||||
int downLimit = tr_sessionGetSpeedLimit(fHandle, TR_DOWN);
|
int downLimit = tr_sessionGetSpeedLimit(fHandle, TR_DOWN);
|
||||||
[fDefaults setInteger: downLimit forKey: @"DownloadLimit"];
|
[fDefaults setInteger: downLimit forKey: @"DownloadLimit"];
|
||||||
|
|
||||||
//speed limit - up
|
//speed limit - up
|
||||||
BOOL upLimitEnabled = tr_sessionIsSpeedLimitEnabled(fHandle, TR_UP);
|
BOOL upLimitEnabled = tr_sessionIsSpeedLimited(fHandle, TR_UP);
|
||||||
[fDefaults setBool: upLimitEnabled forKey: @"CheckUpload"];
|
[fDefaults setBool: upLimitEnabled forKey: @"CheckUpload"];
|
||||||
|
|
||||||
int upLimit = tr_sessionGetSpeedLimit(fHandle, TR_UP);
|
int upLimit = tr_sessionGetSpeedLimit(fHandle, TR_UP);
|
||||||
|
|
|
@ -394,7 +394,7 @@ int trashDataFile(const char * filename)
|
||||||
|
|
||||||
- (BOOL) usesSpeedLimit: (BOOL) upload
|
- (BOOL) usesSpeedLimit: (BOOL) upload
|
||||||
{
|
{
|
||||||
return tr_torrentIsUsingSpeedLimit(fHandle, upload ? TR_UP : TR_DOWN);
|
return tr_torrentUsesSpeedLimit(fHandle, upload ? TR_UP : TR_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setUseSpeedLimit: (BOOL) use upload: (BOOL) upload
|
- (void) setUseSpeedLimit: (BOOL) use upload: (BOOL) upload
|
||||||
|
@ -414,16 +414,12 @@ int trashDataFile(const char * filename)
|
||||||
|
|
||||||
- (BOOL) usesGlobalSpeedLimit
|
- (BOOL) usesGlobalSpeedLimit
|
||||||
{
|
{
|
||||||
const BOOL up = tr_torrentIsUsingGlobalSpeedLimit(fHandle, TR_UP);
|
return tr_torrentUsesSessionLimits(fHandle);
|
||||||
const BOOL down = tr_torrentIsUsingGlobalSpeedLimit(fHandle, TR_DOWN);
|
|
||||||
NSAssert(up == down, @"upload and download global limit settings should have the same value");
|
|
||||||
return up;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setUseGlobalSpeedLimit: (BOOL) use
|
- (void) setUseGlobalSpeedLimit: (BOOL) use
|
||||||
{
|
{
|
||||||
tr_torrentUseGlobalSpeedLimit(fHandle, TR_UP, use);
|
tr_torrentUseSessionLimits(fHandle, use);
|
||||||
tr_torrentUseGlobalSpeedLimit(fHandle, TR_DOWN, use);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMaxPeerConnect: (uint16_t) count
|
- (void) setMaxPeerConnect: (uint16_t) count
|
||||||
|
|
|
@ -3068,6 +3068,7 @@ zcfN584IzijOSc5pzorOqs66ztvO+88czzzPXc99z57Pvs/fz+/QANAg0EHQYdCC0KLQw9Dj0PPRFNE0
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrame">{{1, 1}, {141, 169}}</string>
|
<string key="NSFrame">{{1, 1}, {141, 169}}</string>
|
||||||
<reference key="NSSuperview" ref="544077474"/>
|
<reference key="NSSuperview" ref="544077474"/>
|
||||||
|
<reference key="NSNextKeyView" ref="638525082"/>
|
||||||
<reference key="NSDocView" ref="638525082"/>
|
<reference key="NSDocView" ref="638525082"/>
|
||||||
<reference key="NSBGColor" ref="729660797"/>
|
<reference key="NSBGColor" ref="729660797"/>
|
||||||
<int key="NScvFlags">4</int>
|
<int key="NScvFlags">4</int>
|
||||||
|
@ -3095,6 +3096,7 @@ zcfN584IzijOSc5pzorOqs66ztvO+88czzzPXc99z57Pvs/fz+/QANAg0EHQYdCC0KLQw9Dj0PPRFNE0
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrame">{{20, 49}, {143, 171}}</string>
|
<string key="NSFrame">{{20, 49}, {143, 171}}</string>
|
||||||
<reference key="NSSuperview" ref="284666863"/>
|
<reference key="NSSuperview" ref="284666863"/>
|
||||||
|
<reference key="NSNextKeyView" ref="568562479"/>
|
||||||
<int key="NSsFlags">530</int>
|
<int key="NSsFlags">530</int>
|
||||||
<reference key="NSVScroller" ref="287972127"/>
|
<reference key="NSVScroller" ref="287972127"/>
|
||||||
<reference key="NSHScroller" ref="781866080"/>
|
<reference key="NSHScroller" ref="781866080"/>
|
||||||
|
@ -5363,6 +5365,7 @@ AAABAAAAAQ</bytes>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrame">{{1, 1}, {291, 76}}</string>
|
<string key="NSFrame">{{1, 1}, {291, 76}}</string>
|
||||||
<reference key="NSSuperview" ref="122119447"/>
|
<reference key="NSSuperview" ref="122119447"/>
|
||||||
|
<reference key="NSNextKeyView" ref="173651346"/>
|
||||||
<reference key="NSDocView" ref="173651346"/>
|
<reference key="NSDocView" ref="173651346"/>
|
||||||
<reference key="NSBGColor" ref="729660797"/>
|
<reference key="NSBGColor" ref="729660797"/>
|
||||||
<int key="NScvFlags">4</int>
|
<int key="NScvFlags">4</int>
|
||||||
|
@ -5389,6 +5392,7 @@ AAABAAAAAQ</bytes>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrame">{{103, 96}, {308, 78}}</string>
|
<string key="NSFrame">{{103, 96}, {308, 78}}</string>
|
||||||
<reference key="NSSuperview" ref="810116101"/>
|
<reference key="NSSuperview" ref="810116101"/>
|
||||||
|
<reference key="NSNextKeyView" ref="206862330"/>
|
||||||
<int key="NSsFlags">18</int>
|
<int key="NSsFlags">18</int>
|
||||||
<reference key="NSVScroller" ref="220703981"/>
|
<reference key="NSVScroller" ref="220703981"/>
|
||||||
<reference key="NSHScroller" ref="383062716"/>
|
<reference key="NSHScroller" ref="383062716"/>
|
||||||
|
@ -6129,22 +6133,6 @@ AAABAAAAAQ</bytes>
|
||||||
</object>
|
</object>
|
||||||
<int key="connectionID">531</int>
|
<int key="connectionID">531</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBConnectionRecord">
|
|
||||||
<object class="IBActionConnection" key="connection">
|
|
||||||
<string key="label">setAutoSpeedLimit:</string>
|
|
||||||
<reference key="source" ref="511492310"/>
|
|
||||||
<reference key="destination" ref="401711944"/>
|
|
||||||
</object>
|
|
||||||
<int key="connectionID">532</int>
|
|
||||||
</object>
|
|
||||||
<object class="IBConnectionRecord">
|
|
||||||
<object class="IBActionConnection" key="connection">
|
|
||||||
<string key="label">setAutoSpeedLimit:</string>
|
|
||||||
<reference key="source" ref="511492310"/>
|
|
||||||
<reference key="destination" ref="497078689"/>
|
|
||||||
</object>
|
|
||||||
<int key="connectionID">533</int>
|
|
||||||
</object>
|
|
||||||
<object class="IBConnectionRecord">
|
<object class="IBConnectionRecord">
|
||||||
<object class="IBBindingConnection" key="connection">
|
<object class="IBBindingConnection" key="connection">
|
||||||
<string key="label">value: values.SpeedLimitAutoOnDate</string>
|
<string key="label">value: values.SpeedLimitAutoOnDate</string>
|
||||||
|
@ -8707,6 +8695,22 @@ AAABAAAAAQ</bytes>
|
||||||
</object>
|
</object>
|
||||||
<int key="connectionID">1900</int>
|
<int key="connectionID">1900</int>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBActionConnection" key="connection">
|
||||||
|
<string key="label">setAutoSpeedLimitTime:</string>
|
||||||
|
<reference key="source" ref="511492310"/>
|
||||||
|
<reference key="destination" ref="497078689"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">1902</int>
|
||||||
|
</object>
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBActionConnection" key="connection">
|
||||||
|
<string key="label">setAutoSpeedLimitTime:</string>
|
||||||
|
<reference key="source" ref="511492310"/>
|
||||||
|
<reference key="destination" ref="401711944"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">1903</int>
|
||||||
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||||
<object class="NSArray" key="orderedObjects">
|
<object class="NSArray" key="orderedObjects">
|
||||||
|
@ -12495,7 +12499,7 @@ AAABAAAAAQ</bytes>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<nil key="sourceID"/>
|
<nil key="sourceID"/>
|
||||||
<int key="maxID">1901</int>
|
<int key="maxID">1903</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||||
|
@ -12650,6 +12654,7 @@ AAABAAAAAQ</bytes>
|
||||||
<string>setAutoImport:</string>
|
<string>setAutoImport:</string>
|
||||||
<string>setAutoSize:</string>
|
<string>setAutoSize:</string>
|
||||||
<string>setAutoSpeedLimit:</string>
|
<string>setAutoSpeedLimit:</string>
|
||||||
|
<string>setAutoSpeedLimitTime:</string>
|
||||||
<string>setAutoUpdateToBeta:</string>
|
<string>setAutoUpdateToBeta:</string>
|
||||||
<string>setBadge:</string>
|
<string>setBadge:</string>
|
||||||
<string>setBlocklistAutoUpdate:</string>
|
<string>setBlocklistAutoUpdate:</string>
|
||||||
|
@ -12736,6 +12741,7 @@ AAABAAAAAQ</bytes>
|
||||||
<string>id</string>
|
<string>id</string>
|
||||||
<string>id</string>
|
<string>id</string>
|
||||||
<string>id</string>
|
<string>id</string>
|
||||||
|
<string>id</string>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="outlets">
|
<object class="NSMutableDictionary" key="outlets">
|
||||||
|
|
Loading…
Add table
Reference in a new issue