Show or dismiss installation progress after sending termination request

Whether we show or dismiss progress depends on whether the current application (from the user driver) is being terminated or not.
This commit is contained in:
Zorg committed 2016-08-14 14:32:44 -04:00
1 parent bbfcd564d2
commit 55e906ba3e
5 files changed
+48 -21

No files matched your search

+22 -13
View File
@@ -379,19 +379,26 @@
});
}
- (void)_showInstallingUpdate
{
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[self.statusController setButtonEnabled:NO];
}
- (void)showInstallingUpdate
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[self.statusController setButtonEnabled:NO];
[self _showInstallingUpdate];
});
}
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement
{
// Deciding not to show anything here
[self.coreComponent registerAcknowledgement:acknowledgement];
[self.coreComponent acceptAcknowledgement];
dispatch_async(dispatch_get_main_queue(), ^{
// Deciding not to show anything here
[self.coreComponent registerAcknowledgement:acknowledgement];
[self.coreComponent acceptAcknowledgement];
});
}
#pragma mark Aborting Everything
@@ -399,13 +406,6 @@
- (void)terminateApplication
{
dispatch_async(dispatch_get_main_queue(), ^{
// if a user chooses to NOT relaunch the app (as is the case with WebKit
// when it asks you if you are sure you want to close the app with multiple
// tabs open), the status window still stays on the screen and obscures
// other windows; with this fix, it doesn't
[self.statusController close];
self.statusController = nil;
// Give the delegate a deferred chance for providing an application path
// This is a private API and used by SUUpdater
NSString *applicationPath = nil;
@@ -421,7 +421,16 @@
applicationBundle = self.applicationBundle;
}
[self.uiComponent terminateApplicationForBundle:applicationBundle];
if ([self.uiComponent terminateApplicationForBundleAndWillTerminateCurrentApplication:applicationBundle]) {
// if a user chooses to NOT relaunch the app (as is the case with WebKit
// when it asks you if you are sure you want to close the app with multiple
// tabs open), the status window still stays on the screen and obscures
// other windows; with this fix, it doesn't
[self.statusController close];
self.statusController = nil;
} else {
[self _showInstallingUpdate];
}
});
}
+5 -4
View File
@@ -252,11 +252,12 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
- (void)showInstallingUpdate;
/*!
* Terminate the application
* Terminate the application and show or dismiss installer progress.
*
* Sparkle is signaling that it wants the application to request for application termination.
* Care should be taken if the request for application termination fails or is delayed.
* Eg: may want to hide installation status windows in case termination doesn't happen right away
* Sparkle is asking us to send a request to terminate the application.
*
* If this will terminate the current application, one may decide to dismiss progress UI in case the termination request is delayed or canceled.
* Or if this will terminate a remote application, one may decide to show the user that the update is currently installing.
*
* This can be called from any thread
*/
+2
View File
@@ -15,6 +15,8 @@ SU_EXPORT @interface SPUUserDriverUIComponent : NSObject
- (instancetype)init;
- (BOOL)terminateApplicationForBundleAndWillTerminateCurrentApplication:(NSBundle *)bundle;
- (void)terminateApplicationForBundle:(NSBundle *)bundle;
- (BOOL)applicationIsAliveForBundle:(NSBundle *)bundle;
+13
View File
@@ -21,10 +21,23 @@
- (void)terminateApplicationForBundle:(NSBundle *)bundle
{
[self terminateApplicationForBundleAndWillTerminateCurrentApplication:bundle];
}
- (BOOL)terminateApplicationForBundleAndWillTerminateCurrentApplication:(NSBundle *)bundle
{
NSRunningApplication *currentRunningApplication = [NSRunningApplication currentApplication];
BOOL willTerminateSelf = NO;
NSArray<NSRunningApplication *> *runningApplications = [SPUApplicationInfo runningApplicationsWithBundle:bundle];
for (NSRunningApplication *runningApplication in runningApplications) {
if (!willTerminateSelf && [currentRunningApplication isEqual:runningApplication]) {
willTerminateSelf = YES;
}
[runningApplication terminate];
}
return willTerminateSelf;
}
- (BOOL)applicationIsAliveForBundle:(NSBundle *)bundle
+6 -4
View File
@@ -330,10 +330,12 @@
- (void)terminateApplication
{
dispatch_async(dispatch_get_main_queue(), ^{
// In case our termination request fails or is delayed
[self removeUpdateButton];
[self.uiComponent terminateApplicationForBundle:self.applicationBundle];
if ([self.uiComponent terminateApplicationForBundleAndWillTerminateCurrentApplication:self.applicationBundle]) {
// In case our termination request fails or is delayed
[self removeUpdateButton];
} else {
[self addUpdateButtonWithTitle:@"Installing…"];
}
});
}