×
Namespaces

Variants
Actions

Recognizers

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: ivey (21 Mar 2007)
Last edited: hamishwillee (26 Jul 2012)

Contents

Description

Plug-in code that can examine sample data, and return, if recognized, its data type. A data type is also commonly known as a MIME type.

The plug-in recognizer architecture allows additional data recognizers to be created and added.


Loading

Before Symbian OS v9.1, data recognizers were plug-in DLLs with a .mdl extension and a UID2 of 0x10003A19. They were located in the \System\Recogs\ folder on any drive.

In Symbian OS v9.1 and onwards, recognizers are ECOM plugins, located under \sys\bin\. Each ECOM data recognizer is loaded by the application architecture (apparc) during the OS startup sequence.


Handling the Data

After a recognizer has been selected, apparc attempts to find the application that can best handle the selected data type. And it is not guaranteed that an application will be available to handle a data type, even if it was successfully recognized.


Recognizers List

The recognizer framework maintains an up to date list of all data recognizers that exist in the system. The list is ordered by recognizer priority.


FrameWork

CApaDataRecognizer is an internal class that represents the recognizer framework.Although CApaDataRecognizer is internal, clients can access most of its properties through the RApaLsSession API.

class CApaDataRecognizerType : public CBase;


Interface

All recognizers must implement CApaDataRecognizerType::DoRecognizeL(). This is the function that is called to do the data recognition. It is not pure virtual, but the implementation in CApaDataRecognizerType does not do anything apart from setting CApaDataRecognizerType::iDataType to a default value. Implementations should set iDataType to the MIME type it considers the data to belong to and iConfidence to indicate how confident it is. The decision is based on the two parameters, aName and aBuffer.

The following code recognizes with maximum confidence the word "example" contained in files with a .example extension.

void CExampleRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer)
{
_LIT8(KExampleData, "example");
_LIT(KDotExample, ".Example");
 
TParse parse;
parse.Set(aName,NULL,NULL);
TPtrC ext=parse.Ext(); // extract the extension from the filename
 
if (ext.CompareF(KDotExample)==0 && aBuffer.FindF(KExampleData)!=KErrNotFound)
{
iConfidence=ECertain;
iDataType=TDataType(KExampleTextMimeType);
}
}

This is located in apmrec.h and should be linked against apmime.lib in mmp file.


Function Members of CApaDataRecognizerType

CApaDataRecognizerType(), ~CApaDataRecognizerType(), Confidence(), CreateDataRecognizerL(), FilePassedByHandleL(), Lock(), Locked(), MimeType(), MimeTypesCount(), PreferredBufSize(), Priority(), RecognizeL(), SupportedDataTypeL(), TRecognitionConfidence, TRecognizerPriority, TypeUid(), Unlock(), UpdateDataTypesL().


Related:

--

This page was last modified on 26 July 2012, at 07:28.
52 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×