Remove TemporaryDownloader XPC Service

Temporary downloads now use the Persistent Downloader code
This commit is contained in:
Zorg committed 2016-08-20 12:14:31 -04:00
1 parent e476ca2cf0
commit eb53b58e2b
18 files changed
+123 -462

No files matched your search

+1 -2
View File
@@ -34,10 +34,9 @@ PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034id
INSTALLER_CONNECTION_BUNDLE_ID = org.sparkle-project.InstallerConnection
INSTALLER_STATUS_BUNDLE_ID = org.sparkle-project.InstallerStatus
INSTALLER_LAUNCHER_BUNDLE_ID = org.sparkle-project.InstallerLauncher
TEMPORARY_DOWNLOADER_BUNDLE_ID = org.sparkle-project.TemporaryDownloader
PERSISTENT_DOWNLOADER_BUNDLE_ID = org.sparkle-project.PersistentDownloader
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" TEMPORARY_DOWNLOADER_BUNDLE_ID=\"${TEMPORARY_DOWNLOADER_BUNDLE_ID}\" PERSISTENT_DOWNLOADER_BUNDLE_ID=\"${PERSISTENT_DOWNLOADER_BUNDLE_ID}\"
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" PERSISTENT_DOWNLOADER_BUNDLE_ID=\"${PERSISTENT_DOWNLOADER_BUNDLE_ID}\"
CLANG_ENABLE_OBJC_ARC = YES
GCC_ENABLE_PASCAL_STRINGS = NO
@@ -1,7 +0,0 @@
// TemporaryDownloader
INFOPLIST_FILE = TemporaryDownloader/Info.plist
WRAPPER_EXTENSION = xpc
PRODUCT_BUNDLE_IDENTIFIER = ${TEMPORARY_DOWNLOADER_BUNDLE_ID}
PRODUCT_NAME = ${TEMPORARY_DOWNLOADER_BUNDLE_ID}
CODE_SIGN_ENTITLEMENTS = TemporaryDownloader/${TEMPORARY_DOWNLOADER_BUNDLE_ID}.entitlements
@@ -1,4 +0,0 @@
// TemporaryDownloader Debug
#include "ConfigTemporaryDownloader.xcconfig"
CODE_SIGN_IDENTITY = -
-3
View File
@@ -24,11 +24,9 @@ if [ "$ACTION" = "" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_LAUNCHER_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$PERSISTENT_DOWNLOADER_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$TEMPORARY_DOWNLOADER_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_CONNECTION_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp "$SRCROOT/TemporaryDownloader/$TEMPORARY_DOWNLOADER_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp "$SRCROOT/PersistentDownloader/$PERSISTENT_DOWNLOADER_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
# Only copy dSYMs for Release builds, but don't check for the presence of the actual files
@@ -41,7 +39,6 @@ if [ "$ACTION" = "" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_LAUNCHER_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$PERSISTENT_DOWNLOADER_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$TEMPORARY_DOWNLOADER_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_CONNECTION_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
fi
@@ -2,14 +2,11 @@
# We should make sure ATS is off for the test app
TEMPORARY_INFO_PLIST="${TARGET_BUILD_DIR}"/"${CONTENTS_FOLDER_PATH}"/"XPCServices"/"${TEMPORARY_DOWNLOADER_BUNDLE_ID}.xpc"/"Contents"/"Info.plist"
PERSISTENT_INFO_PLIST="${TARGET_BUILD_DIR}"/"${CONTENTS_FOLDER_PATH}"/"XPCServices"/"${PERSISTENT_DOWNLOADER_BUNDLE_ID}.xpc"/"Contents"/"Info.plist"
#Only alter bundles if code signing is off, else we'll invalidate the signature on them
#If code signing is enabled (as in debug mode), then we rely on another script for turning ATS exceptions on for these services
#In release mode however, those services do not have ATS exceptions set up which is why we have to set up exceptions *here*
if [ -z ${CODE_SIGN_IDENTITY}] ; then
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${TEMPORARY_INFO_PLIST}"
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${PERSISTENT_INFO_PLIST}"
fi
+41 -15
View File
@@ -17,6 +17,12 @@
#error This is a "core" class and should NOT import AppKit
#endif
typedef NS_ENUM(NSUInteger, SPUDownloadMode)
{
SPUDownloadModePersistent,
SPUDownloadModeTemporary
};
static NSString *SUPersistentDownloadingReason = @"Downloading persistent file";
@interface SUPersistentDownloader () <NSURLDownloadDelegate>
@@ -55,18 +61,34 @@ static NSString *SUPersistentDownloadingReason = @"Downloading persistent file";
// Don't implement dealloc - make the client call cleanup, which is the only way to remove the reference cycle from the delegate anyway
- (void)startDownloadWithRequest:(SPUURLRequest *)request mode:(SPUDownloadMode)mode bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
{
dispatch_async(dispatch_get_main_queue(), ^{
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUPersistentDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = mode;
self.desiredFilename = desiredFilename;
self.bundleIdentifier = bundleIdentifier;
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
if (self.download == nil && self.delegate != nil) {
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUPersistentDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = SPUDownloadModePersistent;
self.desiredFilename = desiredFilename;
self.bundleIdentifier = bundleIdentifier;
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
}
});
}
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.download == nil && self.delegate != nil) {
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUPersistentDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = SPUDownloadModeTemporary;
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
}
});
}
@@ -150,15 +172,19 @@ static NSString *SUPersistentDownloadingReason = @"Downloading persistent file";
{
self.response = response;
// It might be tempting to send over the response object instead of the expected content length but this isn't a good idea
// For one, we are only ever concerned about the expected content length
// Another reason is that NSURLResponse doesn't support NSSecureCoding in older OS releases (eg: 10.8), which cause issues with XPC
[self.delegate downloaderDidReceiveExpectedContentLength:response.expectedContentLength];
if (self.mode == SPUDownloadModePersistent) {
// It might be tempting to send over the response object instead of the expected content length but this isn't a good idea
// For one, we are only ever concerned about the expected content length
// Another reason is that NSURLResponse doesn't support NSSecureCoding in older OS releases (eg: 10.8), which cause issues with XPC
[self.delegate downloaderDidReceiveExpectedContentLength:response.expectedContentLength];
}
}
- (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length
{
[self.delegate downloaderDidReceiveDataOfLength:length];
if (self.mode == SPUDownloadModePersistent) {
[self.delegate downloaderDidReceiveDataOfLength:length];
}
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
@@ -18,11 +18,13 @@ NS_ASSUME_NONNULL_BEGIN
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
// Under rare cases, this may be called more than once, in which case the current progress should be reset back to 0
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveDataOfLength:(NSUInteger)length;
// downloadData is nil if this is a persisent download
// downloadData is nil if this is a persisent download, otherwise it's non-nil if it's a temporary download
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData;
- (void)downloaderDidFailWithError:(NSError *)error;
@@ -12,16 +12,12 @@ NS_ASSUME_NONNULL_BEGIN
@class SPUURLRequest;
typedef NS_ENUM(NSUInteger, SPUDownloadMode)
{
SPUDownloadModePersistent,
SPUDownloadModeTemporary
};
// 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 SUPersistentDownloaderProtocol
- (void)startDownloadWithRequest:(SPUURLRequest *)request mode:(SPUDownloadMode)mode bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
@end
-161
View File
@@ -136,9 +136,6 @@
723B5DAA1CF7AB6A00365F95 /* SUPersistentDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 723B5DA31CF7AB0100365F95 /* SUPersistentDownloader.m */; };
7246E0A31C83B685003B4E75 /* SPUStandardUpdaterController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7246E0A11C83B685003B4E75 /* SPUStandardUpdaterController.h */; settings = {ATTRIBUTES = (Public, ); }; };
7246E0A41C83B685003B4E75 /* SPUStandardUpdaterController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7246E0A21C83B685003B4E75 /* SPUStandardUpdaterController.m */; };
724A0A3B1CF7AEEA00D8C3D5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724A0A351CF7AEEA00D8C3D5 /* main.m */; };
724A0A3D1CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 724A0A381CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m */; };
724A0A3E1CF7AF0E00D8C3D5 /* SUTemporaryDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 724A0A381CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m */; };
724BB3711D31D0B7005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; };
724BB3731D31D0B7005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3721D31D0B7005D534A /* main.m */; };
724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB36C1D31D0B7005D534A /* org.sparkle-project.InstallerConnection.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -266,7 +263,6 @@
728638ED1CAF50CE00783084 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */; };
7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
7293A1B01CEE9B9800B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
7293A1B11CEE9B9F00B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
72A1C2631CD6849C004CD282 /* SPUUpdatePermissionPrompt.h in Headers */ = {isa = PBXBuildFile; fileRef = 612DCBAD0D488BC60015DBEA /* SPUUpdatePermissionPrompt.h */; };
72A450531C69A68900D67EEA /* SPUUpdatePermissionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SPUUpdatePermissionResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -322,18 +318,14 @@
72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */; };
72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07AD1CAF08D6001A286B /* org.sparkle-project.InstallerLauncher.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
72F94F5E1CC455B4002DEE68 /* org.sparkle-project.PersistentDownloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* org.sparkle-project.PersistentDownloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
72F94F5F1CC455B4002DEE68 /* org.sparkle-project.TemporaryDownloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 728638F31CAF5A5F00783084 /* org.sparkle-project.TemporaryDownloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; };
72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */; };
72F9EC341D5BF542004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; };
72F9EC351D5BF54E004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; };
72F9EC3B1D5C15D0004AC8B6 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
72F9EC3F1D5E823F004AC8B6 /* SPUUpdaterTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC3D1D5E823F004AC8B6 /* SPUUpdaterTimer.h */; };
72F9EC401D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */; };
72F9EC411D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */; };
72F9EC441D5E9ED8004AC8B6 /* SPUDownloadData.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */; settings = {ATTRIBUTES = (Public, ); }; };
72F9EC451D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */; };
72F9EC461D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */; };
72F9EC481D5EA904004AC8B6 /* SPUUpdaterDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC471D5EA7D3004AC8B6 /* SPUUpdaterDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
72F9EC4B1D5F53A7004AC8B6 /* SPUUserDriverUIComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC491D5F53A7004AC8B6 /* SPUUserDriverUIComponent.h */; settings = {ATTRIBUTES = (Public, ); }; };
72F9EC4C1D5F53A7004AC8B6 /* SPUUserDriverUIComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC4A1D5F53A7004AC8B6 /* SPUUserDriverUIComponent.m */; };
@@ -490,13 +482,6 @@
remoteGlobalIDString = 726E07EE1CAF37BD001A286B;
remoteInfo = SparkleUpdateDownloader;
};
72F94F651CC48669002DEE68 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 728638F21CAF5A5F00783084;
remoteInfo = SparkleAppcastDownloader;
};
72F94F6A1CC4A0C8002DEE68 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
@@ -511,13 +496,6 @@
remoteGlobalIDString = 726E07EE1CAF37BD001A286B;
remoteInfo = SparkleUpdateDownloader;
};
72F94F6E1CC4A0C8002DEE68 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 728638F21CAF5A5F00783084;
remoteInfo = SparkleAppcastDownloader;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -576,7 +554,6 @@
724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */,
72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */,
72F94F5E1CC455B4002DEE68 /* org.sparkle-project.PersistentDownloader.xpc in Embed XPC Services */,
72F94F5F1CC455B4002DEE68 /* org.sparkle-project.TemporaryDownloader.xpc in Embed XPC Services */,
726E4A211C86C88F00C57C6A /* TestAppHelper.xpc in Embed XPC Services */,
);
name = "Embed XPC Services";
@@ -843,11 +820,6 @@
723B5DA51CF7AB0100365F95 /* SUPersistentDownloaderProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUPersistentDownloaderProtocol.h; path = PersistentDownloader/SUPersistentDownloaderProtocol.h; sourceTree = SOURCE_ROOT; };
7246E0A11C83B685003B4E75 /* SPUStandardUpdaterController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUStandardUpdaterController.h; sourceTree = "<group>"; };
7246E0A21C83B685003B4E75 /* SPUStandardUpdaterController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUStandardUpdaterController.m; sourceTree = "<group>"; };
724A0A341CF7AEEA00D8C3D5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = TemporaryDownloader/Info.plist; sourceTree = SOURCE_ROOT; };
724A0A351CF7AEEA00D8C3D5 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = TemporaryDownloader/main.m; sourceTree = SOURCE_ROOT; };
724A0A371CF7AEEA00D8C3D5 /* SUTemporaryDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUTemporaryDownloader.h; path = TemporaryDownloader/SUTemporaryDownloader.h; sourceTree = SOURCE_ROOT; };
724A0A381CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUTemporaryDownloader.m; path = TemporaryDownloader/SUTemporaryDownloader.m; sourceTree = SOURCE_ROOT; };
724A0A391CF7AEEA00D8C3D5 /* SUTemporaryDownloaderProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUTemporaryDownloaderProtocol.h; path = TemporaryDownloader/SUTemporaryDownloaderProtocol.h; sourceTree = SOURCE_ROOT; };
724BB36C1D31D0B7005D534A /* org.sparkle-project.InstallerConnection.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "org.sparkle-project.InstallerConnection.xpc"; sourceTree = BUILT_PRODUCTS_DIR; };
724BB36E1D31D0B7005D534A /* SUInstallerConnectionProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUInstallerConnectionProtocol.h; sourceTree = "<group>"; };
724BB36F1D31D0B7005D534A /* SUInstallerConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUInstallerConnection.h; sourceTree = "<group>"; };
@@ -967,14 +939,11 @@
728337A41C9E6FF40085AA99 /* SUProbeInstallStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbeInstallStatus.h; sourceTree = "<group>"; };
728337A51C9E6FF40085AA99 /* SUProbeInstallStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUProbeInstallStatus.m; sourceTree = "<group>"; };
728638EE1CAF589C00783084 /* ConfigPersistentDownloader.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigPersistentDownloader.xcconfig; sourceTree = "<group>"; };
728638F31CAF5A5F00783084 /* org.sparkle-project.TemporaryDownloader.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "org.sparkle-project.TemporaryDownloader.xpc"; sourceTree = BUILT_PRODUCTS_DIR; };
728639041CAF614000783084 /* ConfigTemporaryDownloader.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTemporaryDownloader.xcconfig; sourceTree = "<group>"; };
7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUURLRequest.h; sourceTree = "<group>"; };
7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUURLRequest.m; sourceTree = "<group>"; };
729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-test-app.sh"; sourceTree = "<group>"; };
729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-downloader-service.sh"; sourceTree = "<group>"; };
729BB3D11D503826007C4276 /* org.sparkle-project.PersistentDownloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.PersistentDownloader.entitlements"; path = "PersistentDownloader/org.sparkle-project.PersistentDownloader.entitlements"; sourceTree = SOURCE_ROOT; };
729BB3D21D503834007C4276 /* org.sparkle-project.TemporaryDownloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.TemporaryDownloader.entitlements"; path = "TemporaryDownloader/org.sparkle-project.TemporaryDownloader.entitlements"; sourceTree = SOURCE_ROOT; };
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = "<group>"; };
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = "<group>"; };
72A450511C69A68900D67EEA /* SPUUpdatePermissionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUpdatePermissionResponse.h; sourceTree = "<group>"; };
@@ -1034,7 +1003,6 @@
72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ShowInstallerProgress.m; path = Sparkle/InstallerProgress/ShowInstallerProgress.m; sourceTree = SOURCE_ROOT; };
72F94ED51CC3441A002DEE68 /* ConfigInstallerLauncherDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigInstallerLauncherDebug.xcconfig; sourceTree = "<group>"; };
72F94ED61CC344A7002DEE68 /* ConfigPersistentDownloaderDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigPersistentDownloaderDebug.xcconfig; sourceTree = "<group>"; };
72F94ED71CC344E4002DEE68 /* ConfigTemporaryDownloaderDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTemporaryDownloaderDebug.xcconfig; sourceTree = "<group>"; };
72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTestAppDebug.xcconfig; sourceTree = "<group>"; };
72F94EDB1CC36C6F002DEE68 /* ConfigTestAppHelperDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTestAppHelperDebug.xcconfig; sourceTree = "<group>"; };
72F94F561CC44DE1002DEE68 /* SPUXPCServiceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUXPCServiceInfo.h; sourceTree = "<group>"; };
@@ -1156,13 +1124,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
728638F01CAF5A5F00783084 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
72B398CF1D3D879300EE297F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -1207,7 +1168,6 @@
726E4A161C86C88F00C57C6A /* TestAppHelper.xpc */,
726E07AD1CAF08D6001A286B /* org.sparkle-project.InstallerLauncher.xpc */,
726E07EF1CAF37BD001A286B /* org.sparkle-project.PersistentDownloader.xpc */,
728638F31CAF5A5F00783084 /* org.sparkle-project.TemporaryDownloader.xpc */,
721C24451CB753E6005440CB /* Updater.app */,
72D9549E1CBB415B006F28BD /* sparkle.app */,
724BB36C1D31D0B7005D534A /* org.sparkle-project.InstallerConnection.xpc */,
@@ -1742,20 +1702,6 @@
path = ../TestAppHelper;
sourceTree = "<group>";
};
728638F41CAF5A5F00783084 /* TemporaryDownloader */ = {
isa = PBXGroup;
children = (
724A0A341CF7AEEA00D8C3D5 /* Info.plist */,
729BB3D21D503834007C4276 /* org.sparkle-project.TemporaryDownloader.entitlements */,
724A0A351CF7AEEA00D8C3D5 /* main.m */,
724A0A371CF7AEEA00D8C3D5 /* SUTemporaryDownloader.h */,
724A0A381CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m */,
724A0A391CF7AEEA00D8C3D5 /* SUTemporaryDownloaderProtocol.h */,
);
name = TemporaryDownloader;
path = ../AppcastDownloader;
sourceTree = "<group>";
};
729746481C91483B00FC134E /* IPC */ = {
isa = PBXGroup;
children = (
@@ -1806,7 +1752,6 @@
children = (
72F94F561CC44DE1002DEE68 /* SPUXPCServiceInfo.h */,
72F94F571CC44DE1002DEE68 /* SPUXPCServiceInfo.m */,
728638F41CAF5A5F00783084 /* TemporaryDownloader */,
726E07AE1CAF08D6001A286B /* InstallerLauncher */,
726E07F01CAF37BD001A286B /* PersistentDownloader */,
724BB36D1D31D0B7005D534A /* InstallerConnection */,
@@ -1854,8 +1799,6 @@
724BB3A51D3338C8005D534A /* ConfigInstallerStatusDebug.xcconfig */,
728638EE1CAF589C00783084 /* ConfigPersistentDownloader.xcconfig */,
72F94ED61CC344A7002DEE68 /* ConfigPersistentDownloaderDebug.xcconfig */,
728639041CAF614000783084 /* ConfigTemporaryDownloader.xcconfig */,
72F94ED71CC344E4002DEE68 /* ConfigTemporaryDownloaderDebug.xcconfig */,
72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */,
14732BC91960F70A00593899 /* make-release-package.sh */,
14652F7919A93E5F00959E44 /* set-git-version-info.sh */,
@@ -1968,7 +1911,6 @@
72DBA37A1D5FDE95002594A8 /* PBXTargetDependency */,
72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */,
72F94F6D1CC4A0C8002DEE68 /* PBXTargetDependency */,
72F94F6F1CC4A0C8002DEE68 /* PBXTargetDependency */,
1454BA1619637EDB00344E57 /* PBXTargetDependency */,
14732BCF1960F73500593899 /* PBXTargetDependency */,
1454BA1819637EE900344E57 /* PBXTargetDependency */,
@@ -2033,7 +1975,6 @@
724BB3831D3203A9005D534A /* PBXTargetDependency */,
72F94F621CC48669002DEE68 /* PBXTargetDependency */,
72F94F641CC48669002DEE68 /* PBXTargetDependency */,
72F94F661CC48669002DEE68 /* PBXTargetDependency */,
726E4A201C86C88F00C57C6A /* PBXTargetDependency */,
724BB39D1D333832005D534A /* PBXTargetDependency */,
);
@@ -2166,24 +2107,6 @@
productReference = 726E4A161C86C88F00C57C6A /* TestAppHelper.xpc */;
productType = "com.apple.product-type.xpc-service";
};
728638F21CAF5A5F00783084 /* SparkleTemporaryDownloader */ = {
isa = PBXNativeTarget;
buildConfigurationList = 728638FF1CAF5A5F00783084 /* Build configuration list for PBXNativeTarget "SparkleTemporaryDownloader" */;
buildPhases = (
728638EF1CAF5A5F00783084 /* Sources */,
728638F01CAF5A5F00783084 /* Frameworks */,
728638F11CAF5A5F00783084 /* Resources */,
729BB3CF1D503531007C4276 /* ShellScript */,
);
buildRules = (
);
dependencies = (
);
name = SparkleTemporaryDownloader;
productName = AppcastDownloader;
productReference = 728638F31CAF5A5F00783084 /* org.sparkle-project.TemporaryDownloader.xpc */;
productType = "com.apple.product-type.xpc-service";
};
72B398D11D3D879300EE297F /* Autoupdate */ = {
isa = PBXNativeTarget;
buildConfigurationList = 72B398D61D3D879400EE297F /* Build configuration list for PBXNativeTarget "Autoupdate" */;
@@ -2297,14 +2220,6 @@
};
};
};
728638F21CAF5A5F00783084 = {
CreatedOnToolsVersion = 7.3;
SystemCapabilities = {
com.apple.Sandbox = {
enabled = 1;
};
};
};
72B398D11D3D879300EE297F = {
CreatedOnToolsVersion = 7.3.1;
};
@@ -2377,7 +2292,6 @@
724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */,
724BB3921D333832005D534A /* SparkleInstallerStatus */,
726E07EE1CAF37BD001A286B /* SparklePersistentDownloader */,
728638F21CAF5A5F00783084 /* SparkleTemporaryDownloader */,
61B5F90109C4CEE200B25A18 /* Sparkle Test App */,
726E4A151C86C88F00C57C6A /* TestAppHelper */,
612279D80DB5470200AB99EA /* Sparkle Unit Tests */,
@@ -2473,13 +2387,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
728638F11CAF5A5F00783084 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
72D9549C1CBB415B006F28BD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -2578,19 +2485,6 @@
shellPath = /bin/sh;
shellScript = "${SRCROOT}/Configurations/set-ats-exceptions-test-app.sh";
};
729BB3CF1D503531007C4276 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "${SRCROOT}/Configurations/set-ats-exceptions-downloader-service.sh";
};
729BB3D01D50354C007C4276 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -2766,19 +2660,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
728638EF1CAF5A5F00783084 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
72F9EC3B1D5C15D0004AC8B6 /* SUConstants.m in Sources */,
72F9EC411D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */,
72F9EC461D5E9ED8004AC8B6 /* SPUDownloadData.m in Sources */,
724A0A3B1CF7AEEA00D8C3D5 /* main.m in Sources */,
7293A1B01CEE9B9800B957A7 /* SPUURLRequest.m in Sources */,
724A0A3D1CF7AEEA00D8C3D5 /* SUTemporaryDownloader.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
72B398CE1D3D879300EE297F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -2840,7 +2721,6 @@
724BB3891D32B915005D534A /* SUInstallerConnection.m in Sources */,
721BC20F1D1CDE55002BC71E /* SPULocalCacheDirectory.m in Sources */,
7267E5B71D3D8AEE00D1BF90 /* SPUInstallationInfo.m in Sources */,
724A0A3E1CF7AF0E00D8C3D5 /* SUTemporaryDownloader.m in Sources */,
723B5DAA1CF7AB6A00365F95 /* SUPersistentDownloader.m in Sources */,
72F9EC4C1D5F53A7004AC8B6 /* SPUUserDriverUIComponent.m in Sources */,
72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */,
@@ -2999,11 +2879,6 @@
target = 726E07EE1CAF37BD001A286B /* SparklePersistentDownloader */;
targetProxy = 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */;
};
72F94F661CC48669002DEE68 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 728638F21CAF5A5F00783084 /* SparkleTemporaryDownloader */;
targetProxy = 72F94F651CC48669002DEE68 /* PBXContainerItemProxy */;
};
72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */;
@@ -3014,11 +2889,6 @@
target = 726E07EE1CAF37BD001A286B /* SparklePersistentDownloader */;
targetProxy = 72F94F6C1CC4A0C8002DEE68 /* PBXContainerItemProxy */;
};
72F94F6F1CC4A0C8002DEE68 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 728638F21CAF5A5F00783084 /* SparkleTemporaryDownloader */;
targetProxy = 72F94F6E1CC4A0C8002DEE68 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -3497,27 +3367,6 @@
};
name = Release;
};
728639001CAF5A5F00783084 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 72F94ED71CC344E4002DEE68 /* ConfigTemporaryDownloaderDebug.xcconfig */;
buildSettings = {
};
name = Debug;
};
728639011CAF5A5F00783084 /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 72F94ED71CC344E4002DEE68 /* ConfigTemporaryDownloaderDebug.xcconfig */;
buildSettings = {
};
name = Coverage;
};
728639021CAF5A5F00783084 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 728639041CAF614000783084 /* ConfigTemporaryDownloader.xcconfig */;
buildSettings = {
};
name = Release;
};
72B398D71D3D879400EE297F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CE0D94A70100DD942E /* ConfigRelaunch.xcconfig */;
@@ -3716,16 +3565,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
728638FF1CAF5A5F00783084 /* Build configuration list for PBXNativeTarget "SparkleTemporaryDownloader" */ = {
isa = XCConfigurationList;
buildConfigurations = (
728639001CAF5A5F00783084 /* Debug */,
728639011CAF5A5F00783084 /* Coverage */,
728639021CAF5A5F00783084 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
72B398D61D3D879400EE297F /* Build configuration list for PBXNativeTarget "Autoupdate" */ = {
isa = XCConfigurationList;
buildConfigurations = (
+71 -19
View File
@@ -8,27 +8,90 @@
#import "SPUURLDownload.h"
#import "SPUXPCServiceInfo.h"
#import "SUTemporaryDownloader.h"
#import "SUTemporaryDownloaderProtocol.h"
#import "SPUURLRequest.h"
#import "SPUDownloadData.h"
#import "SUPersistentDownloaderProtocol.h"
#import "SUPersistentDownloaderDelegate.h"
#import "SUPersistentDownloader.h"
#import "SUErrors.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SPUTemporaryDownloaderDelegate : NSObject <SUPersistentDownloaderDelegate>
@property (nonatomic, copy) void (^completionBlock)(SPUDownloadData * _Nullable, NSError * _Nullable);
@end
@implementation SPUTemporaryDownloaderDelegate
@synthesize completionBlock = _completionBlock;
- (instancetype)initWithCompletion:(void (^)(SPUDownloadData * _Nullable, NSError * _Nullable))completionBlock
{
self = [super init];
if (self != nil) {
_completionBlock = [completionBlock copy];
}
return self;
}
- (void)downloaderDidSetDestinationName:(NSString *)__unused destinationName temporaryDirectory:(NSString *)__unused temporaryDirectory
{
}
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
{
}
- (void)downloaderDidReceiveDataOfLength:(NSUInteger)__unused length
{
}
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData
{
self.completionBlock(downloadData, nil);
self.completionBlock = nil;
}
- (void)downloaderDidFailWithError:(NSError *)error
{
self.completionBlock(nil, error);
self.completionBlock = nil;
}
@end
void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(SPUDownloadData * _Nullable, NSError * _Nullable))
{
id<SUTemporaryDownloaderProtocol> downloader = nil;
id<SUPersistentDownloaderProtocol> downloader = nil;
NSXPCConnection *connection = nil;
__block BOOL retrievedDownloadResult = NO;
if (!SPUXPCServiceExists(@TEMPORARY_DOWNLOADER_BUNDLE_ID)) {
downloader = [[SUTemporaryDownloader alloc] init];
SPUTemporaryDownloaderDelegate *temporaryDownloaderDelegate = [[SPUTemporaryDownloaderDelegate alloc] initWithCompletion:^(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!retrievedDownloadResult) {
retrievedDownloadResult = YES;
[connection invalidate];
if (downloadData == nil || downloadData.data == nil) {
completionBlock(nil, error);
} else {
completionBlock(downloadData, nil);
}
}
});
}];
if (!SPUXPCServiceExists(@PERSISTENT_DOWNLOADER_BUNDLE_ID)) {
downloader = [[SUPersistentDownloader alloc] initWithDelegate:temporaryDownloaderDelegate];
} else {
connection = [[NSXPCConnection alloc] initWithServiceName:@TEMPORARY_DOWNLOADER_BUNDLE_ID];
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUTemporaryDownloaderProtocol)];
connection = [[NSXPCConnection alloc] initWithServiceName:@PERSISTENT_DOWNLOADER_BUNDLE_ID];
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUPersistentDownloaderProtocol)];
connection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUPersistentDownloaderDelegate)];
connection.exportedObject = temporaryDownloaderDelegate;
connection.interruptionHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
@@ -62,16 +125,5 @@ void SPUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(S
downloader = connection.remoteObjectProxy;
}
[downloader startDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:request] completion:^(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
retrievedDownloadResult = YES;
[connection invalidate];
if (downloadData == nil || downloadData.data == nil) {
completionBlock(nil, error);
} else {
completionBlock(downloadData, nil);
}
});
}];
[downloader startTemporaryDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:request]];
}
+3 -9
View File
@@ -183,18 +183,12 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
if (!servingOverHttps) {
BOOL foundXPCTemporaryDownloaderService = NO;
BOOL foundATSTemporaryIssue = [self checkATSIssueForBundle:SPUXPCServiceBundle(@TEMPORARY_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCTemporaryDownloaderService];
BOOL foundXPCPersistentDownloaderService = NO;
BOOL foundATSPersistentIssue = NO;
if (!foundATSTemporaryIssue) {
foundATSPersistentIssue = [self checkATSIssueForBundle:SPUXPCServiceBundle(@PERSISTENT_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCPersistentDownloaderService];
}
BOOL foundATSPersistentIssue = [self checkATSIssueForBundle:SPUXPCServiceBundle(@PERSISTENT_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCPersistentDownloaderService];
NSBundle *mainBundle = [NSBundle mainBundle];
BOOL foundATSMainBundleIssue = NO;
if (!foundATSTemporaryIssue && !foundATSPersistentIssue && (!foundXPCTemporaryDownloaderService || !foundXPCPersistentDownloaderService)) {
if (!foundATSPersistentIssue && !foundXPCPersistentDownloaderService) {
BOOL foundATSIssue = ([mainBundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"] == nil);
BOOL updatingMainBundle = [self.host.bundle isEqualTo:mainBundle];
@@ -205,7 +199,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
}
}
if (foundATSTemporaryIssue || foundATSPersistentIssue || foundATSMainBundleIssue) {
if (foundATSPersistentIssue || foundATSMainBundleIssue) {
if (!self.loggedATSWarning) {
// Just log a warning. Don't outright fail in case we are wrong (eg: app is linked on an old SDK where ATS doesn't take effect)
SULog(@"The feed URL (%@) may need to change to use HTTPS.\nFor more information: https://sparkle-project.org/documentation/app-transport-security", [feedURL absoluteString]);
+1 -1
View File
@@ -119,7 +119,7 @@
[self.delegate downloadDriverWillBeginDownload];
NSString *desiredFilename = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
[self.downloader startDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:self.request] mode:SPUDownloadModePersistent bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename];
[self.downloader startPersistentDownloadWithRequest:[SPUURLRequest URLRequestWithRequest:self.request] bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename];
}
- (void)cleanup
-38
View File
@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Sparkle Project. All rights reserved.</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>
<key>XPCService</key>
<dict>
<key>RunLoopType</key>
<string>NSRunLoop</string>
<key>ServiceType</key>
<string>Application</string>
</dict>
</dict>
</plist>
@@ -1,14 +0,0 @@
//
// SUTemporaryDownloader.h
// TemporaryDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUTemporaryDownloaderProtocol.h"
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
@interface SUTemporaryDownloader : NSObject <SUTemporaryDownloaderProtocol>
@end
@@ -1,96 +0,0 @@
//
// SUTemporaryDownloader.m
// TemporaryDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUTemporaryDownloader.h"
#import "SPUDownloadData.h"
#import "SPUURLRequest.h"
#import "SUErrors.h"
#import "SUConstants.h"
#ifdef _APPKITDEFINES_H
#error This is a "core" class and should NOT import AppKit
#endif
@interface SUTemporaryDownloader () <NSURLDownloadDelegate>
@property (nonatomic, copy) void (^completionBlock)(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error);
@property (nonatomic) NSURLDownload *download;
@property (nonatomic, copy) NSString *downloadFilename;
@property (nonatomic) NSURLResponse *response;
@end
@implementation SUTemporaryDownloader
@synthesize completionBlock = _completionBlock;
@synthesize download = _download;
@synthesize downloadFilename = _downloadFilename;
@synthesize response = _response;
- (void)startDownloadWithRequest:(SPUURLRequest *)request completion:(void (^)(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error))completionBlock
{
dispatch_async(dispatch_get_main_queue(), ^{
self.completionBlock = completionBlock;
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
});
}
- (void)cleanup
{
if (self.downloadFilename != nil) {
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
}
self.downloadFilename = nil;
}
- (void)download:(NSURLDownload *)__unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
{
NSString *destinationFilename = NSTemporaryDirectory();
if (destinationFilename)
{
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
[self.download setDestination:destinationFilename allowOverwrite:NO];
}
}
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
{
self.downloadFilename = path;
}
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
{
self.response = response;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
{
assert(self.response != nil);
assert(self.downloadFilename != nil);
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
if (data != nil) {
// See SUPersistentDownloader as to why sending the NSURLResponse object over is not a good idea
SPUDownloadData *downloadData = [[SPUDownloadData alloc] initWithData:data textEncodingName:self.response.textEncodingName MIMEType:self.response.MIMEType];
self.completionBlock(downloadData, nil);
} else {
self.completionBlock(nil, [NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read temporary downloaded data from %@", self.downloadFilename] }]);
}
self.completionBlock = nil;
[self cleanup];
}
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
{
[self cleanup];
self.completionBlock(nil, error);
self.completionBlock = nil;
}
@end
@@ -1,23 +0,0 @@
//
// SUTemporaryDownloaderProtocol.h
// TemporaryDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class SPUURLRequest;
@class SPUDownloadData;
// 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 SUTemporaryDownloaderProtocol
- (void)startDownloadWithRequest:(SPUURLRequest *)request completion:(void (^)(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error))completionBlock;
@end
NS_ASSUME_NONNULL_END
-49
View File
@@ -1,49 +0,0 @@
//
// main.m
// TemporaryDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUTemporaryDownloader.h"
@interface ServiceDelegate : NSObject <NSXPCListenerDelegate>
@end
@implementation ServiceDelegate
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection.
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUTemporaryDownloaderProtocol)];
// Next, set the object that the connection exports. All messages sent on the connection to this service will be sent to the exported object to handle. The connection retains the exported object.
SUTemporaryDownloader *exportedObject = [SUTemporaryDownloader new];
newConnection.exportedObject = exportedObject;
// Resuming the connection allows the system to deliver more incoming messages.
[newConnection resume];
// Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO.
return YES;
}
@end
int main(int __unused argc, const char * __unused argv[])
{
// Create the delegate for the service.
ServiceDelegate *delegate = [ServiceDelegate new];
// Set up the one NSXPCListener for this service. It will handle all incoming connections.
NSXPCListener *listener = [NSXPCListener serviceListener];
listener.delegate = delegate;
// Resuming the serviceListener starts this service. This method does not return.
[listener resume];
return 0;
}
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>