don't always wait in the background
This commit is contained in:
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
public class I2PChromium {
|
||||
private final String[] CHROMIUM_SEARCH_PATHS = CHROMIUM_FINDER();
|
||||
private final int DEFAULT_TIMEOUT = 200;
|
||||
private Process p = null;
|
||||
|
||||
/**
|
||||
* Construct an I2PChromium class which manages an instance of Chromium and
|
||||
@ -467,6 +468,38 @@ public class I2PChromium {
|
||||
}
|
||||
|
||||
|
||||
public Process launchAndDetatch(boolean privateWindow, String[] url){
|
||||
if (waitForProxy()) {
|
||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||
if (I2PChromiumProfileChecker.validateProfileDirectory(profileDirectory)) {
|
||||
System.out.println("Valid profile directory: "+profileDirectory);
|
||||
} else {
|
||||
System.out.println("Invalid profile directory: "+profileDirectory+" rebuilding...");
|
||||
if (!I2PChromiumProfileBuilder.copyBaseProfiletoProfile()) {
|
||||
System.out.println("Failed to rebuild profile directory: "+profileDirectory);
|
||||
return null;
|
||||
} else {
|
||||
System.out.println("Rebuilt profile directory: "+profileDirectory);
|
||||
}
|
||||
}
|
||||
ProcessBuilder pb = null;
|
||||
if (privateWindow) {
|
||||
pb = this.privateProcessBuilder(url);
|
||||
} else {
|
||||
pb = this.defaultProcessBuilder(url);
|
||||
}
|
||||
try{
|
||||
System.out.println(pb.command());
|
||||
p = pb.start();
|
||||
sleep(2000);
|
||||
return p;
|
||||
}catch(Throwable e){
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a profile directory with a proxy configuration.
|
||||
* Waits for an HTTP proxy on the port 4444 to be ready.
|
||||
@ -477,42 +510,19 @@ public class I2PChromium {
|
||||
* @since 0.0.17
|
||||
*/
|
||||
public void launch(boolean privateWindow, String[] url){
|
||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||
if (I2PChromiumProfileChecker.validateProfileDirectory(profileDirectory)) {
|
||||
System.out.println("Valid profile directory: "+profileDirectory);
|
||||
} else {
|
||||
System.out.println("Invalid profile directory: "+profileDirectory+" rebuilding...");
|
||||
if (!I2PChromiumProfileBuilder.copyBaseProfiletoProfile()) {
|
||||
System.out.println("Failed to rebuild profile directory: "+profileDirectory);
|
||||
return;
|
||||
} else {
|
||||
System.out.println("Rebuilt profile directory: "+profileDirectory);
|
||||
}
|
||||
}
|
||||
if (waitForProxy()){
|
||||
ProcessBuilder pb = null;
|
||||
if (privateWindow) {
|
||||
pb = this.privateProcessBuilder(url);
|
||||
} else {
|
||||
pb = this.defaultProcessBuilder(url);
|
||||
}
|
||||
if (waitForProxy()) {
|
||||
p = launchAndDetatch(privateWindow, url);
|
||||
System.out.println("I2PChromium");
|
||||
try{
|
||||
System.out.println(pb.command());
|
||||
Process p = pb.start();
|
||||
sleep(2000);
|
||||
System.out.println("I2PChromium");
|
||||
try{
|
||||
System.out.println("Waiting for I2PChromium to close...");
|
||||
int exit = p.waitFor();
|
||||
System.out.println("I2PChromium exited with value: "+exit);
|
||||
}catch(Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
}
|
||||
System.out.println("Waiting for I2PChromium to close...");
|
||||
int exit = p.waitFor();
|
||||
System.out.println("I2PChromium exited with value: "+exit);
|
||||
}catch(Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a profile directory with a proxy configuration.
|
||||
* Waits for an HTTP proxy on the port 4444 to be ready.
|
||||
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
public class I2PFirefox {
|
||||
private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER();
|
||||
private final int DEFAULT_TIMEOUT = 200;
|
||||
private Process p = null;
|
||||
|
||||
/**
|
||||
* Construct an I2PFirefox class which manages an instance of Firefox and
|
||||
@ -429,6 +430,40 @@ public class I2PFirefox {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Process launchAndDetatch(boolean privateWindow, String[] url){
|
||||
if (waitForProxy()){
|
||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||
if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) {
|
||||
System.out.println("Valid profile directory: "+profileDirectory);
|
||||
} else {
|
||||
System.out.println("Invalid profile directory: "+profileDirectory+" rebuilding...");
|
||||
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile()) {
|
||||
System.out.println("Failed to rebuild profile directory: "+profileDirectory);
|
||||
return null;
|
||||
} else {
|
||||
System.out.println("Rebuilt profile directory: "+profileDirectory);
|
||||
}
|
||||
}
|
||||
ProcessBuilder pb;
|
||||
if (privateWindow) {
|
||||
pb = privateProcessBuilder(url);
|
||||
} else {
|
||||
pb = defaultProcessBuilder(url);
|
||||
}
|
||||
try{
|
||||
System.out.println(pb.command());
|
||||
p = pb.start();
|
||||
System.out.println("I2PFirefox");
|
||||
sleep(2000);
|
||||
return p;
|
||||
}catch(Throwable e){
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a profile directory with a proxy configuration.
|
||||
* Waits for an HTTP proxy on the port 4444 to be ready.
|
||||
@ -439,37 +474,12 @@ public class I2PFirefox {
|
||||
* @since 0.0.17
|
||||
*/
|
||||
public void launch(boolean privateWindow, String[] url){
|
||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||
if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) {
|
||||
System.out.println("Valid profile directory: "+profileDirectory);
|
||||
} else {
|
||||
System.out.println("Invalid profile directory: "+profileDirectory+" rebuilding...");
|
||||
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile()) {
|
||||
System.out.println("Failed to rebuild profile directory: "+profileDirectory);
|
||||
return;
|
||||
} else {
|
||||
System.out.println("Rebuilt profile directory: "+profileDirectory);
|
||||
}
|
||||
}
|
||||
if (waitForProxy()){
|
||||
ProcessBuilder pb;
|
||||
if (privateWindow) {
|
||||
pb = privateProcessBuilder(url);
|
||||
} else {
|
||||
pb = defaultProcessBuilder(url);
|
||||
}
|
||||
p = launchAndDetatch(privateWindow, url);
|
||||
try{
|
||||
System.out.println(pb.command());
|
||||
Process p = pb.start();
|
||||
System.out.println("I2PFirefox");
|
||||
sleep(2000);
|
||||
try{
|
||||
System.out.println("Waiting for I2PFirefox to close...");
|
||||
int exit = p.waitFor();
|
||||
System.out.println("I2PFirefox exited with value: "+exit);
|
||||
}catch(Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
}
|
||||
System.out.println("Waiting for I2PFirefox to close...");
|
||||
int exit = p.waitFor();
|
||||
System.out.println("I2PFirefox exited with value: "+exit);
|
||||
}catch(Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.util.Scanner;
|
||||
public class I2PGenericUnsafeBrowser {
|
||||
private final int DEFAULT_TIMEOUT = 200;
|
||||
public static String BROWSER = "";
|
||||
private Process p = null;
|
||||
// Ideally, EVERY browser in this list should honor http_proxy, https_proxy, ftp_proxy and no_proxy.
|
||||
// in practice, this is going to be hard to guarantee. For now, we're just assuming. So don't use this until
|
||||
// I understand the situation better, unless you think you know better.
|
||||
@ -350,7 +351,7 @@ public class I2PGenericUnsafeBrowser {
|
||||
}
|
||||
|
||||
|
||||
public void launch(boolean privateWindow, String[] url){
|
||||
public Process launchAndDetatch(boolean privateWindow, String[] url){
|
||||
if (waitForProxy()){
|
||||
ProcessBuilder pb;
|
||||
if (privateWindow) {
|
||||
@ -360,25 +361,34 @@ public class I2PGenericUnsafeBrowser {
|
||||
}
|
||||
try{
|
||||
System.out.println(pb.command());
|
||||
Process p = pb.start();
|
||||
p = pb.start();
|
||||
System.out.println("I2PBrowser");
|
||||
sleep(2000);
|
||||
try{
|
||||
System.out.println("Waiting for I2PBrowser to close...");
|
||||
int exit = p.waitFor();
|
||||
if (privateWindow){
|
||||
if (deleteRuntimeDirectory())
|
||||
System.out.println("Private browsing enforced, deleting runtime directory");
|
||||
}
|
||||
System.out.println("I2PBrowser exited with value: "+exit);
|
||||
}catch(Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
return p;
|
||||
}catch(Throwable e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void launch(boolean privateWindow, String[] url){
|
||||
if (waitForProxy()){
|
||||
p = launchAndDetatch(privateWindow, url);
|
||||
try{
|
||||
System.out.println("Waiting for I2PBrowser to close...");
|
||||
int exit = p.waitFor();
|
||||
if (privateWindow){
|
||||
if (deleteRuntimeDirectory())
|
||||
System.out.println("Private browsing enforced, deleting runtime directory");
|
||||
}
|
||||
System.out.println("I2PBrowser exited with value: "+exit);
|
||||
}catch(Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sleep(int millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
|
Reference in New Issue
Block a user