hwrmhaptics/hapticsserver/src/hwrmhapticsserverstartup.cpp
author William Roberts <williamr@symbian.org>
Mon, 23 Aug 2010 13:33:24 +0100
changeset 57 dd2df5227700
parent 0 4e1aa6a622a0
permissions -rw-r--r--
Remerge workaround for Bug 2620 in S^4

/*
* Copyright (c) 2008 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:  Haptics server startup bootstrap.
*
*/


#include "hwrmhapticsserver.h"
#include "hwrmhapticsserveractivescheduler.h"
#include "hwrmhapticsconfiguration.h"  
#include "hwrmhapticstrace.h"


TInt E32Main(); // Process entry point


// ---------------------------------------------------------------------------
// Function that starts the HWRMHapticsServer.
// ---------------------------------------------------------------------------
//
static TInt StartServerL()
    {
    COMPONENT_TRACE( ( _L( "HWRMHaptics Server - StartServerL()" )) );

    User::LeaveIfError( RThread().RenameMe( KServerProcessName ) );
    RThread().SetPriority( EPriorityAbsoluteHighNormal );

    // create active scheduler
    CHWRMHapticsServerActiveScheduler* scheduler = 
        CHWRMHapticsServerActiveScheduler::NewL();
    
    CleanupStack::PushL( scheduler );
    
    // install scheduler
    CActiveScheduler::Install( scheduler );

    // create server instance
    CHWRMHapticsServer* server = 
        CHWRMHapticsServer::NewL( KServerCActivePriority );

    RProcess::Rendezvous( KErrNone );

    // start scheduling
    CActiveScheduler::Start();
    
    delete server; 
    CleanupStack::PopAndDestroy( scheduler ); 
    
    COMPONENT_TRACE( ( _L( "HWRMHaptics Server - StartServerL() - return" )) );

    return KErrNone;
    }

// ---------------------------------------------------------------------------
// Main function
// ---------------------------------------------------------------------------
//
TInt E32Main()
    {
    COMPONENT_TRACE( ( _L( "HWRMHaptics Server - E32Main()" )) );

    __UHEAP_MARK;

    // create cleanupstack
    CTrapCleanup* cleanup = CTrapCleanup::New();

    TInt ret( KErrNone );

    if( cleanup )
        {
        TRAP( ret, StartServerL() );
        delete cleanup;
        }

    __UHEAP_MARKEND;

    COMPONENT_TRACE( ( _L( "HWRMHaptics Server - E32Main - return %d" ), ret ) );

    return ret;
    }

//  End of File