os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/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 // 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 // code at the __EDIT_ME__ tags
    17 // for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
    18 // in the process of the client. The client initialises the server by calling the
    19 // one and only ordinal.
    20 // 
    21 //
    22 
    23 /**
    24  @file CapTestServer.cpp
    25 */
    26 
    27 #include <simulprocclient.h>
    28 
    29 #include "CapTestServer.h"
    30 #include "CapTestStep0002.h"
    31 #include "CapTestStep0004.h"
    32 #include "CapTestStep0006.h"
    33 #include "CapTestStep0008.h"
    34 #include "CapTestStep0010.h"
    35 #include "CapTestStep0036.h"
    36 
    37 _LIT(KServerName,"SDSCapTestServer");
    38 // __EDIT_ME__ - Use your own server class name
    39 CCapTestServer* CCapTestServer::NewL()
    40 /**
    41  * @return - Instance of the test server
    42  * Called inside the MainL() function to create and start the
    43  * CTestServer derived server.
    44  */
    45 	{
    46 	// __EDIT_ME__ new your server class here
    47 	CCapTestServer * server = new (ELeave) CCapTestServer();
    48 	CleanupStack::PushL(server);
    49 	
    50 	// Either use a StartL or ConstructL, the latter will permit
    51 	// Server Logging.
    52 
    53 	server->StartL(KServerName); 
    54 	//server-> ConstructL(KServerName);
    55 	CleanupStack::Pop(server);
    56 	return server;
    57 	}
    58 
    59 CSession2* CCapTestServer::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const
    60 	{
    61 	// Retrieve client's thread Id
    62 	RThread clientThread;
    63 	aMessage.ClientL(clientThread);
    64 	const_cast<CCapTestServer*>(this)->iClientThreadId = clientThread.Id();
    65 	clientThread.Close();
    66 	
    67 	return CSimulProcServer::NewSessionL(aVersion, aMessage);
    68 	}
    69 	
    70 CCapTestServer::CCapTestServer()
    71 	{
    72 	}
    73 	
    74 CCapTestServer::~CCapTestServer()
    75 	{
    76 	}
    77 	
    78 
    79 // EKA2 much simpler
    80 // Just an E32Main and a MainL()
    81 LOCAL_C void MainL()
    82 /**
    83  * Much simpler, uses the new Rendezvous() call to sync with the client
    84  */
    85 	{
    86 	// Leave the hooks in for platform security
    87 #if (defined __DATA_CAGING__)
    88 	RProcess().DataCaging(RProcess::EDataCagingOn);
    89 	RProcess().SecureApi(RProcess::ESecureApiOn);
    90 #endif
    91 	CActiveScheduler* sched=NULL;
    92 	sched=new(ELeave) CActiveScheduler;
    93 	CActiveScheduler::Install(sched);
    94 	// __EDIT_ME__ Your server name
    95 	CCapTestServer* server = NULL;
    96 	// Create the CTestServer derived server
    97 	// __EDIT_ME__ Your server name
    98 	TRAPD(err,server = CCapTestServer::NewL());
    99 	if(!err)
   100 		{
   101 		// Sync with the client and enter the active scheduler
   102 		RProcess::Rendezvous(KErrNone);
   103 		sched->Start();
   104 		}
   105 	delete server;
   106 	delete sched;
   107 	}
   108 
   109 
   110 GLDEF_C TInt E32Main()
   111 /**
   112  * @return - Standard Epoc error code on exit
   113  */
   114 	{
   115 	CTrapCleanup* cleanup = CTrapCleanup::New();
   116 	if(cleanup == NULL)
   117 		{
   118 		return KErrNoMemory;
   119 		}
   120 	TRAP_IGNORE(MainL());
   121 	delete cleanup;
   122 	return KErrNone;
   123     }
   124 
   125 
   126 CSimulProcTestStep* CCapTestServer::CreateTestStep(const TDesC& aStepName) const
   127 /**
   128  * @return - A CTestStep derived instance
   129  * Implementation of CTestServer pure virtual
   130  */
   131 	{
   132 	CSimulProcTestStep* testStep = NULL; 
   133 	// __EDIT_ME__ - Create your own test steps here
   134 	// This server creates just one step but create as many as you want
   135 	// They are created "just in time" when the worker thread is created
   136 	
   137 	if(aStepName == _L("SecDevSndTS0002"))
   138 		testStep = CSecDevSndTS0002::NewL();
   139 	else if(aStepName == _L("SecDevSndTS0004"))
   140 		testStep = CSecDevSndTS0004::NewL();
   141 	else if(aStepName == _L("SecDevSndTS0006"))
   142 		testStep = CSecDevSndTS0006::NewL();
   143 	else if(aStepName == _L("SecDevSndTS0008"))
   144 		testStep = CSecDevSndTS0008::NewL();
   145 	else if(aStepName == _L("SecDevSndTS0010"))
   146 		testStep = CSecDevSndTS0010::NewL();
   147 	else if(aStepName == _L("SecDevSndTS0036"))
   148 		testStep = CSecDevSndTS0036::NewL(iClientThreadId);
   149 
   150 	return testStep;
   151 	}
   152