Writing a MIME Recognizer

The Mime Recognizers provide the implementation for data type (MIME Type) recognition using the MIME recognition framework.

Each MIME recognizer specifies the MIME type it supports along with the priority and confidence of recognition. A MIME recognizer reads a small piece of data and identifies the data type. Once the data type is identified, it is passed to the Application Architecture (AppArc). AppArc launches the application that best handles the identified data type.


Symbian OS v9.1 and onwards, MIME recognizers are ECOM plug-ins. They are located in \sys\bin\.

Each MIME recognizer is loaded by the Application Architecture (AppArc) during the startup sequence.


  1. Create a project file (.mmp) for the MIME recognizer and ensure the following parameters are set.

    Variable Name





    Specifies the type of binary.


    Use the block start resource ... end

    The variable Resource is set to the registration resource file (.rss))of the MIME recognizer.


    0x10009D8D and the DLL UID

    The variable UID requires two values. The first value is 0x10009D8D and is constant for all MIME recognizers. The second value is the UID of the DLL.



    The AppArc server has protserv capability.The MIME recognizers are loaded by the AppArc server on requirement. The MIME recognizers must have protserv capability to be loaded by the AppArc server.

    For more details, refer Creating a Project File. The code below shows a sample .mmp file with the above parameters set.
    target exampleRecognizer.dll
    capability          Protserv
    targettype          plugin
    uid                    0x10009d8d 0x1d1f75ed
    vendorid            0x70000001
    sourcepath          .
    source                 exampleRecognizer.cpp
    systeminclude       \EPOC32\INCLUDE
    systeminclude       \EPOC32\INCLUDE\ECOM 
    library                EUSER.LIB APMIME.LIB 
    start resource   1d1f75ed.rss
    target           exampleRecognizer.rsc
  2. Export the factory code function of the MIME recognizer as shown below. This is required to create an instance of the MIME recognizer. The class CExampleRecognizer is derived from CApaDataRecognizerType.
    const TInt KImplementationUID = 0x101F7DA1;
    CApaDataRecognizerType* CExampleRecognizer::CreateRecognizerL()
             return new (ELeave) CExampleRecognizer;
    const TImplementationProxy ImplementationTable[] = 
    EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
            aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
            return ImplementationTable;
    For more details refer Exporting Implementation Factories.
  3. Implement CApaDataRecognizerType polymorphic interface.
    1. The code below shows a sample constructor implementation.
      const TUid KExampleUid = {0x1d1f75ed};
      const TInt KNumDataTypes = 1;
      CExampleRecognizer::CExampleRecognizer() : CApaDataRecognizerType(KExampleUid,CApaDataRecognizerType::EHigh) 
           iCountDataTypes = KNumDataTypes;
      Specify a UID (the DLL UID as specified in the plug-in project definition file) and a priority in the constructor. The iCountDataTypes variable, represents the number of data types supported by the recognizer can also be set in the constructor. The value set for this variable should match the implementation of CApaDataRecognizerType::SupportedDataTypeL().
    2. Implement the pure virtual function CApaDataRecognizerType::SupportedDataTypeL(). It returns the MIME types that the recognizer is capable of recognizing. The code below shows a sample implementation of SupportedDataTypeL() for supporting MIME type/ subtype "text/example".
      _LIT8(KExampleTextMimeType, "text/example"); 
      TDataType CExampleRecognizer::SupportedDataTypeL(TInt aIndex) const
              return TDataType(KExampleTextMimeType);
    3. Implement CApaDataRecognizerType::DoRecognizeL(). This function executes data type recognition. The code below shows a sample implementation of DoRecognizeL() for recognizing the MIME type "/text/example" contained in files with .example extension with maximum confidence.
      void CExampleRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer)
          _LIT8(KExampleData, "example");
          _LIT(KDotExample, ".Example");
          TParse parse;
          TPtrC ext=parse.Ext(); // extract the extension from the filename
          if (ext.CompareF(KDotExample)==0 && aBuffer.FindF(KExampleData)!=KErrNotFound)