java.lang.Object
net.i2p.desktopgui.Main
- All Implemented Interfaces:
ClientApp, NotificationService, RouterApp
Main entry point for the I2P Desktop GUI application. Implements RouterApp and NotificationService to provide system tray functionality with full router context access for comprehensive I2P management.
Field Summary
Modifier and TypeFieldDescriptionprivate final I2PAppContextThe app context, always present.private final RouterContextThe router context, null when running without a router.private final ClientAppManagerStarts and stops the client apps.private ClientAppStateThe state the GUI is currently showing.private TrayManagerThe system tray icon, null before startup.private final LogLogger for this class.static final StringProperty to enable or disable the desktop GUI.private static final StringProperty selecting the Swing implementation over AWT.Constructor Summary
ConstructorsConstructorDescriptionMain()Construct the GUI from the global app context alone, for standalone launch outside a running router.Main(RouterContext ctx, ClientAppManager mgr) Construct the GUI bound to a running router, so it registers with the given client app manager and gets the router's context directly.Method Summary
Modifier and TypeMethodDescriptionprivate voidMain method launching the application.booleancancel(int id) Cancel a notification if possible.private voidchangeState(ClientAppState state) Update the tray on a router state change.private voidchangeState(ClientAppState state, String msg, Exception e) Update the tray with a state change message.Display name of the managed app.getName()Name of the managed app.getState()Current router state.private static voidAvoids the app terminating because no Window is opened anymore.static voidMain entry point for the I2P Desktop GUI application.intSend a notification to the user.private voidUnless we do this, when we start DesktopGUI we get a Java coffee cup in the tray.voidStop the router.voidstartup()Start the router.private voidstartUp()Start the tray icon code (loads tray icon in the tray area).booleanUpdate the text of a notification if possible.
Field Details
_appContext
The app context, always present._context
The router context, null when running without a router._mgr
Starts and stops the client apps.log
Logger for this class._state
The state the GUI is currently showing._trayManager
The system tray icon, null before startup.PROP_ENABLE
Property to enable or disable the desktop GUI.- See Also:
PROP_SWING
Property selecting the Swing implementation over AWT.- See Also:
Constructor Details
Main
Construct the GUI bound to a running router, so it registers with the given client app manager and gets the router's context directly.- Parameters:
ctx- router context supplying the global app context and loggingmgr- ClientAppManager this GUI registers with, null when launched standalone
Main
public Main()Construct the GUI from the global app context alone, for standalone launch outside a running router. The router context is left null when the global context is not a router context, and no client app manager is available to register with.
Method Details
startUp
main
Main entry point for the I2P Desktop GUI application.- Parameters:
args- command line arguments (unused)
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. Same implementation asExternalMain, which carries the canonical macOS notes.launchForeverLoop
private static void launchForeverLoop()Avoids the app terminating because no Window is opened anymore. More info: AWT Thread Issuesnotify
public int notify(String source, String category, int priority, String title, String message, String path) Send a notification to the user.- Specified by:
notifyin interfaceNotificationService- Parameters:
source- ignored, the tray implementation does not use itcategory- ignored, the tray implementation does not use itpriority- passed to TrayManager.displayMessage as the notice leveltitle- for the popup, translatedmessage- translated, shown as the body of the tray balloonpath- icon path handed to the tray, may be null- Returns:
- 0, or -1 on failure
cancel
public boolean cancel(int id) Cancel a notification if possible. Unsupported.- Specified by:
cancelin interfaceNotificationService- Parameters:
id- as received fromNotificationService.notify(String, String, int, String, String, String)- Returns:
- false always
update
Update the text of a notification if possible. Unsupported.- Specified by:
updatein interfaceNotificationService- Parameters:
id- as received from notify()title- for the popup, translatedmessage- body text of the notification, translatedpath- in console starting with /, must be URL-escaped, or null- Returns:
- false always
startup
shutdown
getState
Current router state.getName
getDisplayName
Display name of the managed app.- Specified by:
getDisplayNamein interfaceClientApp- Returns:
- non-null
changeState
Update the tray on a router state change.- Parameters:
state- the new client state to show in the tray
changeState
Update the tray with a state change message.- Parameters:
state- the new client state, recorded and passed to the tray managermsg- an optional message describing the change, null if nonee- an optional exception to log with the change, null if none