Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * @copyright See LICENCE for copyright and license information. |
| 4 | * |
| 5 | * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 6 | * @author Ilya Moiseenko <iliamo@ucla.edu> |
| 7 | */ |
| 8 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame^] | 9 | #include "config.h" |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 10 | #import "preference-delegate.h" |
| 11 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame^] | 12 | #define NDND_FIB_COMMAND @ NDNX_ROOT "/bin/ndndc" |
| 13 | |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 14 | @implementation PreferenceDelegate |
| 15 | |
| 16 | -(IBAction)showPreferencesPanel:(id)sender |
| 17 | { |
| 18 | [preferencesPanel setContentView:generalSettingsView]; |
| 19 | [preferencesPanel makeKeyAndOrderFront:sender]; |
| 20 | [preferencesPanel setLevel: NSStatusWindowLevel]; |
| 21 | } |
| 22 | |
| 23 | -(IBAction)openGeneralSettings:(id)sender |
| 24 | { |
| 25 | [preferencesPanel setContentView:generalSettingsView]; |
| 26 | } |
| 27 | |
| 28 | -(IBAction)openForwardingSettings:(id)sender |
| 29 | { |
| 30 | [preferencesPanel setContentView:forwardingSettingsView]; |
| 31 | } |
| 32 | |
| 33 | -(IBAction)openSecuritySettings:(id)sender |
| 34 | { |
| 35 | [preferencesPanel setContentView:securitySettingsView]; |
| 36 | } |
| 37 | |
| 38 | -(IBAction)switchSoftwareUpdates:(id)sender |
| 39 | { |
| 40 | if ([(NSButton*)sender state] == NSOnState) |
| 41 | { |
| 42 | _allowSoftwareUpdates = true; |
| 43 | } |
| 44 | else |
| 45 | { |
| 46 | _allowSoftwareUpdates = false; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | -(IBAction)switchHubDiscovery:(id)sender |
| 51 | { |
| 52 | if ([(NSButton*)sender state] == NSOnState) |
| 53 | { |
| 54 | _enableHubDiscovery = true; |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | _enableHubDiscovery = false; |
| 59 | } |
| 60 | } |
| 61 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame^] | 62 | -(IBAction)addFibEntry:(id)sender |
| 63 | { |
| 64 | [NSApp endSheet:prefixRegistrationSheet]; |
| 65 | [prefixRegistrationSheet orderOut:sender]; |
| 66 | |
| 67 | NSString *operationName = @"add"; |
| 68 | |
| 69 | NSString *prefixName = [namePrefixText stringValue]; |
| 70 | NSString *socketType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]]; |
| 71 | NSString *address = [endpointText stringValue]; |
| 72 | |
| 73 | NSArray *arguments = [NSArray arrayWithObjects: operationName, prefixName, socketType, address, nil]; |
| 74 | |
| 75 | NSTask *task = [[NSTask alloc] init]; |
| 76 | [task setLaunchPath: NDND_FIB_COMMAND]; |
| 77 | [task setArguments: arguments]; |
| 78 | [task launch]; |
| 79 | } |
| 80 | |
| 81 | -(IBAction)removeFibEntry:(id)sender |
| 82 | { |
| 83 | |
| 84 | } |
| 85 | |
| 86 | - (IBAction) showFibEntrySheet:(id)sender |
| 87 | { |
| 88 | [NSApp beginSheet:prefixRegistrationSheet |
| 89 | modalForWindow:preferencesPanel |
| 90 | modalDelegate:self |
| 91 | didEndSelector:nil |
| 92 | contextInfo:nil]; |
| 93 | |
| 94 | [tunnelCombobox selectItemAtIndex:0]; |
| 95 | } |
| 96 | |
| 97 | -(IBAction)hideFibEntrySheet:(id)sender |
| 98 | { |
| 99 | [NSApp endSheet:prefixRegistrationSheet]; |
| 100 | [prefixRegistrationSheet orderOut:sender]; |
| 101 | } |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 102 | |
| 103 | @end |