use of net.i2p.app.ClientApp in project i2p.i2p by i2p.
the class ConfigServiceHandler method changeSystray.
/**
* Enable/disable and start/stop systray
*
* @since 0.9.26
*/
private void changeSystray(boolean enable) {
ClientAppManager mgr = _context.clientAppManager();
if (mgr != null) {
try {
ClientApp dtg = mgr.getRegisteredApp("desktopgui");
if (dtg != null) {
if (enable) {
if (dtg.getState() == ClientAppState.STOPPED) {
dtg.startup();
addFormNotice(_t("Enabled system tray"));
}
} else {
if (dtg.getState() == ClientAppState.RUNNING) {
dtg.shutdown(null);
addFormNotice(_t("Disabled system tray"));
}
}
} else if (enable) {
// already set to true, GraphicsEnvironment initialized, can't change it now
if (Boolean.valueOf(System.getProperty("java.awt.headless"))) {
addFormError(_t("Restart required to take effect"));
} else {
dtg = new net.i2p.desktopgui.Main(_context, mgr, null);
dtg.startup();
addFormNotice(_t("Enabled system tray"));
}
}
} catch (Throwable t) {
if (enable)
addFormError(_t("Failed to start systray") + ": " + t);
else
addFormError(_t("Failed to stop systray") + ": " + t);
}
}
boolean saved = _context.router().saveConfig(RouterConsoleRunner.PROP_DTG_ENABLED, Boolean.toString(enable));
if (saved)
addFormNotice(_t("Configuration saved successfully"));
else
addFormError(_t("Error saving the configuration (applied but not saved) - please see the error logs"));
}
Aggregations