syslibsapitest/syslibssvs/ecom/src/T_ECOMServer.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "T_ECOMServer.h"
       
    20 
       
    21 /*@{*/
       
    22 /*@}*/
       
    23 
       
    24 
       
    25 CT_ECOMServer* CT_ECOMServer::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 	CT_ECOMServer* server = new (ELeave) CT_ECOMServer();
       
    34 	CleanupStack::PushL(server);
       
    35 	server->ConstructL();
       
    36 	CleanupStack::Pop(server);
       
    37 	return server;
       
    38 	}
       
    39 
       
    40 LOCAL_C void MainL()
       
    41 /**
       
    42  * Secure variant
       
    43  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    44  */
       
    45 	{
       
    46 #if (defined __DATA_CAGING__)
       
    47 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    48 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    49 #endif
       
    50 	CActiveScheduler* sched=NULL;
       
    51 	sched=new(ELeave) CActiveScheduler;
       
    52 	CActiveScheduler::Install(sched);
       
    53 	CT_ECOMServer* server = NULL;
       
    54 	TRAPD(err, server = CT_ECOMServer::NewL());
       
    55 	if(!err)
       
    56 		{
       
    57 		RProcess::Rendezvous(KErrNone);
       
    58 		sched->Start();
       
    59 		}
       
    60 	delete server;
       
    61 	delete sched;
       
    62 	}
       
    63 
       
    64 GLDEF_C TInt E32Main()
       
    65 /**
       
    66  * @return - Standard Epoc error code on process exit
       
    67  * Secure variant only
       
    68  * Process entry point. Called by client using RProcess API
       
    69  */
       
    70 	{
       
    71 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    72 	if(cleanup == NULL)
       
    73 		{
       
    74 		return KErrNoMemory;
       
    75 		}
       
    76 	TRAP_IGNORE(MainL());
       
    77 	delete cleanup;
       
    78 	return KErrNone;
       
    79     }