I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 87295b4b authored by zzz's avatar zzz
Browse files

* URLLauncher: Add xdg-open (ticket #617); minor refactor

parent 23ca6b4f
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,32 @@ public class UrlLauncher { ...@@ -43,6 +43,32 @@ public class UrlLauncher {
private static final int MAX_WAIT_TIME = 5*60*1000; private static final int MAX_WAIT_TIME = 5*60*1000;
private static final int MAX_TRIES = 99; private static final int MAX_TRIES = 99;
/**
* Browsers to try IN-ORDER
*/
private static final String[] BROWSERS = {
// This debian script tries everything in $BROWSER, then gnome-www-browser and x-www-browser
// if X is running and www-browser otherwise. Those point to the user's preferred
// browser using the update-alternatives system.
"sensible-browser",
// another one that opens a preferred browser
"xdg-open",
// Try x-www-browser directly
"x-www-browser",
// general graphical browsers
"defaultbrowser", // puppy linux
"opera -newpage",
"firefox",
"mozilla",
"netscape",
"konqueror",
"galeon",
// Text Mode Browsers only below here
"www-browser",
"links",
"lynx"
};
/** /**
* Prevent bad user experience by waiting for the server to be there * Prevent bad user experience by waiting for the server to be there
* before launching the browser. * before launching the browser.
...@@ -156,7 +182,7 @@ public class UrlLauncher { ...@@ -156,7 +182,7 @@ public class UrlLauncher {
if (bufferedReader != null) if (bufferedReader != null)
try { bufferedReader.close(); } catch (IOException ioe) {} try { bufferedReader.close(); } catch (IOException ioe) {}
} }
if (_shellCommand.executeSilentAndWaitTimed(browserString + " " + url, 5)) if (_shellCommand.executeSilentAndWaitTimed(browserString + ' ' + url, 5))
return true; return true;
} else { } else {
...@@ -164,48 +190,10 @@ public class UrlLauncher { ...@@ -164,48 +190,10 @@ public class UrlLauncher {
// fall through // fall through
} }
// This debian script tries everything in $BROWSER, then gnome-www-browser and x-www-browser for (int i = 0; i < BROWSERS.length; i++) {
// if X is running and www-browser otherwise. Those point to the user's preferred if (_shellCommand.executeSilentAndWaitTimed(BROWSERS[i] + ' ' + url, 5))
// browser using the update-alternatives system. return true;
if (_shellCommand.executeSilentAndWaitTimed("sensible-browser " + url, 5)) }
return true;
// Try x-www-browser directly
if (_shellCommand.executeSilentAndWaitTimed("x-www-browser " + url, 5))
return true;
// puppy linux
if (_shellCommand.executeSilentAndWaitTimed("defaultbrowser " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("opera -newpage " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("firefox " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("mozilla " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("netscape " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("konqueror " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("galeon " + url, 5))
return true;
// Text Mode Browsers only below here
if (_shellCommand.executeSilentAndWaitTimed("www-browser " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("links " + url, 5))
return true;
if (_shellCommand.executeSilentAndWaitTimed("lynx " + url, 5))
return true;
} }
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment