00001 /* 00002 * ============================================================================ 00003 * Name : RecognizerEx from RecognizerEx.cpp 00004 * Part of : RecognizerEx 00005 * Created : 27/06/06 by Forum Nokia 00006 * Version : 2.0 00007 * Copyright: Nokia Corporation 00008 * ============================================================================ 00009 */ 00010 00011 // INCLUDE FILES 00012 #include <apmrec.h> 00013 #include <apmstd.h> 00014 //#ifdef __SERIES60_3X__ 00015 #include <ImplementationProxy.h> 00016 //#endif 00017 #include "RecognizerEx.h" 00018 00019 // CONSTANTS 00020 const TUid KUidRecognizerEx={0x101FF1ec}; 00021 const TInt KMaxBufferLength=4; // maximum amount of buffer space we will ever use 00022 const TInt KRecRtFileExtensionsMightBeValid=4; // If the file name length > 4, the file extension might be valid 00023 00024 _LIT(KExtension1, ".new"); 00025 00026 _LIT8(KDataType,"application/something-totally-new"); 00027 00028 // ================= MEMBER FUNCTIONS ======================= 00029 00030 // --------------------------------------------------------- 00031 // RecognizerEx::RecognizerEx() 00032 // constructs the object 00033 // --------------------------------------------------------- 00034 // 00035 CApaRecognizerEx::CApaRecognizerEx() 00036 : CApaDataRecognizerType(KUidRecognizerEx, CApaDataRecognizerType::ENormal) 00037 { 00038 iCountDataTypes=1; 00039 } 00040 00041 // --------------------------------------------------------- 00042 // RecognizerEx::~RecognizerEx() 00043 // Destroys the object 00044 // --------------------------------------------------------- 00045 // 00046 CApaRecognizerEx::~CApaRecognizerEx() 00047 { 00048 // Do nothing 00049 } 00050 00051 // --------------------------------------------------------- 00052 // RecognizerEx::PreferredBufSize() 00053 // Returns preferred buffer size 00054 // --------------------------------------------------------- 00055 // 00056 TUint CApaRecognizerEx::PreferredBufSize() 00057 { 00058 return KMaxBufferLength; 00059 } 00060 00061 // --------------------------------------------------------- 00062 // RecognizerEx::SupportedDataTypeL() 00063 // Returns supported mime type 00064 // --------------------------------------------------------- 00065 // 00066 TDataType CApaRecognizerEx::SupportedDataTypeL(TInt /*aIndex*/) const 00067 { 00068 return TDataType(KDataType); 00069 } 00070 00071 // --------------------------------------------------------- 00072 // RecognizerEx::DoRecognizeL() 00073 // Recognizes the file by name and/or head buffer 00074 // --------------------------------------------------------- 00075 // 00076 void CApaRecognizerEx::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/) 00077 { 00078 // To keep code simple, we only check file name extension 00079 if (aName.Length()>KRecRtFileExtensionsMightBeValid) 00080 { 00081 if (aName.Right(KRecRtFileExtensionsMightBeValid).CompareF(KExtension1)==0) 00082 { 00083 iConfidence=ECertain; // is certainly something totally new 00084 iDataType=TDataType(KDataType); 00085 return; 00086 } 00087 } 00088 } 00089 00090 00091 00092 // ================= OTHER EXPORTED FUNCTIONS ============== 00093 00094 //#ifdef __SERIES60_3X__ 00095 00096 // --------------------------------------------------------- 00097 // RecognizerEx::CreateRecognizerL() 00098 // Returns pointer to the new object 00099 // --------------------------------------------------------- 00100 // 00101 CApaDataRecognizerType* CApaRecognizerEx::CreateRecognizerL() 00102 { 00103 return new (ELeave) CApaRecognizerEx(); 00104 } 00105 00106 const TImplementationProxy ImplementationTable[] = 00107 { 00108 IMPLEMENTATION_PROXY_ENTRY(KRecognizerExImplementationUid, CApaRecognizerEx::CreateRecognizerL) 00109 }; 00110 00111 // --------------------------------------------------------- 00112 // ImplementationGroupProxy 00113 // Provides access to the implementationtable 00114 // --------------------------------------------------------- 00115 // 00116 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) 00117 { 00118 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); 00119 return ImplementationTable; 00120 } 00121 /* 00122 #else 00123 EXPORT_C CApaDataRecognizerType* CreateRecognizer() 00124 { 00125 CApaDataRecognizerType* thing=new CApaRecognizerEx(); 00126 return thing; // NULL if new failed 00127 } 00128 00129 GLDEF_C TInt E32Dll(TDllReason aReason) 00130 { 00131 return KErrNone; 00132 } 00133 #endif 00134 */