printingsupport/printinguisupport/tef/TPrintTestServer.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-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 // Non-secure versions will be xxxServer.Dll and require a thread to be started
       
    15 // in the process of the client.\n
       
    16 // The client initialises the server by calling the one and only ordinal.\n
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent - Internal Symbian test code
       
    23 */
       
    24 #include "TPrintTestServer.h"
       
    25 #include "T_FprStep.h"
       
    26 #include "T_StreamStep.h"
       
    27 
       
    28 
       
    29 // Literal for ServerName
       
    30 _LIT(KServerName,"TPrintTestServer");
       
    31 CTPrintTestServer* CTPrintTestServer::NewL()
       
    32 
       
    33 /**
       
    34   @return - Instance of the test server.\n
       
    35  
       
    36   Called inside the MainL() function to create and start the
       
    37   CTestServer derived server.\n
       
    38  */
       
    39 	{
       
    40 	CTPrintTestServer * server = new (ELeave) CTPrintTestServer();
       
    41 	CleanupStack::PushL(server);
       
    42 	// CServer base class call
       
    43 	server->StartL(KServerName);
       
    44 	CleanupStack::Pop(server);
       
    45 	return server;
       
    46 	}
       
    47 
       
    48 
       
    49 // EKA2 much simpler
       
    50 // Just an E32Main and a MainL()
       
    51 LOCAL_C void MainL()
       
    52 /**
       
    53   Much simpler, uses the new Rendezvous() call to sync with the client.\n
       
    54  */
       
    55 	{
       
    56 	// Leave the hooks in for platform security
       
    57 #if (defined __DATA_CAGING__)
       
    58 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    59 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    60 #endif
       
    61 	CActiveScheduler* sched=NULL;
       
    62 	sched=new(ELeave) CActiveScheduler;
       
    63 	CActiveScheduler::Install(sched);
       
    64 
       
    65 	CTPrintTestServer* server = NULL;
       
    66 	// Create the CTestServer derived server
       
    67 
       
    68 	TRAPD(err,server = CTPrintTestServer::NewL());
       
    69 	if(!err)
       
    70 		{
       
    71 		// Sync with the client and enter the active scheduler
       
    72 		RProcess::Rendezvous(KErrNone);
       
    73 		sched->Start();
       
    74 		}
       
    75 	delete server;
       
    76 	delete sched;
       
    77 	}
       
    78 
       
    79 
       
    80 GLDEF_C TInt E32Main()
       
    81 /**
       
    82   @return - Standard Epoc error code on exit.\n
       
    83  */
       
    84 	{
       
    85 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    86 	if(cleanup == NULL)
       
    87 		{
       
    88 		return KErrNoMemory;
       
    89 		}
       
    90 	TRAP_IGNORE(MainL());
       
    91 	delete cleanup;
       
    92 	return KErrNone;
       
    93     }
       
    94 
       
    95 
       
    96 
       
    97 
       
    98 CTestStep* CTPrintTestServer::CreateTestStep(const TDesC& aStepName)
       
    99 /**
       
   100   @return - A CTestStep derived instance.\n
       
   101  
       
   102   Secure and non-secure variants.\n
       
   103   Implementation of CTestServer pure virtual.\n
       
   104  */
       
   105 	{
       
   106 	CTmsTestStep* testStep = NULL;
       
   107 	// This server creates just one step but create as many as you want
       
   108 	// They are created "just in time" when the worker thread is created
       
   109 	if(aStepName == KT_FprStep)
       
   110 		testStep = new CT_FprStep();
       
   111 	else if(aStepName == KT_StreamStep)
       
   112 		testStep = new CT_StreamStep();
       
   113 	return testStep;
       
   114 	}