blob: 113bf0bab164eb0c6d55278c4245a1644cb29318 [file] [log] [blame]
Alexander Afanasyev14b09482013-10-11 18:24:45 +02001/* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -07002/*
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 Moiseenko68192502013-09-30 14:27:48 -07009#include "config.h"
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070010#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 Moiseenkob4aca052013-10-06 15:10:19 -070019
20 if(m_operationQueue == nil)
21 m_operationQueue = [[NSOperationQueue alloc] init];
22
23 tableController.m_tableView = fibTableView;
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070024}
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 Moiseenkob4aca052013-10-06 15:10:19 -070065-(void)updateFibStatus:(NSXMLDocument*)status;
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070066{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070067 [tableController loadStatus:status];
68 [fibTableView reloadData];
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070069}
70
Ilya Moiseenko68192502013-09-30 14:27:48 -070071-(IBAction)addFibEntry:(id)sender
72{
73 [NSApp endSheet:prefixRegistrationSheet];
74 [prefixRegistrationSheet orderOut:sender];
75
Ilya Moiseenko68192502013-09-30 14:27:48 -070076 NSString *prefixName = [namePrefixText stringValue];
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070077 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 Moiseenko68192502013-09-30 14:27:48 -070087
Ilya Moiseenko68192502013-09-30 14:27:48 -070088}
89
90-(IBAction)removeFibEntry:(id)sender
91{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070092 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 Moiseenko68192502013-09-30 14:27:48 -0700100
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700101 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 Moiseenko68192502013-09-30 14:27:48 -0700112}
113
114- (IBAction) showFibEntrySheet:(id)sender
115{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700116 [NSApp beginSheet:prefixRegistrationSheet
Ilya Moiseenko68192502013-09-30 14:27:48 -0700117 modalForWindow:preferencesPanel
118 modalDelegate:self
119 didEndSelector:nil
120 contextInfo:nil];
121
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700122 [tunnelCombobox selectItemAtIndex:0];
Ilya Moiseenko68192502013-09-30 14:27:48 -0700123}
124
125-(IBAction)hideFibEntrySheet:(id)sender
126{
Ilya Moiseenkob4aca052013-10-06 15:10:19 -0700127 [NSApp endSheet:prefixRegistrationSheet];
128 [prefixRegistrationSheet orderOut:sender];
Ilya Moiseenko68192502013-09-30 14:27:48 -0700129}
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -0700130
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -0700131
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 Moiseenko1dc76da2013-09-30 11:53:36 -0700148@end