Move remaining private ivars to properties/implementation.

This commit is contained in:
Jake Petroules committed 2014-07-01 22:08:13 -04:00
1 parent 7e4f74af14
commit 3b1f97a298
15 files changed
+152 -153

No files matched your search

-4
View File
@@ -89,7 +89,6 @@
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (); }; };
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (); }; };
6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */; };
610EC1E00CF3A5FE00AE239E /* NTSynchronousTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */; };
611142E910FB1BE5009810AA /* bspatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 611142E810FB1BE5009810AA /* bspatch.h */; };
61177A1F0D1112E900749C97 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6117796E0D1112E000749C97 /* IOKit.framework */; };
@@ -387,7 +386,6 @@
6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDiskImageUnarchiver.h; sourceTree = "<group>"; };
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDiskImageUnarchiver.m; sourceTree = "<group>"; };
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiver_Private.h; sourceTree = "<group>"; };
6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUnarchiver_Private.m; sourceTree = "<group>"; };
610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTSynchronousTask.m; sourceTree = "<group>"; };
610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTSynchronousTask.h; sourceTree = "<group>"; };
611142E810FB1BE5009810AA /* bspatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bspatch.h; sourceTree = "<group>"; };
@@ -750,7 +748,6 @@
61299A8B09CA790200B7442F /* SUUnarchiver.h */,
61299A8C09CA790200B7442F /* SUUnarchiver.m */,
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */,
6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */,
);
name = Unarchiving;
sourceTree = "<group>";
@@ -1382,7 +1379,6 @@
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */,
6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */,
61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */,
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */,
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */,
+16 -10
View File
@@ -15,6 +15,12 @@
// If the user hasn't quit in a week, ask them if they want to relaunch to get the latest bits. It doesn't matter that this measure of "one day" is imprecise.
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
@interface SUUpdateDriver ()
- (void)setInterruptible:(BOOL)interruptible;
@end
@implementation SUAutomaticUpdateDriver
{
BOOL postponingInstallation, showErrors;
@@ -25,8 +31,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)showUpdateAlert
{
isInterruptible = NO;
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:self.host delegate:self];
self.interruptible = NO;
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host delegate:self];
// If the app is a menubar app or the like, we need to focus it first and alter the
// update prompt to behave like a normal window. Otherwise if the window were hidden
@@ -53,7 +59,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
willUpdateOnTermination = YES;
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
{
BOOL relaunch = YES;
@@ -64,11 +70,11 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[invocation setArgument:&showUI atIndex:3];
[invocation setTarget:self];
[updaterDelegate updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation];
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
}
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([updateItem isCriticalUpdate])
if ([self.updateItem isCriticalUpdate])
{
[self showUpdateAlert];
}
@@ -77,7 +83,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
showUpdateAlertTimer = [NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO];
// At this point the driver is idle, allow it to be interrupted for user-initiated update checks.
isInterruptible = YES;
self.interruptible = YES;
}
}
@@ -91,9 +97,9 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
willUpdateOnTermination = NO;
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
[updaterDelegate updater:updater didCancelInstallUpdateOnQuit:updateItem];
[updaterDelegate updater:self.updater didCancelInstallUpdateOnQuit:self.updateItem];
}
}
@@ -135,11 +141,11 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
postponingInstallation = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
// We're already waiting on quit, just indicate that we're idle.
isInterruptible = YES;
self.interruptible = YES;
break;
case SUDoNotInstallChoice:
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
break;
}
+5 -5
View File
@@ -15,11 +15,11 @@
#import "SUAppcast.h"
@class SUAppcastItem, SUHost;
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate> {
SUAppcastItem *updateItem;
NSURLDownload *download;
NSString *downloadPath;
}
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate>
@property (weak, readonly) SUAppcastItem *updateItem;
@property (strong, readonly) NSURLDownload *download;
@property (copy, readonly) NSString *downloadPath;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
+25 -21
View File
@@ -37,6 +37,10 @@
NSString *relaunchPath;
}
@synthesize updateItem;
@synthesize download;
@synthesize downloadPath;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
[super checkForUpdatesAtURL:URL host:aHost];
@@ -49,7 +53,7 @@
SUAppcast *appcast = [[SUAppcast alloc] init];
[appcast setDelegate:self];
[appcast setUserAgentString:[updater userAgentString]];
[appcast setUserAgentString:[self.updater userAgentString]];
[appcast fetchAppcastFromURL:URL];
}
@@ -58,8 +62,8 @@
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 ([[self.updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
comparator = [[self.updater delegate] versionComparatorForUpdater:self.updater];
}
// If we don't get a comparator from the delegate, use the default comparator
@@ -108,19 +112,19 @@
- (void)appcastDidFinishLoading:(SUAppcast *)ac
{
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
[[updater delegate] updater:updater didFinishLoadingAppcast:ac];
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
[[self.updater delegate] updater:self.updater didFinishLoadingAppcast:ac];
}
NSDictionary *userInfo = (ac != nil) ? @{SUUpdaterAppcastNotificationKey : ac} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
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?
if ([[self.updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
{
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
}
else // If not, we'll take care of it ourselves.
{
@@ -155,19 +159,19 @@
- (void)didFindValidUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
[[self.updater delegate] updater:self.updater didFindValidUpdate:updateItem];
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:self.updater userInfo:userInfo];
[self downloadUpdate];
}
- (void)didNotFindUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[updater delegate] updaterDidNotFindUpdate:updater];
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", "'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI)"), [self.host name]]
@@ -177,7 +181,7 @@
- (void)downloadUpdate
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
@@ -296,7 +300,7 @@
return;
}
if (![updater mayUpdateAndRestart])
if (![self.updater mayUpdateAndRestart])
{
[self abortUpdate];
return;
@@ -304,7 +308,7 @@
// Give the host app an opportunity to postpone the install and relaunch.
static BOOL postponedOnce = NO;
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
@@ -312,14 +316,14 @@
[invocation setArgument:&relaunch atIndex:2];
[invocation setTarget:self];
postponedOnce = YES;
if ([updaterDelegate updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) {
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) {
return;
}
}
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[updaterDelegate updater:updater willInstallUpdate:updateItem];
[updaterDelegate updater:self.updater willInstallUpdate:updateItem];
}
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;
@@ -342,7 +346,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
[updaterDelegate updaterWillRelaunchApplication:updater];
[updaterDelegate updaterWillRelaunchApplication:self.updater];
if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
{
@@ -354,7 +358,7 @@
NSString *pathToRelaunch = [self.host bundlePath];
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:updater];
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
}
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName];
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:@[[self.host bundlePath],
+3 -3
View File
@@ -23,10 +23,10 @@
- (void)applyBinaryDelta
{
@autoreleasepool {
NSString *sourcePath = [[updateHost bundle] bundlePath];
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
NSString *sourcePath = [[self.updateHost bundle] bundlePath];
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
int result = applyBinaryDelta(sourcePath, targetPath, archivePath);
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath);
if (!result) {
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfSuccess];
+4 -4
View File
@@ -33,7 +33,7 @@
@autoreleasepool {
BOOL mountedSuccessfully = NO;
SULog(@"Extracting %@ as a DMG", archivePath);
SULog(@"Extracting %@ as a DMG", self.archivePath);
// get a unique mount point path
NSString *mountPoint = nil;
@@ -58,7 +58,7 @@
NSData *promptData = nil;
promptData = [NSData dataWithBytes:"yes\n" length:4];
NSArray* arguments = @[@"attach", archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
NSArray* arguments = @[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
NSData *output = nil;
NSInteger taskResult = -1;
@@ -98,7 +98,7 @@
for (NSString *item in contents)
{
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
// We skip any files in the DMG which are not readable.
if (![manager isReadableFileAtPath:fromPath]) {
@@ -128,7 +128,7 @@
if (mountedSuccessfully)
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
else
SULog(@"Can't mount DMG %@",archivePath);
SULog(@"Can't mount DMG %@", self.archivePath);
}
}
+5 -5
View File
@@ -36,7 +36,7 @@
- (void)start
{
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:archivePath] toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:self.archivePath] toTarget:self withObject:nil];
}
+ (BOOL)canUnarchivePath:(NSString *)path
@@ -52,19 +52,19 @@
FILE *fp = NULL, *cmdFP = NULL;
char *oldDestinationString = NULL;
SULog(@"Extracting %@ using '%@'",archivePath,command);
SULog(@"Extracting %@ using '%@'", self.archivePath,command);
// Get the file size.
NSNumber *fs = [[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:nil][NSFileSize];
NSNumber *fs = [[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil][NSFileSize];
if (fs == nil) goto reportError;
// Thank you, Allan Odgaard!
// (who wrote the following extraction alg.)
fp = fopen([archivePath fileSystemRepresentation], "r");
fp = fopen([self.archivePath fileSystemRepresentation], "r");
if (!fp) goto reportError;
oldDestinationString = getenv("DESTINATION");
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
setenv("DESTINATION", [[self.archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
cmdFP = popen([command fileSystemRepresentation], "w");
size_t written;
if (!cmdFP) goto reportError;
+7 -7
View File
@@ -15,23 +15,23 @@
- (void)didFindValidUpdate
{
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)])
[updaterDelegate updater:updater didFindValidUpdate:updateItem];
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
[updaterDelegate updater:self.updater didFindValidUpdate:self.updateItem];
NSDictionary *userInfo = (self.updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : self.updateItem} : nil;
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:self.updater userInfo:userInfo];
[self abortUpdate];
}
- (void)didNotFindUpdate
{
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[updaterDelegate updaterDidNotFindUpdate:updater];
[updaterDelegate updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
[self abortUpdate];
}
+3 -3
View File
@@ -26,12 +26,12 @@
- (void)didNotFindUpdate
{
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[updaterDelegate updaterDidNotFindUpdate:updater];
[updaterDelegate updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
[self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update.
}
+17 -17
View File
@@ -22,17 +22,17 @@
- (void)didFindValidUpdate
{
updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:self.host];
updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host];
[updateAlert setDelegate:self];
id<SUVersionDisplay> versDisp = nil;
if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
versDisp = [[updater delegate] versionDisplayerForUpdater: updater];
if ([[self.updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
versDisp = [[self.updater delegate] versionDisplayerForUpdater:self.updater];
}
[updateAlert setVersionDisplayer: versDisp];
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
}
// If the app is a menubar app or the like, we need to focus it first and alter the
@@ -53,9 +53,9 @@
- (void)didNotFindUpdate
{
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
[[updater delegate] updaterDidNotFindUpdate:updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.")
defaultButton:SULocalizedString(@"OK", nil)
@@ -87,12 +87,12 @@
break;
case SUOpenInfoURLChoice:
[[NSWorkspace sharedWorkspace] openURL: [updateItem infoURL]];
[[NSWorkspace sharedWorkspace] openURL: [self.updateItem infoURL]];
[self abortUpdate];
break;
case SUSkipThisVersionChoice:
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
break;
@@ -135,8 +135,8 @@
- (IBAction)cancelDownload:(id) __unused sender
{
if (download)
[download cancel];
if (self.download)
[self.download cancel];
[self abortUpdate];
}
@@ -154,7 +154,7 @@
if ([statusController maxProgressValue] == 0.0)
{
NSDictionary * attributes;
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:nil];
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.downloadPath error:nil];
[statusController setMaxProgressValue:[attributes[NSFileSize] doubleValue]];
}
[statusController setProgressValue:[statusController progressValue] + (double)length];
@@ -213,8 +213,8 @@
- (void)showModalAlert:(NSAlert *)alert
{
if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
[[updater delegate] updaterWillShowModalAlert: updater];
if ([[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
[[self.updater delegate] updaterWillShowModalAlert:self.updater];
}
// When showing a modal alert we need to ensure that background applications
@@ -224,8 +224,8 @@
[alert setIcon:[self.host icon]];
[alert runModal];
if ([[updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
[[updater delegate] updaterDidShowModalAlert: updater];
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
[[self.updater delegate] updaterDidShowModalAlert:self.updater];
}
@end
+4 -4
View File
@@ -12,10 +12,10 @@
@class SUHost;
@protocol SUUnarchiverDelegate;
@interface SUUnarchiver : NSObject {
NSString *archivePath;
SUHost *updateHost;
}
@interface SUUnarchiver : NSObject
@property (copy, readonly) NSString *archivePath;
@property (weak, readonly) SUHost *updateHost;
@property (weak) id<SUUnarchiverDelegate> delegate;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host;
+55 -1
View File
@@ -16,6 +16,9 @@
#import "SUUnarchiver_Private.h"
@implementation SUUnarchiver
@synthesize archivePath;
@synthesize updateHost;
@synthesize delegate;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
@@ -29,11 +32,62 @@
return nil;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], archivePath]; }
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
- (void)start
{
// No-op
}
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
{
if ((self = [super init]))
{
archivePath = [path copy];
updateHost = host;
}
return self;
}
+ (BOOL)canUnarchivePath:(NSString *) __unused path
{
return NO;
}
- (void)notifyDelegateOfExtractedLength:(size_t)length
{
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) {
[self.delegate unarchiver:self extractedLength:length];
}
}
- (void)notifyDelegateOfSuccess
{
if ([self.delegate respondsToSelector:@selector(unarchiverDidFinish:)]) {
[self.delegate unarchiverDidFinish:self];
}
}
- (void)notifyDelegateOfFailure
{
if ([self.delegate respondsToSelector:@selector(unarchiverDidFail:)]) {
[self.delegate unarchiverDidFail:self];
}
}
static NSMutableArray *gUnarchiverImplementations;
+ (void)registerImplementation:(Class)implementation
{
if (!gUnarchiverImplementations) {
gUnarchiverImplementations = [[NSMutableArray alloc] init];
}
[gUnarchiverImplementations addObject:implementation];
}
+ (NSArray *)unarchiverImplementations
{
return [NSArray arrayWithArray:gUnarchiverImplementations];
}
@end
-65
View File
@@ -1,65 +0,0 @@
//
// SUUnarchiver_Private.m
// Sparkle
//
// Created by Andy Matuschak on 6/17/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUUnarchiver_Private.h"
#import "SUHost.h"
@implementation SUUnarchiver (Private)
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
{
if ((self = [super init]))
{
archivePath = [path copy];
updateHost = host;
}
return self;
}
+ (BOOL)canUnarchivePath:(NSString *) __unused path
{
return NO;
}
- (void)notifyDelegateOfExtractedLength:(size_t)length
{
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) {
[self.delegate unarchiver:self extractedLength:length];
}
}
- (void)notifyDelegateOfSuccess
{
if ([self.delegate respondsToSelector:@selector(unarchiverDidFinish:)]) {
[self.delegate unarchiverDidFinish:self];
}
}
- (void)notifyDelegateOfFailure
{
if ([self.delegate respondsToSelector:@selector(unarchiverDidFail:)]) {
[self.delegate unarchiverDidFail:self];
}
}
static NSMutableArray *gUnarchiverImplementations;
+ (void)registerImplementation:(Class)implementation
{
if (!gUnarchiverImplementations) {
gUnarchiverImplementations = [[NSMutableArray alloc] init];
}
[gUnarchiverImplementations addObject:implementation];
}
+ (NSArray *)unarchiverImplementations
{
return [NSArray arrayWithArray:gUnarchiverImplementations];
}
@end
+2 -4
View File
@@ -15,10 +15,8 @@ extern NSString * const SUUpdateDriverFinishedNotification;
@class SUHost, SUUpdater;
@interface SUUpdateDriver : NSObject<NSURLDownloadDelegate>
{
SUUpdater *updater; //assigned
BOOL isInterruptible;
}
@property (readonly, weak) SUUpdater *updater;
@property (strong) SUHost *host;
- (instancetype) initWithUpdater:(SUUpdater *)updater;
+6
View File
@@ -16,6 +16,7 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
NSURL *appcastURL;
}
@synthesize updater;
@synthesize host;
@synthesize interruptible = isInterruptible;
@synthesize finished;
@@ -42,4 +43,9 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self];
}
- (void)setInterruptible:(BOOL)interruptible
{
isInterruptible = interruptible;
}
@end