os/boardsupport/haitest/bspsvs/suite/bsp/usb/src/t_e32server.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/usb/src/t_e32server.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,106 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +//	User Includes
    1.21 +#include "t_e32server.h"
    1.22 +#include "T_RDevUsbcClientData.h"
    1.23 +
    1.24 +/*@{*/
    1.25 +_LIT(KT_Connectivity,		"RDevUsbcClient");
    1.26 +/*@}*/
    1.27 +
    1.28 +
    1.29 +/**
    1.30 + * @return - Instance of the test server
    1.31 + * Same code for Secure and non-secure variants
    1.32 + * Called inside the MainL() function to create and start the
    1.33 + * CTestServer derived server.
    1.34 + */
    1.35 +CT_e32Server* CT_e32Server::NewL()
    1.36 +	{
    1.37 +    CT_e32Server* server = new (ELeave) CT_e32Server();
    1.38 +    CleanupStack::PushL(server);
    1.39 +    server->ConstructL();
    1.40 +    CleanupStack::Pop(server);
    1.41 +    return server;
    1.42 +    }
    1.43 +
    1.44 +
    1.45 +/**
    1.46 + * Secure variant
    1.47 + * Much simpler, uses the new Rendezvous() call to sync with the client
    1.48 + */
    1.49 +LOCAL_C void MainL()
    1.50 +	{
    1.51 +#if (defined __DATA_CAGING__)
    1.52 +    RProcess().DataCaging(RProcess::EDataCagingOn);
    1.53 +    RProcess().SecureApi(RProcess::ESecureApiOn);
    1.54 +#endif
    1.55 +    CActiveScheduler*	sched=NULL;
    1.56 +    sched=new(ELeave) CActiveScheduler;
    1.57 +    CActiveScheduler::Install(sched);
    1.58 +    CT_e32Server* server = NULL;
    1.59 +
    1.60 +    // Create the CTestServer derived server
    1.61 +    TRAPD(err,server = CT_e32Server::NewL());
    1.62 +    if(!err)
    1.63 +	    {
    1.64 +        // Sync with the client and enter the active scheduler
    1.65 +        RProcess::Rendezvous(KErrNone);
    1.66 +        sched->Start();
    1.67 +        }
    1.68 +
    1.69 +    delete server;
    1.70 +    delete sched;
    1.71 +    }
    1.72 +
    1.73 +
    1.74 +/**
    1.75 + * @return - Standard Epoc error code on process exit
    1.76 + * Secure variant only
    1.77 + * Process entry point. Called by client using RProcess API
    1.78 + */
    1.79 +GLDEF_C TInt E32Main()
    1.80 +	{
    1.81 +    __UHEAP_MARK;
    1.82 +    CTrapCleanup* cleanup = CTrapCleanup::New();
    1.83 +    if(cleanup == NULL)
    1.84 +	    {
    1.85 +        return KErrNoMemory;
    1.86 +        }
    1.87 +
    1.88 +#if (defined TRAP_IGNORE)
    1.89 +	TRAP_IGNORE(MainL());
    1.90 +#else
    1.91 +    TRAPD(err,MainL());
    1.92 +#endif
    1.93 +
    1.94 +    delete cleanup;
    1.95 +    __UHEAP_MARKEND;
    1.96 +    return KErrNone;
    1.97 +    }
    1.98 +
    1.99 +CDataWrapper* CT_e32Server::CT_e32Block::CreateDataL(const TDesC& aData)
   1.100 +	{
   1.101 +	CDataWrapper*	wrapper=NULL;
   1.102 +
   1.103 +	if( KT_Connectivity() == aData )
   1.104 +		{
   1.105 +		wrapper=CT_RDevUsbcClientData::NewL();
   1.106 +		}
   1.107 +
   1.108 +	return wrapper;
   1.109 +	}