blob: 0753290dd56e7daf0dd5fb4dd040a9b6cf0f78dd [file] [log] [blame]
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
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 Moiseenko68192502013-09-30 14:27:48 -07009#include "config.h"
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070010#import "preference-delegate.h"
11
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070012#define NDND_START_COMMAND @ NDNX_ROOT "/bin/ndndstart"
13#define NDND_STOP_COMMAND @ NDNX_ROOT "/bin/ndndstop"
14#define NDND_STATUS_COMMAND @ NDNX_ROOT "/bin/ndndstatus"
Ilya Moiseenko68192502013-09-30 14:27:48 -070015#define NDND_FIB_COMMAND @ NDNX_ROOT "/bin/ndndc"
16
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070017@implementation PreferenceDelegate
18
19-(IBAction)showPreferencesPanel:(id)sender
20{
21 [preferencesPanel setContentView:generalSettingsView];
22 [preferencesPanel makeKeyAndOrderFront:sender];
23 [preferencesPanel setLevel: NSStatusWindowLevel];
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
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070041-(IBAction)openTestbedSettings:(id)sender
42{
43 [preferencesPanel setContentView:testbedSettingsView];
44}
45
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070046-(IBAction)switchSoftwareUpdates:(id)sender
47{
48 if ([(NSButton*)sender state] == NSOnState)
49 {
50 _allowSoftwareUpdates = true;
51 }
52 else
53 {
54 _allowSoftwareUpdates = false;
55 }
56}
57
58-(IBAction)switchHubDiscovery:(id)sender
59{
60 if ([(NSButton*)sender state] == NSOnState)
61 {
62 _enableHubDiscovery = true;
63 }
64 else
65 {
66 _enableHubDiscovery = false;
67 }
68}
69
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -070070-(IBAction)restartDaemon:(id)sender
71{
72 /*daemonStarted = false;
73 [sender setTitle:@"Start"];
74 [connectionStatusText setStringValue:@"Disconnected"];
75
76 NSTask *task = [[NSTask alloc] init];
77 [task setLaunchPath: NDND_STOP_COMMAND];
78 [task launch];
79
80 NSBundle *bundle = [NSBundle bundleForClass:[self class]];
81 NSString *path = [bundle pathForResource:@"FlatDisconnected" ofType:@"png"];
82 menuIcon = [[NSImage alloc] initWithContentsOfFile:path];
83 [statusItem setImage:menuIcon];*/
84}
85
Ilya Moiseenko68192502013-09-30 14:27:48 -070086-(IBAction)addFibEntry:(id)sender
87{
88 [NSApp endSheet:prefixRegistrationSheet];
89 [prefixRegistrationSheet orderOut:sender];
90
91 NSString *operationName = @"add";
92
93 NSString *prefixName = [namePrefixText stringValue];
94 NSString *socketType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]];
95 NSString *address = [endpointText stringValue];
96
97 NSArray *arguments = [NSArray arrayWithObjects: operationName, prefixName, socketType, address, nil];
98
99 NSTask *task = [[NSTask alloc] init];
100 [task setLaunchPath: NDND_FIB_COMMAND];
101 [task setArguments: arguments];
102 [task launch];
103}
104
105-(IBAction)removeFibEntry:(id)sender
106{
107
108}
109
110- (IBAction) showFibEntrySheet:(id)sender
111{
112 [NSApp beginSheet:prefixRegistrationSheet
113 modalForWindow:preferencesPanel
114 modalDelegate:self
115 didEndSelector:nil
116 contextInfo:nil];
117
118 [tunnelCombobox selectItemAtIndex:0];
119}
120
121-(IBAction)hideFibEntrySheet:(id)sender
122{
123 [NSApp endSheet:prefixRegistrationSheet];
124 [prefixRegistrationSheet orderOut:sender];
125}
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -0700126
Ilya Moiseenkoe7058e72013-10-02 15:56:45 -0700127
128-(IBAction)openRoutingStatusPage:(id)sender
129{
130 NSURL *pageURL = [NSURL URLWithString:@"http://netlab.cs.memphis.edu/script/htm/status.htm"];
131
132 [[NSWorkspace sharedWorkspace] openURL: pageURL];
133}
134
135-(IBAction)openTrafficMapPage:(id)sender
136{
137
138 NSURL *pageURL = [NSURL URLWithString:@"http://ndnmap.arl.wustl.edu"];
139
140 [[NSWorkspace sharedWorkspace] openURL: pageURL];
141}
142
143
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -0700144@end