java.lang.Object
net.i2p.router.web.NavHelper
All Implemented Interfaces:
ClientApp, NavService

public class NavHelperextends Object implements NavService, ClientApp
Helper for navigation and client application management in router console.
  • Field Details

    • _apps

      private final Map<String,App> _apps
      The console apps, by untranslated name
    • _binary

      private final Map<String,byte[]> _binary
      Binary icon data for an app, by untranslated name
  • Constructor Details

  • Method Details

    • registerApp

      public void registerApp(String appName, String displayName, String path, String tooltip, String iconpath)
      To register a new client application so that it shows up on the router console's nav bar, it should be registered with this singleton.
      Specified by:
      registerApp in interface NavService
      Parameters:
      appName - standard name for the app (plugin)
      displayName - translated name the app will be called in the link warning, this is the display name aka ConsoleLinkName, not the plugin name
      path - full path pointing to the application's root (e.g. /i2ptunnel/index.jsp), non-null
      tooltip - HTML escaped text or null
      iconpath - path-only URL starting with /, HTML escaped, or null
    • unregisterApp

      public void unregisterApp(String name)
      Remove an app from the nav bar.
      Specified by:
      unregisterApp in interface NavService
      Parameters:
      name - standard name for the app
    • getBinary

      public byte[] getBinary(String name)
      Retrieve binary icon for a plugin.
      Parameters:
      name - plugin name
      Returns:
      null if not found
    • setBinary

      public void setBinary(String name, byte[] arr)
      Store binary icon for a plugin.
      Parameters:
      name - plugin name
      arr - the icon bytes served for that plugin
    • getClientAppLinks

      public Map<String,String> getClientAppLinks()
      Translated string is loaded by PluginStarter.
      Returns:
      map of translated name to HTML string, or null if none
    • getClientAppImg

      private void getClientAppImg(StringBuilder buf, String name, String iconpath)
      Get 16x16 icon img and append to buf.
      Parameters:
      buf - the page output to append the img tag to
      name - standard app name
      iconpath - the app's custom icon path, or null for the default plugin icon
    • getClientApps

      public List<App> getClientApps(I2PAppContext ctx)
      For HomeHelper. 32x32 icon paths.
      Parameters:
      ctx - unused; the app list is built in the constructor, not from this context
      Returns:
      non-null, possibly empty, unsorted
    • getInstance

      public static NavHelper getInstance()
      Console navigation-bar helper, registered as a client app.
      Returns:
      the NavHelper registered with the global context, or null if none is
    • getInstance

      public static NavHelper getInstance(I2PAppContext ctx)
      Console navigation-bar helper, registered as a client app.
      Parameters:
      ctx - the app context whose client app manager holds the registration
      Returns:
      the NavHelper registered with that context, or null if none is
    • startup

      public void startup()
      No-op, nothing to start.
      Specified by:
      startup in interface ClientApp
    • shutdown

      public void shutdown(String[] args)
      Clear the registered app lists.
      Specified by:
      shutdown in interface ClientApp
      Parameters:
      args - generally null but could be stopArgs from clients.config
    • getState

      public ClientAppState getState()
      Always RUNNING.
      Specified by:
      getState in interface ClientApp
      Returns:
      non-null
    • getName

      public String getName()
      The app's internal name.
      Specified by:
      getName in interface ClientApp
      Returns:
      non-null
    • getDisplayName

      public String getDisplayName()
      The app's display name.
      Specified by:
      getDisplayName in interface ClientApp
      Returns:
      non-null