smsprotocols/smsstack/test/TE_SMSPDUDB/TE_smspdudbserver.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2003-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 // @file
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "TE_smspdudbserver.h"
       
    19 #include "TE_testsmspdudb.h"
       
    20 
       
    21 
       
    22 _LIT(KServerName,"TE_SMSPDUDB");
       
    23 
       
    24 
       
    25 CSmsPduDbTestServer* CSmsPduDbTestServer::NewL()
       
    26 /**
       
    27  *  @return - Instance of the test server
       
    28  *  Same code for Secure and non-secure variants
       
    29  *  Called inside the MainL() function to create and start the
       
    30  *  CTestServer derived server.
       
    31  */
       
    32 	{
       
    33 	CSmsPduDbTestServer * server = new (ELeave) CSmsPduDbTestServer();
       
    34 	CleanupStack::PushL(server);
       
    35 	// CServer base class call
       
    36 	server->StartL(KServerName);
       
    37 	CleanupStack::Pop(server);
       
    38 	return server;
       
    39 	}
       
    40 
       
    41 LOCAL_C void MainL()
       
    42 /**
       
    43  *  Much simpler, uses the new Rendezvous() call to sync with the client
       
    44  */
       
    45 	{
       
    46 	CActiveScheduler* sched=NULL;
       
    47 	sched=new(ELeave) CActiveScheduler;
       
    48 	CActiveScheduler::Install(sched);
       
    49 	CSmsPduDbTestServer* server = NULL;
       
    50 	// Create the CTestServer derived server
       
    51 	TRAPD(err,server = CSmsPduDbTestServer::NewL());
       
    52 	if(!err)
       
    53 		{
       
    54 		// Sync with the client and enter the active scheduler
       
    55 		RProcess::Rendezvous(KErrNone);
       
    56 		sched->Start();
       
    57 		}
       
    58 	delete server;
       
    59 	delete sched;
       
    60 	}
       
    61 
       
    62 GLDEF_C TInt E32Main()
       
    63 /**
       
    64  *  @return - Standard Epoc error code on exit
       
    65  */
       
    66 	{
       
    67 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    68 	if(cleanup == NULL)
       
    69 		{
       
    70 		return KErrNoMemory;
       
    71 		}
       
    72 	TRAPD(err,MainL());
       
    73 	delete cleanup;
       
    74 
       
    75 	return err;
       
    76     }
       
    77 
       
    78 CTestStep* CSmsPduDbTestServer::CreateTestStep(const TDesC& aStepName)
       
    79 /**
       
    80  *  @return - A CTestStep derived instance
       
    81  *  Secure and non-secure variants
       
    82  *  Implementation of CTestServer pure virtual
       
    83  */
       
    84 	{
       
    85 	CTestStep*  testStep = NULL;
       
    86 
       
    87 	//
       
    88 	// Here the test step is created when it is needed. Note that this
       
    89 	// function is non-leaving so we cannot use new(ELeave). Therefore
       
    90 	// the new could return NULL, but that is not a problem as it implies
       
    91 	// the test step is missing and this will be marked in the log file.
       
    92 	//
       
    93 	if(aStepName == _L("TestSmsPduDbMessage"))
       
    94 		{
       
    95 		testStep = new CTestSmsPduDbMessage ;
       
    96 		}
       
    97 	else if (aStepName == _L("TestSmsPduDbPdu"))
       
    98 		{
       
    99 		testStep = new CTestSmsPduDbPdu ;
       
   100 		}
       
   101 	else if (aStepName == _L("TestSmsPduDbConcatSegment"))
       
   102 		{
       
   103 		testStep = new CTestSmsPduDbConcatSegment ;
       
   104 		}
       
   105 	else if (aStepName == _L("TestSmsPduDbConcat"))
       
   106 		{
       
   107 		testStep = new CTestSmsPduDbConcat ;
       
   108 		}
       
   109 	else if (aStepName == _L("TestSmsPduDbParse"))
       
   110 		{
       
   111 		testStep = new CTestSmsPduDbParse ;
       
   112 		}
       
   113 	else if (aStepName == _L("TestSmsPduDbCompile"))
       
   114 		{
       
   115 		testStep = new CTestSmsPduDbCompile ;
       
   116 		}
       
   117 	else if (aStepName == _L("TestSmsPduDbTools"))
       
   118 		{
       
   119 		testStep = new CTestSmsPduDbTools ;
       
   120 		}
       
   121 	else if (aStepName == _L("TestSmsServiceCenterTimeStamp"))
       
   122 		{
       
   123 		testStep = new CTestSmsServiceCenterTimeStamp;
       
   124 		}
       
   125 	else if(aStepName == _L("TestSmsValidityPeriod"))
       
   126 		{
       
   127 		testStep = new CTestSmsValidityPeriod;
       
   128 		}
       
   129 
       
   130 	//
       
   131 	// Set the test step name here to save code!!!
       
   132 	//
       
   133 	if (testStep != NULL)
       
   134 		{
       
   135 		testStep->SetTestStepName(aStepName);
       
   136 		}
       
   137 	
       
   138 	return testStep;
       
   139 	}