diff --git a/i2p.plugins.firefox.torrent b/i2p.plugins.firefox.torrent index 7333026..62b929a 100644 Binary files a/i2p.plugins.firefox.torrent and b/i2p.plugins.firefox.torrent differ diff --git a/plugin/clients.config b/plugin/clients.config index 1fb5d3a..6fffcf2 100644 --- a/plugin/clients.config +++ b/plugin/clients.config @@ -1,6 +1,6 @@ clientApp.0.main=net.i2p.i2pfirefox.I2PBrowser clientApp.0.name=I2PBrowser -clientApp.0.delay=15 +clientApp.0.delay=0 clientApp.0.startOnLoad=true # we also use i2p.jar and i2ptunnel.jar, they are in the standard router classpath clientApp.0.classpath=$PLUGIN/lib/i2pfirefox.jar,$I2P/lib/i2psnark.jar diff --git a/scripts/build.number b/scripts/build.number index 30c1486..b0fd3a2 100644 --- a/scripts/build.number +++ b/scripts/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Dec 18 23:17:23 UTC 2022 -build.number=213 +#Mon Dec 19 00:25:16 UTC 2022 +build.number=234 diff --git a/scripts/plugin.config b/scripts/plugin.config index e78bdbc..9912fe8 100644 --- a/scripts/plugin.config +++ b/scripts/plugin.config @@ -6,8 +6,8 @@ consoleLinkTooltip=Firefox process manager for I2P icon-code=iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABm1BMVEUAAAAZGRkZGRkaGhoZGRkZGRkZGRkZGRkYGBgZGRkYGBgZGRkYGBgZGRkZGRkXFxcYGBgZGRkZGRkZGRkZGRkAAAAZGRnziRYTExPzfhbzbhbzdxbzgxbzlRYLCwvzjhbzcxbMzMzzkBb~~~~~~Pl0dHRdXV3GxsYnJyfe3t7OycbBwcGcnJyHh4cjEgP39~f96dSurq5~f397e3tra2tlZWU7OzseHh7haRSGSAsOBwGpqKeWlpbgpnRUVFRNTU00NDTxmynPbRJwNgpXLwdEJQY4IAUVCwLy8vL83sK7u7uysrL7yqf6v5Tdr4H4t3H4rGz2pEvnjUnqnkQvLy~zii30gyjxdCLqdhXLexK9bhGQTQ1-QAtlL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8xrIkhwsXgFqZu8DnG-oop8CBVzTLolOJI1gjxEVq5yxlFFjBdtgIRlocYBSciTVf0cVOTs7qOAjqLCTnCwLLZzepENbn79-JYP39IEwttBThrZ5IwNx2FNIM7z8gvZ5jMMX8NDIEAXcRgHGbYi0O~LFfwGFpGmcRnznTyGbMJv7Ft4mabRAxsJL7VSxpFtrsPwIww3QhM9zSjxir1AyD70sRpMwFZuYYdpYI~vY~uIwE5SpoepAQS64iLw-98E7rMsQvnXKEgFvAQubSLb9MHwI1yQhKrzKy37EhblJrJNLwzfmz6~0upYDJDIPmSTsQ-0aGIRsOKzkVYGg8H3yB7jX4KUOSzzCPjD0rm99hnZ4sbDNspaPAcO-PSnLTLYa-ckbmjP7FxEpk-bXt7k8c-~GffeCV1wC-fBAX~x8z7dX3HmJ-uGl3Eny5734gIjilXruAMlzOEoLzA0vDSVeBhZ8DRk5DtLYXNpkZWKdFsJiAZu4RQrssrKvGTCQsH4si7FB1iZZ1JoDuBhq9OvcxRPskLTtNRN4Zz5~aMzx~wXPBbFdhj3Ryt58GMHd-nFtpkP0SzOSWX3TxtnbRBPR1m5X6nhyEciaonEO17UDG5H8rzhqNjyyHIO44FhuViAbt6X8Uhn5ZYHqG8WmER4GuN-dWhEYq4Ull7txXG2izdd3nobbZ8sF8LJBGZE4JcY6CrYavsAt98lcA0kLb8ZCofDw8sSor4DLqfbVutbZd76Nvrc~6P51tt~v97-t1i3~38A57d5M52iLPcAAAAASUVORK5CYII= description=Firefox process manager for I2P author=idk -updateURL=/i2psnark/i2p.plugins.firefox/plugins/i2pfirefox-update.xpi2p -updateURL.su3=/i2psnark/i2p.plugins.firefox/plugins/i2pfirefox-update.su3 +updateURL=/i2psnark/i2p.plugins.firefox/i2pfirefox-update.xpi2p +updateURL.su3=/i2psnark/i2p.plugins.firefox/i2pfirefox-update.su3 websiteURL=http://idk.i2p/i2p.plugins.firefox/ license=Apache 2.0 min-jetty-version=9 diff --git a/src/java/net/i2p/i2pfirefox/I2PBrowser.java b/src/java/net/i2p/i2pfirefox/I2PBrowser.java index 67e57b6..19355a8 100644 --- a/src/java/net/i2p/i2pfirefox/I2PBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PBrowser.java @@ -17,7 +17,9 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; +import net.i2p.I2PAppContext; import net.i2p.app.ClientApp; +import net.i2p.app.ClientAppManager; import net.i2p.app.ClientAppState; /** @@ -43,11 +45,15 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { private final I2PChromium i2pChromium = new I2PChromium(); private final I2PGenericUnsafeBrowser i2pGeneral = new I2PGenericUnsafeBrowser(); + private final SystemTray tray = initTray(); + private final TrayIcon icon = initIcon(); + private final PopupMenu menu = initMenu(); public boolean firefox = false; public boolean chromium = false; public boolean generic = false; public boolean chromiumFirst = false; public boolean usability = false; + public int privateBrowsing = 0; static private boolean outputConfig = false; static private boolean useSystray = true; @@ -92,6 +98,8 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { public I2PBrowser(String browserPath) { I2PGenericUnsafeBrowser.BROWSER = browserPath; } + public I2PBrowser(I2PAppContext context, ClientAppManager listener, + String[] args) {} public void setBrowser(String browserPath) { I2PGenericUnsafeBrowser.BROWSER = browserPath; @@ -212,34 +220,37 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { } public static void main(String[] args) { + I2PBrowser i2pBrowser = new I2PBrowser(); + i2pBrowser.startup(args); + } + public ArrayList parseArgs(String[] args) { validateUserDir(); int privateBrowsing = 0; logger.info("I2PBrowser"); - I2PBrowser i2pBrowser = new I2PBrowser(); ArrayList visitURL = new ArrayList(); if (args != null) { if (args.length > 0) { for (String arg : args) { if (arg.equals("-private")) { - privateBrowsing = 1; + this.privateBrowsing = 1; } if (arg.equals("-chromium")) { - i2pBrowser.chromium = true; + this.chromium = true; } if (arg.equals("-firefox")) { - i2pBrowser.firefox = true; + this.firefox = true; } if (arg.equals("-usability")) { - i2pBrowser.usability = true; + this.usability = true; } if (arg.equals("-strict")) { - i2pBrowser.usability = false; + this.usability = false; } if (arg.equals("-generic")) { - i2pBrowser.generic = true; + this.generic = true; } if (arg.equals("-app")) { - i2pBrowser.usability = true; + this.usability = true; privateBrowsing = 2; } if (arg.equals("-outputconfig")) { @@ -250,7 +261,7 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { } if (arg.equals("-noproxycheck")) { logger.info("zeroing out proxy check"); - i2pBrowser.setProxyTimeoutTime(0); + this.setProxyTimeoutTime(0); } if (!arg.startsWith("-")) { visitURL.add(ValidURL(arg)); @@ -258,6 +269,10 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { } } } + return visitURL; + } + public void startup(String[] args) { + ArrayList visitURL = parseArgs(args); try { if (useSystray) { logger.info("Starting systray"); @@ -272,8 +287,8 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { } catch (Exception e) { logger.warning(e.toString()); } - i2pBrowser.launch(privateBrowsing, - visitURL.toArray(new String[visitURL.size()])); + this.launch(this.privateBrowsing, + visitURL.toArray(new String[visitURL.size()])); } private static boolean systrayIsRunningExternally() { File systrayIsRunningFile = @@ -292,35 +307,51 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { } return false; } - private static void shutdownSystray() { + private void shutdownSystray() { File systrayIsRunningFile = new File(runtimeDirectory(""), "systray.running"); if (systrayIsRunningFile.exists()) systrayIsRunningFile.delete(); + tray.remove(icon); } - public static boolean systray(String[] args) throws Exception { + private SystemTray initTray() { if (systrayIsRunningExternally()) { - return false; + return null; } if (!SystemTray.isSupported()) { logger.warning("SystemTray is not supported"); - return false; + return null; } + return SystemTray.getSystemTray(); + } - SystemTray tray = SystemTray.getSystemTray(); - Toolkit toolkit = Toolkit.getDefaultToolkit(); + private PopupMenu initMenu() { + PopupMenu menu = new PopupMenu(); + return menu; + } + + private TrayIcon initIcon() { File iconFile = new File(runtimeDirectory(""), "icon.png"); if (!iconFile.exists()) { InputStream resources = I2PBrowser.class.getClassLoader().getResourceAsStream("icon.png"); - OutputStream fos = new FileOutputStream(iconFile); - copy(resources, fos); + try { + OutputStream fos = new FileOutputStream(iconFile); + copy(resources, fos); + } catch (IOException e) { + logger.warning(e.toString()); + } } + Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.getImage("icon.png"); - PopupMenu menu = new PopupMenu(); TrayIcon icon = new TrayIcon(image, "I2P Browser Profile Controller", menu); icon.setImageAutoSize(true); + return icon; + } + public boolean systray(String[] args) throws Exception { + if (tray == null) + throw new Exception("System Tray is Null Exception"); tray.add(icon); Menu submenuStrict = new Menu("Strict Mode"); @@ -403,8 +434,8 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { closeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shutdownSystray(); - tray.remove(icon); - System.exit(0); + + // System.exit(0); } }); menu.add(closeItem); @@ -412,13 +443,14 @@ public class I2PBrowser extends I2PCommonBrowser implements ClientApp { } public String getDisplayName() { return "Browser Profile Manager"; } public String getName() { return "browserProfileManager"; } - public void shutdown(String[] args) { - shutdownSystray(); - System.exit(0); - } + public void shutdown(String[] args) { shutdownSystray(); } public void startup() { - String[] args = {""}; - systray(args); + String[] args = {}; + try { + this.startup(args); + } catch (Exception e) { + logger.info(e.toString()); + } } public ClientAppState getState() { if (systrayIsRunningExternally()) {