Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: eecdc20db3
Fetching contributors…

Cannot retrieve contributors at this time

file 107 lines (85 sloc) 2.405 kb
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

#import "HighwireAppDelegate.h"
#import "HighwireAPI.h"

@implementation HighwireAppDelegate

- (void)awakeFromNib
{
// First run stuff...
if(![[NSUserDefaults standardUserDefaults] valueForKey:@"firstRun"])
{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstRun"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"useRandomPort"];
[[NSUserDefaults standardUserDefaults] setValue:@"64000" forKey:@"sharePort"];
}

loginController = [[LoginWindowController alloc] initWithWindowNibName:@"LoginWindow"];
[loginController showWindow:self];
}

- (void)showMainWindow
{
mainController = [[MainWindowController alloc] initWithWindowNibName:@"MainWindow"];
[mainController showWindow:self];
}

- (IBAction)showConnectionsWindow:(id)sender
{
NSWindow *w = [mainController window];

if(w)
{
NSRect newPosition = [w frame];
newPosition.size = [windowConnections frame].size;
newPosition.origin.x = [w frame].origin.x + [w frame].size.width + 20;
newPosition.origin.y = [w frame].origin.y + ([w frame].size.height - newPosition.size.height);
[windowConnections setFrame:newPosition display:YES];
}

[windowConnections makeKeyAndOrderFront:self];
}

- (IBAction)reopenMainWindow:(id)sender
{
if(mainController)
[mainController showWindow:self];
else
[loginController showWindow:self];
}

- (BOOL)applicationOpenUntitledFile:(NSApplication *)theApplication
{
[self reopenMainWindow:self];
return NO;
}

- (IBAction)manualConnect:(id)sender
{
if(mainController)
{
[mainController manualConnect:self];
}
}

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
if(mainController)
{
[mainController showShutdownSheet];

[[TCMPortMapper sharedInstance] stopBlocking];

HighwireAPI *api = [[HighwireAPI alloc] init];
api.delegate = self;
[api removeThisMachine];

return NSTerminateLater;
}

return NSTerminateNow;
}

#pragma mark -
#pragma mark Misc
#pragma mark -

- (IBAction)signOut:(id)sender
{
[[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"hwEmail"];
[[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"hwPassword"];

if(mainController)
{
[[mainController window] performClose:self];
mainController = nil;
}

[loginController showWindow:self];
}

- (IBAction)toggleStatusItem:(id)sender
{
if(mainController)
[mainController toggleStatusItem:sender];
}

@end
Something went wrong with that request. Please try again.