UpdateCheck now look for last version from properties file located on download site

cusax-fix
Damian Minkov 18 years ago
parent 338e5c1908
commit 9f61ba8d43

@ -345,7 +345,7 @@
<sip-communicator-version property="sip-communicator.version" />
<echo message="SIP Communicator version ${sip-communicator.version}" />
<echo message="SIP Communicator version ${sip-communicator.version}" />
</target>
<!--INIT-->
@ -616,7 +616,8 @@
bundle-pluginmanager,bundle-notification,
bundle-ssh,bundle-plugin-sshaccregwizz,
bundle-contacteventhandler,bundle-plugin-contactinfo,
bundle-plugin-accountinfo,bundle-plugin-chatalerter"/>
bundle-plugin-accountinfo,bundle-plugin-chatalerter,
bundle-updatecheckplugin"/>
<!--BUNDLE-HISTORY-->
<target name="bundle-history">

@ -1,2 +1 @@
destinationPath=http://download.sip-communicator.org/nightly
pkgName=sip-communicator

@ -143,6 +143,11 @@
<target name="build-installation-linux"
depends="clean-install-linux,define-izpack-task,version">
<propertyfile file="${linux.app.dir}/versionupdate.properties"
comment="Last Build Version">
<entry key="last_version" value="${sip-communicator.version}"/>
</propertyfile>
<filter token="VERSION" value="${sip-communicator.version}" />
<filter token="BUILDDATE" value="${build.date}" />
<filter token="PKG_NAME" value="${package.name}" />
@ -216,6 +221,13 @@
<target name="build-installation-windows"
depends="clean-install-windows,define-izpack-task,version">
<propertyfile file="${windows.app.dir}/versionupdate.properties"
comment="Last Build Version">
<entry key="last_version" value="${sip-communicator.version}"/>
<entry key="download_link"
value="http://download.sip-communicator.org/nightly/windows/"/>
</propertyfile>
<filter token="VERSION" value="${sip-communicator.version}" />
<filter token="BUILDDATE" value="${build.date}" />
@ -398,6 +410,14 @@
<target name="dmg" depends="macosx"
if="is.running.macos"
description="Create a .dmg package for MACOSX (only works on MACOSX)">
<propertyfile file="${macosx.app.dir}/versionupdate.properties"
comment="Last Build Version">
<entry key="last_version" value="${sip-communicator.version}"/>
<entry key="download_link"
value="http://download.sip-communicator.org/nightly/macosx/"/>
</propertyfile>
<property name="macosx.dmg.name"
value="${package.name}-${sip-communicator.version}.dmg"/>
<property name="macosx.dmg.tmpname"

@ -1,2 +1,3 @@
dialogTitle=New version available
dialogMessage=<html>There is new version of {0} <br>you can download it at : <br>
dialogMessage1=<html>There is new version of {0} !
dialogMessage2=<br>You can download it at : <br>

@ -43,6 +43,8 @@ public class UpdateCheckActivator
private static BundleContext bundleContext = null;
private static BrowserLauncherService browserLauncherService;
private String downloadLink = null;
/**
* Starts this bundle
@ -82,12 +84,19 @@ public void start(BundleContext bundleContext) throws Exception
contentMessage.setContentType("text/html");
contentMessage.setOpaque(false);
contentMessage.setEditable(false);
contentMessage.setText(
MessageFormat.format(
Resources.getLangString("dialogMessage"),
ver.getApplicationName()) +
"<a href=\"" + Resources.getConfigString("destinationPath") + "\">" +
Resources.getConfigString("destinationPath") + "</a> </html>");
String dialogMsg = MessageFormat.format(
Resources.getLangString("dialogMessage1"),
ver.getApplicationName());
if(downloadLink != null)
{
dialogMsg += Resources.getLangString("dialogMessage2") +
"<a href=\"" + downloadLink + "\">" +
downloadLink + "</a> </html>";
}
contentMessage.setText(dialogMsg);
contentMessage.addHyperlinkListener(new HyperlinkListener() {
@ -167,72 +176,34 @@ public static BrowserLauncherService getBrowserLauncher()
*/
private boolean isNewestVersion(String currentVersionStr)
{
String pkgName = Resources.getConfigString("pkgName") + "-";
EditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
// The Document class does not yet
// handle charset's properly.
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
try
try
{
// as some of the distribution has own mechanisums of
// updating so just check from one of the platforms
// which is the last version
String osName = System.getProperty("os.name");
String osDir = null;
// Create a reader on the HTML content.
Reader rd = getReader(Resources.getConfigString("destinationPath") + "/windows");
// Parse the HTML.
kit.read(rd, doc, 0);
// Iterate through the elements
// of the HTML document.
ElementIterator it = new ElementIterator(doc);
Element elem;
while ((elem = it.next()) != null)
{
SimpleAttributeSet s = (SimpleAttributeSet)
elem.getAttributes().getAttribute(HTML.Tag.A);
if (s != null)
{
String link = s.getAttribute(HTML.Attribute.HREF).toString();
if(!link.startsWith(pkgName))
continue;
link = link.replaceAll(pkgName, "");
link = link.substring(0, link.lastIndexOf('.'));
return link.compareTo(currentVersionStr) <= 0;
}
}
if (osName.startsWith("Mac"))
osDir = "/macosx";
else if (osName.startsWith("Linux"))
osDir = "/linux";
else if (osName.startsWith("Windows"))
osDir = "/windows";
URL url = new URL(Resources.getConfigString("destinationPath") +
osDir + "/versionupdate.properties");
Properties props = new Properties();
props.load(url.openStream());
String lastVersion = props.getProperty("last_version");
downloadLink = props.getProperty("download_link");
return lastVersion.compareTo(currentVersionStr) <= 0;
}
catch (Exception e)
{
e.printStackTrace();
logger.error("Cannot get and compare versions!", e);
}
return false;
}
// Returns a reader on the HTML data. If 'uri' begins
// with "http:", it's treated as a URL; otherwise,
// it's assumed to be a local filename.
static Reader getReader(String uri)
throws IOException
{
if (uri.startsWith("http:"))
{
// Retrieve from Internet.
URLConnection conn = new URL(uri).openConnection();
return new InputStreamReader(conn.getInputStream());
}
else
{
return new FileReader(uri);
}
}
}
Loading…
Cancel
Save