mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 22:59:58 +02:00
auto-updater
This commit is contained in:
parent
9c6c4a264d
commit
7ed13a2ba2
10 changed files with 214 additions and 23 deletions
|
@ -20,6 +20,8 @@ set(src_files
|
||||||
src/DownloadInterface.m
|
src/DownloadInterface.m
|
||||||
src/DownloadDomainContent.h
|
src/DownloadDomainContent.h
|
||||||
src/DownloadDomainContent.m
|
src/DownloadDomainContent.m
|
||||||
|
src/DownloadLauncher.h
|
||||||
|
src/DownloadLauncher.m
|
||||||
src/DownloadScripts.h
|
src/DownloadScripts.h
|
||||||
src/DownloadScripts.m
|
src/DownloadScripts.m
|
||||||
src/CredentialsRequest.h
|
src/CredentialsRequest.h
|
||||||
|
@ -34,6 +36,8 @@ set(src_files
|
||||||
src/Interface.m
|
src/Interface.m
|
||||||
src/ErrorViewController.h
|
src/ErrorViewController.h
|
||||||
src/ErrorViewController.m
|
src/ErrorViewController.m
|
||||||
|
src/LauncherCommandlineArgs.h
|
||||||
|
src/LauncherCommandlineArgs.m
|
||||||
src/Settings.h
|
src/Settings.h
|
||||||
src/Settings.m
|
src/Settings.m
|
||||||
src/LaunchInterface.h
|
src/LaunchInterface.h
|
||||||
|
@ -106,8 +110,12 @@ add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
${CMAKE_SOURCE_DIR}/images "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${APP_NAME}.app/Contents/Resources/")
|
${CMAKE_SOURCE_DIR}/images "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${APP_NAME}.app/Contents/Resources/")
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
|
COMMAND updater
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/updater" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${APP_NAME}.app/Contents/Resources/")
|
||||||
|
|
||||||
install(
|
install(
|
||||||
TARGETS HQLauncher updater
|
TARGETS HQLauncher
|
||||||
BUNDLE DESTINATION "."
|
BUNDLE DESTINATION "."
|
||||||
COMPONENT applications
|
COMPONENT applications
|
||||||
)
|
)
|
||||||
|
|
8
launchers/darwin/src/DownloadLauncher.h
Normal file
8
launchers/darwin/src/DownloadLauncher.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface DownloadLauncher : NSObject<NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLDownloadDelegate> {
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) downloadLauncher:(NSString*) launcherUrl;
|
||||||
|
|
||||||
|
@end
|
74
launchers/darwin/src/DownloadLauncher.m
Normal file
74
launchers/darwin/src/DownloadLauncher.m
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
#import "DownloadLauncher.h"
|
||||||
|
#import "Launcher.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation DownloadLauncher
|
||||||
|
|
||||||
|
- (void) downloadLauncher:(NSString *)launcherUrl
|
||||||
|
{
|
||||||
|
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:launcherUrl]
|
||||||
|
cachePolicy:NSURLRequestUseProtocolCachePolicy
|
||||||
|
timeoutInterval:60.0];
|
||||||
|
|
||||||
|
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
|
||||||
|
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]];
|
||||||
|
NSURLSessionDownloadTask *downloadTask = [defaultSession downloadTaskWithRequest:request];
|
||||||
|
[downloadTask resume];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
|
||||||
|
CGFloat prog = (float)totalBytesWritten/totalBytesExpectedToWrite;
|
||||||
|
NSLog(@"Launcher downloaded %f", (100.0*prog));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {
|
||||||
|
// unused in this example
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location {
|
||||||
|
NSLog(@"Did finish downloading to url");
|
||||||
|
NSError *error = nil;
|
||||||
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
|
NSString *destinationFileName = downloadTask.originalRequest.URL.lastPathComponent;
|
||||||
|
NSString* finalFilePath = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent:destinationFileName];
|
||||||
|
NSURL *destinationURL = [NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
|
||||||
|
NSLog(@"desintation %@", destinationURL);
|
||||||
|
if([fileManager fileExistsAtPath:[destinationURL path]])
|
||||||
|
{
|
||||||
|
[fileManager removeItemAtURL:destinationURL error:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSLog(@"location: %@", location.path);
|
||||||
|
NSLog(@"destination: %@", destinationURL);
|
||||||
|
BOOL success = [fileManager moveItemAtURL:location toURL:destinationURL error:&error];
|
||||||
|
|
||||||
|
|
||||||
|
NSLog(success ? @"TRUE" : @"FALSE");
|
||||||
|
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"Download Launcher: failed to move file to destintation -> error: %@", error);
|
||||||
|
[sharedLauncher displayErrorPage];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSLog(@"extracting domain content file");
|
||||||
|
BOOL extractionSuccessful = [sharedLauncher extractZipFileAtDestination:[sharedLauncher getDownloadPathForContentAndScripts] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:destinationFileName]];
|
||||||
|
|
||||||
|
if (!extractionSuccessful) {
|
||||||
|
[sharedLauncher displayErrorPage];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSLog(@"finished extracting content file");
|
||||||
|
|
||||||
|
|
||||||
|
[[Launcher sharedLauncher] runAutoupdater];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
|
||||||
|
NSLog(@"completed; error: %@", error);
|
||||||
|
if (error) {
|
||||||
|
[[Launcher sharedLauncher] displayErrorPage];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
|
@ -58,9 +58,11 @@
|
||||||
|
|
||||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
NSArray *values = [json valueForKey:@"results"];
|
NSArray *values = [json valueForKey:@"results"];
|
||||||
|
NSDictionary *launcherValues = [json valueForKey:@"launcher"];
|
||||||
NSDictionary *value = [values objectAtIndex:0];
|
NSDictionary *value = [values objectAtIndex:0];
|
||||||
|
|
||||||
|
NSString* launcherVersion = [launcherValues valueForKey:@"version"];
|
||||||
|
NSString* launcherUrl = [[launcherValues valueForKey:@"mac"] valueForKey:@"url"];
|
||||||
NSString* buildNumber = [value valueForKey:@"latest_version"];
|
NSString* buildNumber = [value valueForKey:@"latest_version"];
|
||||||
NSDictionary* installers = [value objectForKey:@"installers"];
|
NSDictionary* installers = [value objectForKey:@"installers"];
|
||||||
NSDictionary* macInstallerObject = [installers objectForKey:@"mac"];
|
NSDictionary* macInstallerObject = [installers objectForKey:@"mac"];
|
||||||
|
@ -71,16 +73,22 @@
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
NSInteger currentVersion = [self getCurrentVersion];
|
NSInteger currentVersion = [self getCurrentVersion];
|
||||||
|
NSInteger currentLauncherVersion = atoi(LAUNCHER_BUILD_VERSION);
|
||||||
|
NSLog(@"Latest Build Request -> current launcher version %ld", currentLauncherVersion);
|
||||||
|
NSLog(@"Latest Build Request -> latest launcher version %ld", launcherVersion.integerValue);
|
||||||
|
NSLog(@"Latest Build Request -> launcher url %@", launcherUrl);
|
||||||
NSLog(@"Latest Build Request -> does build directory exist: %@", appDirectoryExist ? @"TRUE" : @"FALSE");
|
NSLog(@"Latest Build Request -> does build directory exist: %@", appDirectoryExist ? @"TRUE" : @"FALSE");
|
||||||
NSLog(@"Latest Build Request -> current version: %ld", currentVersion);
|
NSLog(@"Latest Build Request -> current version: %ld", currentVersion);
|
||||||
NSLog(@"Latest Build Request -> latest version: %ld", buildNumber.integerValue);
|
NSLog(@"Latest Build Request -> latest version: %ld", buildNumber.integerValue);
|
||||||
NSLog(@"Latest Build Request -> mac url: %@", macInstallerUrl);
|
NSLog(@"Latest Build Request -> mac url: %@", macInstallerUrl);
|
||||||
BOOL latestVersionAvailable = (currentVersion != buildNumber.integerValue);
|
BOOL latestVersionAvailable = (currentVersion != buildNumber.integerValue);
|
||||||
|
BOOL latestLauncherVersionAvailable = (currentLauncherVersion != launcherVersion.integerValue);
|
||||||
[[Settings sharedSettings] buildVersion:buildNumber.integerValue];
|
[[Settings sharedSettings] buildVersion:buildNumber.integerValue];
|
||||||
|
|
||||||
BOOL shouldDownloadInterface = (latestVersionAvailable || !appDirectoryExist);
|
BOOL shouldDownloadInterface = (latestVersionAvailable || !appDirectoryExist);
|
||||||
NSLog(@"Latest Build Request -> SHOULD DOWNLOAD: %@", shouldDownloadInterface ? @"TRUE" : @"FALSE");
|
NSLog(@"Latest Build Request -> SHOULD DOWNLOAD: %@", shouldDownloadInterface ? @"TRUE" : @"FALSE");
|
||||||
[sharedLauncher shouldDownloadLatestBuild:shouldDownloadInterface :macInstallerUrl];
|
[sharedLauncher shouldDownloadLatestBuild:shouldDownloadInterface :macInstallerUrl
|
||||||
|
:latestLauncherVersionAvailable :launcherUrl];
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#import "DownloadInterface.h"
|
#import "DownloadInterface.h"
|
||||||
#import "CredentialsRequest.h"
|
#import "CredentialsRequest.h"
|
||||||
#import "DownloadDomainContent.h"
|
#import "DownloadDomainContent.h"
|
||||||
|
#import "DownloadLauncher.h"
|
||||||
#import "LatestBuildRequest.h"
|
#import "LatestBuildRequest.h"
|
||||||
#import "OrganizationRequest.h"
|
#import "OrganizationRequest.h"
|
||||||
#import "DownloadScripts.h"
|
#import "DownloadScripts.h"
|
||||||
|
@ -44,6 +45,7 @@ struct LatestBuildInfo {
|
||||||
@property (nonatomic, retain) DownloadInterface* downloadInterface;
|
@property (nonatomic, retain) DownloadInterface* downloadInterface;
|
||||||
@property (nonatomic, retain) CredentialsRequest* credentialsRequest;
|
@property (nonatomic, retain) CredentialsRequest* credentialsRequest;
|
||||||
@property (nonatomic, retain) DownloadDomainContent* downloadDomainContent;
|
@property (nonatomic, retain) DownloadDomainContent* downloadDomainContent;
|
||||||
|
@property (nonatomic, retain) DownloadLauncher* downloadLauncher;
|
||||||
@property (nonatomic, retain) DownloadScripts* downloadScripts;
|
@property (nonatomic, retain) DownloadScripts* downloadScripts;
|
||||||
@property (nonatomic, retain) LatestBuildRequest* latestBuildRequest;
|
@property (nonatomic, retain) LatestBuildRequest* latestBuildRequest;
|
||||||
@property (nonatomic, retain) OrganizationRequest* organizationRequest;
|
@property (nonatomic, retain) OrganizationRequest* organizationRequest;
|
||||||
|
@ -74,11 +76,12 @@ struct LatestBuildInfo {
|
||||||
- (void) showLoginScreen;
|
- (void) showLoginScreen;
|
||||||
- (void) restart;
|
- (void) restart;
|
||||||
- (NSString*) getLauncherPath;
|
- (NSString*) getLauncherPath;
|
||||||
|
- (void) runAutoupdater;
|
||||||
- (ProcessState) currentProccessState;
|
- (ProcessState) currentProccessState;
|
||||||
- (void) setCurrentProcessState:(ProcessState) aProcessState;
|
- (void) setCurrentProcessState:(ProcessState) aProcessState;
|
||||||
- (void) setLoginErrorState:(LoginError) aLoginError;
|
- (void) setLoginErrorState:(LoginError) aLoginError;
|
||||||
- (LoginError) getLoginErrorState;
|
- (LoginError) getLoginErrorState;
|
||||||
- (void) shouldDownloadLatestBuild:(BOOL) shouldDownload :(NSString*) downloadUrl;
|
- (void) shouldDownloadLatestBuild:(BOOL) shouldDownload :(NSString*) downloadUrl :(BOOL) newLauncherAvailable :(NSString*) launcherUrl;
|
||||||
- (void) interfaceFinishedDownloading;
|
- (void) interfaceFinishedDownloading;
|
||||||
- (NSString*) getDownloadPathForContentAndScripts;
|
- (NSString*) getDownloadPathForContentAndScripts;
|
||||||
- (void) launchInterface;
|
- (void) launchInterface;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#import "SplashScreen.h"
|
#import "SplashScreen.h"
|
||||||
#import "LoginScreen.h"
|
#import "LoginScreen.h"
|
||||||
#import "DisplayNameScreen.h"
|
#import "DisplayNameScreen.h"
|
||||||
|
#import "LauncherCommandlineArgs.h"
|
||||||
#import "ProcessScreen.h"
|
#import "ProcessScreen.h"
|
||||||
#import "ErrorViewController.h"
|
#import "ErrorViewController.h"
|
||||||
#import "Settings.h"
|
#import "Settings.h"
|
||||||
|
@ -32,6 +33,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
self.username = [[NSString alloc] initWithString:@"Default Property Value"];
|
self.username = [[NSString alloc] initWithString:@"Default Property Value"];
|
||||||
self.downloadInterface = [DownloadInterface alloc];
|
self.downloadInterface = [DownloadInterface alloc];
|
||||||
self.downloadDomainContent = [DownloadDomainContent alloc];
|
self.downloadDomainContent = [DownloadDomainContent alloc];
|
||||||
|
self.downloadLauncher = [DownloadLauncher alloc];
|
||||||
self.credentialsRequest = [CredentialsRequest alloc];
|
self.credentialsRequest = [CredentialsRequest alloc];
|
||||||
self.latestBuildRequest = [LatestBuildRequest alloc];
|
self.latestBuildRequest = [LatestBuildRequest alloc];
|
||||||
self.organizationRequest = [OrganizationRequest alloc];
|
self.organizationRequest = [OrganizationRequest alloc];
|
||||||
|
@ -362,8 +364,12 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: loginScreen];
|
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: loginScreen];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) shouldDownloadLatestBuild:(BOOL) shouldDownload :(NSString*) downloadUrl
|
- (void) shouldDownloadLatestBuild:(BOOL) shouldDownload :(NSString*) downloadUrl :(BOOL) newLauncherAvailable :(NSString*) launcherUrl
|
||||||
{
|
{
|
||||||
|
NSDictionary* launcherArguments = [LauncherCommandlineArgs arguments];
|
||||||
|
if (newLauncherAvailable && ![launcherArguments valueForKey: @"--noUpdate"]) {
|
||||||
|
[self.downloadLauncher downloadLauncher: launcherUrl];
|
||||||
|
} else {
|
||||||
self.shouldDownloadInterface = shouldDownload;
|
self.shouldDownloadInterface = shouldDownload;
|
||||||
self.interfaceDownloadUrl = downloadUrl;
|
self.interfaceDownloadUrl = downloadUrl;
|
||||||
self.latestBuildRequestFinished = TRUE;
|
self.latestBuildRequestFinished = TRUE;
|
||||||
|
@ -382,6 +388,18 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
||||||
[self showLoginScreen];
|
[self showLoginScreen];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)runAutoupdater
|
||||||
|
{
|
||||||
|
NSTask* task = [[NSTask alloc] init];
|
||||||
|
NSString* newLauncher = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent: @"HQ Launcher.app"];
|
||||||
|
task.launchPath = [newLauncher stringByAppendingString:@"/Contents/Resources/updater"];
|
||||||
|
task.arguments = @[[[NSBundle mainBundle] bundlePath], newLauncher];
|
||||||
|
[task launch];
|
||||||
|
|
||||||
|
[NSApp terminate:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)onSplashScreenTimerFinished:(NSTimer *)timer
|
-(void)onSplashScreenTimerFinished:(NSTimer *)timer
|
||||||
|
|
8
launchers/darwin/src/LauncherCommandlineArgs.h
Normal file
8
launchers/darwin/src/LauncherCommandlineArgs.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@interface LauncherCommandlineArgs : NSObject {
|
||||||
|
}
|
||||||
|
+(NSDictionary*) arguments;
|
||||||
|
@end
|
||||||
|
|
30
launchers/darwin/src/LauncherCommandlineArgs.m
Normal file
30
launchers/darwin/src/LauncherCommandlineArgs.m
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#import "LauncherCommandlineArgs.h"
|
||||||
|
|
||||||
|
@implementation LauncherCommandlineArgs
|
||||||
|
+(NSDictionary*) arguments
|
||||||
|
{
|
||||||
|
|
||||||
|
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
|
||||||
|
if (arguments.count < 2)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary* argsDict = [[NSMutableDictionary alloc] init];
|
||||||
|
NSMutableArray* args = [arguments mutableCopy];
|
||||||
|
|
||||||
|
for (NSString* arg in args)
|
||||||
|
{
|
||||||
|
if ([arg rangeOfString:@"="].location != NSNotFound && [arg rangeOfString:@"--"].location != NSNotFound) {
|
||||||
|
NSArray* components = [arg componentsSeparatedByString:@"="];
|
||||||
|
NSString* key = [components objectAtIndex:0];
|
||||||
|
NSString* value = [components objectAtIndex:1];
|
||||||
|
[argsDict setObject:value forKey:key];
|
||||||
|
} else if ([arg rangeOfString:@"--"].location != NSNotFound) {
|
||||||
|
[argsDict setObject:@TRUE forKey:arg];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NSLog(@"AGS: %@", argsDict);
|
||||||
|
return argsDict;
|
||||||
|
}
|
||||||
|
@end
|
|
@ -1,5 +1,6 @@
|
||||||
#import "Launcher.h"
|
#import "Launcher.h"
|
||||||
#import "Settings.h"
|
#import "Settings.h"
|
||||||
|
#import "LauncherCommandlineArgs.h"
|
||||||
|
|
||||||
void redirectLogToDocuments()
|
void redirectLogToDocuments()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,37 @@
|
||||||
int main(int argc, const char* argv[])
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@interface UpdaterHelper : NSObject
|
||||||
|
+(NSURL*) NSStringToNSURL: (NSString*) path;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UpdaterHelper
|
||||||
|
+(NSURL*) NSStringToNSURL: (NSString*) path
|
||||||
{
|
{
|
||||||
NSLog(@"Hello World");
|
return [NSURL URLWithString: [path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
int main(int argc, char const* argv[])
|
||||||
|
{
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
NSLog(@"Error: wrong number of arguments");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < argc; index++) {
|
||||||
|
NSLog(@"argv at index %d = %s", index, argv[index]);
|
||||||
|
}
|
||||||
|
NSString* oldLauncher = [NSString stringWithUTF8String:argv[1]];
|
||||||
|
NSString* newLauncher = [NSString stringWithUTF8String:argv[2]];
|
||||||
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
|
[fileManager removeItemAtURL:[UpdaterHelper NSStringToNSURL:oldLauncher] error:nil];
|
||||||
|
[fileManager moveItemAtURL: [UpdaterHelper NSStringToNSURL: newLauncher] toURL: [UpdaterHelper NSStringToNSURL:oldLauncher] error:nil];
|
||||||
|
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
|
||||||
|
NSURL* applicationURL = [UpdaterHelper NSStringToNSURL: [oldLauncher stringByAppendingString: @"/Contents/MacOS/HQ Launcher"]];
|
||||||
|
NSArray* arguments =@[];
|
||||||
|
NSLog(@"Launcher agruments: %@", arguments);
|
||||||
|
[workspace launchApplicationAtURL:applicationURL options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:nil];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue