Namespaces
Variants
Actions
Revision as of 08:53, 4 October 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Changing the status of a message in Symbian Web Runtime

Jump to: navigation, search

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.

329 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 2013 All rights reserved