perfsrv/memspy/Console/Source/ConsoleMain.cpp
changeset 48 516af714ebb4
equal deleted inserted replaced
45:185201be11b0 48:516af714ebb4
       
     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 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <e32std.h>
       
    20 #include <e32test.h>
       
    21 #include <f32file.h>
       
    22 #include <e32base.h>
       
    23 #include <e32cons.h>
       
    24 #include <f32file.h>
       
    25 #include <bacline.h>
       
    26 
       
    27 // Engine includes
       
    28 #include <memspy/engine/memspyengine.h>
       
    29 #include <memspysession.h>
       
    30 
       
    31 // User includes
       
    32 #include "ConsoleMenu.h"
       
    33 #include "ConsoleConstants.h"
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // DoMainL()
       
    38 // 
       
    39 // 
       
    40 // ---------------------------------------------------------------------------
       
    41 static void DoMainL()
       
    42     {
       
    43     // Scheduler
       
    44     CActiveScheduler* scheduler = new CActiveScheduler();
       
    45     CActiveScheduler::Install( scheduler );
       
    46     CleanupStack::PushL( scheduler );
       
    47 
       
    48     // F32
       
    49     RFs fsSession;
       
    50     User::LeaveIfError( fsSession.Connect() );
       
    51     CleanupClosePushL( fsSession );
       
    52     
       
    53     // Console
       
    54 	CConsoleBase* console = Console::NewL( KMemSpyConsoleName, TSize( KConsFullScreen, KConsFullScreen ) );
       
    55 	CleanupStack::PushL( console );
       
    56 
       
    57     // Engine
       
    58     RMemSpySession session;
       
    59     User::LeaveIfError(session.Connect());
       
    60     CleanupClosePushL(session);
       
    61 
       
    62     // Menu & event handler AO
       
    63     CMemSpyConsoleMenu::NewLC( session, *console );
       
    64 
       
    65     // Play nicely with external processes
       
    66     RProcess::Rendezvous( KErrNone );
       
    67 
       
    68     // Start wait loop - console will stop it when done.
       
    69     CActiveScheduler::Start();
       
    70 
       
    71     // Tidy up
       
    72     CleanupStack::PopAndDestroy( 5, scheduler );
       
    73     }
       
    74    
       
    75 
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // E32Main()
       
    79 // 
       
    80 // 
       
    81 // ---------------------------------------------------------------------------
       
    82 GLDEF_C TInt E32Main()
       
    83     {
       
    84     __UHEAP_MARK;
       
    85     RDebug::Print(_L("[MCon] E32Main() - MEMSPY CONSOLE"));
       
    86 
       
    87     CTrapCleanup* cleanupTrap = CTrapCleanup::New();
       
    88     TRAPD(err, DoMainL());  
       
    89     if  ( err != KErrNone )
       
    90         {
       
    91         RDebug::Printf( " " );
       
    92         RDebug::Printf( " " );
       
    93         RDebug::Print(_L("[MCon] E32Main() - MEMSPY CONSOLE - error: %d"), err);
       
    94         if ( err == KErrAlreadyExists )
       
    95             {
       
    96             RDebug::Printf( "\t\t [MCon] NB: MemSpy and MemSpyConsoleUi cannot run simultaneously!", err);
       
    97             RDebug::Printf( " " );
       
    98             RDebug::Printf( " " );
       
    99             }
       
   100         }
       
   101     delete cleanupTrap; 
       
   102 
       
   103     __UHEAP_MARKEND;
       
   104 
       
   105     return KErrNone;
       
   106     }
       
   107