Changing the status of a message in Symbian Web Runtime
This code snippet demonstrates how to change the status ("Read" or "Unread") of an SMS. The code snippet uses the Messaging Platform Service for Web Runtime, supported from S60 5th Edition onwards.
Article Metadata
Code Example
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.IMessaging.GetList(), Service.IMessaging.ChangeStatus()
Created: ivruban
(26 Feb 2009)
Last edited: hamishwillee
(04 Oct 2012)
Contents |
Source: Relevant HTML components
<div id="bodyContent" class="bodyContent">
<select size="5" id="messageList" multiple></select><br />
<input type="radio" name="choiceStatus" id="read" />
<label for="read">Read</label><br />
<input type="radio" name="choiceStatus" id="unread" />
<label for="unread">Unread</label><br />
<input type="button" onclick="changeStatus();"
value="Change status" />
</div>
Source
/**
* Changes the status of the selected message.
*/
function changeStatus() {
var messageListElement = document.getElementById("messageList");
var criteria = new Object();
for (var msgIndex = 0; msgIndex < messageListElement.length; msgIndex++) {
if (messageListElement.options[msgIndex].selected) {
// Get message id of the selected message
var messageId = messageListElement.options[msgIndex].value;
// Get numeric representation of the message id
criteria.MessageId = parseInt(messageId, 10);
if (document.getElementById("read").checked) {
criteria.Status = "Read";
} else {
criteria.Status = "Unread";
}
// Change the status of the message
var result = serviceObj.IMessaging.ChangeStatus(criteria);
if (result.ErrorCode !== 0) {
alert("Error: " + result.ErrorCode);
break;
}
}
}
alert("Status changed.");
getMessageList();
}
Postconditions
The status of the selected message is changed to Read or Unread, depending on the user's selection.
See also
Supplementary material
This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful to developers. The version of the WRT stub application used as a template in this snippet is v1.1.
- The patched, executable application that can be used to test the features described in this snippet is available for download at Media:ChangeMessageStatus.zip.
- You can view all the changes that are required to implement the above-mentioned features. The changes are provided in unified diff and colour-coded diff (HTML) formats in Media:ChangeMessageStatus.diff.zip.
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example app stubs with logging framework.

