rendered paste bodyIndex: macosx/IPCController.h
===================================================================
--- macosx/IPCController.h (revision 4303)
+++ macosx/IPCController.h (working copy)
@@ -58,8 +58,10 @@
id _delegate;
}
-- (id) initWithHandle: (PrefsController *) thePrefsController;
+
+- (id) init;
- (id) delegate;
- (void) setDelegate: (id) newdelegate;
+- (void) setPrefsController: (id) thePrefsController;
@end
Index: macosx/IPCController.m
===================================================================
--- macosx/IPCController.m (revision 4303)
+++ macosx/IPCController.m (working copy)
@@ -118,9 +118,8 @@
@implementation IPCController
-- (id) initWithHandle : (PrefsController *) thePrefsController
+- (id) init
{
- fPrefsController = thePrefsController;
struct sockaddr_un sun;
self = [super init];
@@ -150,10 +149,12 @@
0 > ipc_addmsg( _funcs, IPC_MSG_ADDONEFILE, msg_addnew ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_AUTOMAP, msg_setbool ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_AUTOSTART, msg_setbool ) ||
+ 0 > ipc_addmsg( _funcs, IPC_MSG_CRYPTO, msg_setstr ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_DIR, msg_setstr ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_DOWNLIMIT, msg_setint ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_GETAUTOMAP, msg_getbool ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_GETAUTOSTART, msg_getbool ) ||
+ 0 > ipc_addmsg( _funcs, IPC_MSG_GETCRYPTO, msg_getstr ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_GETDIR, msg_getstr ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_GETDOWNLIMIT, msg_getint ) ||
0 > ipc_addmsg( _funcs, IPC_MSG_GETINFO, msg_info ) ||
@@ -216,6 +217,11 @@
_delegate = newdelegate;
}
+- (void) setPrefsController: (id) thePrefsController
+{
+ fPrefsController = thePrefsController;
+}
+
@end
@implementation IPCController (Private)
@@ -786,7 +792,7 @@
[client sendrespInt:IPC_MSG_AUTOSTART tag:tag val:[fDefaults boolForKey:@"AutoStartDownload"]];
break;
case IPC_MSG_GETPEX:
-// we dont support this :(
+//warning we dont support this :(
[client sendrespEmpty: IPC_MSG_FAIL tag: tag];
break;
default:
@@ -821,6 +827,7 @@
void msg_getstr( enum ipc_msg msgid, benc_val_t * val, int64_t tag, void * arg )
{
IPCClient * client = arg;
+ NSString * cryptoValue;
fDefaults = [NSUserDefaults standardUserDefaults];
@@ -830,6 +837,19 @@
case IPC_MSG_GETDIR:
[client sendrespStr:IPC_MSG_DIR tag:tag val:[fDefaults stringForKey:@"DownloadFolder"]];
break;
+
+ case IPC_MSG_GETCRYPTO:
+ if ([fDefaults boolForKey: @"EncryptionPrefer"])
+ if ([fDefaults boolForKey: @"EncryptionRequire"])
+ cryptoValue = @"required";
+ else
+ cryptoValue = @"preferred";
+ else
+ cryptoValue = @"plaintext";
+
+ [client sendrespStr:IPC_MSG_CRYPTO tag:tag val:cryptoValue];
+ break;
+
default:
assert( 0 );
break;
@@ -860,7 +880,7 @@
[client sendrespEmpty:IPC_MSG_OK tag:tag];
break;
case IPC_MSG_PEX:
- //we dont support this :(
+//warning we dont support this :(
[client sendrespEmpty: IPC_MSG_FAIL tag: tag];
break;
default:
@@ -889,8 +909,8 @@
[fPrefsController applySpeedSettings: nil];
break;
case IPC_MSG_PORT:
-#warning show in preference window
[fPrefsController setPort:[NSNumber numberWithInt:val->val.i]];
+ [fPrefsController updatePortField];
break;
case IPC_MSG_UPLIMIT:
[fDefaults setInteger:val->val.i forKey:@"UploadLimit"];
@@ -924,6 +944,29 @@
[fDefaults setObject: @"Constant" forKey: @"DownloadChoice"]; //not sure about this line
[client sendrespEmpty: IPC_MSG_OK tag: tag];
break;
+
+ case IPC_MSG_CRYPTO:
+ if(!strcasecmp(val->val.s.s, "required"))
+ {
+ [fDefaults setBool:TRUE forKey: @"EncryptionPrefer"];
+ [fDefaults setBool:TRUE forKey: @"EncryptionRequire"];
+ }
+
+ else if(!strcasecmp(val->val.s.s, "preferred"))
+ {
+ [fDefaults setBool:TRUE forKey: @"EncryptionPrefer"];
+ [fDefaults setBool:FALSE forKey: @"EncryptionRequire"];
+ }
+
+ else if(!strcasecmp(val->val.s.s, "plaintext"))
+ {
+ [fDefaults setBool:FALSE forKey: @"EncryptionPrefer"];
+ [fDefaults setBool:FALSE forKey: @"EncryptionRequire"];
+ }
+
+ [client sendrespEmpty: IPC_MSG_OK tag: tag];
+ break;
+
default:
assert( 0 );
break;
Index: macosx/PrefsController.h
===================================================================
--- macosx/PrefsController.h (revision 4303)
+++ macosx/PrefsController.h (working copy)
@@ -61,6 +61,7 @@
- (id) initWithHandle: (tr_handle *) handle;
- (void) setUpdater: (SUUpdater *) updater;
+- (void) updatePortField;
- (void) setPort: (id) sender;
- (void) setNat: (id) sender;
- (void) updatePortStatus;
Index: macosx/PrefsController.m
===================================================================
--- macosx/PrefsController.m (revision 4303)
+++ macosx/PrefsController.m (working copy)
@@ -222,6 +222,12 @@
return [NSArray arrayWithObjects: TOOLBAR_GENERAL, TOOLBAR_TRANSFERS, TOOLBAR_BANDWIDTH, TOOLBAR_ADVANCED, nil];
}
+- (void) updatePortField
+{
+ //we need this because we dont have binds
+ [fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]];
+}
+
- (void) setPort: (id) sender
{
int port = [sender intValue];
Index: macosx/Controller.m
===================================================================
--- macosx/Controller.m (revision 4303)
+++ macosx/Controller.m (working copy)
@@ -207,8 +207,9 @@
fBadger = [[Badger alloc] initWithLib: fLib];
- fIPCController = [[IPCController alloc] initWithHandle: fPrefsController];
+ fIPCController = [[IPCController alloc] init];
[fIPCController setDelegate: self];
+ [fIPCController setPrefsController: fPrefsController];
fRemoteQuit = NO;
[GrowlApplicationBridge setGrowlDelegate: self];
Index: daemon/server.c
===================================================================
--- daemon/server.c (revision 4303)
+++ daemon/server.c (working copy)
@@ -638,7 +638,9 @@
switch( id )
{
case IPC_MSG_CRYPTO:
- if(!strcasecmp(val->val.s.s, "preferred"))
+ if(!strcasecmp(val->val.s.s, "plaintext"))
+ torrent_set_encryption(TR_PLAINTEXT_PREFERRED);
+ else if(!strcasecmp(val->val.s.s, "preferred"))
torrent_set_encryption(TR_ENCRYPTION_PREFERRED);
else if(!strcasecmp(val->val.s.s, "required"))
torrent_set_encryption(TR_ENCRYPTION_REQUIRED);
@@ -930,6 +932,9 @@
case IPC_MSG_GETCRYPTO:
switch(torrent_get_encryption())
{
+ case TR_PLAINTEXT_PREFERRED:
+ strval = "plaintext";
+ break;
case TR_ENCRYPTION_PREFERRED:
strval = "preferred";
break;
Index: doc/ipcproto.txt
===================================================================
--- doc/ipcproto.txt (revision 4303)
+++ doc/ipcproto.txt (working copy)
@@ -198,7 +198,7 @@
Example: 10:encryption8:required
"encryption", "required"
Details: Set the encryption mode for peer connections. Valid values
- are "required" and "preferred".
+ are "required", "preferred" and "plaintext".
Key: "failed"
Version: 2