common/tools/ats/smoketest/localisation/apparchitecture/tef/TNonNative/TNonNativeRec.cpp
changeset 793 0c32c669a39d
child 872 17498133d9ad
equal deleted inserted replaced
792:893b85cda81b 793:0c32c669a39d
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This recognizer is part of the supporting test code for T_NonNativeAppsStep.CPP
       
    15 // This recognizer only exists to associate the document names defined in T_NonNativeAppsStep.h 
       
    16 // with the TstNonNativeApp.exe application.
       
    17 // This enables T_NonNativeAppsSt ep.CPP to launch TstNonNativeApp.app by starting the document names.
       
    18 // 
       
    19 //
       
    20 
       
    21 
       
    22 
       
    23 /**
       
    24  @file
       
    25  @internalComponent - Internal Symbian test code
       
    26 */
       
    27 
       
    28 #include <E32STD.H>
       
    29 #include <E32BASE.H>
       
    30 #include <APMSTD.H>
       
    31 #include <APMREC.H>
       
    32 #include <F32FILE.H>
       
    33 
       
    34 #include <apfrec.h>
       
    35 #include <ImplementationProxy.h> 
       
    36 
       
    37 _LIT8(KLit8_DataType_Gif, "x-epoc/nna-gif");
       
    38 _LIT8(KLit8_DataType_Html, "x-epoc/nna-html");
       
    39 _LIT8(KLit8_DataType_Vcard, "x-epoc/nna-vcf");
       
    40 _LIT8(KLit8_DataType_plainText, "x-epoc/nna-txt");
       
    41 
       
    42 const TUid KUidNonNativeRecognizer={0x10207f95};
       
    43 const TUint KImplNonNativeRecognizer=0x10207f96;
       
    44 
       
    45 enum TMimeTypes
       
    46     {
       
    47     EMimeTypeNnt1 = 0,
       
    48     EMimeTypeNnt2,
       
    49     EMimeTypeNnt3,
       
    50     EMimeTypeNnt4,
       
    51     EMimeLast
       
    52     };
       
    53 
       
    54 _LIT(KLitMimeExtensionNnt1, ".NNA1");
       
    55 _LIT(KLitMimeExtensionNnt2, ".NNA2");
       
    56 _LIT(KLitMimeExtensionNnt3, ".NNA3");
       
    57 _LIT(KLitMimeExtensionNnt4, ".NNA4");
       
    58 
       
    59 
       
    60 // CTNonNativeRec definition
       
    61 
       
    62 class CTNonNativeRec : public CApaDataRecognizerType
       
    63 	{
       
    64 public:
       
    65 	CTNonNativeRec();
       
    66 	static CApaDataRecognizerType* CreateRecognizerL();
       
    67 private:
       
    68 	// from CApaDataRecognizerType
       
    69 	virtual TUint PreferredBufSize();
       
    70 	virtual TDataType SupportedDataTypeL(TInt aIndex) const;
       
    71 	virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
       
    72 	};
       
    73 
       
    74 
       
    75 // CTNonNativeRec implementation
       
    76 
       
    77 CTNonNativeRec::CTNonNativeRec() 
       
    78 	:CApaDataRecognizerType(KUidNonNativeRecognizer, EHigh)
       
    79 	{
       
    80 	iCountDataTypes = EMimeLast;
       
    81 	} 
       
    82 
       
    83 TUint CTNonNativeRec::PreferredBufSize()
       
    84 	{
       
    85 	return 0;
       
    86 	}
       
    87 
       
    88 TDataType CTNonNativeRec::SupportedDataTypeL(TInt aIndex) const
       
    89 	{
       
    90 	if (aIndex == EMimeTypeNnt1)
       
    91 		return TDataType(KLit8_DataType_Gif);
       
    92     
       
    93     else if (aIndex == EMimeTypeNnt2)
       
    94 		return TDataType(KLit8_DataType_Html);
       
    95     
       
    96     else if (aIndex == EMimeTypeNnt3)
       
    97 		return TDataType(KLit8_DataType_Vcard);
       
    98     
       
    99     else if (aIndex == EMimeTypeNnt4)
       
   100 		return TDataType(KLit8_DataType_plainText);
       
   101     
       
   102     else
       
   103         return TDataType(KNullDesC8);
       
   104     }
       
   105  
       
   106 
       
   107 void CTNonNativeRec::DoRecognizeL(const TDesC& aName, const TDesC8&)
       
   108 	{
       
   109 
       
   110 	// Compare if the file extension is known
       
   111 	if (aName.Length() < 5)
       
   112 		{
       
   113     	iDataType = TDataType(KNullDesC8); 	
       
   114     	iConfidence = ENotRecognized;
       
   115 		return;
       
   116 		}
       
   117 
       
   118 	if (aName.Right(5).CompareF(KLitMimeExtensionNnt1) == 0)
       
   119 		{
       
   120 		iDataType = TDataType(KLit8_DataType_Gif);
       
   121 		iConfidence = ECertain;
       
   122 		}
       
   123 	else if (aName.Right(5).CompareF(KLitMimeExtensionNnt2) == 0)
       
   124 		{
       
   125 		iDataType = TDataType(KLit8_DataType_Html);
       
   126 		iConfidence = ECertain;
       
   127 		}
       
   128 	else if (aName.Right(5).CompareF(KLitMimeExtensionNnt3) == 0)
       
   129 		{
       
   130 		iDataType = TDataType(KLit8_DataType_Vcard);
       
   131 		iConfidence = ECertain;
       
   132 		}
       
   133 	else if (aName.Right(5).CompareF(KLitMimeExtensionNnt4) == 0)
       
   134 		{
       
   135 		iDataType = TDataType(KLit8_DataType_plainText);
       
   136 		iConfidence = ECertain;
       
   137 		}
       
   138     else
       
   139     	{
       
   140     	iDataType = TDataType(KNullDesC8); 	
       
   141     	iConfidence = ENotRecognized;
       
   142     	}
       
   143 	}
       
   144 
       
   145 // stand-alone functions
       
   146 
       
   147 CApaDataRecognizerType* CTNonNativeRec::CreateRecognizerL()
       
   148 	{
       
   149 	return new (ELeave) CTNonNativeRec();
       
   150 	}
       
   151 
       
   152 const TImplementationProxy ImplementationTable[] = 
       
   153     {
       
   154 	IMPLEMENTATION_PROXY_ENTRY(KImplNonNativeRecognizer, CTNonNativeRec::CreateRecognizerL)
       
   155 	};
       
   156 
       
   157 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   158     {
       
   159     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   160     return ImplementationTable;
       
   161     }