serialserver/packetloopbackcsy/src/LoopbackTestServer.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-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 // TelephonyTestServer.cpp
       
    15 // for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to
       
    16 // be started in the process of the client. The client initialises the server
       
    17 // by calling the one and only ordinal.
       
    18 // 
       
    19 //
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include "LoopbackTestServer.h"
       
    26 
       
    27 #include "LoopbackTestStep.h"
       
    28 
       
    29 _LIT(KServerName,"TE_PacketLoopback");
       
    30 
       
    31 CLoopbackTestServer* CLoopbackTestServer::NewL()
       
    32 /**
       
    33  * @return - Instance of the test server
       
    34  * Called inside the MainL() function to create and start the
       
    35  * CTestServer derived server.
       
    36  */
       
    37 	{
       
    38 	// Instantiate server class here
       
    39 	CLoopbackTestServer * server = new (ELeave) CLoopbackTestServer();
       
    40 	CleanupStack::PushL(server);
       
    41 	// CServer base class call
       
    42 	server->StartL(KServerName);
       
    43 	CleanupStack::Pop(server);
       
    44 	return server;
       
    45 	}
       
    46 
       
    47 // EKA2 much simpler
       
    48 // Just an E32Main and a MainL()
       
    49 LOCAL_C void MainL()
       
    50 /**
       
    51  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    52  */
       
    53 	{
       
    54 	CActiveScheduler* sched=NULL;
       
    55 	sched=new(ELeave) CActiveScheduler;
       
    56 	CActiveScheduler::Install(sched);
       
    57 
       
    58 	CLoopbackTestServer* server = NULL;
       
    59 	// Create the CTestServer derived server
       
    60 	TRAPD(err,server = CLoopbackTestServer::NewL());
       
    61 	if(!err)
       
    62 		{
       
    63 		// Sync with the client and enter the active scheduler
       
    64 		RProcess::Rendezvous(KErrNone);
       
    65 		sched->Start();
       
    66 		}
       
    67 	delete server;
       
    68 	delete sched;
       
    69 	}
       
    70 
       
    71 // Only a DLL on emulator for typhoon and earlier
       
    72 
       
    73 GLDEF_C TInt E32Main()
       
    74 /**
       
    75  * @return - Standard Epoc error code on exit
       
    76  */
       
    77 	{
       
    78 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    79 	if(cleanup == NULL)
       
    80 		{
       
    81 		return KErrNoMemory;
       
    82 		}
       
    83 	TRAPD(err,MainL());
       
    84 	delete cleanup;
       
    85 	return err;
       
    86 	}
       
    87 
       
    88 // Create a thread in the calling process
       
    89 // Emulator typhoon and earlier
       
    90 
       
    91 CTestStep* CLoopbackTestServer::CreateTestStep(const TDesC& aStepName)
       
    92 /**
       
    93  * @return - A CTestStep derived instance
       
    94  * Implementation of CTestServer pure virtual
       
    95  */
       
    96 	{
       
    97 	CTestStep* testStep = NULL;
       
    98 	TRAPD
       
    99 		(err,
       
   100 
       
   101 		if(aStepName == KLoopbackTestStep1)
       
   102 			testStep = new(ELeave) CLoopbackTestStep1();
       
   103 		if(aStepName == KLoopbackTestStep2)
       
   104 			testStep = new(ELeave) CLoopbackTestStep2();
       
   105 		if(aStepName == KLoopbackTestStep3)
       
   106 			testStep = new(ELeave) CLoopbackTestStep3();
       
   107 		if(aStepName == KLoopbackTestStep4)
       
   108 			testStep = new(ELeave) CLoopbackTestStep4();
       
   109 		if(aStepName == KLoopbackTestStep5)
       
   110 			testStep = new(ELeave) CLoopbackTestStep5();
       
   111 		if(aStepName == KLoopbackTestStep6)
       
   112 			testStep = new(ELeave) CLoopbackTestStep6();
       
   113 		if(aStepName == KLoopbackTestStep7)
       
   114 			testStep = new(ELeave) CLoopbackTestStep7();
       
   115 		if(aStepName == KLoopbackTestStep8)
       
   116 			testStep = new(ELeave) CLoopbackTestStep8();
       
   117 		if(aStepName == KLoopbackTestStep9)
       
   118 			testStep = new(ELeave) CLoopbackTestStep9();
       
   119 		if(aStepName == KLoopbackTestStep10)
       
   120 			testStep = new(ELeave) CLoopbackTestStep10();
       
   121 		if(aStepName == KLoopbackTestStep11)
       
   122 			testStep = new(ELeave) CLoopbackTestStep11();
       
   123 		if(aStepName == KLoopbackTestStep12)
       
   124 			testStep = new(ELeave) CLoopbackTestStep12();
       
   125 		if(aStepName == KLoopbackTestStep13)
       
   126 			testStep = new(ELeave) CLoopbackTestStep13();
       
   127 		
       
   128 		);
       
   129 	err = err; 		// fix compiler warning about unused variable
       
   130 	return testStep;
       
   131 	}
       
   132 
       
   133