diff --git a/Downloader/SPUDownloader.m b/Downloader/SPUDownloader.m index cf72380d..6eb2fed9 100644 --- a/Downloader/SPUDownloader.m +++ b/Downloader/SPUDownloader.m @@ -9,7 +9,6 @@ #import "SPUDownloader.h" #import "SPUDownloaderDelegate.h" #import "SPULocalCacheDirectory.h" -#import "SPUURLRequest.h" #import "SPUDownloadData.h" #import "SPUDownloadDataPrivate.h" #import "SUErrors.h" @@ -61,19 +60,19 @@ static NSString *SUDownloadingReason = @"Downloading update related file"; return self; } -- (void)startDownloadWithRequest:(SPUURLRequest *)request +- (void)startDownloadWithRequest:(NSURLRequest *)request { self.downloadSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]]; - self.download = [self.downloadSession downloadTaskWithRequest:request.request]; + self.download = [self.downloadSession downloadTaskWithRequest:request]; [self.download resume]; } // Don't implement dealloc - make the client call cleanup, which is the only way to remove the reference cycle from the delegate anyway -- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename +- (void)startPersistentDownloadWithRequest:(NSURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename { dispatch_async(dispatch_get_main_queue(), ^{ if (self.download == nil && self.delegate != nil) { @@ -90,7 +89,7 @@ static NSString *SUDownloadingReason = @"Downloading update related file"; }); } -- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request +- (void)startTemporaryDownloadWithRequest:(NSURLRequest *)request { dispatch_async(dispatch_get_main_queue(), ^{ if (self.download == nil && self.delegate != nil) { diff --git a/Downloader/SPUDownloaderProtocol.h b/Downloader/SPUDownloaderProtocol.h index 7af06c70..1e5d036e 100644 --- a/Downloader/SPUDownloaderProtocol.h +++ b/Downloader/SPUDownloaderProtocol.h @@ -10,14 +10,12 @@ NS_ASSUME_NONNULL_BEGIN -@class SPUURLRequest; - // The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service. @protocol SPUDownloaderProtocol -- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename; +- (void)startPersistentDownloadWithRequest:(NSURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename; -- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request; +- (void)startTemporaryDownloadWithRequest:(NSURLRequest *)request; - (void)removeDownloadDirectory:(NSString *)directoryName bundleIdentifier:(NSString *)bundleIdentifier; diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 37563d6a..5f3db4f3 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -338,9 +338,6 @@ 728ED34C277DA23400D9238F /* SPUSparkleDeltaArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = 728ED349277DA23400D9238F /* SPUSparkleDeltaArchive.m */; }; 728ED34D277DA23400D9238F /* SPUSparkleDeltaArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = 728ED349277DA23400D9238F /* SPUSparkleDeltaArchive.m */; }; 729051E41DC82AC0003DEA7F /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; - 7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */; }; - 7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; }; - 7293A1B11CEE9B9F00B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; }; 729743AB279D1BD2009910B2 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */; }; 729924941DF4A45000DBCDF5 /* SUUpdateValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */; }; 729F7EAC27366353004592DC /* test-links.xml in Resources */ = {isa = PBXBuildFile; fileRef = 729F7EAB27366353004592DC /* test-links.xml */; }; @@ -1265,8 +1262,6 @@ 728638EE1CAF589C00783084 /* ConfigDownloader.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigDownloader.xcconfig; sourceTree = ""; }; 728ED348277DA23400D9238F /* SPUSparkleDeltaArchive.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SPUSparkleDeltaArchive.h; path = Autoupdate/SPUSparkleDeltaArchive.h; sourceTree = SOURCE_ROOT; }; 728ED349277DA23400D9238F /* SPUSparkleDeltaArchive.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SPUSparkleDeltaArchive.m; path = Autoupdate/SPUSparkleDeltaArchive.m; sourceTree = SOURCE_ROOT; }; - 7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUURLRequest.h; sourceTree = ""; }; - 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUURLRequest.m; sourceTree = ""; }; 729924921DF4A45000DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUUpdateValidator.h; path = Sparkle/SUUpdateValidator.h; sourceTree = SOURCE_ROOT; }; 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdateValidator.m; path = Sparkle/SUUpdateValidator.m; sourceTree = SOURCE_ROOT; }; 729BB3D11D503826007C4276 /* org.sparkle-project.Downloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.Downloader.entitlements"; path = "Downloader/org.sparkle-project.Downloader.entitlements"; sourceTree = SOURCE_ROOT; }; @@ -1880,8 +1875,6 @@ 721AB11626C777D900D34A86 /* SPUDownloadDataPrivate.h */, 72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */, 7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */, - 7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */, - 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */, 61B5FB9409C4F04600B25A18 /* SUAppcast.h */, 725DED72263D10C400E7FA8F /* SUAppcast+Private.h */, 61B5FB9509C4F04600B25A18 /* SUAppcast.m */, @@ -2457,7 +2450,6 @@ 72F9EC3F1D5E823F004AC8B6 /* SPUUpdaterTimer.h in Headers */, 7269E494264798200088C213 /* SPUSkippedUpdate.h in Headers */, 723ABFC4259D4CB300BDB4FA /* SUWKWebView.h in Headers */, - 7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */, 725CB9571C7120410064365A /* SPUUserDriver.h in Headers */, 72B767DE1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.h in Headers */, 72F94F581CC44DE1002DEE68 /* SPUXPCServiceInfo.h in Headers */, @@ -3409,7 +3401,6 @@ 72E539121D68C3FA0092CE5E /* SPUDownloadData.m in Sources */, 723B5DA91CF7AB0100365F95 /* SPUDownloader.m in Sources */, 721BC2101D1CDE55002BC71E /* SPULocalCacheDirectory.m in Sources */, - 7293A1B11CEE9B9F00B957A7 /* SPUURLRequest.m in Sources */, 728638ED1CAF50CE00783084 /* SUConstants.m in Sources */, 721D8A871D4C5BF10032E472 /* SULog.m in Sources */, ); @@ -3516,7 +3507,6 @@ 726E078E1CA891E9001A286B /* SPUUpdaterSettings.m in Sources */, 721D588F25BE59F900D23BEA /* SUPhasedUpdateGroupInfo.m in Sources */, 72F9EC401D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */, - 7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */, 72B767DF1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.m in Sources */, 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */, 61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */, diff --git a/Sparkle/SPUDownloadDriver.m b/Sparkle/SPUDownloadDriver.m index e8a38cbf..893fc118 100644 --- a/Sparkle/SPUDownloadDriver.m +++ b/Sparkle/SPUDownloadDriver.m @@ -16,7 +16,6 @@ #import "SUHost.h" #import "SULog.h" #import "SUErrors.h" -#import "SPUURLRequest.h" #import "SPUDownloadedUpdate.h" #import "SPUDownloadData.h" @@ -160,9 +159,9 @@ NSString *bundleIdentifier = self.host.bundle.bundleIdentifier; assert(bundleIdentifier != nil); - [self.downloader startPersistentDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:self.request] bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename]; + [self.downloader startPersistentDownloadWithRequest:self.request bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename]; } else { - [self.downloader startTemporaryDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:self.request]]; + [self.downloader startTemporaryDownloadWithRequest:self.request]; } } diff --git a/Sparkle/SPUURLRequest.h b/Sparkle/SPUURLRequest.h deleted file mode 100644 index 62a4a70b..00000000 --- a/Sparkle/SPUURLRequest.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// SPUURLRequest.h -// Sparkle -// -// Created by Mayur Pawashe on 5/19/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -// A class that wraps NSURLRequest and implements NSSecureCoding -// This class exists because NSURLRequest did not support NSSecureCoding in macOS 10.8 -// I have not verified if NSURLRequest in 10.9 implements NSSecureCoding or not -@interface SPUURLRequest : NSObject - -// Creates a new URL request -// Only these properties are currently tracked: -// * URL -// * Cache policy -// * Timeout interval -// * HTTP header fields -// * networkServiceType -+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request; - -@property (nonatomic, readonly) NSURLRequest *request; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sparkle/SPUURLRequest.m b/Sparkle/SPUURLRequest.m deleted file mode 100644 index f70bf648..00000000 --- a/Sparkle/SPUURLRequest.m +++ /dev/null @@ -1,94 +0,0 @@ -// -// SPUURLRequest.m -// Sparkle -// -// Created by Mayur Pawashe on 5/19/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import "SPUURLRequest.h" - - -#include "AppKitPrevention.h" - -static NSString *SPUURLRequestURLKey = @"SPUURLRequestURL"; -static NSString *SPUURLRequestCachePolicyKey = @"SPUURLRequestCachePolicy"; -static NSString *SPUURLRequestTimeoutIntervalKey = @"SPUURLRequestTimeoutInterval"; -static NSString *SPUURLRequestHttpHeaderFieldsKey = @"SPUURLRequestHttpHeaderFields"; -static NSString *SPUURLRequestNetworkServiceTypeKey = @"SPUURLRequestNetworkServiceType"; - -@interface SPUURLRequest () - -@property (nonatomic, readonly) NSURL *url; -@property (nonatomic, readonly) NSURLRequestCachePolicy cachePolicy; -@property (nonatomic, readonly) NSTimeInterval timeoutInterval; -@property (nonatomic, readonly, nullable) NSDictionary *httpHeaderFields; -@property (nonatomic, readonly) NSURLRequestNetworkServiceType networkServiceType; - -@end - -@implementation SPUURLRequest - -@synthesize url = _url; -@synthesize cachePolicy = _cachePolicy; -@synthesize timeoutInterval = _timeoutInterval; -@synthesize httpHeaderFields = _httpHeaderFields; -@synthesize networkServiceType = _networkServiceType; - -- (instancetype)initWithURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval httpHeaderFields:(NSDictionary *)httpHeaderFields networkServiceType:(NSURLRequestNetworkServiceType)networkServiceType -{ - self = [super init]; - if (self != nil) { - _url = url; - _cachePolicy = cachePolicy; - _timeoutInterval = timeoutInterval; - _httpHeaderFields = httpHeaderFields; - _networkServiceType = networkServiceType; - } - return self; -} - -+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request -{ - return [(SPUURLRequest *)[[self class] alloc] initWithURL:request.URL cachePolicy:request.cachePolicy timeoutInterval:request.timeoutInterval httpHeaderFields:request.allHTTPHeaderFields networkServiceType:request.networkServiceType]; -} - -+ (BOOL)supportsSecureCoding -{ - return YES; -} - -- (void)encodeWithCoder:(NSCoder *)coder -{ - [coder encodeObject:self.url forKey:SPUURLRequestURLKey]; - [coder encodeInteger:(NSInteger)self.cachePolicy forKey:SPUURLRequestCachePolicyKey]; - [coder encodeDouble:self.timeoutInterval forKey:SPUURLRequestTimeoutIntervalKey]; - [coder encodeInteger:(NSInteger)self.networkServiceType forKey:SPUURLRequestNetworkServiceTypeKey]; - - if (self.httpHeaderFields != nil) { - [coder encodeObject:self.httpHeaderFields forKey:SPUURLRequestHttpHeaderFieldsKey]; - } -} - -- (instancetype)initWithCoder:(NSCoder *)decoder -{ - NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey]; - NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey]; - NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey]; - NSDictionary *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey]; - NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey]; - - return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType]; -} - -- (NSURLRequest *)request -{ - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:self.cachePolicy timeoutInterval:self.timeoutInterval]; - if (self.httpHeaderFields != nil) { - request.allHTTPHeaderFields = self.httpHeaderFields; - } - request.networkServiceType = self.networkServiceType; - return [request copy]; -} - -@end