aboutsummaryrefslogtreecommitdiff
path: root/VKPC/AppDelegate.m
diff options
context:
space:
mode:
Diffstat (limited to 'VKPC/AppDelegate.m')
-rw-r--r--VKPC/AppDelegate.m76
1 files changed, 76 insertions, 0 deletions
diff --git a/VKPC/AppDelegate.m b/VKPC/AppDelegate.m
new file mode 100644
index 0000000..1ec88ff
--- /dev/null
+++ b/VKPC/AppDelegate.m
@@ -0,0 +1,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