diff --git a/Info.plist b/Info.plist index 3cfbcb89..f0c18095 100644 --- a/Info.plist +++ b/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - English + en_US CFBundleExecutable ${EXECUTABLE_NAME} CFBundleName diff --git a/NSFileManager+Authentication.m b/NSFileManager+Authentication.m index 2c5d784b..b81cfea4 100644 --- a/NSFileManager+Authentication.m +++ b/NSFileManager+Authentication.m @@ -229,11 +229,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Trash the old copy of the app. NSInteger tag = 0; if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tmpPath stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[tmpPath lastPathComponent]] tag:&tag]) - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to the trash. This is often a sign of a permissions error.", src, dst] forKey:NSLocalizedDescriptionKey]]; - return NO; - } + NSLog(@"Sparkle error: couldn't move %@ to the trash. This is often a sign of a permissions error.", tmpPath); // If the currently-running application is trusted, the new // version should be trusted as well. Remove it from the diff --git a/NSWorkspace_RBAdditions.m b/NSWorkspace_RBAdditions.m index 15f69ccc..1ffac239 100644 --- a/NSWorkspace_RBAdditions.m +++ b/NSWorkspace_RBAdditions.m @@ -137,11 +137,8 @@ static NSString* CheckParents(io_object_t thing,NSString* part,NSMutableDictiona NSMutableDictionary* result = nil; struct statfs fs = {}; if (!statfs(ccpath,&fs)) { - NSString* from = [NSString stringWithUTF8String:fs.f_mntfromname]; - result = [NSMutableDictionary dictionaryWithObjectsAndKeys: - [NSString stringWithUTF8String:fs.f_fstypename],NSWorkspace_RBfstypename, - [NSString stringWithUTF8String:fs.f_mntonname],NSWorkspace_RBmntonname, - nil]; + NSString* from = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:fs.f_mntfromname length:strlen(fs.f_mntfromname)]; + result = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSString stringWithUTF8String:fs.f_fstypename], NSWorkspace_RBfstypename, [[NSFileManager defaultManager] stringWithFileSystemRepresentation:fs.f_mntonname length:strlen(fs.f_mntonname)], NSWorkspace_RBmntonname, nil]; const char* devstring = "/dev/"; size_t devstringlen = 5; if (strncmp(fs.f_mntfromname,devstring,devstringlen)==0) { diff --git a/NTSynchronousTask.m b/NTSynchronousTask.m index 541483a6..d506cad5 100644 --- a/NTSynchronousTask.m +++ b/NTSynchronousTask.m @@ -84,7 +84,7 @@ NS_HANDLER; NS_ENDHANDLER; - [pool release]; + [pool drain]; // retained above [result autorelease]; diff --git a/RSS.m b/RSS.m index ea4efa0e..2920e9c1 100644 --- a/RSS.m +++ b/RSS.m @@ -184,6 +184,11 @@ NSComparisonResult compareNewsItems(id item1, id item2, void *context) [delegate feed:self didFailWithError:error]; } +- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse +{ + return request; +} + - (NSDictionary *) headerItems { return (headerItems); @@ -580,7 +585,7 @@ NSComparisonResult compareNewsItems(id item1, id item2, void *context) shortTitle = [shortTitle trimWhiteSpace]; - title = [NSString stringWithFormat: @"%@...", shortTitle]; + title = [NSString stringWithFormat: @"%@\u2026", shortTitle]; } /*else*/ } /*if*/ @@ -604,7 +609,7 @@ NSComparisonResult compareNewsItems(id item1, id item2, void *context) [rssItem setObject: description forKey: descriptionKey]; - title = [NSString stringWithFormat: @"%@...", shortTitle]; + title = [NSString stringWithFormat: @"%@\u2026", shortTitle]; [rssItem setObject: title forKey: titleKey]; } /*if*/ diff --git a/SUAppcast.m b/SUAppcast.m index fdd14df4..b0d454b5 100644 --- a/SUAppcast.m +++ b/SUAppcast.m @@ -35,25 +35,23 @@ - (void)feedDidFinishLoading:(RSS *)feed { // Set up all the appcast items: - items = [NSMutableArray array]; + NSArray *tempItems = [NSMutableArray array]; id enumerator = [[feed newsItems] objectEnumerator], current; @try { while ((current = [enumerator nextObject])) { - [(NSMutableArray *)items addObject:[[[SUAppcastItem alloc] initWithDictionary:current] autorelease]]; + [(NSMutableArray *)tempItems addObject:[[[SUAppcastItem alloc] initWithDictionary:current] autorelease]]; } + items = [[NSArray arrayWithArray:tempItems] retain]; // Make the items list immutable. + + if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)]) + [delegate performSelectorOnMainThread:@selector(appcastDidFinishLoading:) withObject:self waitUntilDone:NO]; } @catch (NSException *parseException) { [self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while parsing the update feed.", nil), NSLocalizedDescriptionKey, [parseException reason], SUTechnicalErrorInformationKey, nil]]]; - return; } - items = [[NSArray arrayWithArray:items] retain]; // Make the items list immutable. - - if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)]) - [delegate performSelectorOnMainThread:@selector(appcastDidFinishLoading:) withObject:self waitUntilDone:NO]; - CFRelease(feed); } @@ -72,8 +70,11 @@ - (void)setUserAgentString:(NSString *)uas { - [userAgentString release]; - userAgentString = [uas copy]; + if (uas != userAgentString) + { + [userAgentString release]; + userAgentString = [uas copy]; + } } - (void)setDelegate:del diff --git a/SUAppcastItem.m b/SUAppcastItem.m index f04a14e1..28efc7c7 100644 --- a/SUAppcastItem.m +++ b/SUAppcastItem.m @@ -17,6 +17,7 @@ - (void)setTitle:(NSString *)aTitle { + if (title == aTitle) return; [title release]; title = [aTitle copy]; } @@ -26,6 +27,7 @@ - (void)setDate:(NSDate *)aDate { + if (date == aDate) return; [date release]; date = [aDate copy]; } @@ -35,6 +37,7 @@ - (void)setDescription:(NSString *)aDescription { + if (description == aDescription) return; [description release]; description = [aDescription copy]; } @@ -44,6 +47,7 @@ - (void)setReleaseNotesURL:(NSURL *)aReleaseNotesURL { + if (releaseNotesURL == aReleaseNotesURL) return; [releaseNotesURL release]; releaseNotesURL = [aReleaseNotesURL copy]; } @@ -53,6 +57,7 @@ - (void)setDSASignature:(NSString *)aDSASignature { + if (DSASignature == aDSASignature) return; [DSASignature release]; DSASignature = [aDSASignature copy]; } @@ -62,6 +67,7 @@ - (void)setFileURL:(NSURL *)aFileURL { + if (fileURL == aFileURL) return; [fileURL release]; fileURL = [aFileURL copy]; } @@ -71,6 +77,7 @@ - (void)setVersionString:(NSString *)s { + if (versionString == s) return; [versionString release]; versionString = [s copy]; } @@ -80,6 +87,7 @@ - (void)setDisplayVersionString:(NSString *)s { + if (displayVersionString == s) return; [displayVersionString release]; displayVersionString = [s copy]; } @@ -88,6 +96,7 @@ - (NSString *)minimumSystemVersion { return [[minimumSystemVersion retain] autorelease]; } - (void)setMinimumSystemVersion:(NSString *)systemVersionString { + if (minimumSystemVersion == systemVersionString) return; [minimumSystemVersion release]; minimumSystemVersion = [systemVersionString copy]; } diff --git a/SUAutomaticUpdateDriver.m b/SUAutomaticUpdateDriver.m index 66cae631..56dae07e 100644 --- a/SUAutomaticUpdateDriver.m +++ b/SUAutomaticUpdateDriver.m @@ -15,14 +15,14 @@ { alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem hostBundle:hostBundle delegate:self]; if ([NSApp isActive]) - [alert showWindow:self]; + [[alert window] makeKeyAndOrderFront:self]; else [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp]; } - (void)applicationDidBecomeActive:(NSNotification *)aNotification { - [alert showWindow:self]; + [[alert window] makeKeyAndOrderFront:self]; [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp]; } @@ -62,7 +62,6 @@ - (void)installerFinishedForHostBundle:(NSBundle *)hb { if (hb != hostBundle) { return; } - [unarchiver cleanUp]; if (!postponingInstallation) [self relaunchHostApp]; } diff --git a/SUBasicUpdateDriver.h b/SUBasicUpdateDriver.h index bd0297c5..90cb6250 100644 --- a/SUBasicUpdateDriver.h +++ b/SUBasicUpdateDriver.h @@ -20,8 +20,6 @@ NSURLDownload *download; NSString *downloadPath; - SUUnarchiver *unarchiver; - NSString *relaunchPath; } diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 2d5ceee4..b29fc369 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -162,18 +162,27 @@ } } - unarchiver = [[SUUnarchiver alloc] init]; + SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForURL:[[[NSURL alloc] initFileURLWithPath:downloadPath] autorelease]]; + if (!unarchiver) + { + NSLog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath); + [self unarchiverDidFail:nil]; + return; + } + CFRetain(unarchiver); // Manage this memory manually so we don't have to make it an IV. [unarchiver setDelegate:self]; - [unarchiver unarchivePath:downloadPath]; + [unarchiver start]; } - (void)unarchiverDidFinish:(SUUnarchiver *)ua { + if (ua) { CFRelease(ua); } [self installUpdate]; } - (void)unarchiverDidFail:(SUUnarchiver *)ua { + if (ua) { CFRelease(ua); } [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:[NSDictionary dictionaryWithObject:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) forKey:NSLocalizedDescriptionKey]]]; } @@ -197,7 +206,6 @@ - (void)installerFinishedForHostBundle:(NSBundle *)hb { if (hb != hostBundle) { return; } - [unarchiver cleanUp]; [self relaunchHostApp]; } @@ -262,8 +270,6 @@ [hostBundle release]; [downloadPath release]; [relaunchPath release]; - [unarchiver release]; - [download release]; [super dealloc]; } diff --git a/SUDiskImageUnarchiver.h b/SUDiskImageUnarchiver.h new file mode 100644 index 00000000..44c71504 --- /dev/null +++ b/SUDiskImageUnarchiver.h @@ -0,0 +1,20 @@ +// +// SUDiskImageUnarchiver.h +// Sparkle +// +// Created by Andy Matuschak on 6/16/08. +// Copyright 2008 Andy Matuschak. All rights reserved. +// + +#ifndef SUDISKIMAGEUNARCHIVER_H +#define SUDISKIMAGEUNARCHIVER_H + +#import +#import "SUUnarchiver.h" + +@interface SUDiskImageUnarchiver : SUUnarchiver { +} + +@end + +#endif diff --git a/SUDiskImageUnarchiver.m b/SUDiskImageUnarchiver.m new file mode 100644 index 00000000..1d8b2347 --- /dev/null +++ b/SUDiskImageUnarchiver.m @@ -0,0 +1,79 @@ +// +// SUDiskImageUnarchiver.m +// Sparkle +// +// Created by Andy Matuschak on 6/16/08. +// Copyright 2008 Andy Matuschak. All rights reserved. +// + +#import "SUDiskImageUnarchiver.h" +#import "SUUnarchiver_Private.h" +#import "NTSynchronousTask.h" + +@implementation SUDiskImageUnarchiver + ++ (BOOL)_canUnarchiveURL:(NSURL *)URL +{ + return [URL conformsToType:@"public.disk-image"]; +} + +- (void)start +{ + [NSThread detachNewThreadSelector:@selector(_extractDMG) toTarget:self withObject:nil]; +} + +- (void)_extractDMG +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *archivePath = [archiveURL path]; + BOOL mountedSuccessfully = NO; + + // get a unique mount point path + NSString *mountPrefix = [@"/Volumes" stringByAppendingPathComponent:[[archivePath lastPathComponent] stringByDeletingPathExtension]]; + NSString *mountPoint = [mountPrefix stringByAppendingString:[[NSProcessInfo processInfo] globallyUniqueString]]; + + if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError; + + // create mount point folder + [[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil]; + if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError; + + NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil]; + // set up a pipe and push "yes" (y works too), this will accept any license agreement crap + // not every .dmg needs this, but this will make sure it works with everyone + NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4] autorelease]; + + NSData *result = [NTSynchronousTask task:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:yesData]; + if (!result) goto reportError; + mountedSuccessfully = YES; + + // Now that we've mounted it, we need to copy out its contents. + NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[mountPoint lastPathComponent]]; + if (![[NSFileManager defaultManager] createDirectoryAtPath:targetPath attributes:nil]) goto reportError; + + // We can't just copyPath: from the volume root because that always fails. Seems to be a bug. + id subpathEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:mountPoint] objectEnumerator], currentSubpath; + while ((currentSubpath = [subpathEnumerator nextObject])) + { + if (![[NSFileManager defaultManager] copyPath:[mountPoint stringByAppendingPathComponent:currentSubpath] toPath:[targetPath stringByAppendingPathComponent:currentSubpath] handler:nil]) + goto reportError; + } + + [self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO]; + goto finally; + +reportError: + [self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO]; + +finally: + if (mountedSuccessfully) + [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]]; + [pool drain]; +} + ++ (void)load +{ + [self _registerImplementation:self]; +} + +@end diff --git a/SUPipedUnarchiver.h b/SUPipedUnarchiver.h new file mode 100644 index 00000000..b13a0b3a --- /dev/null +++ b/SUPipedUnarchiver.h @@ -0,0 +1,21 @@ +// +// SUPipedUnarchiver.h +// Sparkle +// +// Created by Andy Matuschak on 6/16/08. +// Copyright 2008 Andy Matuschak. All rights reserved. +// + +#ifndef SUPIPEDUNARCHIVER_H +#define SUPIPEDUNARCHIVER_H + +#import +#import "SUUnarchiver.h" + +@interface SUPipedUnarchiver : SUUnarchiver { + +} + +@end + +#endif diff --git a/SUPipedUnarchiver.m b/SUPipedUnarchiver.m new file mode 100644 index 00000000..9ad911c8 --- /dev/null +++ b/SUPipedUnarchiver.m @@ -0,0 +1,106 @@ +// +// SUPipedUnarchiver.m +// Sparkle +// +// Created by Andy Matuschak on 6/16/08. +// Copyright 2008 Andy Matuschak. All rights reserved. +// + +#import "SUPipedUnarchiver.h" +#import "SUUnarchiver_Private.h" + +@implementation SUPipedUnarchiver + ++ (SEL)_selectorConformingToTypeOfURL:(NSURL *)URL +{ + static NSDictionary *typeSelectorDictionary; + if (!typeSelectorDictionary) + typeSelectorDictionary = [[NSDictionary dictionaryWithObjectsAndKeys:@"_extractZIP", @"public.zip-archive", @"_extractTGZ", @"org.gnu.gnu-zip-tar-archive", @"_extractTBZ", @"org.bzip.bzip2-tar-archive", @"_extractTAR", @"public.tar-archive", nil] retain]; + + NSEnumerator *typeEnumerator = [typeSelectorDictionary keyEnumerator]; + id currentType; + while ((currentType = [typeEnumerator nextObject])) + { + if ([URL conformsToType:currentType]) + return NSSelectorFromString([typeSelectorDictionary objectForKey:currentType]); + } + return NULL; +} + +- (void)start +{ + [NSThread detachNewThreadSelector:[[self class] _selectorConformingToTypeOfURL:archiveURL] toTarget:self withObject:nil]; +} + ++ (BOOL)_canUnarchiveURL:(NSURL *)URL +{ + return ([self _selectorConformingToTypeOfURL:URL] != nil); +} + +// This method abstracts the types that use a command line tool piping data from stdin. +- (void)_extractArchivePipingDataToCommand:(NSString *)command +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *archivePath = [archiveURL path]; + FILE *fp = NULL, *cmdFP = NULL; + + // Get the file size. + NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize]; + if (fs == nil) goto reportError; + + // Thank you, Allan Odgaard! + // (who wrote the following extraction alg.) + fp = fopen([archivePath fileSystemRepresentation], "r"); + if (!fp) goto reportError; + + setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1); + cmdFP = popen([command fileSystemRepresentation], "w"); + if (!cmdFP) goto reportError; + + char buf[32*1024]; + long len; + while((len = fread(buf, 1, 32*1024, fp))) + { + fwrite(buf, 1, len, cmdFP); + [self performSelectorOnMainThread:@selector(_notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO]; + } + pclose(cmdFP); + + [self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO]; + goto finally; + +reportError: + [self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO]; + +finally: + if (fp) + fclose(fp); + [pool drain]; +} + +- (void)_extractTAR +{ + return [self _extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""]; +} + +- (void)_extractTGZ +{ + return [self _extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""]; +} + +- (void)_extractTBZ +{ + return [self _extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""]; +} + +- (void)_extractZIP +{ + return [self _extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""]; +} + ++ (void)load +{ + [self _registerImplementation:self]; +} + +@end diff --git a/SUPlainInstaller.m b/SUPlainInstaller.m index 63d5122d..f876c19e 100644 --- a/SUPlainInstaller.m +++ b/SUPlainInstaller.m @@ -27,7 +27,7 @@ extern NSString *SUInstallerDelegateKey; [self installPath:[info objectForKey:SUInstallerPathKey] overHostBundle:[info objectForKey:SUInstallerHostBundleKey] delegate:[info objectForKey:SUInstallerDelegateKey]]; - [pool release]; + [pool drain]; } + (void)performInstallationWithPath:(NSString *)path hostBundle:(NSBundle *)hostBundle delegate:delegate synchronously:(BOOL)synchronously; diff --git a/SUStatusController.m b/SUStatusController.m index 0438fe7e..cd44910a 100644 --- a/SUStatusController.m +++ b/SUStatusController.m @@ -61,7 +61,11 @@ - (void)setButtonTitle:(NSString *)aButtonTitle target:target action:(SEL)action isDefault:(BOOL)isDefault { [self willChangeValueForKey:@"buttonTitle"]; - buttonTitle = [aButtonTitle copy]; + if (buttonTitle != aButtonTitle) + { + [buttonTitle release]; + buttonTitle = [aButtonTitle copy]; + } [self didChangeValueForKey:@"buttonTitle"]; [self window]; @@ -113,7 +117,11 @@ - (void)setStatusText:(NSString *)aStatusText { - statusText = [aStatusText copy]; + if (statusText != aStatusText) + { + [statusText release]; + statusText = [aStatusText copy]; + } } @end diff --git a/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index 998a1101..05644781 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -22,7 +22,7 @@ // Only show the update alert if the app is active; otherwise, we'll wait until it is. if ([NSApp isActive]) - [updateAlert showWindow:self]; + [[updateAlert window] makeKeyAndOrderFront:self]; else [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp]; } @@ -37,7 +37,7 @@ - (void)applicationDidBecomeActive:(NSNotification *)aNotification { - [updateAlert showWindow:self]; + [[updateAlert window] makeKeyAndOrderFront:self]; [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp]; } @@ -51,7 +51,7 @@ { case SUInstallUpdateChoice: statusController = [[SUStatusController alloc] initWithHostBundle:hostBundle]; - [statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", nil) maxProgressValue:0 statusText:nil]; + [statusController beginActionWithTitle:SULocalizedString(@"Downloading update\u2026", nil) maxProgressValue:0 statusText:nil]; [statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO]; [statusController showWindow:self]; [self downloadUpdate]; @@ -70,7 +70,7 @@ [statusController setMaxProgressValue:[response expectedContentLength]]; } -- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(unsigned)length +- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(NSUInteger)length { [statusController setProgressValue:[statusController progressValue] + length]; [statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [NSNumber humanReadableSizeFromDouble:[statusController progressValue]], [NSNumber humanReadableSizeFromDouble:[statusController maxProgressValue]]]]; @@ -86,7 +86,7 @@ - (void)extractUpdate { // Now we have to extract the downloaded archive. - [statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", nil) maxProgressValue:0 statusText:nil]; + [statusController beginActionWithTitle:SULocalizedString(@"Extracting update\u2026", nil) maxProgressValue:0 statusText:nil]; [statusController setButtonEnabled:NO]; [super extractUpdate]; } @@ -112,7 +112,7 @@ - (void)installUpdate { - [statusController beginActionWithTitle:SULocalizedString(@"Installing update...", nil) maxProgressValue:0 statusText:nil]; + [statusController beginActionWithTitle:SULocalizedString(@"Installing update\u2026", nil) maxProgressValue:0 statusText:nil]; [statusController setButtonEnabled:NO]; [super installUpdate]; } diff --git a/SUUnarchiver.h b/SUUnarchiver.h index 337bf500..8b1325c4 100644 --- a/SUUnarchiver.h +++ b/SUUnarchiver.h @@ -11,12 +11,13 @@ @interface SUUnarchiver : NSObject { id delegate; - NSString *archivePath; + NSURL *archiveURL; } -- (void)unarchivePath:(NSString *)path; ++ (SUUnarchiver *)unarchiverForURL:(NSURL *)URL; - (void)setDelegate:delegate; -- (void)cleanUp; + +- (void)start; @end diff --git a/SUUnarchiver.m b/SUUnarchiver.m index 409b86fc..77fed4ac 100644 --- a/SUUnarchiver.m +++ b/SUUnarchiver.m @@ -9,147 +9,22 @@ #import "Sparkle.h" #import "SUUnarchiver.h" +#import "SUUnarchiver_Private.h" @implementation SUUnarchiver -// This method abstracts the types that use a command line tool piping data from stdin. -- (BOOL)_extractArchivePipingDataToCommand:(NSString *)command +extern NSMutableArray *__unarchiverImplementations; + ++ (SUUnarchiver *)unarchiverForURL:(NSURL *)URL { - // Get the file size. - NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize]; - if (fs == nil) { return NO; } - - // Thank you, Allan Odgaard! - // (who wrote the following extraction alg.) - - long current = 0; - FILE *fp, *cmdFP; - if ((fp = fopen([archivePath fileSystemRepresentation], "r"))) + NSEnumerator *implementationEnumerator = [[self _unarchiverImplementations] objectEnumerator]; + id current; + while ((current = [implementationEnumerator nextObject])) { - setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] UTF8String], 1); - if ((cmdFP = popen([command fileSystemRepresentation], "w"))) - { - char buf[32*1024]; - long len; - while((len = fread(buf, 1, 32 * 1024, fp))) - { - current += len; - - NSEvent *event; - while((event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES])) - [NSApp sendEvent:event]; - - fwrite(buf, 1, len, cmdFP); - - [self performSelectorOnMainThread:@selector(notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO]; - } - pclose(cmdFP); - } - fclose(fp); - } - - return YES; -} - -- (BOOL)_extractTAR -{ - return [self _extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""]; -} - -- (BOOL)_extractTGZ -{ - return [self _extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""]; -} - -- (BOOL)_extractTBZ -{ - return [self _extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""]; -} - -- (BOOL)_extractZIP -{ - return [self _extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""]; -} - -- (BOOL)_extractDMG -{ - // get a unique mount point path - NSString *mountPoint = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"mp"]; - int cnt=1; - while ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint] && cnt <= 999) - mountPoint = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"mp%d", cnt++]]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) - { - // create mount point folder - [[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil]; - - if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) - { - NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil]; - // set up a pipe and push "yes" (y works too), this will accept any license agreement crap - // not every .dmg needs this, but this will make sure it works with everyone - NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4] autorelease]; - - [NTSynchronousTask task:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:yesData]; - } + if ([current _canUnarchiveURL:URL]) + return [[[current alloc] _initWithURL:URL] autorelease]; } - - return YES; -} - -- (void)_unarchive -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - // This dictionary associates names of methods responsible for extraction with file extensions. - // The methods take the path of the archive to extract. They return a BOOL indicating whether - // we should continue with the update; returns NO if an error occurred. - NSDictionary *commandDictionary = [NSDictionary dictionaryWithObjectsAndKeys: - @"_extractTBZ", @".tbz", - @"_extractTBZ", @".tar.bz2", - @"_extractTGZ", @".tgz", - @"_extractTGZ", @".tar.gz", - @"_extractTAR", @".tar", - @"_extractZIP", @".zip", - @"_extractDMG", @".dmg", - nil]; - SEL command = NULL; - NSString *theLastPathComponent = [[archivePath lastPathComponent] lowercaseString]; - NSEnumerator *theEnumerator = [[commandDictionary allKeys] objectEnumerator]; - NSString *theExtension = NULL; - while ((theExtension = [theEnumerator nextObject]) != NULL) - { - if ([[theLastPathComponent substringFromIndex:[theLastPathComponent length] - [theExtension length]] isEqualToString:theExtension]) - { - command = NSSelectorFromString([commandDictionary objectForKey:theExtension]); - break; - } - } - - BOOL result; - if (command) - { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:command]]; - [invocation setSelector:command]; - [invocation invokeWithTarget:self]; - [invocation getReturnValue:&result]; - } - else - result = NO; - - if (result) - [self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO]; - else - [self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO]; - - [pool release]; -} - -- (void)unarchivePath:(NSString *)path -{ - archivePath = [path copy]; - [NSThread detachNewThreadSelector:@selector(_unarchive) toTarget:self withObject:nil]; + return nil; } - (void)setDelegate:del @@ -157,37 +32,9 @@ delegate = del; } -- (void)cleanUp +- (void)start { - if ([[archivePath pathExtension] isEqualToString:@".dmg"]) - { - [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", [archivePath stringByDeletingLastPathComponent], @"-force", nil]]; - } - [[NSFileManager defaultManager] removeFileAtPath:archivePath handler:nil]; -} - -- (void)dealloc -{ - [archivePath release]; - [super dealloc]; -} - -- (void)notifyDelegateOfExtractedLength:(long)length -{ - if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) - [delegate unarchiver:self extractedLength:length]; -} - -- (void)notifyDelegateOfSuccess -{ - if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)]) - [delegate performSelector:@selector(unarchiverDidFinish:) withObject:self]; -} - -- (void)notifyDelegateOfFailure -{ - if ([delegate respondsToSelector:@selector(unarchiverDidFail:)]) - [delegate performSelector:@selector(unarchiverDidFail:) withObject:self]; + // No-op } @end diff --git a/SUUnarchiver_Private.h b/SUUnarchiver_Private.h new file mode 100644 index 00000000..bae20e53 --- /dev/null +++ b/SUUnarchiver_Private.h @@ -0,0 +1,30 @@ +// +// SUUnarchiver_Private.h +// Sparkle +// +// Created by Andy Matuschak on 6/17/08. +// Copyright 2008 Andy Matuschak. All rights reserved. +// + +#ifndef SUUNARCHIVER_PRIVATE_H +#define SUUNARCHIVER_PRIVATE_H + +#import +#import "SUUnarchiver.h" + +@interface SUUnarchiver (Private) ++ (void)_registerImplementation:(Class)implementation; ++ (NSArray *)_unarchiverImplementations; ++ (BOOL)_canUnarchiveURL:(NSURL *)URL; +- _initWithURL:(NSURL *)URL; + +- (void)_notifyDelegateOfExtractedLength:(long)length; +- (void)_notifyDelegateOfSuccess; +- (void)_notifyDelegateOfFailure; +@end + +@interface NSURL (SUTypeDetection) +- (BOOL)conformsToType:(NSString *)type; +@end + +#endif diff --git a/SUUnarchiver_Private.m b/SUUnarchiver_Private.m new file mode 100644 index 00000000..a705a0ac --- /dev/null +++ b/SUUnarchiver_Private.m @@ -0,0 +1,80 @@ +// +// SUUnarchiver_Private.m +// Sparkle +// +// Created by Andy Matuschak on 6/17/08. +// Copyright 2008 Andy Matuschak. All rights reserved. +// + +#import "SUUnarchiver_Private.h" + +@implementation SUUnarchiver (Private) + +- _initWithURL:(NSURL *)URL +{ + if ((self = [super init])) + archiveURL = [URL copy]; + return self; +} + +- (void)dealloc +{ + [archiveURL release]; + [super dealloc]; +} + ++ (BOOL)_canUnarchiveURL:(NSURL *)URL +{ + return NO; +} + +- (void)_notifyDelegateOfExtractedLength:(long)length +{ + if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) + [delegate unarchiver:self extractedLength:length]; +} + +- (void)_notifyDelegateOfSuccess +{ + if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)]) + [delegate performSelector:@selector(unarchiverDidFinish:) withObject:self]; +} + +- (void)_notifyDelegateOfFailure +{ + if ([delegate respondsToSelector:@selector(unarchiverDidFail:)]) + [delegate performSelector:@selector(unarchiverDidFail:) withObject:self]; +} + +static NSMutableArray *__unarchiverImplementations; + ++ (void)_registerImplementation:(Class)implementation +{ + if (!__unarchiverImplementations) + __unarchiverImplementations = [[NSMutableArray alloc] init]; + [__unarchiverImplementations addObject:implementation]; +} + ++ (NSArray *)_unarchiverImplementations +{ + return [NSArray arrayWithArray:__unarchiverImplementations]; +} + +@end + +@implementation NSURL (SUTypeDetection) +- (NSString *)__UTI +{ + FSRef fsRefToItem; + FSPathMakeRef((UInt8 *)[[self path] fileSystemRepresentation], &fsRefToItem, NULL ); + + NSString *UTI = nil; + LSCopyItemAttribute(&fsRefToItem, kLSRolesAll, kLSItemContentType, (CFTypeRef *)(&UTI)); + return [UTI autorelease]; +} + +- (BOOL)conformsToType:(NSString *)type +{ + return UTTypeConformsTo((CFStringRef)[self __UTI], (CFStringRef)type); +} +@end diff --git a/SUUpdater.h b/SUUpdater.h index 80788728..a286fc0a 100644 --- a/SUUpdater.h +++ b/SUUpdater.h @@ -18,6 +18,8 @@ id delegate; } ++ (SUUpdater *)sharedUpdater; + - (void)setHostBundle:(NSBundle *)hostBundle; - (void)setDelegate:(id)delegate; diff --git a/SUUpdater.m b/SUUpdater.m index 6ac26a7d..9be1dba9 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -217,12 +217,12 @@ static SUUpdater *sharedUpdater = nil; - (void)setDelegate:aDelegate { - [delegate release]; - delegate = [aDelegate retain]; + delegate = aDelegate; } - (void)setHostBundle:(NSBundle *)hb { + if (hostBundle == hb) return; [hostBundle release]; hostBundle = [hb retain]; [[SUUserDefaults standardUserDefaults] setIdentifier:[hostBundle bundleIdentifier]]; diff --git a/SUUserDefaults.m b/SUUserDefaults.m index 990e8301..d6923f04 100644 --- a/SUUserDefaults.m +++ b/SUUserDefaults.m @@ -27,8 +27,11 @@ - (void)setIdentifier:(NSString *)anIdentifier { - [identifier autorelease]; - identifier = [anIdentifier copy]; + if (identifier != anIdentifier) + { + [identifier release]; + identifier = [anIdentifier copy]; + } } - (void)verifyIdentifier @@ -41,6 +44,12 @@ { [self verifyIdentifier]; CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)identifier); + // Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistratioDomain, so anything + // passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls + // back to using NSUserDefaults, but only if the host bundle is the main bundle, and no value + // is found elsewhere. + if (obj == NULL && [identifier isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]) + obj = [[NSUserDefaults standardUserDefaults] objectForKey:defaultName]; #if MAC_OS_X_VERSION_MIN_REQUIRED > 1050 return [NSMakeCollectable(obj) autorelease]; #else diff --git a/SUUserInitiatedUpdateDriver.m b/SUUserInitiatedUpdateDriver.m index b9520cb9..706dcc51 100644 --- a/SUUserInitiatedUpdateDriver.m +++ b/SUUserInitiatedUpdateDriver.m @@ -16,11 +16,23 @@ [super checkForUpdatesAtURL:appcastURL hostBundle:hb]; checkingController = [[SUStatusController alloc] initWithHostBundle:hb]; [checkingController window]; // Force the checking controller to load its window. - [checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0 statusText:nil]; + [checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates\u2026", nil) maxProgressValue:0 statusText:nil]; [checkingController setButtonHidden:YES]; [checkingController showWindow:self]; } +- (void)closeCheckingWindow +{ + [[checkingController window] close]; + [checkingController release]; +} + +- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error +{ + [self closeCheckingWindow]; + [super appcast:ac failedToLoadWithError:error]; +} + - (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui { // We don't check to see if this update's been skipped, because the user explicitly *asked* if he had the latest version. @@ -29,15 +41,13 @@ - (void)didNotFindUpdate { - [[checkingController window] close]; - [checkingController release]; + [self closeCheckingWindow]; [super didNotFindUpdate]; } - (void)didFindValidUpdate { - [[checkingController window] close]; - [checkingController release]; + [self closeCheckingWindow]; [super didFindValidUpdate]; } diff --git a/Sparkle.h b/Sparkle.h index 924ce289..cd6013b4 100644 --- a/Sparkle.h +++ b/Sparkle.h @@ -14,6 +14,7 @@ #define SPARKLE_H #define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", [NSBundle bundleForClass:[self class]], comment) +#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]); #ifdef __OBJC__ #import diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 2c9d6572..7f0ed833 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -13,6 +13,11 @@ 610134780DD252E60049ACDF /* NSWorkspace+SystemVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 610134760DD252E60049ACDF /* NSWorkspace+SystemVersion.m */; }; 6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */; }; + 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; }; + 6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */; }; 61072EB30DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 61072EB20DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig */; }; 610D5A1A0A1661B8004AAD9C /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; }; 610D5A750A1670A4004AAD9C /* SUStatus.nib in Resources */ = {isa = PBXBuildFile; fileRef = 610D5A740A1670A4004AAD9C /* SUStatus.nib */; }; @@ -95,9 +100,10 @@ 61C1F2780DA066C2007ACE13 /* NSFileManager+ExtendedAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 61C1F2760DA066C2007ACE13 /* NSFileManager+ExtendedAttributes.h */; settings = {ATTRIBUTES = (Public, ); }; }; 61C1F2790DA066C2007ACE13 /* NSFileManager+ExtendedAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 61C1F2770DA066C2007ACE13 /* NSFileManager+ExtendedAttributes.m */; }; 61C46F340D9C54F300B06326 /* SUUpdatePermissionPrompt.nib in Resources */ = {isa = PBXBuildFile; fileRef = 61C46F330D9C54F300B06326 /* SUUpdatePermissionPrompt.nib */; }; + 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */; }; 61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; }; 61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */ = {isa = PBXBuildFile; fileRef = 784590BF0DE0429F00D0D64B /* NSNumber+Units.h */; }; + 784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */ = {isa = PBXBuildFile; fileRef = 784590BF0DE0429F00D0D64B /* NSNumber+Units.h */; settings = {ATTRIBUTES = (Public, ); }; }; 784590C20DE0429F00D0D64B /* NSNumber+Units.m in Sources */ = {isa = PBXBuildFile; fileRef = 784590C00DE0429F00D0D64B /* NSNumber+Units.m */; }; DAAEFC9B0DA5722F0051E0D0 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; }; DAAEFD4E0DA572330051E0D0 /* relaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 613242130CD06CEF00106AA4 /* relaunch.m */; }; @@ -161,6 +167,11 @@ 610134760DD252E60049ACDF /* NSWorkspace+SystemVersion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSWorkspace+SystemVersion.m"; sourceTree = ""; }; 610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbingUpdateDriver.h; sourceTree = ""; }; 6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUProbingUpdateDriver.m; sourceTree = ""; }; + 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPipedUnarchiver.h; sourceTree = ""; }; + 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDiskImageUnarchiver.h; sourceTree = ""; }; + 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDiskImageUnarchiver.m; sourceTree = ""; }; + 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiver_Private.h; sourceTree = ""; }; + 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUnarchiver_Private.m; sourceTree = ""; }; 61072EB20DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkReleaseGCSupport.xcconfig; sourceTree = ""; }; 610D5A740A1670A4004AAD9C /* SUStatus.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = SUStatus.nib; sourceTree = ""; }; 610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTSynchronousTask.m; sourceTree = ""; }; @@ -184,6 +195,7 @@ 61299A8B09CA790200B7442F /* SUUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiver.h; sourceTree = ""; }; 61299A8C09CA790200B7442F /* SUUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUnarchiver.m; sourceTree = ""; }; 61299B3509CB04E000B7442F /* Sparkle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sparkle.h; sourceTree = ""; }; + 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPipedUnarchiver.m; sourceTree = ""; }; 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdatePermissionPrompt.h; sourceTree = ""; }; 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdatePermissionPrompt.m; sourceTree = ""; }; 613242130CD06CEF00106AA4 /* relaunch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = relaunch.m; sourceTree = ""; }; @@ -394,6 +406,12 @@ children = ( 61299A8B09CA790200B7442F /* SUUnarchiver.h */, 61299A8C09CA790200B7442F /* SUUnarchiver.m */, + 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */, + 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */, + 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */, + 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */, + 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */, + 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */, 610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */, 610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */, ); @@ -600,6 +618,9 @@ 61699BCC0DDB92BD005878A4 /* SUVersionComparisonTest.h in Headers */, 784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */, 61A354550DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h in Headers */, + 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */, + 6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */, + 6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -798,7 +819,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = "/usr/bin/env ruby"; - shellScript = "# Xcode auto-versioning script for Subversion\n# by Axel Andersson, modified by Daniel Jalkut to add\n# \"--revision HEAD\" to the svn info line, which allows\n# the latest revision to always be used.\n\nif ENV[\"BUILT_PRODUCTS_DIR\"].nil?\n\tSTDERR.print \"#{$0}: Must be run from Xcode!\"\n\texit(1)\nend\n\n# Get the current Bzr revision number and use it to set the CFBundleVersion value\nENV[\"PATH\"] = \"/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/opt/local/bin\"\nrev = `/usr/bin/env bzr revno`\nexit(0)\ninfo = \"#{ENV[\"BUILT_PRODUCTS_DIR\"]}/#{ENV[\"WRAPPER_NAME\"]}/Resources/Info.plist\"\nversion = rev[/[\\d.]+/]\n\nif version.nil?\n\tSTDERR.print \"#{$0}: Can't find a Bazaar revision!\"\n\texit(0)\nend\n\ninfo_contents = File.read(info)\nif info_contents.nil?\n\tSTDERR.print \"#{$0}: Can't read in the Info.plist file!\"\n\texit(1)\nend\n\ninfo_contents.sub!(/([\\t ]+CFBundleVersion<\\/key>\\n[\\t ]+).*?(<\\/string>)/, '\\1' + version + '\\2')\nSTDERR.print info_contents\nf = File.open(info, \"w\")\nf.write(info_contents)\nf.close"; + shellScript = "# Xcode auto-versioning script for Subversion\n# by Axel Andersson, modified by Daniel Jalkut to add\n# \"--revision HEAD\" to the svn info line, which allows\n# the latest revision to always be used.\n\nif ENV[\"BUILT_PRODUCTS_DIR\"].nil?\n\tSTDERR.print \"#{$0}: Must be run from Xcode!\"\n\texit(1)\nend\n\n# Get the current Bzr revision number and use it to set the CFBundleVersion value\nENV[\"PATH\"] = \"/bin:/sw/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/opt/local/bin\"\nrev = `/usr/bin/env bzr revno`\nexit(0)\ninfo = \"#{ENV[\"BUILT_PRODUCTS_DIR\"]}/#{ENV[\"WRAPPER_NAME\"]}/Resources/Info.plist\"\nversion = rev[/[\\d.]+/]\n\nif version.nil?\n\tSTDERR.print \"#{$0}: Can't find a Bazaar revision!\"\n\texit(0)\nend\n\ninfo_contents = File.read(info)\nif info_contents.nil?\n\tSTDERR.print \"#{$0}: Can't read in the Info.plist file!\"\n\texit(1)\nend\n\ninfo_contents.sub!(/([\\t ]+CFBundleVersion<\\/key>\\n[\\t ]+).*?(<\\/string>)/, '\\1' + version + '\\2')\nSTDERR.print info_contents\nf = File.open(info, \"w\")\nf.write(info_contents)\nf.close"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -859,6 +880,9 @@ 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */, 784590C20DE0429F00D0D64B /* NSNumber+Units.m in Sources */, 61A354560DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m in Sources */, + 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */, + 6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */, + 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1001,6 +1025,7 @@ 61072EAD0DF263BD008FE88B /* Release (GC dual-mode; 10.5-only) */ = { isa = XCBuildConfiguration; buildSettings = { + GCC_VERSION = ""; }; name = "Release (GC dual-mode; 10.5-only)"; }; diff --git a/de.lproj/Sparkle.strings b/de.lproj/Sparkle.strings index 098fcb31..a542ba02 100644 Binary files a/de.lproj/Sparkle.strings and b/de.lproj/Sparkle.strings differ diff --git a/en.lproj/SUUpdateAlert.nib/info.nib b/en.lproj/SUUpdateAlert.nib/info.nib index d9b82f55..778909ea 100644 --- a/en.lproj/SUUpdateAlert.nib/info.nib +++ b/en.lproj/SUUpdateAlert.nib/info.nib @@ -3,17 +3,17 @@ IBFramework Version - 649 + 667 IBLastKnownRelativeProjectPath ../Sparkle.xcodeproj IBOldestOS 5 IBOpenObjects - 6 + 89 IBSystem Version - 9C7010 + 9D34 targetFramework IBCocoaFramework diff --git a/en.lproj/SUUpdateAlert.nib/keyedobjects.nib b/en.lproj/SUUpdateAlert.nib/keyedobjects.nib index b3a80995..5b8f76e2 100644 Binary files a/en.lproj/SUUpdateAlert.nib/keyedobjects.nib and b/en.lproj/SUUpdateAlert.nib/keyedobjects.nib differ diff --git a/en.lproj/Sparkle.strings b/en.lproj/Sparkle.strings index 6a8d379a..6f7d5648 100644 Binary files a/en.lproj/Sparkle.strings and b/en.lproj/Sparkle.strings differ diff --git a/fr.lproj/SUAutomaticUpdateAlert.nib/classes.nib b/fr.lproj/SUAutomaticUpdateAlert.nib/classes.nib new file mode 100644 index 00000000..4b1ab30e --- /dev/null +++ b/fr.lproj/SUAutomaticUpdateAlert.nib/classes.nib @@ -0,0 +1,50 @@ + + + + + IBClasses + + + CLASS + SUWindowController + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + ACTIONS + + doNotInstall + id + installLater + id + installNow + id + + CLASS + SUAutomaticUpdateAlert + LANGUAGE + ObjC + SUPERCLASS + SUWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/fr.lproj/SUAutomaticUpdateAlert.nib/info.nib b/fr.lproj/SUAutomaticUpdateAlert.nib/info.nib new file mode 100644 index 00000000..33a60200 --- /dev/null +++ b/fr.lproj/SUAutomaticUpdateAlert.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBFramework Version + 629 + IBOldestOS + 5 + IBOpenObjects + + IBSystem Version + 9D34 + targetFramework + IBCocoaFramework + + diff --git a/fr.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib b/fr.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib new file mode 100644 index 00000000..4cd529a5 Binary files /dev/null and b/fr.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib differ diff --git a/fr.lproj/SUUpdateAlert.nib/classes.nib b/fr.lproj/SUUpdateAlert.nib/classes.nib new file mode 100644 index 00000000..994d4c36 --- /dev/null +++ b/fr.lproj/SUUpdateAlert.nib/classes.nib @@ -0,0 +1,67 @@ + + + + + IBClasses + + + CLASS + SUWindowController + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + CLASS + NSApplication + LANGUAGE + ObjC + SUPERCLASS + NSResponder + + + ACTIONS + + installUpdate + id + remindMeLater + id + skipThisVersion + id + + CLASS + SUUpdateAlert + LANGUAGE + ObjC + OUTLETS + + delegate + id + description + NSTextField + releaseNotesView + WebView + + SUPERCLASS + SUWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/fr.lproj/SUUpdateAlert.nib/info.nib b/fr.lproj/SUUpdateAlert.nib/info.nib new file mode 100644 index 00000000..3f097908 --- /dev/null +++ b/fr.lproj/SUUpdateAlert.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 629 + IBOldestOS + 5 + IBOpenObjects + + 6 + + IBSystem Version + 9D34 + targetFramework + IBCocoaFramework + + diff --git a/fr.lproj/SUUpdateAlert.nib/keyedobjects.nib b/fr.lproj/SUUpdateAlert.nib/keyedobjects.nib new file mode 100644 index 00000000..f5b43acf Binary files /dev/null and b/fr.lproj/SUUpdateAlert.nib/keyedobjects.nib differ diff --git a/fr.lproj/SUUpdatePermissionPrompt.nib/classes.nib b/fr.lproj/SUUpdatePermissionPrompt.nib/classes.nib new file mode 100644 index 00000000..5220a221 --- /dev/null +++ b/fr.lproj/SUUpdatePermissionPrompt.nib/classes.nib @@ -0,0 +1,59 @@ + + + + + IBClasses + + + CLASS + SUWindowController + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + ACTIONS + + finishPrompt + id + toggleMoreInfo + id + + CLASS + SUUpdatePermissionPrompt + LANGUAGE + ObjC + OUTLETS + + delegate + id + descriptionTextField + NSTextField + moreInfoButton + NSButton + moreInfoView + NSView + + SUPERCLASS + SUWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/fr.lproj/SUUpdatePermissionPrompt.nib/info.nib b/fr.lproj/SUUpdatePermissionPrompt.nib/info.nib new file mode 100644 index 00000000..33a60200 --- /dev/null +++ b/fr.lproj/SUUpdatePermissionPrompt.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBFramework Version + 629 + IBOldestOS + 5 + IBOpenObjects + + IBSystem Version + 9D34 + targetFramework + IBCocoaFramework + + diff --git a/fr.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib b/fr.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib new file mode 100644 index 00000000..b2b2cf2c Binary files /dev/null and b/fr.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib differ diff --git a/fr.lproj/Sparkle.strings b/fr.lproj/Sparkle.strings index 9d9ac091..a8c73c39 100644 Binary files a/fr.lproj/Sparkle.strings and b/fr.lproj/Sparkle.strings differ diff --git a/relaunch.m b/relaunch.m index be65c539..ce90ad99 100644 --- a/relaunch.m +++ b/relaunch.m @@ -16,35 +16,27 @@ - (id) initWithExecutablePath:(const char *)execPath parentProcessId:(pid_t)ppid { self = [super init]; - if (self != nil) { + if (self != nil) + { executablePath = execPath; parentProcessId = ppid; - - [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationDidTerminate:) name:NSWorkspaceDidTerminateApplicationNotification object:nil]; - if (getppid() == 1) { - // ppid is launchd (1) => parent terminated already + if (getppid() == 1) // ppid is launchd (1) => parent terminated already [self relaunch]; - } - - ProcessSerialNumber psn; - if (GetProcessForPID(ppid, &psn) == procNotFound) { - [self relaunch]; - } + [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(watchdog:) userInfo:nil repeats:YES]; } return self; } -- (void) applicationDidTerminate:(NSNotification *)notification +- (void)watchdog:(NSTimer *)timer { - if (parentProcessId == [[[notification userInfo] valueForKey:@"NSApplicationProcessIdentifier"] intValue]) { - // parent just terminated + ProcessSerialNumber psn; + if (GetProcessForPID(parentProcessId, &psn) == procNotFound) [self relaunch]; - } } - (void) relaunch { - [[NSWorkspace sharedWorkspace] launchApplication:[NSString stringWithUTF8String:executablePath]]; + [[NSWorkspace sharedWorkspace] openFile:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:executablePath length:strlen(executablePath)]]; [[NSFileManager defaultManager] removeFileAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"relaunch"] handler:nil]; exit(0); } @@ -61,7 +53,7 @@ int main (int argc, const char * argv[]) [[[TerminationListener alloc] initWithExecutablePath:argv[1] parentProcessId:atoi(argv[2])] autorelease]; [[NSApplication sharedApplication] run]; - [pool release]; + [pool drain]; return EXIT_SUCCESS; }