diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 01d75f84..3daad439 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -989,7 +989,6 @@ 61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */, 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */, 61A2259C0D1C495D00430CCD /* SUVersionComparisonProtocol.h */, - 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */, ); name = "Appcast Support"; sourceTree = ""; @@ -1009,6 +1008,7 @@ 61B5FCA109C5228F00B25A18 /* SUUpdateAlert.m */, 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */, 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */, + 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */, 725602D31C83551C00DAA70E /* SUApplicationInfo.h */, 725602D41C83551C00DAA70E /* SUApplicationInfo.m */, ); diff --git a/Sparkle/SUSparkleUserUpdaterDriver.h b/Sparkle/SUSparkleUserUpdaterDriver.h index 6efa9f46..ea7b2e90 100644 --- a/Sparkle/SUSparkleUserUpdaterDriver.h +++ b/Sparkle/SUSparkleUserUpdaterDriver.h @@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN +@protocol SUVersionDisplay; + @protocol SUSparkleUserUpdaterDriverDelegate @optional @@ -23,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)userUpdaterDriverWillShowModalAlert:(id )userUpdaterDriver; - (void)userUpdaterDriverDidShowModalAlert:(id )userUpdaterDriver; +- (_Nullable id )versionDisplayerForUserDriver:(id )userUpdaterDriver; + @end @interface SUSparkleUserUpdaterDriver : NSObject diff --git a/Sparkle/SUSparkleUserUpdaterDriver.m b/Sparkle/SUSparkleUserUpdaterDriver.m index e7915f36..dd6a38b8 100644 --- a/Sparkle/SUSparkleUserUpdaterDriver.m +++ b/Sparkle/SUSparkleUserUpdaterDriver.m @@ -200,18 +200,20 @@ #pragma mark Update Found -- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem versionDisplayer:(id)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 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]; }); } diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 481b01df..4068b254 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -39,12 +39,7 @@ return; } - id 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]; }); diff --git a/Sparkle/SUUpdateAlert.h b/Sparkle/SUUpdateAlert.h index d6ccda23..7b31757c 100644 --- a/Sparkle/SUUpdateAlert.h +++ b/Sparkle/SUUpdateAlert.h @@ -18,9 +18,9 @@ @class SUAppcastItem, SUHost; @interface SUUpdateAlert : NSWindowController -@property (weak) id versionDisplayer; +@property (nonatomic, weak, readonly) id versionDisplayer; -- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates completionBlock:(void(^)(SUUpdateAlertChoice))c; +- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host versionDisplayer:(id )versionDisplayer allowsAutomaticUpdates:(BOOL)allowsAutomaticUpdates completionBlock:(void(^)(SUUpdateAlertChoice))c; - (IBAction)installUpdate:sender; - (IBAction)skipThisVersion:sender; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index bc8818eb..e470e10f 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -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 )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]; diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index 4f29c449..d1011768 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -12,7 +12,6 @@ #import #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)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)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. diff --git a/Sparkle/SUUserUpdaterDriver.h b/Sparkle/SUUserUpdaterDriver.h index 1fd8137b..18436991 100644 --- a/Sparkle/SUUserUpdaterDriver.h +++ b/Sparkle/SUUserUpdaterDriver.h @@ -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 )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