memspyui/ui/avkon/src/MemSpyViewServerList.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 "MemSpyViewServerList.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/memspyenginehelperprocess.h>
       
    28 #include <memspy/engine/memspyenginehelperheap.h>
       
    29 #include <memspy/engine/memspyenginehelperserver.h>
       
    30 
       
    31 // User includes
       
    32 #include "MemSpyUiUtils.h"
       
    33 #include "MemSpyViewMainMenu.h"
       
    34 #include "MemSpyViewThreads.h"
       
    35 #include "MemSpyContainerObserver.h"
       
    36 
       
    37 
       
    38 
       
    39 
       
    40 CMemSpyViewServerList::CMemSpyViewServerList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
       
    41 :   CMemSpyViewBase( aEngine, aObserver )
       
    42     {
       
    43     }
       
    44 
       
    45 
       
    46 CMemSpyViewServerList::~CMemSpyViewServerList()
       
    47     {
       
    48     delete iList;
       
    49     }
       
    50 
       
    51 
       
    52 void CMemSpyViewServerList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
    53     {
       
    54     _LIT( KTitle, "Running Servers" );
       
    55     SetTitleL( KTitle );
       
    56     //
       
    57     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
    58     }
       
    59 
       
    60 
       
    61 TBool CMemSpyViewServerList::HandleCommandL( TInt aCommand )
       
    62     {
       
    63     TBool handled = ETrue;
       
    64     //
       
    65     switch ( aCommand )
       
    66         {
       
    67     case EMemSpyCmdServerListSortByName:
       
    68         OnCmdServerListSortByNameL();
       
    69         break;
       
    70     case EMemSpyCmdServerListSortBySessionCount:
       
    71         OnCmdServerListSortBySessionCountL();
       
    72         break;
       
    73     case EMemSpyCmdServerListOutputListCSV:
       
    74         OnCmdServerListOutputSummaryL();
       
    75         break;
       
    76     case EMemSpyCmdServerListOutputListDetailed:
       
    77         OnCmdServerListOutputDetailedL();
       
    78         break;
       
    79 
       
    80     default:
       
    81         handled = CMemSpyViewBase::HandleCommandL( aCommand );
       
    82         break;
       
    83         }
       
    84     //
       
    85     return handled;
       
    86     }
       
    87 
       
    88 
       
    89 void CMemSpyViewServerList::RefreshL()
       
    90     {
       
    91     SetListBoxModelL();
       
    92     CMemSpyViewBase::RefreshL();
       
    93     }
       
    94 
       
    95 
       
    96 TMemSpyViewType CMemSpyViewServerList::ViewType() const
       
    97     {
       
    98     return EMemSpyViewTypeServerList;
       
    99     }
       
   100 
       
   101 
       
   102 CMemSpyViewBase* CMemSpyViewServerList::PrepareParentViewL()
       
   103     {
       
   104     CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
       
   105     CleanupStack::PushL( parent );
       
   106     parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
       
   107     CleanupStack::Pop( parent );
       
   108     return parent;
       
   109     }
       
   110 
       
   111 
       
   112 CMemSpyViewBase* CMemSpyViewServerList::PrepareChildViewL()
       
   113     {
       
   114     CMemSpyViewBase* child = NULL;
       
   115 
       
   116     // First, try to find the selected thread
       
   117     if  ( iActionedItem )
       
   118         {
       
   119         // Try to create a view of the thread in question
       
   120         CMemSpyProcess* process = NULL;
       
   121         CMemSpyThread* thread = NULL;
       
   122         //
       
   123         const TInt error = iEngine.Container().ProcessAndThreadByThreadId( iActionedItem->Id(), process, thread );
       
   124         //
       
   125         if  ( error == KErrNone && thread != NULL )
       
   126             {
       
   127             child = new(ELeave) CMemSpyViewThreads( iEngine, iObserver, thread->Process() );
       
   128             CleanupStack::PushL( child );
       
   129             child->ConstructL( Rect(), *Parent(), thread );
       
   130             CleanupStack::Pop( child );
       
   131             }
       
   132         }
       
   133     //
       
   134     return child;
       
   135     }
       
   136 
       
   137 
       
   138 void CMemSpyViewServerList::SetListBoxModelL()
       
   139     {
       
   140     delete iList;
       
   141     iList = NULL;
       
   142     iList = iEngine.HelperServer().ServerListL();
       
   143     //
       
   144     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   145     listbox->Model()->SetItemTextArray( iList );
       
   146     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   147     }
       
   148 
       
   149 
       
   150 void CMemSpyViewServerList::HandleListBoxItemActionedL( TInt aCurrentIndex )
       
   151     {
       
   152     if  ( aCurrentIndex >= 0 && aCurrentIndex < iList->Count() )
       
   153         {
       
   154         const CMemSpyEngineServerEntry& serverInfo = iList->At( aCurrentIndex );
       
   155         iActionedItem = &serverInfo;
       
   156         }
       
   157     else
       
   158         {
       
   159         iActionedItem = NULL;
       
   160         }
       
   161 
       
   162     // Notify observer about an item being 'fired'
       
   163     ReportEventL( MMemSpyViewObserver::EEventItemActioned );
       
   164     }
       
   165 
       
   166 
       
   167 void CMemSpyViewServerList::OnCmdServerListSortByNameL()
       
   168     {
       
   169     iList->SortByNameL();
       
   170     CMemSpyViewBase::RefreshL();
       
   171     }
       
   172 
       
   173 
       
   174 void CMemSpyViewServerList::OnCmdServerListSortBySessionCountL()
       
   175     {
       
   176     iList->SortBySessionCountL();
       
   177     CMemSpyViewBase::RefreshL();
       
   178     }
       
   179 
       
   180 
       
   181 void CMemSpyViewServerList::OnCmdServerListOutputSummaryL()
       
   182     {
       
   183     OnCmdServerListOutputGenericL( EFalse );
       
   184     }
       
   185 
       
   186 
       
   187 void CMemSpyViewServerList::OnCmdServerListOutputDetailedL()
       
   188     {
       
   189     OnCmdServerListOutputGenericL( ETrue );
       
   190     }
       
   191 
       
   192 
       
   193 void CMemSpyViewServerList::OnCmdServerListOutputGenericL( TBool aDetailed )
       
   194     {
       
   195     // Begin a new data stream
       
   196     _LIT( KMemSpyContext, "Server List - " );
       
   197     _LIT( KMemSpyFolder, "Servers" );
       
   198     iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
       
   199 
       
   200     // Set prefix for overall listing
       
   201     iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
       
   202 
       
   203     // Create header
       
   204     CMemSpyEngineServerList::OutputDataColumnsL( iEngine, aDetailed );
       
   205     
       
   206     // List items
       
   207     const TInt count = iList->Count();
       
   208     for(TInt i=0; i<count; i++)
       
   209         {
       
   210         const CMemSpyEngineServerEntry& server = iList->At( i );
       
   211         //
       
   212         server.OutputDataL( iEngine.HelperServer(), aDetailed );
       
   213         }
       
   214 
       
   215     // Tidy up
       
   216     CleanupStack::PopAndDestroy(); // prefix
       
   217  
       
   218     // End data stream
       
   219     iEngine.Sink().DataStreamEndL();
       
   220     }
       
   221 
       
   222 
       
   223 
       
   224 
       
   225 
       
   226 
       
   227