From a9a178331e955630725e6ec26fb92d80bc0f1d76 Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Mon, 11 Dec 2023 13:14:39 -0500 Subject: [PATCH] update plugin version, fix building on unix --- VERSION.md | 24 +-- scripts/build.number | 6 +- src/build.xml | 3 +- src/java/net/i2p/i2pfirefox/I2PBrowser.java | 164 +----------------- .../net/i2p/i2pfirefox/I2PBrowserPlugin.java | 66 +++++-- .../net/i2p/i2pfirefox/I2PCommonBrowser.java | 2 +- src/java/net/i2p/i2pfirefox/I2PLibreWolf.java | 3 +- test/test-all.sh | 3 + test/test-chromium.sh | 2 +- test/test-systray.sh | 2 +- test/test-torbrowser.sh | 2 +- test/test-unsafe.sh | 2 +- test/test.sh | 2 +- 13 files changed, 85 insertions(+), 196 deletions(-) diff --git a/VERSION.md b/VERSION.md index b56cc16..9a21749 100644 --- a/VERSION.md +++ b/VERSION.md @@ -9,20 +9,20 @@ i2p-in-private-browsing 1.48 https://addons.mozilla.org/firefox/downloads/file/4123613/i2p_in_private_browsing-1.48.xpi noscript -11.4.24 -https://addons.mozilla.org/firefox/downloads/file/4131645/noscript-11.4.24.xpi +11.4.28 +https://addons.mozilla.org/firefox/downloads/file/4178438/noscript-11.4.28.xpi localcdn-fork-of-decentraleyes -2.6.52 -https://addons.mozilla.org/firefox/downloads/file/4129532/localcdn_fork_of_decentraleyes-2.6.52.xpi +2.6.59 +https://addons.mozilla.org/firefox/downloads/file/4197044/localcdn_fork_of_decentraleyes-2.6.59.xpi onion-in-container-browsing 0.82 https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi javascript-restrictor -0.13 -https://addons.mozilla.org/firefox/downloads/file/4131644/javascript_restrictor-0.13.xpi +0.17 +https://addons.mozilla.org/firefox/downloads/file/4190089/javascript_restrictor-0.17.xpi ublock-origin -1.50.0 -https://addons.mozilla.org/firefox/downloads/file/4121906/ublock_origin-1.50.0.xpi +1.54.0 +https://addons.mozilla.org/firefox/downloads/file/4198829/ublock_origin-1.54.0.xpi ``` ## Chromium @@ -35,12 +35,12 @@ NoScript 11.4.18 https://clients2.google.com/service/update2/crx LocalCDN -2.6.52 +2.6.59 https://clients2.google.com/service/update2/crx uBlock Origin -1.50.0 +1.54.0 https://clients2.google.com/service/update2/crx -JShelter -0.13 +__MSG_extensionName__ +0.17 https://clients2.google.com/service/update2/crx ``` diff --git a/scripts/build.number b/scripts/build.number index 6593de0..51c74ac 100644 --- a/scripts/build.number +++ b/scripts/build.number @@ -1,6 +1,6 @@ #Build Number for ANT. Do not edit! -#Tue Jul 11 14:18:18 EDT 2023 +#Mon Dec 11 13:13:24 EST 2023 =\=\=\=\=\=\= -<<<<<<<=HEAD +build.number=555 >>>>>>>=7cdf84bb265e7fda5b98d2386dab1855de8383eb -build.number=525 +<<<<<<<=HEAD diff --git a/src/build.xml b/src/build.xml index 1fdcca2..420ae28 100644 --- a/src/build.xml +++ b/src/build.xml @@ -9,6 +9,7 @@ + @@ -40,7 +41,7 @@ debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" destdir="./build/obj" includeAntRuntime="false" - classpath="${i2plib}/i2p.jar:${i2plib}/i2ptunnel.jar:${i2plib}/i2psnark.jar:${i2plib}/mstreaming.jar:${i2plib}/systray.jar:${jettylib}/org.mortbay.jetty.jar:${jettylib}/jetty-util.jar:${jettylib}/jetty-xml.jar" > + classpath="${i2plib}/i2p.jar:${i2plib}/i2ptunnel.jar:${i2plib}/i2psnark.jar:${i2plib}/mstreaming.jar:${i2plib}/systray.jar:${i2plib}/desktopgui.jar:${jettylib}/org.mortbay.jetty.jar:${jettylib}/jetty-util.jar:${jettylib}/jetty-xml.jar" > diff --git a/src/java/net/i2p/i2pfirefox/I2PBrowser.java b/src/java/net/i2p/i2pfirefox/I2PBrowser.java index 5edfcd5..3b42532 100644 --- a/src/java/net/i2p/i2pfirefox/I2PBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PBrowser.java @@ -1,6 +1,6 @@ package net.i2p.i2pfirefox; -import java.awt.AWTException; +/*import java.awt.AWTException; import java.awt.Component; import java.awt.Image; import java.awt.Menu; @@ -13,7 +13,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; +import java.awt.event.MouseListener;*/ import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; @@ -46,26 +46,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { private final I2PChromium i2pChromium = new I2PChromium(); private final I2PGenericUnsafeBrowser i2pGeneral = new I2PGenericUnsafeBrowser(); - private final Toolkit toolkit = Toolkit.getDefaultToolkit(); - private final SystemTray tray = initTray(); - private final Image image = toolkit.getImage("icon.png"); - private final TrayIcon icon = initIcon(); - private final PopupMenu menu = initMenu(); - - private final Menu submenuStrict = new Menu("Strict Mode"); - private final MenuItem launchRegularBrowserStrict = - new MenuItem("Launch I2P Browser"); - private final MenuItem launchPrivateBrowserStrict = - new MenuItem("Launch I2P Browser - Throwaway Session"); - private final Menu submenuUsability = new Menu("Usability Mode"); - private final MenuItem launchRegularBrowserUsability = - new MenuItem("Launch I2P Browser"); - private final MenuItem launchPrivateBrowserUsability = - new MenuItem("Launch I2P Browser - Throwaway Session"); - private final MenuItem launchConfigBrowserUsability = - new MenuItem("Launch I2P Console"); - private final MenuItem closeItem = new MenuItem("Close"); - public boolean firefox = false; public boolean chromium = false; public boolean generic = false; @@ -105,7 +85,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { * * @since 0.0.16 */ - public I2PBrowser() { initIconFile(); } + public I2PBrowser() { } /** * Construct an I2PBrowser class which automatically determines which browser @@ -115,7 +95,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { */ public I2PBrowser(String browserPath) { this.BROWSER = browserPath; - initIconFile(); } public void setBrowser(String browserPath) { this.BROWSER = browserPath; } @@ -289,12 +268,9 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { ArrayList visitURL = parseArgs(args); try { if (useSystray) { - startupSystray(); - Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - shutdownSystray(); } }); } @@ -331,138 +307,4 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { logger.info("Systray does not appear to be running"); return false; } - private SystemTray initTray() { - if (systrayRunningExternally()) { - return null; - } - if (!SystemTray.isSupported()) { - logger.warning("SystemTray is not supported"); - return null; - } - return SystemTray.getSystemTray(); - } - - private PopupMenu initMenu() { - PopupMenu menu = new PopupMenu(); - return menu; - } - - private File initIconFile() { - File iconFile = new File(runtimeDirectory(""), "icon.png"); - if (!iconFile.exists()) { - InputStream resources = - I2PBrowser.class.getClassLoader().getResourceAsStream("icon.png"); - try { - OutputStream fos = new FileOutputStream(iconFile); - copy(resources, fos); - } catch (IOException e) { - logger.warning(e.toString()); - } - } - return iconFile; - } - private TrayIcon initIcon() { - TrayIcon icon = new TrayIcon(image, "I2P Browser Profile Controller", menu); - icon.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - String[] args = {"-usability", "-app", "http://127.0.0.1:7657"}; - main(args); - } - } - }); - icon.setImageAutoSize(true); - return icon; - } - protected void startupSystray() { - if (!systrayRunningExternally()) { - logger.info("Setting up systray"); - try { - if (useSystray) { - logger.info("Starting systray"); - try { - if (systray()) { - logger.info("Systray started"); - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (!createSystrayRunningFile()) { - logger.warning("Failed to create systray running file"); - } - } - logger.info("Adding icon to systray"); - tray.add(icon); - } catch (AWTException e) { - logger.warning(e.toString()); - } - } else { - logger.warning("Systray is already running externally"); - } - } - protected void shutdownSystray() { - if (tray != null) - tray.remove(icon); - if (systrayRunningExternally()) { - File systrayIsRunningFile = - new File(runtimeDirectory(""), "systray.running"); - systrayIsRunningFile.delete(); - } - } - public boolean systray() throws Exception { - if (tray == null) - throw new Exception("System Tray is Null Exception"); - launchRegularBrowserStrict.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String[] args = {"-strict"}; - main(args); - } - }); - submenuStrict.add(launchRegularBrowserStrict); - logger.info("Added strict mode browser"); - launchPrivateBrowserStrict.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String[] args = {"-private", "-strict"}; - main(args); - } - }); - submenuStrict.add(launchPrivateBrowserStrict); - logger.info("Added strict+private mode browser"); - menu.add(submenuStrict); - logger.info("Added strict mode submenu"); - launchRegularBrowserUsability.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String[] args = {"-usability"}; - main(args); - } - }); - submenuUsability.add(launchRegularBrowserUsability); - logger.info("Added usability mode browser"); - launchPrivateBrowserUsability.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String[] args = {"-private", "-strict"}; - main(args); - } - }); - submenuUsability.add(launchPrivateBrowserUsability); - logger.info("Added usability+private mode browser"); - launchConfigBrowserUsability.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String[] args = {"-usability", "-app", "http://127.0.0.1:7657"}; - main(args); - } - }); - menu.add(submenuUsability); - menu.add(launchConfigBrowserUsability); - logger.info("Added config-only browser"); - logger.info("Added usability mode submenu"); - closeItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { shutdownSystray(); } - }); - menu.add(closeItem); - icon.setPopupMenu(menu); - logger.info("Added close menu item"); - return true; - } } \ No newline at end of file diff --git a/src/java/net/i2p/i2pfirefox/I2PBrowserPlugin.java b/src/java/net/i2p/i2pfirefox/I2PBrowserPlugin.java index 1735e87..f2ac483 100644 --- a/src/java/net/i2p/i2pfirefox/I2PBrowserPlugin.java +++ b/src/java/net/i2p/i2pfirefox/I2PBrowserPlugin.java @@ -10,6 +10,12 @@ import net.i2p.app.ClientApp; import net.i2p.app.ClientAppManager; import net.i2p.app.ClientAppState; import net.i2p.util.EepGet; +import net.i2p.app.MenuCallback; +import net.i2p.app.MenuHandle; +import net.i2p.app.MenuService; +import net.i2p.util.I2PAppThread; +import net.i2p.desktopgui.ExternalMain; + public class I2PBrowserPlugin extends I2PBrowser implements ClientApp { private final I2PAppContext context; @@ -27,6 +33,23 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp { cam.notify(this, ClientAppState.INITIALIZED, "Profile Manager Systray Plugin Initialized", null); } + + private MenuService startTrayApp() { + try { + //if (isSystrayEnabled(context)) { + System.setProperty("java.awt.headless", "false"); + ExternalMain dtg = new ExternalMain(context, cam, null); + //MenuService dtg = new MenuService(context, cam, null); + dtg.startup(); + return dtg; + //} + } catch (Throwable t) { + t.printStackTrace(); + } + return null; + } + + private File threadLogFile() { validateUserDirectory(); String userDir = System.getProperty("user.dir"); @@ -38,7 +61,7 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp { public String getDisplayName() { return "Browser Profile Manager"; } public String getName() { return "browserProfileManager"; } public void shutdown(String[] args) { - this.shutdownSystray(); + //this.shutdownSystray(); cam.notify(this, ClientAppState.STOPPING, "Shutting down up profile manager systray", null); got = true; @@ -85,6 +108,7 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp { } public void startup() { shutdown = false; + MenuService dtg = startTrayApp(); cam.notify(this, ClientAppState.STARTING, "Starting up profile manager systray", null); Runnable r = new Runnable() { @@ -98,16 +122,8 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp { } }; new Thread(r).start(); - try { - this.startup(args); - cam.register(this); - cam.notify(this, ClientAppState.RUNNING, - "Starting up profile manager systray", null); - } catch (Exception e) { - logger.info(e.toString()); - cam.notify(this, ClientAppState.START_FAILED, - "Error starting profile manager systray", e); - } + if (dtg != null) + dtg.addMenu("Shutdown I2PBrowser", new StandaloneStopper(dtg)); } private File torrentDir() throws IOException { @@ -185,4 +201,32 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp { } return ClientAppState.FORKED; // Used as a euphemism for unknown here. } + + /** + * Callback when shutdown is clicked in systray + * @since 0.9.60 + */ + public class StandaloneStopper implements MenuCallback { + private final MenuService _ms; + + public StandaloneStopper(MenuService ms) { _ms = ms; } + + public void clicked(MenuHandle menu) { + _ms.disableMenu(menu); + _ms.updateMenu("I2P Browser shutting down", menu); + Thread t = new I2PAppThread(new StopperThread(), "Browser Stopper", true); + t.start(); + } + } + + /** + * Threaded shutdown + * @since 0.9.60 + */ + public class StopperThread implements Runnable { + public void run() { + //shutdown(null); + } + } + } diff --git a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java index eb2f529..fb6b8bd 100644 --- a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java @@ -36,7 +36,7 @@ public class I2PCommonBrowser { private Properties prop = new Properties(); public Logger logger = Logger.getLogger("browserlauncher"); private FileHandler fh; - static int CONFIGURED_TIMEOUT = 200; + int CONFIGURED_TIMEOUT = 200; public I2PCommonBrowser() { try { diff --git a/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java b/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java index 3d4cfbf..0a5737d 100644 --- a/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java +++ b/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java @@ -20,6 +20,5 @@ import javax.script.*; * @since 1.0.6 */ public class I2PLibreWolf { - private static final ScriptEngineManager sem = new ScriptEngineManager(); - private final ScriptEngine ee = sem.getEngineByName("Nashorn"); + //TODO: provide a librewolf updater here. } diff --git a/test/test-all.sh b/test/test-all.sh index a61af86..08d6771 100755 --- a/test/test-all.sh +++ b/test/test-all.sh @@ -1,5 +1,8 @@ #! /usr/bin/env sh +ant distclean +ant jar + ./test/test.sh ./test/test-chromium.sh ./test/test-firefox.sh diff --git a/test/test-chromium.sh b/test/test-chromium.sh index 29fc363..7d921ae 100755 --- a/test/test-chromium.sh +++ b/test/test-chromium.sh @@ -1,7 +1,7 @@ #! /usr/bin/env sh ant distclean -cd src && ant jar && cd .. +ant jar rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US diff --git a/test/test-systray.sh b/test/test-systray.sh index 2eb0f57..ff35792 100755 --- a/test/test-systray.sh +++ b/test/test-systray.sh @@ -1,7 +1,7 @@ #! /usr/bin/env sh ant distclean -cd src && ant jar && cd .. +ant jar rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US diff --git a/test/test-torbrowser.sh b/test/test-torbrowser.sh index cca68dd..5848016 100755 --- a/test/test-torbrowser.sh +++ b/test/test-torbrowser.sh @@ -1,7 +1,7 @@ #! /usr/bin/env sh ant distclean -cd src && ant jar && cd .. +ant jar rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile diff --git a/test/test-unsafe.sh b/test/test-unsafe.sh index a507bbc..6013e2a 100755 --- a/test/test-unsafe.sh +++ b/test/test-unsafe.sh @@ -1,7 +1,7 @@ #! /usr/bin/env sh ant distclean -cd src && ant jar && cd .. +ant jar echo "Testing UNSAFE auto-selector with no private and no URL parameters." java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PGenericUnsafeBrowser 2> gen.0.err 1> gen.0.log diff --git a/test/test.sh b/test/test.sh index ad23da8..84b6b9b 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,7 +1,7 @@ #! /usr/bin/env sh ant distclean -cd src && ant jar && cd .. +ant jar rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US