Alexander Afanasyev | 14b0948 | 2013-10-11 18:24:45 +0200 | [diff] [blame^] | 1 | /* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 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]; |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 19 | |
| 20 | if(m_operationQueue == nil) |
| 21 | m_operationQueue = [[NSOperationQueue alloc] init]; |
| 22 | |
| 23 | tableController.m_tableView = fibTableView; |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | -(IBAction)openGeneralSettings:(id)sender |
| 27 | { |
| 28 | [preferencesPanel setContentView:generalSettingsView]; |
| 29 | } |
| 30 | |
| 31 | -(IBAction)openForwardingSettings:(id)sender |
| 32 | { |
| 33 | [preferencesPanel setContentView:forwardingSettingsView]; |
| 34 | } |
| 35 | |
| 36 | -(IBAction)openSecuritySettings:(id)sender |
| 37 | { |
| 38 | [preferencesPanel setContentView:securitySettingsView]; |
| 39 | } |
| 40 | |
| 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 | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 65 | -(void)updateFibStatus:(NSXMLDocument*)status; |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 66 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 67 | [tableController loadStatus:status]; |
| 68 | [fibTableView reloadData]; |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 71 | -(IBAction)addFibEntry:(id)sender |
| 72 | { |
| 73 | [NSApp endSheet:prefixRegistrationSheet]; |
| 74 | [prefixRegistrationSheet orderOut:sender]; |
| 75 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 76 | NSString *prefixName = [namePrefixText stringValue]; |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 77 | NSString *tunnelType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]]; |
| 78 | NSString *endpoint = [endpointText stringValue]; |
| 79 | |
| 80 | [m_operationQueue addOperationWithBlock:^{ |
| 81 | NSTask *task = [[NSTask alloc] init]; |
| 82 | [task setLaunchPath: @NDND_FIB_COMMAND]; |
| 83 | [task setArguments: [NSArray arrayWithObjects: @"add", prefixName, tunnelType, endpoint, nil]]; |
| 84 | [task launch]; |
| 85 | [task waitUntilExit]; |
| 86 | }]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 87 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | -(IBAction)removeFibEntry:(id)sender |
| 91 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 92 | NSInteger selectedRow = [fibTableView selectedRow]; |
| 93 | |
| 94 | if(selectedRow == -1) |
| 95 | return; |
| 96 | |
| 97 | NSString *faceID = [tableController getFaceByRowIndex:selectedRow]; |
| 98 | if (faceID == nil) |
| 99 | return; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 100 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 101 | NSString *prefix = [tableController getPrefixByRowIndex:selectedRow]; |
| 102 | if (prefix == nil) |
| 103 | return; |
| 104 | |
| 105 | [m_operationQueue addOperationWithBlock:^{ |
| 106 | NSTask *task = [[NSTask alloc] init]; |
| 107 | [task setLaunchPath: @NDND_FIB_COMMAND]; |
| 108 | [task setArguments: [NSArray arrayWithObjects: @"del", prefix, @"face", faceID, nil]]; |
| 109 | [task launch]; |
| 110 | [task waitUntilExit]; |
| 111 | }]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | - (IBAction) showFibEntrySheet:(id)sender |
| 115 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 116 | [NSApp beginSheet:prefixRegistrationSheet |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 117 | modalForWindow:preferencesPanel |
| 118 | modalDelegate:self |
| 119 | didEndSelector:nil |
| 120 | contextInfo:nil]; |
| 121 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 122 | [tunnelCombobox selectItemAtIndex:0]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | -(IBAction)hideFibEntrySheet:(id)sender |
| 126 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 127 | [NSApp endSheet:prefixRegistrationSheet]; |
| 128 | [prefixRegistrationSheet orderOut:sender]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 129 | } |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 130 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 131 | |
| 132 | -(IBAction)openRoutingStatusPage:(id)sender |
| 133 | { |
| 134 | NSURL *pageURL = [NSURL URLWithString:@"http://netlab.cs.memphis.edu/script/htm/status.htm"]; |
| 135 | |
| 136 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 137 | } |
| 138 | |
| 139 | -(IBAction)openTrafficMapPage:(id)sender |
| 140 | { |
| 141 | |
| 142 | NSURL *pageURL = [NSURL URLWithString:@"http://ndnmap.arl.wustl.edu"]; |
| 143 | |
| 144 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 145 | } |
| 146 | |
| 147 | |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 148 | @end |