Skip to content

Commit

Permalink
merged with trunk & updated german localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik authored and Dominik committed Jun 24, 2008
2 parents 17a5bf2 + f425746 commit 70e0924
Show file tree
Hide file tree
Showing 42 changed files with 709 additions and 241 deletions.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en_US</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
Expand Down
6 changes: 1 addition & 5 deletions NSFileManager+Authentication.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ - (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst erro
// 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
Expand Down
7 changes: 2 additions & 5 deletions NSWorkspace_RBAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,8 @@ - (NSDictionary*)propertiesForPath:(NSString*)path {
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) {
Expand Down
2 changes: 1 addition & 1 deletion NTSynchronousTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ + (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withAr
NS_HANDLER;
NS_ENDHANDLER;

[pool release];
[pool drain];

// retained above
[result autorelease];
Expand Down
9 changes: 7 additions & 2 deletions RSS.m
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ - (void)connection:(NSURLConnection*) connection didFailWithError:(NSError *)err
[delegate feed:self didFailWithError:error];
}

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{
return request;
}

- (NSDictionary *) headerItems {

return (headerItems);
Expand Down Expand Up @@ -580,7 +585,7 @@ - (void) normalizeRSSItem: (NSMutableDictionary *) rssItem {

shortTitle = [shortTitle trimWhiteSpace];

title = [NSString stringWithFormat: @"%@...", shortTitle];
title = [NSString stringWithFormat: @"%@\u2026", shortTitle];
} /*else*/
} /*if*/

Expand All @@ -604,7 +609,7 @@ - (void) normalizeRSSItem: (NSMutableDictionary *) rssItem {

[rssItem setObject: description forKey: descriptionKey];

title = [NSString stringWithFormat: @"%@...", shortTitle];
title = [NSString stringWithFormat: @"%@\u2026", shortTitle];

[rssItem setObject: title forKey: titleKey];
} /*if*/
Expand Down
21 changes: 11 additions & 10 deletions SUAppcast.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,23 @@ - (void)fetchAppcastFromURL:(NSURL *)url
- (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);
}

Expand All @@ -72,8 +70,11 @@ - (void)reportError:(NSError *)error

- (void)setUserAgentString:(NSString *)uas
{
[userAgentString release];
userAgentString = [uas copy];
if (uas != userAgentString)
{
[userAgentString release];
userAgentString = [uas copy];
}
}

- (void)setDelegate:del
Expand Down
9 changes: 9 additions & 0 deletions SUAppcastItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ - (NSString *)title { return [[title retain] autorelease]; }

- (void)setTitle:(NSString *)aTitle
{
if (title == aTitle) return;
[title release];
title = [aTitle copy];
}
Expand All @@ -26,6 +27,7 @@ - (NSDate *)date { return [[date retain] autorelease]; }

- (void)setDate:(NSDate *)aDate
{
if (date == aDate) return;
[date release];
date = [aDate copy];
}
Expand All @@ -35,6 +37,7 @@ - (NSString *)description { return [[description retain] autorelease]; }

- (void)setDescription:(NSString *)aDescription
{
if (description == aDescription) return;
[description release];
description = [aDescription copy];
}
Expand All @@ -44,6 +47,7 @@ - (NSURL *)releaseNotesURL { return [[releaseNotesURL retain] autorelease]; }

- (void)setReleaseNotesURL:(NSURL *)aReleaseNotesURL
{
if (releaseNotesURL == aReleaseNotesURL) return;
[releaseNotesURL release];
releaseNotesURL = [aReleaseNotesURL copy];
}
Expand All @@ -53,6 +57,7 @@ - (NSString *)DSASignature { return [[DSASignature retain] autorelease]; }

- (void)setDSASignature:(NSString *)aDSASignature
{
if (DSASignature == aDSASignature) return;
[DSASignature release];
DSASignature = [aDSASignature copy];
}
Expand All @@ -62,6 +67,7 @@ - (NSURL *)fileURL { return [[fileURL retain] autorelease]; }

- (void)setFileURL:(NSURL *)aFileURL
{
if (fileURL == aFileURL) return;
[fileURL release];
fileURL = [aFileURL copy];
}
Expand All @@ -71,6 +77,7 @@ - (NSString *)versionString { return [[versionString retain] autorelease]; }

- (void)setVersionString:(NSString *)s
{
if (versionString == s) return;
[versionString release];
versionString = [s copy];
}
Expand All @@ -80,6 +87,7 @@ - (NSString *)displayVersionString { return [[displayVersionString retain] autor

- (void)setDisplayVersionString:(NSString *)s
{
if (displayVersionString == s) return;
[displayVersionString release];
displayVersionString = [s copy];
}
Expand All @@ -88,6 +96,7 @@ - (void)setDisplayVersionString:(NSString *)s
- (NSString *)minimumSystemVersion { return [[minimumSystemVersion retain] autorelease]; }
- (void)setMinimumSystemVersion:(NSString *)systemVersionString
{
if (minimumSystemVersion == systemVersionString) return;
[minimumSystemVersion release];
minimumSystemVersion = [systemVersionString copy];
}
Expand Down
5 changes: 2 additions & 3 deletions SUAutomaticUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ - (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
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];
}

Expand Down Expand Up @@ -62,7 +62,6 @@ - (void)applicationWillTerminate:(NSNotification *)note
- (void)installerFinishedForHostBundle:(NSBundle *)hb
{
if (hb != hostBundle) { return; }
[unarchiver cleanUp];
if (!postponingInstallation)
[self relaunchHostApp];
}
Expand Down
2 changes: 0 additions & 2 deletions SUBasicUpdateDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
NSURLDownload *download;
NSString *downloadPath;

SUUnarchiver *unarchiver;

NSString *relaunchPath;
}

Expand Down
16 changes: 11 additions & 5 deletions SUBasicUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,27 @@ - (void)extractUpdate
}
}

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]]];
}

Expand All @@ -197,7 +206,6 @@ - (void)installUpdate
- (void)installerFinishedForHostBundle:(NSBundle *)hb
{
if (hb != hostBundle) { return; }
[unarchiver cleanUp];
[self relaunchHostApp];
}

Expand Down Expand Up @@ -262,8 +270,6 @@ - (void)dealloc
[hostBundle release];
[downloadPath release];
[relaunchPath release];
[unarchiver release];
[download release];
[super dealloc];
}

Expand Down
20 changes: 20 additions & 0 deletions SUDiskImageUnarchiver.h
Original file line number Diff line number Diff line change
@@ -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 <Cocoa/Cocoa.h>
#import "SUUnarchiver.h"

@interface SUDiskImageUnarchiver : SUUnarchiver {
}

@end

#endif
79 changes: 79 additions & 0 deletions SUDiskImageUnarchiver.m
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions SUPipedUnarchiver.h
Original file line number Diff line number Diff line change
@@ -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 <Cocoa/Cocoa.h>
#import "SUUnarchiver.h"

@interface SUPipedUnarchiver : SUUnarchiver {

}

@end

#endif
Loading

0 comments on commit 70e0924

Please sign in to comment.