Handle deprecated updater will install on quit callback

I may have to reconsider the design of this API in general.
This commit is contained in:
Zorg committed 2016-08-05 21:18:08 -04:00
1 parent ca36d9963e
commit 86e026588b
2 files changed
+34 -6

No files matched your search

+33 -5
View File
@@ -79,6 +79,12 @@
[self.coreDriver downloadUpdateFromAppcastItem:updateItem];
}
// Method used for backwards compatibility for the updater delegate
- (void)finishInstallationAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showingUI
{
[self.coreDriver finishInstallationWithResponse:(relaunch ? SUInstallAndRelaunchUpdateNow : SUInstallUpdateNow) displayingUserInterface:showingUI];
}
- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently
{
self.willInstallSilently = willInstallSilently;
@@ -86,11 +92,33 @@
if (!willInstallImmediately) {
BOOL installationHandledByDelegate = NO;
id<SUUpdaterDelegate> updaterDelegate = self.updaterDelegate;
if (self.willInstallSilently && [updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)]) {
__weak SUAutomaticUpdateDriver *weakSelf = self;
installationHandledByDelegate = [updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
[weakSelf.coreDriver finishInstallationWithResponse:SUInstallAndRelaunchUpdateNow displayingUserInterface:NO];
}];
if (self.willInstallSilently) {
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)]) {
__weak SUAutomaticUpdateDriver *weakSelf = self;
installationHandledByDelegate = [updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
[weakSelf.coreDriver finishInstallationWithResponse:SUInstallAndRelaunchUpdateNow displayingUserInterface:NO];
}];
} else if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)]) {
// Just for backwards compatibility
BOOL relaunch = YES;
BOOL showUI = NO;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(finishInstallationAndRelaunch:displayingUserInterface:)]];
[invocation setSelector:@selector(finishInstallationAndRelaunch:displayingUserInterface:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setArgument:&showUI atIndex:3];
[invocation setTarget:self];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
#pragma clang diagnostic pop
// We have to assume they will handle the installation since they implement this method
// Not ideal, but this is why this delegate callback is deprecated
installationHandledByDelegate = YES;
}
}
if (!installationHandledByDelegate) {
+1 -1
View File
@@ -291,7 +291,7 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
\param item The appcast item corresponding to the update that is proposed to be installed.
\param invocation Can be used to trigger an immediate silent install and relaunch.
\deprecated See -updater:willInstallUpdateOnQuit:immediateInstallationBlock: instead. This method is no longer invoked.
\deprecated See -updater:willInstallUpdateOnQuit:immediateInstallationBlock: instead. If this method is implemented, Sparkle will assume the delegate is given responsibility to handling the update without a choice. For this reason, please don't implement this method.
*/
- (void)updater:(id)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation __deprecated;