Add Sparkle update framework
[GitX.git] / Sparkle.framework / Versions / A / Headers / SUUpdater.h
blobb3241a3252d94263a233628b6d911ab85f34b32e
1 //
2 // SUUpdater.h
3 // Sparkle
4 //
5 // Created by Andy Matuschak on 1/4/06.
6 // Copyright 2006 Andy Matuschak. All rights reserved.
7 //
9 #ifndef SUUPDATER_H
10 #define SUUPDATER_H
12 #import <Sparkle/SUVersionComparisonProtocol.h>
14 @class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
15 @interface SUUpdater : NSObject {
16 NSTimer *checkTimer;
17 SUUpdateDriver *driver;
19 SUHost *host;
20 IBOutlet id delegate;
23 + (SUUpdater *)sharedUpdater;
24 + (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
25 - (NSBundle *)hostBundle;
27 - (void)setDelegate:(id)delegate;
28 - delegate;
30 - (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecks;
31 - (BOOL)automaticallyChecksForUpdates;
33 - (void)setUpdateCheckInterval:(NSTimeInterval)interval;
34 - (NSTimeInterval)updateCheckInterval;
36 - (void)setFeedURL:(NSURL *)feedURL;
37 - (NSURL *)feedURL;
39 // This IBAction is meant for a main menu item. Hook up any menu item to this action,
40 // and Sparkle will check for updates and report back its findings verbosely.
41 - (IBAction)checkForUpdates:sender;
43 // This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
44 // in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
45 // update is found, it will be downloaded and prepped for installation.
46 - (void)checkForUpdatesInBackground;
48 // This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
49 // (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
50 - (void)checkForUpdateInformation;
52 // Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks.
53 - (void)resetUpdateCycle;
55 - (BOOL)updateInProgress;
56 @end
58 @interface NSObject (SUUpdaterDelegateInformalProtocol)
59 // 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.
60 - (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
62 // Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
63 - (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
65 // Implement this if you want to do some special handling with the appcast once it finishes loading.
66 - (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
68 // If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
69 // a valid update, if any, in the given appcast.
70 - (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)bundle;
72 // Sent when a valid update is found by the update driver.
73 - (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update;
75 // Sent when a valid update is not found.
76 - (void)updaterDidNotFindUpdate:(SUUpdater *)update;
78 // Sent immediately before installing the specified update.
79 - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
81 // Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
82 - (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
84 // Called immediately before relaunching.
85 - (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
87 // This method allows you to provide a custom version comparator.
88 // If you don't implement this method or return nil, the standard version comparator will be used.
89 - (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
91 // Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
92 - (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
94 @end
96 // Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
97 #ifdef DEBUG
98 #define SU_MIN_CHECK_INTERVAL 60
99 #else
100 #define SU_MIN_CHECK_INTERVAL 60*60
101 #endif
103 #ifdef DEBUG
104 #define SU_DEFAULT_CHECK_INTERVAL 60
105 #else
106 #define SU_DEFAULT_CHECK_INTERVAL 60*60*24
107 #endif
109 #endif