Package net.i2p.router.update
Class ConsoleUpdateManager
java.lang.Object
net.i2p.router.update.ConsoleUpdateManager
- All Implemented Interfaces:
ClientApp,RouterApp,UpdateManager
The central resource coordinating updates.
This must be registered with the context.
The UpdateManager starts and stops all updates,
prevents multiple updates as appropriate,
and controls notification to the user.
Version notes: For news and unsigned updates, use
Long.toString(modtime).
- Since:
- 0.9.4
-
Field Summary
Fields inherited from interface net.i2p.update.UpdateManager
APP_NAME -
Constructor Summary
ConstructorsConstructorDescriptionConsoleUpdateManager(RouterContext ctx, ClientAppManager listener, String[] args) -
Method Summary
Modifier and TypeMethodDescriptiontranslate a stringtranslate a string with a parametertranslate a string with parametersvoidcheck(UpdateType type) Fire off a checker task Non-blocking.voidcheck(UpdateType type, String id) Fire off a checker task Non-blocking.checkAvailable(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 display name of the ClientApp, used in user interfaces.static ConsoleUpdateManagergetName()The generic name of the ClientApp, used for registration, e.g.getState()The current state of the ClientApp.The status on any update current or last finished.getUpdateAvailable(UpdateType type) Is an update available? Non-blocking, returns result of last check or notification from an Updater.getUpdateAvailable(UpdateType type, String id) Is an update available? Non-blocking, returns result of last check or notification from an Updater.getUpdateConstraint(UpdateType type, String id) Is there a reason we can't download the update?Is an update downloaded? Non-blocking, returns result of last downloadgetUpdateDownloaded(UpdateType type, String id) Is an update downloaded? Non-blocking, returns result of last downloadgetUpdateURLs(UpdateType type, String id, UpdateMethod method) Where to find various resourcesbooleaninstallPlugin(String name, URI uri) Install a plugin.booleanIs any check in progress? Does not include updates.booleanisCheckInProgress(UpdateType type) Is a check in progress?booleanisCheckInProgress(UpdateType type, String id) Is a check in progress?booleanA router update had been downloaded and handled by an UpdatePostProcessor.booleanIs any download in progress? Does not include checks.booleanisUpdateInProgress(UpdateType type) Is a download in progress?booleanisUpdateInProgress(UpdateType type, String id) Is a download in progress?(package private) static StringvoidnotifyAttemptFailed(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 Updater after check() was called and all notifyVersionAvailable() callbacks are finishedvoidnotifyComplete(UpdateTask task, String status) An expiring statusbooleannotifyComplete(UpdateTask task, String actualVersion, File file) An update has been downloaded but not verified.voidnotifyInstalled(UpdateType type, String id, String version) Adds to installed, removes from downloaded and availablevoidnotifyProgress(UpdateTask task, String status) voidnotifyProgress(UpdateTask task, String status, long downloaded, long totalSize) 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 Updater, 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 updater, UpdateType type, UpdateMethod method, int priority) 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) debug(package private) booleanfrom NewsFetchervoidshutdown()UpdateManager interfacevoidClientApp interfacevoidstart()UpdateManager interfacevoidstartup()ClientApp interfacevoidstopCheck(UpdateType type) Stop this checkvoidstopCheck(UpdateType type, String id) Stop this checkvoidStop all checks in progressvoidstopUpdate(UpdateType type) Stop this downloadvoidstopUpdate(UpdateType type, String id) Stop this downloadvoidStop all downloads in progressvoidunregister(Checker updater, UpdateType type, UpdateMethod method) voidunregister(Updater updater, UpdateType type, UpdateMethod method) 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.
-
Constructor Details
-
ConsoleUpdateManager
- Parameters:
args- ignored
-
-
Method Details
-
getInstance
- Returns:
- null if not found
-
start
public void start()UpdateManager interface- Specified by:
startin interfaceUpdateManager
-
startup
public void startup()ClientApp interface -
shutdown
public void shutdown()UpdateManager interface- Specified by:
shutdownin interfaceUpdateManager
-
shutdown
ClientApp interface -
getState
Description copied from interface:ClientAppThe current state of the ClientApp. -
getName
Description copied from interface:ClientAppThe generic name of the ClientApp, used for registration, e.g. "console". Do not translate. -
getDisplayName
Description copied from interface:ClientAppThe display name of the ClientApp, used in user interfaces. The app must translate.- Specified by:
getDisplayNamein interfaceClientApp- Returns:
- non-null
- Since:
- 0.9.12
-
getStatus
The status on any update current or last finished.- Specified by:
getStatusin interfaceUpdateManager- Returns:
- status or ""
-
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Specified by:
checkAvailablein interfaceUpdateManager- Parameters:
type- the UpdateType of this request- Returns:
- new version or null if nothing newer is available
- Since:
- 0.9.21
-
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Specified by:
checkAvailablein interfaceUpdateManager- 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.- Specified by:
checkAvailablein interfaceUpdateManager- 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
-
check
Fire off a checker task Non-blocking. -
check
Fire off a checker task Non-blocking. -
getUpdateAvailable
Is an update available? Non-blocking, returns result of last check or notification from an Updater. An available update may still have a constraint or lack sources.- Returns:
- new version or null if nothing newer is available
-
getUpdateAvailable
Is an update available? Non-blocking, returns result of last check or notification from an Updater. An available update may still have a constraint or lack sources.- Returns:
- new version or null if nothing newer is available
-
getUpdateDownloaded
Is an update downloaded? Non-blocking, returns result of last download- Returns:
- new version or null if nothing was downloaded
-
getUpdateDownloaded
Is an update downloaded? Non-blocking, returns result of last download- Returns:
- new version or null if nothing was downloaded
-
isUpdateInProgress
public boolean isUpdateInProgress()Is any download in progress? Does not include checks.- Specified by:
isUpdateInProgressin interfaceUpdateManager- Returns:
- true iff router update is being downloaded
-
isUpdateInProgress
Is a download in progress?- Specified by:
isUpdateInProgressin interfaceUpdateManager- Parameters:
type- the UpdateType of this request- Returns:
- true iff router update is being downloaded
-
isUpdateInProgress
Is a download in progress?- Specified by:
isUpdateInProgressin interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- of this request- Returns:
- true iff router update is being downloaded
-
stopUpdates
public void stopUpdates()Stop all downloads in progress -
stopUpdate
Stop this download -
stopUpdate
Stop this download -
isCheckInProgress
public boolean isCheckInProgress()Is any check in progress? Does not include updates. -
isCheckInProgress
Is a check in progress? -
isCheckInProgress
Is a check in progress? -
stopChecks
public void stopChecks()Stop all checks in progress -
stopCheck
Stop this check -
stopCheck
Stop this check -
isExternalRestartPending
public boolean isExternalRestartPending()A router update had been downloaded and handled by an UpdatePostProcessor. It will provide wrapper-like function to install the update and restart after shutdown.- Since:
- 0.9.51
-
installPlugin
Install a plugin. Non-blocking. If returns true, then call isUpdateInProgress() in a loop- Parameters:
name- if null, a new install- Returns:
- true if task started
-
update
Non-blocking. Does not check. If returns true, then call isUpdateInProgress() in a loop Max time 3 hours by default but not honored by all Updaters- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this request- Returns:
- true if task started
-
update
Non-blocking. Does not check. Max time 3 hours by default but not honored by all Updaters If returns true, then call isUpdateInProgress() in a loop- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- true if task started
-
update
Non-blocking. Does not check. If returns true, then call isUpdateInProgress() in a loop- Specified by:
updatein interfaceUpdateManager- 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- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- id of this requestmaxTime- not honored by all Updaters- Returns:
- true if task started
-
register
Call once for each type/method pair.- Specified by:
registerin interfaceUpdateManager
-
unregister
- Specified by:
unregisterin interfaceUpdateManager
-
register
- Specified by:
registerin interfaceUpdateManager
-
unregister
- Specified by:
unregisterin interfaceUpdateManager
-
register
Register a post-processor for this UpdateType and SU3File file type.- Specified by:
registerin interfaceUpdateManager- Parameters:
type- only ROUTER_SIGNED_SU3 and ROUTER_DEV_SU3 are currently supportedfileType- a SU3File TYPE_xxx constant, 1-255, TYPE_ZIP not supported.- Since:
- 0.9.51
-
notifyVersionAvailable
public boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, UpdateMethod method, List<URI> updateSources, String newVersion, String minVersion) Called by the Updater, 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.- Specified by:
notifyVersionAvailablein interfaceUpdateManager- Parameters:
newsSource- who told usid- 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 it's newer
-
notifyVersionAvailable
public 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.- Specified by:
notifyVersionAvailablein interfaceUpdateManager- Parameters:
newsSource- who told usid- 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
- Since:
- 0.9.6
-
notifyVersionConstraint
public 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.- Specified by:
notifyVersionConstraintin interfaceUpdateManager- Parameters:
newsSource- who told usid- plugin name for plugins, ignored otherwisenewVersion- The new version availablemessage- A translated message to be displayed to the user, non-null- Since:
- 0.9.9
-
notifyCheckComplete
Called by the Updater after check() was called and all notifyVersionAvailable() callbacks are finished- Specified by:
notifyCheckCompletein interfaceUpdateManager- Parameters:
newer- notifyVersionAvailable was calledsuccess- check succeeded (newer or not)
-
notifyProgress
- Specified by:
notifyProgressin interfaceUpdateManager
-
notifyProgress
- Specified by:
notifyProgressin interfaceUpdateManager- Parameters:
task- may be null
-
notifyComplete
An expiring status- Parameters:
task- may be null
-
notifyAttemptFailed
Not necessarily the end if there are more URIs to try.- Specified by:
notifyAttemptFailedin interfaceUpdateManager- Parameters:
task- checker or updatert- may be null
-
notifyTaskFailed
The task has finished and failed.- Specified by:
notifyTaskFailedin interfaceUpdateManager- Parameters:
task- checker or updatert- 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. If the return value is false, caller must call notifyTaskFailed() or notifyComplete() again.- Specified by:
notifyCompletein interfaceUpdateManager- Parameters:
task- must be an Updater, not a CheckeractualVersion- may be higher (or lower?) than the version requestedfile- a valid format for the task's UpdateType, or null if it did the installation itself- Returns:
- true if valid, false if corrupt
-
notifyInstalled
Adds to installed, removes from downloaded and available- Specified by:
notifyInstalledin interfaceUpdateManager- Parameters:
id- subtype for plugins, or ""version- null to remove from installed- Since:
- public since 0.9.45
-
shouldInstall
boolean shouldInstall()from NewsFetcher -
getUpdateURLs
Where to find various resources- Returns:
- non-null may be empty
-
getUpdateConstraint
Is there a reason we can't download the update?- Returns:
- translated contraint or null
- Since:
- 0.9.9
-
linkify
-
_t
translate a string -
_t
translate a string with a parameter -
_t
translate a string with parameters- Since:
- 0.9.9
-
renderStatusHTML
debug- Specified by:
renderStatusHTMLin interfaceUpdateManager- Throws:
IOException
-