Remove -updaterIsRequestingQuit: delegate callback and use user driver instead

This way we remove delegate responsibility duplication and this should make backwards compatibility easier
This commit is contained in:
Zorg committed 2016-08-05 19:39:12 -04:00
1 parent c9f673cda8
commit ca36d9963e
4 files changed
+13 -23

No files matched your search

+1
View File
@@ -387,6 +387,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
initWithHost:strongSelf.host
sparkleBundle:strongSelf.sparkleBundle
updater:strongSelf.delegator
userDriver:strongSelf.userDriver
updaterDelegate:strongSelf.delegate];
} else {
updateDriver =
+2 -2
View File
@@ -12,11 +12,11 @@
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
@protocol SUUpdaterDelegate;
@protocol SUUpdaterDelegate, SPUUserDriver;
@interface SUAutomaticUpdateDriver : NSObject <SUUpdateDriver>
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate;
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate;
@end
+8 -7
View File
@@ -13,6 +13,7 @@
#import "SUCoreBasedUpdateDriver.h"
#import "SULog.h"
#import "SUAppcastItem.h"
#import "SPUUserDriver.h"
#import "SUErrors.h"
#ifdef _APPKITDEFINES_H
@@ -22,6 +23,7 @@
@interface SUAutomaticUpdateDriver () <SUCoreBasedUpdateDriverDelegate>
@property (nonatomic, readonly, weak) id updater;
@property (nonatomic, readonly, weak) id<SPUUserDriver> userDriver;
@property (nonatomic, readonly, weak, nullable) id updaterDelegate;
@property (nonatomic, readonly) SUCoreBasedUpdateDriver *coreDriver;
@property (nonatomic) SUAppcastItem* updateItem;
@@ -32,16 +34,19 @@
@implementation SUAutomaticUpdateDriver
@synthesize updater = _updater;
@synthesize userDriver = _userDriver;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize coreDriver = _coreDriver;
@synthesize updateItem = _updateItem;
@synthesize willInstallSilently = _willInstallSilently;
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate
{
self = [super init];
if (self != nil) {
_updater = updater;
// The user driver is only used for a termination callback
_userDriver = userDriver;
_updaterDelegate = updaterDelegate;
_coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
}
@@ -83,8 +88,7 @@
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:^{
installationHandledByDelegate = [updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
[weakSelf.coreDriver finishInstallationWithResponse:SUInstallAndRelaunchUpdateNow displayingUserInterface:NO];
}];
}
@@ -101,10 +105,7 @@
// otherwise the update driver will abort the update before then
- (void)installerIsRequestingAppTermination
{
id<SUUpdaterDelegate> updaterDelegate = self.updaterDelegate;
if ([updaterDelegate respondsToSelector:@selector(updaterIsRequestingQuit:)]) {
[updaterDelegate updaterIsRequestingQuit:self.updater];
}
[self.userDriver terminateApplication];
}
- (void)basicDriverIsRequestingAbortUpdateWithError:(NSError *)error
+2 -14
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: and -updaterIsRequestingQuit: instead. This method is no longer invoked.
\deprecated See -updater:willInstallUpdateOnQuit:immediateInstallationBlock: instead. This method is no longer invoked.
*/
- (void)updater:(id)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation __deprecated;
@@ -300,8 +300,7 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
\param updater The updater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param immediateInstallHandler The install handler to immediately install the update.
If you plan to invoke this, you must return YES from this method and also implement -updaterIsRequestingQuit:
\param immediateInstallHandler The install handler to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation.
\return Return YES if the delegate will handle installing the update or NO if the updater should be given responsibility.
If the updater is given responsibility, it can later remind the user an update is available if they have not terminated the application for a long time.
@@ -310,17 +309,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (BOOL)updater:(id)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
/*!
Called when the updater requests to quit the application after the delegate invoked its installation block from -updater:willInstallUpdateOnQuit:immediateInstallationBlock:
\param updater the updater instance.
The delegate should terminate the application so the installer can immediately install the update.
After the application is terminated, the installer will install the update and the application will be relaunched.
The installer will not show any UI interaction.
*/
- (void)updaterIsRequestingQuit:(id)updater;
/*!
Calls after an update that was scheduled to be silently installed on quit has been canceled.