os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/mmddtestserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/mmddtestserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,136 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Example file/test code to demonstrate how to develop a TestExecute Server
1.18 +// Developers should take this project as a template and substitute their own
1.19 +// code at the __EDIT_ME__ tags
1.20 +// for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
1.21 +// in the process of the client. The client initialises the server by calling the
1.22 +// one and only ordinal.
1.23 +//
1.24 +//
1.25 +
1.26 +/**
1.27 + @file mmddtestserver.cpp
1.28 +*/
1.29 +
1.30 +#include <simulprocclient.h>
1.31 +#include "mmddtestserver.h"
1.32 +#include "mmddteststep0036.h"
1.33 +
1.34 +_LIT(KServerName,"SDSMMDDTestServer");
1.35 +// __EDIT_ME__ - Use your own server class name
1.36 +CMMDDTestServer* CMMDDTestServer::NewL()
1.37 +/**
1.38 + * @return - Instance of the test server
1.39 + * Called inside the MainL() function to create and start the
1.40 + * CMMDDTestServer derived server.
1.41 + */
1.42 + {
1.43 + // __EDIT_ME__ new your server class here
1.44 + CMMDDTestServer * server = new (ELeave) CMMDDTestServer();
1.45 + CleanupStack::PushL(server);
1.46 +
1.47 + // Either use a StartL or ConstructL, the latter will permit
1.48 + // Server Logging.
1.49 +
1.50 + server->StartL(KServerName);
1.51 + //server-> ConstructL(KServerName);
1.52 + CleanupStack::Pop(server);
1.53 + return server;
1.54 + }
1.55 +
1.56 +CSession2* CMMDDTestServer::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const
1.57 + {
1.58 + // Retrieve client's thread Id
1.59 + RThread clientThread;
1.60 + aMessage.ClientL(clientThread);
1.61 + const_cast<CMMDDTestServer*>(this)->iClientThreadId = clientThread.Id();
1.62 + clientThread.Close();
1.63 +
1.64 + return CSimulProcServer::NewSessionL(aVersion, aMessage);
1.65 + }
1.66 +
1.67 +CMMDDTestServer::CMMDDTestServer()
1.68 + {
1.69 + }
1.70 +
1.71 +CMMDDTestServer::~CMMDDTestServer()
1.72 + {
1.73 + }
1.74 +
1.75 +
1.76 +// EKA2 much simpler
1.77 +// Just an E32Main and a MainL()
1.78 +LOCAL_C void MainL()
1.79 +/**
1.80 + * Much simpler, uses the new Rendezvous() call to sync with the client
1.81 + */
1.82 + {
1.83 + // Leave the hooks in for platform security
1.84 +#if (defined __DATA_CAGING__)
1.85 + RProcess().DataCaging(RProcess::EDataCagingOn);
1.86 + RProcess().SecureApi(RProcess::ESecureApiOn);
1.87 +#endif
1.88 + CActiveScheduler* sched=NULL;
1.89 + sched=new(ELeave) CActiveScheduler;
1.90 + CActiveScheduler::Install(sched);
1.91 + // __EDIT_ME__ Your server name
1.92 + CMMDDTestServer* server = NULL;
1.93 + // Create the CMMDDTestServer derived server
1.94 + // __EDIT_ME__ Your server name
1.95 + TRAPD(err,server = CMMDDTestServer::NewL());
1.96 + if(!err)
1.97 + {
1.98 + // Sync with the client and enter the active scheduler
1.99 + RProcess::Rendezvous(KErrNone);
1.100 + sched->Start();
1.101 + }
1.102 + delete server;
1.103 + delete sched;
1.104 + }
1.105 +
1.106 +
1.107 +GLDEF_C TInt E32Main()
1.108 +/**
1.109 + * @return - Standard Epoc error code on exit
1.110 + */
1.111 + {
1.112 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.113 + if(cleanup == NULL)
1.114 + {
1.115 + return KErrNoMemory;
1.116 + }
1.117 + TRAP_IGNORE(MainL());
1.118 + delete cleanup;
1.119 + return KErrNone;
1.120 + }
1.121 +
1.122 +
1.123 +CSimulProcTestStep* CMMDDTestServer::CreateTestStep(const TDesC& aStepName) const
1.124 +/**
1.125 + * @return - A CTestStep derived instance
1.126 + * Implementation of CTestServer pure virtual
1.127 + */
1.128 + {
1.129 + CSimulProcTestStep* testStep = NULL;
1.130 + // __EDIT_ME__ - Create your own test steps here
1.131 + // This server creates just one step but create as many as you want
1.132 + // They are created "just in time" when the worker thread is created
1.133 +
1.134 + if(aStepName == _L("SecDevSndTS0036"))
1.135 + testStep = CSecDevSndTS0036::NewL(iClientThreadId);
1.136 +
1.137 + return testStep;
1.138 + }
1.139 +