5 // Created by Andy Matuschak on 1/4/06.
6 // Copyright 2006 Andy Matuschak. All rights reserved.
12 #import "SUUpdateAlert.h"
13 #import "SUVersionComparisonProtocol.h"
15 @
class SUUpdateDriver
, SUAppcastItem
, SUAppcast
;
16 @interface SUUpdater
: NSObject
{
18 SUUpdateDriver
*driver
;
24 + (SUUpdater
*)sharedUpdater
;
26 - (void)setDelegate
:(id
)delegate
;
28 // This IBAction is meant for a main menu item. Hook up any menu item to this action,
29 // and Sparkle will check for updates and report back its findings verbosely.
30 - (IBAction
)checkForUpdates
:sender
;
32 // This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
33 // in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
34 // update is found, it will be downloaded and prepped for installation.
35 - (void)checkForUpdatesInBackground
;
37 // This forces an update to begin with a particular driver (see SU*UpdateDriver.h)
38 - (void)checkForUpdatesWithDriver
:(SUUpdateDriver
*)driver
;
40 // For non-.app updates:
41 // Call this when your bundle is loaded to tell Sparkle what to update.
42 - (void)setHostBundle
:(NSBundle
*)hostBundle
;
44 // Call this to appropriately reschedule or cancel the update checking timer if preferences for time interval or automatic checks change.
45 // If you're using a .app, this'll be picked up automatically via NSUserDefaultsController, but for non-.apps, there's no way to observe changes.
46 - (void)updatePreferencesChanged
;
48 - (BOOL
)updateInProgress
;
51 @interface
NSObject (SUUpdaterDelegateInformalProtocol
)
52 // This method allows you to add extra parameters to the appcast URL, potentially based on whether or not
53 // Sparkle will also be sending along the system profile. This method should return an array of dictionaries with the following keys:
54 - (NSArray
*)feedParametersForHostBundle
:(NSBundle
*)bundle sendingSystemProfile
:(BOOL
)sendingProfile
;
56 // Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
57 - (BOOL
)shouldPromptForPermissionToCheckForUpdatesToHostBundle
:(NSBundle
*)bundle
;
59 // Implement this if you want to do some special handling with the appcast once it finishes loading.
60 - (void)appcastDidFinishLoading
:(SUAppcast
*)appcast forHostBundle
:(NSBundle
*)bundle
;
62 // If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
63 // a valid update, if any, in the given appcast.
64 - (SUAppcastItem
*)bestValidUpdateInAppcast
:(SUAppcast
*)appcast forHostBundle
:(NSBundle
*)bundle
;
66 // Sent when a valid update is found by the update driver.
67 - (void)didFindValidUpdate
:(SUAppcastItem
*)update toHostBundle
:(NSBundle
*)bundle
;
69 // Sent when a valid update is not found.
70 - (void)didNotFindUpdateToHostBundle
:(NSBundle
*)hb
;
72 // Sent when the user makes a choice in the update alert dialog (install now / remind me later / skip this version).
73 - (void)userChoseAction
:(SUUpdateAlertChoice
)action forUpdate
:(SUAppcastItem
*)update toHostBundle
:(NSBundle
*)bundle
;
75 // Sent immediately before installing the specified update.
76 - (void)updateWillInstall
:(SUAppcastItem
*)update toHostBundle
:(NSBundle
*)bundle
;
78 // Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
79 - (BOOL
)shouldPostponeRelaunchForUpdate
:(SUAppcastItem
*)update toHostBundle
:(NSBundle
*)hostBundle untilInvoking
:(NSInvocation
*)invocation
;
81 // Called immediately before relaunching.
82 - (void)updaterWillRelaunchApplication
;
84 // This method allows you to provide a custom version comparator.
85 // If you don't implement this method or return nil, the standard version comparator will be used.
86 - (id
<SUVersionComparison
>)versionComparatorForHostBundle
:(NSBundle
*)hb
;
90 // Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
92 #define SU_MIN_CHECK_INTERVAL 60
94 #define SU_MIN_CHECK_INTERVAL 60*60
98 #define SU_DEFAULT_CHECK_INTERVAL 60
100 #define SU_DEFAULT_CHECK_INTERVAL 60*60*24