sysstatemgmt/systemstatereferenceplugins/test/tintcustcmd/src/tcustomcmd_server.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include "tcustomcmd_server.h"
       
    23 #include "tcustcmd_step_simsecuritypincheck.h"
       
    24 #include "tcustcmd_step_activateemergencycall.h"
       
    25 #include "tcustcmd_step_deactivateemergencycall.h"
       
    26 #include "tcustcmd_step_devicesecuritypincheck.h"
       
    27 #include "tcustcmd_step_int_execute.h"
       
    28 #include "ssmdebug.h"
       
    29 
       
    30 _LIT(KCustomCmdTestServerName, "tcustomcmd_server");
       
    31 
       
    32 CCmdTestServer* CCmdTestServer::NewLC( )
       
    33 	{
       
    34 	CCmdTestServer * server = new (ELeave) CCmdTestServer();
       
    35 	CleanupStack::PushL(server);
       
    36 	TParsePtrC serverName(RProcess().FileName());
       
    37 	server->StartL(serverName.Name());
       
    38 	return server;
       
    39 	}
       
    40 
       
    41 static void MainL()
       
    42 	{
       
    43 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    44 	CleanupStack::PushL (sched);
       
    45 	CActiveScheduler::Install (sched);
       
    46 
       
    47 	CCmdTestServer* server = CCmdTestServer::NewLC( );
       
    48 	RProcess::Rendezvous (KErrNone );
       
    49 	sched->Start( );
       
    50 
       
    51 	CleanupStack::PopAndDestroy (server );
       
    52 	CleanupStack::PopAndDestroy (sched );
       
    53 	}
       
    54 
       
    55 /**
       
    56  Process entry point. Called by client using RProcess API
       
    57  @return - Standard Epoc error code on process exit
       
    58  */
       
    59 TInt E32Main(void)
       
    60 	{
       
    61 	__UHEAP_MARK;
       
    62 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    63 	if(cleanup == NULL)
       
    64 		{
       
    65 		return KErrNoMemory;
       
    66 		}
       
    67 
       
    68 	TRAPD(err,MainL());
       
    69 	if (err)
       
    70 		{
       
    71 		DEBUGPRINT2(_L("CustCmdTestServer::MainL - Error: %d"), err);
       
    72 	   	SSMLOGLEAVE(err);
       
    73 		}
       
    74 	delete cleanup;
       
    75 
       
    76 	__UHEAP_MARKEND;
       
    77 	return KErrNone;
       
    78 	}
       
    79 
       
    80 /**
       
    81  @return - A CTestStep derived instance
       
    82  */
       
    83 CTestStep* CCmdTestServer::CreateTestStep(const TDesC& aStepName)
       
    84 	{
       
    85 	CTestStep* testStep = NULL;
       
    86 
       
    87 	if (aStepName == KTCCustomCmdTestSecurityPinCheck)
       
    88 		{
       
    89 		testStep = new CCustomCmdTestSecurityPinCheck();
       
    90 		}
       
    91 	else if (aStepName == KTCCustomCmdTestDeviceSecurityPinCheck)
       
    92 		{
       
    93 		testStep = new CCustomCmdTestDeviceSecurityPinCheck();
       
    94 		}	
       
    95 	else if (aStepName == KTCCustomCmdTestActivateEmergencyCall)
       
    96 		{
       
    97 		testStep = new CCustomCmdTestActivateEmergencyCall();
       
    98 		}
       
    99 	else if (aStepName == KTCCustomCmdTestDeActivateEmergencyCall)
       
   100 		{
       
   101 		testStep = new CCustomCmdTestDeActivateEmergencyCall();
       
   102 		}
       
   103 	else if (aStepName == KTestExecuteCustCmd)
       
   104 		{
       
   105 		testStep = new CTestExecuteCustCmd();
       
   106 		}		
       
   107 		
       
   108 	else 
       
   109 		{
       
   110 		DEBUGPRINT2(_L("Unknown CmdTest step %S"), &aStepName);
       
   111 	   	User::Panic(KCustomCmdTestServerName, KErrArgument);
       
   112 		}
       
   113 
       
   114 	return testStep;
       
   115 	}
       
   116