memspyui/source/MemSpyAppUi.cpp
changeset 0 d6fe6244b863
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     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 #include "MemSpyAppUi.h"
       
    19 
       
    20 // System includes
       
    21 #include <AknQueryDialog.h>
       
    22 #include <aknmessagequerydialog.h> 
       
    23 #include <aknradiobuttonsettingpage.h>
       
    24 #include <eikaufty.h>
       
    25 #include <eikmenub.h>
       
    26 #include <avkon.hrh>
       
    27 #include <barsread.h>
       
    28 #include <f32file.h>
       
    29 #include <apgtask.h>
       
    30 #include <memspyui.rsg>
       
    31 
       
    32 // Engine includes
       
    33 #include <memspy/engine/memspyengine.h>
       
    34 #include <memspy/engine/memspyengineoutputsink.h>
       
    35 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    36 #include <memspy/engine/memspyengineobjectprocess.h>
       
    37 #include <memspy/engine/memspyengineobjectthread.h>
       
    38 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
       
    39 #include <memspy/engine/memspyenginehelperchunk.h>
       
    40 #include <memspy/engine/memspyenginehelperthread.h>
       
    41 #include <memspy/engine/memspyenginehelperprocess.h>
       
    42 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
       
    43 #include <memspy/engine/memspyenginehelperfbserv.h>
       
    44 #include <memspyengineclientinterface.h>
       
    45 #include <memspy/driver/memspydriverenumerationsshared.h>
       
    46 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
       
    47 
       
    48 // User includes
       
    49 #include "MemSpyContainer.h"
       
    50 #include "MemSpyDocument.h"
       
    51 #include "MemSpySettings.h"
       
    52 #include "MemSpyDeviceWideOperationDialog.h"
       
    53 #include "MemSpyViewRAMInfo.h" // for aknicon config check
       
    54 #include "MemSpyExportBitmapsToMemoryCardDialog.h"
       
    55 #include "MemSpy.hrh"
       
    56 #include "viewcli.h"
       
    57 
       
    58 // Constants
       
    59 const TInt KMemSpyDefaultAutoCaptureTimerPeriod = 60;
       
    60 const TUint32 KMemSpyEikSrvSID = 0x10003a4a;
       
    61 
       
    62 
       
    63 CMemSpyAppUi::CMemSpyAppUi( CMemSpyEngine& aEngine )
       
    64 :   iEngine( aEngine ), iAutoCaptureTimerPeriod( KMemSpyDefaultAutoCaptureTimerPeriod ), iAutoCaptureOperationType( CMemSpyDeviceWideOperations::EPerEntityHeapInfo )
       
    65     {
       
    66     iEngine.SetObserver( this );
       
    67     }
       
    68 
       
    69 
       
    70 CMemSpyAppUi::~CMemSpyAppUi()
       
    71     {
       
    72     RDebug::Printf( "[MemSpy] MemSpy is now closing." );
       
    73     //
       
    74     delete iAutoCaptureTimer;
       
    75     //
       
    76     if (iAppContainer)
       
    77         {
       
    78         RemoveFromStack( iAppContainer );
       
    79         delete iAppContainer;
       
    80         }
       
    81     //
       
    82     iEngine.SetObserver( NULL );
       
    83     SetViewServerTimeOutStatus( ETrue );
       
    84     }
       
    85 
       
    86 
       
    87 void CMemSpyAppUi::ConstructL()
       
    88     {
       
    89     BaseConstructL( EAknEnableSkin );
       
    90     //
       
    91     iAppContainer = new (ELeave) CMemSpyContainer( iEngine, *this );
       
    92     iAppContainer->SetMopParent(this);
       
    93     iAppContainer->ConstructL( ClientRect() );
       
    94     iAppContainer->SetObserver( this );
       
    95     iAppContainer->SetFocus( ETrue );
       
    96     AddToStackL( iAppContainer );
       
    97     //
       
    98     iAutoCaptureTimer = CPeriodic::NewL( CActive::EPriorityIdle );
       
    99 	//
       
   100 	iEikonEnv->SetSystem( ETrue );
       
   101     //
       
   102     SetViewServerTimeOutStatus( EFalse );
       
   103     }
       
   104 
       
   105 
       
   106 CMemSpyDocument& CMemSpyAppUi::MemSpyDocument()
       
   107     {
       
   108 	CMemSpyDocument* doc = static_cast< CMemSpyDocument* >( Document() );
       
   109     return *doc;
       
   110     }
       
   111 
       
   112 
       
   113 const CMemSpyDocument& CMemSpyAppUi::MemSpyDocument() const
       
   114     {
       
   115 	const CMemSpyDocument* doc = static_cast< const CMemSpyDocument* >( Document() );
       
   116     return *doc;
       
   117     }
       
   118 
       
   119 
       
   120 void CMemSpyAppUi::HandleStatusPaneSizeChange()
       
   121 	{
       
   122 	iAppContainer->SetRect( ClientRect() );
       
   123 	} 
       
   124 
       
   125 
       
   126 void CMemSpyAppUi::HandleControlEventL( CCoeControl* aControl, TCoeEvent /*aEventType*/ )
       
   127     {
       
   128     if  ( aControl == iAppContainer )
       
   129         {
       
   130         UpdateCBAL();
       
   131         }
       
   132     }
       
   133 
       
   134 
       
   135 void CMemSpyAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   136     {
       
   137     CMemSpyViewBase& view = iAppContainer->ActiveView();
       
   138     const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
       
   139     //
       
   140     const TBool openableView = MemSpyViewTypeUtils::IsOpenableItem( viewType );
       
   141     const TBool exitable = MemSpyViewTypeUtils::IsExitableView( viewType );
       
   142     //
       
   143 #ifdef _DEBUG
       
   144     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DynInitMenuPaneL() - START - aResourceId: 0x%08x (%8d), iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d, viewType: %d, openableView: %d, exitable: %d", aResourceId, aResourceId, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive(), viewType, openableView, exitable );
       
   145 #endif
       
   146     //
       
   147     if  ( aResourceId == R_MEMSPY_MENUPANE )
       
   148         {
       
   149         const TInt count = aMenuPane->NumberOfItemsInPane();
       
   150         for( TInt i=0; i<count; i++ )
       
   151             {
       
   152             TBool dimItem = EFalse;
       
   153             CEikMenuPaneItem::SData& menuPaneMetaData = aMenuPane->ItemDataByIndexL( i );
       
   154 
       
   155             // If the command is inside the view-specific range then we'll hide it
       
   156             // unless the view and command id matches.
       
   157             const TBool isViewSpecific = ( menuPaneMetaData.iCommandId >= KMemSpyMenuCommandViewSpecific );
       
   158             if  ( isViewSpecific )
       
   159                 {
       
   160                 // Check whether this view requires this command item.
       
   161                 dimItem = ( view.MenuCascadeCommandId() != menuPaneMetaData.iCommandId );
       
   162                 }
       
   163 
       
   164             aMenuPane->SetItemDimmed( menuPaneMetaData.iCommandId, dimItem );
       
   165             }
       
   166 
       
   167         aMenuPane->SetItemDimmed( EMemSpyCmdOpen, !openableView );
       
   168         aMenuPane->SetItemDimmed( EAknSoftkeyBack, exitable );
       
   169         aMenuPane->SetItemDimmed( EAknCmdExit, !exitable );
       
   170         }
       
   171     else if ( aResourceId == R_MEMSPY_MENUPANE_TOOLS )
       
   172         {
       
   173         const TBool inOpenFilesView = ( viewType == EMemSpyViewTypeOpenFiles );
       
   174         aMenuPane->SetItemDimmed( EMemSpyCmdToolsListOpenFiles, !inOpenFilesView );
       
   175         }
       
   176     else if ( aResourceId == R_MEMSPY_MENUPANE_VIEW )
       
   177         {
       
   178         // Hide the refresh item when in the thread info container view
       
   179         aMenuPane->SetItemDimmed( EMemSpyCmdViewRefresh, viewType == EMemSpyViewTypeThreadInfoItemList );
       
   180         aMenuPane->SetItemDimmed( EMemSpyCmdViewOutputToSink, viewType == EMemSpyViewTypeThreadInfoItemList );
       
   181         }
       
   182     else if ( aResourceId == R_MEMSPY_MENUPANE_OUTPUT )
       
   183         {
       
   184         const TMemSpySinkType currentSink = iEngine.SinkType();
       
   185         aMenuPane->SetItemDimmed( EMemSpyCmdOutputToDebug, currentSink == ESinkTypeDebug );
       
   186         aMenuPane->SetItemDimmed( EMemSpyCmdOutputToFile, currentSink == ESinkTypeFile );
       
   187         }
       
   188     else if ( aResourceId == R_MEMSPY_MENUPANE_AUTO_CAPTURE )
       
   189         {
       
   190         // Change the auto-capture toggle caption appropriately...
       
   191         TInt resId = R_MEMSPY_AUTO_CAPTURE_ENABLE;
       
   192         if  ( iAutoCaptureTimer->IsActive() )
       
   193             {
       
   194             resId = R_MEMSPY_AUTO_CAPTURE_DISABLE;
       
   195             }
       
   196         aMenuPane->SetItemTextL( EMemSpyCmdAutoCaptureToggle, resId );
       
   197         }
       
   198 
       
   199 #ifdef _DEBUG
       
   200     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DynInitMenuPaneL() - sending to view..." );
       
   201 #endif
       
   202 
       
   203     view.DynInitMenuPaneL( aResourceId, aMenuPane );
       
   204 
       
   205 #ifdef _DEBUG
       
   206     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DynInitMenuPaneL() - END - aResourceId: 0x%08x (%8d), iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d, viewType: %d, openableView: %d, exitable: %d", aResourceId, aResourceId, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive(), viewType, openableView, exitable );
       
   207 #endif
       
   208     }
       
   209 
       
   210 
       
   211 TKeyResponse CMemSpyAppUi::HandleKeyEventL( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   212     {
       
   213     return EKeyWasNotConsumed;
       
   214     }
       
   215 
       
   216 
       
   217 void CMemSpyAppUi::HandleCommandL( TInt aCommand )
       
   218     {
       
   219 #ifdef _DEBUG
       
   220     RDebug::Printf( "[MemSpy] CMemSpyAppUi::HandleCommandL() - START - aCommand: %8d, iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", aCommand, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
       
   221 #endif
       
   222 
       
   223     switch ( aCommand )
       
   224         {
       
   225     case EAknSoftkeyBack:
       
   226         OnCmdBackL();
       
   227         break;
       
   228 
       
   229     case EEikCmdExit:
       
   230     case EAknCmdExit:
       
   231     case EAknSoftkeyExit:
       
   232         OnCmdExitL();
       
   233         break;
       
   234 
       
   235     case EMemSpyCmdOpen:
       
   236         OnCmdOpenL();
       
   237         break;
       
   238 
       
   239     case EMemSpyCmdOutputToDebug:
       
   240         OnCmdOutputToDebugL();
       
   241 		break;
       
   242     case EMemSpyCmdOutputToFile:
       
   243         OnCmdOutputToFileL();
       
   244 		break;
       
   245 
       
   246     case EMemSpyCmdToolsAbout:
       
   247         OnCmdAboutL();
       
   248         break;
       
   249     //
       
   250     case EMemSpyCmdPhoneInfoGeneralSummary:
       
   251         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralSummary );
       
   252         break;
       
   253     case EMemSpyCmdPhoneInfoGeneralDetailed:
       
   254         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed );
       
   255         break;
       
   256     case EMemSpyCmdPhoneInfoGeneralHandles:
       
   257         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralHandles );
       
   258         break;
       
   259     case EMemSpyCmdPhoneInfoGeneralKernelContainers:
       
   260         OnCmdPhoneInformationOperationKernelContainersL();
       
   261         break;
       
   262     //
       
   263     case EMemSpyCmdPhoneInfoHeapInfoSummary:
       
   264         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapInfo );
       
   265         break;
       
   266     case EMemSpyCmdPhoneInfoHeapInfoCompact:
       
   267         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceHeapInfoCompact );
       
   268         break;
       
   269     case EMemSpyCmdPhoneInfoHeapCellListing:
       
   270         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapCellListing );
       
   271         break;
       
   272     case EMemSpyCmdPhoneInfoHeapDump:
       
   273         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapData );
       
   274         break;
       
   275     //
       
   276     case EMemSpyCmdPhoneInfoStackInfo:
       
   277         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackInfo );
       
   278         break;
       
   279     case EMemSpyCmdPhoneInfoStackInfoCompact:
       
   280         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceStackInfoCompact );
       
   281         break;
       
   282     case EMemSpyCmdPhoneInfoStackDumpUser:
       
   283         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataUser );
       
   284         break;
       
   285     case EMemSpyCmdPhoneInfoStackDumpKernel:
       
   286         OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataKernel );
       
   287         break;
       
   288 
       
   289     case EMemSpyCmdAutoCaptureToggle:
       
   290         OnCmdAutoCaptureToggleL();
       
   291         break;
       
   292     case EMemSpyCmdAutoCaptureRetryTime:
       
   293         OnCmdAutoCaptureRetryTimeL();
       
   294         break;
       
   295     case EMemSpyCmdAutoCaptureOperationType:
       
   296         OnCmdAutoCaptureOperationTypeL();
       
   297         break;
       
   298 
       
   299     default:
       
   300         iAppContainer->HandleCommandL( aCommand );
       
   301         break;
       
   302         }
       
   303 
       
   304 #ifdef _DEBUG
       
   305     RDebug::Printf( "[MemSpy] CMemSpyAppUi::HandleCommandL() - END - aCommand: %8d, iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", aCommand, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
       
   306 #endif
       
   307     }
       
   308 
       
   309 
       
   310 void CMemSpyAppUi::HandleForegroundEventL( TBool aForeground)
       
   311     {
       
   312     // Refresh the container when coming to the foreground
       
   313     if  ( aForeground )
       
   314         {
       
   315         iAppContainer->OnCmdViewRefreshL();
       
   316         }
       
   317     }
       
   318 
       
   319 
       
   320 void CMemSpyAppUi::HandleThreadSelectedL( const CMemSpyThread& /*aThread*/ )
       
   321     {
       
   322 	MEikAppUiFactory* appUiFactory = (iEikonEnv)->AppUiFactory();
       
   323     appUiFactory->MenuBar()->TryDisplayMenuBarL();
       
   324     }
       
   325 
       
   326 
       
   327 void CMemSpyAppUi::HandleMemSpyEngineEventL( MMemSpyEngineObserver::TEvent aEvent, TAny* aContext )
       
   328     {
       
   329     if  ( aEvent == MMemSpyEngineObserver::EHandleThreadsOrProcessesChanged )
       
   330         {
       
   331         // Get the original container
       
   332         const CMemSpyEngineObjectContainer& oldContainer = *reinterpret_cast< CMemSpyEngineObjectContainer* >( aContext );
       
   333         (void) oldContainer;
       
   334 
       
   335         // Refresh the container
       
   336         iAppContainer->OnCmdViewRefreshL();
       
   337         }
       
   338     else if ( aEvent == MMemSpyEngineObserver::EHandleClientServerOperationRequest )
       
   339         {
       
   340         const TInt function = reinterpret_cast<TInt>( aContext );
       
   341         InitiateMemSpyClientServerOperationL( function );
       
   342         }
       
   343     }
       
   344 
       
   345 
       
   346 void CMemSpyAppUi::DWOperationStarted()
       
   347     {
       
   348 #ifdef _DEBUG
       
   349     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationStarted() - START - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   350 #endif
       
   351 
       
   352     iRunningDeviceWideOperation = ETrue;
       
   353 
       
   354 #ifdef _DEBUG
       
   355     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationStarted() - END - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   356 #endif
       
   357     }
       
   358 
       
   359 
       
   360 void CMemSpyAppUi::DWOperationCancelled()
       
   361     {
       
   362 #ifdef _DEBUG
       
   363     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCancelled() - START - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   364 #endif
       
   365 
       
   366     iAutoCaptureTimer->Cancel();
       
   367 
       
   368 #ifdef _DEBUG
       
   369     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCancelled() - END - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   370 #endif
       
   371     }
       
   372 
       
   373 
       
   374 void CMemSpyAppUi::DWOperationCompleted()
       
   375     {
       
   376 #ifdef _DEBUG
       
   377     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCompleted() - START - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   378 #endif
       
   379 
       
   380     iRunningDeviceWideOperation = EFalse;
       
   381 
       
   382 #ifdef _DEBUG
       
   383     RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCompleted() - END - iAutoCaptureTimer is active: %d", iAutoCaptureTimer->IsActive() );
       
   384 #endif
       
   385     }
       
   386 
       
   387 
       
   388 void CMemSpyAppUi::UpdateCBAL()
       
   389     {
       
   390     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   391     const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
       
   392     //
       
   393     if  ( MemSpyViewTypeUtils::IsExitableView( viewType ) )
       
   394         {
       
   395         cba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_EXIT );
       
   396         }
       
   397     else
       
   398         {
       
   399         cba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK );
       
   400         }
       
   401 
       
   402     cba->MakeVisible( ETrue );
       
   403     cba->DrawNow();
       
   404     }
       
   405 
       
   406 
       
   407 void CMemSpyAppUi::InitiateMemSpyClientServerOperationL( TInt aOpCode )
       
   408     {
       
   409 #ifdef _DEBUG
       
   410     RDebug::Printf( "[MemSpy] CMemSpyAppUi::InitiateMemSpyClientServerOperationL() - START - aOpCode: %d", aOpCode );
       
   411 #endif
       
   412 
       
   413     switch( aOpCode )
       
   414         {
       
   415     case EMemSpyClientServerOpSummaryInfo:
       
   416         HandleCommandL( EMemSpyCmdPhoneInfoGeneralSummary );
       
   417         break;
       
   418     case EMemSpyClientServerOpSummaryInfoDetailed:
       
   419         HandleCommandL( EMemSpyCmdPhoneInfoGeneralDetailed );
       
   420         break;
       
   421     //
       
   422     case EMemSpyClientServerOpHeapInfo:
       
   423         HandleCommandL( EMemSpyCmdPhoneInfoHeapInfoSummary );
       
   424         break;
       
   425     case EMemSpyClientServerOpHeapCellListing:
       
   426         HandleCommandL( EMemSpyCmdPhoneInfoHeapCellListing );
       
   427         break;
       
   428     case EMemSpyClientServerOpHeapData:
       
   429         HandleCommandL( EMemSpyCmdPhoneInfoHeapDump );
       
   430         break;
       
   431     //
       
   432     case EMemSpyClientServerOpStackInfo:
       
   433         HandleCommandL( EMemSpyCmdPhoneInfoStackInfo );
       
   434         break;
       
   435     case EMemSpyClientServerOpStackDataUser:
       
   436         HandleCommandL( EMemSpyCmdPhoneInfoStackDumpUser );
       
   437         break;
       
   438     case EMemSpyClientServerOpStackDataKernel:
       
   439         HandleCommandL( EMemSpyCmdPhoneInfoStackDumpKernel );
       
   440         break;
       
   441     //
       
   442     case EMemSpyClientServerOpBitmapsSave:
       
   443         OnCmdToolsBitmapsSaveToMemoryCardL();
       
   444         break;
       
   445     case EMemSpyClientServerOpSendToBackground:
       
   446         OnCmdToolsSendToBackgroundL();
       
   447         break;
       
   448     case EMemSpyClientServerOpBringToForeground:
       
   449         OnCmdToolsBringToForegroundL();
       
   450         break;
       
   451     case EMemSpyClientServerOpExit:
       
   452         OnCmdExitL();
       
   453         break;
       
   454     //
       
   455     default:
       
   456         User::Leave( KErrNotSupported );
       
   457         break;
       
   458         }
       
   459 
       
   460 #ifdef _DEBUG
       
   461     RDebug::Printf( "[MemSpy] CMemSpyAppUi::InitiateMemSpyClientServerOperationL() - END - aOpCode: %d", aOpCode );
       
   462 #endif
       
   463     }
       
   464 
       
   465 
       
   466 void CMemSpyAppUi::SetViewServerTimeOutStatus( TBool aEnabled )
       
   467     {
       
   468     TRAP_IGNORE(
       
   469         iEngine.HelperProcess().ImpersonateL( KMemSpyEikSrvSID );
       
   470         //
       
   471         CVwsSessionWrapper* ses = CVwsSessionWrapper::NewLC();
       
   472         ses->EnableServerEventTimeOut( aEnabled );
       
   473         CleanupStack::PopAndDestroy( ses );
       
   474         //
       
   475         iEngine.HelperProcess().ImpersonateL( 0 );
       
   476         );
       
   477     }
       
   478 
       
   479 
       
   480 void CMemSpyAppUi::OnCmdBackL()
       
   481     {
       
   482     const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
       
   483     //
       
   484     if  ( !MemSpyViewTypeUtils::IsExitableView( viewType ) )
       
   485         {
       
   486         // Should go back one view
       
   487         iAppContainer->NavigateToParentViewL();
       
   488         }
       
   489     }
       
   490 
       
   491 
       
   492 void CMemSpyAppUi::OnCmdExitL()
       
   493     {
       
   494     Exit();
       
   495     }
       
   496 
       
   497 
       
   498 void CMemSpyAppUi::OnCmdOpenL()
       
   499     {
       
   500     const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
       
   501     //
       
   502     if  ( !MemSpyViewTypeUtils::IsOpenableItem( viewType ) )
       
   503         {
       
   504         // Should go back one view
       
   505         iAppContainer->NavigateToChildViewL();
       
   506         }
       
   507     }
       
   508 
       
   509 
       
   510 void CMemSpyAppUi::OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::TOperation aOp )
       
   511     {
       
   512 #ifdef _DEBUG
       
   513     RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdPhoneInformationOperationL() - START - aOp: %d, iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", aOp, iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   514 #endif
       
   515 
       
   516     if  ( !iRunningDeviceWideOperation )
       
   517         {
       
   518         CMemSpyDeviceWideOperationDialog::ExecuteLD( iEngine, *this, aOp );
       
   519         }
       
   520 
       
   521 #ifdef _DEBUG
       
   522     RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdPhoneInformationOperationL() - END - aOp: %d, iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", aOp, iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
       
   523 #endif
       
   524     }
       
   525 
       
   526 
       
   527 void CMemSpyAppUi::OnCmdPhoneInformationOperationKernelContainersL()
       
   528     {
       
   529     CMemSpyEngineGenericKernelObjectContainer* list = iEngine.HelperKernelContainers().ObjectsAllL();
       
   530     CleanupStack::PushL( list );
       
   531     iEngine.HelperKernelContainers().OutputL( *list );
       
   532     CleanupStack::PopAndDestroy( list );
       
   533     }
       
   534 
       
   535 
       
   536     
       
   537     
       
   538     
       
   539     
       
   540     
       
   541     
       
   542     
       
   543     
       
   544     
       
   545     
       
   546     
       
   547     
       
   548     
       
   549     
       
   550     
       
   551     
       
   552     
       
   553     
       
   554 
       
   555 
       
   556 void CMemSpyAppUi::OnCmdAutoCaptureToggleL()
       
   557     {
       
   558 #ifdef _DEBUG
       
   559     RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdAutoCaptureToggleL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
       
   560 #endif
       
   561 
       
   562     if  ( iAutoCaptureTimer->IsActive() )
       
   563         {
       
   564         iAutoCaptureTimer->Cancel();
       
   565         }
       
   566     else
       
   567         {
       
   568         iAutoCaptureTimer->Cancel();
       
   569         //
       
   570         const TTimeIntervalMicroSeconds32 interval( iAutoCaptureTimerPeriod * 1000000 );
       
   571         iAutoCaptureTimer->Start( 0, interval, TCallBack(AutoCaptureCallBack, this) );
       
   572         }
       
   573 
       
   574 #ifdef _DEBUG
       
   575     RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdAutoCaptureToggleL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
       
   576 #endif
       
   577     }
       
   578 
       
   579 
       
   580 void CMemSpyAppUi::OnCmdAutoCaptureRetryTimeL()
       
   581     {
       
   582     CAknNumberQueryDialog* dialog = new(ELeave) CAknNumberQueryDialog( iAutoCaptureTimerPeriod );
       
   583     dialog->ExecuteLD( R_MEMSPY_DEVICE_WIDE_SETTINGS );
       
   584     }
       
   585 
       
   586 
       
   587 void CMemSpyAppUi::OnCmdAutoCaptureOperationTypeL()
       
   588     {
       
   589     CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL( R_MEMSPY_AUTO_CAPTURE_OPERATION_TYPES );
       
   590     CleanupStack::PushL(items);
       
   591     //
       
   592     TInt currentItem = iAutoCaptureOperationType;
       
   593     //
       
   594     CAknRadioButtonSettingPage* dialog = new(ELeave) CAknRadioButtonSettingPage( R_MEMSPY_AUTO_CAPTURE_OPERATION_TYPES_SETTINGS_PAGE, currentItem, items );
       
   595     if  ( dialog->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
   596         {
       
   597         iAutoCaptureOperationType = static_cast< CMemSpyDeviceWideOperations::TOperation >( currentItem );
       
   598         }
       
   599     //
       
   600     CleanupStack::PopAndDestroy( items ); 
       
   601     }
       
   602 
       
   603 
       
   604 TInt CMemSpyAppUi::AutoCaptureCallBack( TAny* aSelf )
       
   605     {
       
   606     CMemSpyAppUi* self = reinterpret_cast< CMemSpyAppUi* >( aSelf );
       
   607     TRAPD( err, self->AutoCaptureCallBackL() );
       
   608     //
       
   609     const TBool callMeBackAgain = ( err == KErrNone );
       
   610     return callMeBackAgain;
       
   611     }
       
   612 
       
   613 
       
   614 void CMemSpyAppUi::AutoCaptureCallBackL()
       
   615     {
       
   616 #ifdef _DEBUG
       
   617     RDebug::Printf( "[MemSpy] CMemSpyAppUi::AutoCaptureCallBackL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
       
   618 #endif
       
   619 
       
   620     OnCmdPhoneInformationOperationL( iAutoCaptureOperationType );
       
   621 
       
   622 #ifdef _DEBUG
       
   623     RDebug::Printf( "[MemSpy] CMemSpyAppUi::AutoCaptureCallBackL() - END - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
       
   624 #endif
       
   625     }
       
   626 
       
   627 
       
   628 
       
   629 
       
   630 
       
   631 
       
   632 
       
   633 
       
   634 
       
   635 
       
   636 
       
   637 
       
   638 
       
   639 
       
   640 
       
   641 
       
   642 
       
   643 
       
   644 
       
   645 
       
   646 
       
   647 void CMemSpyAppUi::OnCmdOutputToDebugL()
       
   648     {
       
   649     iEngine.InstallSinkL( ESinkTypeDebug );
       
   650     MemSpyDocument().Settings().StoreSettingsL();
       
   651     }
       
   652 
       
   653 
       
   654 void CMemSpyAppUi::OnCmdOutputToFileL()
       
   655     {
       
   656     iEngine.InstallSinkL( ESinkTypeFile );
       
   657     MemSpyDocument().Settings().StoreSettingsL();
       
   658     }
       
   659 
       
   660 
       
   661 
       
   662 
       
   663 
       
   664 
       
   665 
       
   666 
       
   667 
       
   668 
       
   669 
       
   670 void CMemSpyAppUi::OnCmdAboutL()
       
   671     {
       
   672     CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
       
   673     dialog->ExecuteLD( R_MEMSPYUI_ABOUT_DIALOG );
       
   674     }
       
   675 
       
   676 
       
   677 
       
   678 
       
   679 
       
   680 
       
   681 
       
   682 
       
   683 
       
   684 
       
   685 
       
   686 
       
   687 void CMemSpyAppUi::OnCmdToolsBitmapsSaveToMemoryCardL()
       
   688     {
       
   689     // Get bitmap handles
       
   690     RArray<TInt> handles;
       
   691     CleanupClosePushL( handles );
       
   692     iEngine.HelperFbServ().GetArrayOfBitmapHandlesL( handles );
       
   693 
       
   694     // Build bitmap list
       
   695     CMemSpyEngineFbServBitmapArray* array = CMemSpyEngineFbServBitmapArray::NewL( handles );
       
   696     CleanupStack::PopAndDestroy( &handles );
       
   697     CleanupStack::PushL( array );
       
   698 
       
   699     // Export...
       
   700     CMemSpyExportBitmapsToMemoryCardDialog* dialog = CMemSpyExportBitmapsToMemoryCardDialog::NewL( iCoeEnv->FsSession(), *array );
       
   701     
       
   702     // All done
       
   703     CleanupStack::PopAndDestroy( array );
       
   704     }
       
   705 
       
   706 
       
   707 void CMemSpyAppUi::OnCmdToolsSendToBackgroundL()
       
   708     {
       
   709     TApaTask task( iCoeEnv->WsSession() );
       
   710     task.SendToBackground();
       
   711     }
       
   712 
       
   713 
       
   714 void CMemSpyAppUi::OnCmdToolsBringToForegroundL()
       
   715     {
       
   716     iCoeEnv->BringOwnerToFront();
       
   717     }
       
   718 
       
   719 
       
   720 
       
   721