genericservices/mimerecognitionfw/tef/TEcomDecpDataRec.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2006-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 
       
    23 #include <eikenv.h>
       
    24 #include <bautils.h>
       
    25 #include <f32file.h>
       
    26 #include <ecom/implementationproxy.h> 
       
    27 
       
    28 #include "TEcomDecpDataRec.h"
       
    29 
       
    30 const TInt KNumDataTypes = 1;
       
    31 const TUid KUid = {0x102032A2};
       
    32 
       
    33 
       
    34 const TInt KTestDataRecognizerError=-420;  // some random number for test error code
       
    35 _LIT(KDeceptiveRecognizerToken, "c:\\test\\appfwk\\emime\\deceptive_recognizer.token");
       
    36 
       
    37 
       
    38 CApaDataRecognizerType* CTEcomDecpDataRec::CreateRecognizerL()
       
    39 	{
       
    40     return new (ELeave) CTEcomDecpDataRec;
       
    41 	}
       
    42 
       
    43 CTEcomDecpDataRec::CTEcomDecpDataRec():CApaDataRecognizerType(KUid, CApaDataRecognizerType::EHigh)
       
    44 	{
       
    45     iCountDataTypes = KNumDataTypes;
       
    46 	}
       
    47 
       
    48 TUint CTEcomDecpDataRec::PreferredBufSize()
       
    49 	{
       
    50     return 0;
       
    51 	}
       
    52 
       
    53 TDataType CTEcomDecpDataRec::SupportedDataTypeL(TInt /*lIndex*/) const
       
    54 	{
       
    55 	return TDataType(_L8("deceptivedata/app"));
       
    56 	}
       
    57 
       
    58 void CTEcomDecpDataRec::DoRecognizeL(const TDesC& /*aName*/, const TDesC8& /*aBuffer*/)
       
    59 	{
       
    60 	// KTestDataRecognizerError - Random error code chosen to simulate a leave in a recognizer which can be used for testing.
       
    61 	//
       
    62 	// NOTE: To avoid leaving with KTestDataRecognizerError whenever a file is not recognized, a token has been used,
       
    63 	//		 so that only when running emime tests this leaving will occur (i.e, the token is created/destroyed during such tests).
       
    64 	//		 Otherwise, the DoRecognizeL does nothing.
       
    65 	
       
    66 	RFs fs;
       
    67 	CleanupClosePushL(fs);
       
    68 	User::LeaveIfError(fs.Connect());
       
    69 	
       
    70 	if (BaflUtils::FileExists(fs, KDeceptiveRecognizerToken))
       
    71 		{
       
    72 		User::Leave(KTestDataRecognizerError);
       
    73 		}
       
    74 
       
    75  	CleanupStack::PopAndDestroy(&fs);
       
    76  	}