mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Added main delegate methods for setting up 'test' and 'beta' updates checking.
This commit is contained in:
1 parent
90f35f87dc
commit
dd3aca874b
2 files changed
+66
-1
No files matched your search
Vendored
+29
@@ -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 <SUUpdaterDelegate>
|
||||
@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
|
||||
Vendored
+37
-1
@@ -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<SUUpdaterDelegate_DevMateInteraction>)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<SUUpdaterDelegate_DevMateInteraction>)self.delegate updaterShouldCheckForBetaUpdates:self];
|
||||
}
|
||||
if (shouldCheckBeta)
|
||||
{
|
||||
[parameters addObject:@{ @"key" : @"beta", @"value" : @"1"}];
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user