installationservices/swi/test/tdaemon/tdaemon.cpp
changeset 0 ba25891c3a9e
child 25 7333d7932ef7
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2002-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 the License "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 * Example file/test code to demonstrate how to develop a TestExecute Server
       
    16 * Developers should take this project as a template and substitute their own
       
    17 * code at the __EDIT_ME__ tags
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 #include "tdaemon.h"
       
    25 
       
    26 // Tests
       
    27 #include "steps/watcherstep.h"
       
    28 #include "steps/daemonstep.h"
       
    29 
       
    30 
       
    31 namespace Swi
       
    32 {
       
    33 
       
    34 namespace Test
       
    35 {
       
    36 _LIT(KServerName,"tdaemon");
       
    37 
       
    38 CTestDaemon* CTestDaemon::NewL()
       
    39 	{
       
    40 	CTestDaemon * server = new (ELeave) CTestDaemon();
       
    41 	CleanupStack::PushL(server);
       
    42 	User::LeaveIfError(server->iFs.Connect());
       
    43 
       
    44 	// Make the file session sharable
       
    45 	User::LeaveIfError(server->iFs.ShareAuto());
       
    46 
       
    47 	// CServer base class call
       
    48 	server->StartL(KServerName);
       
    49 	CleanupStack::Pop(server);
       
    50 	return server;
       
    51 	}
       
    52 	
       
    53 CTestStep* CTestDaemon::CreateTestStep(const TDesC& aStepName)
       
    54 /*
       
    55  * return a CTestStep derived instance
       
    56  * Implementation of CTestServer pure virtual
       
    57  */
       
    58 	{
       
    59 	// Create a new step depending on the name, if we run out of memory we return NULL
       
    60 	// since we cannot leave.
       
    61 	if (aStepName == KDriveWatcherStep)
       
    62 		return new CWatcherStep();
       
    63 	else if (aStepName == KDaemonStep)
       
    64 		return new CDaemonStep();
       
    65 	
       
    66 	
       
    67 	return NULL;
       
    68 	}
       
    69 
       
    70 } // namespace Swi::Test
       
    71 
       
    72 } //namespace Swi
       
    73 
       
    74 
       
    75 LOCAL_C void MainL()
       
    76 /*
       
    77  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    78  */
       
    79 	{
       
    80 	// Leave the hooks in for platform security
       
    81 #if (defined __DATA_CAGING__)
       
    82 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    83 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    84 #endif
       
    85 	CActiveScheduler* sched=NULL;
       
    86 	sched=new(ELeave) CActiveScheduler;
       
    87 	CActiveScheduler::Install(sched);
       
    88 	// __EDIT_ME__ Your server name
       
    89 	Swi::Test::CTestDaemon* server = NULL;
       
    90 	// Create the CTestServer derived server
       
    91 	// __EDIT_ME__ Your server name
       
    92 	TRAPD(err,server = Swi::Test::CTestDaemon::NewL());
       
    93 	if(!err)
       
    94 		{
       
    95 		// Sync with the client and enter the active scheduler
       
    96 		RProcess::Rendezvous(KErrNone);
       
    97 		sched->Start();
       
    98 		}
       
    99 	delete server;
       
   100 	delete sched;
       
   101 	}
       
   102 
       
   103 GLDEF_C TInt E32Main()
       
   104 /*
       
   105  * return standard error code on exit
       
   106  */
       
   107 	{
       
   108 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   109 	if(cleanup == NULL)
       
   110 		{
       
   111 		return KErrNoMemory;
       
   112 		}
       
   113 	TRAP_IGNORE(MainL());
       
   114 	delete cleanup;
       
   115 	return KErrNone;
       
   116     }