blob: 1ec88ff346a376e4dc359d413b45b8157117632c (
plain)
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
|
//
// AppDelegate.m
// VKPC
//
// Created by Eugene on 11/26/13.
// Copyright (c) 2013-2014 Eugene Z. All rights reserved.
//
#import "AppDelegate.h"
#import "Server.h"
#import "CatchMediaButtons.h"
#import "Controller.h"
//#import "HostsHack.h"
#import "Statistics.h"
#import "PopoverController.h"
#import "Popover.h"
static AppDelegate *shared;
@implementation AppDelegate
+ (AppDelegate *)shared {
return shared;
}
- (void)awakeFromNib {
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
shared = self;
if (IsAnotherProcessRunning()) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Error"];
[alert setInformativeText:@"Another VKPC process is already running."];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
[[NSApplication sharedApplication] terminate:nil];
return;
}
// Init UI stuff
[Popover shared];
[PopoverController shared];
// Preferences
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
VKPCPreferencesShowNotifications: [NSNumber numberWithBool:YES],
VKPCPreferencesInvertPlaylistIcons: [NSNumber numberWithBool:YES],
VKPCPreferencesCatchMediaButtons: [NSNumber numberWithBool:YES],
VKPCPreferencesBrowser: [NSNumber numberWithInt:0],
VKPCPreferencesStatisticReportedTimestamp: [NSNumber numberWithInt:0],
VKPCPreferencesUUID: @"",
VKPCPreferencesUseExtensionMode: [NSNumber numberWithBool:NO],
}];
VKPCInitUUID();
// Start catching (or not catching) media buttons
[CatchMediaButtons initialize];
// Usage reporting
[Statistics initialize];
[[PopoverController shared] setState:PopoverStatePlaylistNotLoaded];
// Start server in a background thread
[Server start];
// Controller
[Controller initialize];
}
@end
|