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