finished work

This commit is contained in:
dante ruiz 2019-07-09 10:43:46 -07:00
parent a5f9283bde
commit 15cc7a0e6c
5 changed files with 75 additions and 37 deletions

View file

@ -5,7 +5,7 @@
- (double) getProgressPercentage - (double) getProgressPercentage
{ {
return (self.progressPercentage * 0.50) + (self.taskProgressPercentage * 0.50); return (self.progressPercentage * 0.70) + (self.taskProgressPercentage * 0.30);
} }
- (void) downloadDomainContent:(NSString *)domainContentUrl - (void) downloadDomainContent:(NSString *)domainContentUrl
@ -90,7 +90,13 @@
} }
- (void) updatePercentage:(NSTimer*) timer { - (void) updatePercentage:(NSTimer*) timer {
self.taskProgressPercentage += 4.0; if (self.taskProgressPercentage < 100.0) {
self.taskProgressPercentage += 1.5;
if (self.taskProgressPercentage > 100.0) {
self.taskProgressPercentage = 100.0;
}
}
[[Launcher sharedLauncher] updateProgressIndicator]; [[Launcher sharedLauncher] updateProgressIndicator];
} }

View file

@ -6,6 +6,7 @@
- (void) downloadInterface:(NSString*) downloadUrl - (void) downloadInterface:(NSString*) downloadUrl
{ {
NSLog(@"-----------------> %@", downloadUrl);
self.progressPercentage = 0.0; self.progressPercentage = 0.0;
self.taskProgressPercentage = 0.0; self.taskProgressPercentage = 0.0;
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:downloadUrl] NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:downloadUrl]
@ -30,7 +31,7 @@
- (double) getProgressPercentage - (double) getProgressPercentage
{ {
return (self.progressPercentage * 0.90) + (self.taskProgressPercentage * 0.10); return (self.progressPercentage * 0.70) + (self.taskProgressPercentage * 0.30);
} }
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes { -(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {
@ -102,7 +103,13 @@
} }
- (void) updateTaskPercentage:(NSTimer*) timer { - (void) updateTaskPercentage:(NSTimer*) timer {
self.taskProgressPercentage += 3.0; if (self.taskProgressPercentage < 100.0) {
self.taskProgressPercentage += 1.5;
if (self.taskProgressPercentage > 100.0) {
self.taskProgressPercentage = 100.0;
}
}
[[Launcher sharedLauncher] updateProgressIndicator]; [[Launcher sharedLauncher] updateProgressIndicator];
} }

View file

@ -21,6 +21,12 @@ typedef enum LoginErrorTypes
CREDENTIALS CREDENTIALS
} LoginError; } LoginError;
struct LatestBuildInfo {
NSString* downloadURL;
BOOL shouldDownload;
BOOL requestBuildFinished;
};
@interface Launcher : NSObject <NSApplicationDelegate, NSWindowDelegate, NSURLDownloadDelegate> { @interface Launcher : NSObject <NSApplicationDelegate, NSWindowDelegate, NSURLDownloadDelegate> {
} }
@property (nonatomic, retain) NSString* password; @property (nonatomic, retain) NSString* password;
@ -52,6 +58,7 @@ typedef enum LoginErrorTypes
@property (nonatomic, assign, readwrite) LoginError loginError; @property (nonatomic, assign, readwrite) LoginError loginError;
@property (nonatomic, assign) NSProgressIndicator* progressIndicator; @property (nonatomic, assign) NSProgressIndicator* progressIndicator;
@property (nonatomic) double progressTarget; @property (nonatomic) double progressTarget;
@property (nonatomic) struct LatestBuildInfo buildInfo;
- (NSProgressIndicator*) getProgressView; - (NSProgressIndicator*) getProgressView;
- (void) setProgressView:(NSProgressIndicator*) aProgressIndicator; - (void) setProgressView:(NSProgressIndicator*) aProgressIndicator;
@ -89,8 +96,8 @@ typedef enum LoginErrorTypes
- (BOOL) isLoadedIn; - (BOOL) isLoadedIn;
- (NSString*) getAppPath; - (NSString*) getAppPath;
- (void) updateProgressIndicator; - (void) updateProgressIndicator;
- (void) setShouldDownloadInterface:(BOOL) shouldDownlaod; - (void) setLatestBuildInfo:(struct LatestBuildInfo) latestBuildInfo;
- (BOOL) getShouldDownloadInterface; - (struct LatestBuildInfo) getLatestBuildInfo;
+ (id) sharedLauncher; + (id) sharedLauncher;
@end @end

