Compare commits

..
27 Commits
Author SHA1 Message Date
Antonin Hildebrand ff13de9ddc fix warnings 2014-04-24 10:14:50 -05:00
Antonin Hildebrand 7c7f1e4955 a hacky way how to remove "Allow Automatic Updates" feature 2014-03-04 20:45:54 -05:00
Antonin Hildebrand 4935893311 prevent exception when cancelling Update Alert Dialog 2014-03-04 20:37:23 -05:00
Antonin Hildebrand b0e543de4e prevent automatic downloads - the feature is broken anyway 2014-03-04 20:37:19 -05:00
Antonin Hildebrand 2a356d4a2a update pbxproj so it can be parsed by CocoaPods/Xcodeproj 2014-01-17 19:33:47 -05:00
Antonin Hildebrand 99b2514752 last upgrade check 2013-12-28 00:45:12 +01:00
Antonin Hildebrand 5b1f7fc88d HACK: never ever ask for password (we don't ship encrypted DMGz)
http://discuss.binaryage.com/t/the-update-asked-for-my-password-why/838
2013-11-07 21:47:19 +00:00
Antonin Hildebrand f50dde6a50 comment out logging statement again 2013-07-03 20:06:07 -07:00
Antonin Hildebrand efe2a7db68 do NOT check for updates when network is not available 2013-07-03 19:21:46 -07:00
Antonin Hildebrand bd365be8b2 solve warnings in Asepsis project 2013-07-02 21:39:05 -07:00
Antonin Hildebrand 374a62495b converted project under XCode5 2013-06-12 21:16:41 -07:00
Antonin Hildebrand 71228f248c enable DWARF+dSYM generation for Release builds 2013-03-19 15:19:58 +01:00
Antonin Hildebrand 731321f861 fix XCode 4.6 warnings 2013-02-24 11:55:20 +01:00
Antonin Hildebrand 333098985b fixes for XCode 4.6 project 2013-02-24 11:36:36 +01:00
Antonin Hildebrand 891be09d49 fix unsafe string manipulation, XCode 4.5 treats it as error 2013-01-08 18:32:29 +01:00
Antonin Hildebrand 8f1e63c8d3 all projects build 64-bit only with latest SDK 2013-01-08 18:27:50 +01:00
Antonin Hildebrand 7021e4356f fix duplicit Sparle.strings 2013-01-06 23:41:33 +01:00
Antonin Hildebrand f9fd4d16c8 disable some static analyzer warnings 2012-12-14 00:24:58 +01:00
Antonin Hildebrand 5c22d0e46e fix broken tr.lproj/Sparkle.strings 2012-12-14 00:16:49 +01:00
Antonin Hildebrand c4de5e38a8 define correct dependencies on locale scripts 2012-12-14 00:10:10 +01:00
Antonin Hildebrand 1ad1373357 disable verbose output in build logs 2012-12-14 00:10:10 +01:00
Antonin Hildebrand a5ea60b5a8 update project settings for Xcode 4.5 2012-12-14 00:10:10 +01:00
Antonin Hildebrand 9b05410c95 hack for TotalFinder, this should be configurable from outside 2012-12-14 00:10:10 +01:00
Antonin Hildebrand 6fd2fc832b make it compile under Xcode 4.2 2012-12-14 00:08:55 +01:00
Antonin Hildebrand 7a1dc310d6 Sparkle source code should be independent on bundle identifier 2012-12-14 00:08:55 +01:00
Antonin Hildebrand 6d967e8641 use shared bundle identifier com.binaryage.sparkle 2012-12-14 00:08:55 +01:00
Antonin Hildebrand 36b35865fb force Sparkle to use my own bundle identifer 2012-12-14 00:08:55 +01:00
60 changed files with 255 additions and 2686 deletions

No files matched your search

-18
View File
@@ -1,18 +0,0 @@
# 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
+4 -5
View File
@@ -3,11 +3,11 @@
PREBINDING = NO
ZERO_LINK = NO
CURRENT_PROJECT_VERSION = 1.5
SDKROOT = macosx10.8
SDKROOT = macosx10.7
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.7
MACOSX_DEPLOYMENT_TARGET[arch=x86_64] = 10.5
GCC_C_LANGUAGE_STANDARD = c99
GCC_ENABLE_OBJC_EXCEPTIONS = YES
GCC_DEBUGGING_SYMBOLS = full
@@ -15,6 +15,7 @@ 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
@@ -47,6 +48,4 @@ GCC_WARN_UNUSED_VALUE = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
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)
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
@@ -6,6 +6,5 @@ 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.
@@ -1,4 +0,0 @@
// Common
ARCHS = x86_64
VALID_ARCHS = x86_64
@@ -1,4 +0,0 @@
// Common
ARCHS = ppc i386 x86_64
+1 -2
View File
@@ -2,8 +2,7 @@
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
+2 -2
View File
@@ -1,8 +1,8 @@
// Framework only
INSTALL_PATH = @loader_path/../Frameworks
DYLIB_COMPATIBILITY_VERSION = 2.0
DYLIB_CURRENT_VERSION = 2.0
DYLIB_COMPATIBILITY_VERSION = 1.5
DYLIB_CURRENT_VERSION = 1.5
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
-10
View File
@@ -1,10 +0,0 @@
// 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
@@ -1,5 +0,0 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonDebug.xcconfig"
#include "ConfigService.xcconfig"
OTHER_CFLAGS = -DDEBUG
@@ -1,3 +0,0 @@
#include "ConfigCommon.xcconfig"
#include "ConfigCommonRelease.xcconfig"
#include "ConfigService.xcconfig"
+1 -2
View File
@@ -7,5 +7,4 @@ 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.7
MACOSX_DEPLOYMENT_TARGET = 10.7
MACOSX_DEPLOYMENT_TARGET = 10.6
@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>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>
@@ -1,4 +0,0 @@
//
// Prefix header for all source files of the 'Downloading XPC Service' target in the 'Downloading XPC Service' project
//
-60
View File
@@ -1,60 +0,0 @@
//
// 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
-210
View File
@@ -1,210 +0,0 @@
//
// 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
@@ -1,29 +0,0 @@
//
// 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
@@ -1,36 +0,0 @@
//
// 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
-448
View File
@@ -1,448 +0,0 @@
//
// 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
-265
View File
@@ -1,265 +0,0 @@
//
// 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);
}
@@ -1,2 +0,0 @@
/* Localized versions of Info.plist keys */
BIN
View File
Binary file not shown.
+6 -6
View File
@@ -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>org.andymatuschak.Sparkle</string>
<string>com.binaryage.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>${DYLIB_CURRENT_VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${DYLIB_CURRENT_VERSION}</string>
<string>1.5</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
@@ -1,33 +0,0 @@
//
// 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
-16
View File
@@ -1,16 +0,0 @@
//
// 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
-107
View File
@@ -1,107 +0,0 @@
//
// 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
@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>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>
-127
View File
@@ -1,127 +0,0 @@
//
// 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;
}
@@ -1,11 +0,0 @@
//
// 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.
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.andymatuschak.Sparkle.relaunch</string>
<string>com.binaryage.totalfinder.sparkle.relaunch</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
-13
View File
@@ -1,13 +0,0 @@
{\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)}
-41
View File
@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>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>
+3 -6
View File
@@ -10,28 +10,25 @@
#define SUAPPCAST_H
@class SUAppcastItem;
@interface SUAppcast : NSObject
@interface SUAppcast : NSObject<NSURLDownloadDelegate>
{
@private
NSArray *items;
NSMutableDictionary *appcastValues;
NSString *userAgentString;
id delegate;
NSString *downloadFilename;
NSURLDownload *download;
}
- (void)fetchAppcastFromURL:(NSURL *)url;
- (void)setDelegate:(id)delegate;
- (void)setDelegate: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
+15 -49
View File
@@ -6,7 +6,7 @@
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater_Private.h"
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
@@ -14,7 +14,6 @@
#import "SUAppcast.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUXPCURLDownload.h"
@interface NSXMLElement (SUAppcastExtensions)
- (NSDictionary *)attributesAsDictionary;
@@ -43,9 +42,13 @@
- (void)dealloc
{
[items release];
[appcastValues release];
items = nil;
[userAgentString release];
userAgentString = nil;
[downloadFilename release];
downloadFilename = nil;
[download release];
download = nil;
[super dealloc];
}
@@ -58,20 +61,10 @@
- (void)fetchAppcastFromURL:(NSURL *)url
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
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];
}
if (userAgentString)
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
- (void)download:(NSURLDownload *)aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
@@ -293,38 +286,11 @@
- (void)setUserAgentString:(NSString *)uas
{
[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];
}
if (uas != userAgentString)
{
[userAgentString release];
userAgentString = [uas copy];
}
}
- (void)setDelegate:del
+2 -2
View File
@@ -34,8 +34,8 @@
}
// Initializes with data from a dictionary provided by the RSS class.
- initWithDictionary:(NSDictionary *)dict;
- initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
- (NSString *)title;
- (NSString *)versionString;
+1 -1
View File
@@ -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://"] || [[self itemDescription] hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
else if ([[self itemDescription] hasPrefix:@"http://"]) // if the description starts with http://, use that.
[self setReleaseNotesURL:[NSURL URLWithString:[self itemDescription]]];
else
[self setReleaseNotesURL:nil];
+1 -42
View File
@@ -11,50 +11,9 @@
#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];
@@ -77,7 +36,7 @@ static NSString * const kSUAutomaticUpdateParamName = @"autoupdate";
- (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;
+1 -3
View File
@@ -13,7 +13,7 @@
#import "SUUpdateDriver.h"
@class SUAppcastItem, SUUnarchiver, SUAppcast, SUUnarchiver, SUHost;
@interface SUBasicUpdateDriver : SUUpdateDriver {
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate> {
SUAppcastItem *updateItem;
SUAppcastItem *nonDeltaUpdateItem;
@@ -36,7 +36,6 @@
- (void)didFindValidUpdate;
- (void)didNotFindUpdate;
- (void)updateURLRequestIfNeeds:(NSMutableURLRequest *)request;
- (void)downloadUpdate;
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
- (void)downloadDidFinish:(NSURLDownload *)d;
@@ -50,7 +49,6 @@
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
- (void)cleanUpDownload;
- (void)abortUpdate;
+37 -123
View File
@@ -20,27 +20,6 @@
#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
@@ -48,18 +27,18 @@ NSArray *SUGetAllDevMateURLHosts(void)
@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];
@@ -68,16 +47,16 @@ NSArray *SUGetAllDevMateURLHosts(void)
- (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
@@ -87,12 +66,12 @@ NSArray *SUGetAllDevMateURLHosts(void)
- (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;
@@ -100,7 +79,7 @@ NSArray *SUGetAllDevMateURLHosts(void)
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
}
return minimumVersionOK && maximumVersionOK;
}
@@ -120,9 +99,9 @@ NSArray *SUGetAllDevMateURLHosts(void)
{
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?
{
@@ -136,7 +115,7 @@ NSArray *SUGetAllDevMateURLHosts(void)
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];
@@ -144,11 +123,11 @@ NSArray *SUGetAllDevMateURLHosts(void)
}
}
}
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
@@ -161,27 +140,6 @@ NSArray *SUGetAllDevMateURLHosts(void)
[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:)])
@@ -200,30 +158,18 @@ NSArray *SUGetAllDevMateURLHosts(void)
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
[self updateURLRequestIfNeeds:request];
if ([SUUpdater shouldUseXPCDownloader])
download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
else
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
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;
@@ -232,7 +178,7 @@ NSArray *SUGetAllDevMateURLHosts(void)
[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;
@@ -253,18 +199,11 @@ NSArray *SUGetAllDevMateURLHosts(void)
[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];
@@ -277,12 +216,12 @@ NSArray *SUGetAllDevMateURLHosts(void)
SULog(@"Code signature check on update failed: %@", error);
}
}
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
}
- (void)downloadDidFinish:(NSURLDownload *)d
{
{
[self extractUpdate];
}
@@ -351,13 +290,14 @@ NSArray *SUGetAllDevMateURLHosts(void)
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:)])
@@ -371,10 +311,10 @@ NSArray *SUGetAllDevMateURLHosts(void)
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]];
@@ -387,30 +327,11 @@ NSArray *SUGetAllDevMateURLHosts(void)
#endif
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
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 )
if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] )
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];
@@ -421,22 +342,15 @@ NSArray *SUGetAllDevMateURLHosts(void)
[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"];
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];
}
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:[NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", nil]];
[NSApp terminate:self];
}
- (void)cleanUpDownload
-5
View File
@@ -12,13 +12,8 @@
#import <Foundation/Foundation.h>
@interface SUCodeSigningVerifier : NSObject
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error;
+ (BOOL)hostApplicationIsCodeSigned;
+ (BOOL)hostApplicationIsSandboxed;
+ (BOOL)hostAppAllowsNetworkOutgoingConnections;
@end
#endif
+15 -120
View File
@@ -13,11 +13,13 @@
@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
{
@@ -66,126 +68,19 @@ finally:
+ (BOOL)hostApplicationIsCodeSigned
{
static BOOL sIsCodesigned = NO;
// This API didn't exist prior to 10.6.
if (SecCodeCopySelf == NULL) return NO;
static BOOL onceToken = NO;
while (!onceToken)
{
onceToken = YES;
// This API didn't exist prior to 10.6.
if (SecCodeCopySelf == NULL)
break;
OSStatus result;
SecCodeRef hostCode = NULL;
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
if (result != 0) return NO;
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;
SecRequirementRef requirement = NULL;
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
if (hostCode) CFRelease(hostCode);
if (requirement) CFRelease(requirement);
return (result == 0);
}
@end
-3
View File
@@ -10,8 +10,6 @@
#ifndef SUCONSTANTS_H
#define SUCONSTANTS_H
#import <Foundation/Foundation.h>
// -----------------------------------------------------------------------------
// Preprocessor flags:
// -----------------------------------------------------------------------------
@@ -89,7 +87,6 @@ extern OSStatus SUMissingInstallerToolError;
extern OSStatus SURelaunchError;
extern OSStatus SUInstallationError;
extern OSStatus SUDowngradeError;
extern OSStatus SUXPCServiceError;
// -----------------------------------------------------------------------------
+5 -1
View File
@@ -6,6 +6,11 @@
// 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";
@@ -50,4 +55,3 @@ OSStatus SUMissingInstallerToolError = 4003;
OSStatus SURelaunchError = 4004;
OSStatus SUInstallationError = 4005;
OSStatus SUDowngradeError = 4006;
OSStatus SUXPCServiceError = 4007;
+54 -94
View File
@@ -48,7 +48,7 @@
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
static BOOL SUAuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
@@ -69,58 +69,6 @@ static BOOL SUAuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authori
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
@@ -228,10 +176,17 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
}
}
AuthorizationRef auth = SUAuthorizationCreate(NULL);
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
while (authStat == errAuthorizationDenied) {
authStat = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
}
BOOL res = NO;
if (NULL != auth)
{
if (authStat == errAuthorizationSuccess) {
res = YES;
char uidgid[42];
@@ -243,18 +198,23 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
// quarantine to avoid a delay at launch, and to avoid
// presenting the user with a confusing trust dialog.
//
// This needs to be done before "chown" changes ownership,
// because the ownership change will fail if the file is quarantined.
// 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.
if (res)
{
SULog(@"releaseFromQuarantine");
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:src waitUntilDone:YES];
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst 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 = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
if( !res )
SULog( @"chown -R %s %s failed.", uidgid, srcPath );
}
@@ -263,7 +223,7 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
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 = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
if( !res )
SULog( @"rm failed" );
}
@@ -271,7 +231,7 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
if( res && haveDst ) // Move old exe to tmp path.
{
const char* mvParams[] = { "-f", dstPath, tmpPath, NULL };
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
if( !res )
SULog( @"mv 1 failed" );
}
@@ -279,7 +239,7 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
if( res ) // Move new exe to old exe's path.
{
const char* mvParams2[] = { "-f", srcPath, dstPath, NULL };
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
if( !res )
SULog( @"mv 2 failed" );
}
@@ -287,26 +247,11 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
// 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 = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
// }
SUAuthorizationRelease(auth);
AuthorizationFree(auth, 0);
// 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.
@@ -334,9 +279,18 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
struct stat dstSB;
stat(dstContainerPath, &dstSB);
AuthorizationRef auth = SUAuthorizationCreate(NULL);
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
while( authStat == errAuthorizationDenied )
{
authStat = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
}
BOOL res = NO;
if (NULL != auth)
if (authStat == errAuthorizationSuccess)
{
res = YES;
@@ -347,7 +301,7 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
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 = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
if( !res )
SULog(@"Can't set permissions");
}
@@ -356,7 +310,7 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
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 = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
if( !res )
SULog(@"Can't remove destination file");
}
@@ -364,12 +318,12 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
if( res ) // Move!.
{
const char* mvParams[] = { "-f", srcPath, dstPath, NULL };
res = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
if( !res )
SULog(@"Can't move source file");
}
SUAuthorizationRelease(auth);
AuthorizationFree(auth, 0);
if (!res)
{
@@ -394,21 +348,30 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
const char* srcPath = [src fileSystemRepresentation];
AuthorizationRef auth = SUAuthorizationCreate(NULL);
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
while( authStat == errAuthorizationDenied )
{
authStat = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
}
BOOL res = NO;
if (NULL != auth)
if (authStat == errAuthorizationSuccess)
{
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 = SUAuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
if( !res )
SULog(@"Can't remove destination file");
}
SUAuthorizationRelease(auth);
AuthorizationFree(auth, 0);
if (!res)
{
@@ -561,10 +524,7 @@ static AuthorizationRef SUAuthorizationCreate(OSStatus *outStatus)
// 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.
if ([NSThread isMultiThreaded])
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
else
[self releaseFromQuarantine:dst];
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
return YES;
}
+13 -18
View File
@@ -59,12 +59,7 @@
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
[[updateAlert window] makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)updateAlert:(SUUpdateAlert *)updateAlert willLoadReleaseNotesWithRequest:(NSMutableURLRequest *)request
{
[self updateURLRequestIfNeeds:request];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
}
- (void)updateAlert:(SUUpdateAlert *)alert finishedWithChoice:(SUUpdateAlertChoice)choice
@@ -168,13 +163,17 @@
- (void)unarchiver:(SUUnarchiver *)unarchiver requiresPasswordReturnedViaInvocation:(NSInvocation *)invocation
{
SUPasswordPrompt *prompt = [[SUPasswordPrompt alloc] initWithHost:host];
NSString *password = nil;
if([prompt run])
{
password = [prompt password];
}
[prompt release];
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];
[invocation setArgument:&password atIndex:2];
[invocation invoke];
}
@@ -206,11 +205,7 @@
- (void)abortUpdateWithError:(NSError *)error
{
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil)
defaultButton:SULocalizedString(@"Cancel Update", nil)
alternateButton:nil
otherButton:nil
informativeTextWithFormat:[error localizedDescription], nil];
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", [error localizedDescription]];
[self showModalAlert:alert];
[super abortUpdateWithError:error];
}
+1 -5
View File
@@ -22,7 +22,7 @@ typedef enum
} SUUpdateAlertChoice;
@class WebView, SUAppcastItem, SUHost;
@interface SUUpdateAlert : SUWindowController <NSURLDownloadDelegate> {
@interface SUUpdateAlert : SUWindowController {
SUAppcastItem *updateItem;
SUHost *host;
id delegate;
@@ -35,9 +35,6 @@ typedef enum
IBOutlet NSButton *laterButton;
NSProgressIndicator *releaseNotesSpinner;
BOOL webViewFinishedLoading;
NSURLDownload *releaseNotesDownloader;
NSString *downloadedReleaseNotesPath;
}
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
@@ -52,7 +49,6 @@ 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
+13 -43
View File
@@ -15,9 +15,8 @@
#import "SUHost.h"
#import <WebKit/WebKit.h>
#import "SUUpdater_Private.h"
#import "SUConstants.h"
#import "SUXPCURLDownload.h"
@interface WebView (SUTenFiveProperty)
@@ -51,9 +50,6 @@
{
[updateItem release];
[host release];
[releaseNotesDownloader release];
[downloadedReleaseNotesPath release];
[super dealloc];
}
@@ -119,23 +115,7 @@
}
else
{
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];
}
[[releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
}
}
else
@@ -144,18 +124,6 @@
}
}
- (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];
@@ -172,15 +140,17 @@
- (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;
// 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
}
- (void)awakeFromNib
+1
View File
@@ -27,6 +27,7 @@ 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;
+4
View File
@@ -35,6 +35,10 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
- (BOOL)finished { return finished; }
- (void)setFinished:(BOOL) _finished {
finished = _finished;
}
- (void)dealloc
{
[host release];
+3 -16
View File
@@ -27,7 +27,7 @@
+ (SUUpdater *)sharedUpdater;
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
- (id)initForBundle:(NSBundle *)bundle;
- (instancetype)initForBundle:(NSBundle *)bundle;
- (NSBundle *)hostBundle;
@@ -73,6 +73,8 @@
- (BOOL)updateInProgress;
-(void) checkForUpdatesInBgReachabilityCheckWithDriver: (SUUpdateDriver*)inDriver;
@end
@@ -140,21 +142,6 @@
@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:
+17 -64
View File
@@ -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 < 5 /*SU_MIN_CHECK_INTERVAL*/)
updateCheckInterval = 5 /*SU_MIN_CHECK_INTERVAL*/;
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
updateCheckInterval = 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 = YES;
BOOL isNetworkReachable = NO;
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
NSMutableDictionary* theDict = [NSMutableDictionary dictionary];
@@ -250,20 +250,21 @@ 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, automatic = %s, local = %s", (reachable?"YES":"NO"), (automatic?"YES":"NO"), (local?"YES":"NO"));
// NSLog(@"reachable = %s, needsConnection = %s, local = %s", (reachable?"YES":"NO"), (needsConnection?"YES":"NO"), (local?"YES":"NO"));
if( !(reachable || automatic || local) )
isNetworkReachable = NO;
if (local || (reachable && !needsConnection))
isNetworkReachable = YES;
}
// 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.
@@ -406,12 +407,13 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
- (BOOL)automaticallyDownloadsUpdates
{
// 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];
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];
}
- (void)setFeedURL:(NSURL *)feedURL
@@ -479,7 +481,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
NSArray *parameters = [self devmateFeedParameters];
NSArray *parameters = [NSArray array];
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
if (sendingSystemProfile)
@@ -551,56 +553,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
return driver && ([driver finished] == NO);
}
- (id)delegate { return delegate; }
- 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
-3
View File
@@ -12,7 +12,4 @@
- (BOOL)mayUpdateAndRestart;
+ (BOOL)shouldUseXPCDownloader;
+ (BOOL)shouldUseXPCInstaller;
@end
+5 -1
View File
@@ -6,8 +6,10 @@
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#ifndef SUVERSIONDISPLAYPROTOCOL_H
#define SUVERSIONDISPLAYPROTOCOL_H
#import <Cocoa/Cocoa.h>
/*!
@protocol
@@ -25,3 +27,5 @@
-(void) formatVersion: (NSString**)inOutVersionA andVersion: (NSString**)inOutVersionB;
@end
#endif
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
+1 -11
View File
@@ -18,19 +18,9 @@
#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 bundleWithIdentifier:@"org.andymatuschak.Sparkle"]
#define SPARKLE_BUNDLE [NSBundle bundleForClass:[SUUpdater class]]
#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
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0450"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -79,7 +79,7 @@
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
@@ -110,7 +110,7 @@
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Deployment"
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Binary file not shown.
Binary file not shown.