accessoryservices/remotecontrolfw/server/src/bulkmain.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 Bulk server.
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #include "remconserver.h"
       
    25 #include "bulkserver.h"
       
    26 
       
    27 #include <bluetooth/logger.h>
       
    28 
       
    29 #ifdef __FLOG_ACTIVE
       
    30 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_SERVER);
       
    31 #endif
       
    32 
       
    33 static void RunBulkServerL(RMsgQueue<TBulkServerMsg>* aMsgQueue);
       
    34 
       
    35 /**
       
    36 Entry point for the Remote Control server.
       
    37 @return Error.
       
    38 */
       
    39 TInt BulkMain(TAny* aParam)
       
    40 	{
       
    41 	CONNECT_LOGGER;
       
    42 	LOG_STATIC_FUNC;
       
    43 	TInt ret = KErrNoMemory;
       
    44 
       
    45 	__UHEAP_MARK;
       
    46 
       
    47 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    48 
       
    49 	if ( cleanup )
       
    50 		{
       
    51 		TRAP(ret, RunBulkServerL(reinterpret_cast<RMsgQueue<TBulkServerMsg>*>(aParam)));
       
    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 bulk server instances, and start the 
       
    64 server.
       
    65 */
       
    66 static void RunBulkServerL(RMsgQueue<TBulkServerMsg>* aMsgQueue)
       
    67 	{
       
    68 	LOG_STATIC_FUNC;
       
    69 	LEAVEIFERRORL(User::RenameThread(KRemConBulkServerName));
       
    70 
       
    71 	// Create and install the active scheduler.
       
    72 	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
    73 	CleanupStack::PushL(scheduler);
       
    74 	CActiveScheduler::Install(scheduler);
       
    75 
       
    76 	// Create the server. NB Odd syntax in this line because we never refer to 
       
    77 	// it directly- it's always owned by the cleanup stack!
       
    78 	static_cast<void>(CRemConBulkServer::NewLC(*aMsgQueue));
       
    79 
       
    80 	// Initialisation complete, now signal the client
       
    81 	RThread().Rendezvous(KErrNone);
       
    82 
       
    83 	// Ready to run. This only returns when the server is closing down.
       
    84 	CActiveScheduler::Start();
       
    85 
       
    86 	// Clean up the server and scheduler.
       
    87 	CleanupStack::PopAndDestroy(2, scheduler);
       
    88 	}