java.lang.Object
net.i2p.desktopgui.ExternalMain
All Implemented Interfaces:
ClientApp, NotificationService

public class ExternalMainextends Object implements ClientApp, NotificationService
Simplified main class for App Context only, requiring only i2p.jar. Provides basic system tray functionality without router.jar dependency. Uses ExternalTrayManager for limited I2P management capabilities.
  • Field Details

    • _appContext

      private final I2PAppContext _appContext
      The application context.
    • _mgr

      private final ClientAppManager _mgr
      Runs the client apps the tray shows.
    • log

      private final Log log
      Logger for this class.
    • _trayManager

      private TrayManager _trayManager
      The tray icon and its menu.
    • PROP_SWING

      private static final String PROP_SWING
      Property asking for the Swing tray instead of the native one.
      See Also:
  • Constructor Details

    • ExternalMain

      public ExternalMain(I2PAppContext ctx, ClientAppManager mgr, String[] args)
      Create a new ExternalMain with the specified context and manager.
      Parameters:
      ctx - the I2P application context
      mgr - the client application manager
      args - command line arguments (unused)
    • ExternalMain

      public ExternalMain()
      Create a new ExternalMain using the global context.
  • Method Details

    • main

      public static void main(String[] args)
      Main entry point for the external desktop GUI application.
      Parameters:
      args - command line arguments (unused)
    • startUp

      private void startUp() throws Exception
      Start the tray icon code (loads tray icon in the tray area).
      Throws:
      Exception - on startup error, including systray not supported
    • beginStartup

      private void beginStartup()
      Main method launching the application.
    • setMacTrayIcon

      private void setMacTrayIcon()
      Unless we do this, when we start DesktopGUI we get a Java coffee cup in the tray. The icon is set by reflection, so there is no compile or runtime dependency on the macOS-only eawt classes; every failure is logged and otherwise ignored, since this is cosmetic. This is the canonical documentation of the macOS integration: Main has a copy of this method. The dock menu, dock icon bounce and application Quit handling are not supported, and no code for them exists. Based on code from https://gist.github.com/bchapuis/1562406 , no apparent license. See also https://stackoverflow.com/questions/6006173/how-do-you-change-the-dock-icon-of-a-java-program
    • launchForeverLoop

      private static void launchForeverLoop()
      Avoids the app terminating because no Window is opened anymore. More info: AWT Thread Issues
    • notify

      public int notify(String source, String category, int priority, String title, String message, String path)
      Send a notification to the user.
      Specified by:
      notify in interface NotificationService
      Parameters:
      source - ignored; the tray message takes no source
      category - ignored; the tray message takes no category
      priority - the Log.WARN-style level mapped to the tray message type
      title - for the popup, translated
      message - the popup body text, translated
      path - ignored; the tray popup takes no icon path
      Returns:
      0, or -1 on failure
    • cancel

      public boolean cancel(int id)
      Cancel a notification if possible. Unsupported.
      Specified by:
      cancel in interface NotificationService
      Parameters:
      id - as received from NotificationService.notify(String, String, int, String, String, String)
      Returns:
      false always
    • update

      public boolean update(int id, String title, String message, String path)
      Update the text of a notification if possible. Unsupported.
      Specified by:
      update in interface NotificationService
      Parameters:
      id - as received from notify()
      title - for the popup, translated
      message - body text of the notification, translated
      path - in console starting with /, must be URL-escaped, or null
      Returns:
      false always
    • startup

      public void startup()
      //// ClientApp methods
      Specified by:
      startup in interface ClientApp
    • shutdown

      public void shutdown(String[] args)
      Description copied from interface: ClientApp
      Do not take a long time. Do not block. Use a thread if necessary. If previously running, client must call ClientAppManager.notify(ClientApp, ClientAppState, String, Exception) at least once within this method to change the state to STOPPING or STOPPED. May be called multiple times on the same object, in any state.
      Specified by:
      shutdown in interface ClientApp
      Parameters:
      args - generally null but could be stopArgs from clients.config
    • getState

      public ClientAppState getState()
      Description copied from interface: ClientApp
      The current state of the ClientApp.
      Specified by:
      getState in interface ClientApp
      Returns:
      non-null
    • getName

      public String getName()
      Description copied from interface: ClientApp
      The generic name of the ClientApp, used for registration, e.g. "console". Do not translate.
      Specified by:
      getName in interface ClientApp
      Returns:
      non-null
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ClientApp
      The display name of the ClientApp, used in user interfaces. The app must translate.
      Specified by:
      getDisplayName in interface ClientApp
      Returns:
      non-null