genericservices/mimerecognitionfw/tef/TEmimeTestServer.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 "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 // Secure EKA2 versions will be a simpler xxxServer.exe running in its own process.
       
    15 // Non-secure versions will be xxxServer.Dll and require a thread to be started
       
    16 // in the process of the client. The client initialises the server by calling the
       
    17 // one and only ordinal.
       
    18 // 
       
    19 //
       
    20 
       
    21 /**
       
    22  @file 
       
    23  @internalComponent - Internal Symbian test code
       
    24 */
       
    25 #include "TEmimeTestServer.h"
       
    26 #include "T_MimeStep.h"
       
    27 #include "T_MstrStep.h"
       
    28 #include "T_Maps.h"
       
    29 #include <ecom/ecom.h>
       
    30 
       
    31 
       
    32 _LIT(KServerName,"TEmimeTestServer");
       
    33 CTEmimeTestServer* CTEmimeTestServer::NewL()
       
    34 /**
       
    35    @return - Instance of the test server
       
    36    Same code for Secure and non-secure variants
       
    37    Called inside the MainL() function to create and start the
       
    38    CTestServer derived server.
       
    39  */
       
    40 	{
       
    41 	CTEmimeTestServer * server = new (ELeave) CTEmimeTestServer();
       
    42 	CleanupStack::PushL(server);
       
    43 	// CServer base class call
       
    44 	server->StartL(KServerName);
       
    45 	CleanupStack::Pop(server);
       
    46 	return server;
       
    47 	}
       
    48 
       
    49 
       
    50 LOCAL_C void MainL()
       
    51 
       
    52 /** Secure variant
       
    53     Much simpler, uses the new Rendezvous() call to sync with the client */
       
    54 
       
    55 	{
       
    56 #if (defined __DATA_CAGING__)
       
    57 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    58 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    59 #endif
       
    60 	CActiveScheduler* sched=NULL;
       
    61 	sched=new(ELeave) CActiveScheduler;
       
    62 	CActiveScheduler::Install(sched);
       
    63 	CTEmimeTestServer* server = NULL;
       
    64 	// Create the CTestServer derived server
       
    65 	TRAPD(err,server = CTEmimeTestServer::NewL());
       
    66 	if(!err)
       
    67 		{
       
    68 		// Sync with the client and enter the active scheduler
       
    69 		RProcess::Rendezvous(KErrNone);
       
    70 		sched->Start();
       
    71 		}
       
    72 	delete server;
       
    73 	delete sched;
       
    74 	}
       
    75 
       
    76 GLDEF_C TInt E32Main()
       
    77 
       
    78 /** 
       
    79 	@return - Standard Epoc error code on process exit
       
    80     Secure variant only
       
    81     Process entry point. Called by client using RProcess API
       
    82 */
       
    83 	{
       
    84 	__UHEAP_MARK;
       
    85 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    86 	if(cleanup == NULL)
       
    87 		{
       
    88 		return KErrNoMemory;
       
    89 		}
       
    90 	TRAP_IGNORE(MainL());
       
    91 	delete cleanup;
       
    92 	REComSession::FinalClose();	
       
    93 	__UHEAP_MARKEND;
       
    94 	return KErrNone;
       
    95     }
       
    96 
       
    97 
       
    98 
       
    99 // __EDIT_ME__ - Use your own server class name
       
   100 CTestStep* CTEmimeTestServer::CreateTestStep(const TDesC& aStepName)
       
   101 
       
   102 /**
       
   103    @return - A CTestStep derived instance
       
   104    Secure and non-secure variants
       
   105    Implementation of CTestServer pure virtual
       
   106  */
       
   107 	{
       
   108 	CTestStep* testStep = NULL;
       
   109 	// __EDIT_ME__ - Create your own test steps here
       
   110 	// This server creates just one step but create as many as you want
       
   111 	// They are created "just in time" when the worker thread is created
       
   112 	if(aStepName == KT_MimeStep)
       
   113 		testStep = new CT_MimeStep();
       
   114 	else if(aStepName == KT_MstrStep)
       
   115 		testStep = new CT_MstrStep();
       
   116 	else if(aStepName == KT_Maps)
       
   117 		testStep = new CT_Maps();
       
   118 	return testStep;
       
   119 	}