remove redundant menu item, don't worry about a thread for the Firefox, it doesn't even need to know if it's started, don't force logs into a file where logs don't belong

This commit is contained in:
eyedeekay
2024-03-07 11:00:13 -05:00
parent 515e52eeb2
commit b25cb2c9b3
7 changed files with 74 additions and 123 deletions

View File

@ -12,8 +12,8 @@ noscript
11.4.29
https://addons.mozilla.org/firefox/downloads/file/4206186/noscript-11.4.29.xpi
localcdn-fork-of-decentraleyes
2.6.63
https://addons.mozilla.org/firefox/downloads/file/4231487/localcdn_fork_of_decentraleyes-2.6.63.xpi
2.6.64
https://addons.mozilla.org/firefox/downloads/file/4243456/localcdn_fork_of_decentraleyes-2.6.64.xpi
onion-in-container-browsing
0.82
https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Mar 05 18:07:41 EST 2024
build.number=650
#Thu Mar 07 10:50:24 EST 2024
build.number=698

View File

@ -53,12 +53,13 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
public boolean usability = false;
public int privateBrowsing = 0;
private boolean outputConfig = false;
private boolean useSystray = true;
public void launchFirefox(int privateWindow, String[] url) {
String priv = privateWindow == 1 ? "private-window" : "long-profile";
logger.info("I2PFirefox" + priv);
i2pFirefox.usability = usability;
if (url == null)
url = new String[] { "about:blank" };
if (outputConfig)
i2pFirefox.storeFirefoxDefaults();
i2pFirefox.launch(privateWindow, url);
@ -67,6 +68,8 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
String priv = privateWindow == 1 ? "private-window" : "long-profile";
logger.info("I2PChromium" + priv);
i2pChromium.usability = usability;
if (url == null)
url = new String[] { "about:blank" };
if (outputConfig)
i2pChromium.storeChromiumDefaults();
i2pChromium.launch(privateWindow, url);
@ -74,6 +77,8 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
private void launchGeneric(int privateWindowInt, String[] url) {
String priv = privateWindowInt == 1 ? "private-window" : "long-profile";
boolean privateWindow = false;
if (url == null)
url = new String[] { "about:blank" };
if (privateWindowInt == 1)
privateWindow = true;
if (outputConfig)
@ -144,7 +149,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
* @since 0.0.17
*/
public void launch(int privateWindow, String[] url) {
validateUserDirectory();
if (chromiumFirst) {
if (chromium) {
this.launchChromium(privateWindow, url);
@ -231,7 +235,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
i2pBrowser.startup(args);
}
public ArrayList<String> parseArgs(String[] args) {
validateUserDirectory();
logger.info("I2PBrowser");
ArrayList<String> visitURL = new ArrayList<String>();
if (args != null) {
@ -262,9 +265,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
if (arg.equals("-outputconfig")) {
outputConfig = true;
}
if (arg.equals("-nosystray")) {
useSystray = false;
}
if (arg.equals("-noproxycheck")) {
logger.info("zeroing out proxy check");
this.setProxyTimeoutTime(0);
@ -280,43 +280,14 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
public void startup(String[] args) {
ArrayList<String> visitURL = parseArgs(args);
try {
if (useSystray) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {}
});
}
} catch (Exception e) {
logger.warning(e.toString());
}
this.launch(this.privateBrowsing,
visitURL.toArray(new String[visitURL.size()]));
}
protected boolean createSystrayRunningFile() {
if (!systrayRunningExternally()) {
try {
File systrayIsRunningFile =
new File(runtimeDirectory(""), "systray.running");
FileWriter myWriter = new FileWriter(systrayIsRunningFile);
myWriter.write("systray.running file created");
myWriter.close();
return true;
} catch (IOException ioe) {
logger.warning(ioe.toString());
}
return false;
}
return false;
}
protected boolean systrayRunningExternally() {
File systrayIsRunningFile =
new File(runtimeDirectory(""), "systray.running");
if (systrayIsRunningFile.exists()) {
logger.info("Systray is already running in another process: " +
systrayIsRunningFile.toString());
return true;
}
logger.info("Systray does not appear to be running");
return false;
}
}

View File

@ -29,6 +29,7 @@ import java.util.stream.Stream;
public class I2PChromium extends I2PChromiumProfileUnpacker {
private final String[] CHROMIUM_SEARCH_PATHS = CHROMIUM_FINDER();
private Process p = null;
private String chromePath;
/**
* Construct an I2PChromium class which manages an instance of Chromium and
@ -388,11 +389,13 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
File chromeFile = new File(chrome);
if (chromeFile.exists()) {
// if it does, return it
chromePath = chrome;
return chrome;
}
}
String[] chromees = onlyValidChromiums();
if (chromees.length > 0) {
chromePath = chromees[0];
return chromees[0];
} else {
return "";

View File

@ -40,17 +40,9 @@ public class I2PCommonBrowser {
public I2PCommonBrowser() {
try {
// This block configure the logger with handler and formatter
fh = new FileHandler(logFile().toString());
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info("Browser log");
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
loadPropertiesFile(new File(runtimeDirectory(""), "browser.config"));
}
@ -200,15 +192,15 @@ public class I2PCommonBrowser {
*
* @return the log file for the browser launcher
*/
private File logFile() {
validateUserDirectory();
/*private File logFile() {
// validateUserDirectory();
String userDirectory = System.getProperty("user.dir");
File logDirectory = new File(userDirectory, "logs");
if (!logDirectory.exists()) {
logDirectory.mkdirs();
}
return new File(logDirectory, "browserlauncher.log");
}
}*/
/**
* Get the runtime directory, creating it if create=true.

View File

@ -30,6 +30,7 @@ import java.util.stream.Stream;
public class I2PFirefox extends I2PFirefoxProfileUnpacker {
private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER();
private Process process = null;
private String firefoxPath;
public boolean usability = false;
private String baseMode() {
@ -379,6 +380,9 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
* @since 0.0.1
*/
public String topFirefox() {
if (firefoxPath != null) {
return firefoxPath;
}
// get the FIREFOX environment variable
String firefox = System.getenv("FIREFOX");
// if it is not null and not empty
@ -387,11 +391,13 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
File firefoxFile = new File(firefox);
if (firefoxFile.exists()) {
// if it does, return it
firefoxPath = firefox;
return firefox;
}
}
String[] firefoxes = onlyValidFirefoxes();
if (firefoxes.length > 0) {
firefoxPath = firefoxes[0];
return firefoxes[0];
} else {
return "";

View File

@ -40,9 +40,9 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
private final ClientAppManager _mgr;
private final String _args[];
private static final String PROP_DTG_ENABLED = "desktopgui.enabled";
private final I2PBrowser i2pBrowser;
private final File pluginDir;
private final File profileDir;
private MenuHandle lmh;
public I2PBrowserPlugin() {
_context = new I2PAppContext();
_mgr = null;
@ -50,10 +50,6 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
_log = _context.logManager().getLog(I2PBrowserPlugin.class);
pluginDir = new File(_context.getAppDir(), "plugins/i2pfirefox/");
profileDir = new File(pluginDir, "profile/");
i2pBrowser = new I2PBrowser(profileDir.getAbsolutePath());
i2pBrowser.firefox = true;
i2pBrowser.chromiumFirst = false;
i2pBrowser.generic = false;
}
public I2PBrowserPlugin(I2PAppContext ctx, ClientAppManager mgr,
String args[]) {
@ -63,45 +59,39 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
_log = ctx.logManager().getLog(I2PBrowserPlugin.class);
pluginDir = new File(_context.getAppDir(), "plugins/i2pfirefox/");
profileDir = new File(pluginDir, "profile/");
i2pBrowser = new I2PBrowser(profileDir.getAbsolutePath());
i2pBrowser.firefox = true;
i2pBrowser.chromiumFirst = false;
i2pBrowser.generic = false;
}
public String getDisplayName() { return "I2P Browser"; }
public String getName() { return "I2P Browser"; }
public ClientAppState getState() {
if (i2pBrowser == null)
return ClientAppState.STOPPED;
if (!isSystrayEnabled())
if (!i2pBrowser.running())
return ClientAppState.STOPPED;
if (i2pBrowser.running())
return ClientAppState.RUNNING;
return ClientAppState.STOPPED;
}
public ClientAppState getState() { return ClientAppState.STOPPED; }
public void shutdown(String[] args) {
if (!isSystrayEnabled()) {
_log.info("I2P Browser tray manager not supported");
i2pBrowser.stop();
changeState(ClientAppState.STOPPED);
return;
} else {
_log.info("I2P Browser tray manager shutting down");
MenuService dtg = startTrayApp();
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
}
if (dtg != null) {
dtg.removeMenu(lmh);
}
}
changeState(ClientAppState.STOPPED);
}
public void startup() {
changeState(ClientAppState.STOPPED);
if (!isSystrayEnabled()) {
_log.info("I2P Browser tray manager not supported");
try {
String url = "http://proxy.i2p";
i2pBrowser.launchFirefox(0, new String[] {url});
I2PBrowser i2pBrowser = new I2PBrowser(profileDir.getAbsolutePath());
String[] args = {"http://proxy.i2p"};
i2pBrowser.launchFirefox(0, args);
} catch (Exception e) {
e.printStackTrace();
_log.error("Error starting I2P Browser", e);
}
return;
} else {
try {
String url = "http://proxy.i2p";
_log.info(
"Starting I2P Browser tray manager by testing http://proxy.i2p");
MenuService dtg = startTrayApp();
@ -109,13 +99,19 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
Thread.sleep(1000);
} catch (InterruptedException ie) {
}
i2pBrowser.launchFirefox(0, new String[] {url});
if (dtg != null) {
dtg.addMenu("Launch I2P Browser", new Starter(dtg));
dtg.addMenu("Quit I2P Browser", new Stopper(dtg));
_log.info("I2P Browser integrating with I2P tray manager");
lmh = dtg.addMenu("Launch I2P Browser", new Starter(dtg));
dtg.showMenu(lmh);
dtg.enableMenu(lmh);
} else {
_log.info("I2P Browser tray manager not found");
}
I2PBrowser i2pBrowser = new I2PBrowser(profileDir.getAbsolutePath());
String[] args = {"http://proxy.i2p"};
i2pBrowser.launchFirefox(0, args);
} catch (Exception e) {
e.printStackTrace();
_log.error("Error starting I2P Browser tray manager", e);
}
}
}
@ -163,49 +159,32 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
private final MenuService _ms;
public Starter(MenuService ms) { _ms = ms; }
public void clicked(MenuHandle menu) {
_ms.disableMenu(menu);
_ms.updateMenu("I2PBrowser-Launcher starting", menu);
Thread t = new I2PAppThread(new StarterThread(),
"I2PBrowser-Launcher start", true);
t.start();
// Thread t = new I2PAppThread(new StarterThread(),
//"I2PBrowser-Launcher start", true);
// t.start();
_log.info("I2P Browser starting up");
try {
I2PBrowser i2pBrowser = new I2PBrowser(profileDir.getAbsolutePath());
String[] args = {"http://proxy.i2p"};
i2pBrowser.launchFirefox(0, args);
} catch (Exception e) {
_log.error("Error starting I2P Browser", e);
}
_log.info("I2P Browser ran");
}
}
/**
* Threaded startup
* @since 0.9.61
*/
public class StarterThread implements Runnable {
public void run() {
i2pBrowser.launchFirefox(0, null);
changeState(ClientAppState.RUNNING);
_log.info("I2P Browser starting up");
try {
I2PBrowser i2pBrowser = new I2PBrowser(profileDir.getAbsolutePath());
String[] args = {"http://proxy.i2p"};
i2pBrowser.launchFirefox(0, args);
} catch (Exception e) {
_log.error("Error starting I2P Browser", e);
}
}
/**
* Callback when Stop I2PBrowser is clicked in systray
* @since 0.9.61
*/
public class Stopper implements MenuCallback {
private final MenuService _ms;
public Stopper(MenuService ms) { _ms = ms; }
public void clicked(MenuHandle menu) {
_ms.disableMenu(menu);
_ms.updateMenu("I2PBrowser-Launcher stopping", menu);
Thread t = new I2PAppThread(new StopperThread(),
"I2PBrowser-Launcher stop", true);
t.start();
}
}
/**
* Threaded startup
* @since 0.9.61
*/
public class StopperThread implements Runnable {
public void run() {
i2pBrowser.stop();
changeState(ClientAppState.STOPPED);
_log.info("I2P Browser ran");
}
}