diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index 7f76efe5..44c81b41 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -378,9 +378,11 @@ }); } -- (void)showUpdateInstallationDidFinish +- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement { - //... + // Deciding not to show anything here + [self.coreComponent registerAcknowledgement:acknowledgement]; + [self.coreComponent acceptAcknowledgement]; } #pragma mark Aborting Everything diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index 4ba2b4d1..5eba6bd1 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -268,9 +268,11 @@ SU_EXPORT @protocol SPUUserDriver * This will only be invoked if the updater process is still alive, which is typically not the case if * the updater's lifetime is tied to the application it is updating. * + * @param acknowledgement Acknowledge to the updater that the installation finish was shown. + * * This can be called from any thread */ -- (void)showUpdateInstallationDidFinish; +- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement; /*! * Dismiss the current update installation diff --git a/Sparkle/SUCoreBasedUpdateDriver.h b/Sparkle/SUCoreBasedUpdateDriver.h index ef275bdc..5a14611e 100644 --- a/Sparkle/SUCoreBasedUpdateDriver.h +++ b/Sparkle/SUCoreBasedUpdateDriver.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)installerIsRequestingAppTermination; -- (void)installerDidFinishInstallation; +- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement; @end diff --git a/Sparkle/SUCoreBasedUpdateDriver.m b/Sparkle/SUCoreBasedUpdateDriver.m index 7ab9de76..882581df 100644 --- a/Sparkle/SUCoreBasedUpdateDriver.m +++ b/Sparkle/SUCoreBasedUpdateDriver.m @@ -247,10 +247,12 @@ } } -- (void)installerDidFinishInstallation +- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement { - if ([self.delegate respondsToSelector:@selector(installerDidFinishInstallation)]) { - [self.delegate installerDidFinishInstallation]; + if ([self.delegate respondsToSelector:@selector(installerDidFinishInstallationWithAcknowledgement:)]) { + [self.delegate installerDidFinishInstallationWithAcknowledgement:acknowledgement]; + } else { + acknowledgement(); } } diff --git a/Sparkle/SUInstallerDriver.h b/Sparkle/SUInstallerDriver.h index 301c6c91..9b6ff664 100644 --- a/Sparkle/SUInstallerDriver.h +++ b/Sparkle/SUInstallerDriver.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently; - (void)installerIsRequestingAppTermination; - (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch; -- (void)installerDidFinishInstallation; +- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement; - (void)installerIsRequestingAbortInstallWithError:(nullable NSError *)error; - (void)installerDidFailToApplyDeltaUpdate; diff --git a/Sparkle/SUInstallerDriver.m b/Sparkle/SUInstallerDriver.m index a463662e..4b212e94 100644 --- a/Sparkle/SUInstallerDriver.m +++ b/Sparkle/SUInstallerDriver.m @@ -284,8 +284,11 @@ [self.installerConnection invalidate]; self.installerConnection = nil; - [self.delegate installerDidFinishInstallation]; - [self.delegate installerIsRequestingAbortInstallWithError:nil]; + [self.delegate installerDidFinishInstallationWithAcknowledgement:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + [self.delegate installerIsRequestingAbortInstallWithError:nil]; + }); + }]; } else if (identifier == SPUUpdaterAlivePing) { // Don't update the current stage; a ping request has no effect on that. [self.installerConnection handleMessageWithIdentifier:SPUUpdaterAlivePong data:[NSData data]]; diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index f19315d6..9272bc80 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -215,9 +215,9 @@ [self.userDriver terminateApplication]; } -- (void)installerDidFinishInstallation +- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement { - [self.userDriver showUpdateInstallationDidFinish]; + [self.userDriver showUpdateInstallationDidFinishWithAcknowledgement:acknowledgement]; } - (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error diff --git a/TestApplication/SUPopUpTitlebarUserDriver.m b/TestApplication/SUPopUpTitlebarUserDriver.m index f67bd51a..219afb11 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.m +++ b/TestApplication/SUPopUpTitlebarUserDriver.m @@ -224,6 +224,14 @@ #pragma mark Update Errors +- (void)acceptAcknowledgementAfterDelay +{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // Installation will be dismissed shortly after this + [self.coreComponent acceptAcknowledgement]; + }); +} + - (void)showUpdaterError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { dispatch_async(dispatch_get_main_queue(), ^{ @@ -232,10 +240,7 @@ NSLog(@"Error: %@", error); [self addUpdateButtonWithTitle:@"Update Errored!" action:nil]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // Installation will be dismissed shortly after this - [self.coreComponent acceptAcknowledgement]; - }); + [self acceptAcknowledgementAfterDelay]; }); } @@ -246,10 +251,7 @@ [self addUpdateButtonWithTitle:@"No Update Available" action:nil]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // Installation will be dismissed shortly after this - [self.coreComponent acceptAcknowledgement]; - }); + [self acceptAcknowledgementAfterDelay]; }); } @@ -302,10 +304,14 @@ }); } -- (void)showUpdateInstallationDidFinish +- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement { dispatch_async(dispatch_get_main_queue(), ^{ + [self.coreComponent registerAcknowledgement:acknowledgement]; + [self addUpdateButtonWithTitle:@"Installation Finished!"]; + + [self acceptAcknowledgementAfterDelay]; }); } diff --git a/sparkle-cli/SPUCommandLineUserDriver.m b/sparkle-cli/SPUCommandLineUserDriver.m index 184e8950..6735fbd3 100644 --- a/sparkle-cli/SPUCommandLineUserDriver.m +++ b/sparkle-cli/SPUCommandLineUserDriver.m @@ -285,12 +285,16 @@ }); } -- (void)showUpdateInstallationDidFinish +- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement { dispatch_async(dispatch_get_main_queue(), ^{ + [self.coreComponent registerAcknowledgement:acknowledgement]; + if (self.verbose) { fprintf(stderr, "Installation Finished.\n"); } + + [self.coreComponent acceptAcknowledgement]; }); }