memspyui/ui/avkon/src/MemSpyViewKernelContainers.cpp
branchRCL_3
changeset 22 fad26422216a
parent 21 b3cee849fa46
child 23 f8280f3bfeb7
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
     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 "MemSpyViewKernelContainers.h"
       
    19 
       
    20 // Engine includes
       
    21 #include <memspy/engine/memspyengine.h>
       
    22 #include <memspy/engine/memspyengineobjectprocess.h>
       
    23 #include <memspy/engine/memspyengineobjectthread.h>
       
    24 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    25 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
       
    26 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
       
    27 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
       
    28 
       
    29 #include <memspysession.h>
       
    30 #include <memspy/api/memspyapiprocess.h>
       
    31 #include <memspy/engine/memspyengineutils.h>
       
    32 
       
    33 // User includes
       
    34 #include "MemSpyUiUtils.h"
       
    35 #include "MemSpyViewKernel.h"
       
    36 #include "MemSpyContainerObserver.h"
       
    37 #include "MemSpyViewKernelObjects.h"
       
    38 
       
    39 // Literal constants
       
    40 
       
    41 
       
    42 
       
    43 CMemSpyViewKernelContainers::CMemSpyViewKernelContainers( RMemSpySession& aSession, MMemSpyViewObserver& aObserver )
       
    44 :   CMemSpyViewBase( aSession, aObserver )
       
    45     {
       
    46     }
       
    47 
       
    48 
       
    49 CMemSpyViewKernelContainers::~CMemSpyViewKernelContainers()
       
    50     {
       
    51     //delete iModel;
       
    52     }
       
    53 
       
    54 
       
    55 void CMemSpyViewKernelContainers::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
    56     {
       
    57     _LIT( KTitle, "Kernel Objects" );
       
    58     SetTitleL( KTitle );
       
    59     //    
       
    60     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
    61     }
       
    62 
       
    63 
       
    64 void CMemSpyViewKernelContainers::RefreshL()
       
    65     {
       
    66     SetListBoxModelL();
       
    67     CMemSpyViewBase::RefreshL();
       
    68     }
       
    69 
       
    70 
       
    71 TMemSpyViewType CMemSpyViewKernelContainers::ViewType() const
       
    72     {
       
    73     return EMemSpyViewTypeKernelContainers;
       
    74     }
       
    75 
       
    76 
       
    77 CMemSpyViewBase* CMemSpyViewKernelContainers::PrepareParentViewL()
       
    78     {
       
    79     CMemSpyViewKernel* parent = new(ELeave) CMemSpyViewKernel( iMemSpySession, iObserver );
       
    80     CleanupStack::PushL( parent );
       
    81     parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
       
    82     CleanupStack::Pop( parent );
       
    83     return parent;
       
    84     }
       
    85 
       
    86 
       
    87 CMemSpyViewBase* CMemSpyViewKernelContainers::PrepareChildViewL()
       
    88     {	
       
    89     CMemSpyViewBase* child = NULL;
       
    90     const TInt index = iListBox->CurrentItemIndex();
       
    91     //child = new(ELeave) CMemSpyViewKernelObjects( iEngine, iObserver, iModel->At( index ).Type() );
       
    92     child = new(ELeave) CMemSpyViewKernelObjects( iMemSpySession, iObserver, iKernelObjects[index]->Type() );
       
    93     CleanupStack::PushL( child );
       
    94     child->ConstructL( Rect(), *Parent() );
       
    95     CleanupStack::Pop( child );
       
    96     return child;   
       
    97     }
       
    98 
       
    99 
       
   100 void CMemSpyViewKernelContainers::SetListBoxModelL()
       
   101     {	
       
   102 	iMemSpySession.GetKernelObjects( iKernelObjects );
       
   103 		
       
   104 	CDesCArrayFlat* model = new (ELeave) CDesC16ArrayFlat( iKernelObjects.Count() ); //array for formated items
       
   105 	
       
   106 	for( TInt i=0 ; i<iKernelObjects.Count() ; i++ )
       
   107 		{
       
   108 		TInt count = iKernelObjects[i]->Count();
       
   109 		TInt size = iKernelObjects[i]->Size();
       
   110 		const TMemSpySizeText sizeText( MemSpyUiUtils::FormatSizeText( size, 0 ) );
       
   111 								
       
   112 		HBufC* tempName = HBufC::NewL( iKernelObjects[i]->Name().Length() + 32 );
       
   113 		
       
   114 		CleanupStack::PushL( tempName );
       
   115 		TPtr tempNamePtr( tempName->Des() );
       
   116 		tempNamePtr.Copy( iKernelObjects[i]->Name() );									
       
   117 		
       
   118 		_LIT(KNameFormat, "\t%S\t\t%d item");
       
   119 		TPtr pName( tempName->Des() );
       
   120 		//
       
   121 		const TPtrC pType( MemSpyUiUtils::TypeAsString( iKernelObjects[i]->Type() ) );
       
   122 		//
       
   123 		pName.Format( KNameFormat, &pType, count );
       
   124 		//
       
   125 		if  ( count == 0 || count > 1 )
       
   126 			{
       
   127 			pName.Append( _L("s") );
       
   128 			}
       
   129 
       
   130 		pName.AppendFormat( _L(", %S"), &sizeText );
       
   131 		
       
   132 		model->AppendL( pName );
       
   133 		
       
   134 		CleanupStack::PopAndDestroy( tempName); //---
       
   135 		}
       
   136 	
       
   137 	CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );	
       
   138 	listbox->Model()->SetItemTextArray( model );
       
   139 	listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   140     }
       
   141 
       
   142 
       
   143 TBool CMemSpyViewKernelContainers::HandleCommandL( TInt aCommand )
       
   144     {
       
   145     TBool handled = ETrue;
       
   146     //
       
   147     switch ( aCommand )
       
   148         {
       
   149     case EMemSpyCmdKernelContainersOutput:
       
   150         OnCmdOutputAllContainerContentsL();
       
   151         break;
       
   152 
       
   153     default:
       
   154         handled = CMemSpyViewBase::HandleCommandL( aCommand );
       
   155         break;
       
   156         }
       
   157     //
       
   158     return handled;
       
   159     }
       
   160 
       
   161 
       
   162 void CMemSpyViewKernelContainers::OnCmdOutputAllContainerContentsL()
       
   163     {
       
   164 	iMemSpySession.OutputAllContainerContents();		
       
   165     }