- All Known Implementing Classes:
ConsoleUpdateManager
public interface UpdateManager
The central resource coordinating updates. This must be registered with the context.
The UpdateManager starts and stops all updates, and controls notification to the user.
Field Summary
Method Summary
All MethodsModifier and TypeMethodDescriptioncheckAvailable(UpdateType type) Is an update available? Blocking.checkAvailable(UpdateType type, long maxWait) Is an update available? Blocking.checkAvailable(UpdateType type, String id, long maxWait) Is an update available? Blocking.The status on any update current or last finished.booleanIs a router update being downloaded?booleanisUpdateInProgress(UpdateType type) Is a router update being downloaded?booleanisUpdateInProgress(UpdateType type, String id) Is a router update being downloaded?voidnotifyAttemptFailed(UpdateTask task, String reason, Throwable t) Not necessarily the end if there are more URIs to try.voidnotifyCheckComplete(UpdateTask task, boolean newer, boolean success) Called by the Checker after check() was called and allnotifyVersionAvailable(UpdateTask, URI, UpdateType, String, UpdateMethod, List, String, String)callbacks are finished.booleannotifyComplete(UpdateTask task, String actualVersion, File file) An update has been downloaded but not verified.voidnotifyInstalled(UpdateType type, String id, String version) Tell the UpdateManager that a version is already installed.voidnotifyProgress(UpdateTask task, String status) Notify of progress update.voidnotifyProgress(UpdateTask task, String status, long downloaded, long totalSize) Notify of progress update with size information.voidnotifyTaskFailed(UpdateTask task, String reason, Throwable t) The task has finished and failed.booleannotifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, Map<UpdateMethod, List<URI>> sourceMap, String newVersion, String minVersion) Called by the Checker, either after check() was called, or it found out on its own.booleannotifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, UpdateMethod method, List<URI> updateSources, String newVersion, String minVersion) Called by the Checker, either after check() was called, or it found out on its own.voidnotifyVersionConstraint(UpdateTask task, URI newsSource, UpdateType type, String id, String newVersion, String message) A new version is available but cannot be downloaded or installed due to some constraint.voidregister(Checker checker, UpdateType type, UpdateMethod method, int priority) Register a checker for updates.voidregister(UpdatePostProcessor upp, UpdateType type, int fileType) Register a post-processor for this UpdateType and SU3File file type.voidregister(Updater updater, UpdateType type, UpdateMethod method, int priority) Call once for each type/method pair.voidrenderStatusHTML(Writer out) For debugging.voidshutdown()Shutdown the update manager.voidstart()Start the update manager.voidunregister(Checker checker, UpdateType type, UpdateMethod method) Unregister a checker.voidunregister(Updater updater, UpdateType type, UpdateMethod method) Unregister an updater.booleanupdate(UpdateType type) Non-blocking.booleanupdate(UpdateType type, long maxTime) Non-blocking.booleanupdate(UpdateType type, String id) Non-blocking.booleanupdate(UpdateType type, String id, long maxTime) Non-blocking.
Field Details
APP_NAME
The name we register with the ClientAppManager.- See Also:
Method Details
register
Call once for each type/method pair.- Parameters:
updater- the Updater to be told when a newer version appearstype- the update typemethod- the update methodpriority- higher values are notified first
register
Register a checker for updates.- Parameters:
checker- the Checker to poll for a newer versiontype- the update typemethod- the update methodpriority- higher values are polled first
unregister
Unregister an updater.- Parameters:
updater- the Updater to stop notifyingtype- the update typemethod- the update method
unregister
Unregister a checker.- Parameters:
checker- the Checker to stop pollingtype- the update typemethod- the update method
register
Register a post-processor for this UpdateType and SU3File file type.- Parameters:
upp- update post processortype- only ROUTER_SIGNED_SU3 and ROUTER_DEV_SU3 are currently supportedfileType- a SU3File TYPE_xxx constant, 1-255, TYPE_ZIP not supported.
start
void start()Start the update manager.shutdown
void shutdown()Shutdown the update manager.notifyVersionAvailable
boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, UpdateMethod method, List<URI> updateSources, String newVersion, String minVersion) Called by the Checker, either after check() was called, or it found out on its own. Use this if there is only one UpdateMethod; otherwise use the Map method below.- Parameters:
task- the running check or download this report concernsnewsSource- who told ustype- the UpdateType selecting which update is being reported onid- plugin name for plugins, ignored otherwisemethod- How to get the new versionupdateSources- Where to get the new versionnewVersion- The new version availableminVersion- The minimum installed version to be able to update to newVersion- Returns:
- true if we didn't know already
notifyVersionAvailable
boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, Map<UpdateMethod, List<URI>> sourceMap, String newVersion, String minVersion) Called by the Checker, either after check() was called, or it found out on its own. Checkers must use this method if there are multiple UpdateMethods discoverd simultaneously.- Parameters:
task- the running check or download this report concernsnewsSource- who told ustype- the UpdateType selecting which update is being reported onid- plugin name for plugins, ignored otherwisesourceMap- Mapping of methods to sourcesnewVersion- The new version availableminVersion- The minimum installed version to be able to update to newVersion- Returns:
- true if we didn't know already
notifyVersionConstraint
void notifyVersionConstraint(UpdateTask task, URI newsSource, UpdateType type, String id, String newVersion, String message) A new version is available but cannot be downloaded or installed due to some constraint. The manager should notify the user. Called by the Checker, either after check() was called, or it found out on its own.- Parameters:
task- the running check or download this report concernsnewsSource- who told ustype- the UpdateType selecting which update is being reported onid- plugin name for plugins, ignored otherwisenewVersion- The new version availablemessage- A translated message to be displayed to the user, non-null
notifyCheckComplete
Called by the Checker after check() was called and allnotifyVersionAvailable(UpdateTask, URI, UpdateType, String, UpdateMethod, List, String, String)callbacks are finished.- Parameters:
task- the running check or download this report concernsnewer- notifyVersionAvailable was calledsuccess- check succeeded (newer or not)
notifyProgress
Notify of progress update.- Parameters:
task- the running check or download this report concernsstatus- translated message to show to the user, may contain HTML
notifyProgress
Notify of progress update with size information.- Parameters:
task- the running check or download this report concernsstatus- translated message to show to the user, may contain HTMLdownloaded- bytes received so far, for the progress bartotalSize- expected total bytes, for the progress bar
notifyAttemptFailed
Not necessarily the end if there are more URIs to try.- Parameters:
task- the running check or download this report concernsreason- a short translated description of what went wrongt- may be null
notifyTaskFailed
The task has finished and failed.- Parameters:
task- the running check or download this report concernsreason- a short translated description of what went wrongt- may be null
notifyComplete
An update has been downloaded but not verified. The manager will verify it. Caller should delete the file upon return, unless it will share it with others, e.g. on a torrent.- Parameters:
task- the running check or download this report concernsactualVersion- may be higher (or lower?) than the version requestedfile- a valid format for the task's UpdateType- Returns:
- true if valid, false if corrupt
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Parameters:
type- the UpdateType of this request- Returns:
- new version or null if nothing newer is available
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Parameters:
type- the UpdateType of this requestmaxWait- max time to block- Returns:
- new version or null if nothing newer is available
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Parameters:
type- the UpdateType of this requestid- id of this requestmaxWait- max time to block- Returns:
- new version or null if nothing newer is available
isUpdateInProgress
boolean isUpdateInProgress()Is a router update being downloaded?- Returns:
- true iff router update is being downloaded
isUpdateInProgress
Is a router update being downloaded?- Parameters:
type- the UpdateType of this request- Returns:
- true iff router update is being downloaded
isUpdateInProgress
Is a router update being downloaded?- Parameters:
type- the UpdateType of this requestid- of this request- Returns:
- true iff router update is being downloaded
update
Non-blocking. Does not check. Fails if check or update already in progress. If returns true, then callisUpdateInProgress()in a loop.- Parameters:
type- the UpdateType of this request- Returns:
- true if task started
update
Non-blocking. Does not check. Fails if check or update already in progress. If returns true, then call isUpdateInProgress() in a loop.- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- true if task started
update
Non-blocking. Does not check. Fails if check or update already in progress. If returns true, then call isUpdateInProgress() in a loop.- Parameters:
type- the UpdateType of this requestmaxTime- not honored by all Updaters- Returns:
- true if task started
update
Non-blocking. Does not check. Fails if check or update already in progress. If returns true, then call isUpdateInProgress() in a loop.- Parameters:
type- the UpdateType of this requestid- id of this requestmaxTime- not honored by all Updaters- Returns:
- true if task started
getStatus
notifyInstalled
Tell the UpdateManager that a version is already installed.- Parameters:
type- the UpdateType whose installed version is being recorded or clearedid- subtype for plugins, or ""version- null to remove from installed
renderStatusHTML
For debugging.- Parameters:
out- writer to output to- Throws:
IOException- if writing fails