diff --git a/Sparkle/Base.lproj/Sparkle.strings b/Sparkle/Base.lproj/Sparkle.strings index faf6b910..48acd4d4 100644 --- a/Sparkle/Base.lproj/Sparkle.strings +++ b/Sparkle/Base.lproj/Sparkle.strings @@ -14,6 +14,12 @@ "%@ %@ is currently the newest version available.\n(You are currently running version %@.)" = "%1$@ %2$@ is currently the newest version available.\n(You are currently running version %3$@.)"; +"Update Installed" = "Update Installed"; + +"%@ is now updated to version %@!" = "%@ is now updated to version %@!"; + +"%@ is now updated!" = "%@ is now updated!"; + /* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is now available—you have %3$@. Would you like to download it now?"; diff --git a/Sparkle/SPUCoreBasedUpdateDriver.h b/Sparkle/SPUCoreBasedUpdateDriver.h index 9014289d..8187bf09 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.h +++ b/Sparkle/SPUCoreBasedUpdateDriver.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)installerIsSendingAppTerminationSignal; -- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement; +- (void)installerDidFinishInstallationAndRelaunched:(BOOL)relaunched acknowledgement:(void(^)(void))acknowledgement; @end diff --git a/Sparkle/SPUCoreBasedUpdateDriver.m b/Sparkle/SPUCoreBasedUpdateDriver.m index 8537aa2e..a1695365 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.m +++ b/Sparkle/SPUCoreBasedUpdateDriver.m @@ -326,10 +326,10 @@ } } -- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement +- (void)installerDidFinishInstallationAndRelaunched:(BOOL)relaunched acknowledgement:(void(^)(void))acknowledgement { - if ([self.delegate respondsToSelector:@selector(installerDidFinishInstallationWithAcknowledgement:)]) { - [self.delegate installerDidFinishInstallationWithAcknowledgement:acknowledgement]; + if ([self.delegate respondsToSelector:@selector(installerDidFinishInstallationAndRelaunched:acknowledgement:)]) { + [self.delegate installerDidFinishInstallationAndRelaunched:relaunched acknowledgement:acknowledgement]; } else { acknowledgement(); } diff --git a/Sparkle/SPUInstallerDriver.h b/Sparkle/SPUInstallerDriver.h index 9ab98a2a..2426f9a2 100644 --- a/Sparkle/SPUInstallerDriver.h +++ b/Sparkle/SPUInstallerDriver.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently; - (void)installerIsSendingAppTerminationSignal; - (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch; -- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement; +- (void)installerDidFinishInstallationAndRelaunched:(BOOL)relaunch acknowledgement:(void(^)(void))acknowledgement; - (void)installerIsRequestingAbortInstallWithError:(nullable NSError *)error; - (void)installerDidFailToApplyDeltaUpdate; diff --git a/Sparkle/SPUInstallerDriver.m b/Sparkle/SPUInstallerDriver.m index c69f49f1..92797933 100644 --- a/Sparkle/SPUInstallerDriver.m +++ b/Sparkle/SPUInstallerDriver.m @@ -52,7 +52,7 @@ @property (nonatomic) BOOL postponedOnce; @property (nonatomic, weak, readonly) id updater; @property (nonatomic, weak, readonly) id updaterDelegate; -@property (nonatomic) BOOL willRelaunch; +@property (nonatomic) BOOL relaunch; @property (nonatomic) BOOL systemDomain; @@ -78,7 +78,7 @@ @synthesize postponedOnce = _postponedOnce; @synthesize updater = _updater; @synthesize updaterDelegate = _updaterDelegate; -@synthesize willRelaunch = _willRelaunch; +@synthesize relaunch = _relaunch; @synthesize systemDomain = _systemDomain; @synthesize updateItem = _updateItem; @synthesize downloadName = _downloadName; @@ -296,7 +296,7 @@ hasTargetTerminated = (BOOL)*((const uint8_t *)data.bytes); } - [self.delegate installerWillFinishInstallationAndRelaunch:self.willRelaunch]; + [self.delegate installerWillFinishInstallationAndRelaunch:self.relaunch]; if (!hasTargetTerminated) { [self.delegate installerIsSendingAppTerminationSignal]; @@ -307,7 +307,7 @@ [self.installerConnection invalidate]; self.installerConnection = nil; - [self.delegate installerDidFinishInstallationWithAcknowledgement:^{ + [self.delegate installerDidFinishInstallationAndRelaunched:self.relaunch acknowledgement:^{ dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate installerIsRequestingAbortInstallWithError:nil]; }); @@ -498,7 +498,7 @@ // For resumability, we'll assume we are far enough for the installation to continue self.currentStage = SPUInstallationFinishedStage1; - self.willRelaunch = relaunch; + self.relaunch = relaunch; uint8_t response[2] = {(uint8_t)relaunch, (uint8_t)showUI}; NSData *responseData = [NSData dataWithBytes:response length:sizeof(response)]; diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index ec544826..a1808635 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -21,6 +21,10 @@ @interface SPUStandardUserDriver () @property (nonatomic, readonly) SUHost *host; +// We must store the oldHostName before the host is potentially replaced +// because we may use this property after update has been installed +@property (nonatomic, readonly) NSString *oldHostName; +@property (nonatomic, readonly) NSURL *oldHostBundleURL; @property (nonatomic, weak, nullable, readonly) id delegate; @@ -37,6 +41,8 @@ @implementation SPUStandardUserDriver @synthesize host = _host; +@synthesize oldHostName = _oldHostName; +@synthesize oldHostBundleURL = _oldHostBundleURL; @synthesize installUpdateHandler = _installUpdateHandler; @synthesize cancellation = _cancellation; @synthesize delegate = _delegate; @@ -52,6 +58,8 @@ self = [super init]; if (self != nil) { _host = [[SUHost alloc] initWithBundle:hostBundle]; + _oldHostName = _host.name; + _oldHostBundleURL = hostBundle.bundleURL; _delegate = delegate; } return self; @@ -427,11 +435,42 @@ [self.statusController setButtonEnabled:NO]; } -- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement +- (void)showUpdateInstalledAndRelaunched:(BOOL)relaunched acknowledgement:(void (^)(void))acknowledgement { assert(NSThread.isMainThread); - // Deciding not to show anything here + // Close window showing update is installing + [self.statusController close]; + self.statusController = nil; + + // Only show installed prompt when the app is not relaunched + // When the app is relaunched, there is enough of a UI from relaunching the app. + if (!relaunched) { + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = SULocalizedString(@"Update Installed", nil); + + // Extract information from newly updated bundle if available + NSString *hostName; + NSString *hostVersion; + NSBundle *newBundle = [NSBundle bundleWithURL:self.oldHostBundleURL]; + if (newBundle != nil) { + SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle]; + hostName = newHost.name; + hostVersion = newHost.displayVersion; + } else { + // This may happen if Sparkle's normalization is enabled + hostName = self.oldHostName; + hostVersion = nil; + } + + if (hostVersion != nil) { + alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ is now updated to version %@!", nil), hostName, hostVersion]; + } else { + alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ is now updated!", nil), hostName]; + } + [self showAlert:alert]; + } + acknowledgement(); } diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index d361509c..a52fcc76 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -270,9 +270,16 @@ [self.userDriver showSendingTerminationSignal]; } -- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement +- (void)installerDidFinishInstallationAndRelaunched:(BOOL)relaunched acknowledgement:(void(^)(void))acknowledgement { - [self.userDriver showUpdateInstallationDidFinishWithAcknowledgement:acknowledgement]; + if ([self.userDriver respondsToSelector:@selector(showUpdateInstalledAndRelaunched:acknowledgement:)]) { + [self.userDriver showUpdateInstalledAndRelaunched:relaunched acknowledgement:acknowledgement]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [self.userDriver showUpdateInstallationDidFinishWithAcknowledgement:acknowledgement]; +#pragma clang diagnostic pop + } } - (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index 00391c4a..17151457 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -256,12 +256,15 @@ SU_EXPORT @protocol SPUUserDriver * Show the user that the update installation finished * * Let the user know that the update finished installing. - * 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 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. This implementation must not try to reference + * the old bundle prior to the installation, which will no longer be around. + * + * @param relaunched Indicates if the update was relaunched. + * @param acknowledgement Acknowledge to the updater that the finished installation was shown. */ -- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement; +- (void)showUpdateInstalledAndRelaunched:(BOOL)relaunched acknowledgement:(void (^)(void))acknowledgement; /*! * Dismiss the current update installation @@ -279,12 +282,14 @@ SU_EXPORT @protocol SPUUserDriver */ @optional -- (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateNotFoundWithError:acknowledgement: instead"); - - (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion __deprecated_msg("Implement -showUserInitiatedUpdateCheckWithCancellation: instead"); - (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion __deprecated_msg("Implement -showDownloadInitiatedWithCancellation: instead"); +- (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateNotFoundWithError:acknowledgement: instead"); + +- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateInstalledAndRelaunched:acknowledgement: instead"); + @end NS_ASSUME_NONNULL_END diff --git a/TestApplication/SUPopUpTitlebarUserDriver.m b/TestApplication/SUPopUpTitlebarUserDriver.m index 46d58477..e1c28838 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.m +++ b/TestApplication/SUPopUpTitlebarUserDriver.m @@ -277,7 +277,7 @@ [self removeUpdateButton]; } -- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement +- (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement { [self addUpdateButtonWithTitle:@"Installation Finished!"]; diff --git a/sparkle-cli/SPUCommandLineUserDriver.m b/sparkle-cli/SPUCommandLineUserDriver.m index 2ca61bdf..edf05cbd 100644 --- a/sparkle-cli/SPUCommandLineUserDriver.m +++ b/sparkle-cli/SPUCommandLineUserDriver.m @@ -244,7 +244,7 @@ } } -- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement +- (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement { if (self.verbose) { fprintf(stderr, "Installation Finished.\n");