1.1 --- a/epoc32/include/apmrec.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/apmrec.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,218 @@
1.4 -apmrec.h
1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#if !defined(__APMREC_H__)
1.21 +#define __APMREC_H__
1.22 +
1.23 +#if !defined(__E32BASE_H__)
1.24 +#include <e32base.h>
1.25 +#endif
1.26 +
1.27 +#if !defined(__APMSTD_H__)
1.28 +#include <apmstd.h>
1.29 +#endif
1.30 +
1.31 +// classes defined
1.32 +class CApaDataRecognizerType;
1.33 +// classes referenced
1.34 +class RFs;
1.35 +class RFile;
1.36 +class TDataToRecognize;
1.37 +class CDataRecognizerExtension;
1.38 +
1.39 +/** Creates an interface object for a abstract base class for a recognizer.
1.40 +
1.41 +@publishedAll
1.42 +@released
1.43 +*/
1.44 +typedef CApaDataRecognizerType* (*CreateCApaDataRecognizerType)();
1.45 +
1.46 +class TDataRecognitionResult
1.47 +/** The result of an attempt to recognize data.
1.48 +
1.49 +The class contains a data (MIME) type and a confidence rating.
1.50 +
1.51 +An object of this type is passed to the Application Architecture server when
1.52 +making a request to recognize data.
1.53 +
1.54 +@publishedAll
1.55 +@released
1.56 +@see RApaLsSession::RecognizeData() */
1.57 + {
1.58 +public:
1.59 + IMPORT_C void Reset();
1.60 +public:
1.61 + /** The data type. */
1.62 + TDataType iDataType;
1.63 + /** The confidence rating associated with the data (EMIME) type. */
1.64 + TInt iConfidence;
1.65 + };
1.66 +
1.67 +/**
1.68 +@internalComponent
1.69 +*/
1.70 +const TInt KDataArrayGranularity=5;
1.71 +
1.72 +/**
1.73 +@publishedAll
1.74 +@released
1.75 +*/
1.76 +typedef CArrayFixFlat<TDataType> CDataTypeArray;
1.77 +
1.78 +class CApaDataRecognizer : public CBase
1.79 +/**
1.80 +@internalTechnology
1.81 +*/
1.82 + {
1.83 +public:
1.84 + IMPORT_C TDataRecognitionResult RecognizeL(const TDesC& aName, const TDesC8& aBuffer);
1.85 + IMPORT_C TDataRecognitionResult RecognizeL(RFile& aFile, TInt aPreferredBufSize);
1.86 + IMPORT_C TBool RecognizeL(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType);
1.87 + IMPORT_C TBool RecognizeL(RFile& aFile, TInt aPreferredBufSize, const TDataType& aDataType);
1.88 + IMPORT_C ~CApaDataRecognizer();
1.89 + IMPORT_C TInt PreferredBufSize() const;
1.90 + IMPORT_C void DataTypeL(CDataTypeArray& aArray);
1.91 + IMPORT_C void UpdateDataTypesL();
1.92 + IMPORT_C TInt AcceptedConfidence() const;
1.93 + IMPORT_C void SetAcceptedConfidence(TInt aConfidence);
1.94 + inline void SetFilePassedByHandle(RFile* aFilePassedByHandle) {iFilePassedByHandle=aFilePassedByHandle;}
1.95 + inline RFile* FilePassedByHandle() {return iFilePassedByHandle;}
1.96 +protected:
1.97 + IMPORT_C CApaDataRecognizer(RFs& aFs);
1.98 + IMPORT_C void AddDataRecognizerTypeL(CApaDataRecognizerType* aDataRecognizerType);
1.99 + inline void AddDataRecognizerType(CApaDataRecognizerType* aDataRecognizerType);
1.100 + IMPORT_C TInt RemoveDataRecognizerType(const CApaDataRecognizerType* aDataRecognizerType);
1.101 + IMPORT_C void DestroyRecognizerList();
1.102 +private:
1.103 + void AddDataTypeL(const TDataType& aDataType);
1.104 + TDataRecognitionResult RecognizeL(TDataToRecognize& aDataToRecognize);
1.105 + TBool RecognizeL(TDataToRecognize& aDataToRecognize, const TDataType& aDataType);
1.106 + TBool DoRecognize(CApaDataRecognizerType* aDataRecognizerType, TDataToRecognize& aDataToRecognize, const TDataType& aDataType, TInt& aError);
1.107 +protected:
1.108 + RFs& iFs;
1.109 + // iMaxBufferSize is mutable to allow modification by PreferredBufSize() which is const.
1.110 + mutable TInt iMaxBufferSize;
1.111 +private:
1.112 + IMPORT_C virtual void CApaDataRecognizer_Reserved_1(); // shouldn't be necessary as the class is @internalTechnology
1.113 +private:
1.114 + RPointerArray<CApaDataRecognizerType> iDataRecognizerList;
1.115 + RArray<TDataType> iDataArray;
1.116 + TInt iAcceptedConfidence;
1.117 + TDataRecognitionResult iResult;
1.118 + RFile* iFilePassedByHandle;
1.119 + };
1.120 +
1.121 +class CApaDataRecognizerType : public CBase
1.122 +/** Abstract base class for a recognizer.
1.123 +
1.124 +Concrete recognizers need to define and implement a derived class; specifically,
1.125 +they need to provide an implementation of the DoRecognizeL(), SupportedDataTypeL()
1.126 +and PreferredBufSize() functions.
1.127 +
1.128 +The class is implemented as part of a DLL. The ordinal 1 function of the DLL
1.129 +must construct an instance of, and return a pointer to, a CApaDataRecognizerType
1.130 +derived class.
1.131 +
1.132 +@publishedAll
1.133 +@released */
1.134 + {
1.135 + friend class TDataToRecognize; // so that it can call the overloads of DoRecognizeL
1.136 +public:
1.137 + /** A set of values used to indicate the probability that the recognizer will successfully
1.138 + identify data. The Application Architecture framework uses this set to determine
1.139 + the order in which recognizers are invoked.
1.140 +
1.141 + @see CApaDataRecognizerType()
1.142 + @see Priority() */
1.143 + enum TRecognizerPriority
1.144 + {
1.145 + /** The highest recognizer priority. Recognizers with this priority are invoked
1.146 + before those with any other priority. */
1.147 + EHigh=100,
1.148 + /** The normal recognizer priority. Recognizers with this priority are invoked
1.149 + after those with a EHigh priority but before those with a ELow priority. */
1.150 + ENormal=0,
1.151 + /** The lowest recognizer priority. */
1.152 + ELow=-100
1.153 + };
1.154 + /** A set of values describing the probability that the recognizer assigns to its
1.155 + belief that the most recently sampled data is of the type ascribed to it. */
1.156 + enum TRecognitionConfidence
1.157 + {
1.158 + /** The data is definitely of the data type. */
1.159 + ECertain=KMaxTInt,
1.160 + /** A level of confidence between ECertain and EPossible. */
1.161 + EProbable=100,
1.162 + /** The data is possibly of the data type. */
1.163 + EPossible=0,
1.164 + /** A level of confidence between EPossible and ENotRecognized. */
1.165 + EUnlikely=-100,
1.166 + /** The data is not recognized. */
1.167 + ENotRecognized=KMinTInt
1.168 + };
1.169 +public:
1.170 + inline TInt MimeTypesCount() const;
1.171 + inline TUid TypeUid() const;
1.172 + inline TInt Priority() const;
1.173 + inline TInt Confidence() const;
1.174 + inline TInt Locked() const;
1.175 + IMPORT_C TDataRecognitionResult RecognizeL(const TDesC& aName, const TDesC8& aBuffer);
1.176 + TDataRecognitionResult RecognizeL(TDataToRecognize& aDataToRecognize);
1.177 + IMPORT_C TDataType MimeType();
1.178 + IMPORT_C void Lock();
1.179 + IMPORT_C void Unlock();
1.180 + IMPORT_C void UpdateDataTypesL();
1.181 + IMPORT_C ~CApaDataRecognizerType();
1.182 + IMPORT_C virtual TUint PreferredBufSize();
1.183 + /** Gets one of the data (MIME) types that the recognizer can recognize.
1.184 +
1.185 + @param aIndex An index that identifies the data type. Typically, the minimum
1.186 + value is zero and the maximum value is the value of MimeTypesCount() - 1.
1.187 + @return The data (MIME) type. */
1.188 + IMPORT_C virtual TDataType SupportedDataTypeL(TInt aIndex) const = 0;
1.189 +protected:
1.190 + IMPORT_C CApaDataRecognizerType(TUid aUid, TInt aPriority);
1.191 + IMPORT_C RFile* FilePassedByHandleL();
1.192 +private:
1.193 + IMPORT_C virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
1.194 + // Reserved virtual functions...
1.195 + IMPORT_C virtual void Reserved_1();
1.196 +public:
1.197 + IMPORT_C static CApaDataRecognizerType* CreateDataRecognizerL(TUid aImplUid);
1.198 + CDataRecognizerExtension* DataRecognizerExtension();
1.199 +protected:
1.200 + const TUid iTypeUid;
1.201 + const TInt iPriority;
1.202 + /** The number of data (MIME) types supported by this recognizer. Typically, this
1.203 + is set during construction of an instance of the derived class.
1.204 +
1.205 + Users of the derived class use MimeTypesCount() to get this value. */
1.206 + TInt iCountDataTypes;
1.207 + /** The recognizer's confidence rating of the most recently recognized data.
1.208 +
1.209 + Users of the derived class use Confidence() to get this value. */
1.210 + TInt iConfidence;
1.211 + /** The data (MIME) type of the most recently recognized data.
1.212 +
1.213 + Users of the derived class use MimeType() to get this value. */
1.214 + TDataType iDataType;
1.215 +private:
1.216 + TInt iLock;
1.217 + CDataRecognizerExtension* iDataRecognizerExtn;
1.218 + };
1.219 +
1.220 +#include <apmrec.inl>
1.221 +
1.222 +#endif