blob: 96309ccb381ad0a39e455e96b5d6e1f74b31e7bd [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 Moiseenko68192502013-09-30 14:27:48 -070012#define NDND_FIB_COMMAND @ NDNX_ROOT "/bin/ndndc"
13
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -070014@implementation PreferenceDelegate
15
16-(IBAction)showPreferencesPanel:(id)sender
17{
18 [preferencesPanel setContentView:generalSettingsView];
19 [preferencesPanel makeKeyAndOrderFront:sender];
20 [preferencesPanel setLevel: NSStatusWindowLevel];
21}
22
23-(IBAction)openGeneralSettings:(id)sender
24{
25 [preferencesPanel setContentView:generalSettingsView];
26}
27
28-(IBAction)openForwardingSettings:(id)sender
29{
30 [preferencesPanel setContentView:forwardingSettingsView];
31}
32
33-(IBAction)openSecuritySettings:(id)sender
34{
35 [preferencesPanel setContentView:securitySettingsView];
36}
37
38-(IBAction)switchSoftwareUpdates:(id)sender
39{
40 if ([(NSButton*)sender state] == NSOnState)
41 {
42 _allowSoftwareUpdates = true;
43 }
44 else
45 {
46 _allowSoftwareUpdates = false;
47 }
48}
49
50-(IBAction)switchHubDiscovery:(id)sender
51{
52 if ([(NSButton*)sender state] == NSOnState)
53 {
54 _enableHubDiscovery = true;
55 }
56 else
57 {
58 _enableHubDiscovery = false;
59 }
60}
61
Ilya Moiseenko68192502013-09-30 14:27:48 -070062-(IBAction)addFibEntry:(id)sender
63{
64 [NSApp endSheet:prefixRegistrationSheet];
65 [prefixRegistrationSheet orderOut:sender];
66
67 NSString *operationName = @"add";
68
69 NSString *prefixName = [namePrefixText stringValue];
70 NSString *socketType = [tunnelCombobox itemObjectValueAtIndex:[tunnelCombobox indexOfSelectedItem]];
71 NSString *address = [endpointText stringValue];
72
73 NSArray *arguments = [NSArray arrayWithObjects: operationName, prefixName, socketType, address, nil];
74
75 NSTask *task = [[NSTask alloc] init];
76 [task setLaunchPath: NDND_FIB_COMMAND];
77 [task setArguments: arguments];
78 [task launch];
79}
80
81-(IBAction)removeFibEntry:(id)sender
82{
83
84}
85
86- (IBAction) showFibEntrySheet:(id)sender
87{
88 [NSApp beginSheet:prefixRegistrationSheet
89 modalForWindow:preferencesPanel
90 modalDelegate:self
91 didEndSelector:nil
92 contextInfo:nil];
93
94 [tunnelCombobox selectItemAtIndex:0];
95}
96
97-(IBAction)hideFibEntrySheet:(id)sender
98{
99 [NSApp endSheet:prefixRegistrationSheet];
100 [prefixRegistrationSheet orderOut:sender];
101}
Ilya Moiseenko1dc76da2013-09-30 11:53:36 -0700102
103@end