diff --git a/build.xml b/build.xml index 23800be33..7b91c6ab8 100644 --- a/build.xml +++ b/build.xml @@ -481,7 +481,7 @@ description="Starts felix and runs sip-comunicator gui (use latest build)."> - diff --git a/lib/sc-launcher.jar b/lib/sc-launcher.jar new file mode 100644 index 000000000..04526ba38 Binary files /dev/null and b/lib/sc-launcher.jar differ diff --git a/resources/install/build.xml b/resources/install/build.xml index 1eea1690b..836984b18 100644 --- a/resources/install/build.xml +++ b/resources/install/build.xml @@ -345,7 +345,7 @@ name="${application.name}" shortname="${application.name}" signature="sipc" - mainclass="org.apache.felix.main.Main" + mainclass="net.java.sip.communicator.launcher.SIPCommunicator" icon="resources/images/logo/sc_logo_128x128.icns" jvmversion="1.5+" version="${sip-communicator.version}" diff --git a/resources/install/debian/sip-communicator.sh.tmpl b/resources/install/debian/sip-communicator.sh.tmpl index c370510bf..a7e74ab86 100644 --- a/resources/install/debian/sip-communicator.sh.tmpl +++ b/resources/install/debian/sip-communicator.sh.tmpl @@ -27,10 +27,10 @@ javabin=`which java` SCDIR=/usr/lib/sip-communicator LIBPATH=$SCDIR/lib -CLASSPATH=$LIBPATH/jdic_stub.jar:$LIBPATH/jdic-all.jar:$LIBPATH/felix.jar:$SCDIR/sc-bundles/util.jar +CLASSPATH=$LIBPATH/jdic_stub.jar:$LIBPATH/jdic-all.jar:$LIBPATH/felix.jar:$LIBPATH/sc-launcher.jar:$SCDIR/sc-bundles/util.jar FELIX_CONFIG=$LIBPATH/felix.client.run.properties LOG_CONFIG=$LIBPATH/logging.properties -COMMAND="$javabin -classpath $CLASSPATH -Dfelix.config.properties=file:$FELIX_CONFIG -Djava.util.logging.config.file=$LOG_CONFIG org.apache.felix.main.Main" +COMMAND="$javabin -classpath $CLASSPATH -Dfelix.config.properties=file:$FELIX_CONFIG -Djava.util.logging.config.file=$LOG_CONFIG net.java.sip.communicator.launcher.SIPCommunicator" #set add LIBPATH to LD_LIBRARY_PATH for any sc natives (e.g. jmf .so's) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBPATH/native diff --git a/resources/install/generic/run.sh b/resources/install/generic/run.sh index 9646cbd69..dca07b5db 100644 --- a/resources/install/generic/run.sh +++ b/resources/install/generic/run.sh @@ -1,4 +1,4 @@ mkdir -p $HOME/.sip-communicator/log export PATH=$PATH:native -java -classpath "lib/jdic-all.jar:lib/jdic_stub.jar:lib/felix.jar:sc-bundles/util.jar" -Djava.library.path=native -Dfelix.config.properties=file:./lib/felix.client.run.properties -Djava.util.logging.config.file=lib/logging.properties org.apache.felix.main.Main +java -classpath "lib/jdic-all.jar:lib/jdic_stub.jar:lib/felix.jar:lib/sc-launcher.jar:sc-bundles/util.jar" -Djava.library.path=native -Dfelix.config.properties=file:./lib/felix.client.run.properties -Djava.util.logging.config.file=lib/logging.properties net.java.sip.communicator.launcher.SIPCommunicator diff --git a/resources/install/linux/run.sh b/resources/install/linux/run.sh index 944205efc..dc48fa95f 100755 --- a/resources/install/linux/run.sh +++ b/resources/install/linux/run.sh @@ -2,4 +2,4 @@ mkdir -p $HOME/.sip-communicator/log export PATH=$PATH:native export JAVA_HOME=jre -${JAVA_HOME}/bin/java -classpath "lib/jdic-all.jar:lib/jdic_stub.jar:lib/felix.jar:sc-bundles/util.jar" -Djava.library.path=native -Dfelix.config.properties=file:./lib/felix.client.run.properties -Djava.util.logging.config.file=lib/logging.properties org.apache.felix.main.Main +${JAVA_HOME}/bin/java -classpath "lib/jdic-all.jar:lib/jdic_stub.jar:lib/felix.jar:lib/sc-launcher.jar:sc-bundles/util.jar" -Djava.library.path=native -Dfelix.config.properties=file:./lib/felix.client.run.properties -Djava.util.logging.config.file=lib/logging.properties net.java.sip.communicator.launcher.SIPCommunicator diff --git a/resources/install/windows/run.bat b/resources/install/windows/run.bat index f1fce5d16..09459ed63 100755 --- a/resources/install/windows/run.bat +++ b/resources/install/windows/run.bat @@ -1,4 +1,4 @@ mkdir "%UserProfile%/.sip-communicator/log" set PATH=%PATH%;native -start javaw -classpath "lib/jdic-all.jar;lib/jdic_stub.jar;lib/felix.jar;sc-bundles/util.jar" -Dfelix.config.properties=file:./lib/felix.client.run.properties -Djava.util.logging.config.file=lib/logging.properties org.apache.felix.main.Main +start javaw -classpath "lib/jdic-all.jar;lib/jdic_stub.jar;lib/felix.jar;lib/sc-launcher.jar;sc-bundles/util.jar" -Dfelix.config.properties=file:./lib/felix.client.run.properties -Djava.util.logging.config.file=lib/logging.properties net.java.sip.communicator.launcher.SIPCommunicator servicebin \ No newline at end of file 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 000000000..4482bda3e --- /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 diff --git a/src/net/java/sip/communicator/launcher/ChangeJVMFrame.java b/src/net/java/sip/communicator/launcher/ChangeJVMFrame.java new file mode 100644 index 000000000..32283dd06 --- /dev/null +++ b/src/net/java/sip/communicator/launcher/ChangeJVMFrame.java @@ -0,0 +1,102 @@ +/* + * 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 java.awt.*; + +import javax.swing.*; +import javax.swing.event.*; + +/** + * The ChangeJVMFrame will ask the user to install the newest java + * version if she's using an old and icompatible one. + * + * @author Yana Stamcheva + */ +public class ChangeJVMFrame + extends JFrame +{ + /** + * The MacOSX operating system. + */ + public static final String MAC_OSX = "MacOSX"; + + /** + * The Windows operating system. + */ + public static final String WINDOWS = "Windows"; + + /** + * The Linux operating system. + */ + public static final String LINUX = "Linux"; + + private JTextArea textArea = new JTextArea(); + + private JEditorPane javaLinkPane = new JEditorPane(); + + private String text = "Sorry. Your Java version is too old. The minimum" + + " Java version required is 1.5. Please folow the link below to install" + + " the newest version for your environment."; + + private String macLink + = "Download Java 1.5 for MacOSX"; + + private String defaultLink + = "Download Java 1.6"; + + private JPanel mainPanel = new JPanel(new BorderLayout()); + + public ChangeJVMFrame(String osName) + { + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + this.setTitle("SIP Communicator requirements"); + + this.mainPanel.setPreferredSize( + new Dimension(450, 150)); + + this.mainPanel.setBorder( + BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + this.textArea.setOpaque(false); + this.textArea.setLineWrap(true); + this.textArea.setWrapStyleWord(true); + this.textArea.setText(text); + this.textArea.setEditable(false); + + this.javaLinkPane.setOpaque(false); + this.javaLinkPane.setContentType("text/html"); + this.javaLinkPane.setEditable(false); + + if (osName.equals(MAC_OSX)) + this.javaLinkPane.setText(macLink); + else + this.javaLinkPane.setText(defaultLink); + + this.javaLinkPane.addHyperlinkListener(new HyperlinkListener() + { + public void hyperlinkUpdate(HyperlinkEvent e) + { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) + { + new BrowserLauncher().openURL(e.getDescription()); + } + } + }); + + this.mainPanel.add(textArea, BorderLayout.NORTH); + this.mainPanel.add(javaLinkPane, BorderLayout.CENTER); + + this.getContentPane().add(mainPanel); + + this.pack(); + } +} diff --git a/src/net/java/sip/communicator/launcher/SIPCommunicator.java b/src/net/java/sip/communicator/launcher/SIPCommunicator.java index c07081fdd..2e268892e 100644 --- a/src/net/java/sip/communicator/launcher/SIPCommunicator.java +++ b/src/net/java/sip/communicator/launcher/SIPCommunicator.java @@ -6,6 +6,10 @@ */ package net.java.sip.communicator.launcher; +import java.awt.*; + +import javax.swing.*; + import org.apache.felix.main.*; /** @@ -22,7 +26,35 @@ public class SIPCommunicator */ public static void main(String[] args) throws Exception - { - Main.main(args); + { + String version = System.getProperty("java.version"); + String vmVendor = System.getProperty("java.vendor"); + String osName = System.getProperty("os.name"); + + if (version.startsWith("1.4") || vmVendor.startsWith("Gnu")) + { + String os = ""; + + if (osName.startsWith("Mac")) + os = ChangeJVMFrame.MAC_OSX; + else if (osName.startsWith("Linux")) + os = ChangeJVMFrame.LINUX; + else if (osName.startsWith("Windows")) + os = ChangeJVMFrame.WINDOWS; + + ChangeJVMFrame changeJVMFrame = new ChangeJVMFrame(os); + + changeJVMFrame.setLocation( + Toolkit.getDefaultToolkit().getScreenSize().width/2 + - changeJVMFrame.getWidth()/2, + Toolkit.getDefaultToolkit().getScreenSize().height/2 + - changeJVMFrame.getHeight()/2 + ); + changeJVMFrame.setVisible(true); + + return; + } + + Main.main(args); } }