ipc update to ensure unlimited bandwidth is set correctly

This commit is contained in:
Mitchell Livingston 2007-12-27 05:07:40 +00:00
parent e319a6ffe4
commit 5f2d3b022e
2 changed files with 35 additions and 13 deletions

View File

@ -408,7 +408,7 @@ PrefsController * fPrefsController;
buf = ipc_mkempty( _ipc, &size, msgid, tag ); buf = ipc_mkempty( _ipc, &size, msgid, tag );
if( NULL == buf ) if( NULL == buf )
return FALSE; return NO;
return [self sendresp: buf return [self sendresp: buf
size: size]; size: size];
@ -423,7 +423,7 @@ PrefsController * fPrefsController;
buf = ipc_mkint( _ipc, &size, msgid, tag, val ); buf = ipc_mkint( _ipc, &size, msgid, tag, val );
if( NULL == buf ) if( NULL == buf )
return FALSE; return NO;
return [self sendresp: buf return [self sendresp: buf
size: size]; size: size];
@ -451,7 +451,7 @@ PrefsController * fPrefsController;
buf = ipc_mkstr( _ipc, &size, msgid, tag, [sucky bytes] ); buf = ipc_mkstr( _ipc, &size, msgid, tag, [sucky bytes] );
} }
if( NULL == buf ) if( NULL == buf )
return FALSE; return NO;
return [self sendresp: buf return [self sendresp: buf
size: size]; size: size];
@ -807,16 +807,26 @@ void msg_getint( enum ipc_msg msgid, benc_val_t * val, int64_t tag, void * arg )
fDefaults = [NSUserDefaults standardUserDefaults]; fDefaults = [NSUserDefaults standardUserDefaults];
int theValue;
switch( msgid ) switch( msgid )
{ {
case IPC_MSG_GETDOWNLIMIT: case IPC_MSG_GETDOWNLIMIT:
[client sendrespInt:IPC_MSG_DOWNLIMIT tag:tag val:[fDefaults integerForKey:@"DownloadLimit"]]; if ( [fDefaults boolForKey:@"CheckDownload"] )
theValue = [fDefaults integerForKey:@"DownloadLimit"];
else
theValue = -1;
[client sendrespInt:IPC_MSG_DOWNLIMIT tag:tag val:theValue];
break; break;
case IPC_MSG_GETPORT: case IPC_MSG_GETPORT:
[client sendrespInt:IPC_MSG_PORT tag:tag val:[fDefaults integerForKey:@"BindPort"]]; [client sendrespInt:IPC_MSG_PORT tag:tag val:[fDefaults integerForKey:@"BindPort"]];
break; break;
case IPC_MSG_GETUPLIMIT: case IPC_MSG_GETUPLIMIT:
[client sendrespInt:IPC_MSG_UPLIMIT tag:tag val:[fDefaults integerForKey:@"UploadLimit"]]; if ( [fDefaults boolForKey:@"CheckUpload"] )
theValue = [fDefaults integerForKey:@"UploadLimit"];
else
theValue = -1;
[client sendrespInt:IPC_MSG_UPLIMIT tag:tag val:theValue];
break; break;
default: default:
assert( 0 ); assert( 0 );
@ -904,7 +914,13 @@ void msg_setint( enum ipc_msg msgid, benc_val_t * val, int64_t tag, void * arg )
switch( msgid ) switch( msgid )
{ {
case IPC_MSG_DOWNLIMIT: case IPC_MSG_DOWNLIMIT:
if ( val->val.i < 0 )
[fDefaults setBool:NO forKey:@"CheckDownload"];
else
{
[fDefaults setBool:YES forKey:@"CheckDownload"];
[fDefaults setInteger:val->val.i forKey:@"DownloadLimit"]; [fDefaults setInteger:val->val.i forKey:@"DownloadLimit"];
}
[fPrefsController updateLimitFields]; [fPrefsController updateLimitFields];
[fPrefsController applySpeedSettings: nil]; [fPrefsController applySpeedSettings: nil];
break; break;
@ -913,7 +929,13 @@ void msg_setint( enum ipc_msg msgid, benc_val_t * val, int64_t tag, void * arg )
[fPrefsController updatePortField]; [fPrefsController updatePortField];
break; break;
case IPC_MSG_UPLIMIT: case IPC_MSG_UPLIMIT:
if ( val->val.i < 0 )
[fDefaults setBool:NO forKey:@"CheckUpload"];
else
{
[fDefaults setBool:YES forKey:@"CheckUpload"];
[fDefaults setInteger:val->val.i forKey:@"UploadLimit"]; [fDefaults setInteger:val->val.i forKey:@"UploadLimit"];
}
[fPrefsController updateLimitFields]; [fPrefsController updateLimitFields];
[fPrefsController applySpeedSettings: nil]; [fPrefsController applySpeedSettings: nil];
break; break;
@ -948,20 +970,20 @@ void msg_setstr( enum ipc_msg msgid, benc_val_t * val, int64_t tag, void * arg )
case IPC_MSG_CRYPTO: case IPC_MSG_CRYPTO:
if(!strcasecmp(val->val.s.s, "required")) if(!strcasecmp(val->val.s.s, "required"))
{ {
[fDefaults setBool:TRUE forKey: @"EncryptionPrefer"]; [fDefaults setBool:YES forKey: @"EncryptionPrefer"];
[fDefaults setBool:TRUE forKey: @"EncryptionRequire"]; [fDefaults setBool:YES forKey: @"EncryptionRequire"];
} }
else if(!strcasecmp(val->val.s.s, "preferred")) else if(!strcasecmp(val->val.s.s, "preferred"))
{ {
[fDefaults setBool:TRUE forKey: @"EncryptionPrefer"]; [fDefaults setBool:YES forKey: @"EncryptionPrefer"];
[fDefaults setBool:FALSE forKey: @"EncryptionRequire"]; [fDefaults setBool:NO forKey: @"EncryptionRequire"];
} }
else if(!strcasecmp(val->val.s.s, "plaintext")) else if(!strcasecmp(val->val.s.s, "plaintext"))
{ {
[fDefaults setBool:FALSE forKey: @"EncryptionPrefer"]; [fDefaults setBool:NO forKey: @"EncryptionPrefer"];
[fDefaults setBool:FALSE forKey: @"EncryptionRequire"]; [fDefaults setBool:NO forKey: @"EncryptionRequire"];
} }
[client sendrespEmpty: IPC_MSG_OK tag: tag]; [client sendrespEmpty: IPC_MSG_OK tag: tag];