Namespaces
Variants
Actions

How-to create self-updating WRT widgets

Jump to: navigation, search
Article Metadata

Compatibility
Platform(s): S60 3rd Edition FP2

Article
Created: forum-mrkt (03 Oct 2007)
Last edited: hamishwillee (03 Feb 2012)

Contents

Theory

For S60 WRT Widgets easiest way to do self-update is to have application to do version checking by itself. A variable in the widget's bundle can indicate current version that can be checked against server interface. This approach doesn't require any extensions or platform tricks, it is pure JavaScript implementation.

Example setup

Following example assumes that you have script running on server side at http://myexample.versionservice.com:8888. Server responds to version request with XML document including version tag. This example can be easily extended e.g. to include update url in version response message.

Example code

/*
* version server url, and current version
*/

var versionURL = "http://myexample.versionservice.com:8888";
var currentVersion = 1;
 
var reqV = null;
 
/*
* called e.g. during app startup or once a day
*/

function checkForUpdate()
{
/*
* asynch XHR to server url
*/

reqV = new XMLHttpRequest();
reqV.onreadystatechange = checkVersion;
reqV.open("GET", versionURL, true);
reqV.send(null);
 
document.getElementById("updateDIV").innerHTML = "checking for updates";
}
 
/*
* parse response and check version
*/

function checkVersion()
{
if (reqV.readyState == 4)
{
if (reqV.status == 200)
{
/*
* little overhead here, one could use also string for version info
*/

var newVersion = reqV.responseText;
if (currentVersion != newVersion)
{
document.getElementById("updateDIV").innerHTML =
"<a href=\"http://www.taika.org/~jario/newversion.wgz\">
Download new version</a>"
;
}
else
{
document.getElementById("updateDIV").innerHTML =
"No new versions available";
}
}
else
{
alert( "connection error" );
}
}
}

Example main HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type='text/javascript' src="selfupdate.js"></script>
</head>
<body onload="checkForUpdate();">
 
<div id="updateDIV"></div>
 
</body>
</html>

Comments

Reviewer-approved.png
18 Sep
2009
Article Review by gaba88 (20090918)

A software needs some improvement and to achieve the same it needs a kind of update feature. The update feature should interact with the outer resource and then should decide weather to update the software or not.

In the case of WRT Widgets the tasks become quite simple as they are frequently connected withe web. The article is an excellent example of achieving the auto updating task of web, the code explains clearly two functions which checks for updates and versions if new is available it will download that and replace the existing one.

This is an article of Basic level beginners can easily go through it.



This page was last modified on 3 February 2012, at 05:31.
79 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2012 All rights reserved