Alexander Afanasyev | 14b0948 | 2013-10-11 18:24:45 +0200 | [diff] [blame] | 1 | /* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 2 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California, |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 5 | * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD |
| 6 | * authors and contributors. |
| 7 | * |
| 8 | * NFD Control Center is free software: you can redistribute it and/or modify it under the |
| 9 | * terms of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 14 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with NFD |
| 17 | * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * \author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
| 20 | * \author Ilya Moiseenko <http://ilyamoiseenko.com/> |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 23 | #include "config.hpp" |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 24 | #import "preference-delegate.h" |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 25 | #import "menu-delegate.h" |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 26 | |
| 27 | @implementation PreferenceDelegate |
| 28 | |
| 29 | -(IBAction)showPreferencesPanel:(id)sender |
| 30 | { |
| 31 | [preferencesPanel setContentView:generalSettingsView]; |
| 32 | [preferencesPanel makeKeyAndOrderFront:sender]; |
| 33 | [preferencesPanel setLevel: NSStatusWindowLevel]; |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 34 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 35 | tableController.m_tableView = fibTableView; |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | -(IBAction)openGeneralSettings:(id)sender |
| 39 | { |
| 40 | [preferencesPanel setContentView:generalSettingsView]; |
| 41 | } |
| 42 | |
| 43 | -(IBAction)openForwardingSettings:(id)sender |
| 44 | { |
| 45 | [preferencesPanel setContentView:forwardingSettingsView]; |
| 46 | } |
| 47 | |
| 48 | -(IBAction)openSecuritySettings:(id)sender |
| 49 | { |
| 50 | [preferencesPanel setContentView:securitySettingsView]; |
| 51 | } |
| 52 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 53 | -(void)updateFibStatus:(NSXMLDocument*)status; |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 54 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 55 | [tableController loadStatus:status]; |
| 56 | [fibTableView reloadData]; |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 59 | -(IBAction)addFibEntry:(id)sender |
| 60 | { |
| 61 | [NSApp endSheet:prefixRegistrationSheet]; |
| 62 | [prefixRegistrationSheet orderOut:sender]; |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 63 | |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 64 | NSString *prefixName = [namePrefixText stringValue]; |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 65 | NSString *tunnelType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]]; |
| 66 | NSString *endpoint = [endpointText stringValue]; |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 67 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 68 | // NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ |
| 69 | // NSTask *task = [[NSTask alloc] init]; |
| 70 | // [task setLaunchPath: @NDND_FIB_COMMAND]; |
| 71 | // [task setArguments: [NSArray arrayWithObjects: @"add", prefixName, tunnelType, endpoint, nil]]; |
| 72 | // [task launch]; |
| 73 | // [task waitUntilExit]; |
| 74 | // }]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 76 | // [(MenuDelegate*)[[NSApplication sharedApplication] delegate] updateStatusWithDependency:operation]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | -(IBAction)removeFibEntry:(id)sender |
| 80 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 81 | NSInteger selectedRow = [fibTableView selectedRow]; |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 82 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 83 | if(selectedRow == -1) |
| 84 | return; |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 85 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 86 | NSString *faceID = [tableController getFaceByRowIndex:selectedRow]; |
| 87 | if (faceID == nil) |
| 88 | return; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 89 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 90 | NSString *prefix = [tableController getPrefixByRowIndex:selectedRow]; |
| 91 | if (prefix == nil) |
| 92 | return; |
| 93 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 94 | // NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ |
| 95 | // NSTask *task = [[NSTask alloc] init]; |
| 96 | // [task setLaunchPath: @NDND_FIB_COMMAND]; |
| 97 | // [task setArguments: [NSArray arrayWithObjects: @"del", prefix, @"face", faceID, nil]]; |
| 98 | // [task launch]; |
| 99 | // [task waitUntilExit]; |
| 100 | // }]; |
Alexander Afanasyev | 4e1c7e9 | 2013-10-11 18:25:09 +0200 | [diff] [blame] | 101 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 102 | // [(MenuDelegate*)[[NSApplication sharedApplication] delegate] updateStatusWithDependency:operation]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | - (IBAction) showFibEntrySheet:(id)sender |
| 106 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 107 | [NSApp beginSheet:prefixRegistrationSheet |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 108 | modalForWindow:preferencesPanel |
| 109 | modalDelegate:self |
| 110 | didEndSelector:nil |
| 111 | contextInfo:nil]; |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 112 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 113 | [tunnelCombobox selectItemAtIndex:0]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | -(IBAction)hideFibEntrySheet:(id)sender |
| 117 | { |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 118 | [NSApp endSheet:prefixRegistrationSheet]; |
| 119 | [prefixRegistrationSheet orderOut:sender]; |
Ilya Moiseenko | 6819250 | 2013-09-30 14:27:48 -0700 | [diff] [blame] | 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 | |
Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 138 | -(IBAction)openCertificationPage:(id)sender |
| 139 | { |
| 140 | NSURL *pageURL = [NSURL URLWithString:@"http://ndncert.named-data.net"]; |
| 141 | |
| 142 | [[NSWorkspace sharedWorkspace] openURL: pageURL]; |
| 143 | } |
| 144 | |
Ilya Moiseenko | e7058e7 | 2013-10-02 15:56:45 -0700 | [diff] [blame] | 145 | |
Ilya Moiseenko | 1dc76da | 2013-09-30 11:53:36 -0700 | [diff] [blame] | 146 | @end |