memana/analyzetoolclient/configurationappgui/src/atconfigurationappguilistboxview.cpp
changeset 2 6a82cd05fb1e
parent 1 3ff3fecb12fe
equal deleted inserted replaced
1:3ff3fecb12fe 2:6a82cd05fb1e
     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 <aknviewappui.h>
       
    19 #include <eikmenub.h>
       
    20 #include <avkon.hrh>
       
    21 #include <barsread.h>
       
    22 #include <stringloader.h>
       
    23 #include <aknlists.h>
       
    24 #include <eikenv.h>
       
    25 #include <akniconarray.h>
       
    26 #include <eikclbd.h>
       
    27 #include <akncontext.h>
       
    28 #include <akntitle.h>
       
    29 #include <eikbtgpc.h>
       
    30 #include <atconfigurationappgui.rsg>
       
    31 #include <aknmessagequerydialog.h>
       
    32 #include <aknnotewrappers.h>
       
    33 #include <apgtask.h>
       
    34 
       
    35 #include "atconfigurationappgui.hrh"
       
    36 #include "atconfigurationappguilistboxview.h"
       
    37 #include "atconfigurationappguilistbox.hrh"
       
    38 #include "atconfigurationappguilistbox.h"
       
    39 #include "atconfigurationappguiappui.h"
       
    40 #include "atlog.h"
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CATConfigurationAppGuiListBoxView::CATConfigurationAppGuiListBoxView()
       
    44 // First phase of Symbian two-phase construction.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CATConfigurationAppGuiListBoxView::CATConfigurationAppGuiListBoxView()
       
    48     {
       
    49     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::CATConfigurationAppGuiListBoxView()" );
       
    50     
       
    51     iATConfigurationAppGuiListBox = NULL;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CATConfigurationAppGuiListBoxView::~CATConfigurationAppGuiListBoxView()
       
    56 // Destructor.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CATConfigurationAppGuiListBoxView::~CATConfigurationAppGuiListBoxView()
       
    60     {
       
    61     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::~CATConfigurationAppGuiListBoxView()" );
       
    62     
       
    63     delete iATConfigurationAppGuiListBox;
       
    64     iATConfigurationAppGuiListBox = NULL;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CATConfigurationAppGuiListBoxView::NewL()
       
    69 // Symbian two-phase constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CATConfigurationAppGuiListBoxView* CATConfigurationAppGuiListBoxView::NewL()
       
    73     {
       
    74     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::NewL()" );
       
    75     
       
    76     CATConfigurationAppGuiListBoxView* self = CATConfigurationAppGuiListBoxView::NewLC();
       
    77     CleanupStack::Pop( self );
       
    78     return self;
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CATConfigurationAppGuiListBoxView::NewLC()
       
    83 // Symbian two-phase constructor.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CATConfigurationAppGuiListBoxView* CATConfigurationAppGuiListBoxView::NewLC()
       
    87     {
       
    88     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::NewLC()" );
       
    89     
       
    90     CATConfigurationAppGuiListBoxView* self = new ( ELeave ) CATConfigurationAppGuiListBoxView();
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL();
       
    93     return self;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CATConfigurationAppGuiListBoxView::ConstructL()
       
    98 // Second-phase constructor for view.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CATConfigurationAppGuiListBoxView::ConstructL()
       
   102     {
       
   103     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::ConstructL()" );
       
   104     
       
   105     BaseConstructL( R_ATCONFIGURATION_APP_GUI_LIST_BOX_ATCONFIGURATION_APP_GUI_LIST_BOX_VIEW );
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CATConfigurationAppGuiListBoxView::Id()
       
   110 // Returns The UID for this view.
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 TUid CATConfigurationAppGuiListBoxView::Id() const
       
   114     {
       
   115     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::Id()" );
       
   116     
       
   117     return TUid::Uid( EATConfigurationAppGuiListBoxViewId );
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CATConfigurationAppGuiListBoxView::HandleCommandL()
       
   122 // Handle a command for this view.
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CATConfigurationAppGuiListBoxView::HandleCommandL( TInt aCommand )
       
   126     {
       
   127     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::HandleCommandL()" );
       
   128     
       
   129     TBool commandHandled = EFalse;
       
   130     switch ( aCommand )
       
   131         { // Code to dispatch to the AknView's menu and CBA commands is generated here
       
   132         case EATConfigurationAppGuiListBoxViewVersionMenuItemCommand:
       
   133             commandHandled = HandleVersionMenuItemSelectedL( aCommand );
       
   134             break;
       
   135         case EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand:
       
   136             {
       
   137             // Listbox items are in the same order as in storage server
       
   138             // thus using current index
       
   139             if ( iATConfigurationAppGuiListBox )
       
   140                 {
       
   141                 TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
       
   142                 RArray<TATProcessInfo> processes;
       
   143                 CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
       
   144                 appUi->StorageServer().GetProcessesL( processes );
       
   145                 if ( current >= KErrNone && current < processes.Count() )
       
   146                     {
       
   147                     TUint processId = processes[ current ].iProcessId;
       
   148                     TInt64 processStartTime = processes[ current ].iStartTime;
       
   149                     appUi->SetCurrentProcessId( processId );
       
   150                     appUi->SetCurrentProcessStartTime( processStartTime );
       
   151                     AppUi()->ActivateLocalViewL( TUid::Uid( EATConfigurationAppGuiProcessViewId ) );
       
   152                     }
       
   153                 // Closes the array and frees all memory allocated to the array.
       
   154                 processes.Close();
       
   155                 }
       
   156             break;
       
   157             }
       
   158         /*case EATConfigurationAppGuiListBoxViewEnd_processMenuItemCommand:
       
   159             {
       
   160             EndProcessL( EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand );
       
   161             break;
       
   162             }*/
       
   163         case EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand:
       
   164             {
       
   165             EndProcessL( EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand );
       
   166             break;
       
   167             }
       
   168         case EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand:
       
   169             {
       
   170             EndProcessL( EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand );
       
   171             break;
       
   172             }
       
   173         case EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand:
       
   174             {
       
   175             EndProcessL( EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand );
       
   176             break;
       
   177             }
       
   178         case EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand:
       
   179             {
       
   180             EndProcessL( EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand );
       
   181             break;
       
   182             }
       
   183         case EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand:
       
   184             {
       
   185             // Listbox items are in the same order as in storage server
       
   186             // thus using current index
       
   187             if ( iATConfigurationAppGuiListBox )
       
   188                 {
       
   189                 TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
       
   190                 RArray<TATProcessInfo> processes;
       
   191                 CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
       
   192                 appUi->StorageServer().GetProcessesL( processes );
       
   193                 if ( current >= KErrNone && current < processes.Count() )
       
   194                     {
       
   195                     TUint processId = processes[ current ].iProcessId;
       
   196                     // Stop subtesting for this process
       
   197                     //if ( appUi->IsSubTestRunning( processId ) )
       
   198                         //appUi->SetProcessSubTestStopL( processId );
       
   199                     
       
   200                     TInt cancelErr = appUi->StorageServer().CancelLogging( processId );
       
   201                     if ( cancelErr != KErrNone )
       
   202                         {
       
   203                         // Logging could not be cancelled
       
   204                         appUi->ShowErrorNoteL( R_ATCONFIGURATION_APP_GUI_LISTBOX_CANCEL_FAILURE_NOTE );
       
   205                         }
       
   206                     else
       
   207                         {
       
   208                         iATConfigurationAppGuiListBox->UpdateViewL();
       
   209                         }
       
   210                     }
       
   211 				// Closes the array and frees all memory allocated to the array.
       
   212                 processes.Close();
       
   213                 }
       
   214             break;
       
   215             }
       
   216         case EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand:
       
   217             {
       
   218             AppUi()->ActivateLocalViewL( TUid::Uid( EATConfigurationAppGuiSettingItemListViewId ),
       
   219                     TUid::Uid( EATConfigurationAppGuiListBoxViewId ), KNullDesC8 );
       
   220             break;
       
   221             }
       
   222         case EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand:
       
   223             {
       
   224             if ( iATConfigurationAppGuiListBox )
       
   225                 {
       
   226                 TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
       
   227                 RArray<TATProcessInfo> processes;
       
   228                 CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
       
   229                 appUi->StorageServer().GetProcessesL( processes );
       
   230                 if ( current >= KErrNone && current < processes.Count() )
       
   231                     {
       
   232                     TUint processId = processes[ current ].iProcessId;
       
   233                     appUi->SetProcessSubTestStartL( processId );
       
   234                     iATConfigurationAppGuiListBox->UpdateViewL();
       
   235                     }
       
   236 				// Closes the array and frees all memory allocated to the array.
       
   237                 processes.Close();
       
   238                 }
       
   239             break;
       
   240             }
       
   241         case EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand:
       
   242             {
       
   243             if ( iATConfigurationAppGuiListBox )
       
   244                 {
       
   245                 TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
       
   246                 RArray<TATProcessInfo> processes;
       
   247                 CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
       
   248                 appUi->StorageServer().GetProcessesL( processes );
       
   249                 if ( current >= KErrNone && current < processes.Count() )
       
   250                     {
       
   251                     TUint processId = processes[ current ].iProcessId;
       
   252                     appUi->SetProcessSubTestStopL( processId );
       
   253                     iATConfigurationAppGuiListBox->UpdateViewL();
       
   254                     }
       
   255 				// Closes the array and frees all memory allocated to the array.
       
   256                 processes.Close();
       
   257                 }
       
   258             break;
       
   259             }
       
   260         default:
       
   261             break;
       
   262         }
       
   263      
       
   264     if ( !commandHandled ) 
       
   265         {
       
   266     
       
   267         if ( aCommand == EAknSoftkeyExit || aCommand == EAknSoftkeyExit )
       
   268             {
       
   269             AppUi()->HandleCommandL( EEikCmdExit );
       
   270             }
       
   271     
       
   272         }
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CATConfigurationAppGuiListBoxView::DoActivateL()
       
   277 // Handles user actions during activation of the view.
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 void CATConfigurationAppGuiListBoxView::DoActivateL( 
       
   281         const TVwsViewId& /*aPrevViewId*/,
       
   282         TUid /*aCustomMessageId*/,
       
   283         const TDesC8& /*aCustomMessage*/ )
       
   284     {
       
   285     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::DoActivateL()" );
       
   286     
       
   287     SetupStatusPaneL();
       
   288     
       
   289     if ( iATConfigurationAppGuiListBox == NULL )
       
   290         {
       
   291         iATConfigurationAppGuiListBox = CreateContainerL();
       
   292         iATConfigurationAppGuiListBox->SetMopParent( this );
       
   293         AppUi()->AddToStackL( *this, iATConfigurationAppGuiListBox );
       
   294         // For supporting MSK context menu
       
   295         MenuBar()->SetContextMenuTitleResourceId( R_ATCONFIGURATION_APP_GUI_LIST_BOX_OPTIONS_MENU );
       
   296         // Start update timer
       
   297         ( (CATConfigurationAppGuiAppUi*)AppUi() )->StartTimerL();
       
   298         } 
       
   299     }
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CATConfigurationAppGuiListBoxView::DoDeactivate()
       
   303 // Handles user actions during deactivation of the view.
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 void CATConfigurationAppGuiListBoxView::DoDeactivate()
       
   307     {
       
   308     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::DoDeactivate()" );
       
   309     
       
   310     CleanupStatusPane();
       
   311     
       
   312     if ( iATConfigurationAppGuiListBox != NULL )
       
   313         {
       
   314         // Cancel timer events
       
   315         TRAP_IGNORE( ( (CATConfigurationAppGuiAppUi*)AppUi() )->TimerNotifyL( EFalse ) );
       
   316         AppUi()->RemoveFromViewStack( *this, iATConfigurationAppGuiListBox );
       
   317         delete iATConfigurationAppGuiListBox;
       
   318         iATConfigurationAppGuiListBox = NULL;
       
   319         }
       
   320     CleanupStatusPane();
       
   321     }
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CATConfigurationAppGuiListBoxView::DynInitMenuPaneL()
       
   325 // Handles dynamical menu item dimming.
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 void CATConfigurationAppGuiListBoxView::DynInitMenuPaneL( TInt aResourceId, 
       
   329 	CEikMenuPane* aMenuPane )
       
   330     {
       
   331     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::DynInitMenuPaneL()" );
       
   332     
       
   333     if ( R_ATCONFIGURATION_APP_GUI_LIST_BOX_MENU_PANE1_MENU_PANE == aResourceId )
       
   334         {
       
   335         if( iATConfigurationAppGuiListBox->GetCurrentItemIndex() < 0 ) 
       
   336             {
       
   337             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand, ETrue );
       
   338             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, ETrue );
       
   339             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, ETrue );
       
   340             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewEnd_processMenuItemCommand, ETrue );
       
   341             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand, ETrue );
       
   342             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewHelpMenuItemCommand, ETrue );
       
   343             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand, ETrue );
       
   344             } 
       
   345         else 
       
   346             {
       
   347             TInt subTest( KErrNotFound );
       
   348             TATLogOption loggingMode = EATUseDefault;//lint !e644
       
   349             if ( iATConfigurationAppGuiListBox )
       
   350                 {
       
   351                 TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
       
   352                 RArray<TATProcessInfo> processes;
       
   353                 CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
       
   354                 appUi->StorageServer().GetProcessesL( processes );
       
   355                 if ( current >= KErrNone && current < processes.Count() )
       
   356                     {
       
   357                     TUint processId = processes[ current ].iProcessId;
       
   358                     subTest = appUi->IsSubTestRunning( processId );
       
   359                     // Get logging mode
       
   360                     appUi->StorageServer().GetLoggingModeL( processId, loggingMode );
       
   361                     }
       
   362 				// Closes the array and frees all memory allocated to the array.
       
   363                 processes.Close();
       
   364                 }
       
   365             if ( subTest > KErrNotFound )
       
   366                 {
       
   367                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, ETrue );
       
   368                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, EFalse );
       
   369                 }
       
   370             else
       
   371                 {
       
   372                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, EFalse );
       
   373                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, ETrue );
       
   374                 }
       
   375             
       
   376             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand, EFalse );
       
   377             
       
   378             if ( loggingMode == EATLoggingOff )
       
   379                 {
       
   380                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand, ETrue );
       
   381                 // Logging cancelled -> hide necessary items
       
   382                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand, ETrue );
       
   383                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, ETrue );
       
   384                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, ETrue );
       
   385                 }
       
   386             else
       
   387                 {
       
   388                 aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand, EFalse );
       
   389                 }
       
   390             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand, ETrue );
       
   391             aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewHelpMenuItemCommand, ETrue );
       
   392             }
       
   393         }
       
   394     }
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 // CATConfigurationAppGuiListBoxView::HandleStatusPaneSizeChange()
       
   398 // Handle status pane size change for this view.
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 void CATConfigurationAppGuiListBoxView::HandleStatusPaneSizeChange()
       
   402     {
       
   403     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::HandleStatusPaneSizeChange()" );
       
   404     
       
   405     CAknView::HandleStatusPaneSizeChange();
       
   406     
       
   407     // This may fail, but we're not able to propagate exceptions here
       
   408     TInt result;
       
   409     TRAP( result, SetupStatusPaneL() ); 
       
   410     }  
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 // CATConfigurationAppGuiListBoxView::SetupStatusPaneL()
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 void CATConfigurationAppGuiListBoxView::SetupStatusPaneL()
       
   417     {
       
   418     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::SetupStatusPaneL()" );
       
   419     
       
   420     // Reset the context pane
       
   421     TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
       
   422     CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
       
   423         StatusPane()->PaneCapabilities( contextPaneUid );
       
   424     if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
       
   425         {
       
   426         CAknContextPane* context = static_cast< CAknContextPane* > ( 
       
   427             StatusPane()->ControlL( contextPaneUid ) );
       
   428         context->SetPictureToDefaultL();
       
   429         }
       
   430     
       
   431     // Setup the title pane
       
   432     TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
       
   433     CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
       
   434         StatusPane()->PaneCapabilities( titlePaneUid );
       
   435     if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
       
   436         {
       
   437         CAknTitlePane* title = static_cast< CAknTitlePane* >( 
       
   438             StatusPane()->ControlL( titlePaneUid ) );
       
   439         TResourceReader reader;
       
   440         iEikonEnv->CreateResourceReaderLC( reader, R_ATCONFIGURATION_APP_GUI_LIST_BOX_TITLE_RESOURCE );
       
   441         title->SetFromResourceL( reader );
       
   442         CleanupStack::PopAndDestroy(); // reader internal state
       
   443         }
       
   444     }
       
   445 
       
   446 // -----------------------------------------------------------------------------
       
   447 // CATConfigurationAppGuiListBoxView::CleanupStatusPane()
       
   448 // -----------------------------------------------------------------------------
       
   449 //
       
   450 void CATConfigurationAppGuiListBoxView::CleanupStatusPane()
       
   451     {
       
   452     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::CleanupStatusPane()" );
       
   453     }
       
   454 
       
   455 // -----------------------------------------------------------------------------
       
   456 // CATConfigurationAppGuiListBoxView::CreateContainerL()
       
   457 // Creates the top-level container for the view.
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 CATConfigurationAppGuiListBox* CATConfigurationAppGuiListBoxView::CreateContainerL()
       
   461     {
       
   462     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::CreateContainerL()" );
       
   463     
       
   464     return CATConfigurationAppGuiListBox::NewL( ClientRect(), this, this );
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // CATConfigurationAppGuiListBoxView::HandleVersionMenuItemSelectedL()
       
   469 // Shows About dialog of the application.
       
   470 // -----------------------------------------------------------------------------
       
   471 //
       
   472 TBool CATConfigurationAppGuiListBoxView::HandleVersionMenuItemSelectedL( 
       
   473 	TInt /*aCommand*/ )
       
   474     {
       
   475     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::HandleVersionMenuItemSelectedL()" );
       
   476     CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog;
       
   477     dlg->ExecuteLD( R_ABOUT_HEADING_PANE );
       
   478     
       
   479     return ETrue;
       
   480     }
       
   481 
       
   482 // -----------------------------------------------------------------------------
       
   483 // CATConfigurationAppGuiListBoxView::UpdateViewL()
       
   484 // Updates view.
       
   485 // -----------------------------------------------------------------------------
       
   486 //
       
   487 void CATConfigurationAppGuiListBoxView::UpdateViewL()
       
   488     {
       
   489     LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::UpdateViewL()" );
       
   490     
       
   491     if ( iATConfigurationAppGuiListBox )
       
   492         {
       
   493         iATConfigurationAppGuiListBox->UpdateViewL();
       
   494         } 
       
   495     }
       
   496 
       
   497 // -----------------------------------------------------------------------------
       
   498 // CATConfigurationAppGuiListBoxView::EndProcessL()
       
   499 // Ends process with a specific method.
       
   500 // -----------------------------------------------------------------------------
       
   501 //
       
   502 void CATConfigurationAppGuiListBoxView::EndProcessL( TInt aCommand )
       
   503     {
       
   504     LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL" );  
       
   505                     
       
   506     TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
       
   507     RArray<TATProcessInfo> processes;
       
   508     CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
       
   509     appUi->StorageServer().GetProcessesL( processes );
       
   510      if ( current >= KErrNone && current < processes.Count() )
       
   511          {
       
   512          RProcess endProcess;
       
   513          TUint processId = processes[ current ].iProcessId;
       
   514          TBuf<KMaxProcessName> processName;
       
   515          processName.Copy( processes[ current ].iProcessName );
       
   516          TInt find = processName.Find( _L( "." ) );
       
   517          if ( find > KErrNotFound )
       
   518              processName.Delete( find, processName.Length() - find );
       
   519          
       
   520          TInt openErr = endProcess.Open( TProcessId( processId ) );
       
   521          if ( openErr ==KErrNone )
       
   522              {
       
   523              if ( aCommand == EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand )
       
   524                  {
       
   525                  LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - end task" );
       
   526                  endProcess.Close();
       
   527 
       
   528                  TApaTaskList apList = TApaTaskList( iEikonEnv->WsSession() );
       
   529                  TApaTask apTask = apList.FindApp( processName );
       
   530                  if ( apTask.Exists() )
       
   531                      {
       
   532                      LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - task exists -> end" );
       
   533                      apTask.EndTask();
       
   534                      }
       
   535                  else
       
   536                      {
       
   537                      _LIT( KAppNotExist, "Could not end this process!" );
       
   538                      CAknErrorNote* note = new ( ELeave ) CAknErrorNote();
       
   539                      note->SetTextL( KAppNotExist() );
       
   540                      note->ExecuteLD();
       
   541                      }
       
   542                  }
       
   543              else if ( aCommand == EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand )
       
   544                  {
       
   545                  LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - kill process" );
       
   546                  endProcess.Kill( KErrNone );
       
   547                  endProcess.Close();
       
   548                  }
       
   549              else if ( aCommand == EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand )
       
   550                  {
       
   551                  LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - terminate process" );
       
   552                  endProcess.Terminate( KErrNone );
       
   553                  endProcess.Close();
       
   554                  }
       
   555              else if ( aCommand == EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand )
       
   556                  {
       
   557                  LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - panic process" );
       
   558                  _LIT( KPanicTxt, "Panic");
       
   559                  endProcess.Panic( KPanicTxt, KErrNone );
       
   560                  endProcess.Close();
       
   561                  }
       
   562              }
       
   563          else
       
   564              {
       
   565              CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote();
       
   566              _LIT( KErrTxt, "Could not open the process!");
       
   567              errorNote->SetTextL( KErrTxt );
       
   568              errorNote->ExecuteLD();
       
   569              }
       
   570          }   
       
   571 	// Closes the array and frees all memory allocated to the array.
       
   572     processes.Close();
       
   573     }
       
   574 
       
   575 // End of File