mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Merge pull request #1819 from sparkle-project/user-driver-relaunch
Show alert that non-relaunched application was installed
This commit is contained in:
10 files changed
+79
-22
No files matched your search
Vendored
+6
@@ -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?";
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)installerIsSendingAppTerminationSignal;
|
||||
|
||||
- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement;
|
||||
- (void)installerDidFinishInstallationAndRelaunched:(BOOL)relaunched acknowledgement:(void(^)(void))acknowledgement;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+3
-3
@@ -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();
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -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;
|
||||
|
||||
Vendored
+5
-5
@@ -52,7 +52,7 @@
|
||||
@property (nonatomic) BOOL postponedOnce;
|
||||
@property (nonatomic, weak, readonly) id updater;
|
||||
@property (nonatomic, weak, readonly) id<SPUUpdaterDelegate> 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)];
|
||||
|
||||
Vendored
+41
-2
@@ -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 <SPUStandardUserDriverDelegate> 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();
|
||||
}
|
||||
|
||||
|
||||
Vendored
+9
-2
@@ -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
|
||||
|
||||
Vendored
+11
-6
@@ -256,12 +256,15 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
* 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 <NSObject>
|
||||
*/
|
||||
@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
|
||||
@@ -277,7 +277,7 @@
|
||||
[self removeUpdateButton];
|
||||
}
|
||||
|
||||
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement
|
||||
- (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement
|
||||
{
|
||||
[self addUpdateButtonWithTitle:@"Installation Finished!"];
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user