Migrate canCheckForUpdates property from user driver -> updater

This commit is contained in:
Zorg committed 2021-01-17 17:01:48 -08:00
1 parent 7896b5ab44
commit 2066cd7232
16 files changed
+32 -115

No files matched your search

-4
View File
@@ -218,7 +218,6 @@
725F97841C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97831C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m */; };
725F97A51C8B304D00265BE4 /* SUInstallUpdateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97A31C8B304D00265BE4 /* SUInstallUpdateViewController.m */; };
725F97A61C8B304D00265BE4 /* SUInstallUpdateViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 725F97A41C8B304D00265BE4 /* SUInstallUpdateViewController.xib */; };
725F97A81C8B42D700265BE4 /* SPUStandardUserDriverProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 725F97A71C8B42D700265BE4 /* SPUStandardUserDriverProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
7267E5751D3D895B00D1BF90 /* SUBinaryDeltaApply.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E56F1D3D895B00D1BF90 /* SUBinaryDeltaApply.m */; };
7267E5761D3D895B00D1BF90 /* SUBinaryDeltaApply.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E56F1D3D895B00D1BF90 /* SUBinaryDeltaApply.m */; };
7267E5771D3D895B00D1BF90 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5711D3D895B00D1BF90 /* SUBinaryDeltaCommon.m */; };
@@ -1197,7 +1196,6 @@
725F97A21C8B304D00265BE4 /* SUInstallUpdateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUInstallUpdateViewController.h; sourceTree = "<group>"; };
725F97A31C8B304D00265BE4 /* SUInstallUpdateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallUpdateViewController.m; sourceTree = "<group>"; };
725F97A41C8B304D00265BE4 /* SUInstallUpdateViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SUInstallUpdateViewController.xib; sourceTree = "<group>"; };
725F97A71C8B42D700265BE4 /* SPUStandardUserDriverProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUStandardUserDriverProtocol.h; sourceTree = "<group>"; };
7267E56E1D3D895B00D1BF90 /* SUBinaryDeltaApply.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUBinaryDeltaApply.h; path = Autoupdate/SUBinaryDeltaApply.h; sourceTree = SOURCE_ROOT; };
7267E56F1D3D895B00D1BF90 /* SUBinaryDeltaApply.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUBinaryDeltaApply.m; path = Autoupdate/SUBinaryDeltaApply.m; sourceTree = SOURCE_ROOT; };
7267E5701D3D895B00D1BF90 /* SUBinaryDeltaCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUBinaryDeltaCommon.h; path = Autoupdate/SUBinaryDeltaCommon.h; sourceTree = SOURCE_ROOT; };
@@ -2126,7 +2124,6 @@
725CB9581C7121830064365A /* SPUStandardUserDriver.h */,
725CB9591C7121830064365A /* SPUStandardUserDriver.m */,
726E4A361C89116000C57C6A /* SPUStandardUserDriverDelegate.h */,
725F97A71C8B42D700265BE4 /* SPUStandardUserDriverProtocol.h */,
726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */,
725CB9561C7120410064365A /* SPUUserDriver.h */,
725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */,
@@ -2426,7 +2423,6 @@
7246E0A31C83B685003B4E75 /* SPUStandardUpdaterController.h in Headers */,
725CB95A1C7121830064365A /* SPUStandardUserDriver.h in Headers */,
726E4A371C89116000C57C6A /* SPUStandardUserDriverDelegate.h in Headers */,
725F97A81C8B42D700265BE4 /* SPUStandardUserDriverProtocol.h in Headers */,
726DF88E1C84277600188804 /* SPUStatusCompletionResults.h in Headers */,
72B767DA1C9CD2E400A07552 /* SPUUIBasedUpdateDriver.h in Headers */,
7229E1B61C97C91100CB50D0 /* SPUUpdateDriver.h in Headers */,
+4 -3
View File
@@ -19,7 +19,8 @@
NS_ASSUME_NONNULL_BEGIN
@class SPUUpdater;
@protocol SPUUserDriver, SPUStandardUserDriverProtocol, SPUUpdaterDelegate, SPUStandardUserDriverDelegate;
@class SPUStandardUserDriver;
@protocol SPUUserDriver, SPUUpdaterDelegate, SPUStandardUserDriverDelegate;
/*!
A controller class that instantiates a SPUUpdater and allows binding UI to it.
@@ -67,7 +68,7 @@ SU_EXPORT @interface SPUStandardUpdaterController : NSObject
This is nil before being loaded from the nib.
You may access this property after your application has finished launching, or after your window controller has finished loading.
*/
@property (nonatomic, readonly, nullable) id <SPUStandardUserDriverProtocol> userDriver;
@property (nonatomic, readonly, nullable) SPUStandardUserDriver *userDriver;
/*!
Use initWithUpdaterDelegate:userDriverDelegate: instead.
@@ -94,7 +95,7 @@ SU_EXPORT @interface SPUStandardUpdaterController : NSObject
/*!
Validates if the menu item for checkForUpdates: can be invoked or not
This validates the menu item by checking -[SPUStandardUserDriver canCheckForUpdates]
This validates the menu item by checking -SPUUpdater.canCheckForUpdates
*/
- (BOOL)validateMenuItem:(NSMenuItem *)item;
+3 -3
View File
@@ -18,7 +18,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
@interface SPUStandardUpdaterController ()
@property (nonatomic) SPUUpdater *updater;
@property (nonatomic) id <SPUStandardUserDriverProtocol> userDriver;
@property (nonatomic) SPUStandardUserDriver *userDriver;
@property (nonatomic) BOOL initializedUpdater;
@end
@@ -56,7 +56,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
self.initializedUpdater = YES;
NSBundle *hostBundle = [NSBundle mainBundle];
id <SPUUserDriver, SPUStandardUserDriverProtocol> userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:self.userDriverDelegate];
SPUStandardUserDriver *userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:self.userDriverDelegate];
self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle applicationBundle:hostBundle userDriver:userDriver delegate:self.updaterDelegate];
self.userDriver = userDriver;
@@ -93,7 +93,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(checkForUpdates:)) {
return self.userDriver.canCheckForUpdates;
return self.updater.canCheckForUpdates;
}
return YES;
}
+1 -2
View File
@@ -15,7 +15,6 @@
#import <Cocoa/Cocoa.h>
#endif
#import "SPUUserDriver.h"
#import "SPUStandardUserDriverProtocol.h"
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
@@ -25,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
/*!
Sparkle's standard built-in user driver for updater interactions
*/
SU_EXPORT @interface SPUStandardUserDriver : NSObject <SPUUserDriver, SPUStandardUserDriverProtocol>
SU_EXPORT @interface SPUStandardUserDriver : NSObject <SPUUserDriver>
/*!
Initializes a Sparkle's standard user driver for user update interactions
-16
View File
@@ -56,22 +56,6 @@
return self;
}
#pragma mark Is Update Busy?
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
assert(NSThread.isMainThread);
[self.coreComponent showCanCheckForUpdates:canCheckForUpdates];
}
- (BOOL)canCheckForUpdates
{
assert(NSThread.isMainThread);
return self.coreComponent.canCheckForUpdates;
}
#pragma mark Update Permission
- (void)showUpdatePermissionRequest:(SPUUpdatePermissionRequest *)request reply:(void (^)(SUUpdatePermissionResponse *))reply
-35
View File
@@ -1,35 +0,0 @@
//
// SPUStandardUserDriverProtocol.h
// Sparkle
//
// Created by Mayur Pawashe on 3/5/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
@protocol SPUStandardUserDriverDelegate;
/*!
Protocol for Sparkle's standard built-in user driver for updater interactions.
Other user drivers may wish to implement this protocol.
Note that this protocol does not adopt SUUserDriver because one may want to *only* export properties from this protocol.
*/
@protocol SPUStandardUserDriverProtocol <NSObject>
/*!
Indicates whether or not an update is in progress as far as the user's perspective is concerned
A typical application may rely on this property for its check for updates menu item validation
*/
@property (nonatomic, readonly) BOOL canCheckForUpdates;
@end
+11
View File
@@ -103,6 +103,17 @@ SU_EXPORT @interface SPUUpdater : NSObject
*/
- (void)checkForUpdateInformation;
/*!
A property indicating whether or not updates can be checked.
This property is useful for determing whether update checks can be made programatically or by the user.
An update check cannot be made when an on-going update check is in progress.
Note this property does not reflect whether or not an update itself is in progress. For example,
an update check can be done to check if there's an already started update that can be resumed.
*/
@property (nonatomic, readonly) BOOL canCheckForUpdates;
/*!
A property indicating whether or not to check for updates automatically.
+5 -3
View File
@@ -56,6 +56,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@property (nonatomic) BOOL startedUpdater;
@property (nonatomic, copy) void (^preStartedScheduledUpdateBlock)(void);
@property (nonatomic, nullable) id<SPUResumableUpdate> resumableUpdate;
@property (nonatomic) BOOL canCheckForUpdates;
@property (nonatomic) BOOL loggedATSWarning;
@property (nonatomic) BOOL loggedDSAWarning;
@@ -78,6 +79,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize startedUpdater = _startedUpdater;
@synthesize preStartedScheduledUpdateBlock = _preStartedScheduledUpdateBlock;
@synthesize resumableUpdate = _resumableUpdate;
@synthesize canCheckForUpdates = _canCheckForUpdates;
@synthesize loggedATSWarning = _loggedATSWarning;
@synthesize loggedDSAWarning = _loggedDSAWarning;
@@ -345,7 +347,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
BOOL automaticallyCheckForUpdates = [self automaticallyChecksForUpdates];
[self.userDriver showCanCheckForUpdates:!automaticallyCheckForUpdates];
self.canCheckForUpdates = !automaticallyCheckForUpdates;
if (!automaticallyCheckForUpdates) {
if ([self.delegate respondsToSelector:@selector(updaterWillIdleSchedulingUpdates:)]) {
@@ -357,7 +359,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
if (firingImmediately) {
[self checkForUpdatesInBackground];
} else {
[self.userDriver showCanCheckForUpdates:YES];
self.canCheckForUpdates = YES;
[self retrieveNextUpdateCheckInterval:^(NSTimeInterval updateCheckInterval) {
// This callback is asynchronous, so the timer may be set. Invalidate to make sure it isn't.
@@ -553,7 +555,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
}
};
[self.userDriver showCanCheckForUpdates:NO];
self.canCheckForUpdates = NO;
if (installerInProgress) {
[self.driver resumeInstallingUpdateWithCompletion:completionBlock];
-10
View File
@@ -43,16 +43,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
SU_EXPORT @protocol SPUUserDriver <NSObject>
/*!
* Show that an update can be checked by the user or not
*
* A client may choose to update the interface letting the user know if they can check for updates.
* For example, this can be used for menu item validation on the "Check for Updates" action.
*
* This can be called from any thread.
*/
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates;
/*!
* Show an updater permission request to the user
*
-4
View File
@@ -21,10 +21,6 @@
SU_EXPORT @interface SPUUserDriverCoreComponent : NSObject
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates;
@property (nonatomic, readonly) BOOL canCheckForUpdates;
- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler;
- (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice;
-10
View File
@@ -13,8 +13,6 @@
@interface SPUUserDriverCoreComponent ()
@property (nonatomic) BOOL canCheckForUpdates;
@property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus);
@property (nonatomic, copy) void (^updateCheckStatusCompletion)(SPUUserInitiatedCheckStatus);
@property (nonatomic, copy) void (^downloadStatusCompletion)(SPUDownloadUpdateStatus);
@@ -24,19 +22,11 @@
@implementation SPUUserDriverCoreComponent
@synthesize canCheckForUpdates = _canCheckForUpdates;
@synthesize installUpdateHandler = _installUpdateHandler;
@synthesize updateCheckStatusCompletion = _updateCheckStatusCompletion;
@synthesize downloadStatusCompletion = _downloadStatusCompletion;
@synthesize acknowledgement = _acknowledgement;
#pragma mark Is Update Busy?
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
self.canCheckForUpdates = canCheckForUpdates;
}
#pragma mark Install Updates
- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler
+4 -2
View File
@@ -192,7 +192,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(checkForUpdates:)) {
return self.userDriver.canCheckForUpdates;
return self.updater.canCheckForUpdates;
}
return YES;
}
@@ -214,7 +214,9 @@ static NSMutableDictionary *sharedUpdaters = nil;
- (BOOL)updateInProgress
{
return !self.userDriver.canCheckForUpdates;
// This is not quite true -- we may be able to check / resume an update if one is in progress
// But this is a close enough approximation for 1.x updater API
return !self.updater.canCheckForUpdates;
}
// Not implemented properly at the moment - leaning towards it not be in the future
+1 -1
View File
@@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import <Sparkle/Sparkle.h>
@interface SUPopUpTitlebarUserDriver : NSObject <SPUUserDriver, SPUStandardUserDriverProtocol>
@interface SUPopUpTitlebarUserDriver : NSObject <SPUUserDriver>
- (instancetype)initWithWindow:(NSWindow *)window;
@@ -99,20 +99,6 @@
self.updateButtonAction = nil;
}
#pragma mark Can Check for Updates?
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.coreComponent showCanCheckForUpdates:canCheckForUpdates];
});
}
- (BOOL)canCheckForUpdates
{
return self.coreComponent.canCheckForUpdates;
}
#pragma mark Update Permission
- (void)showUpdatePermissionRequest:(SPUUpdatePermissionRequest *)__unused request reply:(void (^)(SUUpdatePermissionResponse *))reply
@@ -14,7 +14,7 @@
@property (nonatomic) SPUUpdater *updater;
@property (nonatomic, readonly) BOOL customUserDriver;
@property (nonatomic) id<SPUStandardUserDriverProtocol> userDriver;
@property (nonatomic) SPUStandardUserDriver *userDriver;
@end
@@ -43,7 +43,7 @@
NSBundle *hostBundle = [NSBundle mainBundle];
NSBundle *applicationBundle = hostBundle;
id<SPUUserDriver, SPUStandardUserDriverProtocol> userDriver;
id<SPUUserDriver> userDriver;
if (self.customUserDriver) {
userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithWindow:self.window];
} else {
@@ -73,7 +73,7 @@
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
if (menuItem.action == @selector(checkForUpdates:)) {
return self.userDriver.canCheckForUpdates;
return self.updater.canCheckForUpdates;
}
return YES;
}
-5
View File
@@ -44,11 +44,6 @@
return self;
}
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates
{
[self.coreComponent showCanCheckForUpdates:canCheckForUpdates];
}
- (void)showUpdatePermissionRequest:(SPUUpdatePermissionRequest *)__unused request reply:(void (^)(SUUpdatePermissionResponse *))reply
{
if (self.updatePermissionResponse == nil) {