Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes 258547

SUUpdater now implements two new keys: "automaticallyDownloadsUpdates" and "sendsSystemProfile".

Here's the current state of the setting keys, as documented by Christiaan Hofman:

* UserDefaults through SUUpdater accessors with default value in Info.plist:

SUFeedURL
SUScheduledCheckInterval
SUEnableAutomaticChecks
SUSendProfileInfo
SUAutomaticallyUpdate

* Info.plist only (app settings):

SUShowReleaseNotes
SUPublicDSAKey
SUPublicDSAKeyFile
SUExpectsDSASignature
SUEnableSystemProfiling

* UserDefaults only (private persistent state):

SUHasLaunchedBefore
SUSkippedVersion
SULastCheckTime
SULastProfileSubmitDate

This revision also corrects a compilation error from r285.
  • Loading branch information...
commit ec7f38d1571800dac43adf13b3705806c7d59760 1 parent 5b38483
@andymatuschak andymatuschak authored
Showing with 27 additions and 19 deletions.
  1. +1 −1  SUHost.m
  2. +6 −0 SUUpdater.h
  3. +20 −18 SUUpdater.m
View
2  SUHost.m
@@ -185,7 +185,7 @@ - (id)objectForKey:(NSString *)key {
}
- (BOOL)boolForKey:(NSString *)key {
- return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey] : [self boolForInfoDictionaryKey];
+ return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key];
}
+ (NSString *)systemVersionString
View
6 SUUpdater.h
@@ -36,6 +36,12 @@
- (void)setFeedURL:(NSURL *)feedURL;
- (NSURL *)feedURL;
+- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile;
+- (BOOL)sendsSystemProfile;
+
+- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates;
+- (BOOL)automaticallyDownloadsUpdates;
+
// This IBAction is meant for a main menu item. Hook up any menu item to this action,
// and Sparkle will check for updates and report back its findings verbosely.
- (IBAction)checkForUpdates:sender;
View
38 SUUpdater.m
@@ -19,8 +19,7 @@
@interface SUUpdater (Private)
- initForBundle:(NSBundle *)bundle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
-- (BOOL)_sendingSystemProfile;
-- (BOOL)automaticallyUpdates;
+- (BOOL)automaticallyDownloadsUpdates;
- (void)scheduleNextUpdateCheck;
- (void)registerAsObserver;
- (void)unregisterAsObserver;
@@ -110,7 +109,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note
{
NSArray *profileInfo = [host systemProfile];
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
- profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:[self _sendingSystemProfile]]];
+ profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:[self sendsSystemProfile]]];
[SUUpdatePermissionPrompt promptWithHost:host systemProfile:profileInfo delegate:self];
// We start the update checks and register as observer for changes after the prompt finishes
}
@@ -162,7 +161,7 @@ - (void)scheduleNextUpdateCheck
- (void)checkForUpdatesInBackground
{
- [self checkForUpdatesWithDriver:[[[([self automaticallyUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease]];
+ [self checkForUpdatesWithDriver:[[[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease]];
}
- (IBAction)checkForUpdates:sender
@@ -234,14 +233,15 @@ - (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
- (BOOL)automaticallyChecksForUpdates
{
- // Breaking this down for readability:
- // If the user or the developer says he wants automatic update checks, let's do it.
- if ([host boolForKey:SUEnableAutomaticChecksKey] == YES)
- return YES;
- return NO; // Otherwise, don't bother.
+ return [host boolForKey:SUEnableAutomaticChecksKey];
}
-- (BOOL)automaticallyUpdates
+- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyUpdates
+{
+ [host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
+}
+
+- (BOOL)automaticallyDownloadsUpdates
{
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO)
@@ -251,11 +251,8 @@ - (BOOL)automaticallyUpdates
if ([host boolForInfoDictionaryKey:SUExpectsDSASignatureKey] != YES)
return NO;
- // If there's no setting, or it's set to no, we're not automatically updating.
- if ([host boolForUserDefaultsKey:SUAutomaticallyUpdateKey] != YES)
- return NO;
-
- return YES; // Otherwise, we're good to go.
+ // Otherwise, automatically downloading updates is allowed. Does the user want it?
+ return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
}
- (void)setFeedURL:(NSURL *)feedURL
@@ -273,9 +270,14 @@ - (NSURL *)feedURL
return [NSURL URLWithString:[appcastString stringByTrimmingCharactersInSet:quoteSet]];
}
-- (BOOL)_sendingSystemProfile
+- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile
+{
+ [host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
+}
+
+- (BOOL)sendsSystemProfile
{
- return ([host boolForUserDefaultsKey:SUSendProfileInfoKey] == YES);
+ return [host boolForUserDefaultsKey:SUSendProfileInfoKey];
}
- (NSURL *)parameterizedFeedURL
@@ -283,7 +285,7 @@ - (NSURL *)parameterizedFeedURL
NSURL *baseFeedURL = [self feedURL];
// Determine all the parameters we're attaching to the base feed URL.
- BOOL sendingSystemProfile = [self _sendingSystemProfile];
+ BOOL sendingSystemProfile = [self sendsSystemProfile];
// Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such.
NSDate *lastSubmitDate = [host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
Please sign in to comment.
Something went wrong with that request. Please try again.