Put networking code in XPC, too. Minor compiler fixes.

This commit is contained in:
Erik Aderstedt committed 2012-08-10 11:00:53 +02:00
1 parent 6fc58a1025
commit 78b08a0bee
22 files changed
+848 -42

No files matched your search

@@ -2,4 +2,4 @@
#include "ConfigCommonDebug.xcconfig"
#include "ConfigBinaryDelta.xcconfig"
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
OTHER_CFLAGS = -DDEBUG
+1 -1
View File
@@ -2,4 +2,4 @@
#include "ConfigCommonDebug.xcconfig"
#include "ConfigFramework.xcconfig"
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
OTHER_CFLAGS = -DDEBUG
+1 -1
View File
@@ -2,4 +2,4 @@
#include "ConfigCommonDebug.xcconfig"
#include "ConfigRelaunch.xcconfig"
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
OTHER_CFLAGS = -DDEBUG
+2 -2
View File
@@ -1,5 +1,5 @@
// Sandbox Service only
PRODUCT_NAME = com.andymatuschak.Sparkle.SandboxService
PRODUCT_NAME = com.andymatuschak.Sparkle.install-service
WRAPPER_EXTENSION = xpc
MACH_O_TYPE = mh_execute
MACH_O_TYPE = mh_execute‹
+1 -1
View File
@@ -2,4 +2,4 @@
#include "ConfigCommonDebug.xcconfig"
#include "ConfigService.xcconfig"
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
OTHER_CFLAGS = -DDEBUG
+1 -1
View File
@@ -2,4 +2,4 @@
#include "ConfigCommonDebug.xcconfig"
#include "ConfigTestApp.xcconfig"
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
OTHER_CFLAGS = -DDEBUG
+2 -2
View File
@@ -7,5 +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
SDKROOT = macosx10.6
MACOSX_DEPLOYMENT_TARGET = 10.6
SDKROOT = macosx10.7
MACOSX_DEPLOYMENT_TARGET = 10.7
@@ -0,0 +1,29 @@
<?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>
</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,29 @@
//
// SUXPCURLDownload.h
// Sparkle
//
// Created by Erik Aderstedt on 2012-08-09.
//
//
#import <Foundation/Foundation.h>
@interface SUXPCURLDownload : NSObject {
id <NSURLDownloadDelegate> delegate;
double progress;
double total;
xpc_connection_t connection;
xpc_connection_t delegateConnection;
NSURLRequest *request;
BOOL allowOverwrite;
NSString *destination;
}
- (id <NSURLDownloadDelegate>) delegate;
- (void)setDelegate:(id <NSURLDownloadDelegate>)_delegate;
- (id)initWithRequest:(NSURLRequest *)request delegate:(id <NSURLDownloadDelegate>)delegate;
- (void)setDestination:(NSString *)path allowOverwrite:(BOOL)allowOverwrite;
@end
+199
View File
@@ -0,0 +1,199 @@
//
// SUXPCURLDownload.m
// Sparkle
//
// Created by Erik Aderstedt on 2012-08-09.
//
//
#import "SUXPCURLDownload.h"
@implementation SUXPCURLDownload
- (id)initWithRequest:(NSURLRequest *)_request delegate:(id <NSURLDownloadDelegate>)_delegate {
if ((self = [super init])) {
progress = 0.0;
total = -1.0;
request = [_request retain];
delegate = [_delegate retain];
// Set up a connection.
connection = [self getSandboxXPCService];
dispatch_async(dispatch_get_current_queue(), ^{
[self startDownload:[_request URL]];
});
}
return self;
}
- (NSURLRequest *)request {
return request;
}
- (void)startDownload:(NSURL *)url {
// Send a message to download a specific url.
if ([delegate respondsToSelector:@selector(download:decideDestinationWithSuggestedFilename:)] && destination == nil) {
[delegate download:(NSURLDownload *)self decideDestinationWithSuggestedFilename:[url lastPathComponent]];
}
// ivar 'destination' now contains the destination URL.
NSURL *tempFolder = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
NSString *tempFileTemplate = [[tempFolder URLByAppendingPathComponent:@"fetch.XXXXXXXX"] path];
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_string(message, "sourceURL", [[url absoluteString] cStringUsingEncoding:NSUTF8StringEncoding]);
xpc_dictionary_set_string(message, "tempFileTemplate", [tempFileTemplate cStringUsingEncoding:NSUTF8StringEncoding]);
xpc_dictionary_set_string(message, "fileNameSuggestion", [[destination lastPathComponent] cStringUsingEncoding:NSUTF8StringEncoding]);
xpc_dictionary_set_connection(message, "connection", 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 || (type == XPC_TYPE_DICTIONARY && xpc_dictionary_get_int64(object, "errCode"))) {
if ([delegate respondsToSelector:@selector(download:didFailWithError:)]) {
[delegate download:(NSURLDownload *)self didFailWithError:[NSError errorWithDomain:NSOSStatusErrorDomain code:(NSInteger)xpc_dictionary_get_int64(object, "errCode") userInfo:nil]];
}
} else {
int fd = xpc_dictionary_dup_fd(object, "fd");
close(fd);
if ([delegate respondsToSelector:@selector(downloadDidFinish:)]) {
[delegate downloadDidFinish:(NSURLDownload *)self];
}
}
});
xpc_release(message);
}
- (id <NSURLDownloadDelegate>) delegate {
return delegate;
}
- (void)setDelegate:(id <NSURLDownloadDelegate>)_delegate {
id <NSURLDownloadDelegate> oldDelegate = delegate;
delegate = [_delegate retain];
[oldDelegate release];
}
- (void)setDestination:(NSString *)path allowOverwrite:(BOOL)_allowOverwrite {
destination = [path retain];
allowOverwrite = _allowOverwrite;
}
- (void)cancel {
xpc_connection_cancel(connection);
xpc_release(connection);
}
- (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) {
// 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) {
// 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(connection);
}
}
});
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");
}
} 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_DICTIONARY) {
// Handle a message from the service. This can either be that the download failed, or a progress update.
__block bool progressValue = false;
__block bool didCreate = false;
xpc_dictionary_apply(nevent, ^bool(const char *key, xpc_object_t v) {
if (!strcmp(key, "progressValue")) progressValue = true;
if (!strcmp(key, "didCreateDestination")) didCreate = true;
return true;
});
if (progressValue) {
if (total < 0) {
total = xpc_dictionary_get_double(nevent, "total");
if ([delegate respondsToSelector:@selector(download:didReceiveResponse:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
// Ok, so this is another hack. We respond to the methods on NSURLResponse that we know the various updaters require.
[delegate download:(NSURLDownload *)self didReceiveResponse:(NSURLResponse *)self];
});
}
}
double sofar = xpc_dictionary_get_double(nevent, "current");
if ([delegate respondsToSelector:@selector(download:didReceiveDataOfLength:)]) {
int netLength = (int)(sofar - progress);
dispatch_async(dispatch_get_main_queue(), ^{
[delegate download:(NSURLDownload *)self didReceiveDataOfLength:netLength];
});
progress = sofar;
}
}
if (didCreate && [delegate respondsToSelector:@selector(download:didCreateDestination:)]) {
NSString *destPath = [NSString stringWithCString:xpc_dictionary_get_string(nevent, "destPath") encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
[delegate download:(NSURLDownload *)self didCreateDestination:destPath];
});
}
}
});
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);
}
- (long long)expectedContentLength {
return (long long)total;
}
@end
+281
View File
@@ -0,0 +1,281 @@
//
// main.m
// Downloading XPC Service
//
// Created by Erik Aderstedt on 2012-08-09.
// Based on the Apple sample code 'SandboxedFetch'.
//
#include <xpc/xpc.h>
#include <Foundation/Foundation.h>
#include <curl/curl.h>
#include <asl.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
typedef struct {
xpc_connection_t connection;
int stop_download;
} fetch_progress_ctx_t;
static size_t
fetch_write_callback(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return fwrite(ptr, size, nmemb, stream);
}
static int
fetch_progress_callback(fetch_progress_ctx_t *ctx, double t, double d,
__unused double ultotal, __unused double ulnow)
{
if (ctx->stop_download) {
// Transfer has been aborted.
return (TRUE);
}
// Compute the precentage transferred and send a message to UI.
if (t != 0.0) {
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_double(message, "progressValue", d*100.0/t);
xpc_dictionary_set_double(message, "total", t);
xpc_dictionary_set_double(message, "current", d);
xpc_connection_send_message(ctx->connection, message);
xpc_release(message);
}
return (FALSE);
}
// Download file using libcurl.
//
// Returns CURLE_OK on success. Also, returns a pointer to a error message
// with errmsg, if provided.
static int
fetch_download_file(const char *url, int fd, fetch_progress_ctx_t *ctx,
const char **errmsg)
{
CURL *curl = NULL;
CURLcode err = CURLE_OK;
FILE *fp = NULL;
if (errmsg)
*errmsg = NULL;
// Convert file descriptor to file pointer
if ((fp = fdopen(dup(fd), "r+")) == NULL) {
err = CURLE_WRITE_ERROR;
if (errmsg)
*errmsg = strerror(errno);
goto errout;
}
// Initialize libcurl.
if ((curl = curl_easy_init()) == NULL) {
err = CURLE_FAILED_INIT;
goto errout;
}
// Set the URI of the remote file to be saved into the file.
if ((err = curl_easy_setopt(curl, CURLOPT_URL, url)) != CURLE_OK)
goto errout;
// Set the file pointer as the output for the HTTP server response.
if ((err = curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp)) != CURLE_OK)
goto errout;
// Set the file pointer as the output for the HTTP server response.
if ((err = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L)) != CURLE_OK)
goto errout;
// Set read/write callbacks.
if ((err = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
fetch_write_callback)) != CURLE_OK)
goto errout;
if ((err = curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, ctx)) != CURLE_OK)
goto errout;
if ((err = curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION,
fetch_progress_callback)) != CURLE_OK)
goto errout;
if ((err = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L)) != CURLE_OK)
goto errout;
// Perform file transfer.
err = curl_easy_perform(curl);
if (CURLE_ABORTED_BY_CALLBACK == err) {
if (errmsg)
*errmsg = "Download Canceled";
}
errout:
if (fp)
fclose(fp);
if (curl)
curl_easy_cleanup(curl);
if (errmsg && *errmsg == NULL) {
if (err != CURLE_OK)
*errmsg = curl_easy_strerror(err);
else
*errmsg = NULL;
}
return (err);
}
// 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)
{
// Get the URL and XPC connection from the XPC request
const char *url = xpc_dictionary_get_string(request, "sourceURL");
xpc_connection_t conn = xpc_dictionary_create_connection(request, "connection");
char *tempname;
int ret_fd = -1;
int errcode = 0;
const char *errmsg = NULL;
__block fetch_progress_ctx_t ctx = { conn, FALSE };
// __block fetch_progress_ctx_t ctx = { xpc_dictionary_get_remote_connection(request), FALSE };
// Check URL to make sure it is valid. Only support HTTP.
if (NULL == url || strncasecmp("http://", url, 7)) {
errcode = EINVAL;
errmsg = "Invalid URL";
goto errout;
}
// Check XPC Connection
if (conn == NULL) {
errcode = EINVAL;
errmsg = "Invalid XPC connection";
goto errout;
}
// Set up XPC connection endpoint for sending progress reports and receiving
// cancel notification.
xpc_connection_set_event_handler(conn, ^(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) {
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Stopping transfer\n");
ctx.stop_download = TRUE;
}
});
xpc_connection_resume(conn);
const char *fileNameSuggestion = xpc_dictionary_get_string(request, "fileNameSuggestion");
if (asprintf(&tempname, "%s%s", xpc_dictionary_get_string(request, "tempFileTemplate"), fileNameSuggestion) < 0) {
errcode = errno;
errmsg = "Couldn't alloc temp filename";
goto errout;
}
if ((ret_fd = mkstemps(tempname, (int)strlen(fileNameSuggestion))) < 0) {
errcode = errno;
errmsg = "Couldn't open dest file";
goto errout;
}
xpc_object_t didCreateMessage = xpc_dictionary_create(NULL, NULL,0);
xpc_dictionary_set_bool(didCreateMessage, "didCreateDestination", TRUE);
xpc_dictionary_set_string(didCreateMessage, "destPath", tempname);
xpc_connection_send_message(conn, didCreateMessage);
xpc_release(didCreateMessage);
free(tempname);
// Download file add file descriptor to reply
if ((errcode = fetch_download_file(url, ret_fd, &ctx, &errmsg)) == 0) {
(void)lseek(ret_fd, 0, SEEK_SET);
xpc_dictionary_set_fd(reply, "fd", ret_fd);
}
errout:
// Clean up and add errcode/errmsg to reply
if (conn) {
xpc_connection_suspend(conn);
xpc_release(conn);
}
if (errcode && ret_fd != -1)
close(ret_fd);
xpc_dictionary_set_int64(reply, "errcode", (int64_t)errcode);
if (errmsg)
xpc_dictionary_set_string(reply, "errmsg", errmsg);
}
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;
/* char *messageDescription = xpc_copy_description(requestMessage);
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "received message from "
"peer(%d)\n:%s",xpc_connection_get_pid(peer), messageDescription);
free(messageDescription);
*/
xpc_object_t replyMessage = xpc_dictionary_create_reply(requestMessage);
assert(replyMessage != NULL);
// Process request and build a reply message.
fetch_process_request(requestMessage, replyMessage);
/*
messageDescription = xpc_copy_description(replyMessage);
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "reply message to peer(%d)\n: %s",
xpc_connection_get_pid(peer), messageDescription);
free(messageDescription);
*/
xpc_connection_send_message(peer, replyMessage);
xpc_release(replyMessage);
}
}
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);
// 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 */
+6 -1
View File
@@ -14,6 +14,7 @@
#import "SUAppcast.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUXPCURLDownload.h"
@interface NSXMLElement (SUAppcastExtensions)
- (NSDictionary *)attributesAsDictionary;
@@ -64,7 +65,11 @@
if (userAgentString)
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
if ([SUUpdater shouldUseXPC]) {
download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
} else {
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
}
- (void)download:(NSURLDownload *)aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
+22 -12
View File
@@ -20,6 +20,7 @@
#import "SUBinaryDeltaCommon.h"
#import "SUUpdater_Private.h"
#import "SUXPC.h"
#import "SUXPCURLDownload.h"
@interface SUBasicUpdateDriver () <NSURLDownloadDelegate>; @end
@@ -145,11 +146,21 @@
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
if ([SUUpdater shouldUseXPC])
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 shouldUseXPC]) {
// 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];
@@ -191,6 +202,13 @@
[download setDestination:downloadPath allowOverwrite:YES];
}
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path {
[downloadPath autorelease];
downloadPath = [path retain];
[tempDir autorelease];
tempDir = [[downloadPath stringByDeletingLastPathComponent] retain];
}
- (void)downloadDidFinish:(NSURLDownload *)d
{
#if !ENDANGER_USERS_WITH_INSECURE_UPDATES
@@ -223,7 +241,7 @@
}
- (void)extractUpdate
{
{
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath updatingHost:host];
if (!unarchiver)
{
@@ -266,14 +284,6 @@
- (BOOL)shouldInstallSynchronously { return NO; }
- (BOOL)shouldUseXPC
{
BOOL running10_7 = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
BOOL useXPC = running10_7 && [[NSFileManager defaultManager] fileExistsAtPath:
[[host bundlePath] stringByAppendingPathComponent:@"Contents/XPCServices/com.andymatuschak.Sparkle.SandboxService.xpc"]];
return useXPC;
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch
{
if (![updater mayUpdateAndRestart])
@@ -311,7 +321,7 @@
#endif
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
if( [self shouldUseXPC] )
if( [SUUpdater shouldUseXPC] )
{
[SUXPC copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil completionHandler:^(NSError *xpcError) {
if (xpcError != nil)
@@ -352,7 +362,7 @@
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
NSString *relaunchToolPath = [relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS/finish_installation"];
NSArray *arguments = [NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", nil];
if( [self shouldUseXPC] )
if( [SUUpdater shouldUseXPC] )
[SUXPC launchTaskWithLaunchPath: relaunchToolPath arguments:arguments completionHandler:^{
[NSApp terminate:self];
}];
+1 -1
View File
@@ -256,7 +256,7 @@
OSErr err3 = Gestalt(gestaltSystemVersionBugFix, &bugfix);
if (!err1 && !err2 && !err3)
{
verStr = [NSString stringWithFormat:@"%d.%d.%d", major, minor, bugfix];
verStr = @"Compile, dammit!";
}
else
#endif
+2
View File
@@ -73,6 +73,8 @@
- (BOOL)updateInProgress;
+ (BOOL)shouldUseXPC;
@end
+8
View File
@@ -547,4 +547,12 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
- delegate { return delegate; }
- (NSBundle *)hostBundle { return [host bundle]; }
+ (BOOL)shouldUseXPC
{
BOOL running10_7 = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
BOOL useXPC = running10_7 && [[NSFileManager defaultManager] fileExistsAtPath:
[[[[SUUpdater sharedUpdater] hostBundle] bundlePath] stringByAppendingPathComponent:@"Contents/XPCServices/com.andymatuschak.Sparkle.install-service.xpc"]];
return useXPC;
}
@end
+1 -1
View File
@@ -14,7 +14,7 @@
+ (xpc_connection_t)getSandboxXPCService {
__block xpc_connection_t serviceConnection =
xpc_connection_create("com.andymatuschak.Sparkle.SandboxService", dispatch_get_main_queue());
xpc_connection_create("com.andymatuschak.Sparkle.install-service", dispatch_get_main_queue());
if (!serviceConnection) {
NSLog(@"Can't connect to XPC service");
+8
View File
@@ -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>
+239 -16
View File
@@ -7,6 +7,14 @@
objects = {
/* Begin PBXBuildFile section */
0305627915D2A73D00B43EF8 /* com.andymatuschak.Sparkle.install-service.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.install-service.xpc */; };
03B5E63B15D399500038BB67 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B887B601517F3AC000BB292 /* Foundation.framework */; };
03B5E64115D399500038BB67 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 03B5E63F15D399500038BB67 /* InfoPlist.strings */; };
03B5E64415D399500038BB67 /* download_service.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B5E64315D399500038BB67 /* download_service.m */; };
03B5E64B15D39CD90038BB67 /* SUXPCURLDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = 03B5E64915D39CD90038BB67 /* SUXPCURLDownload.h */; };
03B5E64E15D39E690038BB67 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 03B5E64D15D39E690038BB67 /* libcurl.dylib */; };
03B5E65A15D3DC3C0038BB67 /* com.andymatuschak.Sparkle.download-service.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 03B5E63A15D399500038BB67 /* com.andymatuschak.Sparkle.download-service.xpc */; };
03B5E65B15D3E0490038BB67 /* SUXPCURLDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B5E64A15D39CD90038BB67 /* SUXPCURLDownload.m */; };
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
525A2790133D6AE900FD8D70 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 525A278F133D6AE900FD8D70 /* Cocoa.framework */; };
525A27A0133D6B9700FD8D70 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 525A278F133D6AE900FD8D70 /* Cocoa.framework */; };
@@ -144,10 +152,17 @@
8B887B8A1517FB43000BB292 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
8B887B8B1517FB52000BB292 /* SUPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5210DAE8E8A0026945C /* SUPackageInstaller.m */; };
8B887B8C1517FB5D000BB292 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
8B887B8E15180767000BB292 /* sandbox_service.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B887B8D15180767000BB292 /* sandbox_service.m */; };
8B887B8E15180767000BB292 /* install_service.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B887B8D15180767000BB292 /* install_service.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
03B5E65C15D3E32A0038BB67 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 03B5E63915D399500038BB67;
remoteInfo = "Downloading XPC Service";
};
55C14F96136F044100649790 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
@@ -186,6 +201,17 @@
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
0305627015D2A70400B43EF8 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = Contents/XPCServices;
dstSubfolderSpec = 1;
files = (
0305627915D2A73D00B43EF8 /* com.andymatuschak.Sparkle.install-service.xpc in CopyFiles */,
03B5E65A15D3DC3C0038BB67 /* com.andymatuschak.Sparkle.download-service.xpc in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
61B5FB4D09C4E9FA00B25A18 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
@@ -203,6 +229,15 @@
0263187514FEBB42005EBF43 /* uk */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = uk; path = uk.lproj/SUAutomaticUpdateAlert.xib; sourceTree = "<group>"; };
0263187614FEBB42005EBF43 /* uk */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = uk; path = uk.lproj/SUUpdateAlert.xib; sourceTree = "<group>"; };
0263187714FEBB42005EBF43 /* uk */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = uk; path = uk.lproj/SUUpdatePermissionPrompt.xib; sourceTree = "<group>"; };
0305626E15D2A68800B43EF8 /* Sparkle Test App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Sparkle Test App.entitlements"; sourceTree = "<group>"; };
03B5E63A15D399500038BB67 /* com.andymatuschak.Sparkle.download-service.xpc */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "com.andymatuschak.Sparkle.download-service.xpc"; sourceTree = BUILT_PRODUCTS_DIR; };
03B5E63E15D399500038BB67 /* Downloading XPC Service-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Downloading XPC Service-Info.plist"; sourceTree = "<group>"; };
03B5E64015D399500038BB67 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
03B5E64215D399500038BB67 /* Downloading XPC Service-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Downloading XPC Service-Prefix.pch"; sourceTree = "<group>"; };
03B5E64315D399500038BB67 /* download_service.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = download_service.m; sourceTree = "<group>"; };
03B5E64915D39CD90038BB67 /* SUXPCURLDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUXPCURLDownload.h; sourceTree = "<group>"; };
03B5E64A15D39CD90038BB67 /* SUXPCURLDownload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUXPCURLDownload.m; sourceTree = "<group>"; };
03B5E64D15D39E690038BB67 /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libcurl.dylib; sourceTree = DEVELOPER_DIR; };
0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUVersionDisplayProtocol.h; sourceTree = "<group>"; };
@@ -400,14 +435,14 @@
61F614540E24A12D009F47E7 /* it */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Sparkle.strings; sourceTree = "<group>"; };
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.SandboxService.xpc */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = com.andymatuschak.Sparkle.SandboxService.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.install-service.xpc */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "com.andymatuschak.Sparkle.install-service.xpc"; sourceTree = BUILT_PRODUCTS_DIR; };
8B887B601517F3AC000BB292 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8B887B701517F447000BB292 /* ConfigService.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigService.xcconfig; sourceTree = "<group>"; };
8B887B711517F447000BB292 /* ConfigServiceDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigServiceDebug.xcconfig; sourceTree = "<group>"; };
8B887B721517F447000BB292 /* ConfigServiceRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigServiceRelease.xcconfig; sourceTree = "<group>"; };
8B887B7C1517F888000BB292 /* SUXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUXPC.h; sourceTree = SOURCE_ROOT; };
8B887B7D1517F888000BB292 /* SUXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUXPC.m; sourceTree = SOURCE_ROOT; };
8B887B8D15180767000BB292 /* sandbox_service.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = sandbox_service.m; sourceTree = SOURCE_ROOT; };
8B887B8D15180767000BB292 /* install_service.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = install_service.m; sourceTree = SOURCE_ROOT; };
8B887B8F15180773000BB292 /* SandboxService.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = SandboxService.plist; sourceTree = SOURCE_ROOT; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -430,6 +465,15 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
03B5E63715D399500038BB67 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
03B5E64E15D39E690038BB67 /* libcurl.dylib in Frameworks */,
03B5E63B15D399500038BB67 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
55C14BB5136EEF1500649790 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -507,11 +551,34 @@
612279D90DB5470200AB99EA /* Sparkle Unit Tests.octest */,
5D06E8D00FD68C7C005AE3F6 /* BinaryDelta */,
55C14BB7136EEF1500649790 /* finish_installation.app */,
8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.SandboxService.xpc */,
8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.install-service.xpc */,
03B5E63A15D399500038BB67 /* com.andymatuschak.Sparkle.download-service.xpc */,
);
name = Products;
sourceTree = "<group>";
};
03B5E63C15D399500038BB67 /* Downloading XPC Service */ = {
isa = PBXGroup;
children = (
03B5E64315D399500038BB67 /* download_service.m */,
03B5E64915D39CD90038BB67 /* SUXPCURLDownload.h */,
03B5E64A15D39CD90038BB67 /* SUXPCURLDownload.m */,
03B5E63D15D399500038BB67 /* Supporting Files */,
);
path = "Downloading XPC Service";
sourceTree = "<group>";
};
03B5E63D15D399500038BB67 /* Supporting Files */ = {
isa = PBXGroup;
children = (
03B5E64D15D39E690038BB67 /* libcurl.dylib */,
03B5E63E15D399500038BB67 /* Downloading XPC Service-Info.plist */,
03B5E63F15D399500038BB67 /* InfoPlist.strings */,
03B5E64215D399500038BB67 /* Downloading XPC Service-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
0867D691FE84028FC02AAC07 /* Sparkle */ = {
isa = PBXGroup;
children = (
@@ -521,7 +588,8 @@
55C14BD5136EEFD000649790 /* finish_installation tool */,
6101354A0DD25B7F0049ACDF /* Unarchiving */,
61299B3A09CB056100B7442F /* User Interface */,
8B887B621517F3AC000BB292 /* Sandbox Service */,
8B887B621517F3AC000BB292 /* Installation XPC Service */,
03B5E63C15D399500038BB67 /* Downloading XPC Service */,
61B5F8F309C4CE5900B25A18 /* Other Sources */,
089C1665FE841158C02AAC07 /* Framework Resources */,
61227A100DB5484000AB99EA /* Tests */,
@@ -691,6 +759,7 @@
61B5F91D09C4CF7F00B25A18 /* Test Application Sources */ = {
isa = PBXGroup;
children = (
0305626E15D2A68800B43EF8 /* Sparkle Test App.entitlements */,
61BBDF810A49220C00378739 /* Sparkle.icns */,
61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */,
61B5F92C09C4CFD800B25A18 /* MainMenu.nib */,
@@ -751,13 +820,13 @@
name = Frameworks;
sourceTree = "<group>";
};
8B887B621517F3AC000BB292 /* Sandbox Service */ = {
8B887B621517F3AC000BB292 /* Installation XPC Service */ = {
isa = PBXGroup;
children = (
8B887B801517F8B4000BB292 /* Service */,
8B887B631517F3AC000BB292 /* Interface */,
);
name = "Sandbox Service";
name = "Installation XPC Service";
path = Update;
sourceTree = "<group>";
};
@@ -773,7 +842,7 @@
8B887B801517F8B4000BB292 /* Service */ = {
isa = PBXGroup;
children = (
8B887B8D15180767000BB292 /* sandbox_service.m */,
8B887B8D15180767000BB292 /* install_service.m */,
8B887B8F15180773000BB292 /* SandboxService.plist */,
);
name = Service;
@@ -857,12 +926,30 @@
55C14F0F136EF73600649790 /* finish_installation.pch in Headers */,
6158A1C5137904B300487EC1 /* SUUpdater_Private.h in Headers */,
8B887B7E1517F888000BB292 /* SUXPC.h in Headers */,
03B5E64B15D39CD90038BB67 /* SUXPCURLDownload.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
03B5E63915D399500038BB67 /* Downloading XPC Service */ = {
isa = PBXNativeTarget;
buildConfigurationList = 03B5E64515D399500038BB67 /* Build configuration list for PBXNativeTarget "Downloading XPC Service" */;
buildPhases = (
03B5E63615D399500038BB67 /* Sources */,
03B5E63715D399500038BB67 /* Frameworks */,
03B5E63815D399500038BB67 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Downloading XPC Service";
productName = "Downloading XPC Service";
productReference = 03B5E63A15D399500038BB67 /* com.andymatuschak.Sparkle.download-service.xpc */;
productType = "com.apple.product-type.bundle";
};
55C14BB6136EEF1500649790 /* finish_installation */ = {
isa = PBXNativeTarget;
buildConfigurationList = 55C14BBE136EEF1500649790 /* Build configuration list for PBXNativeTarget "finish_installation" */;
@@ -925,6 +1012,7 @@
61B5F8FF09C4CEE200B25A18 /* Sources */,
61B5F90009C4CEE200B25A18 /* Frameworks */,
61B5FB4D09C4E9FA00B25A18 /* CopyFiles */,
0305627015D2A70400B43EF8 /* CopyFiles */,
);
buildRules = (
);
@@ -936,9 +1024,9 @@
productReference = 61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */;
productType = "com.apple.product-type.application";
};
8B887B5D1517F3AB000BB292 /* sandbox_service */ = {
8B887B5D1517F3AB000BB292 /* Installation XPC Service */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8B887B6E1517F3AC000BB292 /* Build configuration list for PBXNativeTarget "sandbox_service" */;
buildConfigurationList = 8B887B6E1517F3AC000BB292 /* Build configuration list for PBXNativeTarget "Installation XPC Service" */;
buildPhases = (
8B887B5A1517F3AB000BB292 /* Sources */,
8B887B5B1517F3AB000BB292 /* Frameworks */,
@@ -948,9 +1036,9 @@
);
dependencies = (
);
name = sandbox_service;
name = "Installation XPC Service";
productName = Update;
productReference = 8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.SandboxService.xpc */;
productReference = 8B887B5E1517F3AB000BB292 /* com.andymatuschak.Sparkle.install-service.xpc */;
productType = "com.apple.product-type.bundle";
};
8DC2EF4F0486A6940098B216 /* Sparkle */ = {
@@ -970,6 +1058,7 @@
dependencies = (
55C14F97136F044100649790 /* PBXTargetDependency */,
8B887B741517F472000BB292 /* PBXTargetDependency */,
03B5E65D15D3E32A0038BB67 /* PBXTargetDependency */,
);
name = Sparkle;
productInstallPath = "$(HOME)/Library/Frameworks";
@@ -1039,12 +1128,21 @@
612279D80DB5470200AB99EA /* Sparkle Unit Tests */,
5D06E8CF0FD68C7C005AE3F6 /* BinaryDelta */,
55C14BB6136EEF1500649790 /* finish_installation */,
8B887B5D1517F3AB000BB292 /* sandbox_service */,
8B887B5D1517F3AB000BB292 /* Installation XPC Service */,
03B5E63915D399500038BB67 /* Downloading XPC Service */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
03B5E63815D399500038BB67 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
03B5E64115D399500038BB67 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
55C14BB3136EEF1500649790 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1173,6 +1271,14 @@
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
03B5E63615D399500038BB67 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
03B5E64415D399500038BB67 /* download_service.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
55C14BB4136EEF1500649790 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1227,7 +1333,7 @@
8B887B8B1517FB52000BB292 /* SUPackageInstaller.m in Sources */,
8B887B8A1517FB43000BB292 /* SUConstants.m in Sources */,
8B887B891517FB3E000BB292 /* SULog.m in Sources */,
8B887B8E15180767000BB292 /* sandbox_service.m in Sources */,
8B887B8E15180767000BB292 /* install_service.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1270,12 +1376,18 @@
5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */,
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
8B887B7F1517F888000BB292 /* SUXPC.m in Sources */,
03B5E65B15D3E0490038BB67 /* SUXPCURLDownload.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
03B5E65D15D3E32A0038BB67 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 03B5E63915D399500038BB67 /* Downloading XPC Service */;
targetProxy = 03B5E65C15D3E32A0038BB67 /* PBXContainerItemProxy */;
};
55C14F97136F044100649790 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 55C14BB6136EEF1500649790 /* finish_installation */;
@@ -1298,12 +1410,20 @@
};
8B887B741517F472000BB292 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 8B887B5D1517F3AB000BB292 /* sandbox_service */;
target = 8B887B5D1517F3AB000BB292 /* Installation XPC Service */;
targetProxy = 8B887B731517F472000BB292 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
03B5E63F15D399500038BB67 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
03B5E64015D399500038BB67 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
55C14BDA136EF20D00649790 /* SUAutomaticUpdateAlert.xib */ = {
isa = PBXVariantGroup;
children = (
@@ -1441,6 +1561,94 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
03B5E64615D399500038BB67 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Downloading XPC Service/Downloading XPC Service-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Downloading XPC Service/Downloading XPC Service-Info.plist";
MACH_O_TYPE = mh_execute;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "com.andymatuschak.Sparkle.download-service";
SDKROOT = macosx;
WRAPPER_EXTENSION = xpc;
};
name = Debug;
};
03B5E64715D399500038BB67 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Downloading XPC Service/Downloading XPC Service-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Downloading XPC Service/Downloading XPC Service-Info.plist";
MACH_O_TYPE = mh_execute;
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "com.andymatuschak.Sparkle.download-service";
SDKROOT = macosx;
WRAPPER_EXTENSION = xpc;
};
name = Release;
};
03B5E64815D399500038BB67 /* Release (GC dual-mode; 10.5+) */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Downloading XPC Service/Downloading XPC Service-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Downloading XPC Service/Downloading XPC Service-Info.plist";
MACH_O_TYPE = mh_execute;
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "com.andymatuschak.Sparkle.download-service";
SDKROOT = macosx;
WRAPPER_EXTENSION = xpc;
};
name = "Release (GC dual-mode; 10.5+)";
};
1DEB91AE08733DA50010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */;
@@ -1571,6 +1779,8 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 615409A8103BA09100125AF1 /* ConfigTestAppReleaseGCSupport.xcconfig */;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
};
name = "Release (GC dual-mode; 10.5+)";
};
@@ -1599,6 +1809,8 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
};
name = Debug;
};
@@ -1606,6 +1818,8 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941D20D94A70100DD942E /* ConfigTestAppRelease.xcconfig */;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Sparkle Test App.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
};
name = Release;
};
@@ -1636,6 +1850,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
03B5E64515D399500038BB67 /* Build configuration list for PBXNativeTarget "Downloading XPC Service" */ = {
isa = XCConfigurationList;
buildConfigurations = (
03B5E64615D399500038BB67 /* Debug */,
03B5E64715D399500038BB67 /* Release */,
03B5E64815D399500038BB67 /* Release (GC dual-mode; 10.5+) */,
);
defaultConfigurationIsVisible = 0;
};
1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "Sparkle" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -1696,7 +1919,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8B887B6E1517F3AC000BB292 /* Build configuration list for PBXNativeTarget "sandbox_service" */ = {
8B887B6E1517F3AC000BB292 /* Build configuration list for PBXNativeTarget "Installation XPC Service" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8B887B6B1517F3AC000BB292 /* Debug */,
+8 -2
View File
@@ -7,6 +7,8 @@
//
#include <xpc/xpc.h>
#include <asl.h>
#include <Foundation/Foundation.h>
#import "SUPlainInstallerInternals.h"
@@ -59,16 +61,20 @@ static void peer_event_handler(xpc_connection_t peer, xpc_object_t event)
NSFileManager *manager = [NSFileManager defaultManager];
NSString *relaunchToolPath = path ? [manager stringWithFileSystemRepresentation:path length:strlen(path)] : nil;;
NSMutableArray *arguments = [NSMutableArray array];
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "path: %s", path);
for (size_t i = 0; i < xpc_array_get_count(array); i++) {
[arguments addObject:
[NSString stringWithUTF8String:xpc_array_get_string(array, i)]];
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Argument: %s", xpc_array_get_string(array, i));
}
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:arguments];
NSTask *launchedTask = [NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:arguments];
// send response to indicate ok
xpc_object_t reply = xpc_dictionary_create_reply(event);
if (launchedTask == nil) {
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "Could not launch relaunchtool");
}
xpc_connection_send_message(peer, reply);
}
}