Added delegate methods that interacts with DevMate (beta updates, test mode).

This commit is contained in:
Dmytro Tretiakov committed 2014-02-10 18:31:42 +02:00
1 parent 7797a8f58c
commit 9119d287ab
2 files changed
+48 -1

No files matched your search

+15
View File
@@ -142,6 +142,21 @@
@end
// -----------------------------------------------------------------------------
// SUUpdater Delegate: DevMate Interaction
// -----------------------------------------------------------------------------
// NOTE!!! Implemented delegate methods have higher priority than values saved in user preferences
FOUNDATION_EXPORT NSString *const SUUpdaterChecksForBetaUpdatesPrefKey; // bool value
FOUNDATION_EXPORT NSString *const SUUpdaterIsInTestModePrefKey; // bool value
@interface NSObject (SUUpdaterDelegate_DevMateInteraction)
- (BOOL)updaterShouldCheckForBetaUpdates:(SUUpdater *)updater;
- (BOOL)isUpdaterInTestMode:(SUUpdater *)updater;
@end
// -----------------------------------------------------------------------------
// Constants:
+33 -1
View File
@@ -479,7 +479,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
NSArray *parameters = [NSArray array];
NSArray *parameters = [self devmateFeedParameters];
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
if (sendingSystemProfile)
@@ -564,4 +564,36 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
return [[NSFileManager defaultManager] fileExistsAtPath:[xpcServicePrefixPath stringByAppendingPathComponent:xpcServiceSuffixPath]];
}
#pragma mark - DevMate Interaction
NSString *const SUUpdaterChecksForBetaUpdatesPrefKey = @"SUUpdaterChecksForBetaUpdates";
NSString *const SUUpdaterIsInTestModePrefKey = @"SUUpdaterIsInTestMode";
- (NSArray *)devmateFeedParameters
{
NSMutableArray *parameters = [NSMutableArray array];
BOOL isInTestMode = [host boolForUserDefaultsKey:SUUpdaterIsInTestModePrefKey];
if ([delegate respondsToSelector:@selector(isUpdaterInTestMode:)])
{
isInTestMode = [delegate isUpdaterInTestMode:self];
}
if (isInTestMode)
{
[parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"test", @"key", @"1", @"value", nil]];
}
BOOL shouldCheckBeta = [host boolForUserDefaultsKey:SUUpdaterChecksForBetaUpdatesPrefKey];
if ([delegate respondsToSelector:@selector(updaterShouldCheckForBetaUpdates:)])
{
shouldCheckBeta = [delegate updaterShouldCheckForBetaUpdates:self];
}
if (shouldCheckBeta)
{
[parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"beta", @"key", @"1", @"value", nil]];
}
return parameters;
}
@end