Upgrade to Sparkle 1.21.3.
[macgdbp.git] / Sparkle.framework / Versions / A / Headers / SUUpdaterDelegate.h
1 //
2 // SUUpdaterDelegate.h
3 // Sparkle
4 //
5 // Created by Mayur Pawashe on 12/25/16.
6 // Copyright © 2016 Sparkle Project. All rights reserved.
7 //
8
9 #if __has_feature(modules)
10 @import Foundation;
11 #else
12 #import <Foundation/Foundation.h>
13 #endif
14
15 #import "SUExport.h"
16
17 @protocol SUVersionComparison, SUVersionDisplay;
18 @class SUUpdater, SUAppcast, SUAppcastItem;
19
20 NS_ASSUME_NONNULL_BEGIN
21
22 // -----------------------------------------------------------------------------
23 // SUUpdater Notifications for events that might be interesting to more than just the delegate
24 // The updater will be the notification object
25 // -----------------------------------------------------------------------------
26 SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
27 SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
28 SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
29 SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
30 #define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
31 #define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
32
33 // Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
34 SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
35 // Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
36 SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
37
38 // -----------------------------------------------------------------------------
39 // SUUpdater Delegate:
40 // -----------------------------------------------------------------------------
41
42 /*!
43 Provides methods to control the behavior of an SUUpdater object.
44 */
45 @protocol SUUpdaterDelegate <NSObject>
46 @optional
47
48 /*!
49 Returns whether to allow Sparkle to pop up.
50
51 For example, this may be used to prevent Sparkle from interrupting a setup assistant.
52
53 \param updater The SUUpdater instance.
54 */
55 - (BOOL)updaterMayCheckForUpdates:(SUUpdater *)updater;
56
57 /*!
58 Returns additional parameters to append to the appcast URL's query string.
59
60 This is potentially based on whether or not Sparkle will also be sending along the system profile.
61
62 \param updater The SUUpdater instance.
63 \param sendingProfile Whether the system profile will also be sent.
64
65 \return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
66 */
67 - (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
68
69 /*!
70 Returns a custom appcast URL.
71
72 Override this to dynamically specify the entire URL.
73
74 An alternative may be to use SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
75 and let the server handle what kind of feed to provide.
76
77 \param updater The SUUpdater instance.
78 */
79 - (nullable NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
80
81 /*!
82 Returns whether Sparkle should prompt the user about automatic update checks.
83
84 Use this to override the default behavior.
85
86 \param updater The SUUpdater instance.
87 */
88 - (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)updater;
89
90 /*!
91 Called after Sparkle has downloaded the appcast from the remote server.
92
93 Implement this if you want to do some special handling with the appcast once it finishes loading.
94
95 \param updater The SUUpdater instance.
96 \param appcast The appcast that was downloaded from the remote server.
97 */
98 - (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
99
100 /*!
101 Returns the item in the appcast corresponding to the update that should be installed.
102
103 If you're using special logic or extensions in your appcast,
104 implement this to use your own logic for finding a valid update, if any,
105 in the given appcast.
106
107 \param appcast The appcast that was downloaded from the remote server.
108 \param updater The SUUpdater instance.
109 */
110 - (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)updater;
111
112 /*!
113 Called when a valid update is found by the update driver.
114
115 \param updater The SUUpdater instance.
116 \param item The appcast item corresponding to the update that is proposed to be installed.
117 */
118 - (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
119
120 /*!
121 Called when a valid update is not found.
122
123 \param updater The SUUpdater instance.
124 */
125 - (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
126
127 /*!
128 Called immediately before downloading the specified update.
129
130 \param updater The SUUpdater instance.
131 \param item The appcast item corresponding to the update that is proposed to be downloaded.
132 \param request The mutable URL request that will be used to download the update.
133 */
134 - (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
135
136 /*!
137 Called immediately after succesfull download of the specified update.
138
139 \param updater The SUUpdater instance.
140 \param item The appcast item corresponding to the update that has been downloaded.
141 */
142 - (void)updater:(SUUpdater *)updater didDownloadUpdate:(SUAppcastItem *)item;
143
144 /*!
145 Called after the specified update failed to download.
146
147 \param updater The SUUpdater instance.
148 \param item The appcast item corresponding to the update that failed to download.
149 \param error The error generated by the failed download.
150 */
151 - (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
152
153 /*!
154 Called when the user clicks the cancel button while and update is being downloaded.
155
156 \param updater The SUUpdater instance.
157 */
158 - (void)userDidCancelDownload:(SUUpdater *)updater;
159
160 /*!
161 Called immediately before extracting the specified downloaded update.
162
163 \param updater The SUUpdater instance.
164 \param item The appcast item corresponding to the update that is proposed to be extracted.
165 */
166 - (void)updater:(SUUpdater *)updater willExtractUpdate:(SUAppcastItem *)item;
167
168 /*!
169 Called immediately after extracting the specified downloaded update.
170
171 \param updater The SUUpdater instance.
172 \param item The appcast item corresponding to the update that has been extracted.
173 */
174 - (void)updater:(SUUpdater *)updater didExtractUpdate:(SUAppcastItem *)item;
175
176 /*!
177 Called immediately before installing the specified update.
178
179 \param updater The SUUpdater instance.
180 \param item The appcast item corresponding to the update that is proposed to be installed.
181 */
182 - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
183
184 /*!
185 Returns whether the relaunch should be delayed in order to perform other tasks.
186
187 This is not called if the user didn't relaunch on the previous update,
188 in that case it will immediately restart.
189
190 \param updater The SUUpdater instance.
191 \param item The appcast item corresponding to the update that is proposed to be installed.
192 \param invocation The invocation that must be completed with `[invocation invoke]` before continuing with the relaunch.
193
194 \return \c YES to delay the relaunch until \p invocation is invoked.
195 */
196 - (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
197
198 /*!
199 Returns whether the application should be relaunched at all.
200
201 Some apps \b cannot be relaunched under certain circumstances.
202 This method can be used to explicitly prevent a relaunch.
203
204 \param updater The SUUpdater instance.
205 */
206 - (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
207
208 /*!
209 Called immediately before relaunching.
210
211 \param updater The SUUpdater instance.
212 */
213 - (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
214
215 /*!
216 Called immediately after relaunching. SUUpdater delegate must be set before applicationDidFinishLaunching: to catch this event.
217
218 \param updater The SUUpdater instance.
219 */
220 - (void)updaterDidRelaunchApplication:(SUUpdater *)updater;
221
222 /*!
223 Returns an object that compares version numbers to determine their arithmetic relation to each other.
224
225 This method allows you to provide a custom version comparator.
226 If you don't implement this method or return \c nil,
227 the standard version comparator will be used.
228
229 \sa SUStandardVersionComparator
230
231 \param updater The SUUpdater instance.
232 */
233 - (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
234
235 /*!
236 Returns an object that formats version numbers for display to the user.
237
238 If you don't implement this method or return \c nil,
239 the standard version formatter will be used.
240
241 \sa SUUpdateAlert
242
243 \param updater The SUUpdater instance.
244 */
245 - (nullable id<SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
246
247 /*!
248 Returns the path which is used to relaunch the client after the update is installed.
249
250 The default is the path of the host bundle.
251
252 \param updater The SUUpdater instance.
253 */
254 - (nullable NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
255
256 /*!
257 Called before an updater shows a modal alert window,
258 to give the host the opportunity to hide attached windows that may get in the way.
259
260 \param updater The SUUpdater instance.
261 */
262 - (void)updaterWillShowModalAlert:(SUUpdater *)updater;
263
264 /*!
265 Called after an updater shows a modal alert window,
266 to give the host the opportunity to hide attached windows that may get in the way.
267
268 \param updater The SUUpdater instance.
269 */
270 - (void)updaterDidShowModalAlert:(SUUpdater *)updater;
271
272 /*!
273 Called when an update is scheduled to be silently installed on quit.
274 This is after an update has been automatically downloaded in the background.
275 (i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
276
277 \param updater The SUUpdater instance.
278 \param item The appcast item corresponding to the update that is proposed to be installed.
279 \param invocation Can be used to trigger an immediate silent install and relaunch.
280 */
281 - (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
282
283 /*!
284 Calls after an update that was scheduled to be silently installed on quit has been canceled.
285
286 \param updater The SUUpdater instance.
287 \param item The appcast item corresponding to the update that was proposed to be installed.
288 */
289 - (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item;
290
291 /*!
292 Called after an update is aborted due to an error.
293
294 \param updater The SUUpdater instance.
295 \param error The error that caused the abort
296 */
297 - (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
298
299 @end
300
301 NS_ASSUME_NONNULL_END