commsfwutils/commsbufs/mbufgobblerlayer/te_mbufgobbler/src/te_mbufgobblerserver.cpp
branchRCL_3
changeset 84 486e9e9c45a7
parent 76 576874e13a2c
child 85 7c25be0307fe
equal deleted inserted replaced
76:576874e13a2c 84:486e9e9c45a7
     1 // Copyright (c) 2010 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 server
       
    15 //
       
    16 
       
    17 /**
       
    18  @file
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 
       
    23 #include <commdbconnpref.h>
       
    24 #include "te_mbufgobblerserver.h"
       
    25 #include "te_mbufgobblertest.h"
       
    26 
       
    27 _LIT(KServerName,"te_mbufgobbler");
       
    28 
       
    29 CMbufGobblerTestServer* CMbufGobblerTestServer::NewL()
       
    30 /**
       
    31  * @return - Instance of the test server
       
    32  * Called inside the MainL() function to create and start the
       
    33  * CTestServer derived server.
       
    34  */
       
    35 	{
       
    36 	CMbufGobblerTestServer * server = new (ELeave) CMbufGobblerTestServer();
       
    37 	CleanupStack::PushL(server);
       
    38 	
       
    39 	// Either use a StartL or ConstructL, the latter will permit
       
    40 	// Server Logging.
       
    41 
       
    42 	//server->StartL(KServerName); 
       
    43 	server->ConstructL(KServerName);	// from CTestBase
       
    44 	
       
    45 	CleanupStack::Pop(server);
       
    46 	return server;
       
    47 	}
       
    48 
       
    49 
       
    50 /*virtual*/ CMbufGobblerTestServer::~CMbufGobblerTestServer()
       
    51 	{
       
    52 	}
       
    53 
       
    54 
       
    55 // EKA2 much simpler
       
    56 // Just an E32Main and a MainL()
       
    57 LOCAL_C void MainL()
       
    58 /**
       
    59  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    60  */
       
    61 	{
       
    62 	// Leave the hooks in for platform security
       
    63 #if (defined __DATA_CAGING__)
       
    64 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    65 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    66 #endif
       
    67 	CActiveScheduler* sched=NULL;
       
    68 	sched=new(ELeave) CActiveScheduler;
       
    69 	CActiveScheduler::Install(sched);
       
    70 	CMbufGobblerTestServer* server = NULL;
       
    71 	// Create the CTestServer derived server
       
    72 	TRAPD(err,server = CMbufGobblerTestServer::NewL());
       
    73 	if (!err)
       
    74 		{
       
    75 		// Sync with the client and enter the active scheduler
       
    76 		RProcess::Rendezvous(KErrNone);
       
    77 		sched->Start();
       
    78 		}
       
    79 	delete server;
       
    80 	delete sched;
       
    81 	}
       
    82 
       
    83 // Only a DLL on emulator for typhoon and earlier
       
    84 
       
    85 GLDEF_C TInt E32Main()
       
    86 /**
       
    87  * @return - Standard Epoc error code on exit
       
    88  */
       
    89 	{
       
    90 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    91 	if (cleanup == NULL)
       
    92 		{
       
    93 		return KErrNoMemory;
       
    94 		}
       
    95 	TRAP_IGNORE(MainL());
       
    96 	delete cleanup;
       
    97 	return KErrNone;
       
    98     }
       
    99 
       
   100 // Create a thread in the calling process
       
   101 // Emulator typhoon and earlier
       
   102 
       
   103 CTestStep* CMbufGobblerTestServer::CreateTestStep(const TDesC& aStepName)
       
   104 /**
       
   105  * @return - A CTestStep derived instance
       
   106  * Implementation of CTestServer pure virtual
       
   107  */
       
   108 	{
       
   109 	CTestStep* testStep = NULL;
       
   110 
       
   111 	if (aStepName == KTestMbufGobblerStartupTest)
       
   112 		testStep = new CMbufGobblerStartupTest(this);
       
   113 //	else if (aStepName ==   (other step name)
       
   114 //		testStep = new  (other test step class)
       
   115 
       
   116 	return testStep;
       
   117 	}