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
{
return (self.progressPercentage * 0.50) + (self.taskProgressPercentage * 0.50);
return (self.progressPercentage * 0.70) + (self.taskProgressPercentage * 0.30);
}
- (void) downloadDomainContent:(NSString *)domainContentUrl
@ -90,7 +90,13 @@
}
- (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];
}

View file

@ -6,6 +6,7 @@
- (void) downloadInterface:(NSString*) downloadUrl
{
NSLog(@"-----------------> %@", downloadUrl);
self.progressPercentage = 0.0;
self.taskProgressPercentage = 0.0;
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:downloadUrl]
@ -30,7 +31,7 @@
- (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 {
@ -102,7 +103,13 @@
}
- (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];
}

View file

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

View file

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

View file

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