From 581c5fe554c0b0703f13a3a935acdb00b3a3c6fd Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Wed, 5 Jun 2019 14:23:47 -0700 Subject: [PATCH] removing warnings --- launchers/darwin/src/DownloadDomainContent.h | 2 +- launchers/darwin/src/DownloadDomainContent.m | 98 ++++++++------------ launchers/darwin/src/DownloadInterface.h | 2 +- launchers/darwin/src/DownloadInterface.m | 94 ++++++------------- launchers/darwin/src/ProcessScreen.m | 2 +- 5 files changed, 68 insertions(+), 130 deletions(-) diff --git a/launchers/darwin/src/DownloadDomainContent.h b/launchers/darwin/src/DownloadDomainContent.h index a714b201de..c35c8b8f09 100644 --- a/launchers/darwin/src/DownloadDomainContent.h +++ b/launchers/darwin/src/DownloadDomainContent.h @@ -1,6 +1,6 @@ #import -@interface DownloadDomainContent : NSObject { +@interface DownloadDomainContent : NSObject { } - (void) downloadDomainContent:(NSString*) domainContentUrl; diff --git a/launchers/darwin/src/DownloadDomainContent.m b/launchers/darwin/src/DownloadDomainContent.m index 8d1ad715f4..7b0247a6f4 100644 --- a/launchers/darwin/src/DownloadDomainContent.m +++ b/launchers/darwin/src/DownloadDomainContent.m @@ -6,79 +6,55 @@ - (void) downloadDomainContent:(NSString *)domainContentUrl { NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:domainContentUrl] - cachePolicy:NSURLRequestUseProtocolCachePolicy - timeoutInterval:60.0]; - NSURLDownload* theDownload = [[NSURLDownload alloc] initWithRequest:request delegate:self]; + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:60.0]; - /*NSURLSession *session = [NSURLSession sharedSession]; - NSURLSessionDownloadTask *downloadTask = [session downloadTaskWithRequest:request - completionHandler: - ^(NSURL *location, NSURLResponse *response,NSError *error) { - NSString* finalFilePath = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent:[response suggestedFilename]]; - [[NSFileManager defaultManager] moveItemAtURL:location - toURL:[NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]] - error:nil]; - Launcher* sharedLauncher = [Launcher sharedLauncher]; - [sharedLauncher setDownloadContextFilename:[response suggestedFilename]]; - NSLog(@"extracting domain content file"); - [sharedLauncher extractZipFileAtDestination:[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:@"content"] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:[sharedLauncher getDownloadContentFilename]]]; - - NSLog(@"finished extracting content file"); - dispatch_async(dispatch_get_main_queue(), ^{ - [sharedLauncher domainContentDownloadFinished]; - }); + 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(@"domain content downloaded %d%%", (int)(100.0*prog)); - }];*/ - - //[downloadTask resume]; - - if (!theDownload) { - NSLog(@"Download Failed"); - [[Launcher sharedLauncher] displayErrorPage]; +} + +-(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; + 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://"]]; + if([fileManager fileExistsAtPath:[destinationURL path]]) + { + [fileManager removeItemAtURL:destinationURL error:nil]; } -} - -- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { - NSLog(@"download domain content: data received"); -} - -- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { - NSHTTPURLResponse *ne = (NSHTTPURLResponse *)response; - if([ne statusCode] == 200) { - NSLog(@"connection state is 200 - all okay"); - } else { - NSLog(@"connection state is NOT 200"); - [[Launcher sharedLauncher] displayErrorPage]; - } -} - --(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { - NSLog(@"download domain content - Conn Err: %@", [error localizedDescription]); - [[Launcher sharedLauncher] displayErrorPage]; -} - -- (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename -{ - NSString* finalFilePath = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent:filename]; - [download setDestination:finalFilePath allowOverwrite:YES]; - [[Launcher sharedLauncher] setDownloadContextFilename:filename]; -} - -- (void)downloadDidFinish:(NSURLDownload*)download -{ + NSLog(@"%@", location.path); + NSLog(@"%@", destinationURL); + BOOL success = [fileManager moveItemAtURL:location toURL:destinationURL error:&error]; + + + NSLog(success ? @"TRUE" : @"FALSE"); Launcher* sharedLauncher = [Launcher sharedLauncher]; + [sharedLauncher setDownloadContextFilename:destinationFileName]; NSLog(@"extracting domain content file"); [sharedLauncher extractZipFileAtDestination:[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:@"content"] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:[sharedLauncher getDownloadContentFilename]]]; NSLog(@"finished extracting content file"); - [sharedLauncher domainContentDownloadFinished]; } -- (void)download:(NSURLDownload*)download didReceiveResponse:(NSURLResponse*)response -{ - NSLog(@"Download content set response"); +-(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { + NSLog(@"completed; error: %@", error); } + @end diff --git a/launchers/darwin/src/DownloadInterface.h b/launchers/darwin/src/DownloadInterface.h index 8edb75e8ad..08968f19f0 100644 --- a/launchers/darwin/src/DownloadInterface.h +++ b/launchers/darwin/src/DownloadInterface.h @@ -1,6 +1,6 @@ #import -@interface DownloadInterface : NSObject { +@interface DownloadInterface : NSObject { } @property (nonatomic, assign) NSString* finalFilePath; diff --git a/launchers/darwin/src/DownloadInterface.m b/launchers/darwin/src/DownloadInterface.m index 73d8663e48..00e132a91d 100644 --- a/launchers/darwin/src/DownloadInterface.m +++ b/launchers/darwin/src/DownloadInterface.m @@ -7,78 +7,39 @@ - (void) downloadInterface:(NSString*) downloadUrl { NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:downloadUrl] - cachePolicy:NSURLRequestUseProtocolCachePolicy - timeoutInterval:60.0]; + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:60.0]; - NSURLDownload* theDownload = [[NSURLDownload alloc] initWithRequest:request delegate:self]; + NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; + NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]]; + NSURLSessionDownloadTask *downloadTask = [defaultSession downloadTaskWithRequest:request]; - /*NSURLSession *session = [NSURLSession sharedSession]; - NSURLSessionDownloadTask *downloadTask = [session downloadTaskWithRequest:request - completionHandler: - ^(NSURL *location, NSURLResponse *response,NSError *error) { - Launcher* sharedLauncher = [Launcher sharedLauncher]; - NSString* finalFilePath = [[sharedLauncher getAppPath] stringByAppendingPathComponent:[response suggestedFilename]]; - [[Launcher sharedLauncher] setDownloadFilename:[response suggestedFilename]]; - - NSLog(@"----------->%@", location); - [[NSFileManager defaultManager] moveItemAtURL:location - toURL:[NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]] - error:nil]; - dispatch_async(dispatch_get_main_queue(), ^{ - - NSString* appPath = [sharedLauncher getAppPath]; - NSString* downloadFileName = [sharedLauncher getDownloadFilename]; - NSLog(@"!!!!!!%@", downloadFileName); - NSLog(@"extract interface zip"); - [sharedLauncher extractZipFileAtDestination:appPath :[appPath stringByAppendingString:downloadFileName]]; - NSLog(@"finished extracting interface zip"); - - NSLog(@"starting xattr"); - NSTask* quaratineTask = [[NSTask alloc] init]; - quaratineTask.launchPath = @"/usr/bin/xattr"; - quaratineTask.arguments = @[@"-d", @"com.apple.quarantine", [appPath stringByAppendingString:@"interface.app"]]; - - [quaratineTask launch]; - [quaratineTask waitUntilExit]; - NSLog(@"finished xattr"); - - NSString* launcherPath = [appPath stringByAppendingString:@"Launcher"]; - - [[Settings sharedSettings] setLauncherPath:launcherPath]; - [sharedLauncher interfaceFinishedDownloading]; - - }); - }]; - - [downloadTask resume];*/ + [downloadTask resume]; } -- (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename -{ - self.finalFilePath = [[[Launcher sharedLauncher] getAppPath] stringByAppendingPathComponent:filename]; - [download setDestination:self.finalFilePath allowOverwrite:YES]; +-(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(@"interface downloaded %d%%", (int)(100.0*prog)); - [[Launcher sharedLauncher] setDownloadFilename:filename]; } +-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes { + // unused in this example +} -- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { - NSHTTPURLResponse *ne = (NSHTTPURLResponse *)response; - if([ne statusCode] == 200) { - NSLog(@"download interface connection state is 200 - all okay"); - } else { - NSLog(@"download interface connection state is NOT 200"); - [[Launcher sharedLauncher] displayErrorPage]; +-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location { + NSLog(@"Did finish downloading to url"); + NSError *error; + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSString *destinationFileName = downloadTask.originalRequest.URL.lastPathComponent; + NSString* finalFilePath = [[[Launcher sharedLauncher] getAppPath] stringByAppendingPathComponent:destinationFileName]; + NSURL *destinationURL = [NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]]; + if([fileManager fileExistsAtPath:[destinationURL path]]) + { + [fileManager removeItemAtURL:destinationURL error:nil]; } -} - --(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { - NSLog(@"download interface content - Conn Err: %@", [error localizedDescription]); - [[Launcher sharedLauncher] displayErrorPage]; -} - -- (void)downloadDidFinish:(NSURLDownload*)download -{ + [fileManager moveItemAtURL:location toURL:destinationURL error:&error]; + Launcher* sharedLauncher = [Launcher sharedLauncher]; NSString* appPath = [sharedLauncher getAppPath]; NSString* downloadFileName = [sharedLauncher getDownloadFilename]; @@ -102,8 +63,9 @@ [sharedLauncher interfaceFinishedDownloading]; } -- (void)download:(NSURLDownload*)download didReceiveResponse:(NSURLResponse*)response -{ - NSLog(@"Download interface response"); +-(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { + NSLog(@"completed; error: %@", error); } + + @end diff --git a/launchers/darwin/src/ProcessScreen.m b/launchers/darwin/src/ProcessScreen.m index 0a9d6017d1..fb1de799da 100644 --- a/launchers/darwin/src/ProcessScreen.m +++ b/launchers/darwin/src/ProcessScreen.m @@ -49,7 +49,7 @@ } - (void) rotateView:(NSTimer *)timer{ - self.imageRotation += 1; + self.imageRotation -= 1; [self.voxelImage setFrameCenterRotation:self.imageRotation]; } @end