Change application MIME type mapping on Symbian
Article Metadata
Tested with
Compatibility
S60 5th Edition
Article
Contents |
Overview
This snippet demonstrates how to change your application data mapping. We set image/jpg and image/jpeg MIME-type data mapping to our own application by setting higher priority for these data types in our application than the built-in Picture Gallery application has.
After data type mapping is set, the application tries to open any JPG image that the user selects from the device's file manager.
The changing of data types can be done during runtime, there is no need to reboot the device.
This snippet needs Open Signed Online signing because of the required capabilities (see below).
MMP file
The following libraries and capabilities are required:
CAPABILITY WriteDeviceData ReadDeviceData
LIBRARY apgrfx.lib
LIBRARY apmime.lib
Header file
// Your application UID that data mapping will be changed
const TUid KUidYourApp = {0x12345678};
Source file
#include <apgcli.h> // RApaLsSession
#include <apmstd.h> // TDatatype
void CYourClass::ChangeDataMappingL(TDataType datatype, TBool aEnable)
{
// Create session
RApaLsSession rapala;
TInt err = rapala.Connect();
CleanupClosePushL(rapala);
// Change data mapping
// Remove previous mapping...
rapala.DeleteDataMapping(datatype);
// ...and set the new one
if (aEnable)
{
User::LeaveIfError(rapala.InsertDataMapping(datatype,
TDataTypePriority(KDataTypePriorityHigh+1),KUidYourApp));
}
CleanupStack::PopAndDestroy(); // rapala
}
How to use
The following code enables image/jpg and image/jpeg MIME type data mapping in your application. After that, data mapping is disabled from the built-in Picture Gallery application.
_LIT8(KDataType1,"image/jpg");
_LIT8(KDataType2,"image/jpeg");
ChangeDataMappingL(TDataType(KDataType1),ETrue);
ChangeDataMappingL(TDataType(KDataType2),ETrue);
See also
* S60_Platform_Document_Handler_Example * Archived:Data handler applications must implement CAknAppUi::OpenFileL (Known Issue) * Symbian MIME recognizers and opening files for editing * Opening a file using CDocumentHandler
Postconditions
The application tries to open any JPG image selected by the user because it has higher data type mapping that the built-in Picture Gallery application.


(no comments yet)