6
6
// Copyright 2006 Andy Matuschak. All rights reserved.
9
#import <Cocoa/Cocoa.h>
11
// Before you use Sparkle in your app, you must set SUFeedURL in Info.plist to the
12
// address of the appcast on your webserver. If you don't already have an
13
// appcast, please see the Sparkle documentation to learn about how to set one up.
15
// .zip, .dmg, .tar, .tbz, .tgz archives are supported at this time.
17
// By default, Sparkle offers to show the user the release notes of the build they'll be
18
// getting, which it assumes are in the description (or body) field of the relevant RSS item.
19
// Set SUShowReleaseNotes to <false/> in Info.plist to hide the button.
21
@class SUAppcastItem, SUUpdateAlert, SUStatusController;
12
#import <Sparkle/SUVersionComparisonProtocol.h>
14
@class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
22
15
@interface SUUpdater : NSObject {
23
SUAppcastItem *updateItem;
25
SUStatusController *statusController;
26
SUUpdateAlert *updateAlert;
28
NSURLDownload *downloader;
29
NSString *downloadPath;
31
16
NSTimer *checkTimer;
32
NSTimeInterval checkInterval;
17
SUUpdateDriver *driver;
35
BOOL updateInProgress;
23
+ (SUUpdater *)sharedUpdater;
24
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
25
- (NSBundle *)hostBundle;
27
- (void)setDelegate:(id)delegate;
30
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecks;
31
- (BOOL)automaticallyChecksForUpdates;
33
- (void)setUpdateCheckInterval:(NSTimeInterval)interval;
34
- (NSTimeInterval)updateCheckInterval;
36
- (void)setFeedURL:(NSURL *)feedURL;
39
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile;
40
- (BOOL)sendsSystemProfile;
42
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates;
43
- (BOOL)automaticallyDownloadsUpdates;
38
45
// This IBAction is meant for a main menu item. Hook up any menu item to this action,
39
46
// and Sparkle will check for updates and report back its findings verbosely.
40
47
- (IBAction)checkForUpdates:sender;
42
// This method is similar to the above, but it's intended for updates initiated by
43
// the computer instead of by the user. It does not alert the user when he is up to date,
44
// and it remains silent about network errors in fetching the feed. This is what you
45
// want to call to update programmatically; only use checkForUpdates: with buttons and menu items.
49
// This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
50
// in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
51
// update is found, it will be downloaded and prepped for installation.
46
52
- (void)checkForUpdatesInBackground;
48
// This method allows you to schedule a check to run every time interval. You can
49
// pass 0 to this method to cancel a previously scheduled timer. You probably don't want
50
// to call this directly: if you set a SUScheduledCheckInterval key in Info.plist or
51
// the user defaults, Sparkle will set this up for you automatically on startup. You might
52
// just want to call this every time the user changes the setting in the preferences.
53
- (void)scheduleCheckWithInterval:(NSTimeInterval)interval;
b'\\ No newline at end of file'
54
// Date of last update check. Returns null if no check has been performed.
55
- (NSDate*)lastUpdateCheckDate;
57
// This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
58
// (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
59
- (void)checkForUpdateInformation;
61
// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer.
62
- (void)resetUpdateCycle;
64
- (BOOL)updateInProgress;
67
@interface NSObject (SUUpdaterDelegateInformalProtocol)
68
// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
69
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
71
// Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
72
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
74
// Implement this if you want to do some special handling with the appcast once it finishes loading.
75
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
77
// If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
78
// a valid update, if any, in the given appcast.
79
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)bundle;
81
// Sent when a valid update is found by the update driver.
82
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update;
84
// Sent when a valid update is not found.
85
- (void)updaterDidNotFindUpdate:(SUUpdater *)update;
87
// Sent immediately before installing the specified update.
88
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
90
// Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
91
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
93
// Called immediately before relaunching.
94
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
96
// This method allows you to provide a custom version comparator.
97
// If you don't implement this method or return nil, the standard version comparator will be used.
98
- (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
100
// Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
101
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
105
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
107
#define SU_MIN_CHECK_INTERVAL 60
109
#define SU_MIN_CHECK_INTERVAL 60*60
113
#define SU_DEFAULT_CHECK_INTERVAL 60
115
#define SU_DEFAULT_CHECK_INTERVAL 60*60*24