memspyui/source/MemSpyViewKernelObjects.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 "MemSpyViewKernelObjects.h"
       
    19 
       
    20 // System includes
       
    21 #include <eikspane.h>
       
    22 #include <aknnavide.h> 
       
    23 #include <akntabgrp.h>
       
    24 #include <eikclbd.h>
       
    25 #include <AknQueryDialog.h>
       
    26 #include <aknnotewrappers.h>
       
    27 #include <apgwgnam.h>
       
    28 #include <aknmessagequerydialog.h>
       
    29 
       
    30 // Engine includes
       
    31 #include <memspy/engine/memspyengine.h>
       
    32 #include <memspy/engine/memspyengineobjectprocess.h>
       
    33 #include <memspy/engine/memspyengineobjectthread.h>
       
    34 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    35 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
       
    36 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
       
    37 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
       
    38 #include <memspy/engine/memspyenginehelperserver.h>
       
    39 #include <memspy/engine/memspyenginehelpercondvar.h>
       
    40 
       
    41 // User includes
       
    42 #include "MemSpyUiUtils.h"
       
    43 #include "MemSpyViewKernel.h"
       
    44 #include "MemSpyContainerObserver.h"
       
    45 #include "MemSpyViewKernelContainers.h"
       
    46 
       
    47 const TInt KMaxInfoLength = 128;
       
    48 
       
    49 CMemSpyViewKernelObjects::CMemSpyViewKernelObjects( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TMemSpyDriverContainerType aObjectType )
       
    50 :   CMemSpyViewBase( aEngine, aObserver ),
       
    51     iObjectType( aObjectType ),
       
    52     iCurrItemIndex( KErrNotFound )
       
    53     {
       
    54     }
       
    55 
       
    56 
       
    57 CMemSpyViewKernelObjects::~CMemSpyViewKernelObjects()
       
    58     {
       
    59     if ( iNavContainer && iNavDecorator )
       
    60         {
       
    61         iNavContainer->Pop( iNavDecorator );
       
    62         delete iNavDecorator;
       
    63         }
       
    64     delete iModel;
       
    65     delete iItems;
       
    66     delete iObjectList;
       
    67     }
       
    68 
       
    69 
       
    70 void CMemSpyViewKernelObjects::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
    71     {
       
    72     _LIT( KTitle, "Kernel Objects" );
       
    73     SetTitleL( KTitle );
       
    74     iItems = new(ELeave) CDesCArrayFlat(5);
       
    75     //
       
    76     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
    77     CreateTabsL();
       
    78     }
       
    79 
       
    80 
       
    81 CEikListBox* CMemSpyViewKernelObjects::ConstructListBoxL()
       
    82     {
       
    83     delete iListBox;
       
    84     iListBox = NULL;
       
    85     CAknSingleStyleListBox* listbox = new (ELeave) CAknSingleStyleListBox();
       
    86     iListBox = listbox;
       
    87     listbox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
       
    88     listbox->SetContainerWindowL( *this );
       
    89     listbox->CreateScrollBarFrameL( ETrue );
       
    90     SetListBoxModelL();
       
    91     listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
    92     listbox->SetListBoxObserver( this );
       
    93     listbox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
       
    94     listbox->SetObserver( this );
       
    95     return listbox;
       
    96     }
       
    97 
       
    98 
       
    99 void CMemSpyViewKernelObjects::RefreshL()
       
   100     {
       
   101     SetListBoxModelL();
       
   102     CMemSpyViewBase::RefreshL();
       
   103     }
       
   104 
       
   105 
       
   106 TMemSpyViewType CMemSpyViewKernelObjects::ViewType() const
       
   107     {
       
   108     return EMemSpyViewTypeKernelObjects;
       
   109     }
       
   110 
       
   111 
       
   112 CMemSpyViewBase* CMemSpyViewKernelObjects::PrepareParentViewL()
       
   113     {
       
   114     if ( iNavContainer && iNavDecorator )
       
   115         {
       
   116         iNavContainer->Pop( iNavDecorator );
       
   117         delete iNavDecorator;
       
   118         iNavDecorator = NULL;
       
   119         }
       
   120     CMemSpyViewBase* parent = new(ELeave) CMemSpyViewKernelContainers( iEngine, iObserver );
       
   121     CleanupStack::PushL( parent );
       
   122     parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
       
   123     CleanupStack::Pop( parent );
       
   124     return parent;
       
   125     }
       
   126 
       
   127 
       
   128 CMemSpyViewBase* CMemSpyViewKernelObjects::PrepareChildViewL()
       
   129     {
       
   130     CMemSpyViewBase* child = NULL;
       
   131     if ( iListBox && 
       
   132          iListBox->Model()->NumberOfItems() && 
       
   133          iListBox->CurrentItemIndex() > KErrNotFound )
       
   134         {
       
   135         DetailsL();
       
   136         }
       
   137     return child;
       
   138     }
       
   139 
       
   140 
       
   141 void CMemSpyViewKernelObjects::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   142     {
       
   143     if  ( aResourceId == R_MEMSPY_MENUPANE )
       
   144        {
       
   145        if ( iObjectType > EMemSpyDriverContainerTypeProcess )
       
   146            {
       
   147            // Display Terminate, Switch to, End and Panic
       
   148            // commands only for Threads and processes
       
   149            aMenuPane->SetItemDimmed( EMemSpyCmdKernelObjects, ETrue );
       
   150            }
       
   151         }
       
   152     }
       
   153 
       
   154 
       
   155 void CMemSpyViewKernelObjects::SetListBoxModelL()
       
   156     {
       
   157     _LIT( KLineFormatSpec, "\t%S" );
       
   158     
       
   159     // Take ownership of new model
       
   160     CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
       
   161     CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL();
       
   162     
       
   163     delete iModel;
       
   164     iModel = model;
       
   165     
       
   166     iItems->Reset();
       
   167     delete iObjectList;
       
   168     iObjectList = NULL;
       
   169     iObjectList = kernelContainerManager.ObjectsForSpecificContainerL( iObjectType );
       
   170     
       
   171     // TODO: CMemSpyEngineGenericKernelObjectList could inherit MDesCArray like
       
   172     // CMemSpyEngineGenericKernelObjectContainer does. iObjectList could then be passed
       
   173     // to listbox model:
       
   174     // listbox->Model()->SetItemTextArray( iObjectList );
       
   175     
       
   176     TName item;
       
   177     TName name;
       
   178     for ( TInt i = 0; i < iObjectList->Count(); i++ )
       
   179         {
       
   180         name.Copy( iObjectList->At( i ).iName );
       
   181         item.Format( KLineFormatSpec, &name );
       
   182         iItems->AppendL( item );
       
   183         }
       
   184     
       
   185     // Set up list box
       
   186     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   187     listbox->Model()->SetItemTextArray( iItems );
       
   188     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   189     }
       
   190 
       
   191 
       
   192 TBool CMemSpyViewKernelObjects::HandleCommandL( TInt aCommand )
       
   193     {
       
   194     TBool handled = ETrue;
       
   195     //
       
   196     switch ( aCommand )
       
   197         {
       
   198         case EMemSpyCmdKernelObjectTerminate:
       
   199             {
       
   200             TRAPD( err, OnCmdTerminateL() );
       
   201             if ( err )
       
   202                 {
       
   203                 CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
       
   204                 note->ExecuteLD( _L("Cannot terminate task") );
       
   205                 }
       
   206             break;
       
   207             }
       
   208         case EMemSpyCmdKernelObjectSwitchTo:
       
   209             {
       
   210             TRAPD( err, OnCmdSwitchToL() );
       
   211             if ( err )
       
   212                 {
       
   213                 CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
       
   214                 note->ExecuteLD( _L("Cannot bring to foreground") );
       
   215                 }
       
   216             break;
       
   217             }
       
   218         case EMemSpyCmdKernelObjectEnd:
       
   219             {
       
   220             TRAPD( err, OnCmdEndL() );
       
   221             if ( err )
       
   222                 {
       
   223                 CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
       
   224                 note->ExecuteLD( _L("Cannot end task") );
       
   225                 }
       
   226             break;
       
   227             }
       
   228         case EMemSpyCmdKernelObjectPanic:
       
   229             {
       
   230             TRAPD( err, OnCmdPanicL() );
       
   231             if ( err )
       
   232                 {
       
   233                 CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
       
   234                 note->ExecuteLD( _L("Cannot panic task") );
       
   235                 }
       
   236             break;
       
   237             }
       
   238         default:
       
   239             {
       
   240             handled = CMemSpyViewBase::HandleCommandL( aCommand );
       
   241             break;        
       
   242             }
       
   243         }
       
   244     //
       
   245     return handled;
       
   246     }
       
   247 
       
   248 
       
   249 TKeyResponse CMemSpyViewKernelObjects::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   250     {
       
   251     TKeyResponse resp = EKeyWasNotConsumed;
       
   252     if  ( iTabs && ( aKeyEvent.iScanCode == EStdKeyRightArrow || aKeyEvent.iScanCode == EStdKeyLeftArrow ) )
       
   253         {
       
   254         resp = iTabs->OfferKeyEventL( aKeyEvent, aType );
       
   255         }
       
   256     else
       
   257         {
       
   258         resp = CMemSpyViewBase::OfferKeyEventL( aKeyEvent, aType );    
       
   259         }
       
   260     return resp;
       
   261     }
       
   262 
       
   263 
       
   264 void CMemSpyViewKernelObjects::TabChangedL( TInt /*aIndex*/ )
       
   265     {
       
   266     iObjectType = (TMemSpyDriverContainerType)iTabs->ActiveTabId();
       
   267     RefreshL();
       
   268     }
       
   269 
       
   270 
       
   271 void CMemSpyViewKernelObjects::OnCmdTerminateL()
       
   272     {
       
   273     switch ( iObjectType )
       
   274         {
       
   275         case EMemSpyDriverContainerTypeThread:
       
   276             {
       
   277             TBool doTerminate = ETrue;
       
   278             
       
   279             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   280             TThreadId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   281             
       
   282             // Try to find the thread in question...
       
   283             CMemSpyProcess* process = NULL;
       
   284             CMemSpyThread* thread = NULL; 
       
   285             User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
       
   286 
       
   287             if ( thread )
       
   288                 {
       
   289                 thread->Open();
       
   290                 //
       
   291                 if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
       
   292                     {
       
   293                     CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
       
   294                     doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
       
   295                     }
       
   296                 //
       
   297                 if  ( doTerminate )
       
   298                     {
       
   299                     thread->TerminateL();
       
   300                     }                
       
   301                 }
       
   302             RefreshL();
       
   303             break;
       
   304             }
       
   305         case EMemSpyDriverContainerTypeProcess:
       
   306             {
       
   307             TBool doTerminate = ETrue;
       
   308             // Obtain the process that corresponds to the selected item
       
   309             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   310             TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   311             CMemSpyProcess& process = container.ProcessByIdL( id );
       
   312             process.Open();
       
   313 
       
   314             if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
       
   315                 {
       
   316                 CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
       
   317                 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
       
   318                 }
       
   319             //
       
   320             if  ( doTerminate )
       
   321                 {
       
   322                 process.TerminateL();
       
   323                 RefreshL();
       
   324                 }
       
   325             break;
       
   326             }
       
   327         default:
       
   328             {
       
   329             // Programming error
       
   330             __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
       
   331             }
       
   332         }
       
   333     }
       
   334 
       
   335 
       
   336 void CMemSpyViewKernelObjects::OnCmdSwitchToL()
       
   337     {
       
   338     TInt wgCount;
       
   339     RWsSession wsSession;
       
   340     User::LeaveIfError( wsSession.Connect() );
       
   341     CleanupClosePushL( wsSession );
       
   342     User::LeaveIfError( wgCount = wsSession.NumWindowGroups() );
       
   343     RArray<RWsSession::TWindowGroupChainInfo> wgArray;
       
   344     CleanupClosePushL( wgArray );
       
   345     User::LeaveIfError( wsSession.WindowGroupList( &wgArray ) );
       
   346     TApaTask task( wsSession );
       
   347     TBool brought( EFalse );
       
   348     TInt wgId( KErrNotFound );
       
   349     TThreadId threadId;
       
   350     switch ( iObjectType )
       
   351         {
       
   352         case EMemSpyDriverContainerTypeThread:
       
   353             {
       
   354             TThreadId currentThreadId( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   355             
       
   356             // loop trough all window groups and see if a thread id matches
       
   357             while( !brought && wgCount-- )
       
   358                 {
       
   359                 wgId = wgArray[wgCount].iId;
       
   360                 User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
       
   361                 if ( threadId == currentThreadId )
       
   362                     {
       
   363                     CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
       
   364                     task.SetWgId( wgId );
       
   365                     if ( !wgName->Hidden() && task.Exists() )
       
   366                         {
       
   367                         task.BringToForeground();
       
   368                         brought = ETrue;                        
       
   369                         }
       
   370                     CleanupStack::PopAndDestroy( wgName );
       
   371                     }
       
   372                 }                
       
   373             break;
       
   374             }
       
   375         case EMemSpyDriverContainerTypeProcess:
       
   376             {
       
   377             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   378             TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   379             CMemSpyProcess& process = container.ProcessByIdL( id );
       
   380             
       
   381             // loop trough threads in a process
       
   382             for ( TInt i = 0; i < process.MdcaCount(); i++ )
       
   383                 {
       
   384                 TInt wgCountLocal = wgCount;
       
   385                 
       
   386                 // loop trough all window groups and see if a thread id matches
       
   387                 while( !brought && wgCountLocal-- )
       
   388                     {
       
   389                     wgId = wgArray[wgCountLocal].iId;
       
   390                     User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
       
   391                     if ( threadId == process.At( i ).Id() )
       
   392                         {
       
   393                         CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
       
   394                         task.SetWgId( wgId );
       
   395                         if ( !wgName->Hidden() && task.Exists() )
       
   396                             {
       
   397                             task.BringToForeground();
       
   398                             brought = ETrue;                        
       
   399                             }
       
   400                         CleanupStack::PopAndDestroy( wgName );
       
   401                         }
       
   402                     }
       
   403                 }
       
   404 
       
   405             break;
       
   406             }
       
   407         default:
       
   408             {
       
   409             // Programming error
       
   410             __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
       
   411             }
       
   412         }
       
   413     if ( !brought )
       
   414         {
       
   415         // Error handling in HandleCommandL
       
   416         User::Leave( KErrGeneral );
       
   417         }
       
   418     CleanupStack::PopAndDestroy( 2 ); //wgArray,wsSession
       
   419     }
       
   420 
       
   421 
       
   422 void CMemSpyViewKernelObjects::OnCmdEndL()
       
   423     {
       
   424     switch ( iObjectType )
       
   425         {
       
   426         case EMemSpyDriverContainerTypeThread:
       
   427             {
       
   428             TBool doTerminate = ETrue;
       
   429             
       
   430             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   431             TThreadId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   432             
       
   433             // Try to find the thread in question...
       
   434             CMemSpyProcess* process = NULL;
       
   435             CMemSpyThread* thread = NULL; 
       
   436             User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
       
   437 
       
   438             if ( thread )
       
   439                 {
       
   440                 thread->Open();
       
   441                 //
       
   442                 if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
       
   443                     {
       
   444                     CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
       
   445                     doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
       
   446                     }
       
   447                 //
       
   448                 if  ( doTerminate )
       
   449                     {
       
   450                     thread->KillL();
       
   451                     }                
       
   452                 }
       
   453             RefreshL();
       
   454             break;
       
   455             }
       
   456         case EMemSpyDriverContainerTypeProcess:
       
   457             {
       
   458             TBool doTerminate = ETrue;
       
   459             // Obtain the process that corresponds to the selected item
       
   460             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   461             TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   462             CMemSpyProcess& process = container.ProcessByIdL( id );
       
   463             process.Open();
       
   464 
       
   465             if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
       
   466                 {
       
   467                 CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
       
   468                 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
       
   469                 }
       
   470             if  ( doTerminate )
       
   471                 {
       
   472                 process.KillL();
       
   473                 RefreshL();
       
   474                 }
       
   475 
       
   476             break;
       
   477             }
       
   478         default:
       
   479             {
       
   480             // Programming error
       
   481             __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
       
   482             }
       
   483         }    
       
   484     }
       
   485 
       
   486 
       
   487 void CMemSpyViewKernelObjects::OnCmdPanicL()
       
   488     {
       
   489     switch ( iObjectType )
       
   490         {
       
   491         case EMemSpyDriverContainerTypeThread:
       
   492             {
       
   493             TBool doTerminate = ETrue;
       
   494             
       
   495             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   496             TThreadId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   497             
       
   498             // Try to find the thread in question...
       
   499             CMemSpyProcess* process = NULL;
       
   500             CMemSpyThread* thread = NULL; 
       
   501             User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
       
   502 
       
   503             if ( thread )
       
   504                 {
       
   505                 thread->Open();
       
   506                 //
       
   507                 if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
       
   508                     {
       
   509                     CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
       
   510                     doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
       
   511                     }
       
   512                 //
       
   513                 if  ( doTerminate )
       
   514                     {
       
   515                     thread->PanicL();
       
   516                     }                
       
   517                 }
       
   518             RefreshL();
       
   519             break;
       
   520             }
       
   521         case EMemSpyDriverContainerTypeProcess:
       
   522             {
       
   523             TBool doTerminate = ETrue;
       
   524             // Obtain the process that corresponds to the selected item
       
   525             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   526             TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
       
   527             CMemSpyProcess& process = container.ProcessByIdL( id );
       
   528             process.Open();
       
   529 
       
   530             if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
       
   531                 {
       
   532                 CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
       
   533                 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
       
   534                 }
       
   535             if  ( doTerminate )
       
   536                 {
       
   537                 process.PanicL();
       
   538                 RefreshL();
       
   539                 }
       
   540             break;
       
   541             }
       
   542         default:
       
   543             {
       
   544             // Programming error
       
   545             __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
       
   546             }
       
   547         }
       
   548     }
       
   549 
       
   550 
       
   551 void CMemSpyViewKernelObjects::CreateTabsL()
       
   552     {
       
   553     CEikStatusPane* statusPane = static_cast<CAknAppUi*> ( iEikonEnv->EikAppUi() )->StatusPane();
       
   554     TUid uid;
       
   555     uid.iUid = EEikStatusPaneUidNavi;
       
   556     iNavDecorator = ((CAknNavigationControlContainer*)(statusPane->ControlL(uid)))->Top();
       
   557 
       
   558     if ( !iNavDecorator )
       
   559         {
       
   560         iNavContainer = (CAknNavigationControlContainer*)statusPane->ControlL(uid);
       
   561         iNavDecorator = iNavContainer->CreateTabGroupL();
       
   562 
       
   563         iTabs = ( CAknTabGroup* )iNavDecorator->DecoratedControl();
       
   564         iTabs->SetTabFixedWidthL( KTabWidthWithThreeLongTabs );
       
   565     
       
   566         for ( TInt i = 0; i < iModel->Count(); i++ )
       
   567             {
       
   568             const CMemSpyEngineGenericKernelObjectList& item = iModel->At( i );
       
   569             iTabs->AddTabL( item.Type(), item.TypeAsString( item.Type() ) );
       
   570             }
       
   571         iTabs->SetActiveTabById( iObjectType );
       
   572         iTabs->SetObserver( this );
       
   573         iNavContainer->PushL( *iNavDecorator );
       
   574         }
       
   575     }
       
   576 
       
   577 
       
   578 void CMemSpyViewKernelObjects::DetailsL()
       
   579     {
       
   580     HBufC* messageBuf = HBufC::NewLC( 40960 );
       
   581     TPtr messagePtr = messageBuf->Des();
       
   582 
       
   583     const TMemSpyDriverHandleInfoGeneric& selectedObject = iObjectList->At( iListBox->CurrentItemIndex() );
       
   584 
       
   585     // General attributes:
       
   586     TFullName name;
       
   587     name.Copy( selectedObject.iNameDetail );
       
   588     AppendFormatString( messagePtr, _L("Name: %S\n"), &name );
       
   589     name.Zero();
       
   590     name.Copy( selectedObject.iName );
       
   591     AppendFormatString( messagePtr, _L("FullName: %S\n"), &name );
       
   592     name.Zero();
       
   593     AppendFormatString( messagePtr, _L("AccessCount: %d\n"), selectedObject.iAccessCount );
       
   594     AppendFormatString( messagePtr, _L("UniqueID: %d\n"), selectedObject.iUniqueID );
       
   595     AppendFormatString( messagePtr, _L("Protection: %u\n"), selectedObject.iProtection );
       
   596     AppendFormatString( messagePtr, _L("OwnrAddr: 0x%08X\n"), selectedObject.iAddressOfKernelOwner );
       
   597     AppendFormatString( messagePtr, _L("KernelAddr: 0x%08X"), selectedObject.iHandle );
       
   598     
       
   599     // Object type specific attributes:
       
   600     switch ( selectedObject.iType )
       
   601         {
       
   602         case EMemSpyDriverContainerTypeUnknown:
       
   603             {
       
   604             break;
       
   605             }
       
   606         case EMemSpyDriverContainerTypeThread:
       
   607             {
       
   608             AppendFormatString( messagePtr, _L("\nOwnrPrAddr: 0x%08X\n"), selectedObject.iAddressOfOwningProcess );
       
   609             AppendFormatString( messagePtr, _L("ThreadID: %d\n"), selectedObject.iId );
       
   610             AppendFormatString( messagePtr, _L("Priority: %d\n"), selectedObject.iPriority );
       
   611             TFullName procName;
       
   612             procName.Copy( selectedObject.iNameOfOwner );
       
   613             AppendFormatString( messagePtr, _L("Proc: %S"), &procName );
       
   614             procName.Zero();
       
   615             break;
       
   616             }
       
   617         case EMemSpyDriverContainerTypeProcess:
       
   618             {
       
   619             AppendFormatString( messagePtr, _L("\nOwnrPrAddr: 0x%08X\n"), selectedObject.iAddressOfOwningProcess );
       
   620             AppendFormatString( messagePtr, _L("CreatorId: %u\n"), selectedObject.iCreatorId );
       
   621             AppendFormatString( messagePtr, _L("Attributes: 0x%08X\n"), selectedObject.iAttributes );
       
   622             AppendFormatString( messagePtr, _L("StckChnk: 0x%08X\n"), selectedObject.iAddressOfDataBssStackChunk );
       
   623             AppendFormatString( messagePtr, _L("ProcessID: %d\n"), selectedObject.iId );
       
   624             AppendFormatString( messagePtr, _L("Priority: %d\n"), selectedObject.iPriority );
       
   625             AppendFormatString( messagePtr, _L("SecurityZone: %d"), selectedObject.iSecurityZone );
       
   626             CMemSpyEngineObjectContainer& container = iEngine.Container();
       
   627             TProcessId id( selectedObject.iId );
       
   628             TRAP_IGNORE(
       
   629                 CMemSpyProcess& process = container.ProcessByIdL( id );
       
   630                 AppendFormatString( messagePtr, _L("\nSID: 0x%08X\n"), process.SID() );
       
   631                 AppendFormatString( messagePtr, _L("VID: 0x%08X\n"), process.VID() );
       
   632                 AppendFormatString( messagePtr, _L("UID1: 0x%08X\n"), process.UIDs()[0].iUid  );
       
   633                 AppendFormatString( messagePtr, _L("UID2: 0x%08X\n"), process.UIDs()[1].iUid  );
       
   634                 AppendFormatString( messagePtr, _L("UID3: 0x%08X\n"), process.UIDs()[2].iUid );
       
   635                 AppendFormatString( messagePtr, _L("Caps: 0x%08X%08X"), process.Capabilities().iCaps[0], process.Capabilities().iCaps[1]);
       
   636                 );
       
   637             break;
       
   638             }
       
   639         case EMemSpyDriverContainerTypeChunk:
       
   640             {
       
   641             AppendFormatString( messagePtr, _L("\nOwnrPrAddr: 0x%08X\n"), selectedObject.iAddressOfOwningProcess );
       
   642             AppendFormatString( messagePtr, _L("Size: %d\n"), selectedObject.iSize );
       
   643             AppendFormatString( messagePtr, _L("MaxSize: %d\n"), selectedObject.iMaxSize );
       
   644             AppendFormatString( messagePtr, _L("Bottom: %d\n"), selectedObject.iBottom );
       
   645             AppendFormatString( messagePtr, _L("Top: %d\n"), selectedObject.iTop );
       
   646             AppendFormatString( messagePtr, _L("Attr: 0x%08X\n"), selectedObject.iAttributes );
       
   647             AppendFormatString( messagePtr, _L("Start: %d\n"), selectedObject.iStartPos );
       
   648             AppendFormatString( messagePtr, _L("CntrlID: %u\n"), selectedObject.iControllingOwner );
       
   649             AppendFormatString( messagePtr, _L("Restrictions: %u\n"), selectedObject.iRestrictions );
       
   650             AppendFormatString( messagePtr, _L("MapAttr: %u\n"), selectedObject.iMapAttr );
       
   651             AppendFormatString( messagePtr, _L("Type: %u\n"), selectedObject.iChunkType );
       
   652             TFullName procName;
       
   653             procName.Copy( selectedObject.iNameOfOwner );
       
   654             AppendFormatString( messagePtr, _L("Proc: %S"), &procName );
       
   655             procName.Zero();
       
   656             // OwnerAddr iAddressOfKernelOwner already listed
       
   657             // ProcAddr iAddressOfOwningProcess already listed
       
   658             break;
       
   659             }
       
   660         case EMemSpyDriverContainerTypeLibrary:
       
   661             {
       
   662             AppendFormatString( messagePtr, _L("\nMapCount: %d\n"), selectedObject.iMapCount );
       
   663             AppendFormatString( messagePtr, _L("State: %u\n"), selectedObject.iState );
       
   664             AppendFormatString( messagePtr, _L("CodeSeg: 0x%08X"), selectedObject.iAddressOfCodeSeg );
       
   665             break;
       
   666             }
       
   667         case EMemSpyDriverContainerTypeSemaphore:
       
   668             {
       
   669             AppendFormatString( messagePtr, _L("\nCount: %d\n"), selectedObject.iCount );
       
   670             AppendFormatString( messagePtr, _L("Resetting: %u"), selectedObject.iResetting );
       
   671             break;
       
   672             }
       
   673         case EMemSpyDriverContainerTypeMutex:
       
   674             {
       
   675             AppendFormatString( messagePtr, _L("\nHoldCount: %d\n"), selectedObject.iCount );
       
   676             AppendFormatString( messagePtr, _L("WaitCount: %d\n"), selectedObject.iWaitCount );
       
   677             AppendFormatString( messagePtr, _L("Resetting: %u\n"), selectedObject.iResetting );
       
   678             AppendFormatString( messagePtr, _L("Order: %u"), selectedObject.iOrder );
       
   679             break;
       
   680             }
       
   681         case EMemSpyDriverContainerTypeTimer:
       
   682             {
       
   683             AppendFormatString( messagePtr, _L("\nState: %d\n"), selectedObject.iTimerState );
       
   684             AppendFormatString( messagePtr, _L("Type: %d"), selectedObject.iTimerType );
       
   685             break;
       
   686             }
       
   687         case EMemSpyDriverContainerTypeServer:
       
   688             {
       
   689             // Owner == ThrdAddr
       
   690             AppendFormatString( messagePtr, _L("\nThrdAddr: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
       
   691             TFullName thrName;
       
   692             thrName.Copy( selectedObject.iNameOfOwner );
       
   693             AppendFormatString( messagePtr, _L("Thr: %S\n"), &thrName );
       
   694             thrName.Zero();
       
   695             AppendFormatString( messagePtr, _L("Type: %d\n"), selectedObject.iSessionType );
       
   696             TBuf8<55>buf;
       
   697             RArray<TMemSpyDriverServerSessionInfo> sessions;
       
   698             CleanupClosePushL( sessions );
       
   699             iEngine.HelperServer().GetServerSessionsL( selectedObject, sessions );
       
   700             const TInt count = sessions.Count();
       
   701             for ( TInt i = 0; i < count; i++ )
       
   702                 {
       
   703                 const TMemSpyDriverServerSessionInfo& session = sessions[ i ];
       
   704                 AppendFormatString( messagePtr, _L("SessAddr: 0x%08X\n"), session.iAddress );
       
   705                 TFullName sessName;
       
   706                 sessName.Copy( session.iName );
       
   707                 AppendFormatString( messagePtr, _L("Sess: %S\n"), &sessName );
       
   708                 }
       
   709             CleanupStack::PopAndDestroy( &sessions );
       
   710             break;
       
   711             }
       
   712         case EMemSpyDriverContainerTypeSession:
       
   713             {
       
   714             // Server == SvrAddr
       
   715             AppendFormatString( messagePtr, _L("\nServer: 0x%08X\n"), selectedObject.iAddressOfServer );
       
   716             TFullName srvName;
       
   717             srvName.Copy( selectedObject.iName );
       
   718             AppendFormatString( messagePtr, _L("Srv: %S\n"), &srvName );
       
   719             srvName.Zero();
       
   720             // Session: not supported
       
   721             AppendFormatString( messagePtr, _L("AccCount: %u\n"), selectedObject.iTotalAccessCount );
       
   722             AppendFormatString( messagePtr, _L("SesType: %u\n"), selectedObject.iSessionType );
       
   723             AppendFormatString( messagePtr, _L("SvrType: %u\n"), selectedObject.iSvrSessionType );
       
   724             AppendFormatString( messagePtr, _L("MsgCount: %d\n"),  selectedObject.iMsgCount );
       
   725             AppendFormatString( messagePtr, _L("MsgLimit: %d"), selectedObject.iMsgLimit );
       
   726             break;
       
   727             }
       
   728         case EMemSpyDriverContainerTypeLogicalDevice:
       
   729             {
       
   730             AppendFormatString( messagePtr, 
       
   731                                 _L("\nVersion: %d.%d.%d\n"), 
       
   732                                 selectedObject.iVersion.iMajor,
       
   733                                 selectedObject.iVersion.iMinor,
       
   734                                 selectedObject.iVersion.iBuild );
       
   735             AppendFormatString( messagePtr, _L("ParseMask: 0x%08X\n"), selectedObject.iParseMask );
       
   736             AppendFormatString( messagePtr, _L("UnitsMask: 0x%08X\n"), selectedObject.iUnitsMask );
       
   737             AppendFormatString( messagePtr, _L("Open channels: %d"), selectedObject.iOpenChannels );
       
   738             break;
       
   739             }
       
   740         case EMemSpyDriverContainerTypePhysicalDevice:
       
   741             {
       
   742             AppendFormatString( messagePtr, 
       
   743                                 _L("\nVersion: %d.%d.%d\n"), 
       
   744                                 selectedObject.iVersion.iMajor,
       
   745                                 selectedObject.iVersion.iMinor,
       
   746                                 selectedObject.iVersion.iBuild );
       
   747             AppendFormatString( messagePtr, _L("UnitsMask: 0x%08X\n"), selectedObject.iUnitsMask );
       
   748             AppendFormatString( messagePtr, _L("CodeSeg: 0x%08X"), selectedObject.iAddressOfCodeSeg );
       
   749             break;
       
   750             }
       
   751         case EMemSpyDriverContainerTypeLogicalChannel:
       
   752             {
       
   753             // No other details
       
   754             break;
       
   755             }
       
   756         case EMemSpyDriverContainerTypeChangeNotifier:
       
   757             {
       
   758             AppendFormatString( messagePtr, _L("\nChanges: %u\n"), selectedObject.iChanges );
       
   759             // Thread == ThrdAddr
       
   760             AppendFormatString( messagePtr, _L("ThrdAddr: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
       
   761             TFullName thrName;
       
   762             thrName.Copy( selectedObject.iNameOfOwner );
       
   763             AppendFormatString( messagePtr, _L("Thr: %S"), &thrName );
       
   764             thrName.Zero();
       
   765             break;
       
   766             }
       
   767         case EMemSpyDriverContainerTypeUndertaker:
       
   768             {
       
   769             // Thread == ThrdAddr
       
   770             AppendFormatString( messagePtr, _L("\nThrdAddr: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
       
   771             TFullName thrName;
       
   772             thrName.Copy( selectedObject.iNameOfOwner );
       
   773             AppendFormatString( messagePtr, _L("Thr: %S"), &thrName );
       
   774             thrName.Zero();
       
   775             break;
       
   776             }
       
   777         case EMemSpyDriverContainerTypeMsgQueue:
       
   778             {
       
   779             // No other details
       
   780             break;
       
   781             }
       
   782         case EMemSpyDriverContainerTypePropertyRef:
       
   783             {
       
   784             /*
       
   785             Not listing details here, as propertyRef is not listed in TaskMgr.
       
   786             Following propertyRef attributes are available at engine side. 
       
   787             
       
   788             IsReady
       
   789             Type
       
   790             Category
       
   791             Key
       
   792             RefCount
       
   793             ThreadId
       
   794             CreatorSID
       
   795             */
       
   796             break;
       
   797             }
       
   798         case EMemSpyDriverContainerTypeCondVar:
       
   799             {
       
   800             AppendFormatString( messagePtr, _L("\nResetting: %u\n"), selectedObject.iResetting );
       
   801             // Using iAddressOfOwningThread for mutex
       
   802             AppendFormatString( messagePtr, _L("Mutex: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
       
   803             // Using iNameOfOwner for mutex
       
   804             TFullName mtxName;
       
   805             mtxName.Copy( selectedObject.iNameOfOwner );
       
   806             AppendFormatString( messagePtr, _L("Mtx: %S\n"), &mtxName );
       
   807             mtxName.Zero();
       
   808             AppendFormatString( messagePtr, _L("WaitCount: %d\n"), selectedObject.iWaitCount );
       
   809             
       
   810             RArray<TMemSpyDriverCondVarSuspendedThreadInfo> threads;
       
   811             CleanupClosePushL( threads );
       
   812             iEngine.HelperCondVar().GetCondVarSuspendedThreadsL( selectedObject, threads );
       
   813             const TInt count = threads.Count();
       
   814             for ( TInt i = 0; i < count; i++ )
       
   815                 {
       
   816                 const TMemSpyDriverCondVarSuspendedThreadInfo& thr = threads[ i ];
       
   817                 AppendFormatString( messagePtr, _L("SuspThrdAddr: 0x%08X\n"), thr.iAddress );
       
   818                 TFullName thrName;
       
   819                 thrName.Copy( thr.iName );
       
   820                 AppendFormatString( messagePtr, _L("Thr: %S\n"), &thrName );
       
   821                 }
       
   822             CleanupStack::PopAndDestroy( &threads );
       
   823             break;
       
   824             }
       
   825         default:
       
   826             {
       
   827             // Programming error
       
   828             __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
       
   829             }
       
   830         }
       
   831     
       
   832     CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog( CAknQueryDialog::ENoTone );
       
   833     dialog->PrepareLC( R_MEMSPY_KERNEL_OBJECT_DETAILS_DIALOG );
       
   834     TFileName headerText;
       
   835     headerText.Copy( selectedObject.iName );
       
   836     dialog->SetHeaderTextL( headerText );
       
   837     dialog->SetMessageTextL(messagePtr);
       
   838     dialog->RunLD();
       
   839     CleanupStack::PopAndDestroy( messageBuf );
       
   840     }
       
   841 
       
   842 
       
   843 void CMemSpyViewKernelObjects::AppendFormatString( TPtr& aPtr, TRefByValue<const TDesC> aFmt, ... )
       
   844     {
       
   845     TBuf<KMaxInfoLength> infoString;
       
   846     VA_LIST list;
       
   847     VA_START ( list, aFmt );
       
   848     infoString.FormatList( aFmt, list );
       
   849     aPtr.Append( infoString );
       
   850     }
       
   851