Move custom version displayer away from SUUpdater delegate

This is a UI related protocol and thus should be part of the user updater driver,
not a part of the core updater.
This commit is contained in:
Zorg committed 2016-03-01 21:09:28 -05:00
1 parent dafdcf21b6
commit d3a09cc68a
8 files changed
+21 -28

No files matched your search

+1 -1
View File
@@ -989,7 +989,6 @@
61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */,
61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */,
61A2259C0D1C495D00430CCD /* SUVersionComparisonProtocol.h */,
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */,
);
name = "Appcast Support";
sourceTree = "<group>";
@@ -1009,6 +1008,7 @@
61B5FCA109C5228F00B25A18 /* SUUpdateAlert.m */,
612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */,
612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */,
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */,
725602D31C83551C00DAA70E /* SUApplicationInfo.h */,
725602D41C83551C00DAA70E /* SUApplicationInfo.m */,
);
+4
View File
@@ -11,6 +11,8 @@
NS_ASSUME_NONNULL_BEGIN
@protocol SUVersionDisplay;
@protocol SUSparkleUserUpdaterDriverDelegate <NSObject>
@optional
@@ -23,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)userUpdaterDriverWillShowModalAlert:(id <SUUserUpdaterDriver>)userUpdaterDriver;
- (void)userUpdaterDriverDidShowModalAlert:(id <SUUserUpdaterDriver>)userUpdaterDriver;
- (_Nullable id <SUVersionDisplay>)versionDisplayerForUserDriver:(id <SUUserUpdaterDriver>)userUpdaterDriver;
@end
@interface SUSparkleUserUpdaterDriver : NSObject <SUUserUpdaterDriver>
+7 -5
View File
@@ -200,18 +200,20 @@
#pragma mark Update Found
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem versionDisplayer:(id<SUVersionDisplay>)versionDisplayer allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates reply:(void (^)(SUUpdateAlertChoice))reply
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates reply:(void (^)(SUUpdateAlertChoice))reply
{
dispatch_async(dispatch_get_main_queue(), ^{
id <SUVersionDisplay> versionDisplayer = nil;
if ([self.delegate respondsToSelector:@selector(versionDisplayerForUserDriver:)]) {
versionDisplayer = [self.delegate versionDisplayerForUserDriver:self];
}
__weak SUSparkleUserUpdaterDriver *weakSelf = self;
SUUpdateAlert *updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem host:self.host allowsAutomaticUpdates:allowsAutomaticUpdates completionBlock:^(SUUpdateAlertChoice choice) {
self.activeUpdateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem host:self.host versionDisplayer:versionDisplayer allowsAutomaticUpdates:allowsAutomaticUpdates completionBlock:^(SUUpdateAlertChoice choice) {
reply(choice);
weakSelf.activeUpdateAlert = nil;
}];
[updateAlert setVersionDisplayer:versionDisplayer];
self.activeUpdateAlert = updateAlert;
[self setUpFocusForActiveUpdateAlert];
});
}
+1 -6
View File
@@ -39,12 +39,7 @@
return;
}
id<SUVersionDisplay> versDisp = nil;
if ([[self.updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
versDisp = [[self.updater delegate] versionDisplayerForUpdater:self.updater];
}
[self.updater.userUpdaterDriver showUpdateFoundWithAppcastItem:self.updateItem versionDisplayer:versDisp allowsAutomaticUpdates:self.updater.allowsAutomaticUpdates reply:^(SUUpdateAlertChoice choice) {
[self.updater.userUpdaterDriver showUpdateFoundWithAppcastItem:self.updateItem allowsAutomaticUpdates:self.updater.allowsAutomaticUpdates reply:^(SUUpdateAlertChoice choice) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateAlertFinishedWithChoice:choice];
});
+2 -2
View File
@@ -18,9 +18,9 @@
@class SUAppcastItem, SUHost;
@interface SUUpdateAlert : NSWindowController
@property (weak) id<SUVersionDisplay> versionDisplayer;
@property (nonatomic, weak, readonly) id <SUVersionDisplay> versionDisplayer;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates completionBlock:(void(^)(SUUpdateAlertChoice))c;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host versionDisplayer:(id <SUVersionDisplay>)versionDisplayer allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates completionBlock:(void(^)(SUUpdateAlertChoice))c;
- (IBAction)installUpdate:sender;
- (IBAction)skipThisVersion:sender;
+2 -1
View File
@@ -70,7 +70,7 @@
@synthesize skipButton;
@synthesize laterButton;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates completionBlock:(void (^)(SUUpdateAlertChoice))block
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates completionBlock:(void (^)(SUUpdateAlertChoice))block
{
self = [super initWithWindowNibName:@"SUUpdateAlert"];
if (self)
@@ -78,6 +78,7 @@
self.completionBlock = block;
host = aHost;
updateItem = item;
versionDisplayer = aVersionDisplayer;
_allowsAutomaticUpdates = allowsAutomaticUpdates;
[self setShouldCascadeWindows:NO];
+3 -10
View File
@@ -12,7 +12,6 @@
#import <Foundation/Foundation.h>
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
#import "SUUserUpdaterDriver.h"
@class SUAppcastItem, SUAppcast;
@@ -310,16 +309,10 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
/*!
Returns an object that formats version numbers for display to the user.
If you don't implement this method or return \c nil,
the standard version formatter will be used.
\sa SUUpdateAlert
\param updater The SUUpdater instance.
@deprecated This method is no longer used. See SUSparkleUserUpdaterDriver delegate instead.
*/
- (id<SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
// Don't specify SUVersionDisplay in the return type, otherwise we'd have to forward declare a protocol that isn't used here anymore
- (id)versionDisplayerForUpdater:(SUUpdater *)updater __deprecated;
/*!
Returns the path which is used to relaunch the client after the update is installed.
+1 -3
View File
@@ -12,7 +12,6 @@
NS_ASSUME_NONNULL_BEGIN
@class SUUpdatePermissionPromptResult, SUAppcastItem;
@protocol SUVersionDisplay;
/*!
The API in Sparkle for controlling the user update interaction.
@@ -105,7 +104,6 @@ NS_ASSUME_NONNULL_BEGIN
* Let the user know a new update is found and ask them what they want to do.
*
* @param appcastItem The Appcast Item containing information that reflects the new update
* @param versionDisplayer The custom version displayer for showing the update's version string - this may be nil.
* @param allowsAutomaticUpdates Indicates whether the user is allowed to use automatic updates.
* A user interface may use this to give the user an option to enable automatic updates.
* @param reply A reply of SUInstallUpdateChoice installs the new update immediately. A reply of
@@ -115,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* This can be called from any thread
*/
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem versionDisplayer:(_Nullable id <SUVersionDisplay>)versionDisplayer allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates reply:(void (^)(SUUpdateAlertChoice))reply;
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates reply:(void (^)(SUUpdateAlertChoice))reply;
/*!
* Show the user a new update that was already automatically downloaded is available