diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index ea52e53d..0567adc4 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -325,4 +325,33 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; @end +// ----------------------------------------------------------------------------- +// SUUpdater Delegate: DevMate Interaction +// ----------------------------------------------------------------------------- + +// NOTE!!! Implemented delegate methods have higher priority than values saved in user preferences +static NSString * const SUUpdaterChecksForBetaUpdatesPrefKey = @"SUUpdaterChecksForBetaUpdates"; // bool value +static NSString * const SUUpdaterIsInTestModePrefKey = @"SUUpdaterIsInTestMode"; // bool value + +@protocol SUUpdaterDelegate_DevMateInteraction +@optional + +/*! + Calls right before updates checking request to look for beta ones on DevMate. + + \param updater The SUUpdater instance. + \return YES if need also check beta updates, NO otherwise. + */ +- (BOOL)updaterShouldCheckForBetaUpdates:(SUUpdater *)updater; + +/*! + Calls right before updates checking request to look for updates in test mode on DevMate. + + \param updater The SUUpdater instance. + \return YES if need to check updates that are in test mode, NO otherwise. + */ +- (BOOL)isUpdaterInTestMode:(SUUpdater *)updater; + +@end + #endif diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index ca3b3606..0abc4f61 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -448,7 +448,14 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults // A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds). NSString *appcastString = [self.host objectForKey:SUFeedURLKey]; if ([self.delegate respondsToSelector:@selector(feedURLStringForUpdater:)]) + { appcastString = [self.delegate feedURLStringForUpdater:self]; + } + if (0 == appcastString.length) + { + appcastString = @"https://updates.devmate.com/"; + } + if (!appcastString) // Can't find an appcast string! [NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the %@ key in either the Info.plist or the user defaults!", SUFeedURLKey]; NSCharacterSet *quoteSet = [NSCharacterSet characterSetWithCharactersInString:@"\"\'"]; // Some feed publishers add quotes; strip 'em. @@ -496,7 +503,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults const NSTimeInterval oneWeek = 60 * 60 * 24 * 7; sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek); - NSArray *parameters = @[]; + NSArray *parameters = [self devmateFeedParameters]; if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) { parameters = [parameters arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]]; } @@ -566,4 +573,33 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults - (NSBundle *)hostBundle { return [self.host bundle]; } +#pragma mark - DevMate Interaction + +- (NSArray *)devmateFeedParameters +{ + NSMutableArray *parameters = [NSMutableArray array]; + + BOOL isInTestMode = [self.host boolForUserDefaultsKey:SUUpdaterIsInTestModePrefKey]; + if ([self.delegate respondsToSelector:@selector(isUpdaterInTestMode:)]) + { + isInTestMode = [(id)self.delegate isUpdaterInTestMode:self]; + } + if (isInTestMode) + { + [parameters addObject:@{ @"key" : @"test", @"value" : @"1"}]; + } + + BOOL shouldCheckBeta = [self.host boolForUserDefaultsKey:SUUpdaterChecksForBetaUpdatesPrefKey]; + if ([self.delegate respondsToSelector:@selector(updaterShouldCheckForBetaUpdates:)]) + { + shouldCheckBeta = [(id)self.delegate updaterShouldCheckForBetaUpdates:self]; + } + if (shouldCheckBeta) + { + [parameters addObject:@{ @"key" : @"beta", @"value" : @"1"}]; + } + + return parameters; +} + @end