Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes 251968

Sparkle now requires custom feed parameters to include a "displayKey" and "displayVersion" key. These will be displayed to the user in the initial permission dialog so that he knows what he's getting.
  • Loading branch information...
commit 4da902b46c5e4c2e965534ad8f78e0aba7d5ae8a 1 parent 7b39268
@andymatuschak andymatuschak authored
View
2  SUSystemProfiler.m
@@ -33,7 +33,7 @@ - (NSMutableArray *)systemProfileArrayForHost:(SUHost *)host
// Gather profile information and append it to the URL.
NSMutableArray *profileArray = [NSMutableArray array];
- NSArray *profileDictKeys = [NSArray arrayWithObjects:@"key", @"visibleKey", @"value", @"visibleValue", nil];
+ NSArray *profileDictKeys = [NSArray arrayWithObjects:@"key", @"displayKey", @"value", @"displayValue", nil];
int error = 0 ;
int value = 0 ;
unsigned long length = sizeof(value) ;
View
3  SUUpdatePermissionPrompt.h
@@ -19,13 +19,14 @@ typedef enum {
@class SUHost;
@interface SUUpdatePermissionPrompt : SUWindowController {
SUHost *host;
+ NSArray *systemProfileInformationArray;
id delegate;
IBOutlet NSTextField *descriptionTextField;
IBOutlet NSView *moreInfoView;
IBOutlet NSButton *moreInfoButton;
BOOL isShowingMoreInfo, shouldSendProfile;
}
-+ (void)promptWithHost:(SUHost *)aHost delegate:(id)d;
++ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id)d;
- (IBAction)toggleMoreInfo:(id)sender;
- (IBAction)finishPrompt:(id)sender;
@end
View
15 SUUpdatePermissionPrompt.m
@@ -17,7 +17,7 @@ - (BOOL)shouldAskAboutProfile
return [[host objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
}
-- (id)initWithHost:(SUHost *)aHost delegate:(id)d
+- (id)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id)d
{
self = [super initWithHost:aHost windowNibName:@"SUUpdatePermissionPrompt"];
if (self)
@@ -26,19 +26,20 @@ - (id)initWithHost:(SUHost *)aHost delegate:(id)d
delegate = [d retain];
isShowingMoreInfo = NO;
shouldSendProfile = [self shouldAskAboutProfile];
+ systemProfileInformationArray = [profile retain];
[self setShouldCascadeWindows:NO];
}
return self;
}
-+ (void)promptWithHost:(SUHost *)host delegate:(id)d
++ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id)d
{
// If this is a background application we need to focus it in order to bring the prompt
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
// the user would not know why the application was paused.
- if ([host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
+ if ([aHost isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
- id prompt = [[[self class] alloc] initWithHost:host delegate:d];
+ id prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
[NSApp runModalForWindow:[prompt window]];
}
@@ -55,6 +56,7 @@ - (void)awakeFromNib
- (void)dealloc
{
[host release];
+ [systemProfileInformationArray release];
[super dealloc];
}
@@ -68,11 +70,6 @@ - (NSString *)promptDescription
return [NSString stringWithFormat:SULocalizedString(@"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.", nil), [host name]];
}
-- (NSArray *)systemProfileInformationArray
-{
- return [host systemProfile];
-}
-
- (IBAction)toggleMoreInfo:(id)sender
{
[self willChangeValueForKey:@"isShowingMoreInfo"];
View
3  SUUpdater.h
@@ -56,8 +56,7 @@
@end
@interface NSObject (SUUpdaterDelegateInformalProtocol)
-// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not
-// Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key" and "value".
+// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
// Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
View
13 SUUpdater.m
@@ -19,6 +19,7 @@
@interface SUUpdater (Private)
- initForBundle:(NSBundle *)bundle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
+- (BOOL)_sendingSystemProfile;
- (BOOL)automaticallyUpdates;
- (void)scheduleNextUpdateCheck;
- (void)registerAsObserver;
@@ -108,7 +109,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note
if (shouldPrompt)
{
- [SUUpdatePermissionPrompt promptWithHost:host delegate:self];
+ NSArray *profileInfo = [host systemProfile];
+ if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
+ profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:[self _sendingSystemProfile]]];
+ [SUUpdatePermissionPrompt promptWithHost:host systemProfile:profileInfo delegate:self];
// We start the update checks and register as observer for changes after the prompt finishes
}
else
@@ -275,12 +279,17 @@ - (NSURL *)feedURL
return [NSURL URLWithString:[appcastString stringByTrimmingCharactersInSet:quoteSet]];
}
+- (BOOL)_sendingSystemProfile
+{
+ return ([host boolForUserDefaultsKey:SUSendProfileInfoKey] == YES);
+}
+
- (NSURL *)parameterizedFeedURL
{
NSURL *baseFeedURL = [self feedURL];
// Determine all the parameters we're attaching to the base feed URL.
- BOOL sendingSystemProfile = ([host boolForUserDefaultsKey:SUSendProfileInfoKey] == YES);
+ BOOL sendingSystemProfile = [self _sendingSystemProfile];
// 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];
View
6 en.lproj/SUUpdatePermissionPrompt.nib/info.nib
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>IBFramework Version</key>
- <string>667</string>
+ <string>670</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../Sparkle.xcodeproj</string>
<key>IBOldestOS</key>
@@ -11,10 +11,10 @@
<key>IBOpenObjects</key>
<array>
<integer>6</integer>
- <integer>39</integer>
+ <integer>41</integer>
</array>
<key>IBSystem Version</key>
- <string>9D34</string>
+ <string>10A96</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
View
BIN  en.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.