blob: f164c10199f989be3890962ca2c1f7745b4305d9 [file] [log] [blame]
Alexander Afanasyev14b09482013-10-11 18:24:45 +02001/* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyevb6392e32014-05-12 23:43:50 -07002/**
3 * Copyright (c) 2013-2014, Regents of the University of California,
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -07004 *
Alexander Afanasyevb6392e32014-05-12 23:43:50 -07005 * 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 Moiseenko1dc76da2013-09-30 11:53:36 -070021 */
22
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070023#include "config.hpp"
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070024#import "preference-delegate.h"
Alexander Afanasyev4e1c7e92013-10-11 18:25:09 +020025#import "menu-delegate.h"
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070026
27@implementation PreferenceDelegate
28
29-(IBAction)showPreferencesPanel:(id)sender
30{
31 [preferencesPanel setContentView:generalSettingsView];
32 [preferencesPanel makeKeyAndOrderFront:sender];
33 [preferencesPanel setLevel: NSStatusWindowLevel];
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070034
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070035 tableController.m_tableView = fibTableView;
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070036}
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 Moiseenkob4aca052013-10-06 15:10:19 -070053-(void)updateFibStatus:(NSXMLDocument*)status;
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070054{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070055 [tableController loadStatus:status];
56 [fibTableView reloadData];
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070057}
58
Ilya Moiseenko68192502013-09-30 14:27:48 -070059-(IBAction)addFibEntry:(id)sender
60{
61 [NSApp endSheet:prefixRegistrationSheet];
62 [prefixRegistrationSheet orderOut:sender];
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070063
Ilya Moiseenko68192502013-09-30 14:27:48 -070064 NSString *prefixName = [namePrefixText stringValue];
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070065 NSString *tunnelType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]];
66 NSString *endpoint = [endpointText stringValue];
Alexander Afanasyev4e1c7e92013-10-11 18:25:09 +020067
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070068 // 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 Moiseenko68192502013-09-30 14:27:48 -070075
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070076 // [(MenuDelegate*)[[NSApplication sharedApplication] delegate] updateStatusWithDependency:operation];
Ilya Moiseenko68192502013-09-30 14:27:48 -070077}
78
79-(IBAction)removeFibEntry:(id)sender
80{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070081 NSInteger selectedRow = [fibTableView selectedRow];
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070082
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070083 if(selectedRow == -1)
84 return;
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070085
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070086 NSString *faceID = [tableController getFaceByRowIndex:selectedRow];
87 if (faceID == nil)
88 return;
Ilya Moiseenko68192502013-09-30 14:27:48 -070089
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070090 NSString *prefix = [tableController getPrefixByRowIndex:selectedRow];
91 if (prefix == nil)
92 return;
93
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070094 // 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 Afanasyev4e1c7e92013-10-11 18:25:09 +0200101
Alexander Afanasyevb6392e32014-05-12 23:43:50 -0700102 // [(MenuDelegate*)[[NSApplication sharedApplication] delegate] updateStatusWithDependency:operation];
Ilya Moiseenko68192502013-09-30 14:27:48 -0700103}
104
105- (IBAction) showFibEntrySheet:(id)sender
106{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700107 [NSApp beginSheet:prefixRegistrationSheet
Ilya Moiseenko68192502013-09-30 14:27:48 -0700108 modalForWindow:preferencesPanel
109 modalDelegate:self
110 didEndSelector:nil
111 contextInfo:nil];
Alexander Afanasyevb6392e32014-05-12 23:43:50 -0700112
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700113 [tunnelCombobox selectItemAtIndex:0];
Ilya Moiseenko68192502013-09-30 14:27:48 -0700114}
115
116-(IBAction)hideFibEntrySheet:(id)sender
117{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700118 [NSApp endSheet:prefixRegistrationSheet];
119 [prefixRegistrationSheet orderOut:sender];
Ilya Moiseenko68192502013-09-30 14:27:48 -0700120}
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -0700121
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -0700122
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 Moiseenko0c9ab7c2013-10-29 15:08:23 -0700138-(IBAction)openCertificationPage:(id)sender
139{
140 NSURL *pageURL = [NSURL URLWithString:@"http://ndncert.named-data.net"];
141
142 [[NSWorkspace sharedWorkspace] openURL: pageURL];
143}
144
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -0700145
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -0700146@end