[sip-comm-dev] Java webstart applet version


#1

Hello dev,

I'm Mehdi Souilah, student at Louis Pasteur University – Strasbourg, I
selected Sip Communicator Java Web Start as project this semester, and we
worked (me and Gabor Jager) together on this project.

As Gabor Jager has explained in the previous post, he spoke about Felix,
JNLP and how to launch an application from the web without installation,
we'll not repeat it, because until the launch of Sip Communicator is the
same configuration for Felix and JNLP.

The problem was how to show download bundles' progression to the user when
he clicks on the link to launch Sip Communicator. We noted when the user
clicks on the link and open the JNLP file, Felix starts downloading itself,
after this step, Felix downloads the others "file.jars" specified in the
"properties" file, but Felix don't displays to user a frame to show the
download progression.

Until here, we have got two solutions, the first solution was detailed by
Gabor, the second solution was the use of a Java Applet, and we read
periodically (about 5 seconds) the folder which contains bundles downloaded
by Felix. The idea is to count the bundles stored on our website by a PHP
script blow, and put it in the parameter of our applet HTML file.

   *<?php*

*//define the path as relative*

*$path = "../sc-bundles";*

*//using the opendir function*

*$dir_handle = @opendir($path) or die("Unable to open $path");*

*$num = 0;*

*//running the while loop*

*while ($file = readdir($dir_handle)) {*

*if ($file != "." && $file != "..") $num++;*

*}*

*//closing the directory*

*closedir($dir_handle);*

*echo '<applet code="AppletProgress.class" width="450" height="375"
archive="progressApplet.jar" align="middle" >';*

*echo '<PARAM NAME="bundlesCount" VALUE="'.$num.'">'*

*?>*

*..........*

*<PARAM NAME="urlJNLP" VALUE="http://website.com/sip/sipLauncher.jnlp">*

*<PARAM NAME="timeOut" VALUE="15"> <!-- about 15 minutes -->*

*<PARAM NAME="sipPath" VALUE=".sip-communicator_jws">*

*<PARAM NAME="sipPageHTML" VALUE="
http://www.sip-communicator.org/index.php/Main/HomePage">'*

*</APPLET><BR>*

*......**....*

For this applet we use some parameters that we detail below:

- urlJNLP: the path of our JNLP.

- timeout: used by the applet, it gives interval time to the user before
downloading bundles, if this interval is exceeded, we display an error
message.

- sipPath: path where bundles will be stored on the client machine.

- sipPageHTML: we use this address to make redirection to sip communicator
website once the

download is achieved, but we suggest to redirect to a JavaScript page to
close the browser (code below).

   *<HTML>*

*<HEAD>*

*<TITLE>Close HTML</TITLE>*

*</HEAD>*

*<BODY onload="goodbye()">*

*<SCRIPT language="JavaScript">*

*function goodbye()*

*{*

*if(false == self.closed)*

*{*

*self.close ();*

*}*

*else*

*{*

*alert('Window already closed!');*

*}*

*}*

*</SCRIPT>*

*</body>*

*</HTML>*

Now lets speak about the applet, we use in this applet two functions and
some parameters, the first function called "parseFolder (String path)" takes
one parameter, which the path where bundles will be stored and lists all
bundles. The second function "checkBundles ( )" without parameter, calls the
first function periodically to list our folder until the end of downloading.

Take a look to the screenshot execution (file enclosed), I can't put it in
HTML format.

JNLP File sample:

   *<?xml version="1.0" encoding="utf-8"?> *

*<!-- JNLP File --> *

*<jnlp spec="1.0+" codebase="http://mehdi.soft.free.fr/sip"
href="sipLauncher.jnlp">*

*<information>*

*<title>SIP-COMMUNICATOR</title>*

*<vendor>S. Mehdi - mascodo@gmail.com</vendor>*

*<description>SIP launch test by Java webstart</description>*

*<homepage href=“http://www.sip-communicator.org”/>*

*<description kind="short">JNLP launch test for
Sip-Communicator</description>*

*<offline-allowed/>*

*</information>*

*<security>*

*<all-permissions/>*

*</security>*

*<resources>*

* <j2se version=“1.6+” href=“http://java.sun.com/products/autodl/j2se”/>*

* <!-- jar href="/jars/sipProgress.jar"/ -->*

* <!-- extension href="/sipProgressBar.jnlp" / -->*

* <jar href="http://mehdi.soft.free.fr/sip/lib/felix.jar" main="true" />*

* *

* <property name="felix.config.properties" value= "
http://mehdi.soft.free.fr/sip/lib/felix.client.run.properties" />*

*</resources>*

*<!-- component-desc/ -->*

* <!-- installer-desc main-class="org.apache.felix.main.Main" / -->*

*<application-desc main-class="org.apache.felix.main.Main" />*

*</jnlp>*

Note: each jar file mentioned in the JNLP file must be signed with a java
certificate, because Java virtual machine refuses to execute it.

You find the code source, HTML and JNLP files attached here.

Next: in the future we plan to improve this version to add more functions,
as uninstalling bundles…etc.

*I'll send sources to Emile soon.*

We hope you enjoy our work, and we accept all suggestions.

Thank you.

S.Mehdi