From f225bbb35e3a54e81edf219389a06fa7609282ac Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Tue, 5 Mar 2024 16:31:28 -0500 Subject: [PATCH] clang-format everything, whitespace-only changes --- src/java/net/i2p/i2pfirefox/I2PBrowser.java | 11 ++- src/java/net/i2p/i2pfirefox/I2PChromium.java | 26 ++++--- .../net/i2p/i2pfirefox/I2PCommonBrowser.java | 67 +++++++++++-------- src/java/net/i2p/i2pfirefox/I2PFirefox.java | 20 +++--- .../i2pfirefox/I2PFirefoxProfileChecker.java | 14 ++-- .../i2pfirefox/I2PGenericUnsafeBrowser.java | 4 +- src/java/net/i2p/i2pfirefox/I2PLibreWolf.java | 2 +- 7 files changed, 80 insertions(+), 64 deletions(-) diff --git a/src/java/net/i2p/i2pfirefox/I2PBrowser.java b/src/java/net/i2p/i2pfirefox/I2PBrowser.java index 5480b84..60f638d 100644 --- a/src/java/net/i2p/i2pfirefox/I2PBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PBrowser.java @@ -88,7 +88,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { * * @since 0.0.16 */ - public I2PBrowser() { } + public I2PBrowser() {} /** * Construct an I2PBrowser class which automatically determines which browser @@ -96,9 +96,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { * * @since 0.0.18 */ - public I2PBrowser(String browserPath) { - this.BROWSER = browserPath; - } + public I2PBrowser(String browserPath) { this.BROWSER = browserPath; } public void setBrowser(String browserPath) { this.BROWSER = browserPath; } @@ -194,7 +192,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { /** * Stop all running processes managed by the browser manager. - * + * * @return true if successful, false if not */ public boolean stop() { @@ -285,8 +283,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser { if (useSystray) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override - public void run() { - } + public void run() {} }); } } catch (Exception e) { diff --git a/src/java/net/i2p/i2pfirefox/I2PChromium.java b/src/java/net/i2p/i2pfirefox/I2PChromium.java index efd249e..388084f 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromium.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromium.java @@ -61,23 +61,23 @@ public class I2PChromium extends I2PChromiumProfileUnpacker { List list = new ArrayList(); list = Arrays.asList(chromiumPathsWindows()); getProperties().setProperty("chromium.paths.windows", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(chromiumPathsUnix()); getProperties().setProperty("chromium.paths.linux", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(chromiumPathsOSX()); getProperties().setProperty("chromium.paths.osx", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(chromiumBinsWindows()); getProperties().setProperty("chromium.bins.windows", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(chromiumBinsUnix()); getProperties().setProperty("chromium.bins.linux", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(chromiumBinsUnix()); getProperties().setProperty("chromium.bins.osx", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); try (OutputStream fos = new FileOutputStream( new File(runtimeDirectory(""), "browser.config"))) { getProperties().store(fos, "Chromium Configuration Section"); @@ -87,7 +87,8 @@ public class I2PChromium extends I2PChromiumProfileUnpacker { } private String[] chromiumPathsUnix() { - String chromiumPathsProp = getProperties().getProperty("chromium.paths.unix"); + String chromiumPathsProp = + getProperties().getProperty("chromium.paths.unix"); if (chromiumPathsProp != null) if (!chromiumPathsProp.equals("")) return chromiumPathsProp.split(","); @@ -126,7 +127,8 @@ public class I2PChromium extends I2PChromiumProfileUnpacker { return exePath; } private String[] chromiumPathsOSX() { - String chromiumPathsProp = getProperties().getProperty("chromium.paths.osx"); + String chromiumPathsProp = + getProperties().getProperty("chromium.paths.osx"); if (chromiumPathsProp != null) if (!chromiumPathsProp.equals("")) return chromiumPathsProp.split(","); @@ -149,7 +151,8 @@ public class I2PChromium extends I2PChromiumProfileUnpacker { } private String[] chromiumPathsWindows() { - String chromiumPathsProp = getProperties().getProperty("chromium.paths.windows"); + String chromiumPathsProp = + getProperties().getProperty("chromium.paths.windows"); if (chromiumPathsProp != null) if (!chromiumPathsProp.equals("")) return chromiumPathsProp.split(","); @@ -182,7 +185,8 @@ public class I2PChromium extends I2PChromiumProfileUnpacker { }; } private String[] chromiumBinsWindows() { - String chromiumPathsProp = getProperties().getProperty("chromium.bins.windows"); + String chromiumPathsProp = + getProperties().getProperty("chromium.bins.windows"); if (chromiumPathsProp != null) if (!chromiumPathsProp.equals("")) return chromiumPathsProp.split(","); @@ -766,7 +770,7 @@ public class I2PChromium extends I2PChromiumProfileUnpacker { /** * Stop all running processes managed by the browser manager. - * + * * @return true if successful, false if not */ public boolean stop() { diff --git a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java index fb6b8bd..94bc0b3 100644 --- a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java @@ -74,9 +74,7 @@ public class I2PCommonBrowser { * * @return the properties of the object */ - public Properties getProperties() { - return prop; - } + public Properties getProperties() { return prop; } /** * Validates the user directory. @@ -95,7 +93,8 @@ public class I2PCommonBrowser { logger.info("user.home: " + userHomeFile.getAbsolutePath()); if (!userDirFile.getAbsolutePath().contains("Program Files")) { - if (!userDirFile.getAbsolutePath().equals(userHomeFile.getAbsolutePath())) { + if (!userDirFile.getAbsolutePath().equals( + userHomeFile.getAbsolutePath())) { logger.info("user.dir is not inconvenient"); if (userDirFile.exists()) { logger.info("user.dir exists"); @@ -127,7 +126,8 @@ public class I2PCommonBrowser { defaultPathFile.mkdirs(); } if (!defaultPathFile.isDirectory()) { - logger.info("default path exists and is not a directory, get it out of the way"); + logger.info( + "default path exists and is not a directory, get it out of the way"); logger.info(defaultPathFile.getAbsolutePath()); } System.setProperty("user.dir", defaultPathFile.getAbsolutePath()); @@ -169,7 +169,8 @@ public class I2PCommonBrowser { */ protected boolean isOSX() { String osName = System.getProperty("os.name").toLowerCase(); - return osName.contains("osx") || osName.contains("mac") || osName.contains("apple") || osName.contains("darwin"); + return osName.contains("osx") || osName.contains("mac") || + osName.contains("apple") || osName.contains("darwin"); } /** @@ -229,7 +230,8 @@ public class I2PCommonBrowser { /** * Returns the runtime directory path based on the given override parameter. * - * @param override the name of the environment variable to override the runtime + * @param override the name of the environment variable to override the + * runtime * directory * @return the runtime directory path as a string */ @@ -272,7 +274,8 @@ public class I2PCommonBrowser { * @return true if the directory is valid, false otherwise */ private boolean isDirectoryValid(String directory) { - return directory != null && !directory.isEmpty() && new File(directory).exists(); + return directory != null && !directory.isEmpty() && + new File(directory).exists(); } /** @@ -285,7 +288,8 @@ public class I2PCommonBrowser { * @return the profile directory, or null if it could not be created * @since 0.0.19 */ - protected String profileDirectory(String envVar, String browser, String base, boolean app) { + protected String profileDirectory(String envVar, String browser, String base, + boolean app) { String profileDir = System.getenv(envVar); if (profileDir != null && !profileDir.isEmpty()) { File profileDirFile = new File(profileDir); @@ -306,9 +310,11 @@ public class I2PCommonBrowser { * @param app description of parameter * @return description of return value */ - protected String profileDir(String file, String browser, String base, boolean app) { + protected String profileDir(String file, String browser, String base, + boolean app) { String appString = app ? ".app" : ""; - String profileDirName = String.format("i2p.%s.profile.%s%s", browser, base, appString); + String profileDirName = + String.format("i2p.%s.profile.%s%s", browser, base, appString); File profileDir = new File(file, profileDirName); return profileDir.getAbsolutePath(); } @@ -322,11 +328,12 @@ public class I2PCommonBrowser { * @return true if the profile was successfully unpacked, false otherwise */ protected boolean unpackProfile(String profileDirectory, String browser, - String base) { + String base) { logger.info("Unpacking base profile to " + profileDirectory); try { - final InputStream resources = this.getClass().getClassLoader().getResourceAsStream( - "i2p." + browser + "." + base + ".profile.zip"); + final InputStream resources = + this.getClass().getClassLoader().getResourceAsStream( + "i2p." + browser + "." + base + ".profile.zip"); if (resources == null) { logger.info("Could not find resources"); return false; @@ -366,8 +373,8 @@ public class I2PCommonBrowser { } /** - * Copy a directory from sourceDir to destDir, excluding certain files based on - * browser and base. + * Copy a directory from sourceDir to destDir, excluding certain files based + * on browser and base. * * @param sourceDir directory to be copied from * @param destDir directory to be copied to @@ -375,13 +382,16 @@ public class I2PCommonBrowser { * @param base the base name * @throws IOException if an I/O error occurs during copying */ - protected void copyDirectory(File sourceDir, File destDir, String browser, String base) throws IOException { - destDir = new File(destDir.toString().replace("i2p." + browser + "." + base + ".profile", "")); + protected void copyDirectory(File sourceDir, File destDir, String browser, + String base) throws IOException { + destDir = new File(destDir.toString().replace( + "i2p." + browser + "." + base + ".profile", "")); if (!destDir.exists()) { destDir.mkdir(); } for (String file : sourceDir.list()) { - copyDirectoryCompatibilityMode(new File(sourceDir, file), new File(destDir, file), browser, base); + copyDirectoryCompatibilityMode(new File(sourceDir, file), + new File(destDir, file), browser, base); } } @@ -394,8 +404,10 @@ public class I2PCommonBrowser { * @param base the base * @throws IOException if an I/O error occurs */ - private void copyDirectoryCompatibilityMode(File sourceDirectory, File destinationDirectory, String browser, - String base) throws IOException { + private void copyDirectoryCompatibilityMode(File sourceDirectory, + File destinationDirectory, + String browser, String base) + throws IOException { if (sourceDirectory.isDirectory()) { copyDirectory(sourceDirectory, destinationDirectory, browser, base); } else { @@ -426,9 +438,10 @@ public class I2PCommonBrowser { * copied to * @throws IOException if an I/O error occurs during the file copy process */ - private void copyFile(File sourceFile, File destinationFile) throws IOException { + private void copyFile(File sourceFile, File destinationFile) + throws IOException { try (InputStream in = new FileInputStream(sourceFile); - OutputStream out = new FileOutputStream(destinationFile)) { + OutputStream out = new FileOutputStream(destinationFile)) { byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { @@ -466,9 +479,7 @@ public class I2PCommonBrowser { * @return true if the proxy is ready, false if it is not. * @since 0.0.1 */ - public boolean waitForProxy() { - return waitForProxy(CONFIGURED_TIMEOUT); - } + public boolean waitForProxy() { return waitForProxy(CONFIGURED_TIMEOUT); } /** * Waits for an HTTP proxy on port 4444 to be ready. @@ -546,9 +557,7 @@ public class I2PCommonBrowser { * * @param time */ - public void setProxyTimeoutTime(int time) { - CONFIGURED_TIMEOUT = time; - } + public void setProxyTimeoutTime(int time) { CONFIGURED_TIMEOUT = time; } /** * Joins the elements of the given string array into a single string. diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefox.java b/src/java/net/i2p/i2pfirefox/I2PFirefox.java index 48fc0a6..7579cfd 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefox.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefox.java @@ -59,23 +59,23 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker { List list = new ArrayList(); list = Arrays.asList(firefoxPathsWindows()); getProperties().setProperty("firefox.paths.windows", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(firefoxPathsUnix()); getProperties().setProperty("firefox.paths.linux", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(firefoxPathsOSX()); getProperties().setProperty("firefox.paths.osx", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(firefoxBinsWindows()); getProperties().setProperty("firefox.bins.windows", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(firefoxBinsUnix()); getProperties().setProperty("firefox.bins.linux", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); list = Arrays.asList(firefoxBinsUnix()); getProperties().setProperty("firefox.bins.osx", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); try (OutputStream fos = new FileOutputStream( new File(runtimeDirectory(""), "browser.config"))) { getProperties().store(fos, "Firefox Configuration Section"); @@ -147,7 +147,8 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker { return exePath; } public String[] firefoxPathsWindows() { - String firefoxPathsProp = getProperties().getProperty("firefox.paths.windows"); + String firefoxPathsProp = + getProperties().getProperty("firefox.paths.windows"); if (firefoxPathsProp != null) if (!firefoxPathsProp.equals("")) return firefoxPathsProp.split(","); @@ -180,7 +181,8 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker { }; } private String[] firefoxBinsWindows() { - String firefoxPathsProp = getProperties().getProperty("firefox.bins.windows"); + String firefoxPathsProp = + getProperties().getProperty("firefox.bins.windows"); if (firefoxPathsProp != null) if (!firefoxPathsProp.equals("")) return firefoxPathsProp.split(","); @@ -829,7 +831,7 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker { /** * Stop all running processes managed by the browser manager. - * + * * @return true if successful, false if not */ public boolean stop() { diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java index 87a3e05..1d8b43a 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java @@ -39,7 +39,8 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { return; } profileChecker.logger.info("Profile directory: " + profileDirectory); - boolean isProfileValid = profileChecker.validateProfileDirectory(profileDirectory); + boolean isProfileValid = + profileChecker.validateProfileDirectory(profileDirectory); if (isProfileValid) { profileChecker.logger.info("Profile directory is valid"); } else { @@ -65,7 +66,8 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { */ public boolean validateProfileDirectory(String profileDirectory) { File profileDir = new File(profileDirectory); - if (!profileDir.exists() || !profileDir.isDirectory() || !profileDir.canRead() || !profileDir.canWrite()) { + if (!profileDir.exists() || !profileDir.isDirectory() || + !profileDir.canRead() || !profileDir.canWrite()) { return false; } if (!validateFile(profileDir + "/prefs.js")) { @@ -129,7 +131,8 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { */ private boolean undoHomepage(File fileToBeModified) { String oldStringToFind = "\"browser.startup.homepage\", true"; - String newStringToReplace = "\"browser.startup.homepage\", \"http://127.0.0.1:7657\""; + String newStringToReplace = + "\"browser.startup.homepage\", \"http://127.0.0.1:7657\""; try (Scanner scanner = new Scanner(fileToBeModified)) { while (scanner.hasNextLine()) { String line = scanner.nextLine(); @@ -153,7 +156,7 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { * @return true if the value was successfully undone, false otherwise */ public boolean undoValue(String oldString, String newString, - File fileToBeModified) { + File fileToBeModified) { String oldContent = ""; BufferedReader reader = null; FileWriter writer = null; @@ -190,7 +193,8 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { */ public boolean validateFile(String filePath) { File file = new File(filePath); - if (!file.exists() || !file.isFile() || !file.canRead() || !file.canWrite()) { + if (!file.exists() || !file.isFile() || !file.canRead() || + !file.canWrite()) { return false; } return true; diff --git a/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java b/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java index cd351ba..222cb5d 100644 --- a/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java @@ -67,7 +67,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { list = Arrays.asList(browsers()); getProperties().setProperty("generic.bins.unix", - list.stream().collect(Collectors.joining(","))); + list.stream().collect(Collectors.joining(","))); try (OutputStream fos = new FileOutputStream( new File(runtimeDirectory(""), "browser.config"))) { getProperties().store(fos, "Chromium Configuration Section"); @@ -406,7 +406,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { } /** * Stop all running processes managed by the browser manager. - * + * * @return true if successful, false if not */ public boolean stop() { diff --git a/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java b/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java index 0a5737d..a6ddc32 100644 --- a/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java +++ b/src/java/net/i2p/i2pfirefox/I2PLibreWolf.java @@ -20,5 +20,5 @@ import javax.script.*; * @since 1.0.6 */ public class I2PLibreWolf { - //TODO: provide a librewolf updater here. + // TODO: provide a librewolf updater here. }