mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Fixes from Matt Stevens: "For background applications (menu bar, completely UI-less, etc) there are a couple of issues with Sparkle notifications: - When prompts such as the initial prompt to enable update checking are displayed they can be hidden behind other windows since the background app is not in focus. This can cause problems, as these prompts run modally and can stop the application from functioning without the user knowing why. - If the update notification window is displayed and the user clicks away to another application, the window disappears and there is no way to get it back since there is no other UI to cause the app to activate. In this case the update should probably operate as a standard window since it is effectively operating as the application's UI."
87 lines
2.1 KiB
Objective-C
87 lines
2.1 KiB
Objective-C
//
|
|
// SUUserInitiatedUpdateDriver.m
|
|
// Sparkle
|
|
//
|
|
// Created by Andy Matuschak on 5/30/08.
|
|
// Copyright 2008 Andy Matuschak. All rights reserved.
|
|
//
|
|
|
|
#import "SUUserInitiatedUpdateDriver.h"
|
|
#import "Sparkle.h"
|
|
|
|
@implementation SUUserInitiatedUpdateDriver
|
|
|
|
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)aHost
|
|
{
|
|
checkingController = [[SUStatusController alloc] initWithHost:aHost];
|
|
[[checkingController window] center]; // Force the checking controller to load its window.
|
|
[checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates\u2026", nil) maxProgressValue:0 statusText:nil];
|
|
[checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
|
[checkingController showWindow:self];
|
|
[super checkForUpdatesAtURL:appcastURL host:host];
|
|
|
|
// For background applications, obtain focus.
|
|
// Useful if the update check is requested from another app like System Preferences.
|
|
if ([host isBackgroundApplication])
|
|
{
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
}
|
|
}
|
|
|
|
- (void)closeCheckingWindow
|
|
{
|
|
if (checkingController)
|
|
{
|
|
[[checkingController window] close];
|
|
[checkingController release];
|
|
checkingController = nil;
|
|
}
|
|
}
|
|
|
|
- (void)cancelCheckForUpdates:sender
|
|
{
|
|
[self closeCheckingWindow];
|
|
isCanceled = YES;
|
|
}
|
|
|
|
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
|
{
|
|
if (isCanceled)
|
|
{
|
|
[self abortUpdate];
|
|
return;
|
|
}
|
|
[self closeCheckingWindow];
|
|
[super appcastDidFinishLoading:ac];
|
|
}
|
|
|
|
- (void)abortUpdateWithError:(NSError *)error
|
|
{
|
|
[self closeCheckingWindow];
|
|
[super abortUpdateWithError:error];
|
|
}
|
|
|
|
- (void)abortUpdate
|
|
{
|
|
[self closeCheckingWindow];
|
|
[super abortUpdate];
|
|
}
|
|
|
|
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
|
|
{
|
|
if (isCanceled)
|
|
{
|
|
[self abortUpdate];
|
|
return;
|
|
}
|
|
[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.
|
|
return [self hostSupportsItem:ui] && [self isItemNewer:ui];
|
|
}
|
|
|
|
@end
|