Fixed the version check returning true on Tiger (and Panther, for that matter).
authorPeter Hosey <hg@boredzo.org>
Fri Nov 27 20:11:35 2009 -0800 (2009-11-27)
changeset 45522f99d2f175f4
parent 4551 acb44d199f51
child 4553 4ec3953889a2
Fixed the version check returning true on Tiger (and Panther, for that matter).

Specifically: Centralized the Growl framework's version check in one location, updated both the Carbon and Cocoa installation prompts to use the new version, and updated its knowledge of the minimum Mac OS X version Growl requires.
Framework/Source/GrowlInstallationPrompt-Carbon.c
Framework/Source/GrowlInstallationPrompt.m
Framework/Source/GrowlVersionCheck.c
Framework/Source/GrowlVersionCheck.h
Growl.xcodeproj/project.pbxproj
     1.1 --- a/Framework/Source/GrowlInstallationPrompt-Carbon.c	Mon Nov 23 08:32:32 2009 -0800
     1.2 +++ b/Framework/Source/GrowlInstallationPrompt-Carbon.c	Fri Nov 27 20:11:35 2009 -0800
     1.3 @@ -12,6 +12,7 @@
     1.4  #include "GrowlDefinesInternal.h"
     1.5  #include "GrowlInstallationPrompt-Carbon.h"
     1.6  #include "GrowlApplicationBridge-Carbon.h"
     1.7 +#include "GrowlVersionCheck.h"
     1.8  
     1.9  #include <QuickTime/QuickTime.h>
    1.10  #include <alloca.h>
    1.11 @@ -47,21 +48,6 @@
    1.12  
    1.13  #pragma mark -
    1.14  
    1.15 -static const long minimumOSXVersionForGrowl = 0x1030L; //Panther (10.3.0)
    1.16 -
    1.17 -static Boolean _checkOSXVersion(void) {
    1.18 -	long OSXVersion = 0L;
    1.19 -	OSStatus err = Gestalt(gestaltSystemVersion, &OSXVersion);
    1.20 -	if (err != noErr) {
    1.21 -		NSLog(CFSTR("WARNING in GrowlInstallationPrompt: could not get Mac OS X version (selector = %x); got error code %li (will show the installation prompt anyway)"), (unsigned)gestaltSystemVersion, (long)err);
    1.22 -		//we proceed anyway, on the theory that it is better to show the installation prompt when inappropriate than to suppress it when not.
    1.23 -		OSXVersion = minimumOSXVersionForGrowl;
    1.24 -	}
    1.25 -	return (OSXVersion >= minimumOSXVersionForGrowl);
    1.26 -}
    1.27 -
    1.28 -#pragma mark -
    1.29 -
    1.30  static OSStatus _handleCommandInWindow(EventHandlerCallRef nextHandler, EventRef event, void *refcon);
    1.31  
    1.32  static OSStatus _fillOutTextInWindow(WindowRef window, Boolean isUpdate);
    1.33 @@ -89,7 +75,7 @@
    1.34  OSStatus _Growl_ShowUpdatePromptForVersion(CFStringRef updateVersion) {
    1.35  	OSStatus err = noErr;
    1.36  
    1.37 -	if (_checkOSXVersion()) {
    1.38 +	if (GrowlCheckOSXVersion()) {
    1.39  		CFBundleRef bundle = CFBundleGetBundleWithIdentifier(GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
    1.40  		if (!bundle)
    1.41  			NSLog(CFSTR("GrowlInstallationPrompt: could not locate framework bundle (forget about installing Growl); had looked for bundle with identifier '%@'"), GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
     2.1 --- a/Framework/Source/GrowlInstallationPrompt.m	Mon Nov 23 08:32:32 2009 -0800
     2.2 +++ b/Framework/Source/GrowlInstallationPrompt.m	Fri Nov 27 20:11:35 2009 -0800
     2.3 @@ -11,6 +11,7 @@
     2.4  #import "GrowlPathUtilities.h"
     2.5  #import "GrowlDefines.h"
     2.6  #import "GrowlDefinesInternal.h"
     2.7 +#import "GrowlVersionCheck.h"
     2.8  
     2.9  #import "AEVTBuilder.h"
    2.10  #import	"NSFileManager+Authentication.h"
    2.11 @@ -67,20 +68,16 @@
    2.12  - (void) releaseAndClose;
    2.13  @end
    2.14  
    2.15 -static BOOL checkOSXVersion(void) {
    2.16 -	return (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_3);
    2.17 -}
    2.18 -
    2.19  @implementation GrowlInstallationPrompt
    2.20  
    2.21  + (void) showInstallationPrompt {
    2.22 -	if (checkOSXVersion()) {
    2.23 +	if (GrowlCheckOSXVersion()) {
    2.24  		[[[[GrowlInstallationPrompt alloc] initWithWindowNibName:GROWL_INSTALLATION_NIB forUpdateToVersion:nil] window] makeKeyAndOrderFront:nil];
    2.25  	}
    2.26  }
    2.27  
    2.28  + (void) showUpdatePromptForVersion:(NSString *)inUpdateVersion {
    2.29 -	if (checkOSXVersion()) {
    2.30 +	if (GrowlCheckOSXVersion()) {
    2.31  		[[[[GrowlInstallationPrompt alloc] initWithWindowNibName:GROWL_INSTALLATION_NIB forUpdateToVersion:inUpdateVersion] window] makeKeyAndOrderFront:nil];
    2.32  	}
    2.33  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/Framework/Source/GrowlVersionCheck.c	Fri Nov 27 20:11:35 2009 -0800
     3.3 @@ -0,0 +1,25 @@
     3.4 +//
     3.5 +//  GrowlVersionCheck.c
     3.6 +//  Growl
     3.7 +//
     3.8 +//  Created by Peter Hosey on 2009-11-27.
     3.9 +//  Copyright 2009 Peter Hosey. All rights reserved.
    3.10 +//
    3.11 +
    3.12 +#include "GrowlVersionCheck.h"
    3.13 +#include <CoreServices/CoreServices.h>
    3.14 +#include "CFGrowlAdditions.h"
    3.15 +
    3.16 +static const SInt32 minimumOSXVersionForGrowl = 0x1050; //Leopard (10.5.0)
    3.17 +
    3.18 +Boolean GrowlCheckOSXVersion(void) {
    3.19 +	SInt32 OSXVersion = 0;
    3.20 +	OSStatus err = Gestalt(gestaltSystemVersion, &OSXVersion);
    3.21 +	if (err != noErr) {
    3.22 +		NSLog(CFSTR("WARNING in GrowlVersionCheck: Could not get Mac OS X version (selector = %x); got error code %li (will show the installation prompt anyway)"), (unsigned)gestaltSystemVersion, (long)err);
    3.23 +
    3.24 +		//We proceed anyway, on the theory that it is better to show the installation prompt when inappropriate than to suppress it when not.
    3.25 +		OSXVersion = minimumOSXVersionForGrowl;
    3.26 +	}
    3.27 +	return (OSXVersion >= minimumOSXVersionForGrowl);
    3.28 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/Framework/Source/GrowlVersionCheck.h	Fri Nov 27 20:11:35 2009 -0800
     4.3 @@ -0,0 +1,9 @@
     4.4 +//
     4.5 +//  GrowlVersionCheck.h
     4.6 +//  Growl
     4.7 +//
     4.8 +//  Created by Peter Hosey on 2009-11-27.
     4.9 +//  Copyright 2009 Peter Hosey. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +Boolean GrowlCheckOSXVersion(void);
     5.1 --- a/Growl.xcodeproj/project.pbxproj	Mon Nov 23 08:32:32 2009 -0800
     5.2 +++ b/Growl.xcodeproj/project.pbxproj	Fri Nov 27 20:11:35 2009 -0800
     5.3 @@ -105,6 +105,8 @@
     5.4  		31E18504108465590011C78B /* GrowlVersionUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = 0790135507D9321B0023B640 /* GrowlVersionUtilities.c */; };
     5.5  		31E185E51084A9780011C78B /* TestVersionComparison.m in Sources */ = {isa = PBXBuildFile; fileRef = 31E185E41084A9780011C78B /* TestVersionComparison.m */; };
     5.6  		31E1863F1084B7500011C78B /* TestVersionComparisonBetweenStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = 31E1863E1084B7500011C78B /* TestVersionComparisonBetweenStrings.m */; };
     5.7 +		31E194ED10C0D38000B48C1C /* GrowlVersionCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 31E194EB10C0D38000B48C1C /* GrowlVersionCheck.h */; };
     5.8 +		31E194EE10C0D38000B48C1C /* GrowlVersionCheck.c in Sources */ = {isa = PBXBuildFile; fileRef = 31E194EC10C0D38000B48C1C /* GrowlVersionCheck.c */; };
     5.9  		342157C00C2AE377004003BB /* PriorityTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 342157BE0C2AE377004003BB /* PriorityTransformer.m */; };
    5.10  		3433456E0790E39200C84B15 /* Bubbles.growlView in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AB508AE0767C87B006EA5CB /* Bubbles.growlView */; };
    5.11  		343345880790E3D600C84B15 /* Smoke.growlView in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AB508AF0767C87B006EA5CB /* Smoke.growlView */; };
    5.12 @@ -715,6 +717,8 @@
    5.13  		31E185E41084A9780011C78B /* TestVersionComparison.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestVersionComparison.m; sourceTree = "<group>"; };
    5.14  		31E1863D1084B7500011C78B /* TestVersionComparisonBetweenStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestVersionComparisonBetweenStrings.h; sourceTree = "<group>"; };
    5.15  		31E1863E1084B7500011C78B /* TestVersionComparisonBetweenStrings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestVersionComparisonBetweenStrings.m; sourceTree = "<group>"; };
    5.16 +		31E194EB10C0D38000B48C1C /* GrowlVersionCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GrowlVersionCheck.h; path = Framework/Source/GrowlVersionCheck.h; sourceTree = "<group>"; };
    5.17 +		31E194EC10C0D38000B48C1C /* GrowlVersionCheck.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = GrowlVersionCheck.c; path = Framework/Source/GrowlVersionCheck.c; sourceTree = "<group>"; };
    5.18  		32DBCFA20370C41700C91783 /* Growl_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Growl_Prefix.pch; path = Core/Source/Growl_Prefix.pch; sourceTree = "<group>"; };
    5.19  		342157BD0C2AE377004003BB /* PriorityTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PriorityTransformer.h; path = Core/Source/PriorityTransformer.h; sourceTree = "<group>"; };
    5.20  		342157BE0C2AE377004003BB /* PriorityTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PriorityTransformer.m; path = Core/Source/PriorityTransformer.m; sourceTree = "<group>"; };
    5.21 @@ -1767,6 +1771,8 @@
    5.22  				07217173082DEDB500F338F7 /* GrowlInstallationPrompt-Carbon.h */,
    5.23  				07217174082DEDB500F338F7 /* GrowlInstallationPrompt-Carbon.c */,
    5.24  				07217168082DE85B00F338F7 /* GrowlInstallationPrompt-Carbon.nib */,
    5.25 +				31E194EB10C0D38000B48C1C /* GrowlVersionCheck.h */,
    5.26 +				31E194EC10C0D38000B48C1C /* GrowlVersionCheck.c */,
    5.27  			);
    5.28  			name = "Growl-WithInstaller.framework";
    5.29  			sourceTree = "<group>";
    5.30 @@ -2145,6 +2151,7 @@
    5.31  				07217175082DEDB500F338F7 /* GrowlInstallationPrompt-Carbon.h in Headers */,
    5.32  				348FEDFE0C9D019900A5B99E /* AEVTBuilder.h in Headers */,
    5.33  				344EA4200CA857F70035CB69 /* NSFileManager+Authentication.h in Headers */,
    5.34 +				31E194ED10C0D38000B48C1C /* GrowlVersionCheck.h in Headers */,
    5.35  			);
    5.36  			runOnlyForDeploymentPostprocessing = 0;
    5.37  		};
    5.38 @@ -2932,6 +2939,7 @@
    5.39  				95D74012084B68C8000D67BC /* GrowlImageAdditions.m in Sources */,
    5.40  				348FEDFD0C9D019900A5B99E /* AEVTBuilder.m in Sources */,
    5.41  				344EA4210CA857F70035CB69 /* NSFileManager+Authentication.m in Sources */,
    5.42 +				31E194EE10C0D38000B48C1C /* GrowlVersionCheck.c in Sources */,
    5.43  			);
    5.44  			runOnlyForDeploymentPostprocessing = 0;
    5.45  		};