diff --git a/Configurations/ConfigCommonDebug.xcconfig b/Configurations/ConfigCommonDebug.xcconfig index 8bfcf525..718bd9fb 100644 --- a/Configurations/ConfigCommonDebug.xcconfig +++ b/Configurations/ConfigCommonDebug.xcconfig @@ -5,4 +5,4 @@ DEBUG_INFORMATION_FORMAT = dwarf GCC_GENERATE_DEBUGGING_SYMBOLS = YES SPARKLE_EXTRA_DEBUG = -DDEBUG -fstack-protector -D_FORTIFY_SOURCE=2 OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG) -ARCHS = $(NATIVE_ARCH_32_BIT) +ARCHS = $(NATIVE_ARCH_ACTUAL) diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 1accadc9..92c9f2d5 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -6,4 +6,4 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO DEAD_CODE_STRIPPING = YES GCC_TREAT_WARNINGS_AS_ERRORS = YES GCC_WARN_UNINITIALIZED_AUTOS = YES -ARCHS = ppc ppc64 i386 x86_64 +ARCHS = ppc i386 x86_64 diff --git a/Info.plist b/Info.plist index f0c18095..8eb6cc32 100644 --- a/Info.plist +++ b/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en_US + en CFBundleExecutable ${EXECUTABLE_NAME} CFBundleName diff --git a/NSFileManager+Aliases.h b/NSFileManager+Aliases.h index 76b2b501..673b12b3 100644 --- a/NSFileManager+Aliases.h +++ b/NSFileManager+Aliases.h @@ -11,7 +11,7 @@ #import -@interface NSFileManager (Aliases) +@interface NSFileManager (SUAliases) - (BOOL)isAliasFolderAtPath:(NSString *)path; @end diff --git a/NSFileManager+Aliases.m b/NSFileManager+Aliases.m index b54ae9ee..9b2ab411 100644 --- a/NSFileManager+Aliases.m +++ b/NSFileManager+Aliases.m @@ -9,7 +9,7 @@ #import "NSFileManager+Aliases.h" -@implementation NSFileManager (Aliases) +@implementation NSFileManager (SUAliases) - (BOOL)isAliasFolderAtPath:(NSString *)path { diff --git a/NSFileManager+ExtendedAttributes.h b/NSFileManager+ExtendedAttributes.h index e541c300..6744ce0b 100644 --- a/NSFileManager+ExtendedAttributes.h +++ b/NSFileManager+ExtendedAttributes.h @@ -11,7 +11,7 @@ #import -@interface NSFileManager (ExtendedAttributes) +@interface NSFileManager (MMExtendedAttributes) // Wraps the removexattr system call, allowing an AppKit-style NSString* to // be used for the pathname argument. Note that the order of the arguments diff --git a/NSFileManager+ExtendedAttributes.m b/NSFileManager+ExtendedAttributes.m index d6454d80..4a2c3d86 100644 --- a/NSFileManager+ExtendedAttributes.m +++ b/NSFileManager+ExtendedAttributes.m @@ -20,7 +20,7 @@ #define XATTR_NOFOLLOW 1 #endif // SDK >= 10.4 -@implementation NSFileManager (ExtendedAttributes) +@implementation NSFileManager (MMExtendedAttributes) - (int)removeXAttr:(const char*)name fromFile:(NSString*)file diff --git a/NSNumber+Units.h b/NSNumber+Units.h index a0fc9348..f85b5368 100644 --- a/NSNumber+Units.h +++ b/NSNumber+Units.h @@ -9,7 +9,7 @@ #import -@interface NSNumber (Units) +@interface NSNumber (JWUnits) + (NSString *)humanReadableSizeFromDouble:(double)value; diff --git a/NSNumber+Units.m b/NSNumber+Units.m index d08625b5..6a832650 100644 --- a/NSNumber+Units.m +++ b/NSNumber+Units.m @@ -9,7 +9,7 @@ #import "NSNumber+Units.h" #import "Sparkle.h" -@implementation NSNumber (Units) +@implementation NSNumber (JWUnits) + (NSString *)humanReadableSizeFromDouble:(double)value { diff --git a/NSString+extras.h b/NSString+extras.h index 7d84b688..2f53af65 100644 --- a/NSString+extras.h +++ b/NSString+extras.h @@ -48,7 +48,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA #import #import "SUConstants.h" // for NSInteger -@interface NSString (extras) +@interface NSString (BSextras) - (NSString *)stringWithSubstitute:(NSString *)subs forCharactersFromSet:(NSCharacterSet *)set; diff --git a/NSString+extras.m b/NSString+extras.m index 6a4d2403..e20718e8 100644 --- a/NSString+extras.m +++ b/NSString+extras.m @@ -44,7 +44,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA #import "NSString+extras.h" -@implementation NSString (extras) +@implementation NSString (BSextras) - (NSString *)stringWithSubstitute:(NSString *)subs forCharactersFromSet:(NSCharacterSet *)set { diff --git a/NSWorkspace+SystemVersion.h b/NSWorkspace+SystemVersion.h index 11194125..52e81afc 100644 --- a/NSWorkspace+SystemVersion.h +++ b/NSWorkspace+SystemVersion.h @@ -11,7 +11,7 @@ #import -@interface NSWorkspace (SystemVersion) +@interface NSWorkspace (SUSystemVersion) + (NSString *)systemVersionString; @end diff --git a/NSWorkspace+SystemVersion.m b/NSWorkspace+SystemVersion.m index 895a1a71..408cb872 100644 --- a/NSWorkspace+SystemVersion.m +++ b/NSWorkspace+SystemVersion.m @@ -9,7 +9,7 @@ #import "NSWorkspace+SystemVersion.h" -@implementation NSWorkspace (SystemVersion) +@implementation NSWorkspace (SUSystemVersion) + (NSString *)systemVersionString { // This returns a version string of the form X.Y.Z diff --git a/SUBasicUpdateDriver.h b/SUBasicUpdateDriver.h index 90cb6250..ddafed6c 100644 --- a/SUBasicUpdateDriver.h +++ b/SUBasicUpdateDriver.h @@ -47,7 +47,9 @@ - (void)installUpdate; - (void)installerFinishedForHostBundle:(NSBundle *)hb; - (void)installerForHostBundle:(NSBundle *)hb failedWithError:(NSError *)error; + - (void)relaunchHostApp; +- (void)cleanUp; - (void)abortUpdate; - (void)abortUpdateWithError:(NSError *)error; diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index b29fc369..733aa021 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -26,7 +26,7 @@ [appcast release]; [appcast setDelegate:self]; - [appcast setUserAgentString:[NSString stringWithFormat: @"%@/%@ Sparkle/1.5b1", [hostBundle name], [hostBundle displayVersion]]]; + [appcast setUserAgentString:[NSString stringWithFormat: @"%@/%@ Sparkle/1.5b2", [hostBundle name], [hostBundle displayVersion]]]; [appcast fetchAppcastFromURL:appcastURL]; } @@ -58,17 +58,17 @@ - (void)appcastDidFinishLoading:(SUAppcast *)ac { - if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)]) - [delegate appcastDidFinishLoading:ac]; + if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:forHostBundle:)]) + [delegate appcastDidFinishLoading:ac forHostBundle:hostBundle]; NSArray* updates = [ac items]; if ([updates count] > 0) [[SUUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:SULastCheckTimeKey]; // Now we have to find the best valid update in the appcast. - if ([delegate respondsToSelector:@selector(bestValidUpdateInAppcast:)]) // Does the delegate want to handle it? + if ([delegate respondsToSelector:@selector(bestValidUpdateInAppcast:forHostBundle:)]) // Does the delegate want to handle it? { - updateItem = [delegate bestValidUpdateInAppcast:ac]; + updateItem = [delegate bestValidUpdateInAppcast:ac forHostBundle:hostBundle]; } else // If not, we'll take care of it ourselves. { @@ -97,13 +97,15 @@ - (void)didFindValidUpdate { - if ([delegate respondsToSelector:@selector(didFindValidUpdate:)]) - [delegate didFindValidUpdate:updateItem]; + if ([delegate respondsToSelector:@selector(didFindValidUpdate:toHostBundle:)]) + [delegate didFindValidUpdate:updateItem toHostBundle:hostBundle]; [self downloadUpdate]; } - (void)didNotFindUpdate { + if ([delegate respondsToSelector:@selector(didNotFindUpdateToHostBundle:)]) + [delegate didNotFindUpdateToHostBundle:hostBundle]; [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [hostBundle name]] forKey:NSLocalizedDescriptionKey]]]; } @@ -190,8 +192,8 @@ - (void)installUpdate { - if ([delegate respondsToSelector:@selector(updateWillInstall:)]) - [delegate updateWillInstall:updateItem]; + if ([delegate respondsToSelector:@selector(updateWillInstall:toHostBundle:)]) + [delegate updateWillInstall:updateItem toHostBundle:hostBundle]; // Copy the relauncher into a temporary directory so we can get to it after the new version's installed. NSString *relaunchPathToCopy = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:@""]; NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; @@ -213,36 +215,40 @@ { // Give the host app an opportunity to postpone the relaunch. static BOOL postponedOnce = NO; - if (!postponedOnce && [delegate respondsToSelector:@selector(shouldPostponeRelaunchForUpdate:untilInvoking:)]) + if (!postponedOnce && [delegate respondsToSelector:@selector(shouldPostponeRelaunchForUpdate:toHostBundle:untilInvoking:)]) { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[[self class] instanceMethodSignatureForSelector:@selector(relaunchHostApp)] retain]]; [invocation setSelector:@selector(relaunchHostApp)]; [invocation setTarget:self]; postponedOnce = YES; - if ([delegate shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) + if ([delegate shouldPostponeRelaunchForUpdate:updateItem toHostBundle:hostBundle untilInvoking:invocation]) return; } + + [self cleanUp]; // Clean up the download and extracted files. [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self]; if ([delegate respondsToSelector:@selector(updaterWillRelaunchApplication)]) [delegate updaterWillRelaunchApplication]; - @try - { - if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath]) - [NSException raise:@"SURelauncherNotFound" format:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath]; - - [NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:[hostBundle bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]]; - } - @catch (NSException *e) + if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath]) { // Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin. - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [[NSBundle mainBundle] name]], NSLocalizedDescriptionKey, [e reason], NSLocalizedFailureReasonErrorKey, nil]]]; + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [[NSBundle mainBundle] name]], NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath], NSLocalizedFailureReasonErrorKey, nil]]]; // We intentionally don't abandon the update here so that the host won't initiate another. - } + return; + } + + [NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:[hostBundle bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]]; + [NSApp terminate:self]; } +- (void)cleanUp +{ + [[NSFileManager defaultManager] removeFileAtPath:[downloadPath stringByDeletingLastPathComponent] handler:nil]; +} + - (void)installerForHostBundle:(NSBundle *)hb failedWithError:(NSError *)error { if (hb != hostBundle) { return; } diff --git a/SUProbingUpdateDriver.h b/SUProbingUpdateDriver.h index c91c6a32..e2165f44 100644 --- a/SUProbingUpdateDriver.h +++ b/SUProbingUpdateDriver.h @@ -16,9 +16,4 @@ @interface SUProbingUpdateDriver : SUBasicUpdateDriver { } @end -@interface NSObject (SUProbeDriverDelegateProtocol) -- (void)didFindValidUpdate:(SUAppcastItem *)item toHostBundle:(NSBundle *)hb; -- (void)didNotFindUpdateToHostBundle:(NSBundle *)hb; -@end - #endif diff --git a/SUProbingUpdateDriver.m b/SUProbingUpdateDriver.m index f21edfe6..3ec116a9 100644 --- a/SUProbingUpdateDriver.m +++ b/SUProbingUpdateDriver.m @@ -11,17 +11,15 @@ @implementation SUProbingUpdateDriver +// Stop as soon as we have an answer! The superclasses will already have taken care of notifying the delegate. + - (void)didFindValidUpdate { - if ([delegate respondsToSelector:@selector(didFindValidUpdate:toHostBundle:)]) - [delegate didFindValidUpdate:updateItem toHostBundle:hostBundle]; [self abortUpdate]; } - (void)didNotFindUpdate { - if ([delegate respondsToSelector:@selector(didNotFindUpdateToHostBundle:)]) - [delegate didNotFindUpdateToHostBundle:hostBundle]; [self abortUpdate]; } diff --git a/SUStatusController.h b/SUStatusController.h index dc0c197f..e56dc8e7 100644 --- a/SUStatusController.h +++ b/SUStatusController.h @@ -28,7 +28,6 @@ // If isDefault is YES, the button's key equivalent will be \r. - (void)setButtonTitle:(NSString *)buttonTitle target:target action:(SEL)action isDefault:(BOOL)isDefault; - (void)setButtonEnabled:(BOOL)enabled; -- (void)setButtonHidden:(BOOL)hidden; - (double)progressValue; - (void)setProgressValue:(double)value; diff --git a/SUStatusController.m b/SUStatusController.m index cd44910a..cea7a52d 100644 --- a/SUStatusController.m +++ b/SUStatusController.m @@ -87,12 +87,6 @@ [actionButton setEnabled:enabled]; } -- (void)setButtonHidden:(BOOL)hidden -{ - [actionButton setHidden:hidden]; - [[actionButton superview] display]; -} - - (double)progressValue { return progressValue; diff --git a/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index 05644781..848ba42f 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -29,6 +29,8 @@ - (void)didNotFindUpdate { + if ([delegate respondsToSelector:@selector(didNotFindUpdateToHostBundle:)]) + [delegate didNotFindUpdateToHostBundle:hostBundle]; NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up to date!", nil) defaultButton:SULocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [hostBundle name], [hostBundle displayVersion]]; [alert setIcon:[hostBundle icon]]; [alert runModal]; @@ -44,8 +46,8 @@ - (void)updateAlert:(SUUpdateAlert *)alert finishedWithChoice:(SUUpdateAlertChoice)choice { [updateAlert release]; updateAlert = nil; - if ([delegate respondsToSelector:@selector(userChoseAction:forUpdate:)]) - [delegate userChoseAction:choice forUpdate:updateItem]; + if ([delegate respondsToSelector:@selector(userChoseAction:forUpdate:toHostBundle:)]) + [delegate userChoseAction:choice forUpdate:updateItem toHostBundle:hostBundle]; [[SUUserDefaults standardUserDefaults] setObject:nil forKey:SUSkippedVersionKey]; switch (choice) { diff --git a/SUUpdater.h b/SUUpdater.h index a286fc0a..645d25a6 100644 --- a/SUUpdater.h +++ b/SUUpdater.h @@ -9,18 +9,19 @@ #ifndef SUUPDATER_H #define SUUPDATER_H -@class SUUpdateDriver; +#import "SUUpdateAlert.h" + +@class SUUpdateDriver, SUAppcastItem, SUAppcast; @interface SUUpdater : NSObject { NSTimer *checkTimer; SUUpdateDriver *driver; NSBundle *hostBundle; - id delegate; + IBOutlet id delegate; } + (SUUpdater *)sharedUpdater; -- (void)setHostBundle:(NSBundle *)hostBundle; - (void)setDelegate:(id)delegate; // This IBAction is meant for a main menu item. Hook up any menu item to this action, @@ -30,6 +31,14 @@ // This forces an update to begin with a particular driver (see SU*UpdateDriver.h) - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)driver; +// For non-.app updates: +// Call this when your bundle is loaded to tell Sparkle what to update. +- (void)setHostBundle:(NSBundle *)hostBundle; + +// Call this to appropriately reschedule or cancel the update checking timer if preferences for time interval or automatic checks change. +// If you're using a .app, this'll be picked up automatically via NSUserDefaultsController, but for non-.apps, there's no way to observe changes. +- (void)updatePreferencesChanged; + - (BOOL)updateInProgress; @end @@ -37,29 +46,32 @@ @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 the following keys: -- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile; +- (NSArray *)feedParametersForHostBundle:(NSBundle *)bundle sendingSystemProfile:(BOOL)sendingProfile; // Use this to override the default behavior for Sparkle prompting the user about automatic update checks. -- (BOOL)shouldPromptForPermissionToCheckForUpdates; +- (BOOL)shouldPromptForPermissionToCheckForUpdatesToHostBundle:(NSBundle *)bundle; // Implement this if you want to do some special handling with the appcast once it finishes loading. -- (void)appcastDidFinishLoading:(SUAppcast *)appcast; +- (void)appcastDidFinishLoading:(SUAppcast *)appcast forHostBundle:(NSBundle *)bundle; // If you're using special logic or extensions in your appcast, implement this to use your own logic for finding // a valid update, if any, in the given appcast. -- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast; +- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forHostBundle:(NSBundle *)bundle; // Sent when a valid update is found by the update driver. -- (void)didFindValidUpdate:(SUAppcastItem *)update; +- (void)didFindValidUpdate:(SUAppcastItem *)update toHostBundle:(NSBundle *)bundle; + +// Sent when a valid update is not found. +- (void)didNotFindUpdateToHostBundle:(NSBundle *)hb; // Sent when the user makes a choice in the update alert dialog (install now / remind me later / skip this version). -- (void)userChoseAction:(SUUpdateAlertChoice)action forUpdate:(SUAppcastItem *)update; +- (void)userChoseAction:(SUUpdateAlertChoice)action forUpdate:(SUAppcastItem *)update toHostBundle:(NSBundle *)bundle; // Sent immediately before installing the specified update. -- (void)updateWillInstall:(SUAppcastItem *)update; +- (void)updateWillInstall:(SUAppcastItem *)update toHostBundle:(NSBundle *)bundle; // Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue. -- (BOOL)shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation; +- (BOOL)shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update toHostBundle:(NSBundle *)hostBundle untilInvoking:(NSInvocation *)invocation; // Called immediately before relaunching. - (void)updaterWillRelaunchApplication; diff --git a/SUUpdater.m b/SUUpdater.m index 9be1dba9..c75493c9 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -10,10 +10,10 @@ #import "SUUpdater.h" @interface SUUpdater (Private) -- (void)beginUpdateCycle; - (NSArray *)feedParameters; - (BOOL)automaticallyUpdates; - (BOOL)shouldScheduleUpdateCheck; +- (void)scheduleNextUpdateCheck; - (NSTimeInterval)checkInterval; @end @@ -45,6 +45,8 @@ static SUUpdater *sharedUpdater = nil; sharedUpdater = self; [self setHostBundle:[NSBundle mainBundle]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidFinishLaunching:) name:NSApplicationDidFinishLaunchingNotification object:NSApp]; + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:0 context:NULL]; + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:0 context:NULL]; } return self; } @@ -56,9 +58,9 @@ static SUUpdater *sharedUpdater = nil; [[SUUserDefaults standardUserDefaults] boolForKey:SUEnableAutomaticChecksKey] == NO) { return; } // Does the delegate want to take care of the logic for when we should ask permission to update? - if ([delegate respondsToSelector:@selector(shouldPromptForPermissionToCheckForUpdates)]) + if ([delegate respondsToSelector:@selector(shouldPromptForPermissionToCheckForUpdatesToHostBundle)]) { - if ([delegate shouldPromptForPermissionToCheckForUpdates]) + if ([delegate shouldPromptForPermissionToCheckForUpdatesToHostBundle:hostBundle]) [SUUpdatePermissionPrompt promptWithHostBundle:hostBundle delegate:self]; } // Has he been asked already? And don't ask if the host has a default value set in its Info.plist. @@ -76,20 +78,28 @@ static SUUpdater *sharedUpdater = nil; } // We check if the user's said they want updates, or they haven't said anything, and the default is set to checking. - if ([self shouldScheduleUpdateCheck]) - [self beginUpdateCycle]; + [self scheduleNextUpdateCheck]; } - (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result { BOOL automaticallyCheck = (result == SUAutomaticallyCheck); [[SUUserDefaults standardUserDefaults] setBool:automaticallyCheck forKey:SUEnableAutomaticChecksKey]; - if ([self automaticallyUpdates]) - [self beginUpdateCycle]; + [self scheduleNextUpdateCheck]; } -- (void)beginUpdateCycle +- (void)scheduleNextUpdateCheck { + @synchronized (checkTimer) + { + if (checkTimer) + { + [checkTimer invalidate]; + checkTimer = nil; + } + } + if (![self shouldScheduleUpdateCheck]) return; + // How long has it been since last we checked for an update? NSDate *lastCheckDate = [[SUUserDefaults standardUserDefaults] objectForKey:SULastCheckTimeKey]; if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; } @@ -101,7 +111,6 @@ static SUUpdater *sharedUpdater = nil; delayUntilCheck = ([self checkInterval] - intervalSinceCheck); // It hasn't been long enough. else delayUntilCheck = 0; // We're overdue! Run one now. - checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; } @@ -118,7 +127,7 @@ static SUUpdater *sharedUpdater = nil; - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d { if ([self updateInProgress]) { return; } - if (checkTimer) { [checkTimer invalidate]; checkTimer = nil; } + @synchronized (checkTimer) { if (checkTimer) { [checkTimer invalidate]; checkTimer = nil; } } // A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds). NSString *appcastString = [[SUUserDefaults standardUserDefaults] objectForKey:SUFeedURLKey]; @@ -137,11 +146,25 @@ static SUUpdater *sharedUpdater = nil; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (object != driver) { return; } - [driver removeObserver:self forKeyPath:@"finished"]; - [driver release]; driver = nil; - if ([self shouldScheduleUpdateCheck]) - checkTimer = [NSTimer scheduledTimerWithTimeInterval:[self checkInterval] target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; + if (object == driver && [keyPath isEqualToString:@"finished"]) + { + [driver removeObserver:self forKeyPath:@"finished"]; + [driver release]; driver = nil; + [self scheduleNextUpdateCheck]; + } + else if (object == [NSUserDefaultsController sharedUserDefaultsController] && ([keyPath hasSuffix:SUScheduledCheckIntervalKey] || [keyPath hasSuffix:SUEnableAutomaticChecksKey])) + { + [self updatePreferencesChanged]; + } + else + { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + +- (void)updatePreferencesChanged +{ + [self scheduleNextUpdateCheck]; } - (BOOL)shouldScheduleUpdateCheck @@ -154,7 +177,7 @@ static SUUpdater *sharedUpdater = nil; if ([[SUUserDefaults standardUserDefaults] objectForKey:SUEnableAutomaticChecksKey] == nil && [[hostBundle objectForInfoDictionaryKey:SUEnableAutomaticChecksKey] boolValue] == YES) return YES; - return NO; // Otherwise, don't bothe.r + return NO; // Otherwise, don't bother. } - (BOOL)automaticallyUpdates @@ -179,8 +202,8 @@ static SUUpdater *sharedUpdater = nil; { BOOL sendingSystemProfile = ([[SUUserDefaults standardUserDefaults] boolForKey:SUSendProfileInfoKey] == YES); NSArray *parameters = [NSArray array]; - if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) - parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]]; + if ([delegate respondsToSelector:@selector(feedParametersForHostBundle:sendingSystemProfile:)]) + parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForHostBundle:hostBundle sendingSystemProfile:sendingSystemProfile]]; if (sendingSystemProfile) parameters = [parameters arrayByAddingObjectsFromArray:[hostBundle systemProfile]]; return parameters; diff --git a/SUUserInitiatedUpdateDriver.h b/SUUserInitiatedUpdateDriver.h index 6849c91d..9d9a3041 100644 --- a/SUUserInitiatedUpdateDriver.h +++ b/SUUserInitiatedUpdateDriver.h @@ -14,6 +14,7 @@ @interface SUUserInitiatedUpdateDriver : SUUIBasedUpdateDriver { SUStatusController *checkingController; + BOOL isCanceled; } @end diff --git a/SUUserInitiatedUpdateDriver.m b/SUUserInitiatedUpdateDriver.m index 706dcc51..667dd631 100644 --- a/SUUserInitiatedUpdateDriver.m +++ b/SUUserInitiatedUpdateDriver.m @@ -17,18 +17,44 @@ checkingController = [[SUStatusController alloc] initWithHostBundle:hb]; [checkingController window]; // Force the checking controller to load its window. [checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates\u2026", nil) maxProgressValue:0 statusText:nil]; - [checkingController setButtonHidden:YES]; + [checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO]; [checkingController showWindow:self]; } - (void)closeCheckingWindow { - [[checkingController window] close]; - [checkingController release]; + if (checkingController) + { + [[checkingController window] close]; + [checkingController release]; + checkingController = nil; + } +} + +- (void)cancelCheckForUpdates:sender +{ + [self closeCheckingWindow]; + isCanceled = YES; +} + +- (void)appcastDidFinishLoading:(SUAppcast *)ac +{ + if (isCanceled) + { + [self abortUpdate]; + return; + } + [self closeCheckingWindow]; + [super appcastDidFinishLoading:ac]; } - (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error { + if (isCanceled) + { + [self abortUpdate]; + return; + } [self closeCheckingWindow]; [super appcast:ac failedToLoadWithError:error]; } @@ -39,16 +65,4 @@ return [self hostSupportsItem:ui] && [self isItemNewer:ui]; } -- (void)didNotFindUpdate -{ - [self closeCheckingWindow]; - [super didNotFindUpdate]; -} - -- (void)didFindValidUpdate -{ - [self closeCheckingWindow]; - [super didFindValidUpdate]; -} - @end diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 7f0ed833..8a54edf2 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -1033,6 +1033,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 61072EB20DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig */; buildSettings = { + INSTALL_PATH = "@loader_path/../Frameworks"; }; name = "Release (GC dual-mode; 10.5-only)"; }; diff --git a/Test Application/English.lproj/MainMenu.nib/info.nib b/Test Application/English.lproj/MainMenu.nib/info.nib index 953d6cc2..09d03620 100644 --- a/Test Application/English.lproj/MainMenu.nib/info.nib +++ b/Test Application/English.lproj/MainMenu.nib/info.nib @@ -3,15 +3,18 @@ IBFramework Version - 629 + 667 + IBLastKnownRelativeProjectPath + ../../Sparkle.xcodeproj IBOldestOS 5 IBOpenObjects 2 + 57 IBSystem Version - 9B18 + 9D34 targetFramework IBCocoaFramework diff --git a/Test Application/English.lproj/MainMenu.nib/keyedobjects.nib b/Test Application/English.lproj/MainMenu.nib/keyedobjects.nib index 2cb97381..afe4c17d 100644 Binary files a/Test Application/English.lproj/MainMenu.nib/keyedobjects.nib and b/Test Application/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/ca.lproj/Sparkle.strings b/ca.lproj/Sparkle.strings index af834f8d..38373928 100644 Binary files a/ca.lproj/Sparkle.strings and b/ca.lproj/Sparkle.strings differ diff --git a/cs.lproj/Sparkle.strings b/cs.lproj/Sparkle.strings index 53766305..3b86680e 100644 Binary files a/cs.lproj/Sparkle.strings and b/cs.lproj/Sparkle.strings differ diff --git a/cy.lproj/Sparkle.strings b/cy.lproj/Sparkle.strings index 8bacd3c1..7eb1c5b8 100644 Binary files a/cy.lproj/Sparkle.strings and b/cy.lproj/Sparkle.strings differ diff --git a/da.lproj/Sparkle.strings b/da.lproj/Sparkle.strings index 7dd0293a..02c23a97 100644 Binary files a/da.lproj/Sparkle.strings and b/da.lproj/Sparkle.strings differ diff --git a/de.lproj/Sparkle.strings b/de.lproj/Sparkle.strings deleted file mode 100644 index a542ba02..00000000 Binary files a/de.lproj/Sparkle.strings and /dev/null differ diff --git a/es.lproj/SUAutomaticUpdateAlert.nib/classes.nib b/es.lproj/SUAutomaticUpdateAlert.nib/classes.nib new file mode 100644 index 00000000..4b1ab30e --- /dev/null +++ b/es.lproj/SUAutomaticUpdateAlert.nib/classes.nib @@ -0,0 +1,50 @@ + + + + + IBClasses + + + CLASS + SUWindowController + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + ACTIONS + + doNotInstall + id + installLater + id + installNow + id + + CLASS + SUAutomaticUpdateAlert + LANGUAGE + ObjC + SUPERCLASS + SUWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/es.lproj/SUAutomaticUpdateAlert.nib/info.nib b/es.lproj/SUAutomaticUpdateAlert.nib/info.nib new file mode 100644 index 00000000..2e04cfa0 --- /dev/null +++ b/es.lproj/SUAutomaticUpdateAlert.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 667 + IBLastKnownRelativeProjectPath + ../Sparkle.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 6 + + IBSystem Version + 9D34 + targetFramework + IBCocoaFramework + + diff --git a/es.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib b/es.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib new file mode 100644 index 00000000..6b2f938f Binary files /dev/null and b/es.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib differ diff --git a/es.lproj/SUUpdateAlert.nib/classes.nib b/es.lproj/SUUpdateAlert.nib/classes.nib new file mode 100644 index 00000000..994d4c36 --- /dev/null +++ b/es.lproj/SUUpdateAlert.nib/classes.nib @@ -0,0 +1,67 @@ + + + + + IBClasses + + + CLASS + SUWindowController + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + CLASS + NSApplication + LANGUAGE + ObjC + SUPERCLASS + NSResponder + + + ACTIONS + + installUpdate + id + remindMeLater + id + skipThisVersion + id + + CLASS + SUUpdateAlert + LANGUAGE + ObjC + OUTLETS + + delegate + id + description + NSTextField + releaseNotesView + WebView + + SUPERCLASS + SUWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/es.lproj/SUUpdateAlert.nib/info.nib b/es.lproj/SUUpdateAlert.nib/info.nib new file mode 100644 index 00000000..2e04cfa0 --- /dev/null +++ b/es.lproj/SUUpdateAlert.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 667 + IBLastKnownRelativeProjectPath + ../Sparkle.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 6 + + IBSystem Version + 9D34 + targetFramework + IBCocoaFramework + + diff --git a/es.lproj/SUUpdateAlert.nib/keyedobjects.nib b/es.lproj/SUUpdateAlert.nib/keyedobjects.nib new file mode 100644 index 00000000..c9b1e7d8 Binary files /dev/null and b/es.lproj/SUUpdateAlert.nib/keyedobjects.nib differ diff --git a/es.lproj/SUUpdatePermissionPrompt.nib/classes.nib b/es.lproj/SUUpdatePermissionPrompt.nib/classes.nib new file mode 100644 index 00000000..5220a221 --- /dev/null +++ b/es.lproj/SUUpdatePermissionPrompt.nib/classes.nib @@ -0,0 +1,59 @@ + + + + + IBClasses + + + CLASS + SUWindowController + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + ACTIONS + + finishPrompt + id + toggleMoreInfo + id + + CLASS + SUUpdatePermissionPrompt + LANGUAGE + ObjC + OUTLETS + + delegate + id + descriptionTextField + NSTextField + moreInfoButton + NSButton + moreInfoView + NSView + + SUPERCLASS + SUWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/es.lproj/SUUpdatePermissionPrompt.nib/info.nib b/es.lproj/SUUpdatePermissionPrompt.nib/info.nib new file mode 100644 index 00000000..3eb7f818 --- /dev/null +++ b/es.lproj/SUUpdatePermissionPrompt.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 667 + IBLastKnownRelativeProjectPath + ../../Sparkle.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 6 + + IBSystem Version + 9D34 + targetFramework + IBCocoaFramework + + diff --git a/es.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib b/es.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib new file mode 100644 index 00000000..8c54c217 Binary files /dev/null and b/es.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib differ diff --git a/es.lproj/Sparkle.strings b/es.lproj/Sparkle.strings index 36d6d8bf..04883033 100644 Binary files a/es.lproj/Sparkle.strings and b/es.lproj/Sparkle.strings differ diff --git a/fi.lproj/Sparkle.strings b/fi.lproj/Sparkle.strings index cc7a9d36..c92ae65d 100644 Binary files a/fi.lproj/Sparkle.strings and b/fi.lproj/Sparkle.strings differ diff --git a/fr.lproj/Sparkle.strings b/fr.lproj/Sparkle.strings index a8c73c39..ae9ddfd5 100644 Binary files a/fr.lproj/Sparkle.strings and b/fr.lproj/Sparkle.strings differ diff --git a/he.lproj/Sparkle.strings b/he.lproj/Sparkle.strings index 1632fc44..83878c75 100644 Binary files a/he.lproj/Sparkle.strings and b/he.lproj/Sparkle.strings differ diff --git a/hu.lproj/Sparkle.strings b/hu.lproj/Sparkle.strings index 8bacd3c1..7eb1c5b8 100644 Binary files a/hu.lproj/Sparkle.strings and b/hu.lproj/Sparkle.strings differ diff --git a/id.lproj/Sparkle.strings b/id.lproj/Sparkle.strings index 8bacd3c1..7eb1c5b8 100644 Binary files a/id.lproj/Sparkle.strings and b/id.lproj/Sparkle.strings differ diff --git a/is.lproj/Sparkle.strings b/is.lproj/Sparkle.strings index 2f90becf..595ec39f 100644 Binary files a/is.lproj/Sparkle.strings and b/is.lproj/Sparkle.strings differ diff --git a/it.lproj/Sparkle.strings b/it.lproj/Sparkle.strings index 7f5db43d..79e12976 100644 Binary files a/it.lproj/Sparkle.strings and b/it.lproj/Sparkle.strings differ diff --git a/ja.lproj/Sparkle.strings b/ja.lproj/Sparkle.strings index 973f30d8..35502c04 100644 Binary files a/ja.lproj/Sparkle.strings and b/ja.lproj/Sparkle.strings differ diff --git a/ko.lproj/Sparkle.strings b/ko.lproj/Sparkle.strings index 8bacd3c1..7eb1c5b8 100644 Binary files a/ko.lproj/Sparkle.strings and b/ko.lproj/Sparkle.strings differ diff --git a/nl.lproj/Sparkle.strings b/nl.lproj/Sparkle.strings index aad7dbe3..a1de5447 100644 Binary files a/nl.lproj/Sparkle.strings and b/nl.lproj/Sparkle.strings differ diff --git a/no.lproj/Sparkle.strings b/no.lproj/Sparkle.strings index 5f71c080..9dfddba4 100644 Binary files a/no.lproj/Sparkle.strings and b/no.lproj/Sparkle.strings differ diff --git a/pl.lproj/Sparkle.strings b/pl.lproj/Sparkle.strings index 4c8d830c..fa6fdcda 100644 Binary files a/pl.lproj/Sparkle.strings and b/pl.lproj/Sparkle.strings differ diff --git a/ru.lproj/Sparkle.strings b/ru.lproj/Sparkle.strings index d7de1ef4..66d4e3c0 100644 Binary files a/ru.lproj/Sparkle.strings and b/ru.lproj/Sparkle.strings differ diff --git a/sk.lproj/Sparkle.strings b/sk.lproj/Sparkle.strings index 26226c1b..bb6da6d7 100644 Binary files a/sk.lproj/Sparkle.strings and b/sk.lproj/Sparkle.strings differ diff --git a/sv.lproj/Sparkle.strings b/sv.lproj/Sparkle.strings index 792fed8c..2be2d43f 100644 Binary files a/sv.lproj/Sparkle.strings and b/sv.lproj/Sparkle.strings differ diff --git a/th.lproj/Sparkle.strings b/th.lproj/Sparkle.strings index 8bacd3c1..7eb1c5b8 100644 Binary files a/th.lproj/Sparkle.strings and b/th.lproj/Sparkle.strings differ diff --git a/tr.lproj/Sparkle.strings b/tr.lproj/Sparkle.strings index 468e272a..dafe131b 100644 Binary files a/tr.lproj/Sparkle.strings and b/tr.lproj/Sparkle.strings differ diff --git a/zh_CN.lproj/Sparkle.strings b/zh_CN.lproj/Sparkle.strings index 9ec31e73..5eae24a9 100644 Binary files a/zh_CN.lproj/Sparkle.strings and b/zh_CN.lproj/Sparkle.strings differ diff --git a/zh_TW.lproj/Sparkle.strings b/zh_TW.lproj/Sparkle.strings index c72a9f27..96f351d5 100644 --- a/zh_TW.lproj/Sparkle.strings +++ b/zh_TW.lproj/Sparkle.strings @@ -41,16 +41,16 @@ "Check for updates on startup?" = "啟動時檢查更新項目?"; /* No comment provided by engineer. */ -"Downloading update..." = "正在下載更新項目⋯"; +"Downloading update…" = "正在下載更新項目⋯"; /* No comment provided by engineer. */ -"Extracting update..." = "正在解壓縮更新項目⋯"; +"Extracting update…" = "正在解壓縮更新項目⋯"; /* No comment provided by engineer. */ "Install and Relaunch" = "安裝與重新啟動"; /* No comment provided by engineer. */ -"Installing update..." = "安裝更新..."; +"Installing update…" = "安裝更新…"; /* No comment provided by engineer. */ "No" = "否";