Skip to content

Commit

Permalink
Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
Browse files Browse the repository at this point in the history
…Sparkle. More super-unstable refactorings to come...
  • Loading branch information
andymatuschak committed Jul 16, 2008
1 parent f4c6738 commit 98832c4
Show file tree
Hide file tree
Showing 35 changed files with 526 additions and 546 deletions.
59 changes: 0 additions & 59 deletions NSBundle+SUAdditions.h

This file was deleted.

89 changes: 0 additions & 89 deletions NSBundle+SUAdditions.m

This file was deleted.

6 changes: 3 additions & 3 deletions SUAutomaticUpdateAlert.h
Expand Up @@ -18,14 +18,14 @@ typedef enum
SUDoNotInstallChoice
} SUAutomaticInstallationChoice;

@class SUAppcastItem;
@class SUAppcastItem, SUHost;
@interface SUAutomaticUpdateAlert : SUWindowController {
SUAppcastItem *updateItem;
id delegate;
NSBundle *hostBundle;
SUHost *host;
}

- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hostBundle delegate:delegate;
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle delegate:delegate;
- (IBAction)installNow:sender;
- (IBAction)installLater:sender;
- (IBAction)doNotInstall:sender;
Expand Down
14 changes: 7 additions & 7 deletions SUAutomaticUpdateAlert.m
Expand Up @@ -11,14 +11,14 @@

@implementation SUAutomaticUpdateAlert

- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb delegate:del;
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hb delegate:del;
{
self = [super initWithHostBundle:hb windowNibName:@"SUAutomaticUpdateAlert"];
self = [super initWithHost:hb windowNibName:@"SUAutomaticUpdateAlert"];
if (self)
{
updateItem = [item retain];
delegate = del;
hostBundle = [hb retain];
host = [hb retain];
[self setShouldCascadeWindows:NO];
[[self window] center];
}
Expand All @@ -27,7 +27,7 @@ - (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb delega

- (void)dealloc
{
[hostBundle release];
[host release];
[updateItem release];
[super dealloc];
}
Expand All @@ -53,17 +53,17 @@ - (IBAction)doNotInstall:sender

- (NSImage *)applicationIcon
{
return [hostBundle icon];
return [host icon];
}

- (NSString *)titleText
{
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [hostBundle name]];
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [host name]];
}

- (NSString *)descriptionText
{
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [hostBundle name], [hostBundle displayVersion]];
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [host name], [host displayVersion]];
}

@end
8 changes: 4 additions & 4 deletions SUAutomaticUpdateDriver.m
Expand Up @@ -13,7 +13,7 @@ @implementation SUAutomaticUpdateDriver

- (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem hostBundle:hostBundle delegate:self];
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
if ([NSApp isActive])
[[alert window] makeKeyAndOrderFront:self];
else
Expand All @@ -40,7 +40,7 @@ - (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(S
break;

case SUDoNotInstallChoice:
[[SUUserDefaults standardUserDefaults] setObject:[updateItem versionString] forKey:SUSkippedVersionKey];
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
[self abortUpdate];
break;
}
Expand All @@ -59,9 +59,9 @@ - (void)applicationWillTerminate:(NSNotification *)note
[self installUpdate];
}

- (void)installerFinishedForHostBundle:(NSBundle *)hb
- (void)installerFinishedForHost:(SUHost *)aHost
{
if (hb != hostBundle) { return; }
if (aHost != host) { return; }
if (!postponingInstallation)
[self relaunchHostApp];
}
Expand Down
9 changes: 4 additions & 5 deletions SUBasicUpdateDriver.h
Expand Up @@ -12,9 +12,8 @@
#import <Cocoa/Cocoa.h>
#import "SUUpdateDriver.h"

@class SUAppcastItem, SUUnarchiver, SUAppcast, SUUnarchiver;
@class SUAppcastItem, SUUnarchiver, SUAppcast, SUUnarchiver, SUHost;
@interface SUBasicUpdateDriver : SUUpdateDriver {
NSBundle *hostBundle;
SUAppcastItem *updateItem;

NSURLDownload *download;
Expand All @@ -23,7 +22,7 @@
NSString *relaunchPath;
}

- (void)checkForUpdatesAtURL:(NSURL *)appcastURL hostBundle:(NSBundle *)hb;
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)hb;

- (void)appcastDidFinishLoading:(SUAppcast *)ac;
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error;
Expand All @@ -45,8 +44,8 @@
- (void)unarchiverDidFail:(SUUnarchiver *)ua;

- (void)installUpdate;
- (void)installerFinishedForHostBundle:(NSBundle *)hb;
- (void)installerForHostBundle:(NSBundle *)hb failedWithError:(NSError *)error;
- (void)installerFinishedForHost:(SUHost *)hb;
- (void)installerForHost:(SUHost *)hb failedWithError:(NSError *)error;

- (void)relaunchHostApp;
- (void)cleanUp;
Expand Down

0 comments on commit 98832c4

Please sign in to comment.