-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServerStatusAppDelegate.m
More file actions
104 lines (84 loc) · 3.62 KB
/
ServerStatusAppDelegate.m
File metadata and controls
104 lines (84 loc) · 3.62 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
//
// ServerStatusAppDelegate.m
// ServerStatus
//
// Created by Florian Mutter on 11.05.10.
// Copyright 2010 skweez.net. All rights reserved.
//
#import "ServerStatusAppDelegate.h"
#import "ServerListController.h"
#import "NetworkMonitor.h"
#import "AutostartManager.h"
#import "GeneralPreferencesViewController.h"
#import "ServerPreferencesViewController.h"
#import "MASPreferencesWindowController.h"
@implementation ServerStatusAppDelegate
@synthesize serverListController, statusItemController, suupdater;
#pragma mark -
#pragma mark First Launch
- (void)firstLaunch {
DLog(@"First launch of ServerStatus");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![[AutostartManager sharedAutostartManager] isStartingAtLogin]) {
NSInteger ret = NSRunAlertPanel(@"Start ServerStatus automatically when you log in?",
@"To allow ServerStatus to check your servers automatically, it should be started when you login.",
@"Yes", @"No", NULL);
switch (ret){
case NSAlertDefaultReturn:
[[AutostartManager sharedAutostartManager] startAtLogin:YES];
break;
default:
break;
}
}
[defaults setBool:YES forKey:@"hasStartedBefore"];
[defaults synchronize];
}
#pragma mark -
#pragma mark General functions
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
/* Start network monitoring */
[[NetworkMonitor sharedNetworkMonitor] monitorNetwork];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"hasStartedBefore"]) {
[self firstLaunch];
}
}
- (void)applicationWillTerminate:(NSNotification *)notification {
/* save serverList in user preferences */
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.serverListController.serverList];
[defaults setObject:data forKey:@"serverList"];
[defaults synchronize];
}
- (void)awakeFromNib {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
/* Just enable automatic updates and don't ask the user about it */
[NSNumber numberWithBool:YES], @"SUEnableAutomaticChecks",
nil];
[defaults registerDefaults:appDefaults];
}
#pragma mark PreferenceWindowController
- (NSWindowController *)preferencesWindowController
{
if (_preferencesWindowController == nil)
{
GeneralPreferencesViewController *generalPreferencesViewController = [[GeneralPreferencesViewController alloc] init];
ServerPreferencesViewController *serverPreferencesViewController = [[ServerPreferencesViewController alloc] init];
serverPreferencesViewController.serverListController = self.serverListController;
NSArray *controllers = [[NSArray alloc] initWithObjects:serverPreferencesViewController, generalPreferencesViewController, nil];
[generalPreferencesViewController release];
[serverPreferencesViewController release];
NSString *title = NSLocalizedString(@"Preferences", @"Common title for Preferences window");
_preferencesWindowController = [[MASPreferencesWindowController alloc] initWithViewControllers:controllers title:title];
[[_preferencesWindowController.window standardWindowButton:NSWindowZoomButton] setEnabled:NO];
_preferencesWindowController.window.styleMask = _preferencesWindowController.window.styleMask^NSResizableWindowMask;
[controllers release];
}
return _preferencesWindowController;
}
- (IBAction)openPreferences:(id)sender {
[NSApp activateIgnoringOtherApps:YES];
[self.preferencesWindowController showWindow:nil];
}
@end