telephonyserverplugins/simtsy/test/Te_SimMisc/Te_SimMiscTestServer.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-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 #include "Te_SimMiscTestServer.h"
       
    17 #include "Te_SimMisc.h"
       
    18 
       
    19 _LIT(KServerName,"Te_SimMisc");
       
    20 
       
    21 CSimMiscTestServer* CSimMiscTestServer::NewL()
       
    22 /**
       
    23  * @return - Instance of the test server
       
    24  * Same code for Secure and non-secure variants
       
    25  * Called inside the MainL() function to create and start the
       
    26  * CTestServer derived server.
       
    27  */
       
    28 	{
       
    29 	CSimMiscTestServer * testServer = new (ELeave) CSimMiscTestServer();
       
    30 	CleanupStack::PushL(testServer);
       
    31 
       
    32 	testServer->ConstructL(KServerName);
       
    33 	CleanupStack::Pop(testServer);
       
    34 	return testServer;
       
    35 	}
       
    36 
       
    37 LOCAL_C void MainL()
       
    38 /**
       
    39  * Secure variant
       
    40  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    41  */
       
    42 	{
       
    43    	TInt result = StartC32();
       
    44 	if (result != KErrNone  &&  result != KErrAlreadyExists)
       
    45 		{
       
    46 		User::Leave(result);
       
    47 		}
       
    48 
       
    49 	CActiveScheduler* sched=NULL;
       
    50 	sched=new(ELeave) CActiveScheduler;
       
    51 	CActiveScheduler::Install(sched);
       
    52 
       
    53 	
       
    54 	// Create the CTestServer derived server
       
    55 	CSimMiscTestServer* testServer = NULL;
       
    56 	TRAPD(err,testServer = CSimMiscTestServer::NewL());
       
    57 	if(!err)
       
    58 		{
       
    59 		// Sync with the client and enter the active scheduler
       
    60 		RProcess::Rendezvous(KErrNone);
       
    61 		sched->Start();
       
    62 		}
       
    63 	delete testServer;
       
    64 	delete sched;
       
    65 	}
       
    66 
       
    67 GLDEF_C TInt E32Main()
       
    68 /**
       
    69  * @return - Standard Epoc error code on process exit
       
    70  * Secure variant only
       
    71  * Process entry point. Called by client using RProcess API
       
    72  */
       
    73 	{
       
    74 	__UHEAP_MARK;
       
    75 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    76 	if(cleanup == NULL)
       
    77 		{
       
    78 		return KErrNoMemory;
       
    79 		}
       
    80 	TRAPD(err,MainL());
       
    81 	delete cleanup;
       
    82 	__UHEAP_MARKEND;
       
    83 	return err;
       
    84     }
       
    85 
       
    86 CTestStep* CSimMiscTestServer::CreateTestStep(const TDesC& aStepName)
       
    87 /**
       
    88  * @return - A CTestStep derived instance
       
    89  * Secure and non-secure variants
       
    90  * Implementation of CTestServer pure virtual
       
    91  */
       
    92 	{
       
    93 	CTestStep* testStep = NULL;
       
    94 
       
    95 	if(aStepName == _L("PubSubMode"))
       
    96 		{
       
    97 		testStep = new CPubSubMode();
       
    98 		}
       
    99 	else if(aStepName == _L("SignalAndBatteryStrengthTest"))
       
   100 		{
       
   101 		testStep = new CSignalAndBatteryStrengthTest();
       
   102 		}
       
   103 	else if(aStepName == _L("SubscriberIdTest"))
       
   104 		{
       
   105 		testStep = new CSubscriberIdTest();
       
   106 		}
       
   107 	else if(aStepName == _L("PhoneStoreTest"))
       
   108 		{
       
   109 		testStep = new CPhoneStoreTest();
       
   110 		}
       
   111 	else if(aStepName == _L("GetCaps"))
       
   112 		{
       
   113 		testStep = new CGetCaps();
       
   114 		}
       
   115 	else if(aStepName == _L("GetLinesStatus"))
       
   116 		{
       
   117 		testStep = new CGetLinesStatus();
       
   118 		}
       
   119 	else if(aStepName == _L("GetMultimodeCaps"))
       
   120 		{
       
   121 		testStep = new CGetMultimodeCaps();
       
   122 		}
       
   123 	else if(aStepName == _L("GetNetworkCaps"))
       
   124 		{
       
   125 		testStep = new CGetNetworkCaps();
       
   126 		}
       
   127 	else if(aStepName == _L("GetCurrentMode"))
       
   128 		{
       
   129 		testStep = new CGetCurrentMode();
       
   130 		}
       
   131 	else if(aStepName == _L("GetPhoneIdAndCaps"))
       
   132 		{
       
   133 		testStep = new CGetPhoneId();
       
   134 		}
       
   135 
       
   136 	return testStep;
       
   137 	}
       
   138 
       
   139 
       
   140 
       
   141