haitest/bspsvs/suite/bsp/keypad/src/T_KeypadDriverServer.cpp
changeset 0 cec860690d41
equal deleted inserted replaced
-1:000000000000 0:cec860690d41
       
     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 #include "T_KeypadDriverServer.h"
       
    19 #include "T_KeypadDriverData.h"
       
    20 
       
    21 /*@{*/
       
    22 _LIT(KT_KeypadDriver,		"Keypad");
       
    23 /*@}*/
       
    24 
       
    25 CT_KeypadDriverServer* CT_KeypadDriverServer::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_KeypadDriverServer* server = new (ELeave) CT_KeypadDriverServer();
       
    34     CleanupStack::PushL(server);
       
    35     server->ConstructL();
       
    36     CleanupStack::Pop(server);
       
    37     return server;
       
    38     }
       
    39 
       
    40 
       
    41 LOCAL_C void MainL()
       
    42 /**
       
    43  * Secure variant
       
    44  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    45  */
       
    46 	{
       
    47 #if (defined __DATA_CAGING__)
       
    48     RProcess().DataCaging(RProcess::EDataCagingOn);
       
    49     RProcess().SecureApi(RProcess::ESecureApiOn);
       
    50 #endif
       
    51     CActiveScheduler*	sched=NULL;
       
    52     sched=new(ELeave) CActiveScheduler;
       
    53     CActiveScheduler::Install(sched);
       
    54     CT_KeypadDriverServer* server = NULL;
       
    55 
       
    56     // Create the CTestServer derived server
       
    57     TRAPD(err,server = CT_KeypadDriverServer::NewL());
       
    58     if(!err)
       
    59 	    {
       
    60         // Sync with the client and enter the active scheduler
       
    61         RProcess::Rendezvous(KErrNone);
       
    62         sched->Start();
       
    63         }
       
    64 
       
    65     delete server;
       
    66     delete sched;
       
    67     }
       
    68 
       
    69 
       
    70 GLDEF_C TInt E32Main()
       
    71 /**
       
    72  * @return - Standard Epoc error code on process exit
       
    73  * Secure variant only
       
    74  * Process entry point. Called by client using RProcess API
       
    75  */
       
    76 	{
       
    77     __UHEAP_MARK;
       
    78     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    79     if(cleanup == NULL)
       
    80 	    {
       
    81         return KErrNoMemory;
       
    82         }
       
    83 
       
    84 #if (defined TRAP_IGNORE)
       
    85 	TRAP_IGNORE(MainL());
       
    86 #else
       
    87     TRAPD(err,MainL());
       
    88 #endif
       
    89 
       
    90     delete cleanup;
       
    91     __UHEAP_MARKEND;
       
    92     return KErrNone;
       
    93     }
       
    94 
       
    95 CDataWrapper* CT_KeypadDriverServer::CT_KeypadDriverBlock::CreateDataL(const TDesC& aData)
       
    96 	{
       
    97 	CDataWrapper*	wrapper=NULL;
       
    98 
       
    99 	if( KT_KeypadDriver() == aData )
       
   100 		{
       
   101 		wrapper=CT_KeypadDriverData::NewL();
       
   102 		}
       
   103 
       
   104 	return wrapper;
       
   105 	}