wlanapitest/wlanhaitest/wlan/src/T_WlanDriverServer.cpp
branchRCL_3
changeset 42 a828660c511c
parent 40 5fb7af913dfd
child 43 d3d7683d16f5
equal deleted inserted replaced
40:5fb7af913dfd 42:a828660c511c
     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 
       
    20 #include "t_wlandriverserver.h"
       
    21 #include "t_wlanmgmtclientdata.h"
       
    22 #include "t_wlanscaninfodata.h"
       
    23 #include "t_rsocketservdata.h"
       
    24 #include "t_ccommsdatabasedata.h"
       
    25 #include "t_ccommsdbtableviewdata.h"
       
    26 #include "t_rconnectiondata.h"
       
    27 #include "t_rfiledata.h"
       
    28 #include "t_rsocketdata.h"
       
    29 
       
    30 
       
    31 /*@{*/
       
    32 _LIT(KT_WlanMgmtClient, 		"WlanMgmtClient");
       
    33 _LIT(KT_WlanScanInfo,			"WlanScanInfo");
       
    34 _LIT(KT_WlanSocketServ,			"RSocketServ");
       
    35 _LIT(KT_CCommsDB,				"CCommsDatabase");
       
    36 _LIT(KT_CCommsDBTable,			"CCommsDbTableView");
       
    37 _LIT(KT_RConnection,			"RConnection");
       
    38 _LIT(KT_RSocket,				"RSocket");
       
    39 _LIT(KT_RFile,				    "RFile");
       
    40 /*@}*/
       
    41 
       
    42 
       
    43 /**
       
    44  * 
       
    45  * Same code for Secure and non-secure variants
       
    46  * Called inside the MainL() function to create and start the
       
    47  * CTestServer derived server.
       
    48  * @return - Instance of the test server
       
    49  */
       
    50 CT_WlanDriverServer* CT_WlanDriverServer::NewL()
       
    51 	{
       
    52     CT_WlanDriverServer* server = new (ELeave) CT_WlanDriverServer();
       
    53     CleanupStack::PushL(server);
       
    54     server->ConstructL();
       
    55     CleanupStack::Pop(server);
       
    56     return server;
       
    57     }
       
    58 
       
    59 /**
       
    60  * Secure variant
       
    61  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    62  */
       
    63 LOCAL_C void MainL()
       
    64 	{
       
    65 #if (defined __DATA_CAGING__)
       
    66     RProcess().DataCaging(RProcess::EDataCagingOn);
       
    67     RProcess().SecureApi(RProcess::ESecureApiOn);
       
    68 #endif
       
    69     CActiveScheduler* sched = NULL;
       
    70     sched = new(ELeave) CActiveScheduler;
       
    71     CActiveScheduler::Install(sched);
       
    72     CT_WlanDriverServer* server = NULL;
       
    73 
       
    74     // Create the CTestServer derived server
       
    75     TRAPD(err, server = CT_WlanDriverServer::NewL());
       
    76     if(!err)
       
    77 	    {
       
    78         // Sync with the client and enter the active scheduler
       
    79         RProcess::Rendezvous(KErrNone);
       
    80         sched->Start();
       
    81         }
       
    82 
       
    83     delete server;
       
    84     delete sched;
       
    85     }
       
    86 
       
    87 /**
       
    88  * 
       
    89  * Secure variant only
       
    90  * Process entry point. Called by client using RProcess API
       
    91  * @return - Standard Epoc error code on process exit
       
    92  */
       
    93 GLDEF_C TInt E32Main()
       
    94 	{
       
    95     __UHEAP_MARK;
       
    96     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    97     if(cleanup == NULL)
       
    98 	    {
       
    99         return KErrNoMemory;
       
   100         }
       
   101 
       
   102 #if (defined TRAP_IGNORE)
       
   103 	TRAP_IGNORE(MainL());
       
   104 #else
       
   105     TRAPD(err,MainL());
       
   106 #endif
       
   107 
       
   108     delete cleanup;
       
   109     __UHEAP_MARKEND;
       
   110     return KErrNone;
       
   111     }
       
   112 /*
       
   113  * Creates an instance of CDataWrapper that wraps a CT_WlanDriverData object 
       
   114  * @return wrapper	- a CDataWrapper instance that wraps the CT_WlanDriverData object
       
   115  */
       
   116 CDataWrapper* CT_WlanDriverServer::CT_WlanDriverBlock::CreateDataL(const TDesC& aData)
       
   117 	{
       
   118 	CDataWrapper* wrapper = NULL;
       
   119 
       
   120 	if( KT_WlanMgmtClient() == aData )
       
   121 		{
       
   122 		wrapper = CT_WlanMgmtClientData::NewL();
       
   123 		}
       
   124 	else if(KT_WlanScanInfo() == aData)
       
   125 		{
       
   126 		wrapper = CT_WlanScanInfoData::NewL();
       
   127 		}
       
   128 	else if(KT_WlanSocketServ() == aData)
       
   129 		{
       
   130 		wrapper = CT_RSocketServData::NewL();
       
   131 		}
       
   132 	else if(KT_CCommsDB() == aData)
       
   133 		{
       
   134 		wrapper = CT_CCommsDatabaseData::NewL();
       
   135 		}
       
   136 	else if(KT_CCommsDBTable() == aData)
       
   137 		{
       
   138 		wrapper = CT_CCommsDbTableViewData::NewL();
       
   139 		}
       
   140 	else if(KT_RConnection() == aData)
       
   141 		{
       
   142 		wrapper = CT_RConnectionData::NewL();
       
   143 		}
       
   144 	else if(KT_RSocket() == aData)
       
   145 		{
       
   146 		wrapper = CT_RSocketData::NewL();
       
   147 		}
       
   148 	else if(KT_RFile() == aData)
       
   149 		{
       
   150 		wrapper = CT_RFileData::NewL();
       
   151 		}
       
   152 	return wrapper;
       
   153 	}