MIME type handling in Symbian Web Runtime
| Line 12: | Line 12: | ||
Service.IDataSource.GetList() | Service.IDataSource.GetList() | ||
}} | }} | ||
| − | |||
==Overview== | ==Overview== | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | This code snippet shows how to launch an application based on a given document using AppManager Platform Service for Web Runtime, introduced in S60 5th Edition. Image files were chosen to present the mime type handling in WRT. | |
| − | + | ||
| − | + | ||
==Source file: Relevant HTML components== | ==Source file: Relevant HTML components== | ||
| Line 44: | Line 24: | ||
</code> | </code> | ||
| − | ==Source | + | ==Source== |
<code javascript> | <code javascript> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
/** | /** | ||
| − | * | + | * Shows the selected image. |
| − | + | */ | |
| − | */ | + | |
function show() { | function show() { | ||
| + | var so = null; | ||
| + | |||
try { | try { | ||
//Getting service object for application management. | //Getting service object for application management. | ||
| − | var | + | var so = device.getServiceObject("Service.AppManager", "IAppManager"); |
| − | + | } catch (ex) { | |
alert("Exception in getting application service object: " + ex); | alert("Exception in getting application service object: " + ex); | ||
| − | + | return; | |
| + | } | ||
| + | |||
var imageList = document.getElementById("imageList"); | var imageList = document.getElementById("imageList"); | ||
| − | + | for (var i = 0; i < imageList.options.length; i++) { | |
| − | + | ||
| − | for(var i = 0; i < imageList.options.length; i++) { | + | |
if (imageList.options[i].selected) { | if (imageList.options[i].selected) { | ||
| − | + | var criteria = new Object(); | |
| − | var | + | criteria.Document = new Object(); |
| − | + | //Setting the path to file that must be opened in a standalone | |
| − | + | ||
| − | //Setting the path to file | + | |
//application | //application | ||
| − | + | criteria.Document.DocumentPath = imageList.options[i].value; | |
//Opening the file in standalone application | //Opening the file in standalone application | ||
try { | try { | ||
| − | var res = | + | var res = so.IAppManager.LaunchDoc(criteria); |
| − | + | ||
if (res.ErrorCode != 0){ | if (res.ErrorCode != 0){ | ||
alert(res.ErrorCode + ' ; ' + res.ErrorMessage); | alert(res.ErrorCode + ' ; ' + res.ErrorMessage); | ||
} | } | ||
| − | } catch(ex){ | + | } catch (ex){ |
alert("Exception in launching document: " + ex); | alert("Exception in launching document: " + ex); | ||
} | } | ||
} | } | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
} | } | ||
} | } | ||
| Line 177: | Line 65: | ||
==Postconditions== | ==Postconditions== | ||
| − | + | The image that is selected in the list, is displayed in a standalone application. | |
| − | + | ||
| + | ==See also== | ||
| + | |||
| + | * [[CS001245 - Loading images in WRT]] | ||
==Supplementary material== | ==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 for developers. The version of the WRT stub application used as a template in this snippet is v1.1. | |
| − | * You can | + | * The patched, executable application that can be used to test the features described in this snippet is available for download at [[Media:MimeTypeHandling.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:MimeTypeHandling.diff.zip]]. | ||
| + | * For general information on applying the patch, see [[Using Diffs]]. | ||
| + | * For unpatched stub applications, see [[Example stub]]. | ||
[[Category:Web Runtime (WRT)]][[Category:Code Examples]][[Category:Files/Data]][[Category:S60 5th Edition]] | [[Category:Web Runtime (WRT)]][[Category:Code Examples]][[Category:Files/Data]][[Category:S60 5th Edition]] | ||
Revision as of 10:39, 13 May 2009
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: device.getServiceObject(),Service.IAppManager.LaunchDoc(),
menu.setRightSoftkeyLabel(),widget.setNavigationEnabled(),
Service.IDataSource.GetList()Created: (29 Jan 2009)
Last edited: tapla
(13 May 2009)
Overview
This code snippet shows how to launch an application based on a given document using AppManager Platform Service for Web Runtime, introduced in S60 5th Edition. Image files were chosen to present the mime type handling in WRT.
Source file: Relevant HTML components
<select size = "5" id = "imageList" onclick = "show();">
<option></option>
</select>
Source
/**
* Shows the selected image.
*/
function show() {
var so = null;
try {
//Getting service object for application management.
var so = device.getServiceObject("Service.AppManager", "IAppManager");
} catch (ex) {
alert("Exception in getting application service object: " + ex);
return;
}
var imageList = document.getElementById("imageList");
for (var i = 0; i < imageList.options.length; i++) {
if (imageList.options[i].selected) {
var criteria = new Object();
criteria.Document = new Object();
//Setting the path to file that must be opened in a standalone
//application
criteria.Document.DocumentPath = imageList.options[i].value;
//Opening the file in standalone application
try {
var res = so.IAppManager.LaunchDoc(criteria);
if (res.ErrorCode != 0){
alert(res.ErrorCode + ' ; ' + res.ErrorMessage);
}
} catch (ex){
alert("Exception in launching document: " + ex);
}
}
}
}
Postconditions
The image that is selected in the list, is displayed in a standalone application.
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 for 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:MimeTypeHandling.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:MimeTypeHandling.diff.zip.
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example stub.

