devencdiskutils/DevEncStarter/src/DevEncStarter.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 26 Jan 2010 15:20:08 +0200
changeset 0 164170e6151a
permissions -rw-r--r--
Revision: 201004

/*
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Entry point for DevEncStarter
*
*/


#include <c32comm.h>
#include "DevEncStarterEngine.h"
#include "DevEncLog.h"

// LITERALS
_LIT( KDevEncStarterName, "DevEncStarter" );

// LOCAL FUNCTION PROTOTYPES
static void StartDevEncStarterL();

// ============================= LOCAL FUNCTIONS ==============================

// ----------------------------------------------------------------------------
// Entry-point for the USB Watcher.
// ----------------------------------------------------------------------------
//
TInt E32Main()
    {
    DFLOG( "DevEncStarter => E32Main" );
    TInt ret;
    
    // rename the thread so it is easy to find the panic application
    ret = User::RenameThread( KDevEncStarterName );
    
    if (ret == KErrNone)
        {
        __UHEAP_MARK;
        // create clean-up stack
        CTrapCleanup* cleanup = CTrapCleanup::New();
    
        TRAP( ret, StartDevEncStarterL() );
    
        delete cleanup; // destroy clean-up stack
        __UHEAP_MARKEND;
        }
    
    DFLOG( "DevEncStarter => E32Main ended" );
    return ret; // and return
    }

// ----------------------------------------------------------------------------
// Constructs and installs the active scheduler, constructs USB Watcher's
// objects.
// ----------------------------------------------------------------------------
//
static void StartDevEncStarterL()
    {
    DFLOG( "DevEncStarter => StartDevEncStarterL" );
    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL( activeScheduler );
    CActiveScheduler::Install( activeScheduler );

    // Create the engine
    CDevEncStarterEngine* engine = CDevEncStarterEngine::NewLC();
    
    // Start the active scheduler, the active scheduler is stopped
   	// by the engine, when the phone is shutting down.
   	CActiveScheduler::Start();
    	
   	// Cleanup.
   	CleanupStack::PopAndDestroy( engine );	
   	CleanupStack::PopAndDestroy( activeScheduler );
   	DFLOG( "DevEncStarter => StartDevEncStarterL ended" );
    }

// End of file