common/tools/ats/smoketest/lbs/internal/lbstestserver/src/csecureasbase.cpp
changeset 748 e13acd883fbe
child 872 17498133d9ad
equal deleted inserted replaced
747:76f9aaeefbab 748:e13acd883fbe
       
     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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32debug.h>
       
    17 #include <lbsmemlogger.h>
       
    18 #include "lbsdevloggermacros.h"
       
    19 #include "csecureasbase.h"
       
    20 #include "tserverstartparams.h"
       
    21 
       
    22 /** 
       
    23 Default constructor
       
    24 
       
    25 @internalTechnology
       
    26 @released
       
    27  */	
       
    28 CSecureASBase::CSecureASBase()
       
    29 	{
       
    30 	}
       
    31 	
       
    32 /** 
       
    33 The main sever entry point with sever start parameters, create the cleanup stack
       
    34 
       
    35 @param aParams A reference to TServerStartParams object
       
    36 @see TServerStartParams
       
    37 @return Symbian Standard Error code
       
    38 @internalTechnology
       
    39 @released
       
    40  */	
       
    41 TInt CSecureASBase::ServerMain(TServerStartParams& aParams)
       
    42 	{
       
    43 	// called from the server process from E32Main
       
    44 	__UHEAP_MARK;
       
    45 	//
       
    46 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    47 	TInt r=KErrNoMemory;
       
    48 	if (cleanup)
       
    49 		{
       
    50 		TRAP(r,RunServerL(aParams));
       
    51 		delete cleanup;
       
    52 		}
       
    53 	//
       
    54 	__UHEAP_MARKEND;
       
    55 	return r;
       
    56 
       
    57 	} 	
       
    58 
       
    59 /** 
       
    60 start sever with parameters, create ActiveScheduler and install it
       
    61 create a server implementation and signal the client when initialisation completes
       
    62 start the AS object and wait to destroy.
       
    63 
       
    64 @param aParams A reference to TServerStartParams object
       
    65 @see TServerStartParams
       
    66 @return Symbian Standard Error code
       
    67 @internalTechnology
       
    68 @released
       
    69  */	
       
    70 TInt CSecureASBase::RunServerL(TServerStartParams& aParams)
       
    71 	{
       
    72 	LBSLOG(ELogP3, "->CSecureASBase::RunServerL");
       
    73 		
       
    74 	// first check that we are about to create the right type of server
       
    75 	if(aParams.GetType() != KServerStartParamsTypeUid)
       
    76 		{
       
    77 		// this is not a process type that we understand. Has the caller
       
    78 		// pass TProcessStartParams by mistake?
       
    79 		User::Leave(KErrArgument); // this aborts the server startup
       
    80 		}
       
    81 	User::LeaveIfError(User::RenameThread(aParams.GetServerName()));
       
    82 	//
       
    83 	// create and install the active scheduler we need
       
    84 	CSecureASBase* s = new (ELeave) CSecureASBase();
       
    85 	CleanupStack::PushL(s);
       
    86 	CActiveScheduler::Install(s);
       
    87 	
       
    88 	LBSMEMLOG_BEGIN();
       
    89 	
       
    90 	// test with the impl  
       
    91 	MCreateServerImpl* impl = s->GetImplLC();	
       
    92 	//
       
    93 	// create the server (leave it on the cleanup stack)
       
    94 	impl->CreateServerLC(aParams);
       
    95 	//
       
    96 	// Initialisation complete, now signal the client
       
    97 	RProcess().Rendezvous(KErrNone);
       
    98 	//
       
    99 	// Ready to run
       
   100 	LBSLOG(ELogP3, "Calling CActiveScheduler::Start");
       
   101 	CActiveScheduler::Start();
       
   102 	//
       
   103 	// Cleanup the impl, server and scheduler. Impl is destroyed via ~CBase not the M class 
       
   104 	LBSLOG(ELogP3, "Calling CleanupStack::PopAndDestroy(3)");
       
   105 
       
   106 	CleanupStack::PopAndDestroy(3);
       
   107 	
       
   108 	LBSLOG(ELogP3, "<-CSecureASBase::RunServerL");
       
   109 
       
   110 	LBSMEMLOG_END();
       
   111 
       
   112 	return KErrNone;
       
   113 	}
       
   114 
       
   115 
       
   116 /** 
       
   117 Panic the server with CSecureASBase category
       
   118 
       
   119 @param aPanic Reason to painc
       
   120 @see TSecureASBasePanic 
       
   121 @internalTechnology
       
   122 @released
       
   123  */	
       
   124 void CSecureASBase::Panic(const TSecureASBasePanic aPanic)
       
   125 	{
       
   126 	_LIT(KSecureAsBase, "CSecureASBase");
       
   127 	User::Panic(KSecureAsBase, aPanic);
       
   128 	}
       
   129 	
       
   130 
       
   131