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 | |
| 12 | @implementation PreferenceDelegate |
| 13 | |
| 14 | -(IBAction)showPreferencesPanel:(id)sender |
| 15 | { |
| 16 | [preferencesPanel setContentView:generalSettingsView]; |
| 17 | [preferencesPanel makeKeyAndOrderFront:sender]; |
| 18 | [preferencesPanel setLevel: NSStatusWindowLevel]; |
| 19 | } |
| 20 | |
| 21 | -(IBAction)openGeneralSettings:(id)sender |
| 22 | { |
| 23 | [preferencesPanel setContentView:generalSettingsView]; |
| 24 | } |
| 25 | |
| 26 | -(IBAction)openForwardingSettings:(id)sender |
| 27 | { |
| 28 | [preferencesPanel setContentView:forwardingSettingsView]; |
| 29 | } |
| 30 | |
| 31 | -(IBAction)openSecuritySettings:(id)sender |
| 32 | { |
| 33 | [preferencesPanel setContentView:securitySettingsView]; |
| 34 | } |
| 35 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 36 | -(IBAction)openTestbedSettings:(id)sender |
| 37 | { |
| 38 | [preferencesPanel setContentView:testbedSettingsView]; |
| 39 | } |
| 40 | |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 41 | -(IBAction)switchSoftwareUpdates:(id)sender |
| 42 | { |
| 43 | if ([(NSButton*)sender state] == NSOnState) |
| 44 | { |
| 45 | _allowSoftwareUpdates = true; |
| 46 | } |
| 47 | else |
| 48 | { |
| 49 | _allowSoftwareUpdates = false; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | -(IBAction)switchHubDiscovery:(id)sender |
| 54 | { |
| 55 | if ([(NSButton*)sender state] == NSOnState) |
| 56 | { |
| 57 | _enableHubDiscovery = true; |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | _enableHubDiscovery = false; |
| 62 | } |
| 63 | } |
| 64 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 65 | -(IBAction)restartDaemon:(id)sender |
| 66 | { |
| 67 | /*daemonStarted = false; |
| 68 | [sender setTitle:@"Start"]; |
| 69 | [connectionStatusText setStringValue:@"Disconnected"]; |
| 70 | |
| 71 | NSTask *task = [[NSTask alloc] init]; |
| 72 | [task setLaunchPath: NDND_STOP_COMMAND]; |
| 73 | [task launch]; |
| 74 | |
| 75 | NSBundle *bundle = [NSBundle bundleForClass:[self class]]; |
| 76 | NSString *path = [bundle pathForResource:@"FlatDisconnected" ofType:@"png"]; |
| 77 | menuIcon = [[NSImage alloc] initWithContentsOfFile:path]; |
| 78 | [statusItem setImage:menuIcon];*/ |
| 79 | } |
| 80 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 81 | -(IBAction)addFibEntry:(id)sender |
| 82 | { |
| 83 | [NSApp endSheet:prefixRegistrationSheet]; |
| 84 | [prefixRegistrationSheet orderOut:sender]; |
| 85 | |
| 86 | NSString *operationName = @"add"; |
| 87 | |
| 88 | NSString *prefixName = [namePrefixText stringValue]; |
| 89 | NSString *socketType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]]; |
| 90 | NSString *address = [endpointText stringValue]; |
| 91 | |
| 92 | NSArray *arguments = [NSArray arrayWithObjects: operationName, prefixName, socketType, address, nil]; |
| 93 | |
| 94 | NSTask *task = [[NSTask alloc] init]; |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame^] | 95 | [task setLaunchPath: @NDND_FIB_COMMAND]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 96 | [task setArguments: arguments]; |
| 97 | [task launch]; |
| 98 | } |
| 99 | |
| 100 | -(IBAction)removeFibEntry:(id)sender |
| 101 | { |
| 102 | |
| 103 | } |
| 104 | |
| 105 | - (IBAction) showFibEntrySheet:(id)sender |
| 106 | { |
| 107 | [NSApp beginSheet:prefixRegistrationSheet |
| 108 | modalForWindow:preferencesPanel |
| 109 | modalDelegate:self |
| 110 | didEndSelector:nil |
| 111 | contextInfo:nil]; |
| 112 | |
| 113 | [tunnelCombobox selectItemAtIndex:0]; |
| 114 | } |
| 115 | |
| 116 | -(IBAction)hideFibEntrySheet:(id)sender |
| 117 | { |
| 118 | [NSApp endSheet:prefixRegistrationSheet]; |
| 119 | [prefixRegistrationSheet orderOut:sender]; |
| 120 | } |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 121 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 122 | |
| 123 | -(IBAction)openRoutingStatusPage:(id)sender |
| 124 | { |
| 125 | NSURL *pageURL = [NSURL URLWithString:@"http://netlab.cs.memphis.edu/script/htm/status.htm"]; |
| 126 | |
| 127 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 128 | } |
| 129 | |
| 130 | -(IBAction)openTrafficMapPage:(id)sender |
| 131 | { |
| 132 | |
| 133 | NSURL *pageURL = [NSURL URLWithString:@"http://ndnmap.arl.wustl.edu"]; |
| 134 | |
| 135 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 136 | } |
| 137 | |
| 138 | |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 139 | @end |