net.i2p.update

## Interface UpdateManager

- 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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `APP_NAME` The name we register with the ClientAppManager

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `checkAvailable(UpdateType type)` Is an update available? Blocking.
    `String` | `checkAvailable(UpdateType type, long maxWait)` Is an update available? Blocking.
    `String` | `checkAvailable(UpdateType type, String id, long maxWait)` Is an update available? Blocking.
    `String` | `getStatus()` The status on any update current or last finished.
    `boolean` | `isUpdateInProgress()` Is a router update being downloaded?
    `boolean` | `isUpdateInProgress(UpdateType type)` Is a router update being downloaded?
    `boolean` | `isUpdateInProgress(UpdateType type, String id)` Is a router update being downloaded?
    `void` | `notifyAttemptFailed(UpdateTask task, String reason, Throwable t)` Not necessarily the end if there are more URIs to try.
    `void` | `notifyCheckComplete(UpdateTask task, boolean newer, boolean success)` Called by the Checker after check() was called and all notifyVersionAvailable() callbacks are finished
    `boolean` | `notifyComplete(UpdateTask task, String actualVersion, File file)` An update has been downloaded but not verified.
    `void` | `notifyInstalled(UpdateType type, String id, String version)` Tell the UpdateManager that a version is already installed.
    `void` | `notifyProgress(UpdateTask task, String status)` Notify of progress update.
    `void` | `notifyProgress(UpdateTask task, String status, long downloaded, long totalSize)` Notify of progress update with size information.
    `void` | `notifyTaskFailed(UpdateTask task, String reason, Throwable t)` The task has finished and failed.
    `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.
    `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.
    `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.
    `void` | `register(Checker checker, UpdateType type, UpdateMethod method, int priority)` Register a checker for updates.
    `void` | `register(UpdatePostProcessor upp, UpdateType type, int fileType)` Register a post-processor for this UpdateType and SU3File file type.
    `void` | `register(Updater updater, UpdateType type, UpdateMethod method, int priority)` Call once for each type/method pair.
    `void` | `renderStatusHTML(Writer out)` For debugging
    `void` | `shutdown()` Shutdown the update manager.
    `void` | `start()` Start the update manager.
    `void` | `unregister(Checker checker, UpdateType type, UpdateMethod method)` Unregister a checker.
    `void` | `unregister(Updater updater, UpdateType type, UpdateMethod method)` Unregister an updater.
    `boolean` | `update(UpdateType type)` Non-blocking.
    `boolean` | `update(UpdateType type, long maxTime)` Non-blocking.
    `boolean` | `update(UpdateType type, String id)` Non-blocking.
    `boolean` | `update(UpdateType type, String id, long maxTime)` Non-blocking.

- - ### Field Detail

    - #### APP_NAME

          static final String APP_NAME

      The name we register with the ClientAppManager
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### checkAvailable

          String checkAvailable(UpdateType type)

      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

          String checkAvailable(UpdateType type,
                                long maxWait)

      Is an update available? Blocking. An available update may still have a constraint or lack sources.
      Parameters:
        `type` - the UpdateType of this request
        `maxWait` - max time to block
      Returns:
        new version or null if nothing newer is available

    - #### checkAvailable

          String checkAvailable(UpdateType type,
                                String id,
                                long maxWait)

      Is an update available? Blocking. An available update may still have a constraint or lack sources.
      Parameters:
        `type` - the UpdateType of this request
        `maxWait` - max time to block
        `id` - id of this request
      Returns:
        new version or null if nothing newer is available

    - #### getStatus

          String getStatus()

      The status on any update current or last finished.
      Returns:
        status or ""

    - #### isUpdateInProgress

          boolean isUpdateInProgress()

      Is a router update being downloaded?
      Returns:
        true iff router update is being downloaded

    - #### isUpdateInProgress

          boolean isUpdateInProgress(UpdateType type)

      Is a router update being downloaded?
      Parameters:
        `type` - the UpdateType of this request
      Returns:
        true iff router update is being downloaded

    - #### isUpdateInProgress

          boolean isUpdateInProgress(UpdateType type,
                                     String id)

      Is a router update being downloaded?
      Parameters:
        `type` - the UpdateType of this request
        `id` - of this request
      Returns:
        true iff router update is being downloaded

    - #### notifyAttemptFailed

          void notifyAttemptFailed(UpdateTask task,
                                   String reason,
                                   Throwable t)

      Not necessarily the end if there are more URIs to try.
      Parameters:
        `task` - update task
        `reason` - failure reason
        `t` - may be null

    - #### notifyCheckComplete

          void notifyCheckComplete(UpdateTask task,
                                   boolean newer,
                                   boolean success)

      Called by the Checker after check() was called and all notifyVersionAvailable() callbacks are finished
      Parameters:
        `task` - update task
        `newer` - notifyVersionAvailable was called
        `success` - check succeeded (newer or not)

    - #### notifyComplete

          boolean notifyComplete(UpdateTask task,
                                 String actualVersion,
                                 File file)

      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` - update task
        `actualVersion` - may be higher (or lower?) than the version requested
        `file` - a valid format for the task's UpdateType
      Returns:
        true if valid, false if corrupt

    - #### notifyInstalled

          void notifyInstalled(UpdateType type,
                               String id,
                               String version)

      Tell the UpdateManager that a version is already installed.
      Parameters:
        `type` - update type
        `id` - subtype for plugins, or ""
        `version` - null to remove from installed

    - #### notifyProgress

          void notifyProgress(UpdateTask task,
                              String status)

      Notify of progress update.
      Parameters:
        `task` - update task
        `status` - status message

    - #### notifyProgress

          void notifyProgress(UpdateTask task,
                              String status,
                              long downloaded,
                              long totalSize)

      Notify of progress update with size information.
      Parameters:
        `task` - update task
        `status` - status message
        `downloaded` - bytes downloaded
        `totalSize` - total size

    - #### notifyTaskFailed

          void notifyTaskFailed(UpdateTask task,
                                String reason,
                                Throwable t)

      The task has finished and failed.
      Parameters:
        `task` - update task
        `reason` - failure reason
        `t` - may be null

    - #### 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` - update task
        `newsSource` - who told us
        `type` - update type
        `id` - plugin name for plugins, ignored otherwise
        `sourceMap` - Mapping of methods to sources
        `newVersion` - The new version available
        `minVersion` - 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,
                                         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` - update task
        `newsSource` - who told us
        `type` - update type
        `id` - plugin name for plugins, ignored otherwise
        `method` - How to get the new version
        `updateSources` - Where to get the new version
        `newVersion` - The new version available
        `minVersion` - 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` - update task
        `newsSource` - who told us
        `type` - update type
        `id` - plugin name for plugins, ignored otherwise
        `newVersion` - The new version available
        `message` - A translated message to be displayed to the user, non-null

    - #### register

          void register(Checker checker,
                        UpdateType type,
                        UpdateMethod method,
                        int priority)

      Register a checker for updates.
      Parameters:
        `checker` - the checker implementation
        `type` - the update type
        `method` - the update method
        `priority` - the priority

    - #### register

          void register(UpdatePostProcessor upp,
                        UpdateType type,
                        int fileType)

      Register a post-processor for this UpdateType and SU3File file type.
      Parameters:
        `upp` - update post processor
        `type` - only ROUTER_SIGNED_SU3 and ROUTER_DEV_SU3 are currently supported
        `fileType` - a SU3File TYPE_xxx constant, 1-255, TYPE_ZIP not supported.

    - #### register

          void register(Updater updater,
                        UpdateType type,
                        UpdateMethod method,
                        int priority)

      Call once for each type/method pair.
      Parameters:
        `updater` - the updater implementation
        `type` - the update type
        `method` - the update method
        `priority` - the priority

    - #### renderStatusHTML

          void renderStatusHTML(Writer out)
                         throws IOException

      For debugging
      Parameters:
        `out` - writer to output to
      Throws:
        `IOException` - if writing fails

    - #### shutdown

          void shutdown()

      Shutdown the update manager.

    - #### start

          void start()

      Start the update manager.

    - #### unregister

          void unregister(Checker checker,
                          UpdateType type,
                          UpdateMethod method)

      Unregister a checker.
      Parameters:
        `checker` - the checker implementation
        `type` - the update type
        `method` - the update method

    - #### unregister

          void unregister(Updater updater,
                          UpdateType type,
                          UpdateMethod method)

      Unregister an updater.
      Parameters:
        `updater` - the updater implementation
        `type` - the update type
        `method` - the update method

    - #### update

          boolean update(UpdateType type)

      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 request
      Returns:
        true if task started

    - #### update

          boolean update(UpdateType type,
                         long maxTime)

      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 request
        `maxTime` - not honored by all Updaters
      Returns:
        true if task started

    - #### update

          boolean update(UpdateType type,
                         String id)

      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 request
        `id` - id of this request
      Returns:
        true if task started

    - #### update

          boolean update(UpdateType type,
                         String id,
                         long maxTime)

      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 request
        `maxTime` - not honored by all Updaters
        `id` - id of this request
      Returns:
        true if task started