mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Added additional delegate methods.
This commit is contained in:
1 parent
d487361cb9
commit
d5d9824b6c
5 files changed
+57
-20
No files matched your search
+27
-16
@@ -62,22 +62,33 @@ static NSString * const kSUAutomaticUpdateParamName = @"autoupdate";
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
{
|
||||
showErrors = YES;
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host: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
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([host isBackgroundApplication])
|
||||
{
|
||||
[[alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([NSApp isActive])
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
BOOL canAutomaticallyInstallUpdate = NO;
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:canAutomaticallyInstallUpdate:)])
|
||||
canAutomaticallyInstallUpdate = [[updater delegate] updater:updater canAutomaticallyInstallUpdate:updateItem];
|
||||
|
||||
if (!canAutomaticallyInstallUpdate)
|
||||
{
|
||||
showErrors = YES;
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host: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
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([host isBackgroundApplication])
|
||||
{
|
||||
[[alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([NSApp isActive])
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self automaticUpdateAlert:nil finishedWithChoice:SUInstallNowChoice];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
|
||||
+23
-2
@@ -393,6 +393,10 @@ NSArray *SUGetAllDevMateURLHosts(void)
|
||||
if (SUFinishUpdateAbort == finishTasks)
|
||||
{
|
||||
[self abortUpdate:SUUpdateAbortTasksFinished];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didInstallUpdate:)])
|
||||
[[updater delegate] updater:updater didInstallUpdate:updateItem];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,17 +471,34 @@ NSArray *SUGetAllDevMateURLHosts(void)
|
||||
|
||||
if (SUShouldUseXPCInstaller())
|
||||
{
|
||||
[SUXPCInstaller launchTaskWithLaunchPath:relaunchToolPath arguments:arguments];
|
||||
[SUXPCInstaller launchTaskWithPath:relaunchToolPath
|
||||
arguments:arguments
|
||||
environment:nil
|
||||
currentDirectoryPath:nil
|
||||
inputData:nil
|
||||
waitForTaskResult:!shouldFinishUpdateWithRelaunch
|
||||
waitUntilDone:YES
|
||||
completionHandler:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:arguments];
|
||||
NSTask *task = [NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:arguments];
|
||||
|
||||
if (!shouldFinishUpdateWithRelaunch)
|
||||
[task waitUntilExit];
|
||||
}
|
||||
|
||||
if (shouldFinishUpdateWithRelaunch)
|
||||
{
|
||||
[NSApp terminate:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self abortUpdate:SUUpdateAbortTasksFinished];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didInstallUpdate:)])
|
||||
[[updater delegate] updater:updater didInstallUpdate:updateItem];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cleanUpDownload
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ typedef NS_ENUM(NSUInteger, SUUpdateAbortReason)
|
||||
{
|
||||
SUUpdateAbortUndefined = 0,
|
||||
SUUpdateAbortForbiddenByDelegate,
|
||||
SUUpdateAbortTasksFinished, // installed and relaunched by delegate
|
||||
SUUpdateAbortTasksFinished,
|
||||
SUUpdateAbortCanceledByUser,
|
||||
SUUpdateAbortDidNotFind,
|
||||
SUUpdateAbortGotError
|
||||
|
||||
@@ -109,9 +109,15 @@
|
||||
// Sent when a valid update is not found.
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)update;
|
||||
|
||||
// For cases when updater automatically downloads updates
|
||||
- (BOOL)updater:(SUUpdater *)updater canAutomaticallyInstallUpdate:(SUAppcastItem *)update;
|
||||
|
||||
// Sent immediately before installing the specified update.
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
|
||||
|
||||
// Sent immediately after installing the specified update in case when relaunch was forbidden.
|
||||
- (void)updater:(SUUpdater *)updater didInstallUpdate:(SUAppcastItem *)update;
|
||||
|
||||
// Override to handle update manually
|
||||
- (BOOL)updater:(SUUpdater *)updater overrideInstallUpdate:(SUAppcastItem *)update downloadPath:(NSString *)downloadPath shouldRelaunch:(BOOL *)outShouldRelaunch;
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
- (id)initForBundle:(NSBundle *)bundle;
|
||||
- (void)startUpdateCycle;
|
||||
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
|
||||
- (BOOL)automaticallyDownloadsUpdates;
|
||||
- (void)scheduleNextUpdateCheck;
|
||||
- (void)registerAsObserver;
|
||||
- (void)unregisterAsObserver;
|
||||
|
||||
Reference in new issue
Block a user