upnpharvester/mdhserver/src/server/mdhservermain.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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 Metadata Harvester server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "mdhserver.h"
       
    25 #include "mdhcommon.h"
       
    26 #include "msdebug.h"
       
    27 
       
    28 
       
    29 // LOCAL FUNCTION PROTOTYPES
       
    30 void RunServerL();
       
    31 
       
    32 
       
    33 // ============================= LOCAL FUNCTIONS =============================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // E32Main
       
    37 //
       
    38 // Module entry point
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 
       
    42 TInt E32Main()
       
    43     {
       
    44     LOG(_L("[CmMdh Server]\t E32Main"));
       
    45     
       
    46     __UHEAP_MARK;
       
    47     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    48     TInt error = KErrNoMemory;
       
    49     if ( cleanup )
       
    50         {
       
    51         TRAP( error, RunServerL() );
       
    52         delete cleanup;
       
    53         }
       
    54     __UHEAP_MARKEND;
       
    55     
       
    56     return error;
       
    57     }
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // RunServerL
       
    62 // 
       
    63 // Constructs Active Scheduler and starts the server up & running
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void RunServerL()
       
    67     {
       
    68     LOG(_L("[CmMdh Server]\t RunServerL"));
       
    69     // Create and install the active scheduler we need
       
    70     CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler;
       
    71     CleanupStack::PushL( scheduler );
       
    72     CActiveScheduler::Install( scheduler );
       
    73 
       
    74     // Create server
       
    75     CCmMdhServer* server = CCmMdhServer::NewLC();
       
    76 
       
    77     // Initialisation complete, now signal the client
       
    78     User::LeaveIfError( RThread().RenameMe( KCmMdhServerName ) );
       
    79     RProcess::Rendezvous( KErrNone );
       
    80 
       
    81     // Ready to run
       
    82     CActiveScheduler::Start();
       
    83 
       
    84     // Cleanup the server and scheduler
       
    85     CleanupStack::PopAndDestroy( server );
       
    86     CleanupStack::PopAndDestroy( scheduler );
       
    87     }
       
    88     
       
    89 // End of File