diff --git a/Sparkle/SUConstants.h b/Sparkle/SUConstants.h index 4afeec03..d4543acd 100644 --- a/Sparkle/SUConstants.h +++ b/Sparkle/SUConstants.h @@ -14,6 +14,9 @@ // Misc: // ----------------------------------------------------------------------------- +extern const NSTimeInterval SUMinimumUpdateCheckInterval; +extern const NSTimeInterval SUDefaultUpdateCheckInterval; + extern NSString *const SUBundleIdentifier; // ----------------------------------------------------------------------------- diff --git a/Sparkle/SUConstants.m b/Sparkle/SUConstants.m index 66e31194..819cbd4f 100644 --- a/Sparkle/SUConstants.m +++ b/Sparkle/SUConstants.m @@ -13,6 +13,14 @@ #import "SUVersionComparisonProtocol.h" #import "SUConstants.h" +#ifndef DEBUG +#define DEBUG 0 +#endif + +// Define some minimum intervals to avoid DOS-like checking attacks +const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60); +const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24); + NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER; NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation"; diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 4960a4e3..6eff1394 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -152,11 +152,6 @@ static NSString *sUpdateFolder = nil; } } - -#define SUNotifyDictHostKey @"SUNotifyDictHost" -#define SUNotifyDictErrorKey @"SUNotifyDictError" -#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate" - + (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id)delegate { if (result) diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index 267e6789..02c3be10 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -18,7 +18,7 @@ // Constants: // ----------------------------------------------------------------------------- -#define LOG_FILE_PATH @"~/Library/Logs/SparkleUpdateLog.log" +static NSString *const SULogFilePath = @"~/Library/Logs/SparkleUpdateLog.log"; // ----------------------------------------------------------------------------- @@ -38,7 +38,7 @@ void SUClearLog(void) { - FILE *logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation], "w"); + FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "w"); if (logfile) { fclose(logfile); } @@ -62,7 +62,7 @@ void SULog(NSString *format, ...) NSString *theStr = [[NSString alloc] initWithFormat:format arguments:ap]; NSLog(@"Sparkle: %@", theStr); - FILE *logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation], "a"); + FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "a"); if (logfile) { theStr = [NSString stringWithFormat:@"%@: %@\n", [NSDate date], theStr]; NSData *theData = [theStr dataUsingEncoding:NSUTF8StringEncoding]; diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index 4c838571..6bdb49cc 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -313,22 +313,4 @@ extern NSString *const SUUpdaterAppcastNotificationKey; @end - -// ----------------------------------------------------------------------------- -// Constants: -// ----------------------------------------------------------------------------- - -// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds. -#if defined(DEBUG) && DEBUG && 0 -#define SU_MIN_CHECK_INTERVAL 60 -#else -#define SU_MIN_CHECK_INTERVAL 60 * 60 -#endif - -#if defined(DEBUG) && DEBUG && 0 -#define SU_DEFAULT_CHECK_INTERVAL 60 -#else -#define SU_DEFAULT_CHECK_INTERVAL 60 * 60 * 24 -#endif - #endif diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 3117fea5..7d0e25d5 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -231,8 +231,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults // Now we want to figure out how long until we check again. NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval]; - if (updateCheckInterval < SU_MIN_CHECK_INTERVAL) - updateCheckInterval = SU_MIN_CHECK_INTERVAL; + if (updateCheckInterval < SUMinimumUpdateCheckInterval) + updateCheckInterval = SUMinimumUpdateCheckInterval; if (intervalSinceCheck < updateCheckInterval) delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough. else @@ -411,7 +411,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults // Hack to support backwards compatibility with older Sparkle versions, which supported // disabling updates by setting the check interval to 0. if (automaticallyCheckForUpdates && (NSInteger)[self updateCheckInterval] == 0) { - [self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL]; + [self setUpdateCheckInterval:SUDefaultUpdateCheckInterval]; } [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil]; // Provide a small delay in case multiple preferences are being updated simultaneously. @@ -553,7 +553,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults if (intervalValue) return [intervalValue doubleValue]; else - return SU_DEFAULT_CHECK_INTERVAL; + return SUDefaultUpdateCheckInterval; } - (void)dealloc