mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Made it more compatible with DevMate (for correct statistics in DevMate now updater tries to download release notes even for automatic update).
This commit is contained in:
1 parent
addedeac13
commit
ceedfba634
17 files changed
+195
-57
No files matched your search
@@ -24,5 +24,6 @@ const char * SUDownloadServiceShouldDecodeMIMETypeKey = "should_decode_MIME_type
|
||||
|
||||
const char * SUDownloadServiceErrorCodeKey = "errcode"; // int64_t
|
||||
const char * SUDownloadServiceErrorMessageKey = "errmsg"; // c-string
|
||||
const char * SUDownloadServiceErrorDomainKey = "errdomain"; // c-string
|
||||
|
||||
#endif
|
||||
@@ -10,11 +10,13 @@
|
||||
|
||||
@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;
|
||||
@@ -28,4 +30,7 @@
|
||||
- (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
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import "SUXPCURLDownload.h"
|
||||
#import "SUDownloadServiceConstants.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
|
||||
@@ -20,6 +22,28 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
|
||||
@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];
|
||||
@@ -34,6 +58,8 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
dispatch_async(dispatch_get_current_queue(), ^{
|
||||
[self startDownload:request];
|
||||
});
|
||||
|
||||
_isDownloading = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -66,7 +92,7 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
};
|
||||
[self performBlock:block onThread:_startedThread synchronous:YES];
|
||||
}
|
||||
else
|
||||
if (nil == _destination)
|
||||
{
|
||||
_destination = [[[urlRequest URL] lastPathComponent] copy];
|
||||
}
|
||||
@@ -92,34 +118,50 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
xpc_connection_send_message_with_reply(_connection, message, dispatch_get_main_queue(), ^(xpc_object_t object) {
|
||||
xpc_type_t type = xpc_get_type(object);
|
||||
|
||||
if (type == XPC_TYPE_ERROR ||
|
||||
(type == XPC_TYPE_DICTIONARY && noErr != xpc_dictionary_get_int64(object, SUDownloadServiceErrorCodeKey)))
|
||||
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:)])
|
||||
{
|
||||
#ifdef DEBUG
|
||||
const char *errMessage = xpc_dictionary_get_string(object, SUDownloadServiceErrorMessageKey);
|
||||
if (errMessage != NULL)
|
||||
{
|
||||
NSLog(@"Error message: %s", errMessage);
|
||||
}
|
||||
else if (_downloadError != nil)
|
||||
{
|
||||
NSLog(@"Error message: %@", [_downloadError description]);
|
||||
}
|
||||
#endif
|
||||
NSError *error = _downloadError;
|
||||
if (nil == error)
|
||||
{
|
||||
NSInteger errCode = (NSInteger)xpc_dictionary_get_int64(object, SUDownloadServiceErrorCodeKey);
|
||||
error = [NSError errorWithDomain:NSOSStatusErrorDomain code:errCode userInfo:nil];
|
||||
}
|
||||
|
||||
void (^block)(void) = ^{
|
||||
[_delegate download:(NSURLDownload *)self didFailWithError:error];
|
||||
[_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);
|
||||
@@ -137,6 +179,7 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
|
||||
- (void)setDestination:(NSString *)path allowOverwrite:(BOOL)allowOverwrite
|
||||
{
|
||||
[_destination release];
|
||||
_destination = [path copy];
|
||||
_allowOverwrite = allowOverwrite;
|
||||
}
|
||||
@@ -299,7 +342,7 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
|
||||
NSString *destPath = _destination;
|
||||
if ([destPath isEqualToString:[destPath lastPathComponent]])
|
||||
if (nil == destPath || [destPath isEqualToString:[destPath lastPathComponent]])
|
||||
{
|
||||
destPath = _connectionDestination;
|
||||
}
|
||||
@@ -334,12 +377,16 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX";
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#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);
|
||||
@@ -25,8 +26,10 @@ static void fetch_event_handler(xpc_connection_t peer);
|
||||
// data, and build/return XPC reply.
|
||||
static void fetch_process_request(xpc_object_t request, xpc_object_t reply)
|
||||
{
|
||||
__block int errcode = 0;
|
||||
__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];
|
||||
@@ -39,7 +42,8 @@ static void fetch_process_request(xpc_object_t request, xpc_object_t reply)
|
||||
NSURLRequest *urlRequest = [NSKeyedUnarchiver unarchiveObjectWithData:requestData];
|
||||
if (nil == urlRequest)
|
||||
{
|
||||
errcode = EINVAL;
|
||||
errcode = SUXPCServiceError;
|
||||
errdomain = [SUSparkleErrorDomain cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
errmsg = "Invalid URL request data";
|
||||
break;
|
||||
}
|
||||
@@ -48,7 +52,8 @@ static void fetch_process_request(xpc_object_t request, xpc_object_t reply)
|
||||
connection = xpc_dictionary_create_connection(request, SUDownloadServiceDelegateConnectionKey);
|
||||
if (connection == NULL)
|
||||
{
|
||||
errcode = EINVAL;
|
||||
errcode = SUXPCServiceError;
|
||||
errdomain = [SUSparkleErrorDomain cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
errmsg = "Invalid XPC delegate connection";
|
||||
break;
|
||||
}
|
||||
@@ -110,7 +115,8 @@ static void fetch_process_request(xpc_object_t request, xpc_object_t reply)
|
||||
};
|
||||
|
||||
callBacks.downloadDidFail = ^(SUDSDownloader *downloader, NSError *error) {
|
||||
errcode = (int)[error code];
|
||||
errcode = (int32_t)[error code];
|
||||
errdomain = [[error domain] cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
errmsg = [[error localizedDescription] cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
NSData *errorData = [NSKeyedArchiver archivedDataWithRootObject:error];
|
||||
@@ -177,6 +183,10 @@ static void fetch_process_request(xpc_object_t request, xpc_object_t reply)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#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)
|
||||
{
|
||||
@@ -90,9 +91,8 @@ static void peer_event_handler(xpc_connection_t peer, xpc_object_t event)
|
||||
|
||||
default:
|
||||
{
|
||||
#ifdef DEBUG
|
||||
NSLog(@"!!! Unknown XPC service task.");
|
||||
#endif
|
||||
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.");
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
@end
|
||||
|
||||
@interface NSObject (SUAppcastDelegate)
|
||||
- (void)appcast:(SUAppcast *)appcast willFetchURLRequest:(NSMutableURLRequest *)request;
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
|
||||
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
|
||||
@end
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
if ([appcastValues count])
|
||||
[request setAllHTTPHeaderFields:appcastValues];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(appcast:willFetchURLRequest:)])
|
||||
[delegate appcast:self willFetchURLRequest:request];
|
||||
|
||||
if ([SUUpdater shouldUseXPC])
|
||||
{
|
||||
download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
|
||||
|
||||
@@ -11,9 +11,50 @@
|
||||
#import "SUAutomaticUpdateAlert.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUXPCURLDownload.h"
|
||||
|
||||
@implementation SUAutomaticUpdateDriver
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
|
||||
static NSString * const kSUAutomaticUpdateParamName = @"autoupdate";
|
||||
|
||||
- (void)downloadReleaseNotesAndWaitUntilDone
|
||||
{
|
||||
NSURL *releaseNotesURL = [updateItem releaseNotesURL];
|
||||
if (nil == releaseNotesURL || [releaseNotesURL isFileURL])
|
||||
return;
|
||||
|
||||
NSString *URLString = [releaseNotesURL absoluteString];
|
||||
URLString = [URLString stringByAppendingFormat:@"%@%@=1", ([releaseNotesURL query] != nil) ? @"&" : @"?", kSUAutomaticUpdateParamName];
|
||||
releaseNotesURL = [NSURL URLWithString:URLString];
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:releaseNotesURL];
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
|
||||
if ([SUUpdater shouldUseXPC])
|
||||
{
|
||||
[SUXPCURLDownload sendSynchronousRequest:request delegate:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
// For correct DevMate statistics need to send request for Release Notes.
|
||||
[self downloadReleaseNotesAndWaitUntilDone];
|
||||
[super didFindValidUpdate];
|
||||
}
|
||||
|
||||
#endif // SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
{
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
|
||||
@@ -36,7 +77,7 @@
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
{
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
- (void)didFindValidUpdate;
|
||||
- (void)didNotFindUpdate;
|
||||
|
||||
- (void)updateURLRequestIfNeeds:(NSMutableURLRequest *)request;
|
||||
- (void)downloadUpdate;
|
||||
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
|
||||
- (void)downloadDidFinish:(NSURLDownload *)d;
|
||||
|
||||
+23
-17
@@ -23,8 +23,6 @@
|
||||
#import "SUXPCInstaller.h"
|
||||
#import "SUXPCURLDownload.h"
|
||||
|
||||
#define SPARKLE_IS_COMPATIBLE_WITH_DEVMATE (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
|
||||
|
||||
#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFDataRef httpBodyData);
|
||||
|
||||
@@ -64,21 +62,6 @@ NSArray *SUGetAllDevMateURLHosts(void)
|
||||
|
||||
[appcast setDelegate:self];
|
||||
[appcast setUserAgentString:[updater userAgentString]];
|
||||
|
||||
#if SPARKLE_IS_COMPATIBLE_WITH_DEVMATE
|
||||
if ([SUGetAllDevMateURLHosts() containsObject:[URL host]])
|
||||
{
|
||||
CFBundleRef hostBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:[host bundlePath]]);
|
||||
CFDictionaryRef devmateAppcastValues = DMCopyHTTPRequestHeaders(hostBundle, NULL);
|
||||
[appcast setAllAppcastValues:(NSDictionary *)devmateAppcastValues];
|
||||
|
||||
if (NULL != devmateAppcastValues)
|
||||
CFRelease(devmateAppcastValues);
|
||||
if (NULL != hostBundle)
|
||||
CFRelease(hostBundle);
|
||||
}
|
||||
#endif
|
||||
|
||||
[appcast fetchAppcastFromURL:URL];
|
||||
}
|
||||
|
||||
@@ -178,6 +161,27 @@ 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:)])
|
||||
@@ -196,6 +200,8 @@ NSArray *SUGetAllDevMateURLHosts(void)
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
|
||||
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
|
||||
if ([SUUpdater shouldUseXPC])
|
||||
download = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
|
||||
else
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef SUCONSTANTS_H
|
||||
#define SUCONSTANTS_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Preprocessor flags:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
|
||||
|
||||
@@ -59,7 +59,12 @@
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
{
|
||||
[[updateAlert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert willLoadReleaseNotesWithRequest:(NSMutableURLRequest *)request
|
||||
{
|
||||
[self updateURLRequestIfNeeds:request];
|
||||
}
|
||||
|
||||
- (void)updateAlert:(SUUpdateAlert *)alert finishedWithChoice:(SUUpdateAlertChoice)choice
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef enum
|
||||
@end
|
||||
|
||||
@interface NSObject (SUUpdateAlertDelegate)
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert willLoadReleaseNotesWithRequest:(NSMutableURLRequest *)request;
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate: (BOOL*)shouldAllowAutoUpdate;
|
||||
@end
|
||||
|
||||
+13
-3
@@ -119,11 +119,21 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
|
||||
if ([SUUpdater shouldUseXPC]) {
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem releaseNotesURL]
|
||||
cachePolicy:NSURLRequestReloadIgnoringCacheData
|
||||
timeoutInterval:30];
|
||||
if ([delegate respondsToSelector:@selector(updateAlert:willLoadReleaseNotesWithRequest:)])
|
||||
{
|
||||
[delegate updateAlert:self willLoadReleaseNotesWithRequest:request];
|
||||
}
|
||||
|
||||
if ([SUUpdater shouldUseXPC])
|
||||
{
|
||||
[releaseNotesDownloader release];
|
||||
releaseNotesDownloader = (NSURLDownload *)[[SUXPCURLDownload alloc] initWithRequest:request delegate:self];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadRequest:request];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
#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"]
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
03B5E65A15D3DC3C0038BB67 /* com.andymatuschak.Sparkle.download-service.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 03B5E63A15D399500038BB67 /* com.andymatuschak.Sparkle.download-service.xpc */; };
|
||||
03B5E65B15D3E0490038BB67 /* SUXPCURLDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B5E64A15D39CD90038BB67 /* SUXPCURLDownload.m */; };
|
||||
3330768F190A5CB8005602B2 /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; };
|
||||
338A79F11919191500EDD837 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
|
||||
338A79F319193CDC00EDD837 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
33D081831888446F00394A94 /* libDMCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D081821888446E00394A94 /* libDMCore.a */; };
|
||||
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
525A2790133D6AE900FD8D70 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 525A278F133D6AE900FD8D70 /* Cocoa.framework */; };
|
||||
@@ -1319,6 +1321,8 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
338A79F11919191500EDD837 /* SULog.m in Sources */,
|
||||
338A79F319193CDC00EDD837 /* SUConstants.m in Sources */,
|
||||
03B5E64415D399500038BB67 /* download_service.m in Sources */,
|
||||
BEA931AD17AA3EF7007D20A6 /* SUDSDownloader.m in Sources */,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user