installationservices/swi/source/daemon/main.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 24 5cc91383ab1e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
     1 /*
       
     2 * Copyright (c) 2004-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 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 #include "daemon.h"
       
    27 #include "daemonbehaviour.h"
       
    28 #include "log.h"
       
    29 
       
    30 namespace Swi
       
    31 {
       
    32 
       
    33 /**
       
    34  * Daemon main function
       
    35  */
       
    36 void MainL()
       
    37 	{
       
    38 	CDaemonBehaviour* daemonBehaviour=CDaemonBehaviour::NewLC();
       
    39 	CDaemon::NewLC(*daemonBehaviour);
       
    40 	
       
    41 	RProcess::Rendezvous(KErrNone);
       
    42 	CActiveScheduler::Start();
       
    43 
       
    44 	CleanupStack::PopAndDestroy(2, daemonBehaviour);	
       
    45 	}
       
    46 
       
    47 } // namespace Swi
       
    48 
       
    49 /**
       
    50  * Entry Point, sets up the cleanup stack and calls the main function.
       
    51  * @return Always returns KErrNone even if SwiDemon has failed to start.
       
    52  * Note: The break request to fix this problem (BR 1846) was rejected by 
       
    53  * the SCB 17/5/2006 so this cannot be fixed.
       
    54  * see http://smglinx.intra/twiki/bin/view/BR/1846 for more details.
       
    55  */
       
    56 GLDEF_C TInt E32Main()
       
    57 	{
       
    58 	DEBUG_PRINTF(_L8("SWI Daemon - Starting Daemon"));
       
    59 	
       
    60 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    61 	CActiveScheduler* scheduler=new CActiveScheduler();
       
    62 
       
    63 	if(cleanup == NULL || scheduler==NULL)
       
    64 		{
       
    65 		delete scheduler;
       
    66 		delete cleanup;
       
    67 		return KErrNoMemory;
       
    68 		}
       
    69 	CActiveScheduler::Install(scheduler);
       
    70 
       
    71 
       
    72 	// workaround for DEF056843 to ignore return code when this leaves 
       
    73 	// unable to remove this (supposed to be temporary workaround)
       
    74 	// due to BR 1846 (see above)
       
    75 	TRAP_IGNORE(Swi::MainL());
       
    76 
       
    77 	delete scheduler;
       
    78 	delete cleanup;
       
    79 	
       
    80 	DEBUG_PRINTF(_L8("SWI Daemon - Daemon Exiting"));
       
    81 	return KErrNone;
       
    82 	}
       
    83