genericopenlibs/openenvcore/libc/test/testwideapis/src/twideapisserver.cpp
changeset 0 e4d67989cc36
child 48 ab61c4cedc64
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : twideapisserver.cpp
       
    15 // This material, including documentation and any related 
       
    16 // computer programs, is protected by copyright controlled by 
       
    17 // Nokia Corporation. All rights are reserved. Copying, 
       
    18 // including reproducing, storing,  adapting or translating, any 
       
    19 // or all of this material requires the prior written consent of 
       
    20 // Nokia Corporation. This material also contains confidential 
       
    21 // information which may not be disclosed to others without the 
       
    22 // prior written consent of Nokia Corporation.
       
    23 //
       
    24 
       
    25 
       
    26 
       
    27 #include <c32comm.h>
       
    28 
       
    29 #if defined (__WINS__)
       
    30 #define PDD_NAME		_L("ECDRV")
       
    31 #else
       
    32 #define PDD_NAME		_L("EUART1")
       
    33 #define PDD2_NAME		_L("EUART2")
       
    34 #define PDD3_NAME		_L("EUART3")
       
    35 #define PDD4_NAME		_L("EUART4")
       
    36 #endif
       
    37 
       
    38 #define LDD_NAME		_L("ECOMM")
       
    39 
       
    40 /**
       
    41  * @file
       
    42  *
       
    43  * Pipe test server implementation
       
    44  */
       
    45 #include "twideapisserver.h"
       
    46 #include "twideapis.h"
       
    47 
       
    48 
       
    49 _LIT(KServerName, "twideapis");
       
    50 
       
    51 CWideApiTestServer* CWideApiTestServer::NewL()
       
    52 	{
       
    53 	CWideApiTestServer *server = new(ELeave) CWideApiTestServer();
       
    54 	CleanupStack::PushL(server);
       
    55 	server->ConstructL(KServerName);
       
    56 	CleanupStack::Pop(server);
       
    57 	return server;
       
    58 	}
       
    59 
       
    60 static void InitCommsL()
       
    61     {
       
    62     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    63     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    64 
       
    65 #ifndef __WINS__
       
    66     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    67     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    68     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    69 #endif
       
    70 
       
    71     ret = User::LoadLogicalDevice(LDD_NAME);
       
    72     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    73     ret = StartC32();
       
    74     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    75     }
       
    76 
       
    77 LOCAL_C void MainL()
       
    78 	{
       
    79 	// Leave the hooks in for platform security
       
    80 #if (defined __DATA_CAGING__)
       
    81 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    82 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    83 #endif
       
    84 	InitCommsL();
       
    85 	
       
    86 	CActiveScheduler* sched=NULL;
       
    87 	sched=new(ELeave) CActiveScheduler;
       
    88 	CActiveScheduler::Install(sched);
       
    89 	CWideApiTestServer* server = NULL;
       
    90 	// Create the CTestServer derived server
       
    91 	TRAPD(err, server = CWideApiTestServer::NewL());
       
    92 	if(!err)
       
    93 		{
       
    94 		// Sync with the client and enter the active scheduler
       
    95 		RProcess::Rendezvous(KErrNone);
       
    96 		sched->Start();
       
    97 		}
       
    98 	delete server;
       
    99 	delete sched;
       
   100 	}
       
   101 
       
   102 /**
       
   103  * Server entry point
       
   104  * @return Standard Epoc error code on exit
       
   105  */
       
   106 TInt main()
       
   107 	{
       
   108 	__UHEAP_MARK;
       
   109 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   110 	if(cleanup == NULL) 
       
   111 		{
       
   112 		return KErrNoMemory;  
       
   113 		}
       
   114 	TRAP_IGNORE(MainL());
       
   115 	delete cleanup;
       
   116 	__UHEAP_MARKEND;
       
   117 	
       
   118 	return KErrNone;
       
   119 	}
       
   120 
       
   121 
       
   122 CTestStep* CWideApiTestServer::CreateTestStep(const TDesC& aStepName)
       
   123 	{
       
   124 	CTestStep* testStep = NULL;
       
   125 
       
   126 	// This server creates just one step but create as many as you want
       
   127 	// They are created "just in time" when the worker thread is created
       
   128 	// install steps
       
   129 	if(aStepName == Kwfreopen_val)
       
   130 		{
       
   131 		testStep = new CTestWideApi(aStepName);
       
   132 		}
       
   133 	else if(aStepName == Kwfreopen_valm)
       
   134 		{
       
   135 		testStep = new CTestWideApi(aStepName);
       
   136 		}
       
   137 	else if(aStepName == Kwfreopen_valinv)
       
   138 		{
       
   139 		testStep = new CTestWideApi(aStepName);
       
   140 		}
       
   141 	else if(aStepName == Kwfdopen_val)
       
   142 		{
       
   143 		testStep = new CTestWideApi(aStepName);
       
   144 		}
       
   145 	else if(aStepName == Kwfdopen_ivalm)
       
   146 		{
       
   147 		testStep = new CTestWideApi(aStepName);
       
   148 		}
       
   149 	else if(aStepName == Kgetws_null)
       
   150 		{
       
   151 		testStep = new CTestWideApi(aStepName);
       
   152 		}
       
   153 	else if(aStepName == Kgetws_val)
       
   154 		{
       
   155 		testStep = new CTestWideApi(aStepName);
       
   156 		}
       
   157 	else if(aStepName == Kputws_null)
       
   158 		{
       
   159 		testStep = new CTestWideApi(aStepName);
       
   160 		}		
       
   161 	else if(aStepName == Kputws_val1)
       
   162 		{
       
   163 		testStep = new CTestWideApi(aStepName);
       
   164 		}
       
   165 	else if(aStepName == Kputws_val2)
       
   166 		{
       
   167 		testStep = new CTestWideApi(aStepName);
       
   168 		}
       
   169 	else if(aStepName == Kwremove_val1)
       
   170 		{
       
   171 		testStep = new CTestWideApi(aStepName);
       
   172 		}
       
   173 	else if(aStepName == Kwremove_val2)
       
   174 		{
       
   175 		testStep = new CTestWideApi(aStepName);
       
   176 		}
       
   177 	else if(aStepName == Kwremove_val3)
       
   178 		{
       
   179 		testStep = new CTestWideApi(aStepName);
       
   180 		}
       
   181 	else if(aStepName == Kwremove_null)
       
   182 		{
       
   183 		testStep = new CTestWideApi(aStepName);
       
   184 		}
       
   185 	else if(aStepName == Kwfdopen_ivalm1)
       
   186 		{
       
   187 		testStep = new CTestWideApi(aStepName);
       
   188 		}
       
   189 	else if(aStepName == Kwpopen_1)
       
   190 		{
       
   191 		testStep = new CTestWideApi(aStepName);
       
   192 		}
       
   193 	else if(aStepName == Kwfreopen1)
       
   194 		{
       
   195 		testStep = new CTestWideApi(aStepName);
       
   196 		}
       
   197 	else if(aStepName == Kwfreopen2)
       
   198 		{
       
   199 		testStep = new CTestWideApi(aStepName);
       
   200 		}
       
   201 	else if(aStepName == Kwfreopen3)
       
   202 		{
       
   203 		testStep = new CTestWideApi(aStepName);
       
   204 		}
       
   205 	else if(aStepName == Kwfreopen4)
       
   206 		{
       
   207 		testStep = new CTestWideApi(aStepName);
       
   208 		}
       
   209 	return testStep;
       
   210 	}
       
   211