mirror of
https://github.com/tappollo/WWDC.git
synced 2026-01-12 22:45:32 +08:00
Automatically terminating older versions on launch when possible
This commit is contained in:
13
ThrowBack/TBProphylaxis.h
Normal file
13
ThrowBack/TBProphylaxis.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TBProphylaxis.h
|
||||
// WWDC
|
||||
//
|
||||
// Created by Guilherme Rambo on 14/05/17.
|
||||
// Copyright © 2017 Guilherme Rambo. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface TBProphylaxis : NSObject
|
||||
|
||||
@end
|
||||
43
ThrowBack/TBProphylaxis.m
Normal file
43
ThrowBack/TBProphylaxis.m
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// TBProphylaxis.m
|
||||
// WWDC
|
||||
//
|
||||
// Created by Guilherme Rambo on 14/05/17.
|
||||
// Copyright © 2017 Guilherme Rambo. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TBProphylaxis.h"
|
||||
|
||||
@import Cocoa;
|
||||
|
||||
@implementation TBProphylaxis
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
NSArray <NSRunningApplication *> *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"br.com.guilhermerambo.WWDC"];
|
||||
|
||||
BOOL shouldQuit = NO;
|
||||
|
||||
for (NSRunningApplication *app in apps) {
|
||||
NSBundle *bundle = [NSBundle bundleWithURL:app.bundleURL];
|
||||
NSString *shortVersion = bundle.infoDictionary[@"CFBundleShortVersionString"];
|
||||
double shortVersionNumber = [shortVersion doubleValue];
|
||||
|
||||
if (shortVersionNumber < 5) {
|
||||
if (![app forceTerminate]) {
|
||||
shouldQuit = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldQuit) {
|
||||
NSAlert *alert = [NSAlert new];
|
||||
alert.messageText = @"Older version running";
|
||||
alert.informativeText = @"There's an older version of WWDC for macOS running. Version 5 can't work with older versions. Please quit the other version and launch Version 5 again.";
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert runModal];
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -118,6 +118,8 @@
|
||||
DDB3529C1EC8AB5D00254815 /* WWDCLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB3529B1EC8AB5D00254815 /* WWDCLayer.swift */; };
|
||||
DDB3529E1EC8D8CD00254815 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB3529D1EC8D8CD00254815 /* main.m */; };
|
||||
DDB352A01EC9088000254815 /* WWDCTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB3529F1EC9088000254815 /* WWDCTableView.swift */; };
|
||||
DDB352A51EC90ACA00254815 /* TBProphylaxis.h in Headers */ = {isa = PBXBuildFile; fileRef = DDB352A31EC90ACA00254815 /* TBProphylaxis.h */; };
|
||||
DDB352A61EC90ACA00254815 /* TBProphylaxis.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB352A41EC90ACA00254815 /* TBProphylaxis.m */; };
|
||||
DDCE7ECD1EA7A0F800C7A3CA /* MainWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE7ECC1EA7A0F800C7A3CA /* MainWindowController.swift */; };
|
||||
DDCE7ED21EA7A1D300C7A3CA /* WWDCAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = DDCE7ED11EA7A1D300C7A3CA /* WWDCAppearance.m */; };
|
||||
DDCE7ED91EA7A86600C7A3CA /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE7ED81EA7A86600C7A3CA /* AppCoordinator.swift */; };
|
||||
@@ -353,6 +355,8 @@
|
||||
DDB3529B1EC8AB5D00254815 /* WWDCLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WWDCLayer.swift; sourceTree = "<group>"; };
|
||||
DDB3529D1EC8D8CD00254815 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
DDB3529F1EC9088000254815 /* WWDCTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WWDCTableView.swift; sourceTree = "<group>"; };
|
||||
DDB352A31EC90ACA00254815 /* TBProphylaxis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TBProphylaxis.h; sourceTree = "<group>"; };
|
||||
DDB352A41EC90ACA00254815 /* TBProphylaxis.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TBProphylaxis.m; sourceTree = "<group>"; };
|
||||
DDBFA16A1EB525F2004AE10F /* PlayerUI.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PlayerUI.xcodeproj; path = PlayerUI/PlayerUI.xcodeproj; sourceTree = "<group>"; };
|
||||
DDCE7ECC1EA7A0F800C7A3CA /* MainWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowController.swift; sourceTree = "<group>"; };
|
||||
DDCE7ECF1EA7A1D300C7A3CA /* WWDC-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WWDC-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
@@ -853,6 +857,8 @@
|
||||
children = (
|
||||
DDDAA3F11EC7653300DF9D02 /* Info.plist */,
|
||||
DDDAA3F01EC7653300DF9D02 /* ThrowBack.h */,
|
||||
DDB352A31EC90ACA00254815 /* TBProphylaxis.h */,
|
||||
DDB352A41EC90ACA00254815 /* TBProphylaxis.m */,
|
||||
DDDAA4001EC768A900DF9D02 /* Migration */,
|
||||
);
|
||||
path = ThrowBack;
|
||||
@@ -936,6 +942,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DDB352A51EC90ACA00254815 /* TBProphylaxis.h in Headers */,
|
||||
DDDAA3F21EC7653300DF9D02 /* ThrowBack.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1285,6 +1292,7 @@
|
||||
DDDAA4071EC76D9300DF9D02 /* TBPreferences.swift in Sources */,
|
||||
DDDAA40A1EC775B500DF9D02 /* TBSession.swift in Sources */,
|
||||
DDDAA4021EC768C500DF9D02 /* TBUserDataMigrator.swift in Sources */,
|
||||
DDB352A61EC90ACA00254815 /* TBProphylaxis.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user