diff --git a/Sparkle/SPUUpdaterSettings.h b/Sparkle/SPUUpdaterSettings.h index e2969b6639..a480a42aaf 100644 --- a/Sparkle/SPUUpdaterSettings.h +++ b/Sparkle/SPUUpdaterSettings.h @@ -31,6 +31,12 @@ SU_EXPORT @interface SPUUpdaterSettings : NSObject */ @property (readonly, nonatomic) NSTimeInterval updateCheckInterval; +/** + * Indicates whether or not automatically downloading updates is allowed to be turned on by the user. + * If this value is nil, the developer has not explicitly specified this option. + */ +@property (readonly, nonatomic, nullable) NSNumber *allowsAutomaticUpdatesOption; + /** * Indicates whether or not automatically downloading updates is allowed to be turned on by the user. */ diff --git a/Sparkle/SPUUpdaterSettings.m b/Sparkle/SPUUpdaterSettings.m index 9e5deeb2f0..691231d211 100644 --- a/Sparkle/SPUUpdaterSettings.m +++ b/Sparkle/SPUUpdaterSettings.m @@ -52,9 +52,15 @@ - (NSTimeInterval)updateCheckInterval } // For allowing automatic downloaded updates to be turned on or off -- (BOOL)allowsAutomaticUpdates +- (NSNumber * _Nullable)allowsAutomaticUpdatesOption { NSNumber *developerAllowsAutomaticUpdates = [self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey]; + return [developerAllowsAutomaticUpdates isKindOfClass:[NSNumber class]] ? developerAllowsAutomaticUpdates : nil; +} + +- (BOOL)allowsAutomaticUpdates +{ + NSNumber *developerAllowsAutomaticUpdates = [self allowsAutomaticUpdatesOption]; return (developerAllowsAutomaticUpdates == nil || developerAllowsAutomaticUpdates.boolValue); } diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index da170e78ea..96d32158d8 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -98,7 +98,18 @@ - (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateSt _didBecomeKeyBlock = [didBecomeKeyBlock copy]; SPUUpdaterSettings *updaterSettings = [[SPUUpdaterSettings alloc] initWithHostBundle:host.bundle]; - _allowsAutomaticUpdates = updaterSettings.allowsAutomaticUpdates && updaterSettings.automaticallyChecksForUpdates && !item.informationOnlyUpdate; + + BOOL allowsAutomaticUpdates; + NSNumber *allowsAutomaticUpdatesOption = updaterSettings.allowsAutomaticUpdatesOption; + if (item.informationOnlyUpdate) { + allowsAutomaticUpdates = NO; + } else if (allowsAutomaticUpdatesOption == nil) { + allowsAutomaticUpdates = updaterSettings.automaticallyChecksForUpdates; + } else { + allowsAutomaticUpdates = allowsAutomaticUpdatesOption.boolValue; + } + _allowsAutomaticUpdates = allowsAutomaticUpdates; + [self setShouldCascadeWindows:NO]; } else { assert(false);