mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-23 04:34:27 +00:00
Compare commits
52
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7088fc788 | ||
|
|
54aa6f2cc2 | ||
|
|
acf758e485 | ||
|
|
ceedfba634 | ||
|
|
addedeac13 | ||
|
|
eedb0ff0dd | ||
|
|
67a7bc3d62 | ||
|
|
65d7c38ab6 | ||
|
|
5b786043c2 | ||
|
|
ca23238d59 | ||
|
|
fc1870cbd2 | ||
|
|
659aec4eaf | ||
|
|
88a197a7f0 | ||
|
|
9119d287ab | ||
|
|
7797a8f58c | ||
|
|
1f0da95e59 | ||
|
|
84a2feb0ad | ||
|
|
bbe75fc6f2 | ||
|
|
9c8e08b7ae | ||
|
|
371c51fe5a | ||
|
|
feb2ad4b64 | ||
|
|
1e75acb963 | ||
|
|
b3c69f8b8c | ||
|
|
5cd9bdccf6 | ||
|
|
12eede4123 | ||
|
|
9633a57c6c | ||
|
|
ab389260be | ||
|
|
abf70ab8dc | ||
|
|
67ebc6ff74 | ||
|
|
1e14f7d7b6 | ||
|
|
5bd4c1ecb6 | ||
|
|
406f3da615 | ||
|
|
302eb082d6 | ||
|
|
16b75653dc | ||
|
|
fc8176a229 | ||
|
|
502c7fb6db | ||
|
|
71f747aec1 | ||
|
|
0ed83cf9f2 | ||
|
|
c37fc01bb1 | ||
|
|
7fae28135e | ||
|
|
82c722ba37 | ||
|
|
aba5567a15 | ||
|
|
d593a04dda | ||
|
|
8fa758f8aa | ||
|
|
2a0d8afe4e | ||
|
|
69c9c70d21 | ||
|
|
aebb767cfb | ||
|
|
04b1514452 | ||
|
|
22f9c96a1f | ||
|
|
78b08a0bee | ||
|
|
6fc58a1025 | ||
|
|
dbd2b9b30a |
No files matched your search
+18
@@ -0,0 +1,18 @@
|
||||
# Xcode
|
||||
build/*
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
*.xcworkspace
|
||||
!default.xcworkspace
|
||||
xcuserdata/
|
||||
profile
|
||||
*.moved-aside
|
||||
|
||||
## Ignore incredibly annoying .DS_Store files
|
||||
.DS_Store
|
||||
@@ -3,11 +3,11 @@
|
||||
PREBINDING = NO
|
||||
ZERO_LINK = NO
|
||||
CURRENT_PROJECT_VERSION = 1.5
|
||||
SDKROOT = macosx10.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
|
||||
@@ -15,7 +15,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES
|
||||
GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
|
||||
GCC_FAST_OBJC_DISPATCH = YES
|
||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||
ARCHS = ppc i386 x86_64
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0
|
||||
CLANG_LINK_OBJC_RUNTIME = NO
|
||||
|
||||
@@ -48,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)
|
||||
@@ -6,5 +6,6 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
SPARKLE_EXTRA_DEBUG_10_5_ONLY = -fstack-protector -D_FORTIFY_SOURCE=2
|
||||
SPARKLE_EXTRA_DEBUG = -DDEBUG
|
||||
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
|
||||
CODE_SIGN_IDENTITY = Mac Developer
|
||||
|
||||
// Add $(SPARKLE_EXTRA_DEBUG_10_5_ONLY) to SPARKLE_EXTRA_DEBUG if your deployment is 10.5 or greater.
|
||||
@@ -0,0 +1,4 @@
|
||||
// Common
|
||||
|
||||
ARCHS = x86_64
|
||||
VALID_ARCHS = x86_64
|
||||
@@ -0,0 +1,4 @@
|
||||
// Common
|
||||
|
||||
ARCHS = ppc i386 x86_64
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = s
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||
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
|
||||
CODE_SIGN_IDENTITY = Developer ID Application
|
||||
@@ -1,8 +1,8 @@
|
||||
// Framework only
|
||||
|
||||
INSTALL_PATH = @loader_path/../Frameworks
|
||||
DYLIB_COMPATIBILITY_VERSION = 1.5
|
||||
DYLIB_CURRENT_VERSION = 1.5
|
||||
DYLIB_COMPATIBILITY_VERSION = 2.0
|
||||
DYLIB_CURRENT_VERSION = 2.0
|
||||
PRODUCT_NAME = Sparkle
|
||||
WRAPPER_EXTENSION = framework
|
||||
FRAMEWORK_VERSION = A
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "ConfigFrameworkRelease.xcconfig"
|
||||
|
||||
//GCC_ENABLE_OBJC_GC = supported
|
||||
GCC_ENABLE_OBJC_GC = supported
|
||||
@@ -0,0 +1,10 @@
|
||||
// Sandbox Service only
|
||||
|
||||
WRAPPER_EXTENSION = xpc
|
||||
MACH_O_TYPE = mh_execute
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
MACOSX_DEPLOYMENT_TARGET[arch=x86_64] = 10.7
|
||||
|
||||
GCC_WARN_SHADOW = NO
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = NO
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
#include "ConfigService.xcconfig"
|
||||
|
||||
OTHER_CFLAGS = -DDEBUG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonRelease.xcconfig"
|
||||
#include "ConfigService.xcconfig"
|
||||
@@ -7,4 +7,5 @@ WRAPPER_EXTENSION = octest
|
||||
FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_LIBRARY_DIR)/Frameworks
|
||||
GCC_PREFIX_HEADER = $(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
SDKROOT = macosx10.7
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${EXECUTABLE_NAME}</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>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>XPCService</key>
|
||||
<dict>
|
||||
<key>ServiceType</key>
|
||||
<string>Application</string>
|
||||
<key>JoinExistingSession</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,4 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'Downloading XPC Service' target in the 'Downloading XPC Service' project
|
||||
//
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// SUDSDownloader.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Dmytro Tretiakov on 8/1/13.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#define DEBUG_LOGGING_ENABLED defined(DEBUG) && 1
|
||||
|
||||
@class SUDSDownloader;
|
||||
|
||||
typedef void (^SUDSDownloadDidBegin)(SUDSDownloader *downloader);
|
||||
typedef void (^SUDSDownloadDidFinish)(SUDSDownloader *downloader);
|
||||
typedef void (^SUDSDownloadDidFail)(SUDSDownloader *downloader, NSError *error);
|
||||
typedef void (^SUDSDownloadDidReceiveResponse)(SUDSDownloader *downloader, NSURLResponse *response);
|
||||
typedef void (^SUDSDownloadDidReceiveData)(SUDSDownloader *downloader, NSUInteger dataLength);
|
||||
typedef void (^SUDSDownloadDidCreateDestination)(SUDSDownloader *downloader, NSString *destinationPath);
|
||||
typedef BOOL (^SUDSDownloadShouldDecodeSourceData)(SUDSDownloader *downloader, NSString *MIMEType);
|
||||
|
||||
typedef struct SUDSDownloaderCallBacks
|
||||
{
|
||||
SUDSDownloadDidBegin downloadDidBegin;
|
||||
SUDSDownloadDidFinish downloadDidFinish;
|
||||
SUDSDownloadDidFail downloadDidFail;
|
||||
|
||||
SUDSDownloadDidReceiveResponse downloadDidReceiveResponse;
|
||||
SUDSDownloadDidReceiveData downloadDidReceiveData;
|
||||
SUDSDownloadDidCreateDestination downloadDidCreateDestination;
|
||||
|
||||
SUDSDownloadShouldDecodeSourceData downloadShouldDecodeSourceData;
|
||||
} SUDSDownloaderCallBacks;
|
||||
|
||||
FOUNDATION_EXTERN SUDSDownloaderCallBacks SUDSCopyDownloaderCallBacks(SUDSDownloaderCallBacks callBacks);
|
||||
FOUNDATION_EXTERN void SUDSReleaseDownloaderCallBacks(SUDSDownloaderCallBacks callBacks);
|
||||
|
||||
@interface SUDSDownloader : NSObject <NSURLDownloadDelegate>
|
||||
{
|
||||
@private
|
||||
NSURLRequest *_request;
|
||||
NSString *_destFilePath;
|
||||
SUDSDownloaderCallBacks _callBacks;
|
||||
|
||||
NSURLDownload *_download;
|
||||
}
|
||||
|
||||
- (id)initWithURLRequest:(NSURLRequest *)request destinationPath:(NSString *)filePath;
|
||||
+ (id)downloaderWithURLRequest:(NSURLRequest *)request destinationPath:(NSString *)filePath;
|
||||
|
||||
- (NSURLRequest *)request;
|
||||
- (NSString *)destinationPath;
|
||||
- (void)setCallBacks:(SUDSDownloaderCallBacks)callBacks;
|
||||
|
||||
- (void)startDownload;
|
||||
- (void)stopDownload;
|
||||
- (BOOL)isInProgress;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,210 @@
|
||||
//
|
||||
// SUDSDownloader.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Dmytro Tretiakov on 8/1/13.
|
||||
//
|
||||
//
|
||||
|
||||
#import "SUDSDownloader.h"
|
||||
|
||||
SUDSDownloaderCallBacks SUDSCopyDownloaderCallBacks(SUDSDownloaderCallBacks callBacks)
|
||||
{
|
||||
SUDSDownloaderCallBacks callBacksCopy = {0};
|
||||
|
||||
if (callBacks.downloadDidBegin)
|
||||
callBacksCopy.downloadDidBegin = Block_copy(callBacks.downloadDidBegin);
|
||||
if (callBacks.downloadDidFinish)
|
||||
callBacksCopy.downloadDidFinish = Block_copy(callBacks.downloadDidFinish);
|
||||
if (callBacks.downloadDidFail)
|
||||
callBacksCopy.downloadDidFail = Block_copy(callBacks.downloadDidFail);
|
||||
if (callBacks.downloadDidReceiveData)
|
||||
callBacksCopy.downloadDidReceiveData = Block_copy(callBacks.downloadDidReceiveData);
|
||||
if (callBacks.downloadDidCreateDestination)
|
||||
callBacksCopy.downloadDidCreateDestination = Block_copy(callBacks.downloadDidCreateDestination);
|
||||
if (callBacks.downloadDidReceiveResponse)
|
||||
callBacksCopy.downloadDidReceiveResponse = Block_copy(callBacks.downloadDidReceiveResponse);
|
||||
if (callBacks.downloadShouldDecodeSourceData)
|
||||
callBacksCopy.downloadShouldDecodeSourceData = Block_copy(callBacks.downloadShouldDecodeSourceData);
|
||||
|
||||
return callBacksCopy;
|
||||
}
|
||||
|
||||
void SUDSReleaseDownloaderCallBacks(SUDSDownloaderCallBacks callBacks)
|
||||
{
|
||||
if (callBacks.downloadDidBegin)
|
||||
Block_release(callBacks.downloadDidBegin);
|
||||
if (callBacks.downloadDidFinish)
|
||||
Block_release(callBacks.downloadDidFinish);
|
||||
if (callBacks.downloadDidFail)
|
||||
Block_release(callBacks.downloadDidFail);
|
||||
if (callBacks.downloadDidReceiveData)
|
||||
Block_release(callBacks.downloadDidReceiveData);
|
||||
if (callBacks.downloadDidCreateDestination)
|
||||
Block_release(callBacks.downloadDidCreateDestination);
|
||||
if (callBacks.downloadDidReceiveResponse)
|
||||
Block_release(callBacks.downloadDidReceiveResponse);
|
||||
if (callBacks.downloadShouldDecodeSourceData)
|
||||
Block_release(callBacks.downloadShouldDecodeSourceData);
|
||||
}
|
||||
|
||||
@implementation SUDSDownloader
|
||||
|
||||
- (id)initWithURLRequest:(NSURLRequest *)request destinationPath:(NSString *)filePath
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_request = [request retain];
|
||||
_destFilePath = [filePath copy];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (id)downloaderWithURLRequest:(NSURLRequest *)request destinationPath:(NSString *)filePath
|
||||
{
|
||||
return [[[[self class] alloc] initWithURLRequest:request destinationPath:filePath] autorelease];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self stopDownload];
|
||||
|
||||
[_request release];
|
||||
[_destFilePath release];
|
||||
SUDSReleaseDownloaderCallBacks(_callBacks);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSURLRequest *)request
|
||||
{
|
||||
return _request;
|
||||
}
|
||||
|
||||
- (NSString *)destinationPath
|
||||
{
|
||||
return _destFilePath;
|
||||
}
|
||||
|
||||
- (void)setCallBacks:(SUDSDownloaderCallBacks)callBacks
|
||||
{
|
||||
SUDSDownloaderCallBacks oldCallBacks = _callBacks;
|
||||
_callBacks = SUDSCopyDownloaderCallBacks(callBacks);
|
||||
SUDSReleaseDownloaderCallBacks(oldCallBacks);
|
||||
}
|
||||
|
||||
- (void)startDownload
|
||||
{
|
||||
[self stopDownload];
|
||||
|
||||
// to ensure that parent folder exists
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:[_destFilePath stringByDeletingLastPathComponent]
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:NULL];
|
||||
NSURLDownload *urlDownload = [[NSURLDownload alloc] initWithRequest:_request delegate:self];
|
||||
@synchronized (self)
|
||||
{
|
||||
_download = urlDownload;
|
||||
}
|
||||
|
||||
[urlDownload setDestination:_destFilePath allowOverwrite:YES];
|
||||
}
|
||||
|
||||
- (void)stopDownload
|
||||
{
|
||||
@synchronized (self)
|
||||
{
|
||||
[_download cancel];
|
||||
[_download release];
|
||||
_download = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isInProgress
|
||||
{
|
||||
BOOL result = YES;
|
||||
@synchronized (self)
|
||||
{
|
||||
result = _download != nil;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)downloadDidBegin:(NSURLDownload *)download
|
||||
{
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader did begin process.");
|
||||
#endif
|
||||
if (_callBacks.downloadDidBegin)
|
||||
_callBacks.downloadDidBegin(self);
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader did receive response: %@", [response description]);
|
||||
#endif
|
||||
if (_callBacks.downloadDidReceiveResponse)
|
||||
_callBacks.downloadDidReceiveResponse(self, response);
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path
|
||||
{
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader did create destination: %@", path);
|
||||
#endif
|
||||
if (_callBacks.downloadDidCreateDestination)
|
||||
_callBacks.downloadDidCreateDestination(self, path);
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(NSUInteger)length
|
||||
{
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader did receive data of length %ld bytes", (unsigned long)length);
|
||||
#endif
|
||||
if (_callBacks.downloadDidReceiveData)
|
||||
_callBacks.downloadDidReceiveData(self, length);
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
|
||||
{
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader did fail: %@", [error description]);
|
||||
#endif
|
||||
if (_callBacks.downloadDidFail)
|
||||
_callBacks.downloadDidFail(self, error);
|
||||
|
||||
[self stopDownload];
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)download
|
||||
{
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader did finish");
|
||||
#endif
|
||||
if (_callBacks.downloadDidFinish)
|
||||
_callBacks.downloadDidFinish(self);
|
||||
|
||||
[self stopDownload];
|
||||
}
|
||||
|
||||
- (BOOL)download:(NSURLDownload *)download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||
{
|
||||
BOOL shouldDecode = NO;
|
||||
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"XPC Downloader wants decode source data of MIME type: %@", encodingType);
|
||||
#endif
|
||||
if (_callBacks.downloadShouldDecodeSourceData)
|
||||
shouldDecode = _callBacks.downloadShouldDecodeSourceData(self, encodingType);
|
||||
|
||||
return shouldDecode;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// SUDownloadServiceConstants.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Dmytro Tretiakov on 7/29/13.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef Sparkle_SUDownloadServiceConstants_h
|
||||
#define Sparkle_SUDownloadServiceConstants_h
|
||||
|
||||
const char * SUDownloadServiceURLRequestDataKey = "request_data"; // data of archived NSURLRequest
|
||||
const char * SUDownloadServiceDelegateConnectionKey = "connection"; // xpc_connection_t
|
||||
const char * SUDownloadServiceFilePathKey = "file_path"; // c-string
|
||||
|
||||
const char * SUDownloadServiceReceivedDataLengthKey = "received_data_length"; // int64_t
|
||||
const char * SUDownloadServiceReceivedResponseDataKey = "received_response_data"; // data of archived NSURLResponse
|
||||
const char * SUDownloadServiceCreatedDestinationPathKey = "created_destination_path"; // c-string
|
||||
const char * SUDownloadServiceDidBeginDownloadingKey = "did_begin_downloading"; // bool 1
|
||||
const char * SUDownloadServiceDidFinishDownloadingKey = "did_finish_downloading"; // bool 1
|
||||
const char * SUDownloadServiceReceivedFailErrorKey = "received_fail_error"; // data of archived NSError
|
||||
const char * SUDownloadServiceMIMETypeToDecodeKey = "MIME_type_to_decode"; // c-string
|
||||
const char * SUDownloadServiceShouldDecodeMIMETypeKey = "should_decode_MIME_type"; // bool
|
||||
|
||||
const char * SUDownloadServiceErrorCodeKey = "errcode"; // int64_t
|
||||
const char * SUDownloadServiceErrorMessageKey = "errmsg"; // c-string
|
||||
const char * SUDownloadServiceErrorDomainKey = "errdomain"; // c-string
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// SUXPCURLDownload.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Erik Aderstedt on 2012-08-09.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUXPCURLDownload : NSObject
|
||||
{
|
||||
@private
|
||||
id <NSURLDownloadDelegate> _delegate; // weak ref
|
||||
xpc_connection_t _connection;
|
||||
xpc_connection_t _delegateConnection;
|
||||
NSURLRequest *_request;
|
||||
NSThread *_startedThread; // weak ref
|
||||
BOOL _isDownloading;
|
||||
|
||||
BOOL _allowOverwrite;
|
||||
NSString *_destination;
|
||||
NSString *_connectionDestination;
|
||||
NSError *_downloadError;
|
||||
}
|
||||
|
||||
- (id <NSURLDownloadDelegate>)delegate;
|
||||
- (void)setDelegate:(id <NSURLDownloadDelegate>)delegate;
|
||||
|
||||
- (id)initWithRequest:(NSURLRequest *)request delegate:(id <NSURLDownloadDelegate>)delegate;
|
||||
- (void)setDestination:(NSString *)path allowOverwrite:(BOOL)allowOverwrite;
|
||||
|
||||
// Delegate methods for this method will be called from another thread.
|
||||
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request delegate:(id <NSURLDownloadDelegate>)delegate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,448 @@
|
||||
//
|
||||
// SUXPCURLDownload.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Erik Aderstedt on 2012-08-09.
|
||||
//
|
||||
//
|
||||
|
||||
#import "SUXPCURLDownload.h"
|
||||
#import "SUDownloadServiceConstants.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
|
||||
@interface SUXPCURLDownload (Private)
|
||||
|
||||
- (void)performBlock:(void (^)(void))block onThread:(NSThread *)thread synchronous:(BOOL)flag;
|
||||
- (void)fireBlock:(void (^)(void))block;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUXPCURLDownload
|
||||
|
||||
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request delegate:(id <NSURLDownloadDelegate>)delegate
|
||||
{
|
||||
__block SUXPCURLDownload *download = nil;
|
||||
|
||||
static const char *sSynchronousDownloadQueueName = "com.devmate.SynchronousXPCDownloadQueue";
|
||||
dispatch_queue_t queue = dispatch_queue_create(sSynchronousDownloadQueueName, NULL);
|
||||
dispatch_sync(queue, ^{
|
||||
download = [[SUXPCURLDownload alloc] initWithRequest:request delegate:delegate];
|
||||
});
|
||||
|
||||
while (download && download->_isDownloading)
|
||||
{
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]];
|
||||
}
|
||||
|
||||
NSData *downloadData = (nil == download->_downloadError) ? [NSData dataWithContentsOfFile:download->_destination] : nil;
|
||||
[download release];
|
||||
dispatch_release(queue);
|
||||
|
||||
return downloadData;
|
||||
}
|
||||
|
||||
- (id)initWithRequest:(NSURLRequest *)request delegate:(id <NSURLDownloadDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_request = [request retain];
|
||||
_delegate = [delegate retain];
|
||||
_startedThread = [NSThread currentThread];
|
||||
|
||||
// Set up a connection.
|
||||
_connection = [self getSandboxXPCService];
|
||||
dispatch_async(dispatch_get_current_queue(), ^{
|
||||
[self startDownload:request];
|
||||
});
|
||||
|
||||
_isDownloading = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self cancel];
|
||||
|
||||
[_request release];
|
||||
[_destination release];
|
||||
[_connectionDestination release];
|
||||
[_downloadError release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSURLRequest *)request
|
||||
{
|
||||
return _request;
|
||||
}
|
||||
|
||||
- (void)startDownload:(NSURLRequest *)urlRequest
|
||||
{
|
||||
// Send a message to download a specific url.
|
||||
if ([_delegate respondsToSelector:@selector(download:decideDestinationWithSuggestedFilename:)] && _destination == nil)
|
||||
{
|
||||
void (^block)(void) = ^{
|
||||
[_delegate download:(NSURLDownload *)self decideDestinationWithSuggestedFilename:[[urlRequest URL] lastPathComponent]];
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:YES];
|
||||
}
|
||||
if (nil == _destination)
|
||||
{
|
||||
_destination = [[[urlRequest URL] lastPathComponent] copy];
|
||||
}
|
||||
|
||||
// ivar 'destination' now contains the destination URL.
|
||||
|
||||
NSURL *tempFolder = [NSURL fileURLWithPath:NSTemporaryDirectory()];
|
||||
NSString *tempFileTemplate = [[tempFolder URLByAppendingPathComponent:kSUFetchFolderName] path];
|
||||
NSString *tempFilePath = [tempFileTemplate stringByAppendingPathComponent:[_destination lastPathComponent]];
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
if ([fileManager fileExistsAtPath:tempFilePath])
|
||||
[fileManager removeItemAtPath:tempFilePath error:nil];
|
||||
|
||||
_connectionDestination = [tempFilePath copy];
|
||||
|
||||
NSData *requestData = [NSKeyedArchiver archivedDataWithRootObject:urlRequest];
|
||||
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_data(message, SUDownloadServiceURLRequestDataKey, [requestData bytes], [requestData length]);
|
||||
xpc_dictionary_set_string(message, SUDownloadServiceFilePathKey, [tempFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
xpc_dictionary_set_connection(message, SUDownloadServiceDelegateConnectionKey, _delegateConnection);
|
||||
xpc_connection_send_message_with_reply(_connection, message, dispatch_get_main_queue(), ^(xpc_object_t object) {
|
||||
xpc_type_t type = xpc_get_type(object);
|
||||
|
||||
if (type == XPC_TYPE_ERROR && nil == _downloadError)
|
||||
{
|
||||
NSString *errMessage = @"";
|
||||
if (object == XPC_ERROR_CONNECTION_INTERRUPTED)
|
||||
{
|
||||
errMessage = @"Got XPC_ERROR_CONNECTION_INTERRUPTED error.";
|
||||
}
|
||||
else if (object == XPC_ERROR_CONNECTION_INVALID)
|
||||
{
|
||||
errMessage = @"Got XPC_ERROR_CONNECTION_INVALID error.";
|
||||
}
|
||||
|
||||
NSDictionary *errInfo = [NSDictionary dictionaryWithObject:errMessage forKey:NSLocalizedDescriptionKey];
|
||||
_downloadError = [[NSError alloc] initWithDomain:SUSparkleErrorDomain code:SUXPCServiceError userInfo:errInfo];
|
||||
}
|
||||
else if (type == XPC_TYPE_DICTIONARY && noErr != xpc_dictionary_get_int64(object, SUDownloadServiceErrorCodeKey) && nil == _downloadError)
|
||||
{
|
||||
NSInteger errCode = (NSInteger)xpc_dictionary_get_int64(object, SUDownloadServiceErrorCodeKey);
|
||||
|
||||
const char *errDomainStr = xpc_dictionary_get_string(object, SUDownloadServiceErrorDomainKey);
|
||||
NSString *errDomain = errDomainStr ? [NSString stringWithUTF8String:errDomainStr] : NSCocoaErrorDomain;
|
||||
|
||||
const char *errMessage = xpc_dictionary_get_string(object, SUDownloadServiceErrorMessageKey) ? : "";
|
||||
NSDictionary *errInfo = [NSDictionary dictionaryWithObject:[NSString stringWithUTF8String:errMessage]
|
||||
forKey:NSLocalizedDescriptionKey];
|
||||
|
||||
_downloadError = [[NSError alloc] initWithDomain:errDomain code:errCode userInfo:errInfo];
|
||||
}
|
||||
|
||||
if (nil != _downloadError)
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(download:didFailWithError:)])
|
||||
{
|
||||
void (^block)(void) = ^{
|
||||
[_delegate download:(NSURLDownload *)self didFailWithError:_downloadError];
|
||||
_isDownloading = NO;
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
SULog(@"SUXPCURLDownload: got download error (%d - %@)", [_downloadError code], [_downloadError localizedDescription]);
|
||||
_isDownloading = NO;
|
||||
}
|
||||
}
|
||||
});
|
||||
xpc_release(message);
|
||||
}
|
||||
|
||||
- (id <NSURLDownloadDelegate>)delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id <NSURLDownloadDelegate>)delegate
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
- (void)setDestination:(NSString *)path allowOverwrite:(BOOL)allowOverwrite
|
||||
{
|
||||
[_destination release];
|
||||
_destination = [path copy];
|
||||
_allowOverwrite = allowOverwrite;
|
||||
}
|
||||
|
||||
- (void)cancel
|
||||
{
|
||||
if (_connection)
|
||||
{
|
||||
xpc_connection_cancel(_connection);
|
||||
xpc_release(_connection);
|
||||
_connection = NULL;
|
||||
}
|
||||
if (_delegateConnection)
|
||||
{
|
||||
xpc_connection_cancel(_delegateConnection);
|
||||
xpc_release(_delegateConnection);
|
||||
_delegateConnection = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
- (xpc_connection_t)getSandboxXPCService
|
||||
{
|
||||
// Set up two connections, one for instructing the XPC and getting a response,
|
||||
// and another to listen for incoming connections for progress and file creation
|
||||
// notifications.
|
||||
|
||||
_connection = xpc_connection_create("com.andymatuschak.Sparkle.download-service", dispatch_get_main_queue());
|
||||
if (!_connection)
|
||||
{
|
||||
NSLog(@"Can't connect to XPC service");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
xpc_connection_set_event_handler(_connection, ^(xpc_object_t event) {
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
|
||||
if (type == XPC_TYPE_ERROR)
|
||||
{
|
||||
if (event == XPC_ERROR_CONNECTION_INTERRUPTED)
|
||||
{
|
||||
NSLog(@"Got XPC_ERROR_CONNECTION_INTERRUPTED error.");
|
||||
// The service has either cancaled itself, crashed, or been
|
||||
// terminated. The XPC connection is still valid and sending a
|
||||
// message to it will re-launch the service. If the service is
|
||||
// state-full, this is the time to initialize the new service.
|
||||
|
||||
}
|
||||
else if (event == XPC_ERROR_CONNECTION_INVALID)
|
||||
{
|
||||
NSLog(@"Got XPC_ERROR_CONNECTION_INVALID error.");
|
||||
// The service is invalid. Either the service name supplied to
|
||||
// xpc_connection_create() is incorrect or we (this process) have
|
||||
// canceled the service; we can do any cleanup of appliation
|
||||
// state at this point.
|
||||
if (_delegateConnection)
|
||||
{
|
||||
xpc_connection_cancel(_delegateConnection);
|
||||
xpc_release(_delegateConnection);
|
||||
_delegateConnection = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dispatch_queue_t delegate_queue = dispatch_queue_create("com.andymatuschak.Sparkle.download-service-delegate", NULL);
|
||||
assert(delegate_queue != NULL);
|
||||
|
||||
_delegateConnection = xpc_connection_create(NULL, delegate_queue);
|
||||
xpc_connection_set_event_handler(_delegateConnection, ^(xpc_object_t event) {
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
|
||||
if (type == XPC_TYPE_ERROR)
|
||||
{
|
||||
if (event == XPC_ERROR_TERMINATION_IMMINENT)
|
||||
{
|
||||
NSLog(@"received XPC_ERROR_TERMINATION_IMMINENT");
|
||||
}
|
||||
else if (event == XPC_ERROR_CONNECTION_INVALID)
|
||||
{
|
||||
NSLog(@"progress connection is closed");
|
||||
dispatch_release(delegate_queue);
|
||||
}
|
||||
}
|
||||
else if (type == XPC_TYPE_CONNECTION)
|
||||
{
|
||||
xpc_connection_t peer = (xpc_connection_t)event;
|
||||
// A new anonymous connection, from an XPC service that wants to supply us with updates.
|
||||
char *queue_name = NULL;
|
||||
dispatch_queue_t peer_event_queue = dispatch_queue_create(queue_name, NULL);
|
||||
assert(peer_event_queue != NULL);
|
||||
free(queue_name);
|
||||
|
||||
xpc_connection_set_target_queue(peer, peer_event_queue);
|
||||
xpc_connection_set_event_handler(peer, ^(xpc_object_t nevent) {
|
||||
xpc_type_t ntype = xpc_get_type(nevent);
|
||||
|
||||
if (ntype == XPC_TYPE_ERROR && nevent == XPC_ERROR_CONNECTION_INVALID)
|
||||
dispatch_release(peer_event_queue);
|
||||
if (ntype != XPC_TYPE_DICTIONARY)
|
||||
return;
|
||||
|
||||
__block xpc_object_t answer = xpc_dictionary_create_reply(nevent);
|
||||
|
||||
xpc_dictionary_apply(nevent, ^bool(const char *key, xpc_object_t value) {
|
||||
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if (0 == strcmp(key, SUDownloadServiceDidBeginDownloadingKey))
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(downloadDidBegin:)])
|
||||
{
|
||||
void (^block)(void) = ^ {
|
||||
[_delegate downloadDidBegin:(NSURLDownload *)self];
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:NO];
|
||||
}
|
||||
}
|
||||
else if (0 == strcmp(key, SUDownloadServiceReceivedResponseDataKey))
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(download:didReceiveResponse:)])
|
||||
{
|
||||
size_t dataLength = 0;
|
||||
const void * responseDataBytes = xpc_dictionary_get_data(nevent, SUDownloadServiceReceivedResponseDataKey, &dataLength);
|
||||
NSData *responseData = [NSData dataWithBytes:responseDataBytes length:(NSUInteger)dataLength];
|
||||
|
||||
NSURLResponse *response = [NSKeyedUnarchiver unarchiveObjectWithData:responseData];
|
||||
void (^block)(void) = ^ {
|
||||
[_delegate download:(NSURLDownload *)self didReceiveResponse:response];
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:NO];
|
||||
}
|
||||
}
|
||||
else if (0 == strcmp(key, SUDownloadServiceReceivedDataLengthKey))
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(download:didReceiveDataOfLength:)])
|
||||
{
|
||||
int64_t dataLength = xpc_dictionary_get_int64(nevent, SUDownloadServiceReceivedDataLengthKey);
|
||||
void (^block)(void) = ^ {
|
||||
[_delegate download:(NSURLDownload *)self didReceiveDataOfLength:(NSUInteger)dataLength];
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:NO];
|
||||
}
|
||||
}
|
||||
else if (0 == strcmp(key, SUDownloadServiceCreatedDestinationPathKey))
|
||||
{
|
||||
[_connectionDestination release];
|
||||
_connectionDestination = [[NSString alloc] initWithCString:xpc_dictionary_get_string(nevent, SUDownloadServiceCreatedDestinationPathKey)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
else if (0 == strcmp(key, SUDownloadServiceReceivedFailErrorKey))
|
||||
{
|
||||
size_t dataLength = 0;
|
||||
const void * errorDataBytes = xpc_dictionary_get_data(nevent, SUDownloadServiceReceivedFailErrorKey, &dataLength);
|
||||
NSData *errorData = [NSData dataWithBytes:errorDataBytes length:dataLength];
|
||||
|
||||
NSError *error = [NSKeyedUnarchiver unarchiveObjectWithData:errorData];
|
||||
_downloadError = [error retain];
|
||||
}
|
||||
else if (0 == strcmp(key, SUDownloadServiceDidFinishDownloadingKey))
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
|
||||
NSString *destPath = _destination;
|
||||
if (nil == destPath || [destPath isEqualToString:[destPath lastPathComponent]])
|
||||
{
|
||||
destPath = _connectionDestination;
|
||||
}
|
||||
else if (!_allowOverwrite)
|
||||
{
|
||||
NSUInteger index = 1;
|
||||
NSString *parentFolder = [destPath stringByDeletingLastPathComponent];
|
||||
NSString *initialFileName = [[destPath lastPathComponent] stringByDeletingPathExtension];
|
||||
NSString *fileExtension = [destPath pathExtension];
|
||||
|
||||
while ([fileManager fileExistsAtPath:destPath])
|
||||
{
|
||||
NSString *fileName = [initialFileName stringByAppendingFormat:@"_%ld", index];
|
||||
destPath = [[parentFolder stringByAppendingPathComponent:fileName] stringByAppendingPathExtension:fileExtension];
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
BOOL success = YES;
|
||||
|
||||
if (![destPath isEqualToString:_connectionDestination])
|
||||
{
|
||||
success = success && [fileManager createDirectoryAtPath:[destPath stringByDeletingLastPathComponent]
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:&error];
|
||||
if (success && [fileManager fileExistsAtPath:destPath])
|
||||
success = [fileManager removeItemAtPath:destPath error:&error];
|
||||
success = success && [fileManager moveItemAtPath:_connectionDestination toPath:destPath error:&error];
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
[self setDestination:destPath allowOverwrite:_allowOverwrite];
|
||||
|
||||
void (^block)(void) = ^ {
|
||||
if ([_delegate respondsToSelector:@selector(download:didCreateDestination:)])
|
||||
[_delegate download:(NSURLDownload *)self didCreateDestination:destPath];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(downloadDidFinish:)])
|
||||
[_delegate downloadDidFinish:(NSURLDownload *)self];
|
||||
|
||||
_isDownloading = NO;
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
_downloadError = [error retain];
|
||||
}
|
||||
}
|
||||
else if (0 == strcmp(key, SUDownloadServiceMIMETypeToDecodeKey))
|
||||
{
|
||||
void (^block)(void) = ^{
|
||||
BOOL shouldDecode = NO;
|
||||
if ([_delegate respondsToSelector:@selector(download:shouldDecodeSourceDataOfMIMEType:)])
|
||||
{
|
||||
NSString *MIMEType = [NSString stringWithCString:xpc_dictionary_get_string(nevent, SUDownloadServiceMIMETypeToDecodeKey)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
shouldDecode = [_delegate download:(NSURLDownload *)self shouldDecodeSourceDataOfMIMEType:MIMEType];
|
||||
}
|
||||
xpc_dictionary_set_bool(answer, SUDownloadServiceShouldDecodeMIMETypeKey, YES);
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:YES];
|
||||
}
|
||||
|
||||
[localPool release];
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
xpc_connection_send_message(peer, answer);
|
||||
xpc_release(answer);
|
||||
});
|
||||
xpc_connection_resume(peer);
|
||||
}
|
||||
});
|
||||
|
||||
// Need to resume the service in order for it to process messages.
|
||||
xpc_connection_resume(_delegateConnection);
|
||||
xpc_connection_resume(_connection);
|
||||
return _connection;
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)performBlock:(void (^)(void))block onThread:(NSThread *)thread synchronous:(BOOL)flag
|
||||
{
|
||||
void (^blockCopy)(void) = block != NULL ? Block_copy(block) : NULL;
|
||||
[self performSelector:@selector(fireBlock:) onThread:thread withObject:blockCopy waitUntilDone:flag];
|
||||
}
|
||||
|
||||
- (void)fireBlock:(void (^)(void))block
|
||||
{
|
||||
if (NULL == block)
|
||||
return;
|
||||
|
||||
block();
|
||||
Block_release(block);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,265 @@
|
||||
//
|
||||
// main.m
|
||||
// Downloading XPC Service
|
||||
//
|
||||
// Created by Erik Aderstedt on 2012-08-09.
|
||||
// Based on the Apple sample code 'SandboxedFetch'.
|
||||
//
|
||||
|
||||
#import <xpc/xpc.h>
|
||||
#import <asl.h>
|
||||
#import <assert.h>
|
||||
#import <errno.h>
|
||||
#import <stdio.h>
|
||||
|
||||
#import "SUDownloadServiceConstants.h"
|
||||
#import "SUDSDownloader.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
static void fetch_process_request(xpc_object_t request, xpc_object_t reply);
|
||||
static void fetch_peer_event_handler(xpc_connection_t peer, xpc_object_t event);
|
||||
static void fetch_event_handler(xpc_connection_t peer);
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// Process the XPC request, create a temporary file to hold downloaded,
|
||||
// data, and build/return XPC reply.
|
||||
static void fetch_process_request(xpc_object_t request, xpc_object_t reply)
|
||||
{
|
||||
__block int32_t errcode = 0;
|
||||
__block const char *errmsg = NULL;
|
||||
__block const char *errdomain = NULL;
|
||||
|
||||
xpc_connection_t connection = NULL;
|
||||
|
||||
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
|
||||
do
|
||||
{
|
||||
size_t dataLength = 0;
|
||||
const void *data = xpc_dictionary_get_data(request, SUDownloadServiceURLRequestDataKey, &dataLength);
|
||||
NSData *requestData = [NSData dataWithBytes:data length:dataLength];
|
||||
|
||||
NSURLRequest *urlRequest = [NSKeyedUnarchiver unarchiveObjectWithData:requestData];
|
||||
if (nil == urlRequest)
|
||||
{
|
||||
errcode = SUXPCServiceError;
|
||||
errdomain = [SUSparkleErrorDomain cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
errmsg = "Invalid URL request data";
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the URL and XPC connection from the XPC request
|
||||
connection = xpc_dictionary_create_connection(request, SUDownloadServiceDelegateConnectionKey);
|
||||
if (connection == NULL)
|
||||
{
|
||||
errcode = SUXPCServiceError;
|
||||
errdomain = [SUSparkleErrorDomain cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
errmsg = "Invalid XPC delegate connection";
|
||||
break;
|
||||
}
|
||||
|
||||
// Set up XPC connection endpoint for sending progress reports and receiving cancel notification.
|
||||
__block BOOL shouldStopDownload = NO;
|
||||
xpc_connection_set_event_handler(connection, ^(xpc_object_t event) {
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
|
||||
// If the remote end of this connection has gone away then stop download
|
||||
if (XPC_TYPE_ERROR == type &&
|
||||
(XPC_ERROR_CONNECTION_INTERRUPTED == event || XPC_ERROR_CONNECTION_INVALID == event))
|
||||
{
|
||||
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Stopping download process...\n");
|
||||
shouldStopDownload = YES;
|
||||
}
|
||||
});
|
||||
xpc_connection_resume(connection);
|
||||
|
||||
NSString *destinationPath = [NSString stringWithCString:xpc_dictionary_get_string(request, SUDownloadServiceFilePathKey)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
SUDSDownloader *downloader = [SUDSDownloader downloaderWithURLRequest:urlRequest
|
||||
destinationPath:destinationPath];
|
||||
|
||||
SUDSDownloaderCallBacks callBacks = {0};
|
||||
|
||||
callBacks.downloadDidReceiveData = ^(SUDSDownloader *downloader, NSUInteger dataLength) {
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_int64(message, SUDownloadServiceReceivedDataLengthKey, (int64_t)dataLength);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
xpc_release(answer);
|
||||
};
|
||||
|
||||
callBacks.downloadDidReceiveResponse = ^(SUDSDownloader *downloader, NSURLResponse *response) {
|
||||
NSData *responseData = [NSKeyedArchiver archivedDataWithRootObject:response];
|
||||
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_data(message, SUDownloadServiceReceivedResponseDataKey, [responseData bytes], [responseData length]);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
xpc_release(answer);
|
||||
};
|
||||
|
||||
callBacks.downloadDidCreateDestination = ^(SUDSDownloader *downloader, NSString *destinationPath) {
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_string(message, SUDownloadServiceCreatedDestinationPathKey, [destinationPath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
xpc_release(answer);
|
||||
};
|
||||
|
||||
callBacks.downloadDidBegin = ^(SUDSDownloader *downloader) {
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_bool(message, SUDownloadServiceDidBeginDownloadingKey, true);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
xpc_release(answer);
|
||||
};
|
||||
|
||||
callBacks.downloadDidFail = ^(SUDSDownloader *downloader, NSError *error) {
|
||||
errcode = (int32_t)[error code];
|
||||
errdomain = [[error domain] cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
errmsg = [[error localizedDescription] cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
NSData *errorData = [NSKeyedArchiver archivedDataWithRootObject:error];
|
||||
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_data(message, SUDownloadServiceReceivedFailErrorKey, [errorData bytes], [errorData length]);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
xpc_release(answer);
|
||||
};
|
||||
|
||||
callBacks.downloadDidFinish = ^(SUDSDownloader *downloader) {
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_bool(message, SUDownloadServiceDidFinishDownloadingKey, true);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
xpc_release(answer);
|
||||
};
|
||||
|
||||
callBacks.downloadShouldDecodeSourceData = ^BOOL(SUDSDownloader *downloader, NSString *MIMEType) {
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_string(message, SUDownloadServiceMIMETypeToDecodeKey, [MIMEType cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
xpc_object_t answer = xpc_connection_send_message_with_reply_sync(connection, message);
|
||||
xpc_release(message);
|
||||
|
||||
BOOL result = NO;
|
||||
if (xpc_get_type(answer) == XPC_TYPE_DICTIONARY)
|
||||
result = (BOOL)xpc_dictionary_get_bool(answer, SUDownloadServiceShouldDecodeMIMETypeKey);
|
||||
xpc_release(answer);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
[downloader setCallBacks:callBacks];
|
||||
|
||||
[downloader startDownload];
|
||||
while ([downloader isInProgress])
|
||||
{
|
||||
if (shouldStopDownload)
|
||||
{
|
||||
[downloader stopDownload];
|
||||
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Download process stopped.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, true);
|
||||
}
|
||||
}
|
||||
while (NO);
|
||||
[localPool release];
|
||||
|
||||
#if DEBUG_LOGGING_ENABLED
|
||||
NSLog(@"Download process finished. Will send last message...");
|
||||
#endif
|
||||
// Clean up and add errcode/errmsg to reply
|
||||
if (connection)
|
||||
{
|
||||
xpc_connection_cancel(connection);
|
||||
xpc_release(connection);
|
||||
}
|
||||
|
||||
xpc_dictionary_set_int64(reply, SUDownloadServiceErrorCodeKey, (int64_t)errcode);
|
||||
if (errmsg)
|
||||
{
|
||||
xpc_dictionary_set_string(reply, SUDownloadServiceErrorMessageKey, errmsg);
|
||||
}
|
||||
if (errdomain)
|
||||
{
|
||||
xpc_dictionary_set_string(reply, SUDownloadServiceErrorDomainKey, errdomain);
|
||||
}
|
||||
}
|
||||
|
||||
static void fetch_peer_event_handler(xpc_connection_t peer, xpc_object_t event)
|
||||
{
|
||||
// Get the object type.
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
if (XPC_TYPE_ERROR == type)
|
||||
{
|
||||
// Handle an error.
|
||||
if (XPC_ERROR_CONNECTION_INVALID == event)
|
||||
{
|
||||
// The client process on the other end of the connection
|
||||
// has either crashed or cancelled the connection.
|
||||
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "peer(%d) received "
|
||||
"XPC_ERROR_CONNECTION_INVALID",
|
||||
xpc_connection_get_pid(peer));
|
||||
xpc_connection_cancel(peer);
|
||||
}
|
||||
else if (XPC_ERROR_TERMINATION_IMMINENT == event)
|
||||
{
|
||||
// Handle per-connection termination cleanup. This
|
||||
// service is about to exit.
|
||||
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "peer(%d) received "
|
||||
"XPC_ERROR_TERMINATION_IMMINENT",
|
||||
xpc_connection_get_pid(peer));
|
||||
}
|
||||
}
|
||||
else if (XPC_TYPE_DICTIONARY == type)
|
||||
{
|
||||
xpc_object_t requestMessage = event;
|
||||
xpc_object_t replyMessage = xpc_dictionary_create_reply(requestMessage);
|
||||
assert(replyMessage != NULL);
|
||||
|
||||
// Process request and build a reply message.
|
||||
fetch_process_request(requestMessage, replyMessage);
|
||||
|
||||
xpc_connection_send_message(peer, replyMessage);
|
||||
xpc_release(replyMessage);
|
||||
}
|
||||
}
|
||||
|
||||
static void release_dispatch_queue(void *queue)
|
||||
{
|
||||
dispatch_release(queue);
|
||||
}
|
||||
|
||||
static void fetch_event_handler(xpc_connection_t peer)
|
||||
{
|
||||
// Generate an unique name for the queue to handle messages from
|
||||
// this peer and create a new dispatch queue for it.
|
||||
char *queue_name = NULL;
|
||||
asprintf(&queue_name, "%s-peer-%d", "com.andymatuschak.Sparkle.download-service", xpc_connection_get_pid(peer));
|
||||
dispatch_queue_t peer_event_queue = dispatch_queue_create(queue_name, DISPATCH_QUEUE_SERIAL);
|
||||
assert(peer_event_queue != NULL);
|
||||
free(queue_name);
|
||||
|
||||
// Set the target queue for connection.
|
||||
xpc_connection_set_target_queue(peer, peer_event_queue);
|
||||
xpc_connection_set_context(peer, peer_event_queue);
|
||||
xpc_connection_set_finalizer_f(peer, release_dispatch_queue);
|
||||
|
||||
// Set the handler block for connection.
|
||||
xpc_connection_set_event_handler(peer, ^(xpc_object_t event) {
|
||||
fetch_peer_event_handler(peer, event);
|
||||
});
|
||||
|
||||
// Enable the peer connection to receive messages.
|
||||
xpc_connection_resume(peer);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
xpc_main(fetch_event_handler);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+6
-6
@@ -6,22 +6,22 @@
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<string>org.andymatuschak.Sparkle</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.5 Beta (git)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.5</string>
|
||||
<string>${DYLIB_CURRENT_VERSION}</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${DYLIB_CURRENT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// SUInstallServiceConstants.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Dmytro Tretiakov on 8/2/13.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef Sparkle_SUInstallServiceConstants_h
|
||||
#define Sparkle_SUInstallServiceConstants_h
|
||||
|
||||
typedef enum _SUInstallSerciveTask
|
||||
{
|
||||
SUInstallServiceTaskCopyPath = 1LL,
|
||||
SUInstallServiceTaskLaunchTask = 2LL
|
||||
} SUInstallServiceTask;
|
||||
|
||||
const char * SUInstallServiceTaskTypeKey = "task_type"; // int64_t
|
||||
|
||||
// SUInstallServiceTaskCopyPath keys
|
||||
const char * SUInstallServiceSourcePathKey = "source_path"; // c-string
|
||||
const char * SUInstallServiceDestinationPathKey = "destination_path"; // c-string
|
||||
const char * SUInstallServiceTempNameKey = "tmp_name"; // c-string
|
||||
|
||||
// SUInstallServiceTaskLaunchTask keys
|
||||
const char * SUInstallServiceLaunchTaksPathKey = "launch_task_path";
|
||||
const char * SUInstallServiceLaunchTaskArgumentsKey = "launch_task_arguments"; // xpc_array of c-strings
|
||||
|
||||
// Reply keys
|
||||
const char * SUInstallServiceErrorCodeKey = "error_code"; // int64_t
|
||||
const char * SUInstallServiceErrorLocalizedDescriptionKey = "error_localized_description"; // c-string
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// SUXPCInstaller.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Whitney Young on 3/19/12.
|
||||
// Copyright (c) 2012 FadingRed. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUXPCInstaller : NSObject
|
||||
|
||||
+ (void)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp completionHandler:(void (^)(NSError *error))completionHandler;
|
||||
+ (void)launchTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments completionHandler:(void (^)(void))completionHandler ;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// SUXPCInstaller.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Whitney Young on 3/19/12.
|
||||
// Copyright (c) 2012 FadingRed. All rights reserved.
|
||||
//
|
||||
|
||||
#import <xpc/xpc.h>
|
||||
#import "SUXPCInstaller.h"
|
||||
#import "SUInstallServiceConstants.h"
|
||||
|
||||
|
||||
@implementation SUXPCInstaller
|
||||
|
||||
+ (xpc_connection_t)getSandboxXPCService
|
||||
{
|
||||
__block xpc_connection_t serviceConnection = xpc_connection_create("com.andymatuschak.Sparkle.install-service", dispatch_get_main_queue());
|
||||
|
||||
if (!serviceConnection)
|
||||
{
|
||||
NSLog(@"Can't connect to XPC service");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
xpc_connection_set_event_handler(serviceConnection, ^(xpc_object_t event) {
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
|
||||
if (type == XPC_TYPE_ERROR)
|
||||
{
|
||||
if (event == XPC_ERROR_CONNECTION_INVALID)
|
||||
{
|
||||
// The service is invalid. Either the service name supplied to
|
||||
// xpc_connection_create() is incorrect or we (this process) have
|
||||
// canceled the service; we can do any cleanup of appliation
|
||||
// state at this point.
|
||||
xpc_release(serviceConnection);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Need to resume the service in order for it to process messages.
|
||||
xpc_connection_resume(serviceConnection);
|
||||
return (serviceConnection);
|
||||
}
|
||||
|
||||
+ (void)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp completionHandler:(void (^)(NSError *error))completionHandler
|
||||
{
|
||||
xpc_connection_t connection = [self getSandboxXPCService];
|
||||
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_int64(message, SUInstallServiceTaskTypeKey, (int64_t)SUInstallServiceTaskCopyPath);
|
||||
|
||||
if (src)
|
||||
xpc_dictionary_set_string(message, SUInstallServiceSourcePathKey, [src fileSystemRepresentation]);
|
||||
if (dst)
|
||||
xpc_dictionary_set_string(message, SUInstallServiceDestinationPathKey, [dst fileSystemRepresentation]);
|
||||
if (tmp)
|
||||
xpc_dictionary_set_string(message, SUInstallServiceTempNameKey, [tmp UTF8String]);
|
||||
|
||||
xpc_connection_send_message_with_reply(connection, message, dispatch_get_main_queue(), ^(xpc_object_t response) {
|
||||
if (NULL == completionHandler)
|
||||
return;
|
||||
|
||||
const char *errorString = xpc_dictionary_get_string(response, SUInstallServiceErrorLocalizedDescriptionKey);
|
||||
if (errorString != NULL)
|
||||
{
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUXPCServiceError
|
||||
userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithCString:errorString encoding:NSUTF8StringEncoding]
|
||||
forKey:NSLocalizedDescriptionKey]];
|
||||
completionHandler(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
completionHandler(nil);
|
||||
}
|
||||
});
|
||||
xpc_release(message);
|
||||
}
|
||||
|
||||
+ (void)launchTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments completionHandler:(void (^)(void))completionHandler
|
||||
{
|
||||
xpc_connection_t connection = [self getSandboxXPCService];
|
||||
|
||||
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
|
||||
xpc_dictionary_set_int64(message, SUInstallServiceTaskTypeKey, (int64_t)SUInstallServiceTaskLaunchTask);
|
||||
|
||||
if (path)
|
||||
xpc_dictionary_set_string(message, SUInstallServiceLaunchTaksPathKey, [path fileSystemRepresentation]);
|
||||
|
||||
xpc_object_t array = xpc_array_create(NULL, 0);
|
||||
for (id argument in arguments)
|
||||
{
|
||||
xpc_array_set_string(array, XPC_ARRAY_APPEND, [argument UTF8String]);
|
||||
}
|
||||
xpc_dictionary_set_value(message, SUInstallServiceLaunchTaskArgumentsKey, array);
|
||||
xpc_release(array);
|
||||
|
||||
xpc_connection_send_message_with_reply(connection, message, dispatch_get_current_queue(), ^(xpc_object_t response) {
|
||||
if (completionHandler != NULL)
|
||||
completionHandler();
|
||||
});
|
||||
xpc_release(message);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${EXECUTABLE_NAME}</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>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>XPCService</key>
|
||||
<dict>
|
||||
<key>ServiceType</key>
|
||||
<string>Application</string>
|
||||
<key>JoinExistingSession</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// main.m
|
||||
// Update
|
||||
//
|
||||
// Created by Whitney Young on 3/19/12.
|
||||
// Copyright (c) 2012 FadingRed. All rights reserved.
|
||||
//
|
||||
|
||||
#include <xpc/xpc.h>
|
||||
#include <asl.h>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUInstallServiceConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
static void peer_event_handler(xpc_connection_t peer, xpc_object_t event)
|
||||
{
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
if (type == XPC_TYPE_ERROR)
|
||||
{
|
||||
if (event == XPC_ERROR_CONNECTION_INVALID)
|
||||
{
|
||||
// The client process on the other end of the connection has either
|
||||
// crashed or cancelled the connection. After receiving this error,
|
||||
// the connection is in an invalid state, and you do not need to
|
||||
// call xpc_connection_cancel(). Just tear down any associated state
|
||||
// here.
|
||||
}
|
||||
else if (event == XPC_ERROR_TERMINATION_IMMINENT)
|
||||
{
|
||||
// Handle per-connection termination cleanup.
|
||||
}
|
||||
}
|
||||
else if (type == XPC_TYPE_DICTIONARY)
|
||||
{
|
||||
// Handle the message.
|
||||
SUInstallServiceTask task = (SUInstallServiceTask)xpc_dictionary_get_int64(event, SUInstallServiceTaskTypeKey);
|
||||
|
||||
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
|
||||
switch (task)
|
||||
{
|
||||
case SUInstallServiceTaskCopyPath:
|
||||
{
|
||||
const char *src = xpc_dictionary_get_string(event, SUInstallServiceSourcePathKey);
|
||||
const char *dst = xpc_dictionary_get_string(event, SUInstallServiceDestinationPathKey);
|
||||
const char *tmp = xpc_dictionary_get_string(event, SUInstallServiceTempNameKey);
|
||||
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSString *relaunchPathToCopy = src ? [manager stringWithFileSystemRepresentation:src length:strlen(src)] : nil;
|
||||
NSString *targetPath = dst ? [manager stringWithFileSystemRepresentation:dst length:strlen(dst)] : nil;
|
||||
NSString *temporaryName = tmp ? [NSString stringWithUTF8String:tmp] : nil;
|
||||
NSError *error = nil;
|
||||
BOOL result = [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: temporaryName error: &error];
|
||||
|
||||
// send response to indicate ok
|
||||
xpc_object_t reply = xpc_dictionary_create_reply(event);
|
||||
if (!result && error != nil)
|
||||
{
|
||||
xpc_dictionary_set_int64(reply, SUInstallServiceErrorCodeKey, [error code]);
|
||||
xpc_dictionary_set_string(reply, SUInstallServiceErrorLocalizedDescriptionKey, [[error localizedDescription] cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
}
|
||||
xpc_connection_send_message(peer, reply);
|
||||
xpc_release(reply);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SUInstallServiceTaskLaunchTask:
|
||||
{
|
||||
const char *path = xpc_dictionary_get_string(event, SUInstallServiceLaunchTaksPathKey);
|
||||
xpc_object_t array = xpc_dictionary_get_value(event, SUInstallServiceLaunchTaskArgumentsKey);
|
||||
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSString *relaunchToolPath = path ? [manager stringWithFileSystemRepresentation:path length:strlen(path)] : nil;;
|
||||
NSMutableArray *arguments = [NSMutableArray array];
|
||||
for (size_t i = 0; i < xpc_array_get_count(array); i++)
|
||||
{
|
||||
[arguments addObject:[NSString stringWithUTF8String:xpc_array_get_string(array, i)]];
|
||||
}
|
||||
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:arguments];
|
||||
|
||||
// send response to indicate ok
|
||||
xpc_object_t reply = xpc_dictionary_create_reply(event);
|
||||
xpc_connection_send_message(peer, reply);
|
||||
xpc_release(reply);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
SULog(@"XPC Install Service: Unknown XPC service task %lld", (int64_t)task);
|
||||
|
||||
xpc_object_t reply = xpc_dictionary_create_reply(event);
|
||||
xpc_dictionary_set_int64(reply, SUInstallServiceErrorCodeKey, (int64_t)1);
|
||||
xpc_dictionary_set_string(reply, SUInstallServiceErrorLocalizedDescriptionKey, "Unknown install cervice task.");
|
||||
xpc_connection_send_message(peer, reply);
|
||||
xpc_release(reply);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
[localPool release];
|
||||
}
|
||||
}
|
||||
|
||||
static void event_handler(xpc_connection_t peer)
|
||||
{
|
||||
// By defaults, new connections will target the default dispatch
|
||||
// concurrent queue.
|
||||
xpc_connection_set_event_handler(peer, ^(xpc_object_t event) {
|
||||
peer_event_handler(peer, event);
|
||||
});
|
||||
|
||||
// This will tell the connection to begin listening for events. If you
|
||||
// have some other initialization that must be done asynchronously, then
|
||||
// you can defer this call until after that initialization is done.
|
||||
xpc_connection_resume(peer);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
xpc_main(event_handler);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// install_service.pch
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Dmytro Tretiakov on 4/25/14.
|
||||
//
|
||||
//
|
||||
|
||||
#define SPARKLE_BUNDLE [NSBundle mainBundle]
|
||||
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
|
||||
|
||||
Binary file not shown.
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.binaryage.totalfinder.sparkle.relaunch</string>
|
||||
<string>org.andymatuschak.Sparkle.relaunch</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf200
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;\red38\green38\blue38;}
|
||||
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
|
||||
\deftab720
|
||||
\pard\pardeftab720
|
||||
|
||||
\f0\b\fs26 \cf2 Version 2.0\
|
||||
\pard\pardeftab720\sl380
|
||||
|
||||
\b0 \cf2 \'96 Works correctly with Sandboxed environment\
|
||||
\'96 Added simple integration of beta updates check and test mode\
|
||||
\'96 Integrated with DevMate service (sends additional info for statistics)}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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>rules</key>
|
||||
<dict>
|
||||
<key>^Resources/</key>
|
||||
<true/>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^version.plist$</key>
|
||||
<true/>
|
||||
<key>^Headers/</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^PrivateHeaders/</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
+6
-3
@@ -10,25 +10,28 @@
|
||||
#define SUAPPCAST_H
|
||||
|
||||
@class SUAppcastItem;
|
||||
@interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
@interface SUAppcast : NSObject
|
||||
{
|
||||
@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;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUAppcastDelegate)
|
||||
- (void)appcast:(SUAppcast *)appcast willFetchURLRequest:(NSMutableURLRequest *)request;
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
|
||||
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
|
||||
@end
|
||||
|
||||
+57
-15
@@ -6,7 +6,7 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUpdater.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
@@ -14,6 +14,7 @@
|
||||
#import "SUAppcast.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SUXPCURLDownload.h"
|
||||
|
||||
@interface NSXMLElement (SUAppcastExtensions)
|
||||
- (NSDictionary *)attributesAsDictionary;
|
||||
@@ -42,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];
|
||||
}
|
||||
@@ -61,10 +58,20 @@
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
|
||||
if (userAgentString)
|
||||
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
if ([appcastValues count])
|
||||
[request setAllHTTPHeaderFields:appcastValues];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(appcast:willFetchURLRequest:)])
|
||||
[delegate appcast:self willFetchURLRequest:request];
|
||||
|
||||
if ([SUUpdater shouldUseXPCDownloader])
|
||||
{
|
||||
download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
||||
@@ -104,7 +111,11 @@
|
||||
}
|
||||
document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease];
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil];
|
||||
#else
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
#endif
|
||||
[downloadFilename release];
|
||||
downloadFilename = nil;
|
||||
}
|
||||
@@ -230,7 +241,11 @@
|
||||
{
|
||||
if (downloadFilename)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil];
|
||||
#else
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
#endif
|
||||
}
|
||||
[downloadFilename release];
|
||||
downloadFilename = nil;
|
||||
@@ -278,11 +293,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
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@
|
||||
}
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
|
||||
- initWithDictionary:(NSDictionary *)dict;
|
||||
- initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
|
||||
|
||||
- (NSString *)title;
|
||||
- (NSString *)versionString;
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@
|
||||
// Find the appropriate release notes URL.
|
||||
if ([dict objectForKey:@"sparkle:releaseNotesLink"])
|
||||
[self setReleaseNotesURL:[NSURL URLWithString:[dict objectForKey:@"sparkle:releaseNotesLink"]]];
|
||||
else if ([[self itemDescription] hasPrefix:@"http://"]) // if the description starts with http://, use that.
|
||||
else if ([[self itemDescription] hasPrefix:@"http://"] || [[self itemDescription] hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
|
||||
[self setReleaseNotesURL:[NSURL URLWithString:[self itemDescription]]];
|
||||
else
|
||||
[self setReleaseNotesURL:nil];
|
||||
|
||||
@@ -11,9 +11,50 @@
|
||||
#import "SUAutomaticUpdateAlert.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUXPCURLDownload.h"
|
||||
|
||||
@implementation SUAutomaticUpdateDriver
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
|
||||
static NSString * const kSUAutomaticUpdateParamName = @"autoupdate";
|
||||
|
||||
- (void)downloadReleaseNotesAndWaitUntilDone
|
||||
{
|
||||
NSURL *releaseNotesURL = [updateItem releaseNotesURL];
|
||||
if (nil == releaseNotesURL || [releaseNotesURL isFileURL])
|
||||
return;
|
||||
|
||||
NSString *URLString = [releaseNotesURL absoluteString];
|
||||
URLString = [URLString stringByAppendingFormat:@"%@%@=1", ([releaseNotesURL query] != nil) ? @"&" : @"?", kSUAutomaticUpdateParamName];
|
||||
releaseNotesURL = [NSURL URLWithString:URLString];
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:releaseNotesURL];
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
|
||||
if ([SUUpdater shouldUseXPCDownloader])
|
||||
{
|
||||
[SUXPCURLDownload sendSynchronousRequest:request delegate:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
// For correct DevMate statistics need to send request for Release Notes.
|
||||
[self downloadReleaseNotesAndWaitUntilDone];
|
||||
[super didFindValidUpdate];
|
||||
}
|
||||
|
||||
#endif // SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
{
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
|
||||
@@ -36,7 +77,7 @@
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
{
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#import "SUUpdateDriver.h"
|
||||
|
||||
@class SUAppcastItem, SUUnarchiver, SUAppcast, SUUnarchiver, SUHost;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate> {
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver {
|
||||
SUAppcastItem *updateItem;
|
||||
SUAppcastItem *nonDeltaUpdateItem;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
- (void)didFindValidUpdate;
|
||||
- (void)didNotFindUpdate;
|
||||
|
||||
- (void)updateURLRequestIfNeeds:(NSMutableURLRequest *)request;
|
||||
- (void)downloadUpdate;
|
||||
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
|
||||
- (void)downloadDidFinish:(NSURLDownload *)d;
|
||||
@@ -49,6 +50,7 @@
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
|
||||
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
|
||||
- (void)cleanUpDownload;
|
||||
|
||||
- (void)abortUpdate;
|
||||
|
||||
+143
-37
@@ -20,6 +20,27 @@
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUXPCInstaller.h"
|
||||
#import "SUXPCURLDownload.h"
|
||||
|
||||
#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",
|
||||
@"test.updates.aws.devmate.vpn",
|
||||
nil];
|
||||
}
|
||||
|
||||
return sAllKnownDevMateURLHosts;
|
||||
}
|
||||
#endif
|
||||
|
||||
@interface SUBasicUpdateDriver () <NSURLDownloadDelegate>; @end
|
||||
|
||||
@@ -27,18 +48,18 @@
|
||||
@implementation SUBasicUpdateDriver
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
{
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
if ([aHost isRunningOnReadOnlyVolume])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] forKey:NSLocalizedDescriptionKey]]];
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SUAppcast *appcast = [[SUAppcast alloc] init];
|
||||
CFRetain(appcast); // We'll manage the appcast's memory ourselves so we don't have to make it an IV to support GC.
|
||||
[appcast release];
|
||||
|
||||
|
||||
[appcast setDelegate:self];
|
||||
[appcast setUserAgentString:[updater userAgentString]];
|
||||
[appcast fetchAppcastFromURL:URL];
|
||||
@@ -47,16 +68,16 @@
|
||||
- (id <SUVersionComparison>)versionComparator
|
||||
{
|
||||
id <SUVersionComparison> comparator = nil;
|
||||
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)])
|
||||
comparator = [[updater delegate] versionComparatorForUpdater:updater];
|
||||
|
||||
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator)
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
|
||||
return comparator;
|
||||
|
||||
return comparator;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
@@ -66,12 +87,12 @@
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
{
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
||||
|
||||
|
||||
BOOL minimumVersionOK = TRUE;
|
||||
BOOL maximumVersionOK = TRUE;
|
||||
|
||||
|
||||
// Check minimum and maximum System Version
|
||||
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
|
||||
@@ -79,7 +100,7 @@
|
||||
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
|
||||
}
|
||||
|
||||
|
||||
return minimumVersionOK && maximumVersionOK;
|
||||
}
|
||||
|
||||
@@ -99,9 +120,9 @@
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)])
|
||||
[[updater delegate] updater:updater didFinishLoadingAppcast:ac];
|
||||
|
||||
|
||||
SUAppcastItem *item = nil;
|
||||
|
||||
|
||||
// Now we have to find the best valid update in the appcast.
|
||||
if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
@@ -115,7 +136,7 @@
|
||||
item = [updateEnumerator nextObject];
|
||||
} while (item && ![self hostSupportsItem:item]);
|
||||
|
||||
if (binaryDeltaSupported()) {
|
||||
if (binaryDeltaSupported()) {
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:[host version]];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
nonDeltaUpdateItem = [item retain];
|
||||
@@ -123,11 +144,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateItem = [item retain];
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
if (updateItem == nil) { [self didNotFindUpdate]; return; }
|
||||
|
||||
|
||||
if ([self itemContainsValidUpdate:updateItem])
|
||||
[self didFindValidUpdate];
|
||||
else
|
||||
@@ -140,6 +161,27 @@
|
||||
[self abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)appcast:(SUAppcast *)appcast willFetchURLRequest:(NSMutableURLRequest *)request
|
||||
{
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
}
|
||||
|
||||
- (void)updateURLRequestIfNeeds:(NSMutableURLRequest *)request
|
||||
{
|
||||
#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
if ([SUGetAllDevMateURLHosts() containsObject:[[request URL] host]])
|
||||
{
|
||||
CFBundleRef hostBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:[host bundlePath]]);
|
||||
NSDictionary *devmateHeaders = (NSDictionary *)DMCopyHTTPRequestHeaders(hostBundle, NULL) ? : [NSDictionary new];
|
||||
[request setAllHTTPHeaderFields:(NSDictionary *)devmateHeaders];
|
||||
|
||||
[devmateHeaders release];
|
||||
if (NULL != hostBundle)
|
||||
CFRelease(hostBundle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
@@ -158,18 +200,30 @@
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
|
||||
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
|
||||
if ([SUUpdater shouldUseXPCDownloader])
|
||||
download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
|
||||
else
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
{
|
||||
if ([SUUpdater shouldUseXPCDownloader]) {
|
||||
// The downloader will determine a file name, somewhere within our sandbox.
|
||||
downloadPath = nil;
|
||||
[d setDestination:name allowOverwrite:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
// If name ends in .txt, the server probably has a stupid MIME configuration. We'll give the developer the benefit of the doubt and chop that off.
|
||||
if ([[name pathExtension] isEqualToString:@"txt"])
|
||||
name = [name stringByDeletingPathExtension];
|
||||
|
||||
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]];
|
||||
|
||||
|
||||
|
||||
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain];
|
||||
int cnt=1;
|
||||
@@ -178,20 +232,39 @@
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
|
||||
}
|
||||
|
||||
|
||||
// Create the temporary directory if necessary.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
BOOL success = YES;
|
||||
NSEnumerator *pathComponentEnumerator = [[tempDir pathComponents] objectEnumerator];
|
||||
NSString *pathComponentAccumulator = @"";
|
||||
NSString *currentPathComponent;
|
||||
while ((currentPathComponent = [pathComponentEnumerator nextObject])) {
|
||||
pathComponentAccumulator = [pathComponentAccumulator stringByAppendingPathComponent:currentPathComponent];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:pathComponentAccumulator]) continue;
|
||||
success &= [[NSFileManager defaultManager] createDirectoryAtPath:pathComponentAccumulator attributes:nil];
|
||||
}
|
||||
#else
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
#endif
|
||||
if (!success)
|
||||
{
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[download cancel];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir] forKey:NSLocalizedDescriptionKey]]];
|
||||
}
|
||||
|
||||
|
||||
downloadPath = [[tempDir stringByAppendingPathComponent:name] retain];
|
||||
[download setDestination:downloadPath allowOverwrite:YES];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path {
|
||||
[downloadPath autorelease];
|
||||
downloadPath = [path retain];
|
||||
[tempDir autorelease];
|
||||
tempDir = [[downloadPath stringByDeletingLastPathComponent] retain];
|
||||
}
|
||||
|
||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
||||
{
|
||||
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:host];
|
||||
@@ -204,12 +277,12 @@
|
||||
SULog(@"Code signature check on update failed: %@", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)d
|
||||
{
|
||||
{
|
||||
[self extractUpdate];
|
||||
}
|
||||
|
||||
@@ -278,14 +351,13 @@
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
relaunch = NO; // TOTALFINDER-related HACK to prevent relaunch, installer does relaunch automatically
|
||||
|
||||
|
||||
if (![updater mayUpdateAndRestart])
|
||||
{
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Give the host app an opportunity to postpone the install and relaunch.
|
||||
static BOOL postponedOnce = NO;
|
||||
if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
@@ -299,23 +371,46 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)])
|
||||
[[updater delegate] updater:updater willInstallUpdate:updateItem];
|
||||
|
||||
|
||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:@"finish_installation" ofType:@"app"];
|
||||
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSError *error = nil;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] attributes: [NSDictionary dictionary]];
|
||||
#else
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: [NSDictionary dictionary] error: &error];
|
||||
#endif
|
||||
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] )
|
||||
if( [SUUpdater shouldUseXPCInstaller] )
|
||||
{
|
||||
[SUXPCInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil completionHandler:^(NSError *xpcError) {
|
||||
if (xpcError != nil)
|
||||
NSLog(@"Error during asynchronous XPC call to copyPath: %@", xpcError);
|
||||
[self finishRelaunchAfterSuccessfulCopying:(xpcError == nil) fromPath:relaunchPathToCopy toPath:targetPath relaunch:relaunch];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL copiedRelaunchTool = [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error];
|
||||
[self finishRelaunchAfterSuccessfulCopying:copiedRelaunchTool fromPath:relaunchPathToCopy toPath:targetPath relaunch:relaunch];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)finishRelaunchAfterSuccessfulCopying:(BOOL)copiedRelaunchTool fromPath:(NSString *)relaunchPathToCopy toPath:(NSString *)targetPath relaunch:(BOOL)relaunch
|
||||
{
|
||||
|
||||
NSError *error = nil;
|
||||
if( copiedRelaunchTool )
|
||||
relaunchPath = [targetPath retain];
|
||||
else
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[[updater delegate] updaterWillRelaunchApplication:updater];
|
||||
@@ -326,15 +421,22 @@
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [host name]], NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NSString *pathToRelaunch = [host bundlePath];
|
||||
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
|
||||
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
|
||||
NSString *relaunchToolPath = [relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS/finish_installation"];
|
||||
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:[NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", nil]];
|
||||
|
||||
[NSApp terminate:self];
|
||||
NSArray *arguments = [NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", nil];
|
||||
if( [SUUpdater shouldUseXPCInstaller] )
|
||||
[SUXPCInstaller launchTaskWithLaunchPath: relaunchToolPath arguments:arguments completionHandler:^{
|
||||
[NSApp terminate:self];
|
||||
}];
|
||||
else
|
||||
{
|
||||
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:arguments];
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cleanUpDownload
|
||||
@@ -356,8 +458,12 @@
|
||||
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
|
||||
{
|
||||
if (aHost != host) { return; }
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] removeFileAtPath: relaunchPath handler: nil]; // Clean up the copied relauncher
|
||||
#else
|
||||
NSError * dontThrow = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath: relaunchPath error: &dontThrow]; // Clean up the copied relauncher
|
||||
#endif
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
}
|
||||
|
||||
|
||||
@@ -148,10 +148,18 @@ NSString *hashOfTree(NSString *path)
|
||||
|
||||
void removeTree(NSString *path)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] removeItemAtPath:path error:0];
|
||||
#else
|
||||
[[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
void copyTree(NSString *source, NSString *dest)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:0];
|
||||
#else
|
||||
[[NSFileManager defaultManager] copyPath:source toPath:dest handler:nil];
|
||||
#endif
|
||||
}
|
||||
@@ -12,8 +12,13 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error;
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned;
|
||||
+ (BOOL)hostApplicationIsSandboxed;
|
||||
+ (BOOL)hostAppAllowsNetworkOutgoingConnections;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
+120
-15
@@ -13,13 +13,11 @@
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
extern OSStatus SecCodeCopySelf(SecCSFlags flags, SecCodeRef *self) __attribute__((weak_import));
|
||||
|
||||
extern OSStatus SecCodeCopyDesignatedRequirement(SecStaticCodeRef code, SecCSFlags flags, SecRequirementRef *requirement) __attribute__((weak_import));
|
||||
|
||||
extern OSStatus SecStaticCodeCreateWithPath(CFURLRef path, SecCSFlags flags, SecStaticCodeRef *staticCode) __attribute__((weak_import));
|
||||
|
||||
extern OSStatus SecStaticCodeCheckValidityWithErrors(SecStaticCodeRef staticCode, SecCSFlags flags, SecRequirementRef requirement, CFErrorRef *errors) __attribute__((weak_import));
|
||||
|
||||
extern OSStatus SecRequirementCreateWithString(CFStringRef text, SecCSFlags flags, SecRequirementRef *requirement) __attribute__((weak_import));
|
||||
extern OSStatus SecCodeCheckValidity(SecCodeRef code, SecCSFlags flags, SecRequirementRef requirement) __attribute__((weak_import));
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error
|
||||
{
|
||||
@@ -68,19 +66,126 @@ finally:
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned
|
||||
{
|
||||
// This API didn't exist prior to 10.6.
|
||||
if (SecCodeCopySelf == NULL) return NO;
|
||||
static BOOL sIsCodesigned = NO;
|
||||
|
||||
OSStatus result;
|
||||
SecCodeRef hostCode = NULL;
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) return NO;
|
||||
static BOOL onceToken = NO;
|
||||
while (!onceToken)
|
||||
{
|
||||
onceToken = YES;
|
||||
|
||||
// This API didn't exist prior to 10.6.
|
||||
if (SecCodeCopySelf == NULL)
|
||||
break;
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
SecCodeRef hostCode = NULL;
|
||||
OSStatus result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != noErr)
|
||||
break;
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
|
||||
sIsCodesigned = (noErr == result);
|
||||
}
|
||||
|
||||
return sIsCodesigned;
|
||||
}
|
||||
|
||||
+ (BOOL)hostApplicationIsSandboxed
|
||||
{
|
||||
static BOOL sIsAppSandboxed = NO;
|
||||
|
||||
static BOOL onceToken = NO;
|
||||
while (!onceToken)
|
||||
{
|
||||
onceToken = YES;
|
||||
|
||||
// This API didn't exist prior to 10.6
|
||||
if (SecCodeCopySelf == NULL)
|
||||
break;
|
||||
|
||||
SecCodeRef hostCode = NULL;
|
||||
SecRequirementRef hostRequirement = NULL;
|
||||
|
||||
#define Cleanup() \
|
||||
{ \
|
||||
if (hostCode) CFRelease(hostCode); \
|
||||
if (hostRequirement) CFRelease(hostRequirement); \
|
||||
}
|
||||
|
||||
OSStatus status = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
|
||||
if (status != noErr || hostCode == NULL)
|
||||
{
|
||||
Cleanup();
|
||||
break;
|
||||
}
|
||||
|
||||
CFStringRef requirementString = CFSTR("entitlement[\"com.apple.security.app-sandbox\"] exists");
|
||||
status = SecRequirementCreateWithString(requirementString, kSecCSDefaultFlags, &hostRequirement);
|
||||
|
||||
if (status != noErr || hostRequirement == NULL)
|
||||
{
|
||||
Cleanup();
|
||||
break;
|
||||
}
|
||||
|
||||
status = SecCodeCheckValidity(hostCode, kSecCSDefaultFlags, hostRequirement);
|
||||
sIsAppSandboxed = (noErr == status);
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
return sIsAppSandboxed;
|
||||
}
|
||||
|
||||
+ (BOOL)hostAppAllowsNetworkOutgoingConnections
|
||||
{
|
||||
static BOOL sIsAppAllowsOutgoingConnections = NO;
|
||||
|
||||
static BOOL onceToken = NO;
|
||||
while (!onceToken)
|
||||
{
|
||||
onceToken = YES;
|
||||
|
||||
if (![self hostApplicationIsSandboxed])
|
||||
{
|
||||
sIsAppAllowsOutgoingConnections = YES;
|
||||
break;
|
||||
}
|
||||
|
||||
SecCodeRef hostCode = NULL;
|
||||
SecRequirementRef hostRequirement = NULL;
|
||||
|
||||
#define Cleanup() \
|
||||
{ \
|
||||
if (hostCode) CFRelease(hostCode); \
|
||||
if (hostRequirement) CFRelease(hostRequirement); \
|
||||
}
|
||||
|
||||
OSStatus status = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (status != noErr || hostCode == NULL)
|
||||
{
|
||||
Cleanup();
|
||||
break;
|
||||
}
|
||||
|
||||
CFStringRef requirementString = CFSTR("entitlement[\"com.apple.security.network.client\"] exists");
|
||||
status = SecRequirementCreateWithString(requirementString, kSecCSDefaultFlags, &hostRequirement);
|
||||
if (status != noErr || hostRequirement == NULL)
|
||||
{
|
||||
Cleanup();
|
||||
break;
|
||||
}
|
||||
|
||||
status = SecCodeCheckValidity(hostCode, kSecCSDefaultFlags, hostRequirement);
|
||||
sIsAppAllowsOutgoingConnections = (noErr == status);
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
return sIsAppAllowsOutgoingConnections;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef SUCONSTANTS_H
|
||||
#define SUCONSTANTS_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Preprocessor flags:
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -87,6 +89,7 @@ extern OSStatus SUMissingInstallerToolError;
|
||||
extern OSStatus SURelaunchError;
|
||||
extern OSStatus SUInstallationError;
|
||||
extern OSStatus SUDowngradeError;
|
||||
extern OSStatus SUXPCServiceError;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
+1
-5
@@ -6,11 +6,6 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
|
||||
@@ -55,3 +50,4 @@ OSStatus SUMissingInstallerToolError = 4003;
|
||||
OSStatus SURelaunchError = 4004;
|
||||
OSStatus SUInstallationError = 4005;
|
||||
OSStatus SUDowngradeError = 4006;
|
||||
OSStatus SUXPCServiceError = 4007;
|
||||
@@ -249,6 +249,7 @@
|
||||
// There may be a better way to deal with the problem that gestaltSystemVersionMajor
|
||||
// et al. are not defined in 10.3, but this is probably good enough.
|
||||
NSString* verStr = nil;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
||||
SInt32 major, minor, bugfix;
|
||||
OSErr err1 = Gestalt(gestaltSystemVersionMajor, &major);
|
||||
OSErr err2 = Gestalt(gestaltSystemVersionMinor, &minor);
|
||||
@@ -257,6 +258,12 @@
|
||||
{
|
||||
verStr = [NSString stringWithFormat:@"%ld.%ld.%ld", (long)major, (long)minor, (long)bugfix];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
NSString *versionPlistPath = @"/System/Library/CoreServices/SystemVersion.plist";
|
||||
verStr = [[NSDictionary dictionaryWithContentsOfFile:versionPlistPath] objectForKey:@"ProductVersion"];
|
||||
}
|
||||
return verStr;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,11 @@
|
||||
SULog(@"Extracting %@ using '%@'",archivePath,command);
|
||||
|
||||
// Get the file size.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize];
|
||||
#else
|
||||
NSNumber *fs = [[[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:nil] objectForKey:NSFileSize];
|
||||
#endif
|
||||
if (fs == nil) goto reportError;
|
||||
|
||||
// Thank you, Allan Odgaard!
|
||||
|
||||
+102
-54
@@ -48,7 +48,7 @@
|
||||
|
||||
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
|
||||
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
|
||||
static BOOL SUAuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
@@ -69,6 +69,58 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static void SUAuthorizationRelease(AuthorizationRef authorization)
|
||||
{
|
||||
if (NULL == authorization)
|
||||
return;
|
||||
|
||||
AuthorizationFree(authorization, kAuthorizationFlagDefaults);
|
||||
}
|
||||
|
||||
static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
|
||||
{
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while (errAuthorizationDenied == authStat)
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth);
|
||||
}
|
||||
|
||||
if (errAuthorizationSuccess == authStat)
|
||||
{
|
||||
AuthorizationFlags theFlags = kAuthorizationFlagDefaults | kAuthorizationFlagPreAuthorize | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
|
||||
|
||||
AuthorizationItem rightsItems = {kAuthorizationRightExecute, 0, NULL, 0};
|
||||
AuthorizationRights authRights = {1, &rightsItems};
|
||||
|
||||
AuthorizationItem envItems[1];
|
||||
|
||||
envItems[0].name = kAuthorizationEnvironmentPrompt;
|
||||
envItems[0].value = (void *)[SULocalizedString(@"The update requires administrative permissions to be completed.", nil) cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
envItems[0].valueLength = strlen((const char *)envItems[0].value);
|
||||
envItems[0].flags = 0;
|
||||
|
||||
AuthorizationEnvironment environment;
|
||||
environment.count = sizeof(envItems) / sizeof(AuthorizationItem);
|
||||
environment.items = envItems;
|
||||
|
||||
authStat = AuthorizationCopyRights(auth, &authRights, &environment, theFlags, NULL);
|
||||
}
|
||||
|
||||
if (errAuthorizationSuccess != authStat)
|
||||
{
|
||||
SUAuthorizationRelease(auth);
|
||||
auth = NULL;
|
||||
}
|
||||
|
||||
if (NULL != outStatus)
|
||||
{
|
||||
*outStatus = authStat;
|
||||
}
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
@implementation SUPlainInstaller (Internals)
|
||||
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path
|
||||
@@ -176,17 +228,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while (authStat == errAuthorizationDenied) {
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
AuthorizationRef auth = SUAuthorizationCreate(NULL);
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess) {
|
||||
if (NULL != auth)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
@@ -198,23 +243,18 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined. It also needs to be
|
||||
// done before "chown" changes ownership, because the ownership
|
||||
// change will almost certainly make it impossible to change
|
||||
// attributes to release the files from the quarantine.
|
||||
// This needs to be done before "chown" changes ownership,
|
||||
// because the ownership change will fail if the file is quarantined.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine");
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:src waitUntilDone:YES];
|
||||
}
|
||||
|
||||
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
if( !res )
|
||||
SULog( @"chown -R %s %s failed.", uidgid, srcPath );
|
||||
}
|
||||
@@ -223,7 +263,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog( @"rm failed" );
|
||||
}
|
||||
@@ -231,7 +271,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if( res && haveDst ) // Move old exe to tmp path.
|
||||
{
|
||||
const char* mvParams[] = { "-f", dstPath, tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
if( !res )
|
||||
SULog( @"mv 1 failed" );
|
||||
}
|
||||
@@ -239,7 +279,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if( res ) // Move new exe to old exe's path.
|
||||
{
|
||||
const char* mvParams2[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
|
||||
if( !res )
|
||||
SULog( @"mv 2 failed" );
|
||||
}
|
||||
@@ -247,11 +287,26 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
// if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover.
|
||||
// { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one.
|
||||
// const char* rmParams2[] = { "-rf", tmpPath, NULL };
|
||||
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
|
||||
// res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
|
||||
// }
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
SUAuthorizationRelease(auth);
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine after installing");
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
@@ -279,18 +334,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
struct stat dstSB;
|
||||
stat(dstContainerPath, &dstSB);
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
AuthorizationRef auth = SUAuthorizationCreate(NULL);
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
if (NULL != auth)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
@@ -301,7 +347,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
if( !res )
|
||||
SULog(@"Can't set permissions");
|
||||
}
|
||||
@@ -310,7 +356,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
@@ -318,12 +364,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if( res ) // Move!.
|
||||
{
|
||||
const char* mvParams[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
if( !res )
|
||||
SULog(@"Can't move source file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
SUAuthorizationRelease(auth);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
@@ -348,30 +394,21 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
AuthorizationRef auth = SUAuthorizationCreate(NULL);
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
if (NULL != auth)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
if( res ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
SUAuthorizationRelease(auth);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
@@ -392,7 +429,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error
|
||||
{
|
||||
BOOL success = YES;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
if( ![[NSFileManager defaultManager] removeFileAtPath: path handler: nil] )
|
||||
#else
|
||||
if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] )
|
||||
#endif
|
||||
{
|
||||
success = [self _removeFileAtPathWithForcedAuthentication: path error: error];
|
||||
}
|
||||
@@ -520,7 +561,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
// new home in case it's moved across filesystems: if that
|
||||
// happens, the move is actually a copy, and it may result
|
||||
// in the application being quarantined.
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
|
||||
if ([NSThread isMultiThreaded])
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
|
||||
else
|
||||
[self releaseFromQuarantine:dst];
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -581,7 +625,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
NSDictionary* rootAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:root traverseLink:NO];
|
||||
#else
|
||||
NSDictionary* rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:root error:nil];
|
||||
#endif
|
||||
NSString* rootType = [rootAttributes objectForKey:NSFileType];
|
||||
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
|
||||
+22
-13
@@ -59,7 +59,12 @@
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
{
|
||||
[[updateAlert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert willLoadReleaseNotesWithRequest:(NSMutableURLRequest *)request
|
||||
{
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
}
|
||||
|
||||
- (void)updateAlert:(SUUpdateAlert *)alert finishedWithChoice:(SUUpdateAlertChoice)choice
|
||||
@@ -141,7 +146,11 @@
|
||||
if ([statusController maxProgressValue] == 0.0)
|
||||
{
|
||||
NSDictionary * attributes;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
attributes = [[NSFileManager defaultManager] fileAttributesAtPath:downloadPath traverseLink:NO];
|
||||
#else
|
||||
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:nil];
|
||||
#endif
|
||||
[statusController setMaxProgressValue:[[attributes objectForKey:NSFileSize] doubleValue]];
|
||||
}
|
||||
[statusController setProgressValue:[statusController progressValue] + (double)length];
|
||||
@@ -159,17 +168,13 @@
|
||||
|
||||
- (void)unarchiver:(SUUnarchiver *)unarchiver requiresPasswordReturnedViaInvocation:(NSInvocation *)invocation
|
||||
{
|
||||
NSString *password = @"";
|
||||
// some users reported sparkle is asking for password randomly
|
||||
// HACK: do not open prompt and pass empty string as a password
|
||||
//
|
||||
// SUPasswordPrompt *prompt = [[SUPasswordPrompt alloc] initWithHost:host];
|
||||
// NSString *password = nil;
|
||||
// if([prompt run])
|
||||
// {
|
||||
// password = [prompt password];
|
||||
// }
|
||||
// [prompt release];
|
||||
SUPasswordPrompt *prompt = [[SUPasswordPrompt alloc] initWithHost:host];
|
||||
NSString *password = nil;
|
||||
if([prompt run])
|
||||
{
|
||||
password = [prompt password];
|
||||
}
|
||||
[prompt release];
|
||||
[invocation setArgument:&password atIndex:2];
|
||||
[invocation invoke];
|
||||
}
|
||||
@@ -201,7 +206,11 @@
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", [error localizedDescription]];
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil)
|
||||
defaultButton:SULocalizedString(@"Cancel Update", nil)
|
||||
alternateButton:nil
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:[error localizedDescription], nil];
|
||||
[self showModalAlert:alert];
|
||||
[super abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
+5
-3
@@ -9,8 +9,6 @@
|
||||
#ifndef SUUPDATEALERT_H
|
||||
#define SUUPDATEALERT_H
|
||||
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
#import "SUWindowController.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
|
||||
@@ -24,7 +22,7 @@ typedef enum
|
||||
} SUUpdateAlertChoice;
|
||||
|
||||
@class WebView, SUAppcastItem, SUHost;
|
||||
@interface SUUpdateAlert : SUWindowController <WebPolicyDelegate, WebFrameLoadDelegate> {
|
||||
@interface SUUpdateAlert : SUWindowController <NSURLDownloadDelegate> {
|
||||
SUAppcastItem *updateItem;
|
||||
SUHost *host;
|
||||
id delegate;
|
||||
@@ -37,6 +35,9 @@ typedef enum
|
||||
IBOutlet NSButton *laterButton;
|
||||
NSProgressIndicator *releaseNotesSpinner;
|
||||
BOOL webViewFinishedLoading;
|
||||
|
||||
NSURLDownload *releaseNotesDownloader;
|
||||
NSString *downloadedReleaseNotesPath;
|
||||
}
|
||||
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
|
||||
@@ -51,6 +52,7 @@ typedef enum
|
||||
@end
|
||||
|
||||
@interface NSObject (SUUpdateAlertDelegate)
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert willLoadReleaseNotesWithRequest:(NSMutableURLRequest *)request;
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate: (BOOL*)shouldAllowAutoUpdate;
|
||||
@end
|
||||
|
||||
+43
-13
@@ -15,8 +15,9 @@
|
||||
#import "SUHost.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
#import "SUXPCURLDownload.h"
|
||||
|
||||
@interface WebView (SUTenFiveProperty)
|
||||
|
||||
@@ -50,6 +51,9 @@
|
||||
{
|
||||
[updateItem release];
|
||||
[host release];
|
||||
[releaseNotesDownloader release];
|
||||
[downloadedReleaseNotesPath release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -115,7 +119,23 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem releaseNotesURL]
|
||||
cachePolicy:NSURLRequestReloadIgnoringCacheData
|
||||
timeoutInterval:30];
|
||||
if ([delegate respondsToSelector:@selector(updateAlert:willLoadReleaseNotesWithRequest:)])
|
||||
{
|
||||
[delegate updateAlert:self willLoadReleaseNotesWithRequest:request];
|
||||
}
|
||||
|
||||
if ([SUUpdater shouldUseXPCDownloader])
|
||||
{
|
||||
[releaseNotesDownloader release];
|
||||
releaseNotesDownloader = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadRequest:request];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -124,6 +144,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)aDownload didCreateDestination:(NSString *)path
|
||||
{
|
||||
[downloadedReleaseNotesPath release];
|
||||
downloadedReleaseNotesPath = [path copy];
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)aDownload
|
||||
{
|
||||
NSString *s = [NSString stringWithContentsOfFile:downloadedReleaseNotesPath encoding:NSUTF8StringEncoding error:nil];
|
||||
[[releaseNotesView mainFrame] loadHTMLString:s baseURL:nil];
|
||||
}
|
||||
|
||||
- (BOOL)showsReleaseNotes
|
||||
{
|
||||
NSNumber *shouldShowReleaseNotes = [host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
|
||||
@@ -140,17 +172,15 @@
|
||||
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
// BOOL allowAutoUpdates = YES; // Defaults to YES.
|
||||
// if( [host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] )
|
||||
// allowAutoUpdates = [host boolForInfoDictionaryKey: SUAllowsAutomaticUpdatesKey];
|
||||
//
|
||||
// // UK 2007-08-31: Give delegate a chance to modify this choice:
|
||||
// if( delegate && [delegate respondsToSelector: @selector(updateAlert:shouldAllowAutoUpdate:)] )
|
||||
// [delegate updateAlert: self shouldAllowAutoUpdate: &allowAutoUpdates];
|
||||
//
|
||||
// return allowAutoUpdates;
|
||||
|
||||
return NO; // HACK: darwin
|
||||
BOOL allowAutoUpdates = YES; // Defaults to YES.
|
||||
if( [host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] )
|
||||
allowAutoUpdates = [host boolForInfoDictionaryKey: SUAllowsAutomaticUpdatesKey];
|
||||
|
||||
// UK 2007-08-31: Give delegate a chance to modify this choice:
|
||||
if( delegate && [delegate respondsToSelector: @selector(updateAlert:shouldAllowAutoUpdate:)] )
|
||||
[delegate updateAlert: self shouldAllowAutoUpdate: &allowAutoUpdates];
|
||||
|
||||
return allowAutoUpdates;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
|
||||
@@ -27,7 +27,6 @@ extern NSString * const SUUpdateDriverFinishedNotification;
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
- (void)abortUpdate;
|
||||
- (BOOL)finished;
|
||||
- (void)setFinished:(BOOL) finished;
|
||||
- (SUHost*)host;
|
||||
- (void)setHost:(SUHost*)newHost;
|
||||
|
||||
|
||||
@@ -35,10 +35,6 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
|
||||
- (BOOL)finished { return finished; }
|
||||
|
||||
- (void)setFinished:(BOOL) _finished {
|
||||
finished = _finished;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[host release];
|
||||
|
||||
+16
-3
@@ -27,7 +27,7 @@
|
||||
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
- (id)initForBundle:(NSBundle *)bundle;
|
||||
|
||||
- (NSBundle *)hostBundle;
|
||||
|
||||
@@ -73,8 +73,6 @@
|
||||
|
||||
- (BOOL)updateInProgress;
|
||||
|
||||
-(void) checkForUpdatesInBgReachabilityCheckWithDriver: (SUUpdateDriver*)inDriver;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -142,6 +140,21 @@
|
||||
|
||||
@end
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Delegate: DevMate Interaction
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// NOTE!!! Implemented delegate methods have higher priority than values saved in user preferences
|
||||
|
||||
#define SUUpdaterChecksForBetaUpdatesPrefKey @"SUUpdaterChecksForBetaUpdates" // bool value
|
||||
#define SUUpdaterIsInTestModePrefKey @"SUUpdaterIsInTestMode" // bool value
|
||||
|
||||
@interface NSObject (SUUpdaterDelegate_DevMateInteraction)
|
||||
|
||||
- (BOOL)updaterShouldCheckForBetaUpdates:(SUUpdater *)updater;
|
||||
- (BOOL)isUpdaterInTestMode:(SUUpdater *)updater;
|
||||
|
||||
@end
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constants:
|
||||
|
||||
+64
-17
@@ -213,8 +213,8 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
|
||||
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
|
||||
if (updateCheckInterval < 5 /*SU_MIN_CHECK_INTERVAL*/)
|
||||
updateCheckInterval = 5 /*SU_MIN_CHECK_INTERVAL*/;
|
||||
if (intervalSinceCheck < updateCheckInterval)
|
||||
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
@@ -239,7 +239,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SCNetworkConnectionFlags flags = 0;
|
||||
BOOL isNetworkReachable = NO;
|
||||
BOOL isNetworkReachable = YES;
|
||||
|
||||
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
|
||||
NSMutableDictionary* theDict = [NSMutableDictionary dictionary];
|
||||
@@ -250,21 +250,20 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
Boolean reachabilityResult = NO;
|
||||
// If the feed's using a file:// URL, we won't be able to use reachability.
|
||||
if (reachability != NULL) {
|
||||
reachabilityResult = YES;
|
||||
SCNetworkReachabilityGetFlags(reachability, &flags);
|
||||
CFRelease(reachability);
|
||||
}
|
||||
|
||||
if( reachabilityResult )
|
||||
{
|
||||
BOOL needsConnection = ((flags & kSCNetworkFlagsConnectionRequired) != 0);
|
||||
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
|
||||
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;
|
||||
BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress;
|
||||
|
||||
// NSLog(@"reachable = %s, needsConnection = %s, local = %s", (reachable?"YES":"NO"), (needsConnection?"YES":"NO"), (local?"YES":"NO"));
|
||||
//NSLog(@"reachable = %s, automatic = %s, local = %s", (reachable?"YES":"NO"), (automatic?"YES":"NO"), (local?"YES":"NO"));
|
||||
|
||||
if (local || (reachable && !needsConnection))
|
||||
isNetworkReachable = YES;
|
||||
if( !(reachable || automatic || local) )
|
||||
isNetworkReachable = NO;
|
||||
}
|
||||
|
||||
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
|
||||
@@ -407,13 +406,12 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
- (BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
return NO; // HACK: darwin
|
||||
// // If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
|
||||
// if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO)
|
||||
// return NO;
|
||||
//
|
||||
// // Otherwise, automatically downloading updates is allowed. Does the user want it?
|
||||
// return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
|
||||
if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO)
|
||||
return NO;
|
||||
|
||||
// Otherwise, automatically downloading updates is allowed. Does the user want it?
|
||||
return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
@@ -481,7 +479,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
|
||||
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
|
||||
|
||||
NSArray *parameters = [NSArray array];
|
||||
NSArray *parameters = [self devmateFeedParameters];
|
||||
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
|
||||
if (sendingSystemProfile)
|
||||
@@ -553,7 +551,56 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
return driver && ([driver finished] == NO);
|
||||
}
|
||||
|
||||
- delegate { return delegate; }
|
||||
- (id)delegate { return delegate; }
|
||||
- (NSBundle *)hostBundle { return [host bundle]; }
|
||||
|
||||
+ (BOOL)shouldUseXPCDownloader
|
||||
{
|
||||
if ([SUCodeSigningVerifier hostAppAllowsNetworkOutgoingConnections])
|
||||
return NO;
|
||||
|
||||
NSString *xpcServicePrefixPath = [[[SUUpdater sharedUpdater] hostBundle] bundlePath];
|
||||
NSString *xpcServiceSuffixPath = @"Contents/XPCServices/com.andymatuschak.Sparkle.download-service.xpc";
|
||||
return [[NSFileManager defaultManager] fileExistsAtPath:[xpcServicePrefixPath stringByAppendingPathComponent:xpcServiceSuffixPath]];
|
||||
}
|
||||
|
||||
+ (BOOL)shouldUseXPCInstaller
|
||||
{
|
||||
if (![SUCodeSigningVerifier hostApplicationIsSandboxed])
|
||||
return NO;
|
||||
|
||||
NSString *xpcServicePrefixPath = [[[SUUpdater sharedUpdater] hostBundle] bundlePath];
|
||||
NSString *xpcServiceSuffixPath = @"Contents/XPCServices/com.andymatuschak.Sparkle.install-service.xpc";
|
||||
return [[NSFileManager defaultManager] fileExistsAtPath:[xpcServicePrefixPath stringByAppendingPathComponent:xpcServiceSuffixPath]];
|
||||
}
|
||||
|
||||
#pragma mark - DevMate Interaction
|
||||
|
||||
- (NSArray *)devmateFeedParameters
|
||||
{
|
||||
NSMutableArray *parameters = [NSMutableArray array];
|
||||
|
||||
BOOL isInTestMode = [host boolForUserDefaultsKey:SUUpdaterIsInTestModePrefKey];
|
||||
if ([delegate respondsToSelector:@selector(isUpdaterInTestMode:)])
|
||||
{
|
||||
isInTestMode = [delegate isUpdaterInTestMode:self];
|
||||
}
|
||||
if (isInTestMode)
|
||||
{
|
||||
[parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"test", @"key", @"1", @"value", nil]];
|
||||
}
|
||||
|
||||
BOOL shouldCheckBeta = [host boolForUserDefaultsKey:SUUpdaterChecksForBetaUpdatesPrefKey];
|
||||
if ([delegate respondsToSelector:@selector(updaterShouldCheckForBetaUpdates:)])
|
||||
{
|
||||
shouldCheckBeta = [delegate updaterShouldCheckForBetaUpdates:self];
|
||||
}
|
||||
if (shouldCheckBeta)
|
||||
{
|
||||
[parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"beta", @"key", @"1", @"value", nil]];
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,4 +12,7 @@
|
||||
|
||||
- (BOOL)mayUpdateAndRestart;
|
||||
|
||||
+ (BOOL)shouldUseXPCDownloader;
|
||||
+ (BOOL)shouldUseXPCInstaller;
|
||||
|
||||
@end
|
||||
@@ -6,11 +6,9 @@
|
||||
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUVERSIONDISPLAYPROTOCOL_H
|
||||
#define SUVERSIONDISPLAYPROTOCOL_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
/*!
|
||||
@protocol
|
||||
@abstract Implement this protocol to apply special formatting to the two
|
||||
@@ -27,5 +25,3 @@
|
||||
-(void) formatVersion: (NSString**)inOutVersionA andVersion: (NSString**)inOutVersionB;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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/>
|
||||
</dict>
|
||||
</plist>
|
||||
+11
-1
@@ -18,9 +18,19 @@
|
||||
#define NSAppKitVersionNumber10_6 1038
|
||||
#endif
|
||||
|
||||
#ifndef NSAppKitVersionNumber10_7
|
||||
#define NSAppKitVersionNumber10_7 1138
|
||||
#endif
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_7
|
||||
#define MAC_OS_X_VERSION_10_7 1070
|
||||
#endif
|
||||
|
||||
#define SPARKLE_IS_COMPATIBLE_WITH_DEVMATE (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
|
||||
|
||||
#ifdef __OBJC__
|
||||
|
||||
#define SPARKLE_BUNDLE [NSBundle bundleForClass:[SUUpdater class]]
|
||||
#define SPARKLE_BUNDLE [NSBundle bundleWithIdentifier:@"org.andymatuschak.Sparkle"]
|
||||
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
|
||||
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0450"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "61B5F90109C4CEE200B25A18"
|
||||
BuildableName = "Sparkle Test App.app"
|
||||
BlueprintName = "Sparkle Test App"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "5D06E8CF0FD68C7C005AE3F6"
|
||||
BuildableName = "BinaryDelta"
|
||||
BlueprintName = "BinaryDelta"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "612279D80DB5470200AB99EA"
|
||||
BuildableName = "Sparkle Unit Tests.octest"
|
||||
BlueprintName = "Sparkle Unit Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "61B5F90109C4CEE200B25A18"
|
||||
BuildableName = "Sparkle Test App.app"
|
||||
BlueprintName = "Sparkle Test App"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "YES"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "61B5F90109C4CEE200B25A18"
|
||||
BuildableName = "Sparkle Test App.app"
|
||||
BlueprintName = "Sparkle Test App"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
ignoresPersistentStateOnLaunch = "YES"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Deployment"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -8,12 +8,12 @@
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Sparkle</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Sparkle Test App</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.andymatuschak.SparkleTestApp</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
@@ -24,10 +24,10 @@
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>SUEnableSystemProfiling</key>
|
||||
<true/>
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://www.andymatuschak.org/files/sparkletestcast.xml</string>
|
||||
<key>SUEnableSystemProfiling</key>
|
||||
<true/>
|
||||
<key>SUPublicDSAKeyFile</key>
|
||||
<string>dsa_pub.pem</string>
|
||||
</dict>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
|
||||
Binary file not shown.
@@ -9,7 +9,7 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Sparkle</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<string>org.andymatuschak.sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
|
||||
@@ -128,7 +128,11 @@
|
||||
if( ![SUPlainInstaller _removeFileAtPath: [SUInstaller updateFolder] error: &theError] )
|
||||
SULog( @"Couldn't remove update folder: %@.", theError );
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
[[NSFileManager defaultManager] removeFileAtPath: selfPath handler: nil];
|
||||
#else
|
||||
[[NSFileManager defaultManager] removeItemAtPath: selfPath error: NULL];
|
||||
#endif
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
+1025
-189
File diff suppressed because it is too large.
Load diff
Binary file not shown.
+1045
-189
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user