os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/CapTestServer/src/CapTestServer.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-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 // Test code to develop a TestExecute Server
    15 // for (WINS && !EKA2) 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 CapTestServer.cpp
    23 */
    24 
    25 #include <simulprocclient.h>
    26 
    27 #include "CapTestServer.h"
    28 #include "CapTestStep0012.h"
    29 #include "CapTestStep0014.h"
    30 
    31 
    32 _LIT(KServerName,"CapTestServer");
    33 CCapTestServer* CCapTestServer::NewL()
    34 /**
    35  * @return - Instance of the test server
    36  * Called inside the MainL() function to create and start the
    37  * CTestServer derived server.
    38  */
    39 	{
    40 	CCapTestServer * server = new (ELeave) CCapTestServer();
    41 	CleanupStack::PushL(server);
    42 	
    43 	// Either use a StartL or ConstructL, the latter will permit
    44 	// Server Logging.
    45 	server->StartL(KServerName); 
    46 
    47 	//server-> ConstructL(KServerName);
    48 	CleanupStack::Pop(server);
    49 	return server;
    50 	}
    51 	
    52 CCapTestServer::CCapTestServer()
    53 	{
    54 	}
    55 	
    56 CCapTestServer::~CCapTestServer()
    57 	{
    58 	}
    59 	
    60 
    61 // EKA2 much simpler
    62 // Just an E32Main and a MainL()
    63 LOCAL_C void MainL()
    64 /**
    65  * Much simpler, uses the new Rendezvous() call to sync with the client
    66  */
    67 	{
    68 	// Leave the hooks in for platform security
    69 #if (defined __DATA_CAGING__)
    70 	RProcess().DataCaging(RProcess::EDataCagingOn);
    71 	RProcess().SecureApi(RProcess::ESecureApiOn);
    72 #endif
    73 	CActiveScheduler* sched=NULL;
    74 	sched=new(ELeave) CActiveScheduler;
    75 	CActiveScheduler::Install(sched);
    76 	CCapTestServer* server = NULL;
    77 	// Create the CTestServer derived server
    78 	TRAPD(err,server = CCapTestServer::NewL());
    79 	if(!err)
    80 		{
    81 		// Sync with the client and enter the active scheduler
    82 		RProcess::Rendezvous(KErrNone);
    83 		sched->Start();
    84 		}
    85 	delete server;
    86 	delete sched;
    87 	}
    88 
    89 
    90 GLDEF_C TInt E32Main()
    91 /**
    92  * @return - Standard Epoc error code on exit
    93  */
    94 	{
    95 	CTrapCleanup* cleanup = CTrapCleanup::New();
    96 	if(cleanup == NULL)
    97 		{
    98 		return KErrNoMemory;
    99 		}
   100 	TRAP_IGNORE(MainL());
   101 	delete cleanup;
   102 	return KErrNone;
   103     }
   104 
   105 
   106 CSimulProcTestStep* CCapTestServer::CreateTestStep(const TDesC& aStepName) const
   107 /**
   108  * @return - A CTestStep derived instance
   109  * Implementation of CTestServer pure virtual
   110  */
   111 	{
   112 	CSimulProcTestStep* testStep = NULL; 
   113 	// This server creates just one step but create as many as you want
   114 	// They are created "just in time" when the worker thread is created
   115 
   116 	if(aStepName == _L("CapTestStep0012"))
   117 		testStep = CAudPlayUtilTS0012::NewL();
   118 	else if(aStepName == _L("CapTestStep0014"))
   119 		testStep = CAudPlayUtilTS0014::NewL();
   120 
   121 	return testStep;
   122 	}
   123