idlefw/src/framework/main.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Entry point of Active Idle process.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ecom/ecom.h"
       
    20 #include "aifw.h"
       
    21 #include "debug.h"
       
    22 
       
    23 GLDEF_C TInt E32Main()
       
    24     {
       
    25     __TICK("FW: Entry point");
       
    26     __UHEAP_MARK;
       
    27 #ifdef _DEBUG
       
    28     // Check heap and handle count balance in debug builds
       
    29     TInt initPhc, initThc;
       
    30     RThread().HandleCount(initPhc, initThc);
       
    31 #endif
       
    32 
       
    33     // Create cleaup stack
       
    34     CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
    35     if (!cleanupStack)
       
    36         {
       
    37         return KErrNoMemory;
       
    38         }
       
    39         
       
    40     // Create and run the Active Idle Framework
       
    41     TInt aiFwResult = KErrNone;
       
    42     TRAP( aiFwResult, 
       
    43         CAiFw* fw = CAiFw::NewLC();
       
    44         fw->RunL();
       
    45         CleanupStack::PopAndDestroy( fw );
       
    46         );
       
    47 
       
    48     // Clean up before exit
       
    49     delete cleanupStack;
       
    50     REComSession::FinalClose();
       
    51 
       
    52 #ifdef _DEBUG
       
    53     // Check heap and handle count balance in debug builds
       
    54     TInt exitPhc, exitThc;
       
    55     RThread().HandleCount(exitPhc, exitThc);
       
    56     if ( exitThc != initThc )
       
    57         {
       
    58         __PRINT(__DBG_FORMAT("FW: Handle count mismatch %d at exit"), exitThc - initThc);
       
    59         }
       
    60 #endif
       
    61 
       
    62     __UHEAP_MARKEND;
       
    63     __PRINT_IF_ERROR(aiFwResult, "FW: Framework exit with error %d");
       
    64     return aiFwResult;
       
    65     }
       
    66