clang-format everything, whitespace-only changes
This commit is contained in:
@ -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; }
|
||||
|
||||
@ -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) {
|
||||
|
@ -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(",");
|
||||
|
@ -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();
|
||||
}
|
||||
@ -325,7 +331,8 @@ public class I2PCommonBrowser {
|
||||
String base) {
|
||||
logger.info("Unpacking base profile to " + profileDirectory);
|
||||
try {
|
||||
final InputStream resources = this.getClass().getClassLoader().getResourceAsStream(
|
||||
final InputStream resources =
|
||||
this.getClass().getClassLoader().getResourceAsStream(
|
||||
"i2p." + browser + "." + base + ".profile.zip");
|
||||
if (resources == null) {
|
||||
logger.info("Could not find resources");
|
||||
@ -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,7 +438,8 @@ 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)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
@ -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.
|
||||
|
@ -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(",");
|
||||
|
@ -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();
|
||||
@ -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;
|
||||
|
Reference in New Issue
Block a user