Add acknowledgement handler to installation did finish

This commit is contained in:
Zorg committed 2016-08-13 09:50:19 -04:00
1 parent f65f4beda8
commit 6dddbcc353
9 files changed
+41 -22

No files matched your search

+4 -2
View File
@@ -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
+3 -1
View File
@@ -268,9 +268,11 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
* 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
+1 -1
View File
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)installerIsRequestingAppTermination;
- (void)installerDidFinishInstallation;
- (void)installerDidFinishInstallationWithAcknowledgement:(void(^)(void))acknowledgement;
@end
+5 -3
View File
@@ -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();
}
}
+1 -1
View File
@@ -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;
+5 -2
View File
@@ -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]];
+2 -2
View File
@@ -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
+15 -9
View File
@@ -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];
});
}
+5 -1
View File
@@ -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];
});
}