memspy/MemSpyServer/Source/MemSpyServerMain.cpp
branchRCL_3
changeset 21 52e343bb8f80
parent 20 ca8a1b6995f6
child 22 e26895079d7c
equal deleted inserted replaced
20:ca8a1b6995f6 21:52e343bb8f80
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 * MemSpyServer Main class
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <f32file.h>
       
    22 
       
    23 // Engine includes
       
    24 #include <memspy/engine/memspyengine.h>
       
    25 
       
    26 // User includes
       
    27 //#include "MemSpyServer.h"
       
    28 
       
    29 static void RunServerL()
       
    30     {
       
    31     // Scheduler
       
    32     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
    33     CleanupStack::PushL( scheduler );    
       
    34     CActiveScheduler::Install( scheduler );    
       
    35     
       
    36     // F32
       
    37     RFs fsSession;
       
    38     User::LeaveIfError(fsSession.Connect());
       
    39     CleanupClosePushL(fsSession);
       
    40     
       
    41     // MemSpyEngine initialization
       
    42     CMemSpyEngine* engine = CMemSpyEngine::NewL(fsSession);
       
    43     CleanupStack::PushL(engine);
       
    44     
       
    45     // Play nicely with external processes
       
    46     RProcess::Rendezvous( KErrNone );       
       
    47 
       
    48     // Start wait loop.
       
    49     CActiveScheduler::Start();
       
    50     
       
    51     // Tidy up
       
    52     CleanupStack::PopAndDestroy( 3, scheduler );
       
    53     }
       
    54 
       
    55 TInt E32Main()
       
    56     {
       
    57     __UHEAP_MARK;
       
    58 
       
    59     CTrapCleanup* cleanupTrap = CTrapCleanup::New();
       
    60     
       
    61 	TInt r = KErrNoMemory;
       
    62 	if ( cleanupTrap )
       
    63 		{
       
    64 		TRAPD(err, RunServerL());		
       
    65 		if  ( err != KErrNone )
       
    66 		        {
       
    67 		        RDebug::Print(_L("[MemSpyCmdLine] E32Main() - MemSpyServer - error: %d"), err);
       
    68 		        }
       
    69 		delete cleanupTrap;
       
    70 		}  
       
    71 
       
    72     __UHEAP_MARKEND;
       
    73 
       
    74     return r;
       
    75     }