diff --git a/SUBundleDefaults.h b/SUBundleDefaults.h index 828ceea5..0116fa5a 100644 --- a/SUBundleDefaults.h +++ b/SUBundleDefaults.h @@ -28,10 +28,12 @@ /* - (int)integerForKey:(NSString *)defaultName; - (float)floatForKey:(NSString *)defaultName; +*/ - (BOOL)boolForKey:(NSString *)defaultName; - +/* - (void)setInteger:(int)value forKey:(NSString *)defaultName; - (void)setFloat:(float)value forKey:(NSString *)defaultName; -- (void)setBool:(BOOL)value forKey:(NSString *)defaultName; */ +- (void)setBool:(BOOL)value forKey:(NSString *)defaultName; + @end diff --git a/SUBundleDefaults.m b/SUBundleDefaults.m index 5f9236c5..88acbe57 100644 --- a/SUBundleDefaults.m +++ b/SUBundleDefaults.m @@ -70,13 +70,29 @@ { return (NSArray *)CFPreferencesCopyValue((CFStringRef)defaultName, (CFStringRef)applicationID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); } + /* - (int)integerForKey:(NSString *)defaultName; - (float)floatForKey:(NSString *)defaultName; -- (BOOL)boolForKey:(NSString *)defaultName; +*/ +- (BOOL)boolForKey:(NSString *)defaultName +{ + CFPropertyListRef plr = (CFPropertyListRef)CFPreferencesCopyValue((CFStringRef)defaultName, (CFStringRef)applicationID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (plr == NULL) + return NO; + return CFBooleanGetValue((CFBooleanRef)plr); +} + +/* - (void)setInteger:(int)value forKey:(NSString *)defaultName; - (void)setFloat:(float)value forKey:(NSString *)defaultName; -- (void)setBool:(BOOL)value forKey:(NSString *)defaultName; */ + +- (void)setBool:(BOOL)value forKey:(NSString *)defaultName +{ + CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)[NSNumber numberWithBool:value], (CFStringRef)applicationID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFPreferencesSynchronize((CFStringRef)applicationID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); +} + @end diff --git a/SUConstants.h b/SUConstants.h index b0ac4e36..00ec4a2f 100644 --- a/SUConstants.h +++ b/SUConstants.h @@ -18,3 +18,4 @@ extern NSString *SUExpectsDSASignatureKey; extern NSString *SUPublicDSAKeyKey; extern NSString *SUAutomaticallyUpdateKey; extern NSString *SUAllowsAutomaticUpdatesKey; +extern NSString *SUIgnoreChecksKey; diff --git a/SUConstants.m b/SUConstants.m index 3399ab47..93c581d9 100644 --- a/SUConstants.m +++ b/SUConstants.m @@ -17,4 +17,5 @@ NSString *SULastCheckTimeKey = @"SULastCheckTime"; NSString *SUExpectsDSASignatureKey = @"SUExpectsDSASignature"; NSString *SUPublicDSAKeyKey = @"SUPublicDSAKey"; NSString *SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate"; -NSString *SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates"; \ No newline at end of file +NSString *SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates"; +NSString *SUIgnoreChecksKey = @"SUIgnoreChecks"; \ No newline at end of file diff --git a/SUUpdater.m b/SUUpdater.m index 7c15df59..e995b4e1 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -101,6 +101,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note { + if ([[utilities standardBundleDefaults] boolForKey:SUIgnoreChecksKey]) + return; + // If there's a scheduled interval, we see if it's been longer than that interval since the last // check. If so, we perform a startup check; if not, we don't. if ([self storedCheckInterval]) @@ -188,10 +191,28 @@ [self checkForUpdatesAndNotify:YES]; // if we're coming from IB, then we want to be more verbose. } +- (BOOL)validateMenuItem:(NSMenuItem *)item { + if ([item action] == @selector(checkForUpdates:)) { + if (![[utilities standardBundleDefaults] boolForKey:SUIgnoreChecksKey]) + { + if (updateInProgress) + return NO; + else + return YES; + } else { + return NO; + } + } + return NO; +} + // If the verbosity flag is YES, Sparkle will say when it can't reach the server and when there's no new update. // This is generally useful for a menu item--when the check is explicitly invoked. - (void)checkForUpdatesAndNotify:(BOOL)verbosity { + if ([[utilities standardBundleDefaults] boolForKey:SUIgnoreChecksKey]) + return; + if (updateInProgress) { if (verbosity)