package org.greenstone.util; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import org.greenstone.server.BaseProperty; import org.greenstone.util.Misc; import org.apache.log4j.*; public class BrowserLauncher extends Thread { private String url = "about:blank" ; static Logger logger = Logger.getLogger(org.greenstone.util.BrowserLauncher.class.getName()); private String[] default_browsers = new String[]{"firefox","mozilla"}; private String command = ""; private int state = -1; //0: launch success, 1: launch failed public final static int LAUNCHSUCCESS = 0; public final static int LAUNCHFAILED = 1; private String browserPath = ""; public BrowserLauncher(String browserPath, String url) { this.url = url; this.browserPath = browserPath; //use the default browser if (this.browserPath.equals("")){ setBrowserCommand(); } else{ this.command = this.browserPath + " " + this.url; } } public BrowserLauncher(){ } // we should try and use settings from the settings panel?? protected void setBrowserCommand() { if(Misc.isWindows()) { // we use cmd and start if (Misc.isWindows9x()) { this.command = BaseProperty.WIN_9X_OPEN_COMMAND;//"command.com /c start \""+url+"\""; } else { this.command = BaseProperty.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\""; } } else if (Misc.isMac()) { this.command = BaseProperty.MAC_OPEN_COMMAND; // "open %1" } else { // we try to look for a browser for (int i=0; i