You Are Here:

Community: Wiki

This page was last modified on 20 January 2009, at 07:36.

CS001246 - Listing inbox messages in WRT

From Forum Nokia Wiki



ID CS001246 Creation date December 18, 2008
Platform S60 5th Edition Tested on devices Nokia 5800 XpressMusic
Category Web Runtime (WRT) Subcategory Messaging


Keywords (APIs, classes, methods, functions): device.getServiceObject(), Service.Messaging.GetList()

Overview

This code snippet shows how to get a list of received messages using the Messaging Platform Service for Web Runtime introduced in S60 5th Edition.

The device.getServiceObject("Service.Messaging", "IMessaging") method is used to obtain access to the service object for the Messaging Service API.

After setting the correct values for the criteria object (criteria.Type, criteria.Filter, and criteria.Filter.MessageTypeList), the IMessaging.GetList(criteria) method is used for getting the list of messages synchronously.

Source: Relevant HTML components

<input type="radio" name="choiceType" id="sms" checked="true" />
<label for="sms">SMS</label><br />
 
<input type="radio" name="choiceType" id="mms" />
<label for="mms">MMS</label><br />
 
<input type="button" value="Get messages"
onclick="getMessageList();" />
 
<select size="5" id="messageList" multiple></select><br />

Source: JavaScript file

var serviceObj = null;
 
window.onload = init;
 
// Initializes the widget
function init() {
try {
serviceObj = device.getServiceObject("Service.Messaging",
"IMessaging");
} catch (ex) {
alert("Service object cannot be found.");
return;
}
 
// Get the list of all messages and show it in SELECT object.
getMessageList();
}
 
function getMessageList() {
var criteria = new Object();
criteria.Type = "Inbox";
criteria.Filter = new Object();
criteria.Filter.MessageTypeList = new Array();
if (document.getElementById("sms").checked) {
criteria.Filter.MessageTypeList[0] = "SMS";
} else {
criteria.Filter.MessageTypeList[0] = "MMS";
}
 
try {
// Get list of messages
var result = serviceObj.IMessaging.GetList(criteria);
if(result.ErrorCode != 0) {
alert("Error in getting messages");
return;
}
showMessages(result.ReturnValue);
} catch(exception) {
alert("getList: " + exception);
}
}
 
// Displays available messages in a list box
function showMessages(iterator) {
var messageList = document.getElementById("messageList");
//Iterator is the list of the files, reset to set pointer to the first
//element.
iterator.reset();
//Cleaning the file list.
while (messageList.length != 0) {
messageList.remove(0);
}
document.getElementById("messageList").style.display = "block";
var item;
while ((item = iterator.getNext()) != undefined) {
var node = document.createElement("option");
//Value of option consists of the full path.
node.value = item.MessageId;
node.appendChild (document.createTextNode(item.Sender + item.Time +
item.Subject));
messageList.appendChild(node);
}
}

Postconditions

  • After loading, a listbox with all messages from inbox (SMS or MMS) is shown.
  • The user can choose the type of message.
  • Thw list box contains the "From", "Data/Time", and message text fields.

Supplementary material

You can view the source file and executable application in the attached ZIP archive. The archive is available for download at Media:Listing_inbox_messages_in_WRT.zip.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fSeriesE5f60E25E457E25ACE25ACE25E454E25B8E2589E25E457E2589E2588E25E454E25B8E258AE25E456E258FE2590E25E455E258FE2596E25E456E25B6E2588E25E456E2581E25AFE25E457E259AE2584E25E459E2599E2584E25E454E25BBE25B6X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZmessagingQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxmessagingX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