mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
- changed some #include to #import - fixed some NULL -> nil Cocoa coding conventions - added new compiler warnings and fixed some warnings they generated - check for nil from NSTemporaryDirectory - added missing files to unit test and test app targets - added xcconfig files for unit test target - added @private to some ivars - changes some variables from signed to unsigned as appropriate - changed from base 2 to base 10 measurements of file size, consistent with both the actual meaning of metric prefixes and Apple's new policy as of 10.6 - reduced some unneeded copy-paste of code - fixed failure to check for null from malloc and unneeded check against null before calling free - OSErr was incorrectly used instead of OSStatus - added some consts & statics to global strings - fixed some issues discovered by static analysis - fixed some 64bit issues, mostly related to casting and the use of slightly incorrect types/sizes - some dealloc methods were using accessors, changed to access ivars directly, as per Apple guidelines - removed old NS_DURING, NS_HANDLER, NS_ENDHANDLER macros - fixed a bug where immutable data was being mutated - removed all instance of "== YES" as they are dangerous - removed some redundant nil checks - fixed some leaks - conditionally replaced deprecated method usage - cleanup CF/NSMakeCollectable usage - fixed bug in GC where memory could be collected too early due to lack of strong references when using UTF8String - prevent passing null to CFRelease
89 lines
2.1 KiB
Objective-C
89 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 "SUStatusController.h"
|
|
#import "SUHost.h"
|
|
|
|
@implementation SUUserInitiatedUpdateDriver
|
|
|
|
- (void)checkForUpdatesAtURL:(NSURL *)URL 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...", nil) maxProgressValue:0.0 statusText:nil];
|
|
[checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
|
[checkingController showWindow:self];
|
|
[super checkForUpdatesAtURL:URL host:aHost];
|
|
|
|
// For background applications, obtain focus.
|
|
// Useful if the update check is requested from another app like System Preferences.
|
|
if ([aHost 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
|