forked from sparkle-project/Sparkle
/
SUUserInitiatedUpdateDriver.m
68 lines (59 loc) · 1.7 KB
/
SUUserInitiatedUpdateDriver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// 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 hostBundle:(NSBundle *)hb
{
[super checkForUpdatesAtURL:appcastURL hostBundle:hb];
checkingController = [[SUStatusController alloc] initWithHostBundle:hb];
[checkingController window]; // 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];
}
- (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)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
{
if (isCanceled)
{
[self abortUpdate];
return;
}
[self closeCheckingWindow];
[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