os/boardsupport/haitest/bspsvs/suite/bsp/usb/src/t_e32server.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 //	User Includes
    18 #include "t_e32server.h"
    19 #include "T_RDevUsbcClientData.h"
    20 
    21 /*@{*/
    22 _LIT(KT_Connectivity,		"RDevUsbcClient");
    23 /*@}*/
    24 
    25 
    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 CT_e32Server* CT_e32Server::NewL()
    33 	{
    34     CT_e32Server* server = new (ELeave) CT_e32Server();
    35     CleanupStack::PushL(server);
    36     server->ConstructL();
    37     CleanupStack::Pop(server);
    38     return server;
    39     }
    40 
    41 
    42 /**
    43  * Secure variant
    44  * Much simpler, uses the new Rendezvous() call to sync with the client
    45  */
    46 LOCAL_C void MainL()
    47 	{
    48 #if (defined __DATA_CAGING__)
    49     RProcess().DataCaging(RProcess::EDataCagingOn);
    50     RProcess().SecureApi(RProcess::ESecureApiOn);
    51 #endif
    52     CActiveScheduler*	sched=NULL;
    53     sched=new(ELeave) CActiveScheduler;
    54     CActiveScheduler::Install(sched);
    55     CT_e32Server* server = NULL;
    56 
    57     // Create the CTestServer derived server
    58     TRAPD(err,server = CT_e32Server::NewL());
    59     if(!err)
    60 	    {
    61         // Sync with the client and enter the active scheduler
    62         RProcess::Rendezvous(KErrNone);
    63         sched->Start();
    64         }
    65 
    66     delete server;
    67     delete sched;
    68     }
    69 
    70 
    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 GLDEF_C TInt E32Main()
    77 	{
    78     __UHEAP_MARK;
    79     CTrapCleanup* cleanup = CTrapCleanup::New();
    80     if(cleanup == NULL)
    81 	    {
    82         return KErrNoMemory;
    83         }
    84 
    85 #if (defined TRAP_IGNORE)
    86 	TRAP_IGNORE(MainL());
    87 #else
    88     TRAPD(err,MainL());
    89 #endif
    90 
    91     delete cleanup;
    92     __UHEAP_MARKEND;
    93     return KErrNone;
    94     }
    95 
    96 CDataWrapper* CT_e32Server::CT_e32Block::CreateDataL(const TDesC& aData)
    97 	{
    98 	CDataWrapper*	wrapper=NULL;
    99 
   100 	if( KT_Connectivity() == aData )
   101 		{
   102 		wrapper=CT_RDevUsbcClientData::NewL();
   103 		}
   104 
   105 	return wrapper;
   106 	}