memspyui/source/MemSpyViewCodeSegList.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 "MemSpyViewCodeSegList.h"
       
    19 
       
    20 // System includes
       
    21 #include <memspyui.rsg>
       
    22 
       
    23 // Engine includes
       
    24 #include <memspy/engine/memspyengine.h>
       
    25 #include <memspy/engine/memspyengineobjectprocess.h>
       
    26 #include <memspy/engine/memspyengineobjectthread.h>
       
    27 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    28 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
       
    29 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
       
    30 #include <memspy/engine/memspyenginehelperprocess.h>
       
    31 #include <memspy/engine/memspyenginehelpercodesegment.h>
       
    32 
       
    33 // User includes
       
    34 #include "MemSpyUiUtils.h"
       
    35 #include "MemSpyViewMainMenu.h"
       
    36 #include "MemSpyViewThreads.h"
       
    37 #include "MemSpyContainerObserver.h"
       
    38 #include "MemSpyExportBitmapsToMemoryCardDialog.h"
       
    39 
       
    40 
       
    41 
       
    42 CMemSpyViewCodeSegBase::CMemSpyViewCodeSegBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList* aList )
       
    43 :   CMemSpyViewBase( aEngine, aObserver ), iList( aList )
       
    44     {
       
    45     }
       
    46 
       
    47 
       
    48 CMemSpyViewCodeSegBase::~CMemSpyViewCodeSegBase()
       
    49     {
       
    50     delete iList;
       
    51     }
       
    52 
       
    53 
       
    54 TBool CMemSpyViewCodeSegBase::HandleCommandL( TInt aCommand )
       
    55     {
       
    56     TBool handled = ETrue;
       
    57     //
       
    58     switch ( aCommand )
       
    59         {
       
    60     case EMemSpyCmdCodeSegSortByName:
       
    61         iList->SortByFileNameL();
       
    62         CMemSpyViewBase::RefreshL();
       
    63         break;
       
    64     case EMemSpyCmdCodeSegSortByCodeSize:
       
    65         iList->SortByCodeSizeL();
       
    66         CMemSpyViewBase::RefreshL();
       
    67         break;
       
    68     case EMemSpyCmdCodeSegSortByDataSize:
       
    69         iList->SortByDataSizeL();
       
    70         CMemSpyViewBase::RefreshL();
       
    71         break;
       
    72     case EMemSpyCmdCodeSegSortByUid:
       
    73         iList->SortByUidsL();
       
    74         CMemSpyViewBase::RefreshL();
       
    75         break;
       
    76     case EMemSpyCmdCodeSegListing:
       
    77         OnCmdCodeSegmentListingL();
       
    78         break;
       
    79     case EMemSpyCmdCodeSegShowItemsAll:
       
    80         OnCmdShowItemsAllL();
       
    81         break;
       
    82     case EMemSpyCmdCodeSegShowItemsGlobalData:
       
    83         OnCmdShowItemsGlobalDataL();
       
    84         break;
       
    85 
       
    86     case EMemSpyCmdCodeSegShowCapsWithTCBProcess:
       
    87     case EMemSpyCmdCodeSegShowCapsWithTCBAll:              
       
    88         OnCmdFilterByCapabilityL( ECapabilityTCB, aCommand == EMemSpyCmdCodeSegShowCapsWithTCBAll );
       
    89         break;
       
    90     case EMemSpyCmdCodeSegShowCapsWithCommDDProcess:
       
    91     case EMemSpyCmdCodeSegShowCapsWithCommDDAll:
       
    92         OnCmdFilterByCapabilityL( ECapabilityCommDD, aCommand == EMemSpyCmdCodeSegShowCapsWithCommDDAll );
       
    93         break;
       
    94     case EMemSpyCmdCodeSegShowCapsWithPowerMgmtProcess:
       
    95     case EMemSpyCmdCodeSegShowCapsWithPowerMgmtAll:
       
    96         OnCmdFilterByCapabilityL( ECapabilityPowerMgmt, aCommand == EMemSpyCmdCodeSegShowCapsWithPowerMgmtAll );
       
    97         break;
       
    98     case EMemSpyCmdCodeSegShowCapsWithMultimediaDDProcess:
       
    99     case EMemSpyCmdCodeSegShowCapsWithMultimediaDDAll:
       
   100         OnCmdFilterByCapabilityL( ECapabilityMultimediaDD, aCommand == EMemSpyCmdCodeSegShowCapsWithMultimediaDDAll );
       
   101         break;
       
   102     case EMemSpyCmdCodeSegShowCapsWithReadDeviceDataProcess:
       
   103     case EMemSpyCmdCodeSegShowCapsWithReadDeviceDataAll:
       
   104         OnCmdFilterByCapabilityL( ECapabilityReadDeviceData, aCommand == EMemSpyCmdCodeSegShowCapsWithReadDeviceDataAll );
       
   105         break;
       
   106     case EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataProcess:
       
   107     case EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataAll:
       
   108         OnCmdFilterByCapabilityL( ECapabilityWriteDeviceData, aCommand == EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataAll );
       
   109         break;
       
   110     case EMemSpyCmdCodeSegShowCapsWithDRMProcess:
       
   111     case EMemSpyCmdCodeSegShowCapsWithDRMAll:
       
   112         OnCmdFilterByCapabilityL( ECapabilityDRM, aCommand == EMemSpyCmdCodeSegShowCapsWithDRMAll );
       
   113         break;
       
   114     case EMemSpyCmdCodeSegShowCapsWithTrustedUIProcess:
       
   115     case EMemSpyCmdCodeSegShowCapsWithTrustedUIAll:
       
   116         OnCmdFilterByCapabilityL( ECapabilityTrustedUI, aCommand == EMemSpyCmdCodeSegShowCapsWithTrustedUIAll );
       
   117         break;
       
   118     case EMemSpyCmdCodeSegShowCapsWithProtServProcess:
       
   119     case EMemSpyCmdCodeSegShowCapsWithProtServAll:
       
   120         OnCmdFilterByCapabilityL( ECapabilityProtServ, aCommand == EMemSpyCmdCodeSegShowCapsWithProtServAll );
       
   121         break;
       
   122     case EMemSpyCmdCodeSegShowCapsWithDiskAdminProcess:
       
   123     case EMemSpyCmdCodeSegShowCapsWithDiskAdminAll:
       
   124         OnCmdFilterByCapabilityL( ECapabilityDiskAdmin, aCommand == EMemSpyCmdCodeSegShowCapsWithDiskAdminAll );
       
   125         break;
       
   126     case EMemSpyCmdCodeSegShowCapsWithNetworkControlProcess:
       
   127     case EMemSpyCmdCodeSegShowCapsWithNetworkControlAll:
       
   128         OnCmdFilterByCapabilityL( ECapabilityNetworkControl, aCommand == EMemSpyCmdCodeSegShowCapsWithNetworkControlAll );
       
   129         break;
       
   130     case EMemSpyCmdCodeSegShowCapsWithAllFilesProcess:
       
   131     case EMemSpyCmdCodeSegShowCapsWithAllFilesAll:
       
   132         OnCmdFilterByCapabilityL( ECapabilityAllFiles, aCommand == EMemSpyCmdCodeSegShowCapsWithAllFilesAll );
       
   133         break;
       
   134     case EMemSpyCmdCodeSegShowCapsWithSwEventProcess:
       
   135     case EMemSpyCmdCodeSegShowCapsWithSwEventAll:
       
   136         OnCmdFilterByCapabilityL( ECapabilitySwEvent, aCommand == EMemSpyCmdCodeSegShowCapsWithSwEventAll );
       
   137         break;
       
   138     case EMemSpyCmdCodeSegShowCapsWithNetworkServicesProcess:
       
   139     case EMemSpyCmdCodeSegShowCapsWithNetworkServicesAll:
       
   140         OnCmdFilterByCapabilityL( ECapabilityNetworkServices, aCommand == EMemSpyCmdCodeSegShowCapsWithNetworkServicesAll );
       
   141         break;
       
   142     case EMemSpyCmdCodeSegShowCapsWithLocalServicesProcess:
       
   143     case EMemSpyCmdCodeSegShowCapsWithLocalServicesAll:
       
   144         OnCmdFilterByCapabilityL( ECapabilityLocalServices, aCommand == EMemSpyCmdCodeSegShowCapsWithLocalServicesAll );
       
   145         break;
       
   146     case EMemSpyCmdCodeSegShowCapsWithReadUserDataProcess:
       
   147     case EMemSpyCmdCodeSegShowCapsWithReadUserDataAll:
       
   148         OnCmdFilterByCapabilityL( ECapabilityReadUserData, aCommand == EMemSpyCmdCodeSegShowCapsWithReadUserDataAll );
       
   149         break;
       
   150     case EMemSpyCmdCodeSegShowCapsWithWriteUserDataProcess:
       
   151     case EMemSpyCmdCodeSegShowCapsWithWriteUserDataAll:
       
   152         OnCmdFilterByCapabilityL( ECapabilityWriteUserData, aCommand == EMemSpyCmdCodeSegShowCapsWithWriteUserDataAll );
       
   153         break;
       
   154     case EMemSpyCmdCodeSegShowCapsWithLocationProcess:
       
   155     case EMemSpyCmdCodeSegShowCapsWithLocationAll:
       
   156         OnCmdFilterByCapabilityL( ECapabilityLocation, aCommand == EMemSpyCmdCodeSegShowCapsWithLocationAll );
       
   157         break;
       
   158     case EMemSpyCmdCodeSegShowCapsWithSurroundingsDDProcess:
       
   159     case EMemSpyCmdCodeSegShowCapsWithSurroundingsDDAll:
       
   160         OnCmdFilterByCapabilityL( ECapabilitySurroundingsDD, aCommand == EMemSpyCmdCodeSegShowCapsWithSurroundingsDDAll );
       
   161         break;
       
   162     case EMemSpyCmdCodeSegShowCapsWithUserEnvProcess:
       
   163     case EMemSpyCmdCodeSegShowCapsWithUserEnvAll:
       
   164         OnCmdFilterByCapabilityL( ECapabilityUserEnvironment, aCommand == EMemSpyCmdCodeSegShowCapsWithUserEnvAll );
       
   165         break;
       
   166     default:
       
   167         handled = CMemSpyViewBase::HandleCommandL( aCommand );
       
   168         break;
       
   169         }
       
   170     //
       
   171     return handled;
       
   172     }
       
   173 
       
   174 
       
   175 void CMemSpyViewCodeSegBase::RefreshL()
       
   176     {
       
   177     SetListBoxModelL();
       
   178     CMemSpyViewBase::RefreshL();
       
   179     }
       
   180 
       
   181 
       
   182 void CMemSpyViewCodeSegBase::OnCmdCodeSegmentListingL()
       
   183     {
       
   184     // Begin a new data stream
       
   185     _LIT( KMemSpyContext, "CodeSeg List - " );
       
   186     _LIT( KMemSpyFolder, "CodeSegs" );
       
   187     iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
       
   188 
       
   189     // Set prefix for overall listing
       
   190     _LIT(KOverallPrefix, "CodeSeg List - ");
       
   191     iEngine.Sink().OutputPrefixSetLC( KOverallPrefix );
       
   192 
       
   193     // Create header
       
   194     CMemSpyEngineCodeSegList::OutputDataColumnsL( iEngine );
       
   195     
       
   196     // List items
       
   197     const TInt count = iList->Count();
       
   198     for(TInt i=0; i<count; i++)
       
   199         {
       
   200         const CMemSpyEngineCodeSegEntry& entry = iList->At( i );
       
   201         //
       
   202         entry.OutputDataL( iEngine.HelperCodeSegment() );
       
   203         }
       
   204 
       
   205     // Tidy up
       
   206     CleanupStack::PopAndDestroy(); // prefix
       
   207 
       
   208     // End data stream
       
   209     iEngine.Sink().DataStreamEndL();
       
   210     }
       
   211 
       
   212 
       
   213 void CMemSpyViewCodeSegBase::OnCmdShowItemsAllL()
       
   214     {
       
   215     iList->ShowAllL();
       
   216     CMemSpyViewBase::RefreshL();
       
   217     }
       
   218 
       
   219 
       
   220 void CMemSpyViewCodeSegBase::OnCmdShowItemsGlobalDataL()
       
   221     {
       
   222     iList->ShowOnlyEntriesWithGlobalDataL();
       
   223     CMemSpyViewBase::RefreshL();
       
   224     }
       
   225 
       
   226 
       
   227 void CMemSpyViewCodeSegBase::OnCmdFilterByCapabilityL( TCapability aCapability, TBool aAllBinaries )
       
   228     {
       
   229     TMemSpyViewCodeSegFilter filterLogic( aCapability, aAllBinaries );
       
   230     TMemSpyEngineVisibiltyFunction<CMemSpyEngineCodeSegEntry> filterFunction( TMemSpyViewCodeSegFilter::FilterItem, &filterLogic );
       
   231     iList->ShowL( filterFunction );
       
   232     CMemSpyViewBase::RefreshL();
       
   233     }
       
   234 
       
   235 
       
   236 
       
   237 
       
   238 
       
   239 
       
   240 
       
   241 
       
   242 
       
   243 
       
   244 
       
   245 
       
   246 
       
   247 
       
   248 
       
   249 
       
   250 
       
   251 
       
   252 
       
   253 
       
   254 
       
   255 
       
   256 
       
   257 
       
   258 
       
   259 
       
   260 
       
   261 
       
   262 
       
   263 CMemSpyViewCodeSegList::CMemSpyViewCodeSegList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
       
   264 :   CMemSpyViewCodeSegBase( aEngine, aObserver, NULL )
       
   265     {
       
   266     }
       
   267 
       
   268 
       
   269 CMemSpyViewCodeSegList::CMemSpyViewCodeSegList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList& aList )
       
   270 :   CMemSpyViewCodeSegBase( aEngine, aObserver, &aList )
       
   271     {
       
   272     }
       
   273 
       
   274 
       
   275 void CMemSpyViewCodeSegList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
   276     {
       
   277     _LIT( KTitle, "Code Segments" );
       
   278     SetTitleL( KTitle );
       
   279 
       
   280     if  ( iList == NULL )
       
   281         {
       
   282         // Prepare code segment list
       
   283         iList = iEngine.HelperCodeSegment().CodeSegmentListL();
       
   284         iList->SortByCodeSizeL();
       
   285         }
       
   286 
       
   287     // Finish construction
       
   288     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
   289 
       
   290     if  ( aSelectionRune != NULL )
       
   291         {
       
   292         iCurrentCodeSegment = reinterpret_cast< CMemSpyEngineCodeSegEntry* >( aSelectionRune );
       
   293         const TInt index = iList->ItemIndex( *iCurrentCodeSegment );
       
   294         iListBox->SetCurrentItemIndex( index );
       
   295         HandleListBoxItemSelectedL( index );
       
   296         }
       
   297 
       
   298     iListBox->DrawDeferred();
       
   299     }
       
   300 
       
   301 
       
   302 TMemSpyViewType CMemSpyViewCodeSegList::ViewType() const
       
   303     {
       
   304     return EMemSpyViewTypeCodeSegmentList;
       
   305     }
       
   306 
       
   307 
       
   308 CMemSpyViewBase* CMemSpyViewCodeSegList::PrepareParentViewL()
       
   309     {
       
   310     CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
       
   311     CleanupStack::PushL( parent );
       
   312     parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
       
   313     CleanupStack::Pop( parent );
       
   314     return parent;
       
   315     }
       
   316 
       
   317 
       
   318 CMemSpyViewBase* CMemSpyViewCodeSegList::PrepareChildViewL()
       
   319     {
       
   320     CMemSpyViewBase* child = new(ELeave) CMemSpyViewCodeSegDetails( iEngine, iObserver, *iList, *iCurrentCodeSegment );
       
   321 
       
   322     // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
       
   323     // This object is about to die in any case.
       
   324     iList = NULL;
       
   325 
       
   326     CleanupStack::PushL( child );
       
   327     child->ConstructL( Rect(), *Parent() );
       
   328     CleanupStack::Pop( child );
       
   329     return child;
       
   330     }
       
   331 
       
   332 
       
   333 void CMemSpyViewCodeSegList::SetListBoxModelL()
       
   334     {
       
   335     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   336     listbox->Model()->SetItemTextArray( iList );
       
   337     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   338     }
       
   339 
       
   340 
       
   341 void CMemSpyViewCodeSegList::HandleListBoxItemActionedL( TInt aIndex )
       
   342     {
       
   343     const TInt count = iList->Count();
       
   344     if  ( aIndex >= 0 && aIndex < count )
       
   345         {
       
   346         CMemSpyEngineCodeSegEntry& codeSeg = iList->At( aIndex );
       
   347         iCurrentCodeSegment = &codeSeg;
       
   348         }
       
   349     else
       
   350         {
       
   351         iCurrentCodeSegment = NULL;
       
   352         }
       
   353 
       
   354     // Notify observer about item selection
       
   355     ReportEventL( MMemSpyViewObserver::EEventItemActioned );
       
   356     }
       
   357 
       
   358 
       
   359 void CMemSpyViewCodeSegList::HandleListBoxItemSelectedL( TInt aIndex )
       
   360     {
       
   361     const TInt count = iList->Count();
       
   362     if  ( aIndex >= 0 && aIndex < count )
       
   363         {
       
   364         CMemSpyEngineCodeSegEntry& codeSeg = iList->At( aIndex );
       
   365         iCurrentCodeSegment = &codeSeg;
       
   366         }
       
   367     else
       
   368         {
       
   369         iCurrentCodeSegment = NULL;
       
   370         }
       
   371 
       
   372     // Notify observer about item selection
       
   373     ReportEventL( MMemSpyViewObserver::EEventItemSelected );
       
   374     }
       
   375 
       
   376 
       
   377 
       
   378 
       
   379 
       
   380 
       
   381 
       
   382 
       
   383 
       
   384 
       
   385 
       
   386 
       
   387 
       
   388 
       
   389 
       
   390 
       
   391 
       
   392 
       
   393 
       
   394 
       
   395 
       
   396 
       
   397 
       
   398 
       
   399 
       
   400 
       
   401 
       
   402 
       
   403 
       
   404 
       
   405 
       
   406 
       
   407 
       
   408 
       
   409 
       
   410 CMemSpyViewCodeSegDetails::CMemSpyViewCodeSegDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList& aList, CMemSpyEngineCodeSegEntry& aSelectedCodeSegment )
       
   411 :   CMemSpyViewCodeSegBase( aEngine, aObserver, &aList ), iCodeSegment( aSelectedCodeSegment )
       
   412     {
       
   413     }
       
   414 
       
   415 
       
   416 void CMemSpyViewCodeSegDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
   417     {
       
   418     _LIT( KTitle, "Code Segment Details" );
       
   419     SetTitleL( KTitle );
       
   420 
       
   421     // Finish construction
       
   422     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
   423     }
       
   424 
       
   425 
       
   426 void CMemSpyViewCodeSegDetails::RefreshL()
       
   427     {
       
   428     SetListBoxModelL();
       
   429     CMemSpyViewBase::RefreshL();
       
   430     }
       
   431 
       
   432 
       
   433 TMemSpyViewType CMemSpyViewCodeSegDetails::ViewType() const
       
   434     {
       
   435     return EMemSpyViewTypeCodeSegmentDetails;
       
   436     }
       
   437 
       
   438 
       
   439 CMemSpyViewBase* CMemSpyViewCodeSegDetails::PrepareParentViewL()
       
   440     {
       
   441     CMemSpyViewCodeSegList* parent = new(ELeave) CMemSpyViewCodeSegList( iEngine, iObserver, *iList );
       
   442 
       
   443     // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
       
   444     // This object is about to die in any case.
       
   445     iList = NULL;
       
   446 
       
   447     CleanupStack::PushL( parent );
       
   448     parent->ConstructL( Rect(), *Parent(), &iCodeSegment );
       
   449     CleanupStack::Pop( parent );
       
   450     return parent;
       
   451     }
       
   452 
       
   453 
       
   454 void CMemSpyViewCodeSegDetails::SetListBoxModelL()
       
   455     {
       
   456     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   457     listbox->Model()->SetItemTextArray( &iCodeSegment );
       
   458     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   459     }
       
   460 
       
   461 
       
   462 
       
   463 
       
   464 
       
   465 
       
   466 
       
   467 
       
   468 
       
   469 
       
   470 
       
   471 
       
   472 
       
   473 
       
   474 
       
   475 
       
   476 
       
   477 
       
   478 
       
   479 
       
   480 
       
   481 TBool TMemSpyViewCodeSegFilter::FilterItem( const CMemSpyEngineCodeSegEntry*& aItem, TAny* aRune )
       
   482     {
       
   483     TMemSpyViewCodeSegFilter* self = reinterpret_cast< TMemSpyViewCodeSegFilter* >( aRune );
       
   484 
       
   485     TBool match = aItem->HasCapability( self->iCapability );
       
   486     if  ( match && self->iAllBinaries == EFalse )
       
   487         {
       
   488         // We're only looking for EXE's...
       
   489         TParsePtrC parser( aItem->FileName() );
       
   490         const TPtrC pExtension( parser.Ext() );
       
   491         _LIT(KProcessExtension, ".exe");
       
   492         //
       
   493         match = ( pExtension.CompareF( KProcessExtension ) == 0 );
       
   494         }
       
   495     //
       
   496     return match;
       
   497     }
       
   498 
       
   499 
       
   500