Get rid of unuseful unpacker classes

This commit is contained in:
eyedeekay
2024-08-26 20:17:24 -04:00
parent aca1dd618d
commit b46abac574
6 changed files with 6 additions and 93 deletions

View File

@ -26,7 +26,7 @@ import java.util.stream.Stream;
* @author idk * @author idk
* @since 0.0.1 * @since 0.0.1
*/ */
public class I2PChromium extends I2PChromiumProfileUnpacker { public class I2PChromium extends I2PChromiumProfileBuilder {
private final String[] CHROMIUM_SEARCH_PATHS = CHROMIUM_FINDER(); private final String[] CHROMIUM_SEARCH_PATHS = CHROMIUM_FINDER();
private Process p = null; private Process p = null;
private String chromePath; private String chromePath;

View File

@ -30,8 +30,7 @@ public class I2PChromiumProfileBuilder extends I2PChromiumProfileChecker {
return profileDir.getAbsolutePath(); return profileDir.getAbsolutePath();
} else { } else {
// create the directory // create the directory
I2PChromiumProfileUnpacker unpacker = new I2PChromiumProfileUnpacker(); if (!this.unpackProfile(profileDir.getAbsolutePath(), "chromium", mode)) {
if (!unpacker.unpackProfile(profileDir.getAbsolutePath(), mode)) {
return null; return null;
} }
return profileDir.getAbsolutePath(); return profileDir.getAbsolutePath();
@ -54,8 +53,7 @@ public class I2PChromiumProfileBuilder extends I2PChromiumProfileChecker {
if (pdf.exists() && pdf.isDirectory()) { if (pdf.exists() && pdf.isDirectory()) {
return pd; return pd;
} else { } else {
I2PChromiumProfileUnpacker unpacker = new I2PChromiumProfileUnpacker(); if (!this.unpackProfile(pdf.getAbsolutePath(), "chromium", mode)) {
if (!unpacker.unpackProfile(pdf.getAbsolutePath(), mode)) {
return null; return null;
} }
} }

View File

@ -1,42 +0,0 @@
package net.i2p.i2pfirefox;
/**
* I2PChromiumProfileUnpacker.java
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License. See LICENSE.md for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* I2PChromiumProfileUnpacker is a class that unpacks the Chromium profile zip
* file into the Chromium base profile directory. This is not used by the
* Chromium browser instance, it's unpacked to the disk to be copied to the
* active profile directory.
*
* @author idk
* @since 0.0.1
*/
public class I2PChromiumProfileUnpacker extends I2PChromiumProfileBuilder {
public static void main(String[] args) {
I2PChromiumProfileUnpacker pu = new I2PChromiumProfileUnpacker();
String profileDirectory = pu.profileDirectory("base");
if (profileDirectory == null) {
pu.logger.info("No profile directory found");
return;
}
}
/**
* unpack the profile directory
*
* @return true if the profile directory was successfully unpacked
* @since 0.0.1
*/
public boolean unpackProfile(String profileDirectory, String mode) {
logger.info("Unpacking base profile to " + profileDirectory);
return unpackProfile(profileDirectory, "chromium", mode);
}
}

View File

@ -27,7 +27,7 @@ import java.util.stream.Stream;
* @author idk * @author idk
* @since 0.0.1 * @since 0.0.1
*/ */
public class I2PFirefox extends I2PFirefoxProfileUnpacker { public class I2PFirefox extends I2PFirefoxProfileBuilder {
private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER(); private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER();
private Process process = null; private Process process = null;
private String firefoxPath; private String firefoxPath;

View File

@ -109,8 +109,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
return profileDir.getAbsolutePath(); return profileDir.getAbsolutePath();
} else { } else {
// create the directory // create the directory
I2PFirefoxProfileUnpacker unpacker = new I2PFirefoxProfileUnpacker(); if (!this.unpackProfile(profileDir.getAbsolutePath(), "firefox", base)) {
if (!unpacker.unpackProfile(profileDir.getAbsolutePath(), base)) {
return null; return null;
} }
return profileDir.getAbsolutePath(); return profileDir.getAbsolutePath();
@ -129,8 +128,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
if (pdf.exists() && pdf.isDirectory()) { if (pdf.exists() && pdf.isDirectory()) {
return pd; return pd;
} else { } else {
I2PFirefoxProfileUnpacker unpacker = new I2PFirefoxProfileUnpacker(); if (!this.unpackProfile(pdf.getAbsolutePath(), "firefox", base)) {
if (!unpacker.unpackProfile(pdf.getAbsolutePath(), base)) {
return null; return null;
} }
} }

View File

@ -1,41 +0,0 @@
package net.i2p.i2pfirefox;
/**
* I2PFirefoxProfileUnpacker.java
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License. See LICENSE.md for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* I2PFirefoxProfileUnpacker is a class that unpacks the I2P Firefox profile
* from a zip file embedded in the `jar` file. The zip is unpacked to a base
* directory where it is left untouched, and the base profile is copied to the
* active profile directory.
*
* @author idk
* @since 0.0.1
*/
public class I2PFirefoxProfileUnpacker extends I2PFirefoxProfileBuilder {
public static void main(String[] args) {
I2PFirefoxProfileUnpacker up = new I2PFirefoxProfileUnpacker();
String profileDirectory = up.profileDirectory(false, "base");
if (profileDirectory == null) {
up.logger.info("No profile directory found");
return;
}
}
/**
* unpack the profile directory
*
* @return true if the profile directory was successfully unpacked
* @since 0.0.1
*/
public boolean unpackProfile(String profileDirectory, String base) {
return unpackProfile(profileDirectory, "firefox", base);
}
}