accessoryservices/remotecontrolfw/server/src/main.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Entry point for Rem Con server.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <bluetooth/logger.h>
       
    24 #include <e32base.h>
       
    25 #include "remconserver.h"
       
    26 #include "server.h"
       
    27 
       
    28 #ifdef __FLOG_ACTIVE
       
    29 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_SERVER);
       
    30 #endif
       
    31 
       
    32 static void RunServerL();
       
    33 
       
    34 /**
       
    35 Entry point for the Remote Control server.
       
    36 @return Error.
       
    37 */
       
    38 GLDEF_C TInt E32Main()
       
    39 	{
       
    40 	CONNECT_LOGGER;
       
    41 	LOG_STATIC_FUNC;
       
    42 	TInt ret = KErrNoMemory;
       
    43 
       
    44 	__UHEAP_MARK;
       
    45 
       
    46 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    47 
       
    48 	if ( cleanup )
       
    49 		{
       
    50 		TRAP(ret, RunServerL());
       
    51 
       
    52 		delete cleanup;
       
    53 		}
       
    54 
       
    55 	__UHEAP_MARKEND;
       
    56 
       
    57 	LOG1(_L8("\tret = %d"), ret);
       
    58 	CLOSE_LOGGER;
       
    59 	return ret;
       
    60 	}
       
    61 
       
    62 /**
       
    63 Create the active scheduler and Rem Con server instances, and start the 
       
    64 server.
       
    65 */
       
    66 static void RunServerL()
       
    67 	{
       
    68 	LOG_STATIC_FUNC;
       
    69 	LEAVEIFERRORL(User::RenameThread(KRemConServerName));
       
    70 
       
    71 	CONNECT_LOGGER
       
    72 
       
    73 	// Create and install the active scheduler.
       
    74 	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
    75 	CleanupStack::PushL(scheduler);
       
    76 	CActiveScheduler::Install(scheduler);
       
    77 
       
    78 	// Create the server. NB Odd syntax in this line because we never refer to 
       
    79 	// it directly- it's always owned by the cleanup stack!
       
    80 	(void)CRemConServer::NewLC();
       
    81 
       
    82 	// Initialisation complete, now signal the client
       
    83 	RProcess::Rendezvous(KErrNone);
       
    84 
       
    85 	// Ready to run. This only returns when the server is closing down.
       
    86 	CActiveScheduler::Start();
       
    87 
       
    88 	// Clean up the server and scheduler.
       
    89 	CleanupStack::PopAndDestroy(2, scheduler);
       
    90 	CLOSE_LOGGER
       
    91 	}