mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:31:13 +02:00
making requested changes
This commit is contained in:
parent
7ed13a2ba2
commit
b9106b9ade
4 changed files with 26 additions and 35 deletions
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
@implementation DownloadLauncher
|
@implementation DownloadLauncher
|
||||||
|
|
||||||
- (void) downloadLauncher:(NSString *)launcherUrl
|
- (void) downloadLauncher:(NSString*)launcherUrl {
|
||||||
{
|
|
||||||
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:launcherUrl]
|
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:launcherUrl]
|
||||||
cachePolicy:NSURLRequestUseProtocolCachePolicy
|
cachePolicy:NSURLRequestUseProtocolCachePolicy
|
||||||
timeoutInterval:60.0];
|
timeoutInterval:60.0];
|
||||||
|
@ -22,20 +21,15 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {
|
-(void)URLSession:(NSURLSession*)session downloadTask:(NSURLSessionDownloadTask*)downloadTask didFinishDownloadingToURL:(NSURL*)location {
|
||||||
// unused in this example
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location {
|
|
||||||
NSLog(@"Did finish downloading to url");
|
NSLog(@"Did finish downloading to url");
|
||||||
NSError *error = nil;
|
NSError* error = nil;
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
NSString *destinationFileName = downloadTask.originalRequest.URL.lastPathComponent;
|
NSString* destinationFileName = downloadTask.originalRequest.URL.lastPathComponent;
|
||||||
NSString* finalFilePath = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent:destinationFileName];
|
NSString* finalFilePath = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent:destinationFileName];
|
||||||
NSURL *destinationURL = [NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
|
NSURL *destinationURL = [NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
|
||||||
NSLog(@"desintation %@", destinationURL);
|
NSLog(@"desintation %@", destinationURL);
|
||||||
if([fileManager fileExistsAtPath:[destinationURL path]])
|
if([fileManager fileExistsAtPath:[destinationURL path]]) {
|
||||||
{
|
|
||||||
[fileManager removeItemAtURL:destinationURL error:nil];
|
[fileManager removeItemAtURL:destinationURL error:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,21 +45,21 @@
|
||||||
NSLog(@"Download Launcher: failed to move file to destintation -> error: %@", error);
|
NSLog(@"Download Launcher: failed to move file to destintation -> error: %@", error);
|
||||||
[sharedLauncher displayErrorPage];
|
[sharedLauncher displayErrorPage];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSLog(@"extracting domain content file");
|
NSLog(@"extracting Launcher file");
|
||||||
BOOL extractionSuccessful = [sharedLauncher extractZipFileAtDestination:[sharedLauncher getDownloadPathForContentAndScripts] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:destinationFileName]];
|
BOOL extractionSuccessful = [sharedLauncher extractZipFileAtDestination:[sharedLauncher getDownloadPathForContentAndScripts] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:@"HQ Launcher.zip"]];
|
||||||
|
|
||||||
if (!extractionSuccessful) {
|
if (!extractionSuccessful) {
|
||||||
[sharedLauncher displayErrorPage];
|
[sharedLauncher displayErrorPage];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSLog(@"finished extracting content file");
|
NSLog(@"finished extracting Launcher file");
|
||||||
|
|
||||||
|
|
||||||
[[Launcher sharedLauncher] runAutoupdater];
|
[[Launcher sharedLauncher] runAutoupdater];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
|
- (void)URLSession:(NSURLSession*)session task:(NSURLSessionTask*)task didCompleteWithError:(NSError*)error {
|
||||||
NSLog(@"completed; error: %@", error);
|
NSLog(@"completed; error: %@", error);
|
||||||
if (error) {
|
if (error) {
|
||||||
[[Launcher sharedLauncher] displayErrorPage];
|
[[Launcher sharedLauncher] displayErrorPage];
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
NSInteger currentVersion;
|
NSInteger currentVersion;
|
||||||
@try {
|
@try {
|
||||||
NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"];
|
NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"];
|
||||||
NSError * error = nil;
|
NSError* error = nil;
|
||||||
Interface * interface = [[Interface alloc] initWith:interfaceAppPath];
|
Interface* interface = [[Interface alloc] initWith:interfaceAppPath];
|
||||||
currentVersion = [interface getVersion:&error];
|
currentVersion = [interface getVersion:&error];
|
||||||
if (currentVersion == 0 && error != nil) {
|
if (currentVersion == 0 && error != nil) {
|
||||||
NSLog(@"can't get version from interface, falling back to settings: %@", error);
|
NSLog(@"can't get version from interface, falling back to settings: %@", error);
|
||||||
|
@ -24,17 +24,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) requestLatestBuildInfo {
|
- (void) requestLatestBuildInfo {
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest new];
|
NSMutableURLRequest* request = [NSMutableURLRequest new];
|
||||||
[request setURL:[NSURL URLWithString:@"https://thunder.highfidelity.com/builds/api/tags/latest?format=json"]];
|
[request setURL:[NSURL URLWithString:@"https://thunder.highfidelity.com/builds/api/tags/latest?format=json"]];
|
||||||
[request setHTTPMethod:@"GET"];
|
[request setHTTPMethod:@"GET"];
|
||||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||||
|
|
||||||
// We're using an ephermeral session here to ensure the tags api response is never cached.
|
// We're using an ephermeral session here to ensure the tags api response is never cached.
|
||||||
NSURLSession * session = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.ephemeralSessionConfiguration];
|
NSURLSession* session = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.ephemeralSessionConfiguration];
|
||||||
NSURLSessionDataTask* dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
NSURLSessionDataTask* dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
||||||
NSLog(@"Latest Build Request error: %@", error);
|
NSLog(@"Latest Build Request error: %@", error);
|
||||||
NSLog(@"Latest Build Request Data: %@", data);
|
NSLog(@"Latest Build Request Data: %@", data);
|
||||||
NSHTTPURLResponse *ne = (NSHTTPURLResponse *)response;
|
NSHTTPURLResponse* ne = (NSHTTPURLResponse *)response;
|
||||||
NSLog(@"Latest Build Request Response: %ld", [ne statusCode]);
|
NSLog(@"Latest Build Request Response: %ld", [ne statusCode]);
|
||||||
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@
|
||||||
NSMutableData* webData = [NSMutableData data];
|
NSMutableData* webData = [NSMutableData data];
|
||||||
[webData appendData:data];
|
[webData appendData:data];
|
||||||
NSString* jsonString = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[data length] encoding:NSUTF8StringEncoding];
|
NSString* jsonString = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[data length] encoding:NSUTF8StringEncoding];
|
||||||
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
NSData* jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
NSLog(@"Latest Build Request -> json string: %@", jsonString);
|
NSLog(@"Latest Build Request -> json string: %@", jsonString);
|
||||||
NSError *jsonError = nil;
|
NSError* jsonError = nil;
|
||||||
id json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&jsonError];
|
id json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&jsonError];
|
||||||
|
|
||||||
if (jsonError) {
|
if (jsonError) {
|
||||||
|
@ -57,9 +57,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
NSArray *values = [json valueForKey:@"results"];
|
NSArray* values = [json valueForKey:@"results"];
|
||||||
NSDictionary *launcherValues = [json valueForKey:@"launcher"];
|
NSDictionary* launcherValues = [json valueForKey:@"launcher"];
|
||||||
NSDictionary *value = [values objectAtIndex:0];
|
NSDictionary* value = [values objectAtIndex:0];
|
||||||
|
|
||||||
NSString* launcherVersion = [launcherValues valueForKey:@"version"];
|
NSString* launcherVersion = [launcherValues valueForKey:@"version"];
|
||||||
NSString* launcherUrl = [[launcherValues valueForKey:@"mac"] valueForKey:@"url"];
|
NSString* launcherUrl = [[launcherValues valueForKey:@"mac"] valueForKey:@"url"];
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#import "LauncherCommandlineArgs.h"
|
#import "LauncherCommandlineArgs.h"
|
||||||
|
|
||||||
@implementation LauncherCommandlineArgs
|
@implementation LauncherCommandlineArgs
|
||||||
+(NSDictionary*) arguments
|
+(NSDictionary*) arguments {
|
||||||
{
|
|
||||||
|
|
||||||
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
|
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
|
||||||
if (arguments.count < 2)
|
if (arguments.count < 2)
|
||||||
|
|
|
@ -12,10 +12,8 @@
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
int main(int argc, char const* argv[])
|
int main(int argc, char const* argv[]) {
|
||||||
{
|
if (argc < 3) {
|
||||||
if (argc < 3)
|
|
||||||
{
|
|
||||||
NSLog(@"Error: wrong number of arguments");
|
NSLog(@"Error: wrong number of arguments");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +23,9 @@ int main(int argc, char const* argv[])
|
||||||
}
|
}
|
||||||
NSString* oldLauncher = [NSString stringWithUTF8String:argv[1]];
|
NSString* oldLauncher = [NSString stringWithUTF8String:argv[1]];
|
||||||
NSString* newLauncher = [NSString stringWithUTF8String:argv[2]];
|
NSString* newLauncher = [NSString stringWithUTF8String:argv[2]];
|
||||||
|
NSURL* destinationUrl = [UpdaterHelper NSStringToNSURL:newLauncher];
|
||||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
[fileManager removeItemAtURL:[UpdaterHelper NSStringToNSURL:oldLauncher] error:nil];
|
[fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:oldLauncher] withItemAtURL:[UpdaterHelper NSStringToNSURL:newLauncher] backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:nil];
|
||||||
[fileManager moveItemAtURL: [UpdaterHelper NSStringToNSURL: newLauncher] toURL: [UpdaterHelper NSStringToNSURL:oldLauncher] error:nil];
|
|
||||||
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
|
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
|
||||||
NSURL* applicationURL = [UpdaterHelper NSStringToNSURL: [oldLauncher stringByAppendingString: @"/Contents/MacOS/HQ Launcher"]];
|
NSURL* applicationURL = [UpdaterHelper NSStringToNSURL: [oldLauncher stringByAppendingString: @"/Contents/MacOS/HQ Launcher"]];
|
||||||
NSArray* arguments =@[];
|
NSArray* arguments =@[];
|
||||||
|
|
Loading…
Reference in a new issue