localisation/apparchitecture/tef/TMimeRec/recmime.CPP
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 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 //
       
    15 
       
    16 #include <ImplementationProxy.h>
       
    17 
       
    18 #include "appfwk_test_utils.h"
       
    19 #include "recmime.h"
       
    20 #include "constants.hrh"
       
    21 #include "constants.h"
       
    22 
       
    23 /////////////////////////////////////////////////
       
    24 
       
    25 const TInt KMaxBufferLength=1024; // maximum amount of buffer space we will ever use
       
    26 
       
    27 /////////////////////////////////////////////////
       
    28 
       
    29 /*
       
    30 DLL entry point
       
    31 */
       
    32 GLDEF_C TInt E32Dll()
       
    33 	{
       
    34 	return KErrNone;
       
    35 	}
       
    36 
       
    37 /*
       
    38 Private constructor
       
    39 */
       
    40 CTestMimeRecognizer::CTestMimeRecognizer()
       
    41 	:CApaDataRecognizerType(KUidMmrRecognizer, CApaDataRecognizerType::EHigh)
       
    42 	{
       
    43 	iCountDataTypes=KNumMimeTypes;
       
    44 	}
       
    45 	
       
    46 /*
       
    47 Ecom factory function
       
    48 
       
    49 Due to platsec we can't build plugin.dll to an alternative location and we can't
       
    50 copy files from epoc32\release\winscw\udeb. Both plugin.rsc and plugin.dll must 
       
    51 be on the same drive to be installed. 
       
    52 
       
    53 The workaround to implement this tef-test is works like this:
       
    54 1. This test plugin are copied into z: by the build tools
       
    55 2. This plugin will not be installed during startup because CreateRecognizerL will leave
       
    56 3. During the test a dummy plugin.rsc will be copied into c:\resource\plugins to trig Ecom
       
    57 4. Apparc will re-scan and make sure all recognizers listed by Ecom are properly installed
       
    58 5. Ecom will not install the copied dummy file as it has no matching dll on the same drive, but
       
    59 6. This recognizer will detect the dummy file and chose not to leave from CreateRecognizerL
       
    60 */
       
    61 CApaDataRecognizerType* CTestMimeRecognizer::CreateRecognizerL()
       
    62 	{
       
    63 	RSmlTestUtils fileServ;
       
    64 	CleanupClosePushL(fileServ);
       
    65 	User::LeaveIfError(fileServ.Connect());
       
    66 	TBool fileExists = EFalse;
       
    67 	User::LeaveIfError(fileServ.IsFilePresent(KRscTargetPath, fileExists));
       
    68 	CleanupStack::PopAndDestroy(&fileServ);	
       
    69 	
       
    70 	if(!fileExists)
       
    71 		User::Leave(KErrPathNotFound);			
       
    72 	
       
    73 	return new (ELeave) CTestMimeRecognizer();
       
    74 	}
       
    75 	
       
    76 TUint CTestMimeRecognizer::PreferredBufSize()
       
    77 	{
       
    78 	return KMaxBufferLength;
       
    79 	}
       
    80 
       
    81 TDataType CTestMimeRecognizer::SupportedDataTypeL(TInt /*aIndex*/) const
       
    82 	{
       
    83 	return TDataType(KDataTypeNew);
       
    84 	}
       
    85 
       
    86 void CTestMimeRecognizer::DoRecognizeL(const TDesC& /*aName*/, const TDesC8& /*aBuffer*/)
       
    87 	{
       
    88     // If an error stops CTestMimeRecognizer being removed as part of test cleanup, 
       
    89     // returning ENotRecognized will avoid the possibility of impacting other test code.
       
    90 	iDataType=TDataType();
       
    91 	iConfidence=ENotRecognized;
       
    92 	}
       
    93 
       
    94 const TImplementationProxy ImplementationTable[] = 
       
    95     {
       
    96 	IMPLEMENTATION_PROXY_ENTRY(KUidMmrRecognizerValue, CTestMimeRecognizer::CreateRecognizerL)
       
    97 	};
       
    98 
       
    99 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   100     {
       
   101     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   102     return ImplementationTable;
       
   103     }