diff options
author | Yana Stamcheva <yana@jitsi.org> | 2008-03-03 19:13:22 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2008-03-03 19:13:22 +0000 |
commit | 5b4a4cfa69f949f2a48756f880ba17e28111b316 (patch) | |
tree | 2b460c729463353471734290137ce9736f83b2f2 /src/net/java/sip/communicator/launcher/BrowserLauncher.java | |
parent | b40ce115fb89cf3b8da845c66adbae8507ebd837 (diff) | |
download | jitsi-5b4a4cfa69f949f2a48756f880ba17e28111b316.zip jitsi-5b4a4cfa69f949f2a48756f880ba17e28111b316.tar.gz jitsi-5b4a4cfa69f949f2a48756f880ba17e28111b316.tar.bz2 |
The defaul felix launcher is replaced by the SIP Communicator launcher, which will check the java version before starting the application and will show the appropriate message for the requirements.
Diffstat (limited to 'src/net/java/sip/communicator/launcher/BrowserLauncher.java')
-rw-r--r-- | src/net/java/sip/communicator/launcher/BrowserLauncher.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/launcher/BrowserLauncher.java b/src/net/java/sip/communicator/launcher/BrowserLauncher.java new file mode 100644 index 0000000..4482bda --- /dev/null +++ b/src/net/java/sip/communicator/launcher/BrowserLauncher.java @@ -0,0 +1,76 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.launcher; + +import com.apple.eio.*; + +/** + * A simple implementation of the BrowserLauncherService. Checks the operating + * system and launches the appropriate browser. + * + * @author Yana Stamcheva + */ +public class BrowserLauncher +{ + public void openURL(String url) + { + new LaunchBrowser(url).start(); + } + + /** + * Launch browser in a separate thread. + */ + private class LaunchBrowser extends Thread + { + private String url; + + public LaunchBrowser(String url) + { + this.url = url; + } + + public void run() + { + try + { + String osName = System.getProperty("os.name"); + + if (osName.startsWith("Mac OS")) + { + FileManager.openURL(url); + } + else if (osName.startsWith("Windows")) + { + Runtime.getRuntime().exec( + "rundll32 url.dll,FileProtocolHandler " + url); + } + else + { + String[] browsers = {"firefox", "iceweasel", "opera", "konqueror", + "epiphany", "mozilla", "netscape" }; + + String browser = null; + + for (int i = 0; i < browsers.length && browser == null; i ++) + { + if (Runtime.getRuntime().exec( + new String[] {"which", browsers[i]}).waitFor() == 0) + browser = browsers[i]; + } + if (browser == null) + throw new Exception("Could not find web browser"); + else + Runtime.getRuntime().exec(new String[] {browser, url}); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } +}
\ No newline at end of file |