Removing message from Inbox in Symbian Web Runtime
copyeditor
(Talk | contribs) m (language check) |
hamishwillee
(Talk | contribs) m (Text replace - "Category:S60 5th Edition (initial release)" to "Category:S60 5th Edition") |
||
| (15 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | {{ArticleMetaData <!-- v1.2 --> | |
| − | + | |sourcecode= [[Media:Removing message from Inbox in WRT.zip]] | |
| − | {{ | + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> |
| − | | | + | |devices= Nokia 5800 XpressMusic |
| − | | | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> |
| − | |devices=Nokia 5800 XpressMusic | + | |platform= S60 5th Edition |
| − | | | + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> |
| − | | | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| − | | | + | |signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer --> |
| − | |keywords=device.getServiceObject(), Service. | + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> |
| + | |keywords= device.getServiceObject(), Service.Messaging.Delete() | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20081210 | ||
| + | |author= [[User:Dekuykin]] | ||
| + | <!-- The following are not in current metadata --> | ||
| + | |subcategory= Messaging | ||
| + | |id= CS001241 | ||
}} | }} | ||
| − | |||
==Overview== | ==Overview== | ||
| − | |||
| − | + | This code snippet shows how to delete a message from the Inbox using the Messaging Platform Service for S60 Web Runtime introduced in S60 5th Edition. | |
| − | + | The {{Icode|device.getServiceObject("Service.Messaging", "IMessaging")}} method is used to get access to the service object for the Messaging Service API. | |
| − | + | ||
| − | + | ||
| − | + | ==Source== | |
| − | + | ||
| − | + | The HTML {{Icode|select}} component contains the messages: | |
<code xml> | <code xml> | ||
| − | < | + | <select size="5" id="messageList" multiple></select><br /> |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | </ | + | |
</code> | </code> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
<code javascript> | <code javascript> | ||
| − | + | var serviceObj = null; | |
| − | // | + | // Initializes the widget |
| − | + | function init() { | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | function | + | |
try { | try { | ||
| − | + | serviceObj = device.getServiceObject("Service.Messaging", | |
| − | + | ||
| − | + | ||
"IMessaging"); | "IMessaging"); | ||
| − | } catch ( | + | } catch (ex) { |
| − | alert("Service | + | alert("Service object cannot be found."); |
return; | return; | ||
} | } | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
} | } | ||
| − | / | + | </code> |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | <code javascript> | |
| − | + | // Removes the message which is selected in the list box. | |
| − | + | function removeMessage() { | |
| − | + | // Get a reference to SELECT object which contains the list of messages | |
| + | var messageList = document.getElementById("messageList"); | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
var criteria = new Object(); | var criteria = new Object(); | ||
| − | // Find | + | // Find the selected messages |
| − | for (var msgIndex = 0; msgIndex < | + | for (var msgIndex = 0; msgIndex < messageList.length; msgIndex++) { |
| − | if ( | + | if (messageList.options[msgIndex].selected) { |
| − | // Get message id of selected message | + | // Get message id of the selected message |
| − | var messageId = | + | var messageId = messageList.options[msgIndex].value; |
// Radix of message id integer value | // Radix of message id integer value | ||
var radix = 10; | var radix = 10; | ||
| Line 220: | Line 73: | ||
var result = serviceObject.IMessaging.Delete(criteria); | var result = serviceObject.IMessaging.Delete(criteria); | ||
if (result.ErrorCode !== 0) { | if (result.ErrorCode !== 0) { | ||
| + | alert("Error in deleting messages"); | ||
break; | break; | ||
} | } | ||
// Remove message record from selection list | // Remove message record from selection list | ||
| − | + | messageList.remove(msgIndex); | |
msgIndex = msgIndex - 1; | msgIndex = msgIndex - 1; | ||
} | } | ||
} | } | ||
getMessageList(); | getMessageList(); | ||
| − | |||
} | } | ||
</code> | </code> | ||
==Postconditions== | ==Postconditions== | ||
| − | + | ||
| − | + | The selected SMS or MMS messages are deleted. | |
| − | + | ||
| − | + | ||
| − | + | ||
==Supplementary material== | ==Supplementary material== | ||
| − | |||
| − | [[Category:Web Runtime | + | You can view the source file and executable application in the attached ZIP archive. The archive is available for download at [[Media:Removing message from Inbox in WRT.zip]]. |
| + | |||
| + | ==See also== | ||
| + | |||
| + | * [[Listing inbox messages in Symbian Web Runtime]] | ||
| + | |||
| + | [[Category:Symbian Web Runtime]][[Category:Code Examples]][[Category:Messaging]][[Category:S60 5th Edition]][[Category:Code Snippet]] | ||
Latest revision as of 07:40, 1 August 2012
Article Metadata
Code Example
Source file: Media:Removing message from Inbox in WRT.zip
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.Messaging.Delete()
Created: dekuykin
(10 Dec 2008)
Last edited: hamishwillee
(01 Aug 2012)
Contents |
Overview
This code snippet shows how to delete a message from the Inbox using the Messaging Platform Service for S60 Web Runtime introduced in S60 5th Edition.
The device.getServiceObject("Service.Messaging", "IMessaging") method is used to get access to the service object for the Messaging Service API.
Source
The HTML select component contains the messages:
<select size="5" id="messageList" multiple></select><br />var serviceObj = null;
// Initializes the widget
function init() {
try {
serviceObj = device.getServiceObject("Service.Messaging",
"IMessaging");
} catch (ex) {
alert("Service object cannot be found.");
return;
}
}
// Removes the message which is selected in the list box.
function removeMessage() {
// Get a reference to SELECT object which contains the list of messages
var messageList = document.getElementById("messageList");
var criteria = new Object();
// Find the selected messages
for (var msgIndex = 0; msgIndex < messageList.length; msgIndex++) {
if (messageList.options[msgIndex].selected) {
// Get message id of the selected message
var messageId = messageList.options[msgIndex].value;
// Radix of message id integer value
var radix = 10;
// Get numeric representation of the message id
criteria.MessageId = parseInt(messageId, radix);
// Delete the message
var result = serviceObject.IMessaging.Delete(criteria);
if (result.ErrorCode !== 0) {
alert("Error in deleting messages");
break;
}
// Remove message record from selection list
messageList.remove(msgIndex);
msgIndex = msgIndex - 1;
}
}
getMessageList();
}
Postconditions
The selected SMS or MMS messages are deleted.
Supplementary material
You can view the source file and executable application in the attached ZIP archive. The archive is available for download at Media:Removing message from Inbox in WRT.zip.

