diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 1c0f8f70..1555d6cf 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -7,7 +7,7 @@ SDKROOT = macosx10.8 MACOSX_DEPLOYMENT_TARGET[arch=ppc] = 10.4 MACOSX_DEPLOYMENT_TARGET[arch=ppc64] = 10.5 MACOSX_DEPLOYMENT_TARGET[arch=i386] = 10.4 -MACOSX_DEPLOYMENT_TARGET[arch=x86_64] = 10.5 +MACOSX_DEPLOYMENT_TARGET[arch=x86_64] = 10.7 GCC_C_LANGUAGE_STANDARD = c99 GCC_ENABLE_OBJC_EXCEPTIONS = YES GCC_DEBUGGING_SYMBOLS = full @@ -47,4 +47,6 @@ GCC_WARN_UNUSED_VALUE = YES GCC_WARN_UNUSED_PARAMETER = YES GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES GCC_WARN_UNDECLARED_SELECTOR = YES -WARNING_CFLAGS = -Wall -Wno-unused-parameter -Werror -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-format-attribute -Wpacked -Wredundant-decls -Winline -Wdisabled-optimization -Winvalid-pch + +COMMON_WARNING_FLAGS = -Wall -Wno-unused-parameter -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-format-attribute -Wpacked -Wredundant-decls -Winline -Wdisabled-optimization -Winvalid-pch +WARNING_CFLAGS = $(COMMON_WARNING_FLAGS) diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 19e09866..7a4f60e7 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -6,3 +6,4 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO DEAD_CODE_STRIPPING = YES GCC_TREAT_WARNINGS_AS_ERRORS = YES GCC_WARN_UNINITIALIZED_AUTOS = YES +WARNING_CFLAGS = $(COMMON_WARNING_FLAGS) -Wno-deprecated-declarations \ No newline at end of file diff --git a/External/libDMCore.a b/External/libDMCore.a new file mode 100644 index 00000000..5f6015d5 Binary files /dev/null and b/External/libDMCore.a differ diff --git a/SUAppcast.h b/SUAppcast.h index 5a60d2fd..77e4f9f0 100644 --- a/SUAppcast.h +++ b/SUAppcast.h @@ -14,15 +14,17 @@ { @private NSArray *items; - NSString *userAgentString; + NSMutableDictionary *appcastValues; id delegate; NSString *downloadFilename; NSURLDownload *download; } - (void)fetchAppcastFromURL:(NSURL *)url; -- (void)setDelegate:delegate; +- (void)setDelegate:(id)delegate; - (void)setUserAgentString:(NSString *)userAgentString; +- (void)setAppcastValue:(NSString *)value forKey:(NSString *)key; +- (void)setAllAppcastValues:(NSDictionary *)inAppcastValues; - (NSArray *)items; diff --git a/SUAppcast.m b/SUAppcast.m index 726b12dd..8168bc1d 100644 --- a/SUAppcast.m +++ b/SUAppcast.m @@ -43,13 +43,9 @@ - (void)dealloc { [items release]; - items = nil; - [userAgentString release]; - userAgentString = nil; + [appcastValues release]; [downloadFilename release]; - downloadFilename = nil; [download release]; - download = nil; [super dealloc]; } @@ -62,12 +58,15 @@ - (void)fetchAppcastFromURL:(NSURL *)url { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - if (userAgentString) - [request setValue:userAgentString forHTTPHeaderField:@"User-Agent"]; - - if ([SUUpdater shouldUseXPC]) { + if ([appcastValues count]) + [request setAllHTTPHeaderFields:appcastValues]; + + if ([SUUpdater shouldUseXPC]) + { download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self]; - } else { + } + else + { download = [[NSURLDownload alloc] initWithRequest:request delegate:self]; } } @@ -291,11 +290,38 @@ - (void)setUserAgentString:(NSString *)uas { - if (uas != userAgentString) - { - [userAgentString release]; - userAgentString = [uas copy]; - } + [self setAppcastValue:uas forKey:@"User-Agent"]; +} + +- (void)setAppcastValue:(NSString *)value forKey:(NSString *)key +{ + if (nil == key) + return; + + if (nil == appcastValues) + appcastValues = [[NSMutableDictionary alloc] init]; + + if (nil == value) + [appcastValues removeObjectForKey:key]; + else + [appcastValues setValue:[[value copy] autorelease] forKey:key]; +} + +- (void)setAllAppcastValues:(NSDictionary *)inAppcastValues +{ + if (0 == [inAppcastValues count]) + return; + + NSEnumerator *keyEnumerator = [inAppcastValues keyEnumerator]; + id key = nil; + while ((key = [keyEnumerator nextObject])) + { + id value = [inAppcastValues objectForKey:key]; + if (![key isKindOfClass:[NSString class]] || ![value isKindOfClass:[NSString class]]) + continue; + + [self setAppcastValue:value forKey:key]; + } } - (void)setDelegate:del diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 4df8f68a..4b3e60d9 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -23,6 +23,26 @@ #import "SUXPCInstaller.h" #import "SUXPCURLDownload.h" +#define SPARKLE_IS_COMPATIBLE_WITH_DEVMATE (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) + +#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE +CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFDataRef httpBodyData); + +NSArray *SUGetAllDevMateURLHosts(void); +NSArray *SUGetAllDevMateURLHosts(void) +{ + static NSArray *sAllKnownDevMateURLHosts = nil; + if (nil == sAllKnownDevMateURLHosts) + { + sAllKnownDevMateURLHosts = [[NSArray alloc] initWithObjects: + @"updates.devmate.com", + nil]; + } + + return sAllKnownDevMateURLHosts; +} +#endif + @interface SUBasicUpdateDriver () ; @end @@ -43,6 +63,21 @@ [appcast setDelegate:self]; [appcast setUserAgentString:[updater userAgentString]]; + +#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE + if ([SUGetAllDevMateURLHosts() containsObject:[URL host]]) + { + CFBundleRef hostBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:[host bundlePath]]); + CFDictionaryRef devmateAppcastValues = DMCopyHTTPRequestHeaders(hostBundle, NULL); + [appcast setAllAppcastValues:(NSDictionary *)devmateAppcastValues]; + + if (NULL != devmateAppcastValues) + CFRelease(devmateAppcastValues); + if (NULL != hostBundle) + CFRelease(hostBundle); + } +#endif + [appcast fetchAppcastFromURL:URL]; } diff --git a/Sparkle.pch b/Sparkle.pch index 9bd4777f..1dc55d77 100644 --- a/Sparkle.pch +++ b/Sparkle.pch @@ -18,6 +18,10 @@ #define NSAppKitVersionNumber10_6 1038 #endif +#ifndef NSAppKitVersionNumber10_7 +#define NSAppKitVersionNumber10_7 1138 +#endif + #ifdef __OBJC__ #define SPARKLE_BUNDLE [NSBundle bundleWithIdentifier:@"org.andymatuschak.Sparkle"] diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 655890db..1ea05d21 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 03B5E64B15D39CD90038BB67 /* SUXPCURLDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = 03B5E64915D39CD90038BB67 /* SUXPCURLDownload.h */; }; 03B5E65A15D3DC3C0038BB67 /* com.andymatuschak.Sparkle.download-service.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 03B5E63A15D399500038BB67 /* com.andymatuschak.Sparkle.download-service.xpc */; }; 03B5E65B15D3E0490038BB67 /* SUXPCURLDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B5E64A15D39CD90038BB67 /* SUXPCURLDownload.m */; }; + 33D081831888446F00394A94 /* libDMCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D081821888446E00394A94 /* libDMCore.a */; }; 3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 525A2790133D6AE900FD8D70 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 525A278F133D6AE900FD8D70 /* Cocoa.framework */; }; 525A27A0133D6B9700FD8D70 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 525A278F133D6AE900FD8D70 /* Cocoa.framework */; }; @@ -245,6 +246,7 @@ 03B5E64A15D39CD90038BB67 /* SUXPCURLDownload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUXPCURLDownload.m; sourceTree = ""; }; 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 33D081821888446E00394A94 /* libDMCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libDMCore.a; path = External/libDMCore.a; sourceTree = ""; }; 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUVersionDisplayProtocol.h; sourceTree = ""; }; 525A278F133D6AE900FD8D70 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 550347001370023A00AE7681 /* Sparkle.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Sparkle.icns; sourceTree = ""; }; @@ -559,6 +561,7 @@ 5D1AF82B0FD768180065DB48 /* libz.dylib in Frameworks */, 525A2790133D6AE900FD8D70 /* Cocoa.framework in Frameworks */, 55C14F32136EFC2400649790 /* SystemConfiguration.framework in Frameworks */, + 33D081831888446F00394A94 /* libDMCore.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -618,6 +621,7 @@ 089C1665FE841158C02AAC07 /* Framework Resources */, 61227A100DB5484000AB99EA /* Tests */, 61B5F91D09C4CF7F00B25A18 /* Test Application Sources */, + 33D081811888444000394A94 /* External Frameworks and Libraries */, 0867D69AFE84028FC02AAC07 /* Apple Frameworks and Libraries */, FA1941C40D94A6EA00DD942E /* Configurations */, 034768DFFF38A50411DB9C8B /* Products */, @@ -659,6 +663,14 @@ name = "Framework Resources"; sourceTree = ""; }; + 33D081811888444000394A94 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 33D081821888446E00394A94 /* libDMCore.a */, + ); + name = "External Frameworks and Libraries"; + sourceTree = ""; + }; 55C14BD5136EEFD000649790 /* finish_installation tool */ = { isa = PBXGroup; children = ( @@ -1694,6 +1706,10 @@ buildSettings = { COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/External", + ); }; name = Debug; }; @@ -1703,6 +1719,10 @@ buildSettings = { COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/External", + ); }; name = Release; }; @@ -1822,6 +1842,10 @@ buildSettings = { COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/External", + ); }; name = "Release (GC dual-mode; 10.5+)"; }; @@ -1830,7 +1854,6 @@ baseConfigurationReference = 615409A8103BA09100125AF1 /* ConfigTestAppReleaseGCSupport.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; }; name = "Release (GC dual-mode; 10.5+)"; @@ -1864,7 +1887,6 @@ baseConfigurationReference = FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; }; name = Debug; @@ -1874,7 +1896,6 @@ baseConfigurationReference = FA1941D20D94A70100DD942E /* ConfigTestAppRelease.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; }; name = Release; @@ -1919,6 +1940,10 @@ buildSettings = { COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/External", + ); }; name = Deployment; }; @@ -1927,7 +1952,6 @@ baseConfigurationReference = FA1941D20D94A70100DD942E /* ConfigTestAppRelease.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; }; name = Deployment; diff --git a/Sparkle.xcodeproj/xcshareddata/xcschemes/Sparkle.xcscheme b/Sparkle.xcodeproj/xcshareddata/xcschemes/Sparkle.xcscheme index 68039d71..27c52108 100644 --- a/Sparkle.xcodeproj/xcshareddata/xcschemes/Sparkle.xcscheme +++ b/Sparkle.xcodeproj/xcshareddata/xcschemes/Sparkle.xcscheme @@ -79,7 +79,7 @@