mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-29 05:24:26 +00:00
Add the old and a new postpone relaunch hook to the install driver
This commit is contained in:
1 parent
704518278c
commit
702a1dffc0
2 files changed
+48
-10
No files matched your search
Vendored
+28
-9
@@ -529,6 +529,12 @@
|
||||
return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]);
|
||||
}
|
||||
|
||||
// Only implemented due to backwards compability reasons; see -installWithToolAndRelaunch:displayingUserInterface: below
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
assert(self.updateItem);
|
||||
@@ -540,16 +546,29 @@
|
||||
}
|
||||
|
||||
// Give the host app an opportunity to postpone the install and relaunch.
|
||||
if (!self.postponedOnce && [self.updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
if (!self.postponedOnce)
|
||||
{
|
||||
// NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
// [invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
// [invocation setArgument:&relaunch atIndex:2];
|
||||
// [invocation setTarget:self];
|
||||
// self.postponedOnce = YES;
|
||||
// if ([self.updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||
// return;
|
||||
// }
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvokingBlock:)]) {
|
||||
self.postponedOnce = YES;
|
||||
__weak SUInstallerDriver *weakSelf = self;
|
||||
if ([self.updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvokingBlock:^{
|
||||
[weakSelf installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
||||
}]) {
|
||||
return;
|
||||
}
|
||||
} else if ([self.updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) {
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setTarget:self];
|
||||
self.postponedOnce = YES;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
if ([self.updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||
#pragma clang diagnostic pop
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set up local and remote ports to the installer if they are not set up already
|
||||
|
||||
Vendored
+20
-1
@@ -148,18 +148,37 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
\deprecated Use -updater:shouldPostponeRelaunchForUpdate:untilInvokingBlock: instead
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
in that case it will immediately restart.
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation The invocation that must be completed before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p invocation is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation __deprecated;
|
||||
|
||||
/*!
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
in that case it will immediately restart.
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param installHandler The install handler that must be completed before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p installHandler is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler;
|
||||
|
||||
/*!
|
||||
Returns whether the application should be relaunched at all.
|
||||
|
||||
Reference in new issue
Block a user