Finished integrating SparklePlus profiling! Just set SUEnableSystemProfiling to YES in your info.plist. The Test App has this on by default so you all can see.

This commit is contained in:
andym committed 2008-02-15 04:17:26 +00:00
1 parent 6fd1422eea
commit 8c3960fc5f
13 files changed
+201 -42

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ extern NSString *SUPublicDSAKeyKey;
extern NSString *SUAutomaticallyUpdateKey;
extern NSString *SUAllowsAutomaticUpdatesKey;
extern NSString *SUEnableAutomaticChecksKey;
extern NSString *SUEnableSystemProfilingKey;
extern NSString *SUSendProfileInfoKey;
// NSInteger is a type that was added to Leopard.
+1
View File
@@ -21,5 +21,6 @@ NSString *SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
NSString *SUPublicDSAKeyKey = @"SUPublicDSAKey";
NSString *SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
NSString *SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
NSString *SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
NSString *SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
NSString *SUSendProfileInfoKey = @"SUSendProfileInfo";
+17 -1
View File
@@ -11,10 +11,26 @@
#import "Sparkle.h"
typedef enum {
SUAutomaticallyUpdate,
SUDoNotAutomaticallyUpdate
} SUPermissionPromptResult;
@interface SUUpdatePermissionPrompt : SUWindowController {
NSBundle *hostBundle;
id delegate;
IBOutlet NSTextField *descriptionTextField;
IBOutlet NSView *moreInfoView;
IBOutlet NSButton *moreInfoButton;
BOOL isShowingMoreInfo, shouldSendProfile;
}
+ (void)promptWithHostBundle:(NSBundle *)hb delegate:(id)d;
- (IBAction)toggleMoreInfo:(id)sender;
- (IBAction)finishPrompt:(id)sender;
@end
@interface NSObject (SUUpdatePermissionPromptDelegateInformalProtocol)
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result;
@end
#endif
+108
View File
@@ -11,4 +11,112 @@
@implementation SUUpdatePermissionPrompt
- (BOOL)shouldAskAboutProfile
{
return [[hostBundle objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
}
- (id)initWithHostBundle:(NSBundle *)hb delegate:(id)d
{
hostBundle = [hb retain];
delegate = [d retain];
isShowingMoreInfo = NO;
shouldSendProfile = [self shouldAskAboutProfile];
[super initWithHostBundle:hb windowNibName:@"SUUpdatePermissionPrompt"];
[self setShouldCascadeWindows:NO];
return self;
}
+ (void)promptWithHostBundle:(NSBundle *)hb delegate:(id)d
{
id prompt = [[[self class] alloc] initWithHostBundle:hb delegate:d];
[prompt showWindow:self];
}
- (void)awakeFromNib
{
if (![self shouldAskAboutProfile])
{
NSRect frame = [[self window] frame];
frame.size.height -= [moreInfoButton frame].size.height;
[[self window] setFrame:frame display:YES];
}
}
- (void)dealloc
{
[hostBundle release];
[super dealloc];
}
- (NSImage *)icon
{
return [hostBundle icon];
}
- (NSString *)description
{
return [NSString stringWithFormat:SULocalizedString(@"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.", nil), [hostBundle name]];
}
- (NSArray *)systemProfileInformationArray
{
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHostBundle:hostBundle];
}
- (IBAction)toggleMoreInfo:(id)sender
{
[self willChangeValueForKey:@"isShowingMoreInfo"];
isShowingMoreInfo = !isShowingMoreInfo;
[self didChangeValueForKey:@"isShowingMoreInfo"];
NSView *contentView = [[self window] contentView];
NSRect contentViewFrame = [contentView frame];
NSRect windowFrame = [[self window] frame];
NSRect profileMoreInfoViewFrame = [moreInfoView frame];
NSRect profileMoreInfoButtonFrame = [moreInfoButton frame];
NSRect descriptionFrame = [descriptionTextField frame];
if (isShowingMoreInfo)
{
// Add the subview
contentViewFrame.size.height += profileMoreInfoViewFrame.size.height;
profileMoreInfoViewFrame.origin.y = profileMoreInfoButtonFrame.origin.y - profileMoreInfoViewFrame.size.height;
profileMoreInfoViewFrame.origin.x = descriptionFrame.origin.x;
profileMoreInfoViewFrame.size.width = descriptionFrame.size.width;
windowFrame.size.height += profileMoreInfoViewFrame.size.height;
windowFrame.origin.y -= profileMoreInfoViewFrame.size.height;
[moreInfoView setFrame:profileMoreInfoViewFrame];
[moreInfoView setHidden:YES];
[contentView addSubview:moreInfoView
positioned:NSWindowBelow
relativeTo:moreInfoButton];
} else {
// Remove the subview
[moreInfoView setHidden:NO];
[moreInfoView removeFromSuperview];
contentViewFrame.size.height -= profileMoreInfoViewFrame.size.height;
windowFrame.size.height -= profileMoreInfoViewFrame.size.height;
windowFrame.origin.y += profileMoreInfoViewFrame.size.height;
}
[[self window] setFrame:windowFrame display:YES animate:YES];
[contentView setFrame:contentViewFrame];
[contentView setNeedsDisplay:YES];
[moreInfoView setHidden:(!isShowingMoreInfo)];
}
- (IBAction)finishPrompt:(id)sender
{
if (![delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)])
[NSException raise:@"SUInvalidDelegate" format:@"SUUpdatePermissionPrompt's delegate (%@) doesn't respond to updatePermissionPromptFinishedWithResult:!", delegate];
[[SUUserDefaults standardUserDefaults] setBool:shouldSendProfile forKey:SUSendProfileInfoKey];
[delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyUpdate : SUDoNotAutomaticallyUpdate)];
[[self window] close];
[self autorelease];
}
@end
+38 -29
View File
@@ -17,6 +17,7 @@
@interface SUUpdater (Private)
- (void)beginUpdateCheck;
- (void)beginUpdateCycle;
- (void)showUpdateAlert;
- (void)beginDownload;
- (void)extractUpdate;
@@ -83,38 +84,46 @@ static SUUpdater *sharedUpdater = nil;
return;
}
// The user's never been asked, so let's see if they want automatic checking.
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Allow automatic update checking?", nil) defaultButton:SULocalizedString(@"Allow", nil) alternateButton:SULocalizedString(@"Don't Allow", nil) otherButton:nil informativeTextWithFormat:SULocalizedString(@"Would you like %1$@ to automatically check for updates to itself? If not, you can check for updates manually from the %1$@ menu.", nil), [hostBundle name]];
[alert setIcon:[hostBundle icon]];
[[SUUserDefaults standardUserDefaults] setBool:([alert runModal] == NSAlertDefaultReturn) forKey:SUEnableAutomaticChecksKey];
[SUUpdatePermissionPrompt promptWithHostBundle:hostBundle delegate:self];
}
if ([[SUUserDefaults standardUserDefaults] boolForKey:SUEnableAutomaticChecksKey] == YES)
{
// Find the stored check interval. User defaults override Info.plist.
if ([[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey])
checkInterval = [[[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey] longValue];
else if ([hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey])
checkInterval = [[hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] longValue];
if (checkInterval < SU_MIN_CHECK_INTERVAL) // This can also mean one that isn't set.
checkInterval = SU_DEFAULT_CHECK_INTERVAL;
// How long has it been since last we checked for an update?
NSDate *lastCheckDate = [[SUUserDefaults standardUserDefaults] objectForKey:SULastCheckTimeKey];
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
// Now we want to figure out how long until we check again.
NSTimeInterval delayUntilCheck;
if (intervalSinceCheck < checkInterval)
delayUntilCheck = (checkInterval - intervalSinceCheck); // It hasn't been long enough.
else
delayUntilCheck = 0; // We're overdue! Run one now.
[self performSelector:@selector(checkForUpdatesInBackground) withObject:nil afterDelay:delayUntilCheck];
[self performSelector:@selector(scheduleCheckWithIntervalObject:) withObject:[NSNumber numberWithDouble:checkInterval] afterDelay:delayUntilCheck];
}
[self beginUpdateCycle];
}
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result
{
BOOL automaticallyUpdate = (result == SUAutomaticallyUpdate);
[[SUUserDefaults standardUserDefaults] setBool:(result == SUAutomaticallyUpdate) forKey:SUEnableAutomaticChecksKey];
if (automaticallyUpdate)
[self beginUpdateCycle];
}
- (void)beginUpdateCycle
{
// Find the stored check interval. User defaults override Info.plist.
if ([[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey])
checkInterval = [[[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey] longValue];
else if ([hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey])
checkInterval = [[hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] longValue];
if (checkInterval < SU_MIN_CHECK_INTERVAL) // This can also mean one that isn't set.
checkInterval = SU_DEFAULT_CHECK_INTERVAL;
// How long has it been since last we checked for an update?
NSDate *lastCheckDate = [[SUUserDefaults standardUserDefaults] objectForKey:SULastCheckTimeKey];
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
// Now we want to figure out how long until we check again.
NSTimeInterval delayUntilCheck;
if (intervalSinceCheck < checkInterval)
delayUntilCheck = (checkInterval - intervalSinceCheck); // It hasn't been long enough.
else
delayUntilCheck = 0; // We're overdue! Run one now.
[self performSelector:@selector(checkForUpdatesInBackground) withObject:nil afterDelay:delayUntilCheck];
[self performSelector:@selector(scheduleCheckWithIntervalObject:) withObject:[NSNumber numberWithDouble:checkInterval] afterDelay:delayUntilCheck];
}
- (void)scheduleCheckWithInterval:(NSTimeInterval)interval
+1 -1
View File
@@ -16,4 +16,4 @@
- (id)initWithHostBundle:(NSBundle *)hb windowNibName:(NSString *)nibName;
@end
#endif
#endif
+1
View File
@@ -46,6 +46,7 @@
#import "SUUnarchiver.h"
#import "SUUpdateAlert.h"
#import "SUUpdater.h"
#import "SUUpdatePermissionPrompt.h"
#import "SUUserDefaults.h"
#import "SUVersionComparisonProtocol.h"
#import "SUWindowController.h"
+12
View File
@@ -17,6 +17,7 @@
61177A1F0D1112E900749C97 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6117796E0D1112E000749C97 /* IOKit.framework */; };
61180BCA0D64138900B4E0D1 /* SUWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = 61180BC80D64138900B4E0D1 /* SUWindowController.h */; settings = {ATTRIBUTES = (Public, ); }; };
61180BCB0D64138900B4E0D1 /* SUWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61180BC90D64138900B4E0D1 /* SUWindowController.m */; };
61180C900D64262100B4E0D1 /* SUUpdatePermissionPrompt.nib in Resources */ = {isa = PBXBuildFile; fileRef = 61180C8E0D64262100B4E0D1 /* SUUpdatePermissionPrompt.nib */; };
6120721209CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */; settings = {ATTRIBUTES = (Public, ); }; };
6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */; };
61299A2F09CA2DAB00B7442F /* NSFileManager+Verification.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A2D09CA2DAB00B7442F /* NSFileManager+Verification.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -126,6 +127,7 @@
6117796E0D1112E000749C97 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
61180BC80D64138900B4E0D1 /* SUWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUWindowController.h; sourceTree = "<group>"; };
61180BC90D64138900B4E0D1 /* SUWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUWindowController.m; sourceTree = "<group>"; };
61180C8F0D64262100B4E0D1 /* en */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = en; path = en.lproj/SUUpdatePermissionPrompt.nib; sourceTree = "<group>"; };
6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAutomaticUpdateAlert.h; sourceTree = "<group>"; };
6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAutomaticUpdateAlert.m; sourceTree = "<group>"; };
6129984309C9E2DA00B7442F /* NSFileManager+Authentication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFileManager+Authentication.h"; sourceTree = "<group>"; };
@@ -376,6 +378,7 @@
61AAE8220A321A7F00D8810D /* Sparkle.strings */,
61AAE8240A321A7F00D8810D /* SUAutomaticUpdateAlert.nib */,
61AAE8260A321A7F00D8810D /* SUUpdateAlert.nib */,
61180C8E0D64262100B4E0D1 /* SUUpdatePermissionPrompt.nib */,
61299B3509CB04E000B7442F /* Sparkle.h */,
);
name = "Other Sources";
@@ -628,6 +631,7 @@
61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */,
61AAE8290A321A8000D8810D /* SUAutomaticUpdateAlert.nib in Resources */,
61AAE82A0A321A8000D8810D /* SUUpdateAlert.nib in Resources */,
61180C900D64262100B4E0D1 /* SUUpdatePermissionPrompt.nib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -718,6 +722,14 @@
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
61180C8E0D64262100B4E0D1 /* SUUpdatePermissionPrompt.nib */ = {
isa = PBXVariantGroup;
children = (
61180C8F0D64262100B4E0D1 /* en */,
);
name = SUUpdatePermissionPrompt.nib;
sourceTree = "<group>";
};
61AAE8220A321A7F00D8810D /* Sparkle.strings */ = {
isa = PBXVariantGroup;
children = (
@@ -26,5 +26,7 @@
<string>NSApplication</string>
<key>SUFeedURL</key>
<string>http://www.andymatuschak.org/files/sparkletestcast.xml</string>
<key>SUEnableSystemProfiling</key>
<true/>
</dict>
</plist>
Binary file not shown.
@@ -6,37 +6,37 @@
<array>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<string>SUWindowController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSWindowController</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>checkForUpdates</key>
<key>finishPrompt</key>
<string>id</string>
<key>closeProfileInfoSheet</key>
<key>toggleMoreInfo</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>SUUpdater</string>
<string>SUUpdatePermissionPrompt</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>checkForUpdatesText</key>
<string>NSTextField</string>
<key>delegate</key>
<string>id</string>
<key>profileMoreInfoButton</key>
<key>descriptionTextField</key>
<string>NSTextField</string>
<key>moreInfoButton</key>
<string>NSButton</string>
<key>profileMoreInfoView</key>
<key>moreInfoView</key>
<string>NSView</string>
<key>profileMoreInfoWindow</key>
<string>NSWindow</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
<string>SUWindowController</string>
</dict>
<dict>
<key>CLASS</key>
@@ -46,6 +46,12 @@
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
@@ -4,10 +4,13 @@
<dict>
<key>IBFramework Version</key>
<string>629</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../Sparkle.xcodeproj</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
<integer>39</integer>
<integer>6</integer>
</array>
<key>IBSystem Version</key>
Binary file not shown.