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.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Example file/test code to demonstrate how to develop a TestExecute Server
sl@0
    15
// Developers should take this project as a template and substitute their own
sl@0
    16
// code at the __EDIT_ME__ tags
sl@0
    17
// for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
sl@0
    18
// in the process of the client. The client initialises the server by calling the
sl@0
    19
// one and only ordinal.
sl@0
    20
// 
sl@0
    21
//
sl@0
    22
sl@0
    23
/**
sl@0
    24
 @file mmddtestserver.cpp
sl@0
    25
*/
sl@0
    26
sl@0
    27
#include <simulprocclient.h>
sl@0
    28
#include "mmddtestserver.h"
sl@0
    29
#include "mmddteststep0036.h"
sl@0
    30
sl@0
    31
_LIT(KServerName,"SDSMMDDTestServer");
sl@0
    32
// __EDIT_ME__ - Use your own server class name
sl@0
    33
CMMDDTestServer* CMMDDTestServer::NewL()
sl@0
    34
/**
sl@0
    35
 * @return - Instance of the test server
sl@0
    36
 * Called inside the MainL() function to create and start the
sl@0
    37
 * CMMDDTestServer derived server.
sl@0
    38
 */
sl@0
    39
	{
sl@0
    40
	// __EDIT_ME__ new your server class here
sl@0
    41
	CMMDDTestServer * server = new (ELeave) CMMDDTestServer();
sl@0
    42
	CleanupStack::PushL(server);
sl@0
    43
	
sl@0
    44
	// Either use a StartL or ConstructL, the latter will permit
sl@0
    45
	// Server Logging.
sl@0
    46
sl@0
    47
	server->StartL(KServerName); 
sl@0
    48
	//server-> ConstructL(KServerName);
sl@0
    49
	CleanupStack::Pop(server);
sl@0
    50
	return server;
sl@0
    51
	}
sl@0
    52
sl@0
    53
CSession2* CMMDDTestServer::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const
sl@0
    54
	{
sl@0
    55
	// Retrieve client's thread Id
sl@0
    56
	RThread clientThread;
sl@0
    57
	aMessage.ClientL(clientThread);
sl@0
    58
	const_cast<CMMDDTestServer*>(this)->iClientThreadId = clientThread.Id();
sl@0
    59
	clientThread.Close();
sl@0
    60
	
sl@0
    61
	return CSimulProcServer::NewSessionL(aVersion, aMessage);
sl@0
    62
	}
sl@0
    63
	
sl@0
    64
CMMDDTestServer::CMMDDTestServer()
sl@0
    65
	{
sl@0
    66
	}
sl@0
    67
	
sl@0
    68
CMMDDTestServer::~CMMDDTestServer()
sl@0
    69
	{
sl@0
    70
	}
sl@0
    71
	
sl@0
    72
sl@0
    73
// EKA2 much simpler
sl@0
    74
// Just an E32Main and a MainL()
sl@0
    75
LOCAL_C void MainL()
sl@0
    76
/**
sl@0
    77
 * Much simpler, uses the new Rendezvous() call to sync with the client
sl@0
    78
 */
sl@0
    79
	{
sl@0
    80
	// Leave the hooks in for platform security
sl@0
    81
#if (defined __DATA_CAGING__)
sl@0
    82
	RProcess().DataCaging(RProcess::EDataCagingOn);
sl@0
    83
	RProcess().SecureApi(RProcess::ESecureApiOn);
sl@0
    84
#endif
sl@0
    85
	CActiveScheduler* sched=NULL;
sl@0
    86
	sched=new(ELeave) CActiveScheduler;
sl@0
    87
	CActiveScheduler::Install(sched);
sl@0
    88
	// __EDIT_ME__ Your server name
sl@0
    89
	CMMDDTestServer* server = NULL;
sl@0
    90
	// Create the CMMDDTestServer derived server
sl@0
    91
	// __EDIT_ME__ Your server name
sl@0
    92
	TRAPD(err,server = CMMDDTestServer::NewL());
sl@0
    93
	if(!err)
sl@0
    94
		{
sl@0
    95
		// Sync with the client and enter the active scheduler
sl@0
    96
		RProcess::Rendezvous(KErrNone);
sl@0
    97
		sched->Start();
sl@0
    98
		}
sl@0
    99
	delete server;
sl@0
   100
	delete sched;
sl@0
   101
	}
sl@0
   102
sl@0
   103
sl@0
   104
GLDEF_C TInt E32Main()
sl@0
   105
/**
sl@0
   106
 * @return - Standard Epoc error code on exit
sl@0
   107
 */
sl@0
   108
	{
sl@0
   109
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
   110
	if(cleanup == NULL)
sl@0
   111
		{
sl@0
   112
		return KErrNoMemory;
sl@0
   113
		}
sl@0
   114
	TRAP_IGNORE(MainL());
sl@0
   115
	delete cleanup;
sl@0
   116
	return KErrNone;
sl@0
   117
    }
sl@0
   118
sl@0
   119
sl@0
   120
CSimulProcTestStep* CMMDDTestServer::CreateTestStep(const TDesC& aStepName) const
sl@0
   121
/**
sl@0
   122
 * @return - A CTestStep derived instance
sl@0
   123
 * Implementation of CTestServer pure virtual
sl@0
   124
 */
sl@0
   125
	{
sl@0
   126
	CSimulProcTestStep* testStep = NULL; 
sl@0
   127
	// __EDIT_ME__ - Create your own test steps here
sl@0
   128
	// This server creates just one step but create as many as you want
sl@0
   129
	// They are created "just in time" when the worker thread is created
sl@0
   130
	
sl@0
   131
	if(aStepName == _L("SecDevSndTS0036"))
sl@0
   132
		testStep = CSecDevSndTS0036::NewL(iClientThreadId);
sl@0
   133
	
sl@0
   134
	return testStep;
sl@0
   135
	}
sl@0
   136