bluetoothengine/btaudioman/src/basrvmain.cpp
changeset 0 f63038272f30
child 41 0b2439c3e397
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Contains global dll entry of BT Accessory Server which also creates 
       
    15 *                first instance of the server.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "debug.h"
       
    21 #include "BTAccServer.h"        // create instance of server
       
    22 #include "BTAccClientSrv.h"        // server name
       
    23 
       
    24 static void RunServerL();
       
    25 
       
    26 /**
       
    27 * Main entry-point for the server process. 
       
    28 * Its a global definition, so GLDEF_C keyword can be omitted though.
       
    29 **/
       
    30 GLDEF_C TInt E32Main()
       
    31     {
       
    32     TRACE_STATIC_FUNC
       
    33 
       
    34     __UHEAP_MARK;
       
    35     CTrapCleanup* cleanup=CTrapCleanup::New();
       
    36     TInt r=KErrNoMemory;
       
    37     if (cleanup)
       
    38         {
       
    39         TRAP(r,RunServerL());
       
    40         delete cleanup;
       
    41         }
       
    42     //
       
    43     __UHEAP_MARKEND;
       
    44     return r;
       
    45     }
       
    46 
       
    47 /**
       
    48 Create the active scheduler and server instances, and start the 
       
    49 server.
       
    50 */
       
    51 static void RunServerL()
       
    52     {
       
    53     
       
    54     User::LeaveIfError(User::RenameThread(KBTAudioManName));    
       
    55 
       
    56     // Create and install the active scheduler.
       
    57     CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
    58     CleanupStack::PushL(scheduler);
       
    59     CActiveScheduler::Install(scheduler);
       
    60 
       
    61     // Create the server. NB Odd syntax in this line because we never refer to 
       
    62     // it directly- it's always owned by the cleanup stack!
       
    63     (void)CBTAccServer::NewLC();
       
    64 
       
    65     // Initialisation complete, now signal the client
       
    66     RProcess::Rendezvous(KErrNone);
       
    67 
       
    68     // Ready to run. This only returns when the server is closing down.
       
    69     CActiveScheduler::Start();
       
    70 
       
    71     // Clean up the server and scheduler.
       
    72     CleanupStack::PopAndDestroy(2, scheduler);
       
    73     
       
    74     }
       
    75 
       
    76 // End of file