The MIME recognizers are used by the client applications for data type recognition. When there is a client request to the AppArc for data type recognition, AppArc internally uses the MIME recognition framework for processing the request.
The client connects
to AppArc and creates a session using the class RApaLsSession
.
Apparc provides access to the MIME framework via RApaLsSession
APIs.
The class provides the APIs for data type recognition.
All MIME (data)
recognizers are derived from the abstract base class, CApaDataRecognizerType.
The RApaLsSession
data recognition APIs access the properties
of CApaDataRecognizerType
for data type recognition.
RApaLsSession::Connect()
.
Example:
RApaLsSession aLs; TInt ret; // Client session with the server created. ret=aLs.Connect();
RApaLsSession::RecognizeData()
or RApaLsSession::RecognizeSpecificData()
.
These APIs internally invoke the implementation for CApaDataRecognizerType::DoRecognizeL().
DoRecognizeL()
of the class derived from CApaDataRecognizerType
implements
the data recognition behaviour.
Example:
// Implementation of RecognizeData() RecognizeData(const TDesC &aName, const TDesC8 &aBuffer, TDataRecognitionResult &aDataType) { CExampleRecognizer *myrecognizer= CExampleRecognizer::CreateRecognizerL(); myrecognize->DoRecognizeL(aName,aBuffer); } // The RApaLsSession object invokes RecognizeData() for data type recognition. _LIT(KMyFile, "Myfile.example"); _LIT(KMyBufer, "serach for example string in the file buffer"); TInt ret=aLs.RecognizeData(KMyFile,KMyBufer,result);
A TDataRecognitionResult
object is returned to
AppArc. The object contains the data (MIME) type and the confidence of recognition.
AppArc attempts to find the application that can best handle the identified data type. It is not guaranteed that an application will be available to handle a data type, even after successful recognition.
Notes:
RApaLsSession::RecognizeData()
or RApaLsSession::RecognizeSpecificData()
the
following functions of the RApaLsSession
also support the
processing of data type recognition request. The overloads of RApaLsSession::RecognizeFilesL()
are
used to recognize all files contained in a specified directory.
RApaLsSession::GetAcceptedConfidence()
and RApaLsSession::SetAcceptedConfidence()
retrieve and set the accepted confidence level of the MIME framework. The
default value is ECertain
.
RApaLsSession::GetSupportedDataTypesL()
retrieves
the list of data types supported by all recognizers in the recognizer list
of the MIME framework.
The preferred buffer
size determines the amount of data passed to DoRecognizeL()
function.
The preferred buffer size can be retrieved using RApaLsSession::GetPreferredBufSize()
.
This value cannot be greater than the maximum buffer value.
The maximum
value for the buffer is set by using RApaLsSession::SetMaxDataBufSize()
.
If the maximum buffer size is not set by the client, the default value is
256 bytes. The maximum buffer size can be retrieved using RApaLsSession::GetMaxDataBufSize()
.