View file

@ -36,6 +36,11 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
self.latestBuildRequest = [LatestBuildRequest alloc]; self.latestBuildRequest = [LatestBuildRequest alloc];
self.organizationRequest = [OrganizationRequest alloc]; self.organizationRequest = [OrganizationRequest alloc];
self.downloadScripts = [DownloadScripts alloc]; self.downloadScripts = [DownloadScripts alloc];
struct LatestBuildInfo latestBuildInfo;
latestBuildInfo.downloadURL = nil;
latestBuildInfo.shouldDownload = FALSE;
latestBuildInfo.requestBuildFinished = FALSE;
self.buildInfo = latestBuildInfo;
self.credentialsAccepted = TRUE; self.credentialsAccepted = TRUE;
self.gotCredentialResponse = FALSE; self.gotCredentialResponse = FALSE;
self.waitingForCredentialReponse = FALSE; self.waitingForCredentialReponse = FALSE;
@ -89,22 +94,21 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
double contentPercentage = [self.downloadDomainContent getProgressPercentage]; double contentPercentage = [self.downloadDomainContent getProgressPercentage];
double interfacePercentage = [self.downloadInterface getProgressPercentage]; double interfacePercentage = [self.downloadInterface getProgressPercentage];
double currentTotalPercentage = self.progressTarget; double currentTotalPercentage = self.progressTarget;
if (self.shouldDownloadInterface) { if (self.processState == DOWNLOADING_INTERFACE) {
currentTotalPercentage = (contentPercentage * 0.5) + (interfacePercentage * 0.5); if (self.shouldDownloadInterface) {
currentTotalPercentage = (contentPercentage * 0.5) + (interfacePercentage * 0.5);
} else {
currentTotalPercentage = contentPercentage;
}
} else { } else {
currentTotalPercentage = contentPercentage; currentTotalPercentage = interfacePercentage;
} }
self.progressTarget = currentTotalPercentage; self.progressTarget = currentTotalPercentage;
//[progressIndicator incrementBy: (currentTotalPercentage - oldValue)];
//progressIndicator.doubleValue = [self lerp:oldValue :currentTotalPercentage :0.7];
} }
- (double) lerp:(double) pointA :(double) pointB :(double) interp - (double) lerp:(double) pointA :(double) pointB :(double) interp
{ {
//NSLog(@"PointA: %f PointB: %f interp: %f", pointA, pointB, interp);
double lerpValue = pointA + interp * (pointB - pointA); double lerpValue = pointA + interp * (pointB - pointA);
//NSLog(@"----> lerp value: %f", lerpValue);
return lerpValue; return lerpValue;
} }
@ -150,7 +154,6 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
- (void) checkLoginStatus - (void) checkLoginStatus
{ {
[self.latestBuildRequest requestLatestBuildInfo];
[NSTimer scheduledTimerWithTimeInterval:2.0 [NSTimer scheduledTimerWithTimeInterval:2.0
target:self target:self
selector:@selector(onSplashScreenTimerFinished:) selector:@selector(onSplashScreenTimerFinished:)
@ -308,9 +311,12 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
} else { } else {
[sharedLauncher setCurrentProcessState: RUNNING_INTERFACE_AFTER_UPDATE]; [sharedLauncher setCurrentProcessState: RUNNING_INTERFACE_AFTER_UPDATE];
} }
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen]; [NSTimer scheduledTimerWithTimeInterval: 0.2
[self launchInterface]; target: self
selector: @selector(callLaunchInterface:)
userInfo:nil
repeats: NO];
} }
- (void) credentialsEntered:(NSString*)aOrginization :(NSString*)aUsername :(NSString*)aPassword - (void) credentialsEntered:(NSString*)aOrginization :(NSString*)aUsername :(NSString*)aPassword
@ -337,6 +343,16 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
return YES; return YES;
} }
- (struct LatestBuildInfo) getLatestBuildInfo
{
return self.buildInfo;
}
- (void) setLatestBuildInfo:(struct LatestBuildInfo) latestBuildInfo
{
self.buildInfo = latestBuildInfo;
}
-(void) showLoginScreen -(void) showLoginScreen
{ {
LoginScreen* loginScreen = [[LoginScreen alloc] initWithNibName:@"LoginScreen" bundle:nil]; LoginScreen* loginScreen = [[LoginScreen alloc] initWithNibName:@"LoginScreen" bundle:nil];
@ -348,24 +364,14 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
self.shouldDownloadInterface = shouldDownload; self.shouldDownloadInterface = shouldDownload;
self.interfaceDownloadUrl = downloadUrl; self.interfaceDownloadUrl = downloadUrl;
self.latestBuildRequestFinished = TRUE; self.latestBuildRequestFinished = TRUE;
NSLog(@"------> FINISHED ->>>>>>>>");
/*if (shouldDownload) {
[self.downloadInterface downloadInterface: downloadUrl];
return;
}
[self launchInterface];*/
}
-(void)onSplashScreenTimerFinished:(NSTimer *)timer
{
if ([self isLoadedIn]) { if ([self isLoadedIn]) {
Launcher* sharedLauncher = [Launcher sharedLauncher]; Launcher* sharedLauncher = [Launcher sharedLauncher];
[sharedLauncher setCurrentProcessState:CHECKING_UPDATE]; [sharedLauncher setCurrentProcessState:CHECKING_UPDATE];
NSLog(@"Should Downlaod: %@", self.shouldDownloadInterface ? @"True" : @"False"); if (shouldDownload) {
if (self.shouldDownloadInterface) {
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil]; ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen]; [[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
[self.downloadInterface downloadInterface: self.interfaceDownloadUrl]; [self startUpdateProgressIndicatorTimer];
[self.downloadInterface downloadInterface: downloadUrl];
return; return;
} }
[self interfaceFinishedDownloading]; [self interfaceFinishedDownloading];
@ -375,6 +381,11 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
} }
} }
-(void)onSplashScreenTimerFinished:(NSTimer *)timer
{
[self.latestBuildRequest requestLatestBuildInfo];
}
-(void)setCurrentProcessState:(ProcessState)aProcessState -(void)setCurrentProcessState:(ProcessState)aProcessState
{ {
self.processState = aProcessState; self.processState = aProcessState;
@ -454,11 +465,11 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
} }
[workspace launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error]; [workspace launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];
NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval: 3.0 [NSTimer scheduledTimerWithTimeInterval: 3.0
target: self target: self
selector: @selector(exitLauncher:) selector: @selector(exitLauncher:)
userInfo:nil userInfo:nil
repeats: NO]; repeats: NO];
} }
- (ProcessState) currentProccessState - (ProcessState) currentProccessState
@ -466,6 +477,13 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
return self.processState; return self.processState;
} }
- (void) callLaunchInterface:(NSTimer*) timer
{
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
[self launchInterface];
}
- (void) exitLauncher:(NSTimer*) timer - (void) exitLauncher:(NSTimer*) timer
{ {

View file

@ -17,7 +17,7 @@ void redirectLogToDocuments()
int main(int argc, const char* argv[]) { int main(int argc, const char* argv[]) {
//NSApp.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua]; //NSApp.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
//redirectLogToDocuments(); redirectLogToDocuments();
NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"]; NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"];
if ([apps count] > 1) { if ([apps count] > 1) {
NSLog(@"launcher is already running"); NSLog(@"launcher is already running");