forked from kwerle/ssh-tunnel-manager
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SSHTunnelApp.m
executable file
·74 lines (65 loc) · 2.19 KB
/
SSHTunnelApp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#import "SSHTunnelApp.h"
#import "SSHTunnel.h"
#import "passWindowController.h"
@implementation SSHTunnelApp
- (NSMutableArray*)tunnels
{
return [[ SSHTunnel tunnelsFromArray: [ [ NSUserDefaults standardUserDefaults ] objectForKey: @"tunnels" ]] mutableCopy ];
}
- (id)authenticate:(NSScriptCommand *)command {
NSDictionary *args = [command evaluatedArguments];
NSString *givenQuery = [ args objectForKey:@"query"];
NSString *tunnelName = [ args objectForKey:@"tunnelName"];
NSString *fifo = [ args objectForKey:@"fifo"];
//NSString *result = @"";
SSHTunnel *tunnel;
NSEnumerator *e;
passWindowController *wc;
NSWindow *window;
// int RC;
e = [ tunnels objectEnumerator ];
while (tunnel = [ e nextObject ])
{
if ([[ tunnel valueForKey: @"connName" ] isEqual: tunnelName ])
break;
}
if ([ givenQuery rangeOfString: @" (yes/no)? " ].location != NSNotFound )
{
wc = [[ NSWindowController alloc ] initWithWindowNibName: @"ynQuery" ];
window = [wc window];
[[ wc window ] center ];
[[ wc window ] setValue: fifo forKey: @"fifo" ];
[[ wc window ] setValue: tunnel forKey: @"tunnel" ];
[[ wc window ] setTitle: [ tunnel valueForKey: @"connName" ]];
[(passWindowController*)[ wc window ] setACaption: givenQuery ];
[[ wc window ] makeKeyAndOrderFront: self ];
}
else
{
wc = [[ passWindowController alloc ] initWithWindowNibName: @"passQuery"];
window = [wc window];
[wc setFifo: fifo];
[wc setTunnel: tunnel];
//[window setTitle: [ tunnel connName]];
[wc setACaption: givenQuery ];
[window makeKeyAndOrderFront: self ];
}
return @"OK";
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
return NSTerminateNow;
}
-(id)handleQuitScriptCommand:(NSScriptCommand *)command {
[ NSApp terminate: self ];
return self;
}
- (void)orderFrontStandardAboutPanel:(id)sender
{
[ self orderFrontStandardAboutPanelWithOptions: [ NSDictionary dictionaryWithObjectsAndKeys:
[ NSString stringWithFormat: @"%X",
[[[ NSBundle mainBundle ] objectForInfoDictionaryKey: @"CFBundleVersion" ] intValue]
]
,@"Version", nil ]];
}
@end