Compatibility: Web Runtime in S60 3rd Edition, Feature Pack 2

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 reqVersion = 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 =
    "
    Download new version
    ";
    }
    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();">



</body>
</html>