mmsharing/mmshmanagersrv/src/musmanagerservermain.cpp
changeset 22 496ad160a278
parent 0 f0cf47e981f9
child 21 ce86b6d44a6d
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "muslogger.h"
       
    20 #include "musmanagerservermain.h"
       
    21 #include "musmanagerserver.h"
       
    22 #include "musmanageripccommon.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // MusManagerServerMain::ThreadFunction
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 TInt MusManagerServerMain::ThreadFunction ( TAny* /*aNone*/ )
       
    31 	{
       
    32     TInt err = KErrNone;
       
    33     CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
    34 	if (!cleanupStack) 
       
    35         {
       
    36         PanicServer( ECreateTrapCleanup );
       
    37         }
       
    38 	RSemaphore semaphore;
       
    39 	err = semaphore.OpenGlobal( KMusManagerServerSemaphoreName );
       
    40     if (err != KErrNone)
       
    41         {
       
    42         PanicServer( ESrvCreateServer );
       
    43         }
       
    44     TRAP( err, ThreadFunctionL( semaphore ) );
       
    45     if ( err != KErrNone )
       
    46         {
       
    47         semaphore.Signal();
       
    48         semaphore.Close();
       
    49         }
       
    50 
       
    51     delete cleanupStack;
       
    52     return err;
       
    53 	}
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // MusManagerServerMain::ThreadFunctionL
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void MusManagerServerMain::ThreadFunctionL (RSemaphore& aSemaphore)
       
    60 	{
       
    61 	// Give a name to this thread
       
    62     User::LeaveIfError(User::RenameThread(KMusManagerServerName));
       
    63 
       
    64     // Construct server
       
    65     CMusManagerServer* server = CMusManagerServer::NewLC();
       
    66 
       
    67 	// Server created ok
       
    68 	aSemaphore.Signal();
       
    69 	aSemaphore.Close();
       
    70 
       
    71 	// Start handling requests
       
    72 	CActiveScheduler::Start();
       
    73 
       
    74     // This will be executed after the active scheduler has been stopped:
       
    75     CleanupStack::PopAndDestroy(server); 
       
    76 	}
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // MusManagerServerMain::PanicServer
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void MusManagerServerMain::PanicServer (TMusManagerServerPanic aPanic)
       
    83 	{
       
    84     User::Panic( KMusManagerServer(), aPanic );
       
    85 	}
       
    86 
       
    87 
       
    88 // ======== GLOBAL FUNCTIONS ========
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Main function of the application executable.
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 
       
    95 GLDEF_C TInt E32Main()
       
    96     {
       
    97     return MusManagerServerMain::ThreadFunction( NULL );
       
    98     }