traceservices/tracefw/ulogger/unit_test/te-outfrwkchans/te-serial/te_serialsuiteserver.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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 // Example file/test code to demonstrate how to develop a TestExecute Server
       
    15 // Developers should take this project as a template and substitute their own
       
    16 // for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
       
    17 // in the process of the client. The client initialises the server by calling the
       
    18 // one and only ordinal.
       
    19 // 
       
    20 //
       
    21 
       
    22 /**
       
    23  @file Te_fileSuiteServer.cpp
       
    24  @internalTechnology
       
    25 */
       
    26 
       
    27 #include "te_serialsuiteserver.h"
       
    28 #include "uloggerserialplugintest.h"
       
    29 
       
    30 _LIT(KServerName,"uloggerplugserialtest");
       
    31 CTe_serialSuite* CTe_serialSuite::NewL()
       
    32 /**
       
    33  * @return - Instance of the test server
       
    34  * Same code for Secure and non-secure variants
       
    35  * Called inside the MainL() function to create and start the
       
    36  * CTestServer derived server.
       
    37  */
       
    38 	{
       
    39 	CTe_serialSuite * server = new (ELeave) CTe_serialSuite();
       
    40 	CleanupStack::PushL(server);
       
    41 
       
    42 	server->ConstructL(KServerName);
       
    43 	CleanupStack::Pop(server);
       
    44 	return server;
       
    45 	}
       
    46 
       
    47 
       
    48 // Secure variants much simpler
       
    49 // For EKA2, just an E32Main and a MainL()
       
    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 	// Leave the hooks in for platform security
       
    57 #if (defined __DATA_CAGING__)
       
    58 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    59 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
    60 #endif
       
    61 	CActiveScheduler* sched=NULL;
       
    62 	sched=new(ELeave) CActiveScheduler;
       
    63 	CActiveScheduler::Install(sched);
       
    64 	CTe_serialSuite* server = NULL;
       
    65 	// Create the CTestServer derived server
       
    66 	TRAPD(err,server = CTe_serialSuite::NewL());
       
    67 	if(!err)
       
    68 		{
       
    69 		// Sync with the client and enter the active scheduler
       
    70 		RProcess::Rendezvous(KErrNone);
       
    71 		sched->Start();
       
    72 		}
       
    73 	delete server;
       
    74 	delete sched;
       
    75 	}
       
    76 
       
    77 
       
    78 
       
    79 GLDEF_C TInt E32Main()
       
    80 /**
       
    81  * @return - Standard Epoc error code on process exit
       
    82  * Secure variant only
       
    83  * Process entry point. Called by client using RProcess API
       
    84  */
       
    85 	{
       
    86 	__UHEAP_MARK;
       
    87 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    88 	if(cleanup == NULL)
       
    89 		{
       
    90 		return KErrNoMemory;
       
    91 		}
       
    92 	TRAPD(err,MainL());
       
    93 	delete cleanup;
       
    94 	__UHEAP_MARKEND;
       
    95 	return err;
       
    96     }
       
    97 
       
    98 
       
    99 CTestStep* CTe_serialSuite::CreateTestStep(const TDesC& aStepName)
       
   100 /**
       
   101  * @return - A CTestStep derived instance
       
   102  * Secure and non-secure variants
       
   103  * Implementation of CTestServer pure virtual
       
   104  */
       
   105 	{
       
   106 	CTestStep* testStep = NULL;
       
   107     if(aStepName == KSerial0Step)
       
   108          testStep = new CSerial0Step();
       
   109 
       
   110 	return testStep;
       
   111 	}