mediator/src/Server/MediatorServerMain.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Main functions to start the server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "MediatorServer.h"
       
    21 #include "MediatorCommon.h"
       
    22 #include "Debug.h"
       
    23 
       
    24 // ============================= LOCAL FUNCTIONS ===============================
       
    25 
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // RunServerL
       
    29 // 
       
    30 // Constructs Active Scheduler and starts the server up & running
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 static void RunServerL()
       
    34 	{
       
    35 	LOG(_L("[Mediator Server]\t RunServerL"));
       
    36 	// Create and install the active scheduler we need
       
    37 	CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler;
       
    38 	CleanupStack::PushL( scheduler );
       
    39 	CActiveScheduler::Install( scheduler );
       
    40 
       
    41 	// Create server
       
    42 	CMediatorServer* server = CMediatorServer::NewLC();
       
    43 
       
    44 	// Initialisation complete, now signal the client
       
    45 	User::LeaveIfError( User::RenameThread( KMediatorServerProcessName ) ); // renaming eases debugging in panic cases
       
    46 	RProcess::Rendezvous( KErrNone );
       
    47 
       
    48 	// Ready to run
       
    49 	CActiveScheduler::Start();
       
    50 
       
    51 	// Cleanup the server and scheduler
       
    52 	CleanupStack::PopAndDestroy( server );
       
    53 	CleanupStack::PopAndDestroy( scheduler );
       
    54 	}
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // E32Main
       
    58 //
       
    59 // Module entry point
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 TInt E32Main()
       
    63 	{
       
    64 	LOG(_L("[Mediator Server]\t E32Main"));
       
    65 	
       
    66     __UHEAP_MARK;
       
    67     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    68     TInt error = KErrNoMemory;
       
    69     if ( cleanup )
       
    70         {
       
    71         TRAP( error, RunServerL() );
       
    72         delete cleanup;
       
    73         ERROR_TRACE(Print(_L("[Mediator] E32Main: error=%d\n"), error ) );
       
    74         }
       
    75     __UHEAP_MARKEND;
       
    76     
       
    77     return error;
       
    78 	}
       
    79 
       
    80 // End of File