telephonyserverplugins/simtsy/test/te_simeap/te_simeaptestserver.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #include "te_simeaptestserver.h"
       
    21 #include "te_simeap.h"
       
    22 
       
    23 _LIT(KServerName, "te_simeap");
       
    24 
       
    25 /**
       
    26 Same code for Secure and non-secure variants
       
    27 Called inside the MainL() function to create and start the
       
    28 CTestServer derived server.
       
    29 
       
    30 @return Instance of the test server
       
    31 */
       
    32 CSimEapTestServer* CSimEapTestServer::NewL()
       
    33 	{
       
    34 	CSimEapTestServer * testServer = new(ELeave) CSimEapTestServer();
       
    35 	CleanupStack::PushL(testServer);
       
    36 	testServer->ConstructL(KServerName);
       
    37 	CleanupStack::Pop(testServer);
       
    38 	return testServer;
       
    39 	}
       
    40 
       
    41 /**
       
    42 Secure variant.
       
    43 Much simpler, uses the new Rendezvous() call to sync with the client.
       
    44 */
       
    45 LOCAL_C void MainL()
       
    46 	{
       
    47 	TInt result = StartC32();
       
    48 	if (result != KErrNone  &&  result != KErrAlreadyExists)
       
    49 		{
       
    50 		User::Leave(result);
       
    51 		}
       
    52 
       
    53 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    54 	CActiveScheduler::Install(sched);
       
    55 
       
    56 	// Create the CTestServer derived server
       
    57 	CSimEapTestServer* testServer = NULL;
       
    58 	TRAPD(err, testServer = CSimEapTestServer::NewL());
       
    59 	if(err == KErrNone)
       
    60 		{
       
    61 		// Sync with the client and enter the active scheduler
       
    62 		RProcess::Rendezvous(KErrNone);
       
    63 		sched->Start();
       
    64 		}
       
    65 	delete testServer;
       
    66 	delete sched;
       
    67 	}
       
    68 
       
    69 /**
       
    70 Secure variant only.
       
    71 Process entry point.  Called by client using RProcess API.
       
    72 
       
    73 @return System-wide error code on process exit.
       
    74 */
       
    75 GLDEF_C TInt E32Main()
       
    76 	{
       
    77 	__UHEAP_MARK;
       
    78 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    79 	if(cleanup == NULL)
       
    80 		{
       
    81 		return KErrNoMemory;
       
    82 		}
       
    83 
       
    84 	TRAPD(err,MainL());
       
    85 	delete cleanup;
       
    86 	__UHEAP_MARKEND;
       
    87 	return err;
       
    88 	}
       
    89 
       
    90 /**
       
    91 Implementation of CTestServer pure virtual.
       
    92 
       
    93 @return A CTestStep derived instance.
       
    94 */
       
    95 CTestStep* CSimEapTestServer::CreateTestStep(const TDesC& aStepName)
       
    96 	{
       
    97 	CSimEapTestStepBase* testStep = NULL;
       
    98 
       
    99 	if(aStepName == _L("TestSmartCardEap"))
       
   100 		{
       
   101 		testStep = new CTestSmartCardEap();
       
   102  		}
       
   103 	else if(aStepName == _L("TestSmartCardAppAuthenticate"))
       
   104 		{
       
   105 		testStep = new CTestSmartCardAppAuthenticate();
       
   106  		}
       
   107 	else if(aStepName == _L("TestGetSmartCardAppEapList"))
       
   108 		{
       
   109 		testStep = new CTestGetSmartCardAppEapList();
       
   110  		}
       
   111  	else if(aStepName == _L("TestSmartCardBasedEapBadClient"))
       
   112  		{
       
   113  		testStep = new CTestInitEapWithoutClosing();
       
   114  		}
       
   115  	else if(aStepName == _L("TestSmartCardAppAuthenticate2"))
       
   116  		{
       
   117  		testStep = new CTestSmartCardAppAuthenticate2();
       
   118  		}
       
   119 
       
   120 	return testStep;
       
   121 	}