implement most of the rpc preferences updating

This commit is contained in:
Mitchell Livingston 2008-06-03 17:55:43 +00:00
parent c42a623ada
commit 84601b3e09
4 changed files with 75 additions and 1 deletions

View File

@ -268,5 +268,9 @@ typedef enum
- (void) prepareForUpdate: (NSNotification *) notification;
- (void) rpcCallback: (tr_rpc_callback_type) type forTorrentStruct: (struct tr_torrent *) torrentStruct;
- (void) rpcAddTorrentStruct: (NSValue *) torrentStructPtr;
- (void) rpcRemoveTorrent: (Torrent *) torrent;
- (void) rpcStartedStoppedTorrent: (Torrent *) torrent;
- (void) rpcChangedTorrent: (Torrent *) torrent;
@end

View File

@ -4159,7 +4159,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
//get the torrent
Torrent * torrent;
Torrent * torrent = nil;
if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED))
{
NSEnumerator * enumerator = [fTorrents objectEnumerator];
@ -4197,10 +4197,12 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
break;
case TR_RPC_SESSION_CHANGED:
[fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
break;
default:
NSLog(@"Unknown RPC command received!");
[torrent release];
}
[pool release];
@ -4248,6 +4250,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
if ([[fTableView selectedTorrents] containsObject: torrent])
{
#warning update the file table as well
[fInfoController updateInfoStats];
[fInfoController updateOptions];
}

View File

@ -116,4 +116,6 @@
- (void) helpForPeers: (id) sender;
- (void) helpForNetwork: (id) sender;
- (void) rpcUpdatePrefs;
@end

View File

@ -624,6 +624,70 @@
inBook: [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"]];
}
- (void) rpcUpdatePrefs
{
//encryption
tr_encryption_mode encryptionMode = tr_sessionGetEncryption(fHandle);
[fDefaults setBool: encryptionMode != TR_PLAINTEXT_PREFERRED forKey: @"EncryptionPrefer"];
[fDefaults setBool: encryptionMode == TR_ENCRYPTION_PREFERRED forKey: @"EncryptionPrefer"];
//download directory
#warning missing!
//peers
uint16_t peersTotal = tr_sessionGetPeerLimit(fHandle);
[fDefaults setInteger: peersTotal forKey: @"PeersTotal"];
//pex
BOOL pex = tr_sessionIsPexEnabled(fHandle);
[fDefaults setBool: pex forKey: @"PEXGlobal"];
//port
int port = tr_sessionGetPeerPort(fHandle);
[fDefaults setInteger: port forKey: @"BindPort"];
BOOL nat = tr_sessionIsPortForwardingEnabled(fHandle);
[fDefaults setBool: nat forKey: @"NatTraversal"];
fPeerPort = -1;
fNatStatus = -1;
[self updatePortStatus];
//speed limit - down
BOOL downLimitEnabled = tr_sessionIsSpeedLimitEnabled(fHandle, TR_DOWN);
[fDefaults setBool: downLimitEnabled forKey: @"CheckDownload"];
int downLimit = tr_sessionGetSpeedLimit(fHandle, TR_DOWN);
[fDefaults setInteger: downLimit forKey: @"DownloadLimit"];
//speed limit - up
BOOL upLimitEnabled = tr_sessionIsSpeedLimitEnabled(fHandle, TR_UP);
[fDefaults setBool: upLimitEnabled forKey: @"CheckUpload"];
int upLimit = tr_sessionGetSpeedLimit(fHandle, TR_UP);
[fDefaults setInteger: upLimit forKey: @"UploadLimit"];
//update gui if necessary
if (fHasLoaded)
{
//encryption handled by bindings
[fPeersGlobalField setIntValue: peersTotal];
//pex handled by bindings
[fPortField setIntValue: port];
//port forwarding (nat) handled by bindings
//limit check handled by bindings
[fDownloadField setIntValue: downLimit];
//limit check handled by bindings
[fUploadField setIntValue: upLimit];
}
}
@end
@implementation PrefsController (Private)