Commits

Peter Hosey committed 2f99d2f

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.

  • Participants
  • Parent commits acb44d1
  • Branches default

Comments (0)

Files changed (5)

Framework/Source/GrowlInstallationPrompt-Carbon.c

 #include "GrowlDefinesInternal.h"
 #include "GrowlInstallationPrompt-Carbon.h"
 #include "GrowlApplicationBridge-Carbon.h"
+#include "GrowlVersionCheck.h"
 
 #include <QuickTime/QuickTime.h>
 #include <alloca.h>
 
 #pragma mark -
 
-static const long minimumOSXVersionForGrowl = 0x1030L; //Panther (10.3.0)
-
-static Boolean _checkOSXVersion(void) {
-	long OSXVersion = 0L;
-	OSStatus err = Gestalt(gestaltSystemVersion, &OSXVersion);
-	if (err != noErr) {
-		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);
-		//we proceed anyway, on the theory that it is better to show the installation prompt when inappropriate than to suppress it when not.
-		OSXVersion = minimumOSXVersionForGrowl;
-	}
-	return (OSXVersion >= minimumOSXVersionForGrowl);
-}
-
-#pragma mark -
-
 static OSStatus _handleCommandInWindow(EventHandlerCallRef nextHandler, EventRef event, void *refcon);
 
 static OSStatus _fillOutTextInWindow(WindowRef window, Boolean isUpdate);
 OSStatus _Growl_ShowUpdatePromptForVersion(CFStringRef updateVersion) {
 	OSStatus err = noErr;
 
-	if (_checkOSXVersion()) {
+	if (GrowlCheckOSXVersion()) {
 		CFBundleRef bundle = CFBundleGetBundleWithIdentifier(GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
 		if (!bundle)
 			NSLog(CFSTR("GrowlInstallationPrompt: could not locate framework bundle (forget about installing Growl); had looked for bundle with identifier '%@'"), GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);

Framework/Source/GrowlInstallationPrompt.m

 #import "GrowlPathUtilities.h"
 #import "GrowlDefines.h"
 #import "GrowlDefinesInternal.h"
+#import "GrowlVersionCheck.h"
 
 #import "AEVTBuilder.h"
 #import	"NSFileManager+Authentication.h"
 - (void) releaseAndClose;
 @end
 
-static BOOL checkOSXVersion(void) {
-	return (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_3);
-}
-
 @implementation GrowlInstallationPrompt
 
 + (void) showInstallationPrompt {
-	if (checkOSXVersion()) {
+	if (GrowlCheckOSXVersion()) {
 		[[[[GrowlInstallationPrompt alloc] initWithWindowNibName:GROWL_INSTALLATION_NIB forUpdateToVersion:nil] window] makeKeyAndOrderFront:nil];
 	}
 }
 
 + (void) showUpdatePromptForVersion:(NSString *)inUpdateVersion {
-	if (checkOSXVersion()) {
+	if (GrowlCheckOSXVersion()) {
 		[[[[GrowlInstallationPrompt alloc] initWithWindowNibName:GROWL_INSTALLATION_NIB forUpdateToVersion:inUpdateVersion] window] makeKeyAndOrderFront:nil];
 	}
 }

Framework/Source/GrowlVersionCheck.c

+//
+//  GrowlVersionCheck.c
+//  Growl
+//
+//  Created by Peter Hosey on 2009-11-27.
+//  Copyright 2009 Peter Hosey. All rights reserved.
+//
+
+#include "GrowlVersionCheck.h"
+#include <CoreServices/CoreServices.h>
+#include "CFGrowlAdditions.h"
+
+static const SInt32 minimumOSXVersionForGrowl = 0x1050; //Leopard (10.5.0)
+
+Boolean GrowlCheckOSXVersion(void) {
+	SInt32 OSXVersion = 0;
+	OSStatus err = Gestalt(gestaltSystemVersion, &OSXVersion);
+	if (err != noErr) {
+		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);
+
+		//We proceed anyway, on the theory that it is better to show the installation prompt when inappropriate than to suppress it when not.
+		OSXVersion = minimumOSXVersionForGrowl;
+	}
+	return (OSXVersion >= minimumOSXVersionForGrowl);
+}

Framework/Source/GrowlVersionCheck.h

+//
+//  GrowlVersionCheck.h
+//  Growl
+//
+//  Created by Peter Hosey on 2009-11-27.
+//  Copyright 2009 Peter Hosey. All rights reserved.
+//
+
+Boolean GrowlCheckOSXVersion(void);

Growl.xcodeproj/project.pbxproj

 		31E18504108465590011C78B /* GrowlVersionUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = 0790135507D9321B0023B640 /* GrowlVersionUtilities.c */; };
 		31E185E51084A9780011C78B /* TestVersionComparison.m in Sources */ = {isa = PBXBuildFile; fileRef = 31E185E41084A9780011C78B /* TestVersionComparison.m */; };
 		31E1863F1084B7500011C78B /* TestVersionComparisonBetweenStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = 31E1863E1084B7500011C78B /* TestVersionComparisonBetweenStrings.m */; };
+		31E194ED10C0D38000B48C1C /* GrowlVersionCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 31E194EB10C0D38000B48C1C /* GrowlVersionCheck.h */; };
+		31E194EE10C0D38000B48C1C /* GrowlVersionCheck.c in Sources */ = {isa = PBXBuildFile; fileRef = 31E194EC10C0D38000B48C1C /* GrowlVersionCheck.c */; };
 		342157C00C2AE377004003BB /* PriorityTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 342157BE0C2AE377004003BB /* PriorityTransformer.m */; };
 		3433456E0790E39200C84B15 /* Bubbles.growlView in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AB508AE0767C87B006EA5CB /* Bubbles.growlView */; };
 		343345880790E3D600C84B15 /* Smoke.growlView in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AB508AF0767C87B006EA5CB /* Smoke.growlView */; };
 		31E185E41084A9780011C78B /* TestVersionComparison.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestVersionComparison.m; sourceTree = "<group>"; };
 		31E1863D1084B7500011C78B /* TestVersionComparisonBetweenStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestVersionComparisonBetweenStrings.h; sourceTree = "<group>"; };
 		31E1863E1084B7500011C78B /* TestVersionComparisonBetweenStrings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestVersionComparisonBetweenStrings.m; sourceTree = "<group>"; };
+		31E194EB10C0D38000B48C1C /* GrowlVersionCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GrowlVersionCheck.h; path = Framework/Source/GrowlVersionCheck.h; sourceTree = "<group>"; };
+		31E194EC10C0D38000B48C1C /* GrowlVersionCheck.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = GrowlVersionCheck.c; path = Framework/Source/GrowlVersionCheck.c; sourceTree = "<group>"; };
 		32DBCFA20370C41700C91783 /* Growl_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Growl_Prefix.pch; path = Core/Source/Growl_Prefix.pch; sourceTree = "<group>"; };
 		342157BD0C2AE377004003BB /* PriorityTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PriorityTransformer.h; path = Core/Source/PriorityTransformer.h; sourceTree = "<group>"; };
 		342157BE0C2AE377004003BB /* PriorityTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PriorityTransformer.m; path = Core/Source/PriorityTransformer.m; sourceTree = "<group>"; };
 				07217173082DEDB500F338F7 /* GrowlInstallationPrompt-Carbon.h */,
 				07217174082DEDB500F338F7 /* GrowlInstallationPrompt-Carbon.c */,
 				07217168082DE85B00F338F7 /* GrowlInstallationPrompt-Carbon.nib */,
+				31E194EB10C0D38000B48C1C /* GrowlVersionCheck.h */,
+				31E194EC10C0D38000B48C1C /* GrowlVersionCheck.c */,
 			);
 			name = "Growl-WithInstaller.framework";
 			sourceTree = "<group>";
 				07217175082DEDB500F338F7 /* GrowlInstallationPrompt-Carbon.h in Headers */,
 				348FEDFE0C9D019900A5B99E /* AEVTBuilder.h in Headers */,
 				344EA4200CA857F70035CB69 /* NSFileManager+Authentication.h in Headers */,
+				31E194ED10C0D38000B48C1C /* GrowlVersionCheck.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				95D74012084B68C8000D67BC /* GrowlImageAdditions.m in Sources */,
 				348FEDFD0C9D019900A5B99E /* AEVTBuilder.m in Sources */,
 				344EA4210CA857F70035CB69 /* NSFileManager+Authentication.m in Sources */,
+				31E194EE10C0D38000B48C1C /* GrowlVersionCheck.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};