mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Show alert that non-relaunched application was installed
This only applies when the updater outlives the application it is updating and the application is not relaunched (i.e, an external/remote updater).
This commit is contained in:
1 parent
1f90f7c993
commit
e909c0d988
9 files changed
+72
-20
No files matched your search
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
+42
-2
@@ -22,6 +22,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, readonly) SPUUserDriverCoreComponent *coreComponent;
|
||||
@property (nonatomic, weak, nullable, readonly) id <SPUStandardUserDriverDelegate> delegate;
|
||||
@@ -36,6 +40,8 @@
|
||||
@implementation SPUStandardUserDriver
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize oldHostName = _oldHostName;
|
||||
@synthesize oldHostBundleURL = _oldHostBundleURL;
|
||||
@synthesize coreComponent = _coreComponent;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize checkingController = _checkingController;
|
||||
@@ -50,6 +56,8 @@
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
_oldHostName = _host.name;
|
||||
_oldHostBundleURL = hostBundle.bundleURL;
|
||||
_delegate = delegate;
|
||||
_coreComponent = [[SPUUserDriverCoreComponent alloc] init];
|
||||
}
|
||||
@@ -421,12 +429,44 @@
|
||||
[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;
|
||||
|
||||
[self.coreComponent registerAcknowledgement:acknowledgement];
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
[self.coreComponent acceptAcknowledgement];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+9
-2
@@ -259,9 +259,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
+9
-4
@@ -273,12 +273,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, which only happens if the application was running before installing the update.
|
||||
* @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
|
||||
@@ -293,6 +296,8 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
|
||||
- (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
|
||||
@@ -292,7 +292,7 @@
|
||||
[self removeUpdateButton];
|
||||
}
|
||||
|
||||
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement
|
||||
- (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement
|
||||
{
|
||||
[self.coreComponent registerAcknowledgement:acknowledgement];
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement
|
||||
- (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement
|
||||
{
|
||||
[self.coreComponent registerAcknowledgement:acknowledgement];
|
||||
|
||||
|
||||
Reference in new issue
Block a user