diff --git a/NSFileManager+Authentication.m b/NSFileManager+Authentication.m index 7ffcc6ee..f2d98efd 100644 --- a/NSFileManager+Authentication.m +++ b/NSFileManager+Authentication.m @@ -96,9 +96,9 @@ return result; } else if (useAuthentication == YES) - { return [self _copyPathWithForcedAuthentication:src toPath:dst]; - } + else + return NO; } @end diff --git a/SUSystemProfiler.h b/SUSystemProfiler.h new file mode 100644 index 00000000..bf5667b3 --- /dev/null +++ b/SUSystemProfiler.h @@ -0,0 +1,14 @@ +// +// SUSystemProfiler.h +// Sparkle +// +// Created by Andy Matuschak on 12/22/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface SUSystemProfiler : NSObject {} ++ (NSURL *)profiledURLForAppcastURL:(NSURL *)appcastURL hostBundle:(NSBundle *)hostBundle; +@end diff --git a/SUSystemProfiler.m b/SUSystemProfiler.m new file mode 100644 index 00000000..0761ebe6 --- /dev/null +++ b/SUSystemProfiler.m @@ -0,0 +1,133 @@ +// +// SUSystemProfiler.m +// Sparkle +// +// Created by Andy Matuschak on 12/22/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "SUSystemProfiler.h" +#import "NSBundle+SUAdditions.h" +#import + +@implementation SUSystemProfiler ++ (NSDictionary *)modelTranslationTable +{ + NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"]; + return [[NSDictionary alloc] initWithContentsOfFile:path]; +} + ++ (NSMutableArray *)systemProfileInformationArrayWithHostBundle:(NSBundle *)hostBundle +{ + NSDictionary *modelTranslation = [self modelTranslationTable]; + + // Gather profile information and append it to the URL. + NSMutableArray *profileArray = [NSMutableArray array]; + NSArray *profileDictKeys = [NSArray arrayWithObjects:@"key", @"visibleKey", @"value", @"visibleValue", nil]; + int error = 0 ; + int value = 0 ; + unsigned long length = sizeof(value) ; + + // OS version (Apple recommends using SystemVersion.plist instead of Gestalt() here, don't ask me why). + NSString *currentSystemVersion = SUSystemVersionString(); + if (currentSystemVersion != nil) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"osVersion",@"OS Version",currentSystemVersion,currentSystemVersion,nil] forKeys:profileDictKeys]]; + + // CPU type (decoder info for values found here is in mach/machine.h) + error = sysctlbyname("hw.cputype", &value, &length, NULL, 0); + int cpuType = -1; + if (error == 0) { + cpuType = value; + NSString *visibleCPUType; + switch(value) { + case 7: visibleCPUType=@"Intel"; break; + case 18: visibleCPUType=@"PowerPC"; break; + default: visibleCPUType=@"Unknown"; break; + } + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"cputype",@"CPU Type", [NSNumber numberWithInt:value], visibleCPUType,nil] forKeys:profileDictKeys]]; + } + error = sysctlbyname("hw.cpusubtype", &value, &length, NULL, 0); + if (error == 0) { + NSString *visibleCPUSubType; + if (cpuType == 7) { + // Intel + visibleCPUSubType = @"Intel"; // If anyone knows how to tell a Core Duo from a Core Solo, please email tph@atomicbird.com + } else if (cpuType == 18) { + // PowerPC + switch(value) { + case 9: visibleCPUSubType=@"G3"; break; + case 10: case 11: visibleCPUSubType=@"G4"; break; + case 100: visibleCPUSubType=@"G5"; break; + default: visibleCPUSubType=@"Other"; break; + } + } else { + visibleCPUSubType = @"Other"; + } + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"cpusubtype",@"CPU Subtype", [NSNumber numberWithInt:value], visibleCPUSubType,nil] forKeys:profileDictKeys]]; + } + error = sysctlbyname("hw.model", NULL, &length, NULL, 0); + if (error == 0) { + char *cpuModel; + cpuModel = (char *)malloc(sizeof(char) * length); + error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0); + if (error == 0) { + NSString *rawModelName = [NSString stringWithUTF8String:cpuModel]; + NSString *visibleModelName = [modelTranslation objectForKey:rawModelName]; + if (visibleModelName == nil) + visibleModelName = rawModelName; + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"model",@"Mac Model", rawModelName, visibleModelName, nil] forKeys:profileDictKeys]]; + } + if (cpuModel != NULL) + free(cpuModel); + } + + // Number of CPUs + error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0); + if (error == 0) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"ncpu",@"Number of CPUs", [NSNumber numberWithInt:value], [NSNumber numberWithInt:value],nil] forKeys:profileDictKeys]]; + + // User preferred language + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSArray *languages = [defs objectForKey:@"AppleLanguages"]; + if (languages && ([languages count] > 0)) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"lang",@"Preferred Language", [languages objectAtIndex:0], [languages objectAtIndex:0],nil] forKeys:profileDictKeys]]; + + // Application sending the request + NSString *appName = [hostBundle name]; + if (appName) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"appName",@"Application Name", appName, appName,nil] forKeys:profileDictKeys]]; + NSString *appVersion = [hostBundle version]; + if (appVersion) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"appVersion",@"Application Version", appVersion, appVersion,nil] forKeys:profileDictKeys]]; + + // Number of displays? + // CPU speed + OSErr err; + SInt32 gestaltInfo; + err = Gestalt(gestaltProcClkSpeedMHz,&gestaltInfo); + if (err == noErr) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"cpuFreqMHz",@"CPU Speed (MHz)", [NSNumber numberWithInt:gestaltInfo], [NSNumber numberWithInt:gestaltInfo],nil] forKeys:profileDictKeys]]; + + // amount of RAM + err = Gestalt(gestaltPhysicalRAMSizeInMegabytes,&gestaltInfo); + if (err == noErr) + [profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"ramMB",@"Memory (MB)", [NSNumber numberWithInt:gestaltInfo], [NSNumber numberWithInt:gestaltInfo],nil] forKeys:profileDictKeys]]; + + return profileArray; +} + ++ (NSURL *)profiledURLForAppcastURL:(NSURL *)appcastURL hostBundle:(NSBundle *)hostBundle +{ + NSMutableArray *profileInfo = [NSMutableArray array]; + NSEnumerator *profileInfoEnumerator = [[self systemProfileInformationArrayWithHostBundle:hostBundle] objectEnumerator]; + NSDictionary *currentProfileInfo; + while ((currentProfileInfo = [profileInfoEnumerator nextObject])) { + [profileInfo addObject:[NSString stringWithFormat:@"%@=%@", [currentProfileInfo objectForKey:@"key"], [currentProfileInfo objectForKey:@"value"]]]; + } + + NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@?%@", [appcastURL absoluteString], [profileInfo componentsJoinedByString:@"&"]]; + + // Clean it up so it's a valid URL + return [NSURL URLWithString:[appcastStringWithProfile stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; +} +@end diff --git a/SUUpdater.m b/SUUpdater.m index c361afbb..fd83774b 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -34,7 +34,6 @@ - (void)beginDownload; - (void)extractUpdate; - (void)showUpdateErrorAlertWithInfo:(NSString *)info; -- (NSTimeInterval)storedCheckInterval; - (void)abandonUpdate; - (IBAction)installAndRestart:sender; - (NSString *)systemVersionString; @@ -119,13 +118,13 @@ // Now we want to figure out how long until we check again. NSTimeInterval delayUntilCheck; - if (intervalSinceCheck < [self storedCheckInterval]) - delayUntilCheck = ([self storedCheckInterval] - intervalSinceCheck); // It hasn't been long enough. + 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:[self storedCheckInterval]] afterDelay:delayUntilCheck]; + [self performSelector:@selector(scheduleCheckWithIntervalObject:) withObject:[NSNumber numberWithDouble:checkInterval] afterDelay:delayUntilCheck]; } } @@ -492,7 +491,7 @@ [NSApp sendEvent:event]; // Search subdirectories for the application - NSString *currentFile, *newAppDownloadPath, *bundleFileName = [[hostBundle bundlePath] lastPathComponent]; + NSString *currentFile, *newAppDownloadPath = nil, *bundleFileName = [[hostBundle bundlePath] lastPathComponent]; BOOL isPackage = NO; NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:[downloadPath stringByDeletingLastPathComponent]]; while ((currentFile = [dirEnum nextObject])) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index f2fc1353..8d68d0d8 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */; }; 61A2262B0D1C58FD00430CCD /* SUUserDefaults.h in Headers */ = {isa = PBXBuildFile; fileRef = 61A226290D1C58FD00430CCD /* SUUserDefaults.h */; }; 61A2262C0D1C58FD00430CCD /* SUUserDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A2262A0D1C58FD00430CCD /* SUUserDefaults.m */; }; + 61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */; }; + 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */; }; 61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; }; 61AAE8290A321A8000D8810D /* SUAutomaticUpdateAlert.nib in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8240A321A7F00D8810D /* SUAutomaticUpdateAlert.nib */; }; 61AAE82A0A321A8000D8810D /* SUUpdateAlert.nib in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8260A321A7F00D8810D /* SUUpdateAlert.nib */; }; @@ -136,6 +138,8 @@ 61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUStandardVersionComparator.m; sourceTree = ""; }; 61A226290D1C58FD00430CCD /* SUUserDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUserDefaults.h; sourceTree = ""; }; 61A2262A0D1C58FD00430CCD /* SUUserDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUserDefaults.m; sourceTree = ""; }; + 61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUSystemProfiler.h; sourceTree = ""; }; + 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUSystemProfiler.m; sourceTree = ""; }; 61AAE8230A321A7F00D8810D /* en */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Sparkle.strings; sourceTree = ""; }; 61AAE8250A321A7F00D8810D /* en */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = en; path = en.lproj/SUAutomaticUpdateAlert.nib; sourceTree = ""; }; 61AAE8270A321A7F00D8810D /* en */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = en; path = en.lproj/SUUpdateAlert.nib; sourceTree = ""; }; @@ -421,6 +425,8 @@ 61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */, 61A226290D1C58FD00430CCD /* SUUserDefaults.h */, 61A2262A0D1C58FD00430CCD /* SUUserDefaults.m */, + 61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */, + 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */, ); includeInIndex = 1; name = Utilities; @@ -464,6 +470,7 @@ 61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */, 61A225A40D1C4AC000430CCD /* SUStandardVersionComparator.h in Headers */, 61A2262B0D1C58FD00430CCD /* SUUserDefaults.h in Headers */, + 61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -659,6 +666,7 @@ 61A225940D1C3ADD00430CCD /* NSBundle+SUAdditions.m in Sources */, 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */, 61A2262C0D1C58FD00430CCD /* SUUserDefaults.m in Sources */, + 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -835,6 +843,8 @@ ); OTHER_LDFLAGS = "-lcrypto"; PRODUCT_NAME = Sparkle; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + "SDKROOT[arch=ppc]" = /Developer/SDKs/MacOSX10.3.9.sdk; SKIP_INSTALL = YES; STRIP_INSTALLED_PRODUCT = NO; WARNING_CFLAGS = "-Wall"; @@ -855,8 +865,8 @@ CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)"; COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; + DYLIB_COMPATIBILITY_VERSION = 1.5; + DYLIB_CURRENT_VERSION = 1.5; FRAMEWORK_VERSION = A; GCC_C_LANGUAGE_STANDARD = c99; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -865,14 +875,20 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Sparkle_Prefix.pch; + GCC_REUSE_STRINGS = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "@executable_path/../Frameworks"; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 10.3; + "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; + "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; OTHER_LDFLAGS = "-lcrypto"; PREBINDING = YES; PRODUCT_NAME = Sparkle; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + "SDKROOT[arch=ppc]" = /Developer/SDKs/MacOSX10.3.9.sdk; + "SDKROOT[arch=x86_64]" = /Developer/SDKs/MacOSX10.5.sdk; SKIP_INSTALL = YES; STRIP_INSTALLED_PRODUCT = NO; STRIP_STYLE = all; @@ -888,13 +904,11 @@ ARCHS = ( i386, ppc, - ppc64, - x86_64, ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.5; + MACOSX_DEPLOYMENT_TARGET = 10.4; "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.3; OTHER_CFLAGS = "-fsingle-precision-constant"; @@ -902,6 +916,7 @@ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; "SDKROOT[arch=i386]" = /Developer/SDKs/MacOSX10.4u.sdk; "SDKROOT[arch=ppc]" = /Developer/SDKs/MacOSX10.4u.sdk; + VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; WARNING_CFLAGS = "-wall"; }; name = Debug; @@ -912,13 +927,11 @@ ARCHS = ( i386, ppc, - ppc64, - x86_64, ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.5; + MACOSX_DEPLOYMENT_TARGET = 10.4; "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.3; OTHER_CFLAGS = "-fsingle-precision-constant"; @@ -926,6 +939,7 @@ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; "SDKROOT[arch=i386]" = /Developer/SDKs/MacOSX10.4u.sdk; "SDKROOT[arch=ppc]" = /Developer/SDKs/MacOSX10.4u.sdk; + VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; WARNING_CFLAGS = "-wall"; }; name = Release; diff --git a/en.lproj/SUUpdateAlert.nib/info.nib b/en.lproj/SUUpdateAlert.nib/info.nib index 34649eb3..1bfdea32 100644 --- a/en.lproj/SUUpdateAlert.nib/info.nib +++ b/en.lproj/SUUpdateAlert.nib/info.nib @@ -10,7 +10,7 @@ 5 IBOpenObjects - 5 + 6 IBSystem Version 9B18 diff --git a/en.lproj/SUUpdateAlert.nib/keyedobjects.nib b/en.lproj/SUUpdateAlert.nib/keyedobjects.nib index 4d2156a4..a09a0f86 100644 Binary files a/en.lproj/SUUpdateAlert.nib/keyedobjects.nib and b/en.lproj/SUUpdateAlert.nib/keyedobjects.nib differ