diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/example_recognizer_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/example_recognizer_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ - -
-00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). -00002 // All rights reserved. -00003 // This component and the accompanying materials are made available -00004 // under the terms of "Eclipse Public License v1.0" -00005 // which accompanies this distribution, and is available -00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". -00007 // -00008 // Initial Contributors: -00009 // Nokia Corporation - initial contribution. -00010 // -00011 // Contributors: -00012 // -00013 // Description: -00014 // EXAMPLE RECOGNIZER -00015 // This example code demonstrates how to write a simple data recognizer. -00016 // -00017 -00018 -00019 #include <eikenv.h> -00020 #include <implementationproxy.h> -00021 -00022 // User include -00023 #include "exampleRecognizer.h" -00024 -00025 const TInt KNumDataTypes = 1; -00026 const TUid KExampleDllUid = {0xE8000002}; -00027 const TInt KImplementationUid = 0x101F7DA1; -00028 -00029 // An example mime type -00030 _LIT8(KExampleTextMimeType, "text/example"); -00031 -00032 /* -00033 Constructor - sets the number of supported mime types, -00034 the recognizer's priority and its UID. -00035 */ -00036 CExampleNewRecognizer::CExampleNewRecognizer():CApaDataRecognizerType(KExampleDllUid, CApaDataRecognizerType::EHigh) -00037 { -00038 iCountDataTypes = KNumDataTypes; -00039 } -00040 -00041 /* -00042 Specifies this recognizer's preferred data buffer size passed to DoRecognizeL(). -00043 The actual value used will be the maximum of all recognizers. -00044 */ -00045 TUint CExampleNewRecognizer::PreferredBufSize() -00046 { -00047 return 24; -00048 } -00049 -00050 -00051 /* -00052 Returns the indexed data type that the recognizer can recognize. -00053 In this case, only 1 is supported. -00054 */ -00055 TDataType CExampleNewRecognizer::SupportedDataTypeL(TInt /*aIndex*/) const -00056 { -00057 return TDataType(KExampleTextMimeType); -00058 } -00059 -00060 /* -00061 Attempts to recognize the data type, given the filename and data buffer. -00062 */ -00063 void CExampleNewRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer) -00064 { -00065 _LIT8(KExampleData, "example"); -00066 _LIT(KDotExample, ".Example"); -00067 -00068 TParse parse; -00069 parse.Set(aName,NULL,NULL); -00070 TPtrC ext=parse.Ext(); // extract the extension from the filename -00071 -00072 if (ext.CompareF(KDotExample)==0 && aBuffer.FindF(KExampleData)!=KErrNotFound) -00073 { -00074 iConfidence=ECertain; -00075 iDataType=TDataType(KExampleTextMimeType); -00076 } -00077 } -00078 -00079 /* -00080 The ECom implementation creation function. -00081 */ -00082 CApaDataRecognizerType* CExampleNewRecognizer::CreateRecognizerL() -00083 { -00084 return new (ELeave) CExampleNewRecognizer; -00085 } -00086 -00087 /* -00088 Standard ECom framework code -00089 */ -00090 const TImplementationProxy ImplementationTable[] = -00091 { -00092 IMPLEMENTATION_PROXY_ENTRY(KImplementationUid,CExampleNewRecognizer::CreateRecognizerL) -00093 }; -00094 -00095 /* -00096 Standard ECom framework code -00097 */ -00098 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) -00099 { -00100 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); -00101 return ImplementationTable; -00102 } -