predictivesearch/PcsServer/src/CPcsStartup.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 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:  PCS Server Startup module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <ecom/ecom.h>
       
    22 
       
    23 #include "CPcsDebug.h"
       
    24 #include "CPcsStartup.h"
       
    25 #include "CPcsServer.h"
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // Initialize and run the server
       
    29 // ----------------------------------------------------------------------------
       
    30 static void RunTheServerL()
       
    31 {
       
    32     PRINT ( _L("Enter RunTheServerL") );
       
    33 
       
    34     // First create and install the active scheduler
       
    35     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
    36     CActiveScheduler::Install(scheduler);
       
    37 
       
    38     // Create the server
       
    39     CPcsServer* server = CPcsServer::NewL();
       
    40   
       
    41     
       
    42     // Signal the client the startup is complete
       
    43     RProcess::Rendezvous(KErrNone);
       
    44 
       
    45     // Enter the wait loop
       
    46     CActiveScheduler::Start();
       
    47 
       
    48     // Exited cleanup scheduler and server
       
    49     delete server;
       
    50     delete scheduler;
       
    51 
       
    52     REComSession::FinalClose();
       
    53     
       
    54     PRINT ( _L("End RunTheServerL") );
       
    55 }
       
    56 
       
    57 
       
    58 // ----------------------------------------------------------------------------
       
    59 // Main entry-point for the server thread/process
       
    60 // ----------------------------------------------------------------------------
       
    61 static TInt RunTheServer()
       
    62 {
       
    63     PRINT ( _L("Enter RunTheServer") );
       
    64     
       
    65     CTrapCleanup* cleanup=CTrapCleanup::New();
       
    66     TInt r = KErrNoMemory;
       
    67     if (cleanup)
       
    68     {
       
    69 		TRAP(r,RunTheServerL());
       
    70 		delete cleanup;
       
    71     }
       
    72     
       
    73     PRINT ( _L("End RunTheServer") );
       
    74     
       
    75     return (r);
       
    76 }
       
    77 
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // Process entry point 
       
    81 // ----------------------------------------------------------------------------
       
    82 TInt E32Main()
       
    83 {
       
    84     return RunTheServer();
       
    85 }