Skip to content

Commit

Permalink
Fixes 251968
Browse files Browse the repository at this point in the history
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
andymatuschak committed Aug 11, 2008
1 parent 7b39268 commit 4da902b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion SUSystemProfiler.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;
Expand Down
3 changes: 2 additions & 1 deletion SUUpdatePermissionPrompt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions SUUpdatePermissionPrompt.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]];
}

Expand All @@ -55,6 +56,7 @@ - (void)awakeFromNib
- (void)dealloc
{
[host release];
[systemProfileInformationArray release];
[super dealloc];
}

Expand All @@ -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"];
Expand Down
3 changes: 1 addition & 2 deletions SUUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions SUUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@interface SUUpdater (Private)
- initForBundle:(NSBundle *)bundle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
- (BOOL)_sendingSystemProfile;
- (BOOL)automaticallyUpdates;
- (void)scheduleNextUpdateCheck;
- (void)registerAsObserver;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions en.lproj/SUUpdatePermissionPrompt.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified en.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib
Binary file not shown.

0 comments on commit 4da902b

Please sign in to comment.