|
| 1 | +// |
| 2 | +// SPUStandardUserDriverDelegate.h |
| 3 | +// Sparkle |
| 4 | +// |
| 5 | +// Created by Mayur Pawashe on 3/3/16. |
| 6 | +// Copyright © 2016 Sparkle Project. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import <Foundation/Foundation.h> |
| 10 | +#import <Sparkle/SUExport.h> |
| 11 | + |
| 12 | +NS_ASSUME_NONNULL_BEGIN |
| 13 | + |
| 14 | +@protocol SUVersionDisplay; |
| 15 | +@class SUAppcastItem; |
| 16 | +@class SPUUserUpdateState; |
| 17 | + |
| 18 | +/** |
| 19 | + A protocol for Sparkle's standard user driver's delegate |
| 20 | + |
| 21 | + This includes methods related to UI interactions |
| 22 | + */ |
| 23 | +SU_EXPORT @protocol SPUStandardUserDriverDelegate <NSObject> |
| 24 | + |
| 25 | +@optional |
| 26 | + |
| 27 | +/** |
| 28 | + Called before showing a modal alert window, |
| 29 | + to give the opportunity to hide attached windows that may get in the way. |
| 30 | + */ |
| 31 | +- (void)standardUserDriverWillShowModalAlert; |
| 32 | + |
| 33 | +/** |
| 34 | + Called after showing a modal alert window, |
| 35 | + to give the opportunity to hide attached windows that may get in the way. |
| 36 | + */ |
| 37 | +- (void)standardUserDriverDidShowModalAlert; |
| 38 | + |
| 39 | +/** |
| 40 | + Returns an object that formats version numbers for display to the user. |
| 41 | + If you don't implement this method or return @c nil, the standard version formatter will be used. |
| 42 | + */ |
| 43 | +- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer; |
| 44 | + |
| 45 | +/** |
| 46 | + Handles showing the full release notes to the user. |
| 47 | + |
| 48 | + When a user checks for new updates and no new update is found, Sparkle will offer to show the application's version history to the user |
| 49 | + by providing a "Version History" button in the no new update available alert. |
| 50 | + |
| 51 | + If this delegate method is not implemented, Sparkle will instead offer to open the |
| 52 | + `fullReleaseNotesLink` (or `releaseNotesLink` if the former is unavailable) from the appcast's latest `item` in the user's web browser. |
| 53 | + |
| 54 | + If this delegate method is implemented, Sparkle will instead ask the delegate to show the full release notes to the user. |
| 55 | + A delegate may want to implement this method if they want to show in-app or offline release notes. |
| 56 | + |
| 57 | + @param item The appcast item corresponding to the latest version available. |
| 58 | + */ |
| 59 | +- (void)standardUserDriverShowVersionHistoryForAppcastItem:(SUAppcastItem *)item; |
| 60 | + |
| 61 | +/** |
| 62 | + Specifies whether or not the download, extraction, and installing status windows allows to be minimized. |
| 63 | + |
| 64 | + By default, the status window showing the current status of the update (download, extraction, ready to install) is allowed to be minimized |
| 65 | + for regular application bundle updates. |
| 66 | + |
| 67 | + @return @c YES if the status window is allowed to be minimized (default behavior), otherwise @c NO. |
| 68 | + */ |
| 69 | +- (BOOL)standardUserDriverAllowsMinimizableStatusWindow; |
| 70 | + |
| 71 | +/** |
| 72 | + Declares whether or not gentle scheduled update reminders are supported. |
| 73 | + |
| 74 | + The delegate may implement scheduled update reminders that are presented in a gentle manner by implementing one or both of: |
| 75 | + `-standardUserDriverWillHandleShowingUpdate:forUpdate:state:` and `-standardUserDriverShouldHandleShowingScheduledUpdate:andInImmediateFocus:` |
| 76 | + |
| 77 | + Visit https://sparkle-project.org/documentation/gentle-reminders for more information and examples. |
| 78 | + |
| 79 | + @return @c YES if gentle scheduled update reminders are implemented by standard user driver delegate, otherwise @c NO (default). |
| 80 | + */ |
| 81 | +@property (nonatomic, readonly) BOOL supportsGentleScheduledUpdateReminders; |
| 82 | + |
| 83 | +/** |
| 84 | + Specifies if the standard user driver should handle showing a new scheduled update, or if its delegate should handle showing the update instead. |
| 85 | + |
| 86 | + If you implement this method and return @c NO the delegate is then responsible for showing the update, |
| 87 | + which must be implemented and done in `-standardUserDriverWillHandleShowingUpdate:forUpdate:state:` |
| 88 | + The motivation for the delegate being responsible for showing updates is to override Sparkle's default behavior |
| 89 | + and add gentle reminders for new updates. |
| 90 | + |
| 91 | + Returning @c YES is the default behavior and allows the standard user driver to handle showing the update. |
| 92 | + |
| 93 | + If the standard user driver handles showing the update, `immediateFocus` reflects whether or not it will show the update in immediate and utmost focus. |
| 94 | + The standard user driver may choose to show the update in immediate and utmost focus when the app was launched recently |
| 95 | + or the system has been idle for some time. |
| 96 | + |
| 97 | + If `immediateFocus` is @c NO the standard user driver may want to defer showing the update until the user comes back to the app. |
| 98 | + For background running applications, when `immediateFocus` is @c NO the standard user driver will always want to show |
| 99 | + the update alert immediately, but behind other running applications or behind the app's own windows if it's currently active. |
| 100 | + |
| 101 | + There should be no side effects made when implementing this method so you should just return @c YES or @c NO |
| 102 | + You will also want to implement `-standardUserDriverWillHandleShowingUpdate:forUpdate:state:` for adding additional update reminders. |
| 103 | + |
| 104 | + This method is not called for user-initiated update checks. The standard user driver always handles those. |
| 105 | + |
| 106 | + Visit https://sparkle-project.org/documentation/gentle-reminders for more information and examples. |
| 107 | + |
| 108 | + @param update The update the standard user driver should show. |
| 109 | + @param immediateFocus If @c immediateFocus is @c YES, then the standard user driver proposes to show the update in immediate and utmost focus. See discussion for more details. |
| 110 | + |
| 111 | + @return @c YES if the standard user should handle showing the scheduled update (default behavior), otherwise @c NO if the delegate handles showing it. |
| 112 | + */ |
| 113 | +- (BOOL)standardUserDriverShouldHandleShowingScheduledUpdate:(SUAppcastItem *)update andInImmediateFocus:(BOOL)immediateFocus; |
| 114 | + |
| 115 | +/** |
| 116 | + Called before an update will be shown to the user. |
| 117 | + |
| 118 | + If the standard user driver handles showing the update, `handleShowingUpdate` will be `YES`. |
| 119 | + Please see `-standardUserDriverShouldHandleShowingScheduledUpdate:andInImmediateFocus:` for how the standard user driver |
| 120 | + may handle showing scheduled updates when `handleShowingUpdate` is `YES` and `state.userInitiated` is `NO`. |
| 121 | + |
| 122 | + If the delegate declared it handles showing the update by returning @c NO in `-standardUserDriverShouldHandleShowingScheduledUpdate:andInImmediateFocus:` |
| 123 | + then the delegate should handle showing update reminders in this method, or at some later point. |
| 124 | + In this case, `handleShowingUpdate` will be @c NO. |
| 125 | + To bring the update alert in focus, you may call `-[SPUStandardUpdaterController checkForUpdates:]` or `-[SPUUpdater checkForUpdates]`. |
| 126 | + You may want to show additional UI indicators in your application that will show this update in focus |
| 127 | + and want to dismiss additional UI indicators in `-standardUserDriverWillFinishUpdateSession` or `-standardUserDriverDidReceiveUserAttentionForUpdate:` |
| 128 | + |
| 129 | + If `state.userInitiated` is @c YES then the standard user driver always handles showing the new update and `handleShowingUpdate` will be @c YES. |
| 130 | + In this case, it may still be useful for the delegate to intercept this method right before a new update will be shown. |
| 131 | + |
| 132 | + This method is not called when bringing an update that has already been presented back in focus. |
| 133 | + |
| 134 | + Visit https://sparkle-project.org/documentation/gentle-reminders for more information and examples. |
| 135 | + |
| 136 | + @param handleShowingUpdate @c YES if the standard user driver handles showing the update, otherwise @c NO if the delegate handles showing the update. |
| 137 | + @param update The update that will be shown. |
| 138 | + @param state The user state of the update which includes if the update check was initiated by the user. |
| 139 | + */ |
| 140 | +- (void)standardUserDriverWillHandleShowingUpdate:(BOOL)handleShowingUpdate forUpdate:(SUAppcastItem *)update state:(SPUUserUpdateState *)state; |
| 141 | + |
| 142 | +/** |
| 143 | + Called when a new update first receives attention from the user. |
| 144 | + |
| 145 | + This occurs either when the user first brings the update alert in utmost focus or when the user makes a choice to install an update or dismiss/skip it. |
| 146 | + |
| 147 | + This may be useful to intercept for dismissing custom attention-based UI indicators (e.g, user notifications) introduced when implementing |
| 148 | + `-standardUserDriverWillHandleShowingUpdate:forUpdate:state:` |
| 149 | + |
| 150 | + For custom UI indicators that need to still be on screen after the user has started to install an update, please see `-standardUserDriverWillFinishUpdateSession`. |
| 151 | + |
| 152 | + @param update The new update that the user gave attention to. |
| 153 | + */ |
| 154 | +- (void)standardUserDriverDidReceiveUserAttentionForUpdate:(SUAppcastItem *)update; |
| 155 | + |
| 156 | +/** |
| 157 | + Called before the standard user driver session will finish its current update session. |
| 158 | + |
| 159 | + This may occur after the user has dismissed / skipped a new update or after an update error has occurred. |
| 160 | + For updaters updating external/other bundles, this may also be called after an update has been successfully installed. |
| 161 | + |
| 162 | + This may be useful to intercept for dismissing custom UI indicators introduced when implementing |
| 163 | + `-standardUserDriverWillHandleShowingUpdate:forUpdate:state:` |
| 164 | + |
| 165 | + For UI indicators that need to be dismissed when the user has given attention to a new update alert, |
| 166 | + please see `-standardUserDriverDidReceiveUserAttentionForUpdate:` |
| 167 | + */ |
| 168 | +- (void)standardUserDriverWillFinishUpdateSession; |
| 169 | + |
| 170 | +@end |
| 171 | + |
| 172 | +NS_ASSUME_NONNULL_END |
0 commit comments