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" |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 11 | #import "menu-delegate.h" |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 12 | |
| 13 | @implementation PreferenceDelegate |
| 14 | |
| 15 | -(IBAction)showPreferencesPanel:(id)sender |
| 16 | { |
| 17 | [preferencesPanel setContentView:generalSettingsView]; |
| 18 | [preferencesPanel makeKeyAndOrderFront:sender]; |
| 19 | [preferencesPanel setLevel: NSStatusWindowLevel]; |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 20 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 21 | tableController.m_tableView = fibTableView; |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | -(IBAction)openGeneralSettings:(id)sender |
| 25 | { |
| 26 | [preferencesPanel setContentView:generalSettingsView]; |
| 27 | } |
| 28 | |
| 29 | -(IBAction)openForwardingSettings:(id)sender |
| 30 | { |
| 31 | [preferencesPanel setContentView:forwardingSettingsView]; |
| 32 | } |
| 33 | |
| 34 | -(IBAction)openSecuritySettings:(id)sender |
| 35 | { |
| 36 | [preferencesPanel setContentView:securitySettingsView]; |
| 37 | } |
| 38 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 39 | -(void)updateFibStatus:(NSXMLDocument*)status; |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 40 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 41 | [tableController loadStatus:status]; |
| 42 | [fibTableView reloadData]; |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 45 | -(IBAction)addFibEntry:(id)sender |
| 46 | { |
| 47 | [NSApp endSheet:prefixRegistrationSheet]; |
| 48 | [prefixRegistrationSheet orderOut:sender]; |
| 49 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 50 | NSString *prefixName = [namePrefixText stringValue]; |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 51 | NSString *tunnelType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]]; |
| 52 | NSString *endpoint = [endpointText stringValue]; |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 53 | |
| 54 | NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 55 | NSTask *task = [[NSTask alloc] init]; |
| 56 | [task setLaunchPath: @NDND_FIB_COMMAND]; |
| 57 | [task setArguments: [NSArray arrayWithObjects: @"add", prefixName, tunnelType, endpoint, nil]]; |
| 58 | [task launch]; |
| 59 | [task waitUntilExit]; |
| 60 | }]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 61 | |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 62 | [(MenuDelegate*)[[NSApplication sharedApplication] delegate] updateStatusWithDependency:operation]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | -(IBAction)removeFibEntry:(id)sender |
| 66 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 67 | NSInteger selectedRow = [fibTableView selectedRow]; |
| 68 | |
| 69 | if(selectedRow == -1) |
| 70 | return; |
| 71 | |
| 72 | NSString *faceID = [tableController getFaceByRowIndex:selectedRow]; |
| 73 | if (faceID == nil) |
| 74 | return; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 75 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 76 | NSString *prefix = [tableController getPrefixByRowIndex:selectedRow]; |
| 77 | if (prefix == nil) |
| 78 | return; |
| 79 | |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 80 | NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 81 | NSTask *task = [[NSTask alloc] init]; |
| 82 | [task setLaunchPath: @NDND_FIB_COMMAND]; |
| 83 | [task setArguments: [NSArray arrayWithObjects: @"del", prefix, @"face", faceID, nil]]; |
| 84 | [task launch]; |
| 85 | [task waitUntilExit]; |
| 86 | }]; |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 87 | |
| 88 | [(MenuDelegate*)[[NSApplication sharedApplication] delegate] updateStatusWithDependency:operation]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | - (IBAction) showFibEntrySheet:(id)sender |
| 92 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 93 | [NSApp beginSheet:prefixRegistrationSheet |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 94 | modalForWindow:preferencesPanel |
| 95 | modalDelegate:self |
| 96 | didEndSelector:nil |
| 97 | contextInfo:nil]; |
| 98 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 99 | [tunnelCombobox selectItemAtIndex:0]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | -(IBAction)hideFibEntrySheet:(id)sender |
| 103 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 104 | [NSApp endSheet:prefixRegistrationSheet]; |
| 105 | [prefixRegistrationSheet orderOut:sender]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 106 | } |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 107 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 108 | |
| 109 | -(IBAction)openRoutingStatusPage:(id)sender |
| 110 | { |
| 111 | NSURL *pageURL = [NSURL URLWithString:@"http://netlab.cs.memphis.edu/script/htm/status.htm"]; |
| 112 | |
| 113 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 114 | } |
| 115 | |
| 116 | -(IBAction)openTrafficMapPage:(id)sender |
| 117 | { |
| 118 | |
| 119 | NSURL *pageURL = [NSURL URLWithString:@"http://ndnmap.arl.wustl.edu"]; |
| 120 | |
| 121 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 122 | } |
| 123 | |
Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 124 | -(IBAction)openCertificationPage:(id)sender |
| 125 | { |
| 126 | NSURL *pageURL = [NSURL URLWithString:@"http://ndncert.named-data.net"]; |
| 127 | |
| 128 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 129 | } |
| 130 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 131 | |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 132 | @end |