logsui/AppSrc/CLogsRecentListView.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     Abstract base class for recent views
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 // System includes
       
    23 #include <eikmenub.h>
       
    24 #include <AknQueryDialog.h>
       
    25 #include <aknnotewrappers.h> 
       
    26 #include <baclipb.h>
       
    27 #include <StringLoader.h> 
       
    28 #include <CMessageData.h>
       
    29 #include <sendui.h> 
       
    30 #include <SendUiConsts.h>
       
    31 #include <TSendingCapabilities.h>
       
    32 #include <sendnorm.rsg>
       
    33 #include <Logs.rsg>
       
    34 #include <AiwCommon.hrh>                //KAiwCmdCall
       
    35 #include <AiwPoCParameters.h>           //TAiwPocParameterData
       
    36 #include <aknViewAppUi.h>
       
    37 #include <AiwServiceHandler.h>
       
    38 #include <AiwGenericParam.h>
       
    39 #include <StringLoader.h>
       
    40 #include <aknnotewrappers.h>
       
    41 #include <AknGlobalNote.h>
       
    42 #include <AknGlobalConfirmationQuery.h>
       
    43 #include <MGFetch.h>
       
    44 #include <AiwContactSelectionDataTypes.h>
       
    45 #include <AiwContactAssignDataTypes.h>
       
    46 
       
    47 // Virtual Phonebook
       
    48 #include <RVPbkContactFieldDefaultPriorities.h>
       
    49 #include <VPbkFieldType.hrh>
       
    50 #include <TVPbkContactStoreUriPtr.h>
       
    51 #include <CVPbkContactStoreUriArray.h>
       
    52 #include <MVPbkContactStoreList.h>
       
    53 #include <CVPbkContactManager.h>
       
    54 #include <CVPbkFieldTypeSelector.h>
       
    55 #include <CVPbkContactLinkArray.h>
       
    56 #include <VPbkContactStoreUris.h>
       
    57 #include <VPbkContactViewFilterBuilder.h>
       
    58 //------------------------
       
    59 
       
    60 #include "CLogsRecentListView.h"
       
    61 #include "CLogsRecentListControlContainer.h"
       
    62 #include "CLogsEngine.h"
       
    63 #include "MLogsEventGetter.h"
       
    64 #include "MLogsClearLog.h"
       
    65 #include "MLogsStateHolder.h"
       
    66 #include "MLogsSharedData.h"
       
    67 #include "CLogsAppUi.h"
       
    68 #include "LogsUID.h"
       
    69 #include "CLogsViewGlobals.h"
       
    70 #include "MLogsExtensionFactory.h"
       
    71 #include "MLogsViewExtension.h"
       
    72 #include "MLogsSystemAgent.h"
       
    73 #include "MLogsUiControlExtension.h"
       
    74 #include "LogsConstants.hrh"
       
    75 #include "CLogsPrependQuery.h"
       
    76 
       
    77 #include "LogsDebug.h"
       
    78 #include "LogsTraces.h"
       
    79 
       
    80 // EXTERNAL DATA STRUCTURES
       
    81 
       
    82 // EXTERNAL FUNCTION PROTOTYPES  
       
    83 
       
    84 // CONSTANTS
       
    85 
       
    86 // Panic string
       
    87 _LIT( KStmRecentView, "StmRecentView" );
       
    88 
       
    89 // MACROS
       
    90 
       
    91 
       
    92 // LOCAL CONSTANTS AND MACROS
       
    93 
       
    94 // MODULE DATA STRUCTURES
       
    95 
       
    96 // LOCAL FUNCTION PROTOTYPES
       
    97 
       
    98 // ================= MEMBER FUNCTIONS =======================
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // CLogsRecentListView::NewL
       
   102 // ----------------------------------------------------------------------------
       
   103 //
       
   104 CLogsRecentListView* CLogsRecentListView::NewL( TLogsModel aModel )
       
   105     {
       
   106     CLogsRecentListView* self = new ( ELeave ) CLogsRecentListView( aModel );
       
   107     CleanupStack::PushL( self );
       
   108     self->ConstructL();
       
   109     CleanupStack::Pop( self );  // self
       
   110     return self;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CLogsRecentListView::CLogsRecentListView
       
   115 // ----------------------------------------------------------------------------
       
   116 //
       
   117 CLogsRecentListView::CLogsRecentListView( TLogsModel aModel ) :
       
   118     iState( EStateUndefined ),
       
   119     iViewExtension( NULL ),
       
   120     iEventListCurrentNoChange( KErrNotFound ) //iEventListCurrentNoChange switched off
       
   121     {
       
   122     iModel = aModel;
       
   123     }
       
   124     
       
   125 // ----------------------------------------------------------------------------
       
   126 // CLogsRecentListView::~CLogsRecentListView
       
   127 // ----------------------------------------------------------------------------
       
   128 //
       
   129 CLogsRecentListView::~CLogsRecentListView()
       
   130     {
       
   131     delete iExitCbaButton;
       
   132     delete iBackCbaButton;
       
   133     iCoeEnv->RemoveForegroundObserver( *this );
       
   134     
       
   135     Release( iViewExtension );
       
   136     Release( iViewGlobal );
       
   137     }
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // CLogsRecentListView::ConstructL
       
   141 // ----------------------------------------------------------------------------
       
   142 //
       
   143 void CLogsRecentListView::ConstructL()
       
   144     {
       
   145     BaseConstructL( R_STM_COMMON_VIEW );
       
   146     iCoeEnv->AddForegroundObserverL( *this );
       
   147     iExitCbaButton = iCoeEnv->AllocReadResourceL( R_STM_EXIT_CBA_BUTTON );
       
   148     iBackCbaButton = iCoeEnv->AllocReadResourceL( R_STM_BACK_CBA_BUTTON );
       
   149     iViewGlobal = CLogsViewGlobals::InstanceL();
       
   150     
       
   151 // Safwish VoIP changes  >>>
       
   152     if ( !iViewExtension )
       
   153         {
       
   154         CPbkContactEngine* nullContactEngine = NULL;
       
   155         iViewExtension = iViewGlobal->ExtensionFactoryL().
       
   156                 CreateLogsViewExtensionL( *nullContactEngine, this );        
       
   157                 
       
   158         iViewExtension->SetSendUi( *LogsAppUi()->SendUiL() ); 
       
   159         iViewExtension->SetSendUiText( SendUiTextL() );                 
       
   160         }
       
   161 // <<<  Safwish VoIP changes
       
   162     }
       
   163     
       
   164 // ----------------------------------------------------------------------------
       
   165 // CLogsRecentListView::LogsCurrentRecentViewId
       
   166 // ----------------------------------------------------------------------------
       
   167 //
       
   168 TLogsViewIds CLogsRecentListView::LogsCurrentRecentViewId() const
       
   169     {
       
   170     switch( iModel )
       
   171         {
       
   172         case ELogsReceivedModel:
       
   173             return EStmReceivedListViewId;
       
   174         case ELogsDialledModel:
       
   175             return EStmDialledListViewId;
       
   176         case ELogsMissedModel:
       
   177             return EStmMissedListViewId;
       
   178         default:
       
   179             User::Panic( KStmRecentView, KErrUnknown );
       
   180             return ELogsDummyViewId; // just to compile without error
       
   181             //break;
       
   182         }
       
   183     }
       
   184 
       
   185 
       
   186 // ----------------------------------------------------------------------------
       
   187 // CLogsRecentListView::Id
       
   188 // ----------------------------------------------------------------------------
       
   189 //
       
   190 TUid CLogsRecentListView::Id() const
       
   191     {
       
   192     return TUid::Uid( LogsCurrentRecentViewId() );
       
   193     }
       
   194 
       
   195 // ----------------------------------------------------------------------------
       
   196 // CLogsRecentListView::RecentListType
       
   197 // ----------------------------------------------------------------------------
       
   198 //
       
   199 TLogsModel CLogsRecentListView::RecentListType() const
       
   200     {
       
   201     return iModel;
       
   202     }
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CLogsRecentListView::ProcessKeyEventL
       
   206 //
       
   207 // Called by base control container when a key press happens. 
       
   208 // ----------------------------------------------------------------------------
       
   209 //
       
   210 TBool CLogsRecentListView::ProcessKeyEventL( 
       
   211     const TKeyEvent& aKeyEvent,
       
   212     TEventCode aType )
       
   213     {
       
   214     if( MenuBar()->ItemSpecificCommandsEnabled() && aType == EEventKey )
       
   215         {
       
   216         if( aKeyEvent.iCode == EKeyBackspace ) 
       
   217             {
       
   218             HandleCommandL( ELogsCmdMenuDelete );
       
   219             return ETrue;
       
   220             }
       
   221         }
       
   222         
       
   223     const MLogsEventGetter* event( CurrentEvent() );
       
   224     
       
   225     //FIXME (CLogsRecentListView and CLogsEventListView): 
       
   226     //The below is needed only because we get key event before the actual row
       
   227     //is changed in the listbox. If/when listbox observer for changed row focus
       
   228     //is available, remove code below and get correct event index from observer.
       
   229     SetEventListCurrent(iContainer->ListBox()->CurrentItemIndex());
       
   230 
       
   231     if( aType == EEventKey && EventListCurrent() != KErrNotFound ) 
       
   232         {
       
   233         TInt count( CurrentModel()->Count() );
       
   234         switch (aKeyEvent.iScanCode)
       
   235             {
       
   236             case EStdKeyUpArrow:
       
   237                 //Set iEventListCurrent + jump to previous or last event depending on position in list
       
   238                 iEventListCurrent > 0 ? event = CurrentModel()->At( --iEventListCurrent ) :
       
   239                                         event = CurrentModel()->At( iEventListCurrent = count - 1 );
       
   240                 break;
       
   241 
       
   242             case EStdKeyDownArrow:
       
   243                 //Set iEventListCurrent + jump to next or first event depending on position in list                
       
   244                 iEventListCurrent < count - 1 ? event = CurrentModel()->At( ++iEventListCurrent ) :
       
   245                                                 event = CurrentModel()->At( iEventListCurrent = 0 );
       
   246                 break;                
       
   247             }
       
   248         } 
       
   249 		 
       
   250         
       
   251     return CLogsBaseView::ProcessKeyEventEventL( aKeyEvent,aType, event );
       
   252     }
       
   253     
       
   254 // ----------------------------------------------------------------------------
       
   255 // CLogsRecentListView::ProcessPointerEventL
       
   256 //
       
   257 // Handler for pointer events, when the current focused item is tapped
       
   258 // ----------------------------------------------------------------------------
       
   259 // 
       
   260 void CLogsRecentListView::ProcessPointerEventL( TInt /* aIndex */ )
       
   261 	{
       
   262     // Open the context sensitive menu   
       
   263 	ProcessCommandL( EAknSoftkeyContextOptions );      	
       
   264 	}
       
   265 
       
   266 // ----------------------------------------------------------------------------
       
   267 // CLogsRecentListView::HandleCommandL
       
   268 // ----------------------------------------------------------------------------
       
   269 //
       
   270 void CLogsRecentListView::HandleCommandL( TInt aCommandId )
       
   271     {
       
   272     TRACE_ENTRY_POINT;
       
   273 
       
   274 // Safwish VoIP changes  >>>
       
   275     //1. Process first the commands that may be in range interested by PECLogs exension
       
   276     if ( iViewExtension->HandleCommandL( aCommandId ) )
       
   277         {
       
   278         return;
       
   279         }
       
   280 // <<<  Safwish VoIP changes
       
   281 
       
   282     //2. Was not a command in range intended for extension. Continue processing.
       
   283     const MLogsEventGetter* event = CurrentEvent();
       
   284                         
       
   285     switch( aCommandId )
       
   286         {
       
   287         case ELogsCmdMenuDeleteAll:
       
   288             CmdClearRecentListL();
       
   289             break;
       
   290 
       
   291         case ELogsCmdMenuDelete:
       
   292             CmdDeleteEventL();
       
   293             break;
       
   294 
       
   295         case ELogsCmdHandleMSK:
       
   296             {
       
   297             // If single click or press MSK for a log event,
       
   298             // it will request directly by AiwSrvCmd.
       
   299             aCommandId = ELogsCmdSingleTapCall;
       
   300             } // Fall through
       
   301             
       
   302         default:
       
   303             {
       
   304             CLogsBaseView::HandleCommandEventL( aCommandId, event );
       
   305             }
       
   306         } 
       
   307    
       
   308     TRACE_EXIT_POINT;
       
   309     }
       
   310 
       
   311 // ----------------------------------------------------------------------------
       
   312 // CLogsRecentListView::ChangeTitlePaneTextToDefaultL
       
   313 // ----------------------------------------------------------------------------
       
   314 //
       
   315 void CLogsRecentListView::ChangeTitlePaneTextToDefaultL()
       
   316     {       
       
   317     iContainer->SetTitlePaneTextToDefaultL( LogsAppUi()->ActiveViewId() );
       
   318     } 
       
   319 
       
   320 // ----------------------------------------------------------------------------
       
   321 // CLogsRecentListView::ProcessCommandL
       
   322 //
       
   323 // Called from FW when e.g. cba pressed 
       
   324 // ----------------------------------------------------------------------------
       
   325 //
       
   326 void CLogsRecentListView::ProcessCommandL( TInt aCommand )
       
   327     {
       
   328     TRACE_ENTRY_POINT;
       
   329            
       
   330     if (LogsAppUi()->ActiveViewId() != LogsCurrentRecentViewId() || !iContainer )
       
   331         {
       
   332         LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
   333                 ( "CLogsRecentListView::ProcessCommandL - view already deactivated! return " ));  
       
   334         return;
       
   335         }
       
   336     
       
   337     if (aCommand == EAknSoftkeyOptions)
       
   338         {
       
   339         // If options menu is opened call SetRefreshMenuOnUpdate which records the current event id
       
   340         // which can then be used to make a decision on wether options menu needs to be refreshed
       
   341         // when reading is finished.
       
   342         SetRefreshMenuOnUpdate( CurrentEvent() );
       
   343         }
       
   344     
       
   345     CLogsBaseView::ProcessCommandL( aCommand );
       
   346         
       
   347     TRACE_EXIT_POINT;
       
   348     }
       
   349     
       
   350 // ----------------------------------------------------------------------------
       
   351 // CLogsRecentListView::DynInitMenuPaneL
       
   352 // ----------------------------------------------------------------------------
       
   353 //
       
   354 void CLogsRecentListView::DynInitMenuPaneL( 
       
   355     TInt aResourceId, 
       
   356     CEikMenuPane* aMenuPane )
       
   357     {
       
   358     //Get event. Note that event may NOT yet be available if asynch request(s) are not completed. 
       
   359     const MLogsEventGetter*  event = CurrentEvent(); //returns NULL if no data yet available
       
   360     CLogsBaseView::DynInitMenuPaneEventL( aResourceId, aMenuPane, event );    
       
   361     
       
   362 // Sawfish VoIP changes  >>>
       
   363     iViewExtension->DynInitMenuPaneL( aResourceId, aMenuPane, event );
       
   364 // <<<  Sawfish VoIP changes    
       
   365 
       
   366     }
       
   367 
       
   368 
       
   369 // ----------------------------------------------------------------------------
       
   370 // CLogsRecentListView::HandleClientRectChange
       
   371 // ----------------------------------------------------------------------------
       
   372 //
       
   373 void CLogsRecentListView::HandleClientRectChange()
       
   374     {
       
   375     if (iContainer)
       
   376     	{
       
   377     	iContainer->SetRect( ClientRect() );  
       
   378     	}
       
   379     }
       
   380 
       
   381 // ----------------------------------------------------------------------------
       
   382 // CLogsRecentListView::DrawComponents
       
   383 // ----------------------------------------------------------------------------
       
   384 //
       
   385 void CLogsRecentListView::DrawComponents()
       
   386     {
       
   387     if (iContainer)
       
   388         {
       
   389         iContainer->DrawNow();
       
   390         }
       
   391     }
       
   392 
       
   393 // ----------------------------------------------------------------------------
       
   394 // CLogsRecentListView::ViewDeactivated
       
   395 //
       
   396 // This is called by framework when really losing foreground but not when losing foreground to some note etc.
       
   397 // Also called by framework when switching views inside application.
       
   398 // So DoDeactivate is not always called when ViewDeactivated is called.
       
   399 //
       
   400 // Note: there is no guarenteed order of which is called first ViewDeactivated or HandleLosingForeground
       
   401 //
       
   402 // ----------------------------------------------------------------------------
       
   403 //
       
   404 void CLogsRecentListView::ViewDeactivated()
       
   405     {
       
   406     // When view is deactivated due to losing foreground we reset the list here in advance so there won't be 
       
   407     // flickering of the old list. Since view server introduced redraw storing the HandleGainingForeground
       
   408     // comes too late and the old list will flicker before it is reseted. 
       
   409     // We'll skip this when Phonebook update pending - the list is going to be updated later.
       
   410     //
       
   411     // If we would do this in HandleLosingForeground, then the list would be emptied when for example when
       
   412     // active applications list, global note etc. is shown.
       
   413     //
       
   414     if (CurrentModel() && iContainer && ( iFocusChangeControl != ELogsNoChange_PbkUpdPending ) )
       
   415         {
       
   416 		
       
   417 		// EJZO-7RJB3V
       
   418         if (IgnoreViewDeactivatedOperation())
       
   419             {
       
   420             CAknView::ViewDeactivated();
       
   421             return;
       
   422             }
       
   423 
       
   424         if (iFocusChangeControl != ELogsOkToChange)
       
   425             {
       
   426             StoreEvenListCurrentFocus();
       
   427             }
       
   428          
       
   429         // Reset array and set dirty which means refresh requested, 
       
   430         // will call StateChangedL with state EStateArrayReseted and update the listbox.
       
   431         CurrentModel()->DoDeactivate( MLogsModel::ESkipClearing,
       
   432                                       MLogsModel::EResetOnlyArrayWithDirty );
       
   433      
       
   434         // On gaining foreground, do a clean read of events
       
   435         iResetAndRefreshOnGainingForeground = MLogsModel::EResetAndRefresh;
       
   436         }       
       
   437     
       
   438     CAknView::ViewDeactivated();
       
   439     }
       
   440 
       
   441 // ----------------------------------------------------------------------------
       
   442 // CLogsRecentListView::DoActivateL
       
   443 // ----------------------------------------------------------------------------
       
   444 //
       
   445 void CLogsRecentListView::DoActivateL(
       
   446     const TVwsViewId& aPrevViewId,
       
   447     TUid aCustomMessageId,
       
   448     const TDesC8& aCustomMessage )
       
   449     {
       
   450     TRACE_ENTRY_POINT;
       
   451        
       
   452     CLogsBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );    
       
   453 
       
   454     //To prevent first time flicker of context menu if no ctx mnu will be displayed
       
   455     Cba()->MakeCommandVisible( EAknSoftkeyContextOptions, EFalse );
       
   456     
       
   457     iFocusChangeControl = ELogsOkToChange;           
       
   458     iEventListCurrentNoChange = KErrNotFound;
       
   459     
       
   460     LogsAppUi()->SetCurrentViewId( Id() );
       
   461     
       
   462     //To avoid possible flicker, change the cba text to 'Exit' when going to background
       
   463     //but don't draw it. Sometimes CAknView::ConstructMenuAndCbaL might draw the cba
       
   464     //when we are going to background and activating dialled calls view. It is safer 
       
   465     //to have the cba thus set as 'Exit'
       
   466     if( aCustomMessageId.iUid == ELogsViewActivationBackground && 
       
   467         LogsAppUi()->ExecutionMode() == ELogsInBackground_ExitOrEndPressed )
       
   468         {
       
   469         ChangeCba2ToExitL( ELogsDontDraw );     
       
   470         }
       
   471     else if ( LogsAppUi()->ProvideOnlyRecentViews())                   
       
   472         {  
       
   473         LogsAppUi()->SetPreviousAppUid( aPrevViewId.iAppUid );
       
   474         LogsAppUi()->SetPreviousViewId( aPrevViewId.iViewUid );
       
   475         Engine()->DeleteConfig();           //Logs settings
       
   476         ChangeCba2ToExitL( ELogsDrawNow );                //We must not be able to back to other Logs views, just exit
       
   477         }
       
   478     else  
       
   479         {
       
   480         ChangeCba2ToBackL();
       
   481         }
       
   482    
       
   483 
       
   484     Engine()->CreateModelL( iModel );       //Creates model only if not yet exists
       
   485 
       
   486     //Create the control container. 
       
   487     if( !iContainer )
       
   488         {
       
   489         iContainer = CLogsRecentListControlContainer::NewL( this, ClientRect() );
       
   490         AppUi()->AddToViewStackL( *this,iContainer );  
       
   491         }
       
   492     iContainer->ListBox()->SetListBoxObserver( this );
       
   493 
       
   494     //External launch has been done already, so come here
       
   495     if ( ! LogsAppUi()->ProvideOnlyRecentViews() )
       
   496         {
       
   497         LogsAppUi()->SetPreviousAppUid( TUid::Uid( KLogsAppUID3 ) );
       
   498         LogsAppUi()->SetPreviousViewId( aPrevViewId.iViewUid );
       
   499         }
       
   500 
       
   501     //Update item selection. Set always focus to top. If previous focus is to be retained, comment below two rows out
       
   502     SetEventListCurrent(0);
       
   503     SetEventListTop(0);
       
   504     
       
   505     CurrentModel()->SetObserver( this );
       
   506     
       
   507     if( aCustomMessageId.iUid == ELogsViewActivationBackground && 
       
   508         LogsAppUi()->ExecutionMode() == ELogsInBackground_ExitOrEndPressed )
       
   509         {
       
   510         // We have activated this view because we are hiding Logs into background (faking exit) 
       
   511         // so this view is waiting when Logs is again foregrounded.    
       
   512         //
       
   513         // With MLogsModel::ECloseDBConnectionAndResetArray the connection to the database is
       
   514         // closed and event array will be deleted. Calls StateChangedL with state EStateArrayReseted 
       
   515         // which will update the listbox to empty state.
       
   516         CurrentModel()->DoDeactivate( MLogsModel::ENormalOperation,
       
   517                                       MLogsModel::ECloseDBConnectionAndResetArray );
       
   518 
       
   519         // Now we can enable bring-to-foreground on view activation:
       
   520         AppUi()->SetCustomControl(0); 
       
   521         AppUi()->HideInBackground(); 
       
   522         // When coming back to foreground, do a clean read of events
       
   523         iResetAndRefreshOnGainingForeground = MLogsModel::EResetAndRefresh; 
       
   524         }
       
   525     else
       
   526         {
       
   527         // Just to make sure the inputblocker is not on
       
   528         RemoveInputBlocker();
       
   529         CurrentModel()->DoActivateL( MLogsModel::EResetAndRefresh );
       
   530         
       
   531         // By default on gaining foreground, just refresh the list. So when active applications list, 
       
   532         // keylock or some note (like when plugin in the charger) is shown the list doesn't flicker. 
       
   533         // When view is deactivated this is set to MLogsModel::EResetAndRefresh.
       
   534         iResetAndRefreshOnGainingForeground = MLogsModel::ERefresh; 
       
   535         }
       
   536     
       
   537     
       
   538     if( CurrentModel()->Count() )
       
   539           {
       
   540           iContainer->ListBox()->SetTopItemIndex( EventListTop() );
       
   541           if( EventListCurrent() < 0 )
       
   542               {
       
   543               SetEventListCurrent(0);
       
   544               }
       
   545           iContainer->ListBox()->SetCurrentItemIndex( EventListCurrent() );
       
   546           }
       
   547      
       
   548     ClearMissedCallNotificationsL();     //Clear cenrep new missed calls counter + notifications (however, possible missed 
       
   549                                          //list duplicate counters need to be cleared separately).  
       
   550      
       
   551     TRACE_EXIT_POINT;    
       
   552     }
       
   553 
       
   554 // ----------------------------------------------------------------------------
       
   555 // CLogsRecentListView::ReadingFinished
       
   556 // ----------------------------------------------------------------------------
       
   557 //
       
   558 TBool CLogsRecentListView::ReadingFinished()
       
   559     {
       
   560     TBool finished = ( iState != EStateActive       && iState != EStateUndefined  &&  
       
   561                        iState != EStateInitializing && iState != EStateSemiFinished &&
       
   562                        iState != EStateInterrupted );  
       
   563                                           
       
   564     return finished;
       
   565     }   
       
   566     
       
   567 // ----------------------------------------------------------------------------
       
   568 // CLogsRecentListView::IgnoreViewDeactivatedOperation
       
   569 // ----------------------------------------------------------------------------
       
   570 //  
       
   571 TBool CLogsRecentListView::IgnoreViewDeactivatedOperation()
       
   572     {
       
   573     TBool ret = EFalse;
       
   574     if (iIgnoreViewDeactivatedHandling)
       
   575         {
       
   576 	      // no guarenteed order of which is called first ViewDeactivated or HandleLosingForeground,
       
   577 	      // so add the iSemiFinishViewDeactivatedOperation flag
       
   578         if (iSemiFinishViewDeactivatedOperation)
       
   579             {
       
   580             iIgnoreViewDeactivatedHandling = EFalse;
       
   581             iSemiFinishViewDeactivatedOperation = EFalse;
       
   582             }
       
   583         else
       
   584             {
       
   585             iSemiFinishViewDeactivatedOperation = ETrue;
       
   586             }
       
   587                 
       
   588         ret = ETrue;
       
   589         }
       
   590         
       
   591     return ret;   
       
   592 	}
       
   593 	  
       
   594 // ----------------------------------------------------------------------------
       
   595 // CLogsRecentListView::DoDeactivate
       
   596 // ----------------------------------------------------------------------------
       
   597 //
       
   598 void CLogsRecentListView::DoDeactivate()
       
   599     {
       
   600     TRACE_ENTRY_POINT;
       
   601         
       
   602     CLogsBaseView::DoDeactivate(); 
       
   603                          
       
   604     if( iContainer )
       
   605         {
       
   606         SetEventListCurrent(iContainer->ListBox()->CurrentItemIndex());
       
   607         SetEventListTop(iContainer->ListBox()->TopItemIndex());
       
   608         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   609         delete iContainer;
       
   610         iContainer = NULL;
       
   611         }
       
   612 
       
   613      if( iModel == ELogsMissedModel )
       
   614         {
       
   615         // Below we test for reading finshed to prevent unnecessary clearing of duplicate counters, 
       
   616         // new missed call icons and missed call notification and the "x missed calls" text 
       
   617         // in the Call register view. 
       
   618         //
       
   619         // This would otherwise be done when user reopens Logs by 
       
   620         // green key or from appshell after first leaving Missed calls view to background. 
       
   621         //
       
   622         // (Missed calls view will first receive HandleGainingForeground followed by an 
       
   623         // immediate DoDeactivate )
       
   624         //
       
   625         // FIXME: This fix is not 100% sure cause it might happen rarely that the reading has time to 
       
   626         // finish before framework activates the actual view that was opened (and calls DoDeactivate for 
       
   627         // missed calls view). No better solution found yet though. 
       
   628         //
       
   629         if ( ReadingFinished() )
       
   630             {
       
   631             LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
   632                     ( "CLogsRecentListView::DoDeactivate - ReadingFinished" ));  
       
   633             ClearMissedCallNotifications();   //Clear cenrep new missed calls counter + notifications          
       
   634             CurrentModel()->DoDeactivate( MLogsModel::ENormalOperation,
       
   635                                           MLogsModel::ECloseDBConnection );//ETrue: disconnect from db. This helps for EMSH-6JDFBV but
       
   636                                               //reduces user's perceived performance for other views
       
   637                                               //(seems to keep clearing of missed duplicates process alive
       
   638                                               // so no need for EFalse here as it would increase probability of 
       
   639                                               // EMSH-6JDFBV occurring again   
       
   640                                     
       
   641             }
       
   642                               
       
   643         else
       
   644             {
       
   645             LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
   646                     ( "CLogsRecentListView::DoDeactivate - Reading interrupted" )); 
       
   647             CurrentModel()->DoDeactivate( MLogsModel::ESkipClearing,
       
   648                                           MLogsModel::ECloseDBConnection );
       
   649             }    
       
   650         }
       
   651     else
       
   652         {
       
   653         CurrentModel()->DoDeactivate( MLogsModel::ENormalOperation,
       
   654                                       MLogsModel::ECloseDBConnection );//ETrue: disconnect from db. This helps for EMSH-6JDFBV but
       
   655                                               //reduces user's perceived performance for other views
       
   656                                               //EFalse: don't disconnect from db. This keeps read data cached in Logs.
       
   657         }
       
   658         
       
   659     //To prevent second time flicker of context menu if ctx mnu was was displayed
       
   660     //but will not later be displayed
       
   661     Cba()->MakeCommandVisible( EAknSoftkeyContextOptions, EFalse );
       
   662     
       
   663     TRACE_EXIT_POINT;
       
   664     }
       
   665 
       
   666 // ----------------------------------------------------------------------------
       
   667 // CLogsRecentListView::CmdClearRecentListL
       
   668 // ----------------------------------------------------------------------------
       
   669 //
       
   670 void CLogsRecentListView::CmdClearRecentListL()
       
   671     {
       
   672     if( CurrentModel()->Count() )
       
   673         {
       
   674         TInt resId( 0 );
       
   675 
       
   676         CAknQueryDialog* queryDlg = CAknQueryDialog::NewL();
       
   677                 
       
   678         switch( iModel )
       
   679             {
       
   680             case ELogsMissedModel:
       
   681                 resId = R_CLEAR_MISSED_LIST_CONFIRMATION_QUERY;
       
   682                 break;
       
   683 
       
   684             case ELogsReceivedModel:
       
   685                 resId = R_CLEAR_RECEIVED_LIST_CONFIRMATION_QUERY;
       
   686                 break;
       
   687 
       
   688             case ELogsDialledModel:
       
   689                 resId = R_CLEAR_DIALLED_LIST_CONFIRMATION_QUERY;
       
   690                 break;
       
   691 
       
   692             default:
       
   693                 User::Panic( KStmRecentView, KErrUnknown );
       
   694                 break;
       
   695             }
       
   696           
       
   697         if( queryDlg->ExecuteLD( resId ) )
       
   698             {
       
   699             Engine()->ClearLogsL()->ClearModelL( iModel );
       
   700             SetEventListTop(0);
       
   701             SetEventListCurrent(0);
       
   702                 
       
   703             SetInputBlockerL();
       
   704             } 
       
   705         }
       
   706     }
       
   707 
       
   708 // ----------------------------------------------------------------------------
       
   709 // CLogsRecentListView::CmdDeleteEventL
       
   710 // ----------------------------------------------------------------------------
       
   711 //
       
   712 void CLogsRecentListView::CmdDeleteEventL()
       
   713     {
       
   714     if( CurrentModel()->Count() && iContainer->ListBox()->CurrentItemIndex() != KErrNotFound )    
       
   715         {
       
   716         CAknQueryDialog* queryDlg = CAknQueryDialog::NewL();
       
   717         SetEventListTop(iContainer->ListBox()->TopItemIndex());
       
   718         SetEventListCurrent(iContainer->ListBox()->CurrentItemIndex());
       
   719 
       
   720         TLogId id = CurrentModel()->At( EventListCurrent() )->LogId();
       
   721         
       
   722         if( queryDlg->ExecuteLD( R_DELETE_CONFIRMATION_QUERY ) )
       
   723             {
       
   724             iEventListCurrentNoChange = iContainer->ListBox()->CurrentItemIndex(); 
       
   725             Engine()->ClearLogsL()->DeleteEventL( id ); //Delete the event from LogDb. Event from view gets 
       
   726                                                         //removed when the view data is reread from db.
       
   727             iFocusChangeControl = ELogsNoChange;        //Prevent focus moving to top when list is reread 
       
   728             } 
       
   729         }
       
   730     }
       
   731 
       
   732 // ----------------------------------------------------------------------------
       
   733 // CLogsRecentListView::ChangeCba2ToExitL
       
   734 // ----------------------------------------------------------------------------
       
   735 //
       
   736 TBool CLogsRecentListView::ChangeCba2ToExitL( TLogsDrawNow aDrawNow )
       
   737     {
       
   738     //We must attempt to change CBA only if we have correct view in the foreground
       
   739     if( LogsAppUi()->ActiveViewId() != LogsCurrentRecentViewId() )
       
   740         {
       
   741         return EFalse; //There is some other view already active, so we don't have 
       
   742         }              // our own cba's present
       
   743  
       
   744     TInt pos = Cba()->PositionById( EAknSoftkeyBack );   
       
   745          
       
   746     if( pos > 0 )
       
   747         {
       
   748         Cba()->SetCommandL( pos, 
       
   749                             ELogsCmdMenuExit, 
       
   750                             iExitCbaButton->Des() );
       
   751                             
       
   752         if (aDrawNow == ELogsDrawNow)
       
   753             {
       
   754             Cba()->DrawNow();  
       
   755             }
       
   756             
       
   757         return ETrue;
       
   758         }
       
   759         
       
   760     return EFalse;
       
   761     }
       
   762 
       
   763 // ----------------------------------------------------------------------------
       
   764 // CLogsRecentListView::ChangeCba2ToBackL
       
   765 // ----------------------------------------------------------------------------
       
   766 //
       
   767 TBool CLogsRecentListView::ChangeCba2ToBackL()
       
   768     {
       
   769     if( LogsAppUi()->ActiveViewId() != LogsCurrentRecentViewId() )
       
   770         {
       
   771         return EFalse; //There is some other view already active, so we don't have our own cba's present
       
   772         }              // (e.g. FSW can be brought to foreground already)
       
   773         
       
   774     TInt pos = Cba()->PositionById( ELogsCmdMenuExit ); 
       
   775            
       
   776     if( pos > 0 )
       
   777         {
       
   778         Cba()->SetCommandL( pos, 
       
   779                             EAknSoftkeyBack, 
       
   780                             iBackCbaButton->Des() );
       
   781         Cba()->DrawNow();//Needed when this view already been open and cba changed in other view
       
   782         
       
   783         return ETrue;
       
   784         }
       
   785         
       
   786     return EFalse;
       
   787     }
       
   788 
       
   789 // ----------------------------------------------------------------------------
       
   790 // CLogsRecentListView::HandleGainingForeground
       
   791 //
       
   792 // This function is called once for each already constructed Recent View when 
       
   793 // Logs is gaining foreground. No matter if a view is deactivated (i.e. is also 
       
   794 // called for view(s) not actually gaining foreground but just have been constructed)
       
   795 // ----------------------------------------------------------------------------
       
   796 //
       
   797 void CLogsRecentListView::HandleGainingForeground()
       
   798     {   
       
   799     TRACE_ENTRY_POINT;  
       
   800          
       
   801     CLogsBaseView::HandleGainingForeground();
       
   802 
       
   803     //Process cba if this view is already open and then just brought to foreground
       
   804     //in ProvideOnlyRecentViews mode
       
   805     if( LogsAppUi()->ProvideOnlyRecentViews() )    
       
   806         {
       
   807         TRAPD( err, ChangeCba2ToExitL( ELogsDrawNow ) );  
       
   808         if( err ) 
       
   809             {
       
   810             iCoeEnv->HandleError( err );
       
   811             }
       
   812         
       
   813         // Always reset focus to the top of the list, when Logs is opened by a send key 
       
   814         // press from idle    
       
   815         if (LogsAppUi()->LogsOpenedWithSendKey() && LogsCurrentRecentViewId() == EStmDialledListViewId)
       
   816             {
       
   817             iFocusChangeControl = ELogsOkToChange;
       
   818             iEventListCurrentNoChange = KErrNotFound;
       
   819             LogsAppUi()->SetLogsOpenedWithSendKey(EFalse); // reset the send key checking 
       
   820             LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
   821                 ( "CLogsRecentListView::HandleGainingForeground - LogsOpenedWithSendKey: reset focus" ));  
       
   822             }       
       
   823         }
       
   824 
       
   825     //Activate current view's model that we deactivated in HandleLosingForeground().
       
   826     //No need to check if already active, DoActivateL() handles this.
       
   827     if( LogsAppUi()->ActiveViewId() == LogsCurrentRecentViewId() && iContainer )  //Only if this object corresponds 
       
   828                                                                     //to current view.
       
   829         {
       
   830         MLogsModel* model = CurrentModel();
       
   831         
       
   832         //ELogsNoChange is special case here, i.e contact just added to pbk: skip activating to avoid unwanted UI-focus change.
       
   833         //We don't know in hw which is finished first, reading of entries because of gaining of foreground (EMSH-6JDFBV) here or 
       
   834         //re-reading of entries because change observed in db, or will the first db-read have enough time to finish before.
       
   835         if( model )  
       
   836             {
       
   837             if( iFocusChangeControl != ELogsNoChange_PbkUpdPending) 
       
   838                 {
       
   839                  //If menu is shown, we need to close it as focus is lost
       
   840                 if (MenuBar()->IsDisplayed())
       
   841                     {
       
   842                     MenuBar()->StopDisplayingMenuBar();
       
   843                     }
       
   844                 
       
   845                 SetEventListCurrent( KErrNotFound );//just to make sure that UI does not try to read anything from eventarray                
       
   846                 TRAPD( err, model->DoActivateL( iResetAndRefreshOnGainingForeground ) );  
       
   847                 if( err ) 
       
   848                     {
       
   849                     iCoeEnv->HandleError( err );
       
   850                     }
       
   851                 
       
   852                 // By default on gaining foreground, just refresh the list. So when active applications list, 
       
   853                 // keylock or some note (like when plugin in the charger) is shown the list doesn't flicker. 
       
   854                 // When view is deactivated this is set to MLogsModel::EResetAndRefresh.
       
   855                 iResetAndRefreshOnGainingForeground = MLogsModel::ERefresh;
       
   856                 }
       
   857             else
       
   858                 {
       
   859                 // Change ELogsNoChange_PbkUpdPending to ELogsNoChange now so there is no need to 
       
   860                 // differentiate those in StateChangedL
       
   861                 iFocusChangeControl = ELogsNoChange;
       
   862                 }
       
   863             }
       
   864         
       
   865         RemoveInputBlocker(); //just in case
       
   866         }                            
       
   867     TRACE_EXIT_POINT; 
       
   868     }
       
   869 
       
   870 // ----------------------------------------------------------------------------
       
   871 // CLogsRecentListView::StoreEvenListCurrentFocus()
       
   872 // ----------------------------------------------------------------------------
       
   873 //
       
   874 void CLogsRecentListView::StoreEvenListCurrentFocus()
       
   875     {
       
   876     //
       
   877     // Check that not called from deactivated recent list view that also gets 
       
   878     // a notification of losin foreground.
       
   879     if (!iContainer || LogsAppUi()->ActiveViewId() != LogsCurrentRecentViewId())
       
   880         {
       
   881         return;
       
   882         }
       
   883      
       
   884     // Store the current focused item. Sometimes foreground can be regained for only very briefly and 
       
   885     // event reading is not finished so skip those situations. 
       
   886     // Also there is no guarantees which is called fist, HandleLosingForeground
       
   887     // or ViewDeactivated so don't change when list is already deleted.
       
   888     //
       
   889     if( (iContainer->ListBox()->CurrentItemIndex() != KErrNotFound) && ReadingFinished() )
       
   890         {
       
   891         SetEventListCurrent(iContainer->ListBox()->CurrentItemIndex());
       
   892         
       
   893         // Switch on iEventListCurrentNoChange: store the current item index to 
       
   894         // keep it over effects of loss and gain of foreground.
       
   895         iEventListCurrentNoChange = EventListCurrent(); 
       
   896         SetEventListTop(iContainer->ListBox()->TopItemIndex());
       
   897         }
       
   898     //
       
   899     // If the list has no focus and iEventListCurrentNoChange is not set, let the focus go 
       
   900     // to the top of the list when events are reread.
       
   901     else if ( ( iContainer->ListBox()->CurrentItemIndex() == KErrNotFound ) &&
       
   902               ( iEventListCurrentNoChange == KErrNotFound ) )
       
   903         {
       
   904         iFocusChangeControl = ELogsOkToChange;
       
   905         }
       
   906     }
       
   907 
       
   908 // ----------------------------------------------------------------------------
       
   909 // CLogsRecentListView::HandleLosingForeground
       
   910 //
       
   911 // This function is called once for each type of already constructed recent view (e.g.when fast swapping 
       
   912 // window is brought to foreground).
       
   913 // ----------------------------------------------------------------------------
       
   914 //
       
   915 void CLogsRecentListView::HandleLosingForeground()
       
   916     {
       
   917     TRACE_ENTRY_POINT;
       
   918     CLogsBaseView::HandleLosingForeground(); 
       
   919     
       
   920     TBool finished = ReadingFinished();     
       
   921     TLogsViewIds currView = LogsCurrentRecentViewId();      
       
   922     
       
   923     
       
   924     if ( iContainer && ( LogsAppUi()->ActiveViewId() == currView )) 
       
   925         {
       
   926         // EJZO-7RJB3V
       
   927         if (IgnoreViewDeactivatedOperation())
       
   928             {
       
   929             TRACE_EXIT_POINT;
       
   930             return; 
       
   931             }
       
   932            
       
   933         // If we are losing foreground in the middle of event reading, force empty text to the view.
       
   934         // This happens for example when keys are locked EYSN-6X5DYS
       
   935         if (!finished)
       
   936             {
       
   937             // Does not have effect if list is not empty
       
   938             iContainer->ForceEmptyTextListBox();
       
   939             }
       
   940         //
       
   941         // If focus is to be kept (iFocusChangeControl is ELogsNoChange or 
       
   942         // ELogsNoChange_PbkUpdPending) store the current focused item
       
   943        if ( iFocusChangeControl != ELogsOkToChange  )   
       
   944             {
       
   945             StoreEvenListCurrentFocus();
       
   946             }
       
   947         }
       
   948     
       
   949     // The below is additional code for tuning performance consumption. It can be removed when no need 
       
   950     // for this is found as the code below does not affect functionality.
       
   951     // For performance consumption reasons (EMSH-6JDFBV) we need to deactivate the 
       
   952     // current view when we lose foreground. However, this needs to be done only for 
       
   953     // missed calls view as other views should not be affected by this. However we do it for dialled calls in order 
       
   954     // to prevent old wrong entry staying a while in top of list when redialing from dialled list. 
       
   955     //
       
   956     // Update: apply the same for Received calls view. This is needed to to avoid inconsistency 
       
   957     // between the views, like in EYSN-6X5DYS  
       
   958     //
       
   959     if( ( LogsAppUi()->ActiveViewId() == currView ) &&  //Only if this object corresponds to current view.
       
   960         ( currView == EStmMissedListViewId  || 
       
   961           currView == EStmDialledListViewId ||
       
   962           currView == EStmReceivedListViewId ) ) 
       
   963         {                                               
       
   964         MLogsModel* model = CurrentModel();
       
   965         if( model )
       
   966             {
       
   967             // End key pressed in missed calls view: sent to background before the Dialled calls view 
       
   968             // is activated while in background. so need to clear duplicates now since the reader is deleted
       
   969             // and they cannot be cleared in DoDeactivate anymore
       
   970             if( LogsAppUi()->ExecutionMode() == ELogsInBackground_ExitOrEndPressed && currView == EStmMissedListViewId )
       
   971                 {
       
   972                  LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
   973                     ( "CLogsRecentListView::HandleLosingForeground - clear duplicates" ));      
       
   974                 model->DoDeactivate( MLogsModel::ENormalOperation, 
       
   975                                      MLogsModel::ECloseDBConnection );    //EFalse: don't disconnect from db 
       
   976                 }
       
   977             else    
       
   978                 {
       
   979                 LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
   980                     ( "CLogsRecentListView::HandleLosingForeground - skip clearing" )); 
       
   981                 //Other loss of foreground (call or AppKey). We'll not touch duplicate counters
       
   982                 model->DoDeactivate( MLogsModel::ESkipClearing, //Don't update db (for missed view)
       
   983                                      MLogsModel::ECloseDBConnection );    //ETrue: disconnect from db in order to immediately to stop
       
   984                                                  //EFalse: don't disconnect from db                                     
       
   985                 }
       
   986             }
       
   987         }
       
   988     
       
   989     TRACE_EXIT_POINT;
       
   990     }
       
   991  
       
   992 // ----------------------------------------------------------------------------
       
   993 // CLogsRecentListView::StateChangedL
       
   994 //
       
   995 // CLogsModel informs it has changed event array, e.g. added entry to array or reseted the array etc.
       
   996 // This function is called as many times as there is new/changed row in the event array. 
       
   997 // ----------------------------------------------------------------------------
       
   998 //
       
   999 void CLogsRecentListView::StateChangedL( MLogsStateHolder* aHolder )
       
  1000     {
       
  1001     TRACE_ENTRY_POINT;
       
  1002     
       
  1003     if( !aHolder )
       
  1004          {
       
  1005          return;  
       
  1006          }
       
  1007          
       
  1008      iState = aHolder->State();
       
  1009     
       
  1010     // When check contact link finished, call base method to check if need to 
       
  1011     // refresh menu.
       
  1012      if( iState == EStateCheckContactLinkFinished )
       
  1013          {
       
  1014          CLogsBaseView::StateChangedL(aHolder);
       
  1015          return;
       
  1016          }
       
  1017     
       
  1018     //Call Update() when related items available to show changes immediately plus when reading is finished. 
       
  1019     const TInt KNbrShownEntries = 8;
       
  1020     
       
  1021     iState = aHolder->State();
       
  1022     LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
  1023         ( "CLogsRecentListView::StateChangedL - iState:%d  iFocusChangeControl:%d viewid:%d"), 
       
  1024           iState, iFocusChangeControl, LogsCurrentRecentViewId() );  
       
  1025         
       
  1026     // If there was some error reading events - most likely KErrNoMemory, 
       
  1027     // display information to user and close Logs 
       
  1028     if( iState == EStateError )
       
  1029     	{
       
  1030     	iCoeEnv->HandleError(KErrNoMemory);
       
  1031 	    LogsAppUi()->CmdExit();
       
  1032     	}
       
  1033     
       
  1034     //A. If reader deleted (EMSH-6JDFBV), stop all processing.
       
  1035     if( iState == EStateReaderDeletedOrStopped )
       
  1036         { 
       
  1037         return;
       
  1038         }
       
  1039     // Special case, array is reseted so update the list to empty state. This prevents flicker
       
  1040     // of the old list when regaining foreground
       
  1041     else if ( iState == EStateArrayReseted )
       
  1042         {
       
  1043         if( iContainer )
       
  1044             {
       
  1045             iContainer->UpdateL();
       
  1046             }
       
  1047         return;
       
  1048         }
       
  1049               
       
  1050     //B. Continue to show contents quickly and without flicker when enough events available
       
  1051     if( iContainer )
       
  1052         {
       
  1053         //1. Check are we finished and set scroll bars
       
  1054         TInt count( iContainer->ListBox()->Model()->NumberOfItems() );  //Current count of items CLogsModel has read into item array
       
  1055         TBool finished = ReadingFinished();  
       
  1056         CEikScrollBarFrame* sbFrame = iContainer->ListBox()->ScrollBarFrame();    
       
  1057 
       
  1058         if( finished || iState == EStateSemiFinished) //To avoid scroll bar flicker don't show scroll bar until completely finished
       
  1059             {
       
  1060             sbFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn );  
       
  1061             }
       
  1062         else if (count == 0)
       
  1063             {
       
  1064             sbFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); 
       
  1065             }
       
  1066         
       
  1067         //2. Update listbox when sufficiently events available
       
  1068         if( finished || iState == EStateSemiFinished)
       
  1069             {
       
  1070             iContainer->UpdateL();      //Calls HandleItemAdditionL (plus sets Empty text if needed)    
       
  1071             // Fetch data for extension
       
  1072             iContainer->ControlExtension()->HandleAdditionalData( 
       
  1073                 *CurrentModel(), 
       
  1074                 *iContainer->ListBox() );
       
  1075             ClearMissedCallNotificationsL();
       
  1076             // When event reading is finished, remove inputblocker
       
  1077             RemoveInputBlocker();
       
  1078             }        
       
  1079         // If focus is not retained, refresh the UI when a screenful of events is read
       
  1080         else if( iFocusChangeControl == ELogsOkToChange && count == KNbrShownEntries ) 
       
  1081             {
       
  1082             iContainer->UpdateL();
       
  1083             }
       
  1084    
       
  1085         //3. Control focus changes in the list during the read of events
       
  1086         
       
  1087         //Set focus once when ok to change     
       
  1088         if ( iFocusChangeControl == ELogsOkToChange ) 
       
  1089             {
       
  1090             if( iState == EStateFinished || iState == EStateSemiFinished )
       
  1091                 {            
       
  1092                 //Reset iEventListCurrentNoChange and iFocusChangeControl
       
  1093                 iEventListCurrentNoChange = KErrNotFound; 
       
  1094                 iFocusChangeControl =  ELogsNoChange;
       
  1095                 }
       
  1096             
       
  1097             if( count &&  //at least one entry from previous read to this view
       
  1098                ( iState == EStateUndefined || iState == EStateInitializing )) //we're about start reread        
       
  1099                 {
       
  1100                 SetEventListCurrent(0); 
       
  1101                 iContainer->ListBox()->SetCurrentItemIndex( EventListCurrent() );
       
  1102                 }                
       
  1103             }
       
  1104   
       
  1105         else
       
  1106             //No focus change when entry saved to phonebook, deleted or list updated twice.
       
  1107             {
       
  1108             if( (iState == EStateFinished && LogsCurrentRecentViewId() != EStmMissedListViewId ) || iState == EStateSemiFinished)
       
  1109                 {
       
  1110                 //If e.g. foreground regained, use iEventListCurrentNoChange if switched on
       
  1111                 if( iEventListCurrentNoChange != KErrNotFound &&    //iEventListCurrentNoChange is switched on.
       
  1112                     ( EventListCurrent() == KErrNotFound ||
       
  1113                       EventListCurrent() == 0) )     //No iEventListCurrent available.
       
  1114                     {
       
  1115                     SetEventListCurrent(iEventListCurrentNoChange);  //Use iEventListCurrentNoChange
       
  1116                     }
       
  1117              
       
  1118                 if( count > 0 ) 
       
  1119                     {
       
  1120                     //If now less rows than current item before, or if no current selection (e.g last
       
  1121                     //row was deleted), try to set focus to last available item. Otherwise try to use 
       
  1122                     //iEventListCurrent.
       
  1123                     if( count <= EventListCurrent() || EventListCurrent() < 0 ) 
       
  1124                         {
       
  1125                         iContainer->ListBox()->SetCurrentItemIndex( count - 1 );
       
  1126                         }
       
  1127                     else if( count > EventListCurrent() )
       
  1128                         {
       
  1129                         iContainer->ListBox()->SetCurrentItemIndex( EventListCurrent() );
       
  1130                         // if event list top is sensible, adjust the window back to what it was
       
  1131                         if ((EventListTop() >= 0) && (EventListTop() < count) )
       
  1132                             {
       
  1133                             iContainer->ListBox()->SetTopItemIndex(EventListTop());
       
  1134                             }
       
  1135                         }
       
  1136                     }
       
  1137                 
       
  1138                 iFocusChangeControl =  ELogsNoChange;
       
  1139                 SetEventListCurrent( iContainer->ListBox()->CurrentItemIndex() );                    
       
  1140                 }
       
  1141             }
       
  1142         
       
  1143                 //When reading twice (EMSH-6JDFBV), prevent setting focus again for second phase read. 
       
  1144         if( iState == EStateSemiFinished ) 
       
  1145             {
       
  1146             iFocusChangeControl = ELogsNoChange; 
       
  1147             }
       
  1148         
       
  1149         //4. Set MSK state
       
  1150         if( iState == EStateFinished || iState == EStateSemiFinished )         
       
  1151             {
       
  1152             Cba()->MakeCommandVisible( 
       
  1153                 EAknSoftkeyContextOptions, 
       
  1154                 IsOkToShowContextMenu( CurrentEvent() ));
       
  1155             }
       
  1156 
       
  1157         //5. To improve user's perceived responsiviness we probably now have a good moment to perform 
       
  1158         //some time consuming operations if not yet already done
       
  1159         if( count == KNbrShownEntries ) //if( iState == EStateFinished )
       
  1160             {
       
  1161             ConstructDelayedL( ETrue );   //EFalse: perform immediately, ETrue: perform using idle time                                
       
  1162             }
       
  1163         
       
  1164         //6. When starting reading, call UpdateL so the informative text 
       
  1165         // "Retrieving data" can be shown instead just the empty screen.    
       
  1166         if (count == 0 && iState == EStateInitializing )
       
  1167             {
       
  1168             iContainer->UpdateL();  
       
  1169             }
       
  1170       
       
  1171         //7. Just in case the menu was open before reading events, handle the possible menu refresh now 
       
  1172         if (finished)
       
  1173             {
       
  1174             HandleMenuRefreshL(CurrentEvent());
       
  1175             }
       
  1176         
       
  1177         }
       
  1178         
       
  1179     TRACE_EXIT_POINT;    
       
  1180     }
       
  1181 
       
  1182 // ----------------------------------------------------------------------------
       
  1183 // CLogsRecentListView::ExtStateChangedL
       
  1184 // ----------------------------------------------------------------------------
       
  1185 //
       
  1186 void CLogsRecentListView::ExtStateChangedL()
       
  1187     {
       
  1188     if( iContainer )
       
  1189         {
       
  1190         iContainer->UpdateL();
       
  1191         }
       
  1192     }
       
  1193 
       
  1194 // ----------------------------------------------------------------------------
       
  1195 // CLogsRecentListView::State
       
  1196 // ----------------------------------------------------------------------------
       
  1197 //
       
  1198 TLogsState CLogsRecentListView::State() const
       
  1199     {
       
  1200     return iState;  
       
  1201     }
       
  1202 
       
  1203 // ----------------------------------------------------------------------------
       
  1204 // CLogsRecentListView::CurrentEvent
       
  1205 //
       
  1206 // Returns event relating current selection of listbox or NULL
       
  1207 // ----------------------------------------------------------------------------
       
  1208 //
       
  1209 const MLogsEventGetter* CLogsRecentListView::CurrentEvent()
       
  1210     {
       
  1211     TRACE_ENTRY_POINT;
       
  1212     //KErrNotFound if no current selection in listbox:
       
  1213     if (iContainer && iContainer->ListBox())
       
  1214         {
       
  1215         SetEventListCurrent(iContainer->ListBox()->CurrentItemIndex());
       
  1216         }
       
  1217     else
       
  1218         {
       
  1219         TRACE_EXIT_POINT;
       
  1220         return NULL;
       
  1221         }
       
  1222     
       
  1223     //Return null if no current selection or no suitable event available 
       
  1224     if( CurrentModel() && CurrentModel()->Count() > 0 && EventListCurrent() >= 0  )    
       
  1225         {
       
  1226         TRACE_EXIT_POINT;
       
  1227         return CurrentModel()->At( EventListCurrent() );    
       
  1228         }
       
  1229     else
       
  1230         {
       
  1231         TRACE_EXIT_POINT;
       
  1232         return NULL;
       
  1233         }
       
  1234     }
       
  1235 
       
  1236 // ----------------------------------------------------------------------------
       
  1237 // CLogsRecentListView::HandleNotifyL
       
  1238 //
       
  1239 // Handle AIW-notifications (from asynch ExecuteCmdL call)
       
  1240 // ----------------------------------------------------------------------------
       
  1241 //
       
  1242 TInt CLogsRecentListView::HandleNotifyL(
       
  1243     TInt aCmdId, 
       
  1244     TInt aEventId,
       
  1245     CAiwGenericParamList& aEventParamList,
       
  1246     const CAiwGenericParamList& aInParamList )
       
  1247     {
       
  1248     TInt result = CLogsBaseView::HandleNotifyL( aCmdId, aEventId, aEventParamList, aInParamList );        
       
  1249     return result;    
       
  1250     }
       
  1251 
       
  1252 
       
  1253 //  End of File