diff --git a/SUSystemProfiler.m b/SUSystemProfiler.m index 3354bf22..9df2fd5f 100644 --- a/SUSystemProfiler.m +++ b/SUSystemProfiler.m @@ -31,7 +31,7 @@ unsigned long length = sizeof(value) ; // OS version - NSString *currentSystemVersion = SUSystemVersionString(); + NSString *currentSystemVersion = [SUUpdater systemVersionString]; if (currentSystemVersion != nil) [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"osVersion",@"OS Version",currentSystemVersion,currentSystemVersion,nil] forKeys:profileDictKeys]]; diff --git a/SUUpdater.h b/SUUpdater.h index 53cc87ce..e4c240a7 100644 --- a/SUUpdater.h +++ b/SUUpdater.h @@ -52,6 +52,8 @@ // just want to call this every time the user changes the setting in the preferences. - (void)scheduleCheckWithInterval:(NSTimeInterval)interval; ++ (NSString *)systemVersionString; // Returns the current system's version. + @end // Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds. diff --git a/SUUpdater.m b/SUUpdater.m index e1ad29ee..96e94f48 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -23,7 +23,6 @@ - (void)showUpdateErrorAlertWithInfo:(NSString *)info; - (void)abandonUpdate; - (IBAction)installAndRestart:sender; -- (NSString *)systemVersionString; @end @implementation SUUpdater @@ -214,7 +213,7 @@ { // We also have to make sure that the newest version can run on the user's system. id comparator = [SUStandardVersionComparator defaultComparator]; - BOOL canRunOnCurrentSystem = ([comparator compareVersion:[updateItem minimumSystemVersion] toVersion:SUSystemVersionString()] != NSOrderedDescending); + BOOL canRunOnCurrentSystem = ([comparator compareVersion:[updateItem minimumSystemVersion] toVersion:[SUUpdater systemVersionString]] != NSOrderedDescending); return (canRunOnCurrentSystem && ([comparator compareVersion:[hostBundle version] toVersion:[updateItem fileVersion]]) == NSOrderedAscending); } @@ -614,4 +613,28 @@ [super dealloc]; } ++ (NSString *)systemVersionString +{ + // This returns a version string of the form X.Y.Z + // There may be a better way to deal with the problem that gestaltSystemVersionMajor + // et al. are not defined in 10.3, but this is probably good enough. + NSString* verStr = nil; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + SInt32 major, minor, bugfix; + OSErr err1 = Gestalt(gestaltSystemVersionMajor, &major); + OSErr err2 = Gestalt(gestaltSystemVersionMinor, &minor); + OSErr err3 = Gestalt(gestaltSystemVersionBugFix, &bugfix); + if (!err1 && !err2 && !err3) + { + verStr = [NSString stringWithFormat:@"%ld.%ld.%ld", major, minor, bugfix]; + } + else +#endif + { + NSString *versionPlistPath = @"/System/Library/CoreServices/SystemVersion.plist"; + verStr = [[[NSDictionary dictionaryWithContentsOfFile:versionPlistPath] objectForKey:@"ProductVersion"] retain]; + } + return verStr; +} + @end diff --git a/Sparkle.h b/Sparkle.h index e4411f5b..7f0585a7 100644 --- a/Sparkle.h +++ b/Sparkle.h @@ -21,21 +21,6 @@ #import "SUConstants.h" #endif -// This returns a version string of the form X.Y.Z -static inline NSString* SUSystemVersionString(void) -{ - SInt32 major, minor, bugfix; - OSErr err1 = Gestalt(gestaltSystemVersionMajor, &major); - OSErr err2 = Gestalt(gestaltSystemVersionMinor, &minor); - OSErr err3 = Gestalt(gestaltSystemVersionBugFix, &bugfix); - NSString* verStr = nil; - if (!err1 && !err2 && !err3) - { - verStr = [NSString stringWithFormat:@"%d.%d.%d", major, minor, bugfix]; - } - return verStr; -} - // This list should include the shared headers. It doesn't matter if some of them aren't shared (unless // there are name-space collisions) so we can list all of them to start with: diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index fecb1545..dbdedbd9 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -939,6 +939,7 @@ ppc64, x86_64, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;