logsui/AppSrc/CLogsBaseView.cpp
branchRCL_3
changeset 20 f4a778e096c2
child 21 9da50d567e3c
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     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 *     Logs Application view superclass
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    22 #include <logengevents.h>
       
    23 #endif
       
    24 #include <eikmenub.h>
       
    25 #include <Pbk2UID.h>
       
    26 #include <bldvariant.hrh>
       
    27 #include <featmgr.h>
       
    28 #include <baclipb.h>
       
    29 #include <AknQueryDialog.h>
       
    30 #include <aknnotewrappers.h> 
       
    31 #include <StringLoader.h> 
       
    32 #include <AiwCommon.hrh>                //kaiwcmdcall
       
    33 #include <AiwContactSelectionDataTypes.h>
       
    34 #include <AiwContactAssignDataTypes.h>
       
    35 
       
    36 #ifdef __OMA_POC
       
    37 #include <pocuiintegrationservices.h>   //cpocuiintegrationservices 
       
    38 #endif
       
    39 
       
    40 #include <commonphoneparser.h>
       
    41 #include <CMessageData.h>
       
    42 #include <sendui.h> 
       
    43 #include <SendUiConsts.h>
       
    44 #include <TSendingCapabilities.h>
       
    45 #include <aknbutton.h>
       
    46 #include <AknsUtils.h>
       
    47 #include <logs.mbg>     // logs own icons
       
    48 #include <LogsApiConsts.h>      //additional event uids
       
    49 #include <CPhCltEmergencyCall.h>
       
    50 
       
    51 #include <Logs.rsg>
       
    52 
       
    53 #include "LogsIcons.hrh"
       
    54 #include "LogsConsts.h"
       
    55 #include "LogsConstants.hrh"
       
    56 #include "LogsUID.h"
       
    57 #include "CLogsBaseView.h"
       
    58 #include "CLogsAppUi.h"
       
    59 #include "CLogsEngine.h"
       
    60 #include "CLogsCntLinkChecker.h"
       
    61 #include "CLogsReaderConfigFactory.h"
       
    62 #include "MLogsReader.h"
       
    63 #include "MLogsEventGetter.h"
       
    64 #include "MLogsSharedData.h"
       
    65 #include "MLogsSystemAgent.h"   
       
    66 #include "CLogsTimer.h"
       
    67 #include "aiwdialdataext.h"
       
    68 #include "CPhoneNumberFormat.h"
       
    69 #include "LogsDebug.h"
       
    70 #include "LogsTraces.h"
       
    71 #include "CLogsPrependQuery.h"    
       
    72 
       
    73 // service table
       
    74 #include <spsettings.h>
       
    75 #include <spentry.h>
       
    76 
       
    77 // EXTERNAL DATA STRUCTURES
       
    78 
       
    79 // EXTERNAL FUNCTION PROTOTYPES  
       
    80 
       
    81 // CONSTANTS
       
    82 
       
    83 // MACROS
       
    84 
       
    85 // LOCAL CONSTANTS AND MACROS
       
    86 
       
    87 // MODULE DATA STRUCTURES
       
    88 
       
    89 // LOCAL FUNCTION PROTOTYPES
       
    90 
       
    91 // ==================== LOCAL FUNCTIONS ====================
       
    92 
       
    93 // ================= MEMBER FUNCTIONS =======================
       
    94 
       
    95 // ----------------------------------------------------------------------------
       
    96 // CLogsBaseView::LogsAppUi
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 CLogsAppUi* CLogsBaseView::LogsAppUi()
       
   100     {
       
   101     return static_cast<CLogsAppUi*>( CAknView::AppUi() );
       
   102     }
       
   103 
       
   104 // ----------------------------------------------------------------------------
       
   105 // CLogsBaseView::~CLogsBaseView
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 CLogsBaseView::~CLogsBaseView()
       
   109     {
       
   110     delete iSendUiText;
       
   111     delete iAddress;    
       
   112     delete iConstructDelayed;
       
   113     delete iNumberInPbkProcessing;
       
   114     delete iUriInPbkProcessing;    
       
   115     delete iLogsTimer;    
       
   116     delete iEmergencyCallAPI;
       
   117     RemoveInputBlocker();
       
   118     }
       
   119 
       
   120 // ----------------------------------------------------------------------------
       
   121 // CLogsBaseView::CLogsBaseView
       
   122 // ----------------------------------------------------------------------------
       
   123 //
       
   124 CLogsBaseView::CLogsBaseView() : 
       
   125     iConstructDelayedOk( EFalse ),
       
   126     iSendUiText( NULL ),
       
   127     iFocusChangeControl( ELogsOkToChange ),     
       
   128     iEventListCurrent( 0 ),
       
   129     iEventListTop( 0 ),
       
   130     iRefreshMenuOnUpdate( EFalse ),
       
   131     iMenuType(CEikMenuBar::EMenuOptions),
       
   132     iInputBlocker(NULL),
       
   133     iIsCheckedCntLinkInvaild( EFalse),  
       
   134 	iResetAndRefreshOnHandleNotify(MLogsModel::ERefresh),
       
   135 	iIgnoreViewDeactivatedHandling(EFalse),
       
   136 	iSemiFinishViewDeactivatedOperation(EFalse)
       
   137     {
       
   138     //Construct CIdle object call back to finalise time consuming construction
       
   139     iConstructDelayed = CIdle::New( CActive::EPriorityIdle );
       
   140     
       
   141     if( iConstructDelayed )
       
   142         {
       
   143         //The below seems to slow down reading of Logs entries from db so we're
       
   144         //not calling it from here
       
   145         //iConstructDelayed->Start( TCallBack( ConstructDelayedCallbackL, this) );            
       
   146         }
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------------------------------
       
   150 // CLogsBaseView::BaseConstructL
       
   151 //
       
   152 // This is just a hook to catch BaseConstructL calls from derived classes before/
       
   153 // after call to super class's BaseConstructL if needed.
       
   154 // ----------------------------------------------------------------------------
       
   155 //
       
   156 void CLogsBaseView::BaseConstructL(TInt aResId )
       
   157     {
       
   158     CAknView::BaseConstructL( aResId );
       
   159     
       
   160     if( AknLayoutUtils::PenEnabled() && Toolbar() ) 
       
   161         {
       
   162         //By default keep toolbar invisible        
       
   163         ShowToolbarOnViewActivation( EFalse ); 
       
   164         Toolbar()->SetToolbarObserver( this );
       
   165         } 
       
   166     }
       
   167     
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // CLogsBaseView::Engine
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 CLogsEngine* CLogsBaseView::Engine()
       
   174     {
       
   175     return LogsAppUi()->Engine();
       
   176     }
       
   177 
       
   178 // Safwish VoIP changes  >>>
       
   179 // ----------------------------------------------------------------------------
       
   180 // CLogsBaseView::SendUiTextL
       
   181 // ----------------------------------------------------------------------------
       
   182 //
       
   183 const TDesC& CLogsBaseView::SendUiTextL()
       
   184     {
       
   185     if ( !iSendUiText )
       
   186         {
       
   187         iSendUiText =  iCoeEnv->AllocReadResourceL( R_STM_WRITE_MSG );
       
   188         }    
       
   189     return *iSendUiText;
       
   190     }
       
   191 // <<< Safwish VoIP changes  
       
   192 
       
   193 // ----------------------------------------------------------------------------
       
   194 // CLogsBaseView::ConstructDelayedL
       
   195 //
       
   196 // Perform time consuming construction operations once. Calling this is needed 
       
   197 // before e.g. pressing Send key or launching a command from ui's menu.
       
   198 // ----------------------------------------------------------------------------
       
   199 //
       
   200 void CLogsBaseView::ConstructDelayedL( TBool aIdle )  //EFalse: immediately
       
   201     {                                                 //ETrue:  using idle time
       
   202     if( iConstructDelayed && aIdle && !iConstructDelayed->IsActive() )     
       
   203         {
       
   204         iConstructDelayed->Start( TCallBack( ConstructDelayedCallbackL, this) );            
       
   205         }
       
   206     else
       
   207         {
       
   208         DoConstructDelayedL();            
       
   209         }        
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // CLogsBaseView::ConstructDelayedCallbackL
       
   214 //
       
   215 // Called from CIdle once to finish time consuming construction operations
       
   216 // ----------------------------------------------------------------------------
       
   217 //
       
   218 TInt CLogsBaseView::ConstructDelayedCallbackL( TAny* aContainer )
       
   219     {
       
   220     CLogsBaseView* container = static_cast<CLogsBaseView*>( aContainer );
       
   221     container->DoConstructDelayedL();    
       
   222     return 0;
       
   223     }
       
   224 
       
   225 // ----------------------------------------------------------------------------
       
   226 // CLogsBaseView::DoConstructDelayedL
       
   227 //
       
   228 // Perform time consuming construction operations once. 
       
   229 // ----------------------------------------------------------------------------
       
   230 //
       
   231 void CLogsBaseView::DoConstructDelayedL()
       
   232     {
       
   233     TRACE_ENTRY_POINT;
       
   234     
       
   235     if( iConstructDelayed ) 
       
   236         {
       
   237         iConstructDelayed->Cancel();
       
   238         delete iConstructDelayed;
       
   239         iConstructDelayed = NULL;
       
   240         }
       
   241     
       
   242     if( iConstructDelayedOk ) 
       
   243         {
       
   244         return;    
       
   245         }
       
   246         
       
   247     iConstructDelayedOk = ETrue;
       
   248     iServHandlerRef = LogsAppUi()->CallUiL();  //ownership remains in LogsAppUi,
       
   249                                                //this takes a lot of time.
       
   250                                            
       
   251     if ( !iSendUiText )
       
   252         {
       
   253         iSendUiText = iCoeEnv->AllocReadResourceL( R_STM_WRITE_MSG );
       
   254         }
       
   255 
       
   256     iAddress = iCoeEnv->AllocReadResourceL(R_LOGS_ADDR_PROMPT);    
       
   257     iLogsTimer = CLogsTimer::NewL( CActive::EPriorityUserInput ); //EPriorityStandard  EPriorityHigh
       
   258     iEmergencyCallAPI = CPhCltEmergencyCall::NewL( this );
       
   259     
       
   260     TRACE_EXIT_POINT
       
   261     }
       
   262 
       
   263 
       
   264 // ----------------------------------------------------------------------------
       
   265 // CLogsBaseView::HandleLogsTimerL
       
   266 //
       
   267 // Callback function for iLogsTimer 
       
   268 // ----------------------------------------------------------------------------
       
   269 //
       
   270 void CLogsBaseView::HandleLogsTimerL( TAny* /* aPtr */ )
       
   271     {
       
   272     HandleCommandL( ELogsCmdLongSendKeyCall );
       
   273     }
       
   274 
       
   275 // ----------------------------------------------------------------------------
       
   276 // CLogsBaseView::LaunchPopupMenuL
       
   277 //
       
   278 // Launch a popup menu when ok-button has been pressed
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 void CLogsBaseView::LaunchPopupMenuL( TInt aResourceId )
       
   282     {
       
   283     SetCurrentMenuType(CEikMenuBar::EMenuContext);
       
   284     
       
   285     TRAPD( err, DoLaunchPopupL( aResourceId ) );
       
   286     if( err )
       
   287         {
       
   288         SetCurrentMenuType(CEikMenuBar::EMenuOptions);
       
   289         User::Leave( err );
       
   290         }
       
   291         
       
   292     SetCurrentMenuType(CEikMenuBar::EMenuOptions);
       
   293     }
       
   294 
       
   295 // ----------------------------------------------------------------------------
       
   296 // CLogsBaseView::DoLaunchPopupL
       
   297 //
       
   298 // Performs the popup menu launching
       
   299 // ----------------------------------------------------------------------------
       
   300 //
       
   301 void CLogsBaseView::DoLaunchPopupL( TInt aResourceId )
       
   302     {
       
   303     MenuBar()->SetContextMenuTitleResourceId( aResourceId );    
       
   304     MenuBar()->TryDisplayContextMenuBarL(); //TryDisplayContextMenuBarL() does not provide "Act 
       
   305                                             //apps" selection as TryDisplayMenuBarL() would.
       
   306     }
       
   307 
       
   308 // ----------------------------------------------------------------------------
       
   309 // CLogsBaseView::FindXSPServiceSettingsLC
       
   310 // Checks for stored settings for the logged service id. Returns a pointer to the 
       
   311 // found service table entry or NULL. If a NULL pointer is returned, the object is 
       
   312 // not pushed to the CleanupStack.
       
   313 // ----------------------------------------------------------------------------
       
   314 //
       
   315 CSPEntry* CLogsBaseView::FindXSPServiceSettingsLC(const MLogsEventGetter* aEvent)
       
   316     {
       
   317     CSPEntry* entry = NULL;
       
   318     
       
   319     // check only if the service id and sip uri stored.
       
   320     if (aEvent->LogsEventData()->ServiceId() && SipUriAvailable( aEvent ) )
       
   321         {
       
   322         TInt err = KErrNotFound;
       
   323         entry = CSPEntry::NewLC();      
       
   324        
       
   325         CSPSettings* settings = CSPSettings::NewL();
       
   326         CleanupStack::PushL(settings);
       
   327         err = settings->FindEntryL( aEvent->LogsEventData()->ServiceId(), *entry );  
       
   328         CleanupStack::PopAndDestroy( settings ); 
       
   329         
       
   330         if (err != KErrNone)
       
   331             {
       
   332             CleanupStack::PopAndDestroy( entry ); 
       
   333             entry = NULL;
       
   334             }   
       
   335         }
       
   336      
       
   337     return entry;
       
   338     }
       
   339         
       
   340         
       
   341         
       
   342 // ----------------------------------------------------------------------------
       
   343 // CLogsBaseView::CmdSaveToVirtualPhonebookL
       
   344 // ----------------------------------------------------------------------------
       
   345 //
       
   346 void CLogsBaseView::CmdSaveToVirtualPhonebookL( 
       
   347     TInt aCommandId, 
       
   348     TBool aCalledForMenu,
       
   349     const MLogsEventGetter* aEvent )    
       
   350     {
       
   351     TRACE_ENTRY_POINT;
       
   352     
       
   353     using namespace AiwContactAssign;        
       
   354     
       
   355     CAiwGenericParamList& inParamList = iServHandlerRef->InParamListL();    
       
   356     
       
   357     TUint assignFlags = NULL;
       
   358     
       
   359     if( !aCalledForMenu )
       
   360         {
       
   361         assignFlags = AiwContactAssign::ECreateNewContact;
       
   362         }
       
   363 
       
   364     inParamList.AppendL(
       
   365         TAiwGenericParam(
       
   366             EGenericParamContactAssignData,     //AiwGenericParam.hrh
       
   367             TAiwVariant(TAiwSingleContactAssignDataV1Pckg( 
       
   368                 TAiwSingleContactAssignDataV1().SetFlags(assignFlags)))));                    
       
   369 //           TAiwVariant(TAiwContactAttributeAssignDataV1Pckg( 
       
   370 //               TAiwContactAttributeAssignDataV1().SetFlags(assignFlags)))));
       
   371 // the above commented code also provides just one field to add to phonenbook so we must 
       
   372 // select between msisdn and uri in code below.
       
   373     
       
   374     
       
   375     // Check first if there is a service id logged and there are settigs configured.
       
   376     // If valid settings found for the logged service id, store to contacts as an xsp id
       
   377     //   
       
   378     CSPEntry* entry = FindXSPServiceSettingsLC(aEvent);
       
   379     if (entry)
       
   380         {    
       
   381         TBuf<KLogsSipUriMaxLen> xspuserid;
       
   382         if ( Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), xspuserid ))
       
   383             {
       
   384             return; //Converting uri to unicode failed
       
   385             }
       
   386         else 
       
   387             {     
       
   388             _LIT(KLogsColon, ":");
       
   389             
       
   390             HBufC* xspid = HBufC::NewLC(
       
   391                     xspuserid.Length() + 
       
   392                     entry->GetServiceName().Length() + 
       
   393                     KLogsColon().Length() );
       
   394             
       
   395             xspid->Des().Append( entry->GetServiceName() );        
       
   396             xspid->Des().Append( KLogsColon );
       
   397             xspid->Des().Append( xspuserid );                                   
       
   398             
       
   399             inParamList.AppendL( 
       
   400                 TAiwGenericParam(
       
   401                         EGenericParamXSpId,
       
   402                         TAiwVariant(  xspid->Des() )
       
   403                 ));         
       
   404             CleanupStack::PopAndDestroy( xspid ); 
       
   405             CleanupStack::PopAndDestroy( entry );
       
   406             }
       
   407         }
       
   408     //
       
   409     // If service id not found or no valid settings, store as a sip uir or phonenumber
       
   410     //
       
   411     else if( SipUriAvailable( aEvent ) )
       
   412         {
       
   413         //inParamList allocates it's own buffer, so it's safe to hand over buf 
       
   414         TBuf<KLogsSipUriMaxLen> buf; 
       
   415         if ( Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf ) )
       
   416             {
       
   417             return; //Converting uri to unicode failed
       
   418             }
       
   419         else
       
   420             {
       
   421             inParamList.AppendL(
       
   422                 TAiwGenericParam(
       
   423                     EGenericParamSIPAddress,
       
   424                     TAiwVariant( buf )
       
   425                     ));        
       
   426             }
       
   427         }    
       
   428     else if( PhoneNumberAvailable( aEvent ) )
       
   429         {
       
   430         inParamList.AppendL(
       
   431             TAiwGenericParam(
       
   432                 EGenericParamPhoneNumber,
       
   433                 TAiwVariant( aEvent->Number() )
       
   434                 ));
       
   435         }
       
   436     else
       
   437         {
       
   438         return; //Nothing to store
       
   439         }
       
   440 
       
   441     delete iNumberInPbkProcessing;
       
   442     delete iUriInPbkProcessing;    
       
   443     iNumberInPbkProcessing = NULL;
       
   444     iUriInPbkProcessing = NULL;    
       
   445     
       
   446     //2. If sip uri available, we prefer it over phone number (PoC or VoIP)
       
   447     if( SipUriAvailable( aEvent ))    
       
   448         {
       
   449         TBuf<KLogsSipUriMaxLen> buf; 
       
   450         // Returns KErrNone if everythin ok
       
   451         if ( !(Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf )) ) 
       
   452             {
       
   453             iUriInPbkProcessing = buf.AllocL();
       
   454             }
       
   455         }
       
   456     else if( PhoneNumberAvailable( aEvent ))    
       
   457         {
       
   458         iNumberInPbkProcessing = aEvent->Number()->AllocL();        
       
   459         }
       
   460         
       
   461     //Add to Phonebook    will call CPbk2AiwAssignProvider::HandleServiceCmdL    
       
   462     if ( !aCalledForMenu )    
       
   463         {
       
   464         iServHandlerRef->ExecuteServiceCmdL(
       
   465             aCommandId,
       
   466             inParamList,
       
   467             iServHandlerRef->OutParamListL(),
       
   468             0,
       
   469             this );//HandleNotifyL
       
   470         }
       
   471     else
       
   472         {
       
   473         iServHandlerRef->ExecuteMenuCmdL(
       
   474             aCommandId,
       
   475             inParamList,
       
   476             iServHandlerRef->OutParamListL(),
       
   477             0,
       
   478             this );//HandleNotifyL
       
   479         }
       
   480     
       
   481     // Store AiW call parameters so that we can cancel the call later if needed. 
       
   482     SaveAiwCallParamsL(aCommandId, aCalledForMenu, &inParamList);
       
   483     
       
   484     // Set input blocker cause we don't want to have the user open menus etc
       
   485     // while opening phonebook
       
   486     SetInputBlockerL();
       
   487 
       
   488     TRACE_EXIT_POINT;    
       
   489     }
       
   490 
       
   491 
       
   492 
       
   493 // --------------------------------------------------------------------------
       
   494 // CLogsBaseView::SaveAiwCallParamsL
       
   495 // --------------------------------------------------------------------------
       
   496 //
       
   497 void CLogsBaseView::SaveAiwCallParamsL( TInt aCommandId,
       
   498                                         TBool  aCalledForMenu,
       
   499                                         CAiwGenericParamList*  aInParamList ) 
       
   500     { 
       
   501     iAiwCommandId = aCommandId;
       
   502     iAiwCalledFromMenu = aCalledForMenu;
       
   503     iAiwInParamList = aInParamList;
       
   504     
       
   505     // To detect and cancel the aiw call early enough, we will need to observe view activation
       
   506     LogsAppUi()->AddViewActivationObserverL(this);
       
   507     }
       
   508 
       
   509 // --------------------------------------------------------------------------
       
   510 // CLogsBaseView::ClearAiwCallParams
       
   511 // --------------------------------------------------------------------------
       
   512 //
       
   513 void CLogsBaseView::ClearAiwCallParams()
       
   514     {
       
   515     iAiwCommandId = KErrNotFound;
       
   516     iAiwCalledFromMenu = EFalse;
       
   517     iAiwInParamList = NULL;
       
   518       
       
   519     // No need to observe view activation anymore. 
       
   520     LogsAppUi()->RemoveViewActivationObserver(this);
       
   521     }
       
   522 
       
   523 // --------------------------------------------------------------------------
       
   524 // CLogsBaseView::CancelSaveToPbkL
       
   525 // --------------------------------------------------------------------------
       
   526 //
       
   527 void CLogsBaseView::CancelSaveToPbkL()
       
   528     {
       
   529     if (iAiwInParamList && iAiwCommandId != KErrNotFound )
       
   530         {
       
   531         
       
   532         iResetAndRefreshOnHandleNotify = MLogsModel::EResetAndRefresh;
       
   533         
       
   534         // Cancel the previously done AiW call by calling with the same parameters
       
   535         // + flag KAiwOptCancel
       
   536         //
       
   537         if ( !iAiwCalledFromMenu )    
       
   538             {
       
   539             iServHandlerRef->ExecuteServiceCmdL(
       
   540                     iAiwCommandId,
       
   541                     *iAiwInParamList,
       
   542                     iServHandlerRef->OutParamListL(),
       
   543                     KAiwOptCancel,
       
   544                     this );//HandleNotifyL
       
   545             }
       
   546         else
       
   547             {
       
   548             iServHandlerRef->ExecuteMenuCmdL(
       
   549                     iAiwCommandId,
       
   550                     *iAiwInParamList,
       
   551                     iServHandlerRef->OutParamListL(),
       
   552                     KAiwOptCancel,
       
   553                     this  );//HandleNotifyL
       
   554             }          
       
   555         }
       
   556   
       
   557     ClearAiwCallParams();
       
   558     } 
       
   559 
       
   560    
       
   561 // --------------------------------------------------------------------------
       
   562 // CLogsBaseView::HandleViewActivation
       
   563 // --------------------------------------------------------------------------
       
   564 //
       
   565 void CLogsBaseView::HandleViewActivation(const TVwsViewId& aNewlyActivatedViewId,const TVwsViewId& aViewIdToBeDeactivated)
       
   566     { 
       
   567     TInt err;
       
   568     
       
   569     // Do nothing if iNumberInPbkProcessing of iUriInPbkProcessing already cancelled.
       
   570     //
       
   571     if ( iNumberInPbkProcessing || iUriInPbkProcessing  )
       
   572         {
       
   573         // If another Logs view is going to be activated, cancel the save to pbk AiW command.
       
   574         //
       
   575         if ( aNewlyActivatedViewId.iAppUid == TUid::Uid(KLogsAppUID3) &&
       
   576              aNewlyActivatedViewId.iViewUid != this->Id() )            
       
   577             {  
       
   578             TRAP(err, CancelSaveToPbkL());
       
   579             }
       
   580         //
       
   581         // Also if Logs has received a commandline parameter telling it to activate this view,
       
   582         // like when opening Logs from Idle with send key, it is best to cancel the command so that
       
   583         // the view is in "fresh" state.
       
   584         //
       
   585         else if ( aNewlyActivatedViewId.iAppUid == TUid::Uid(KLogsAppUID3) &&
       
   586                   aNewlyActivatedViewId.iViewUid == this->Id() && 
       
   587                   aViewIdToBeDeactivated.iAppUid != TUid::Uid(KLogsAppUID3) )
       
   588             {
       
   589             // Reset array, will call StateChangedL with state EStateArrayReseted and update the listbox.
       
   590             if ( (aNewlyActivatedViewId.iViewUid.iUid == EStmDialledListViewId )||
       
   591                     (aNewlyActivatedViewId.iViewUid.iUid == EStmMissedListViewId )||
       
   592                     (aNewlyActivatedViewId.iViewUid.iUid == EStmReceivedListViewId ))
       
   593                 {
       
   594                 CurrentModel()->DoDeactivate( MLogsModel::ESkipClearing,
       
   595                                                           MLogsModel::EKeepDBConnection ); 
       
   596                 }
       
   597             else
       
   598                 {
       
   599                 CurrentModel()->DoDeactivate( MLogsModel::ESkipClearing,
       
   600                                                           MLogsModel::EResetOnlyArray ); 
       
   601                 }	
       
   602             DrawComponents();
       
   603             TRAP(err, CancelSaveToPbkL());
       
   604             }
       
   605         
       
   606         // If a leave happened, clear the call parameters here.
       
   607         if (err != KErrNone)
       
   608             {
       
   609             ClearAiwCallParams();
       
   610             }
       
   611         }
       
   612     }
       
   613 
       
   614 // ----------------------------------------------------------------------------
       
   615 // CLogsBaseView::StateChangedL
       
   616 // ----------------------------------------------------------------------------
       
   617 //
       
   618 void CLogsBaseView::StateChangedL( MLogsStateHolder* aHolder )
       
   619     {
       
   620     if ( !aHolder )
       
   621         {
       
   622         return;
       
   623         }
       
   624     if ( aHolder->State() == EStateCheckContactLinkFinished )
       
   625         {
       
   626         const MLogsEventGetter* event = NULL;
       
   627         MLogsEventData* eventData = NULL;
       
   628         
       
   629         if( CurrentModel() && CurrentModel()->Count() > 0 && EventListCurrent() >= 0 )
       
   630             {
       
   631             event = CurrentModel()->At( EventListCurrent() );    
       
   632             eventData = event->LogsEventData();
       
   633             
       
   634             if ( eventData )
       
   635                 {
       
   636                 TPtrC8 ptrContactLink( KNullDesC8 );
       
   637                 if ( KErrNone == eventData->GetContactLink( ptrContactLink ) )
       
   638                     {
       
   639                     CLogsCntLinkChecker* contactCheckerPtr = Engine()->CntLinkCheckerL();
       
   640                     if ( !contactCheckerPtr->IsCntLinkValidSync( ptrContactLink ) )
       
   641                         {
       
   642                         iIsCheckedCntLinkInvaild = ETrue;
       
   643                         }
       
   644                     }
       
   645                 // When log event is for VOIP, it needs to check if the contact link is valid.
       
   646                 // If it's invalid, refresh menubar in order to avoid "voice" and "video" items.
       
   647                 // Can't avoid flicking in this case, however, it's so rare to repro.
       
   648                 if ( eventData->VoIP() && SipUriAvailable( event ) 
       
   649                        && iIsCheckedCntLinkInvaild )
       
   650                     {
       
   651                     if ( MenuBar()->IsDisplayed() )
       
   652                         {
       
   653                         MenuBar()->StopDisplayingMenuBar();
       
   654         
       
   655                         if ( CurrentMenuType() == CEikMenuBar::EMenuContext )
       
   656                             {
       
   657                             MenuBar()->TryDisplayContextMenuBarL();
       
   658                             }
       
   659                             else
       
   660                             {
       
   661                             MenuBar()->TryDisplayMenuBarL();
       
   662                             }
       
   663                         }
       
   664                     }
       
   665                 }
       
   666             }
       
   667         }
       
   668     }
       
   669 
       
   670 // --------------------------------------------------------------------------
       
   671 // CLogsBaseView::SetInputBlockerL
       
   672 // --------------------------------------------------------------------------
       
   673 //
       
   674 void CLogsBaseView::SetInputBlockerL()
       
   675      {
       
   676      if (!iInputBlocker)
       
   677          {
       
   678          iInputBlocker = CAknInputBlock::NewCancelHandlerLC( this );
       
   679          CleanupStack::Pop( iInputBlocker );   
       
   680          iInputBlocker->SetCancelDelete( iInputBlocker );
       
   681          }
       
   682      } 
       
   683 
       
   684 // --------------------------------------------------------------------------
       
   685 // CLogsBaseView::RemoveInputBlockerL
       
   686 // --------------------------------------------------------------------------
       
   687 //
       
   688 void CLogsBaseView::RemoveInputBlocker()
       
   689     {
       
   690     if (iInputBlocker)
       
   691         {
       
   692         iInputBlocker->Cancel();
       
   693         }
       
   694     }
       
   695 
       
   696 // --------------------------------------------------------------------------
       
   697 // CLogsBaseView::AknInputBlockCancel
       
   698 // --------------------------------------------------------------------------
       
   699 //
       
   700 void CLogsBaseView::AknInputBlockCancel()
       
   701      {
       
   702      iInputBlocker = NULL;
       
   703      } 
       
   704 
       
   705 // ----------------------------------------------------------------------------
       
   706 // CLogsBaseView::ProcessKeyEventL
       
   707 //
       
   708 // Called by base control container when a key press happens.     
       
   709 // ----------------------------------------------------------------------------
       
   710 //
       
   711 TBool CLogsBaseView::ProcessKeyEventL( 
       
   712     const TKeyEvent& aKeyEvent,
       
   713     TEventCode aType )
       
   714     {
       
   715     if( aType == EEventKey )
       
   716         {
       
   717         switch( aKeyEvent.iCode )
       
   718             {
       
   719             case EKeyApplication0:  //S60 app key pressed
       
   720                 iCoeEnv->Flush( KDelayMicroSeconds );
       
   721                 return EFalse;
       
   722             }
       
   723         }
       
   724     
       
   725     return EFalse;
       
   726     }   
       
   727     
       
   728 // ----------------------------------------------------------------------------
       
   729 // CLogsBaseView::ProcessPointerEventL
       
   730 //
       
   731 // Default handler for pointer events, when the current focused item is tapped
       
   732 // ----------------------------------------------------------------------------
       
   733 //
       
   734 void CLogsBaseView::ProcessPointerEventL( TInt aIndex)
       
   735 	{
       
   736     // Default action when tapping the focused item is to open another view
       
   737     LogsAppUi()->CmdOkL(aIndex);
       
   738 	}
       
   739   
       
   740 // ----------------------------------------------------------------------------
       
   741 // CLogsBaseView::FocusChangedL
       
   742 //
       
   743 // Informs subclass that focus is changed in listbox (item is tapped)
       
   744 // ----------------------------------------------------------------------------
       
   745 //
       
   746 //void CLogsBaseView::FocusChangedL()
       
   747 //	{
       
   748 //    HandleCommandL( ELogsCmdHandleTapFocusChange );    //Calls subclass impl if available
       
   749 //	}
       
   750 
       
   751 // --------------------------------------------------------------------------
       
   752 // CLogsBaseView::DynInitToolbarL
       
   753 // --------------------------------------------------------------------------
       
   754 //
       
   755 void CLogsBaseView::DynInitToolbarL( 
       
   756     TInt /* aResourceId */, 
       
   757     CAknToolbar* /* aToolbar */ )
       
   758     {
       
   759     }
       
   760 
       
   761 // --------------------------------------------------------------------------
       
   762 // CLogsBaseView::OfferToolbarEventL
       
   763 // --------------------------------------------------------------------------
       
   764 //
       
   765 void CLogsBaseView::OfferToolbarEventL( TInt aCommand )
       
   766     {
       
   767     // Call ConstructDelayedL now incase it has not been done yet. 
       
   768     // One example case was ELFG-6YV99Q when there are less than a screenful of events 
       
   769     // (see magic number KNbrShownEntries in CLogsRecentListView::StateChangedL)
       
   770     ConstructDelayedL( EFalse ); 
       
   771     HandleCommandL( aCommand );    //Calls subclass impl if available
       
   772     }
       
   773 
       
   774 // ----------------------------------------------------------------------------
       
   775 // CLogsBaseView::HandleLosingForeground
       
   776 //
       
   777 // This function is called once for each type of already constructed view 
       
   778 // (e.g.when fast swapping window is brought to foreground).
       
   779 // ----------------------------------------------------------------------------
       
   780 //
       
   781 void CLogsBaseView::HandleLosingForeground()
       
   782     {
       
   783     }
       
   784 
       
   785 // ----------------------------------------------------------------------------
       
   786 // CLogsBaseView::HandleGainingForeground
       
   787 //
       
   788 // This function is called once for each already View when 
       
   789 // Logs is gaining foreground. No matter if a view is deactivated (i.e. is also 
       
   790 // called for view(s) not actually gaining foreground but just have been constructed)
       
   791 // ----------------------------------------------------------------------------
       
   792 //
       
   793 void CLogsBaseView::HandleGainingForeground()
       
   794     {     
       
   795     }
       
   796     
       
   797 // ----------------------------------------------------------------------------
       
   798 // CLogsBaseView::DoDeactivate
       
   799 // ----------------------------------------------------------------------------
       
   800 //
       
   801 void CLogsBaseView::DoDeactivate()
       
   802     {
       
   803     }
       
   804 
       
   805 // ----------------------------------------------------------------------------
       
   806 // CLogsBaseView::DoActivateL
       
   807 // ----------------------------------------------------------------------------
       
   808 //
       
   809 void CLogsBaseView::DoActivateL(
       
   810     const TVwsViewId& /* aPrevViewId */,
       
   811     TUid /* aCustomMessageId */,
       
   812     const TDesC8& /* aCustomMessage */ )
       
   813     {
       
   814     // AppUi owns the service handler refrence and it might have been deleted and recreated
       
   815     // so the reference here might thus be invalid. But skip this step if delayed construction 
       
   816     // is still going to be done.
       
   817     if (iConstructDelayedOk)
       
   818         {
       
   819         iServHandlerRef = LogsAppUi()->CallUiL(EFalse);  //ownership remains in LogsAppUi,
       
   820         }
       
   821     }
       
   822 
       
   823 // ----------------------------------------------------------------------------
       
   824 // CLogsBaseView::HandleSendKeyMenuCommandL
       
   825 //
       
   826 // Handles send key press when menu is open. For call commands, send key works as 
       
   827 // if the menu option would have been selected. Default behaviour is not to consume the
       
   828 // key which causes send key to open dialler. 
       
   829 // ----------------------------------------------------------------------------
       
   830 //
       
   831 TBool CLogsBaseView::ProcessSendKeyEventInMenuL(TEventCode aType, const MLogsEventGetter* aEvent)
       
   832     {
       
   833     CEikMenuPane* cascadeMenuPane = MenuBar()->MenuPane()->CascadeMenuPane();
       
   834     TInt cmdId = KErrNotFound;
       
   835     TBool ret = EFalse;
       
   836     
       
   837     if (cascadeMenuPane && cascadeMenuPane->IsFocused())
       
   838         {
       
   839         cmdId = cascadeMenuPane->MenuItemCommandId( cascadeMenuPane->SelectedItem() );
       
   840         } 
       
   841     
       
   842     TInt srvCmd = iServHandlerRef->ServiceCmdByMenuCmd( cmdId ); 
       
   843     switch( srvCmd )    //AiwCommon.hrh
       
   844         {
       
   845         case KAiwCmdCall:    
       
   846         case KAiwCmdPoC:  
       
   847             {
       
   848             if (aType == EEventKeyDown ) 
       
   849                 {
       
   850                 MenuBar()->StopDisplayingMenuBar();
       
   851                 CmdAiwMenuCmdL(cmdId, aEvent);
       
   852                 }
       
   853             ret = ETrue; // consume the send key  
       
   854             break;
       
   855             }    
       
   856           
       
   857         case KErrNotFound:      
       
   858         default:
       
   859             {
       
   860             ret = EFalse; // send key event not consumed
       
   861             break;       
       
   862             }
       
   863         }
       
   864     
       
   865     return ret;
       
   866     }
       
   867 
       
   868 // ----------------------------------------------------------------------------
       
   869 // CLogsBaseView::ProcessKeyEventEventL
       
   870 //
       
   871 // For subclasses to handle key events needing LogEvent data    
       
   872 // ----------------------------------------------------------------------------
       
   873 //
       
   874 TBool CLogsBaseView::ProcessKeyEventEventL( 
       
   875     const TKeyEvent& aKeyEvent,
       
   876     TEventCode aType,
       
   877     const MLogsEventGetter* aEvent )
       
   878     {
       
   879     //First try non-event related
       
   880     TBool ret = CLogsBaseView::ProcessKeyEventL( aKeyEvent, aType ); //Don't call subclass again    
       
   881     
       
   882     // If events not read yet or a query dialog is shown, consume the key so dialler is not opened
       
   883     if ( aKeyEvent.iScanCode == EStdKeyYes && ( LogsAppUi()->IsDisplayingDialog() || !aEvent ) )
       
   884         {
       
   885         return ETrue;
       
   886         } 
       
   887     else if( ret || !aEvent )
       
   888         {
       
   889         return ret;
       
   890         }
       
   891   
       
   892     //Process Send key for cellular, voip or poc call 
       
   893     if( aKeyEvent.iScanCode == EStdKeyYes )
       
   894         {
       
   895         ConstructDelayedL( EFalse );        //EFalse: perform immediately
       
   896         TBool supportLongSendPress = EFalse;//FIXME: FeatureManager::FeatureSupported( ??? ) this value should be available from platform in future
       
   897         
       
   898         // Handle first the special case when send key is pressed while options menu is open
       
   899         // default behaviour is not to consume the key and let dialler open. For some call commands
       
   900         // it is better to handle the command as if the menu option had been selected.
       
   901         if (MenuBar()->IsDisplayed() && MenuBar()->MenuPane() )
       
   902             {
       
   903             return ProcessSendKeyEventInMenuL(aType, aEvent); 
       
   904             }       
       
   905         // 
       
   906         else if( aType == EEventKeyDown ) 
       
   907             {     
       
   908             if( supportLongSendPress ) 
       
   909                 {
       
   910                 //Start timer to wait delay period for forced video call
       
   911                 const TInt delay = 600000; //0.6sec, FIXME: this value should be available from platform in future
       
   912                 iLogsTimer->Cancel();
       
   913                 iLogsTimer->After( delay, this,  const_cast<MLogsEventGetter*>(aEvent) );
       
   914                 }
       
   915             else
       
   916                 {
       
   917                 HandleCommandEventL( ELogsCmdSendKeyCall, aEvent ); 
       
   918                 }
       
   919             }
       
   920         else if( aType == EEventKey )             
       
   921             {
       
   922             //nop (send key down)
       
   923             }
       
   924         else if( aType == EEventKeyUp ) 
       
   925             {
       
   926             if( supportLongSendPress && iLogsTimer->IsActive() ) 
       
   927                 {
       
   928                 //Not pressed long enough, make normal call
       
   929                 iLogsTimer->Cancel();                
       
   930                 HandleCommandEventL( ELogsCmdSendKeyCall, aEvent ); 
       
   931                 }
       
   932             }
       
   933         return ETrue;                 
       
   934         }
       
   935 
       
   936     //Process other keys
       
   937     if( aType == EEventKey )
       
   938         {
       
   939         switch( aKeyEvent.iCode )
       
   940             {
       
   941             case EKeyApplication0:  //S60 app key pressed
       
   942                 iCoeEnv->Flush( KDelayMicroSeconds );
       
   943                 return EFalse;
       
   944                 
       
   945 //            case EKeyPhoneSend: //Send key pressed      (same as EKeyYes in enum TKeyCode)                
       
   946 //                return ETrue;            
       
   947                 
       
   948             //PoC key usage (Voice/side key) goes as follows:
       
   949             //When Poc app is active, it captures the key press. If Logs window is active in foreground,
       
   950             //Poc app sends EKeyPoC event to Logs. Because we don't get EKeySide event to Logs, we are dependent 
       
   951             //on PoC to be active app to provide it (so no need to check the EKeySide event). Therefore only 
       
   952             //Poc call should be provided, no voip or voice call even if the current Logs event is voice/voip 
       
   953             //when EKeyPoC was pressed.
       
   954 
       
   955             //case EKeySide:    //Voice key pressed     (same as EKeyDevice6 in enum TKeyCode)
       
   956             case EKeyPoC:       //Poc key pressed       (same as EKeyApplication1 in enum TKeyCode)
       
   957                 if ( MenuBar()->ItemSpecificCommandsEnabled() )
       
   958                     {
       
   959                     //First check have we already done construction fully. If not, then we first need to do it. 
       
   960                     ConstructDelayedL( EFalse );   //EFalse: perform immediately
       
   961                     HandleCommandEventL( ELogsCmdDeviceCallKey, aEvent ); //Other device special key pressed e.g. 
       
   962                                                                           //for poc call
       
   963                     return ETrue;
       
   964                     }
       
   965             }
       
   966         }
       
   967 
       
   968     //Set MSK & toolbar state        
       
   969     if(( aKeyEvent.iScanCode == EStdKeyUpArrow || 
       
   970          aKeyEvent.iScanCode == EStdKeyDownArrow ) && 
       
   971          aType == EEventKey ) 
       
   972         {
       
   973         SetToolbarItems( aEvent );
       
   974                 
       
   975         Cba()->MakeCommandVisible( 
       
   976             EAknSoftkeyContextOptions, 
       
   977             IsOkToShowContextMenu( aEvent ));
       
   978         }
       
   979    
       
   980     return EFalse;
       
   981     }
       
   982     
       
   983     
       
   984 // ----------------------------------------------------------------------------
       
   985 // CLogsBaseView::TabObserver
       
   986 //
       
   987 // ----------------------------------------------------------------------------
       
   988 //
       
   989 MAknTabObserver* CLogsBaseView::TabObserver()
       
   990     {
       
   991     return LogsAppUi();
       
   992     }
       
   993 
       
   994 // ----------------------------------------------------------------------------
       
   995 // CLogsBaseView::HandleCommandL
       
   996 // 
       
   997 // For other commands
       
   998 // ----------------------------------------------------------------------------
       
   999 //
       
  1000 void CLogsBaseView::HandleCommandL( TInt aCommandId )
       
  1001     {
       
  1002     TRACE_ENTRY_POINT;
       
  1003     switch( aCommandId )
       
  1004         {
       
  1005         case ELogsCmdStartPhonebook:
       
  1006             LogsAppUi()->StartApplicationL( TUid::Uid(KPbk2UID3), KNullDesC8 );
       
  1007             break;
       
  1008             
       
  1009         case ELogsCmdMenuSettings:
       
  1010             AppUi()->HandleCommandL( aCommandId );
       
  1011             break;
       
  1012 
       
  1013         case EEikCmdExit:       // flow-through
       
  1014         case ELogsCmdMenuExit:  // flow-through
       
  1015         case EAknSoftkeyExit:
       
  1016             LogsAppUi()->HandleCommandL( ELogsCmdMenuExit );
       
  1017             break;
       
  1018 
       
  1019         case EAknCmdHideInBackground:
       
  1020             {
       
  1021             //If phonebook update is pending, request reset of callui. Otherwise in certain 
       
  1022             //cases pending phonebook updates end up in wrong state (ECJA-7JDD5, ECJA-7JDCZW) 
       
  1023             if( iPreviousCommand == KAiwCmdAssign )
       
  1024                 {
       
  1025                 iServHandlerRef = LogsAppUi()->CallUiL( ETrue ); 
       
  1026                 }
       
  1027             break;
       
  1028             }
       
  1029 
       
  1030         case EAknSoftkeyBack:
       
  1031             {
       
  1032             // Set inputblocker to avoid problems of fast tapping during view switch. 
       
  1033             // View switch will then cancel the inputblokcer.
       
  1034             SetInputBlockerL();  
       
  1035             LogsAppUi()->CmdBackL();
       
  1036             break;
       
  1037             }
       
  1038 
       
  1039         case EAknCmdHelp:
       
  1040             AppUi()->HandleCommandL( aCommandId );
       
  1041             break;
       
  1042 
       
  1043         default:
       
  1044             break;
       
  1045         }
       
  1046         
       
  1047     TRACE_EXIT_POINT;  
       
  1048     }
       
  1049 
       
  1050 // ----------------------------------------------------------------------------
       
  1051 // CLogsBaseView::HandleCommandEventL
       
  1052 //
       
  1053 // For event-related commands
       
  1054 // ----------------------------------------------------------------------------
       
  1055 //
       
  1056 void CLogsBaseView::HandleCommandEventL( 
       
  1057     TInt aCommandId,
       
  1058     const MLogsEventGetter* aEvent )
       
  1059     {
       
  1060     //Try first non-event commands
       
  1061     CLogsBaseView::HandleCommandL( aCommandId ); //Don't call subclass again    
       
  1062     
       
  1063     if( !aEvent )
       
  1064         {
       
  1065         return;
       
  1066         }
       
  1067 
       
  1068     //Check event releated commands    
       
  1069     switch( aCommandId )
       
  1070         {
       
  1071         case ELogsCmdMenuPrependNumber:
       
  1072             CmdPrependCallL(ETrue, aEvent);  //ETrue: prefer phone number in case sip uri also available
       
  1073             break;
       
  1074         
       
  1075         case ELogsCmdMenuPrependAddress:        
       
  1076             CmdPrependCallL(EFalse, aEvent); //EFalse: prefer sip uri if available
       
  1077             break;
       
  1078 
       
  1079         case ELogsCmdMenuCopyNumber:
       
  1080             CmdCopyNumberL( aEvent );
       
  1081             break;
       
  1082 
       
  1083         case ELogsCmdMenuCopyAddress:
       
  1084             CmdCopyAddressL( aEvent );
       
  1085             break;
       
  1086 
       
  1087         case ELogsCmdDeviceCallKey:              //Special device key pressed to make a call 
       
  1088         case ELogsCmdSendKeyCall:                //or Send key pressed to make a call
       
  1089         case ELogsCmdLongSendKeyCall:        
       
  1090         case ELogsCmdSingleTapCall:              //or touch tapping to make a call
       
  1091             {
       
  1092             // Reset focus when calling from dialled calls view.       
       
  1093             if( iModel == ELogsDialledModel) 
       
  1094                 {         
       
  1095                 iFocusChangeControl = ELogsOkToChange;
       
  1096                 }
       
  1097             CmdAiwSrvCmdL( aCommandId, aEvent );            
       
  1098             break;
       
  1099             }
       
  1100             
       
  1101         case ELogsCmdShowMyAddress:
       
  1102             CmdShowMyAddressL( aEvent );
       
  1103             break;
       
  1104             
       
  1105         case ELogsCmdMenuSendUi:                 // Cmd assigned for SendUI submenu processing (SMS, MMS)
       
  1106         case ELogsCmdToolBarSendUi:              // or toolbar send message button pressed 
       
  1107             SendMessageCmdHandlerL( aCommandId, aEvent );
       
  1108             break;
       
  1109 
       
  1110         case ELogsCmdAiwCmdAssign:
       
  1111             iFocusChangeControl = ELogsNoChange_PbkUpdPending; //Prevent focus moving to top when list is reread         
       
  1112             CmdSaveToVirtualPhonebookL( KAiwCmdAssign, EFalse, aEvent ); 
       
  1113             break;
       
  1114            
       
  1115         case ELogsCmdHandleTapFocusChange:   
       
  1116            SetToolbarItems( aEvent );
       
  1117            Cba()->MakeCommandVisible( 
       
  1118                EAknSoftkeyContextOptions, 
       
  1119                IsOkToShowContextMenu( aEvent ));
       
  1120            break;                      
       
  1121             
       
  1122         default:            
       
  1123             //If commandId is in range allocated to AIW, forward it to AIW for processing.
       
  1124             //commandId's allocated for AIW must not overlap with the other menu ids.
       
  1125             //Note, that there are some command id's allocated on top of ELogsCmdLast in PECLogs extension.
       
  1126             //However, these commands are already handled in CLogsRecentListView ReceiViewExtension->HandleCommandL(aCommandId)), 
       
  1127             //no extension commands left here. Therefore ELogsCmdLast is ok  instead of EDpbCmdLas of extension.
       
  1128             if( aCommandId >= ELogsCmdLast ) 
       
  1129                 {
       
  1130                 CmdAiwMenuCmdL( aCommandId, aEvent );
       
  1131                 }
       
  1132         }
       
  1133     }
       
  1134 
       
  1135 // ----------------------------------------------------------------------------
       
  1136 // CLogsBaseView::SetToolbarState
       
  1137 // ----------------------------------------------------------------------------
       
  1138 //
       
  1139 void CLogsBaseView::SetToolbarState(TLogsShowToolbar aShowToolbar, TBool aSetRect) 
       
  1140 	{
       
  1141 	TRAPD( err, SetToolbarStateL( aShowToolbar, aSetRect ) );  
       
  1142 	if( err ) 
       
  1143 		{
       
  1144 		// Only possible leave cause is KErrToolbarShown if 
       
  1145 		// DisableToolbarL is called when toolbar is shown. 
       
  1146 		}
       
  1147 	}
       
  1148 
       
  1149 // ----------------------------------------------------------------------------
       
  1150 // CLogsBaseView::SetToolbarStateL
       
  1151 // ----------------------------------------------------------------------------
       
  1152 //
       
  1153 void CLogsBaseView::SetToolbarStateL(TLogsShowToolbar aShowToolbar, TBool aSetRect)
       
  1154 	{
       
  1155     if (AknLayoutUtils::PenEnabled() )
       
  1156         {
       
  1157         CAknToolbar* toolbar = Toolbar();
       
  1158         if (toolbar)
       
  1159             {  
       
  1160             if (aShowToolbar == ELogsToolbarOn  &&  
       
  1161                 iToolBarState != ELogsHideItemsAndDrawOnlyBackground &&
       
  1162                 iToolBarState != ELogsUnHideItemsAndDrawOnlyBackground )
       
  1163                 {
       
  1164                 if ( toolbar->IsToolbarDisabled() && !toolbar->IsShown() )
       
  1165                     {
       
  1166                     // Enable toolbar and
       
  1167                     toolbar->DisableToolbarL(EFalse);     
       
  1168                     }
       
  1169                 // set visibility on 
       
  1170                 toolbar->SetToolbarVisibility( ETrue, EFalse);
       
  1171                 iToolBarState = aShowToolbar;
       
  1172                 
       
  1173                 if (aSetRect)
       
  1174                     {
       
  1175                     HandleClientRectChange();
       
  1176                     DrawComponents();
       
  1177                     }
       
  1178                 }  
       
  1179             else if (aShowToolbar == ELogsToolbarOff && iToolBarState != ELogsHideItemsAndDrawOnlyBackground)
       
  1180                 {
       
  1181                 // Set toolbar visibility off and disable toolbar              
       
  1182                 toolbar->SetToolbarVisibility( EFalse, EFalse);
       
  1183                 toolbar->DisableToolbarL(ETrue);  
       
  1184                 iToolBarState = aShowToolbar;
       
  1185                 }   
       
  1186             
       
  1187             else if (aShowToolbar == ELogsHideItemsAndDrawOnlyBackground)
       
  1188                 {  
       
  1189                 toolbar->HideItemsAndDrawOnlyBackground(ETrue);
       
  1190                 iToolBarState = aShowToolbar;
       
  1191                 }
       
  1192             else if (aShowToolbar == ELogsUnHideItemsAndDrawOnlyBackground)
       
  1193                 {       
       
  1194                 toolbar->HideItemsAndDrawOnlyBackground(EFalse);
       
  1195                 iToolBarState = aShowToolbar;
       
  1196                 if (aSetRect)
       
  1197                     {
       
  1198                     HandleClientRectChange();
       
  1199                     DrawComponents();
       
  1200                     }
       
  1201                 }
       
  1202             }        
       
  1203         }    
       
  1204 	}
       
  1205 
       
  1206 // ----------------------------------------------------------------------------
       
  1207 // CLogsBaseView::HandleClientRectChange
       
  1208 // ----------------------------------------------------------------------------
       
  1209 //
       
  1210 void CLogsBaseView::HandleClientRectChange()
       
  1211     {
       
  1212     // base class has no implementation.
       
  1213     }
       
  1214 
       
  1215 // ----------------------------------------------------------------------------
       
  1216 // CLogsBaseView::DrawComponents
       
  1217 // ----------------------------------------------------------------------------
       
  1218 //
       
  1219 void CLogsBaseView::DrawComponents()
       
  1220     {
       
  1221     // base class has no implementation.
       
  1222     }
       
  1223 
       
  1224 // ----------------------------------------------------------------------------
       
  1225 // CLogsBaseView::ProcessCommandL
       
  1226 //
       
  1227 // Called from FW when e.g. cba pressed
       
  1228 // ----------------------------------------------------------------------------
       
  1229 //
       
  1230 void CLogsBaseView::ProcessCommandL( TInt aCommand )
       
  1231     {
       
  1232     TRACE_ENTRY_POINT;
       
  1233     // Close popup menu if open
       
  1234     MenuBar()->StopDisplayingMenuBar();
       
  1235 
       
  1236     //If MSK-press, convert it ELogsCmdHandleMSK in order to be forwarded to
       
  1237     //HandleCommandL for possible processing
       
  1238     if ( aCommand == EAknSoftkeyContextOptions )
       
  1239         {
       
  1240         aCommand = ELogsCmdHandleMSK;
       
  1241         }
       
  1242 
       
  1243     // Call base class calls HandleCommandL 
       
  1244     CAknView::ProcessCommandL( aCommand );
       
  1245     
       
  1246     //Store last executed command
       
  1247     if( aCommand >= ELogsCmdLast && iServHandlerRef) 
       
  1248         {
       
  1249         iPreviousCommand = iServHandlerRef->ServiceCmdByMenuCmd( aCommand );
       
  1250         }
       
  1251     else
       
  1252         {
       
  1253         iPreviousCommand = aCommand;
       
  1254         }
       
  1255       
       
  1256     TRACE_EXIT_POINT;
       
  1257     }
       
  1258 
       
  1259 // ----------------------------------------------------------------------------
       
  1260 // CLogsBaseView::HandleMenuRefreshL
       
  1261 //
       
  1262 // Checks wether the options menu needs to be refreshed. This is needed when 
       
  1263 // options menu was opened before events were populated. Called from 
       
  1264 // CLogsRecentListView::StateChangedL and CLogsEventListView::StateChangedL 
       
  1265 // ----------------------------------------------------------------------------
       
  1266 //
       
  1267 void CLogsBaseView::HandleMenuRefreshL(const MLogsEventGetter* aCurrentEvent) 
       
  1268     {
       
  1269     // Will be called when reading is finished. In some scenarios could be called twice
       
  1270     // so to avoid flickering the flag RefreshMenuOnUpdate is used.
       
  1271     if (MenuBar()->IsDisplayed() && RefreshMenuOnUpdate( aCurrentEvent ) ) 
       
  1272         {
       
  1273         MenuBar()->StopDisplayingMenuBar();
       
  1274         MenuBar()->TryDisplayMenuBarL();
       
  1275         // After the refresh, set the conditional switch off. 
       
  1276         iRefreshMenuOnUpdate = EFalse;
       
  1277         }
       
  1278     }
       
  1279 
       
  1280 // ----------------------------------------------------------------------------
       
  1281 // CLogsBaseView::SetRefreshMenuOnUpdate
       
  1282 // ----------------------------------------------------------------------------
       
  1283 //  
       
  1284 void CLogsBaseView::SetRefreshMenuOnUpdate( const MLogsEventGetter* aCurrentEvent )
       
  1285     {
       
  1286     if (aCurrentEvent)
       
  1287         {
       
  1288         iEventUidWhenMenuOpened = aCurrentEvent->EventUid().iUid;
       
  1289         }
       
  1290     else
       
  1291         {
       
  1292         iEventUidWhenMenuOpened = KErrNotFound;
       
  1293         }
       
  1294     
       
  1295     iRefreshMenuOnUpdate = ETrue;
       
  1296     }
       
  1297     
       
  1298 // ----------------------------------------------------------------------------
       
  1299 // CLogsBaseView::RefreshMenuOnUpdate
       
  1300 // ----------------------------------------------------------------------------
       
  1301 //  
       
  1302 TBool CLogsBaseView::RefreshMenuOnUpdate(const MLogsEventGetter* aCurrentEvent) 
       
  1303     {
       
  1304     TBool refreshMenu(EFalse);
       
  1305     
       
  1306     if (iRefreshMenuOnUpdate)
       
  1307         { 
       
  1308         if (aCurrentEvent)
       
  1309             {
       
  1310             if (iEventUidWhenMenuOpened != aCurrentEvent->EventUid().iUid) 
       
  1311                 {
       
  1312                 refreshMenu = ETrue;
       
  1313                 }
       
  1314             }
       
  1315         else if (iEventUidWhenMenuOpened != KErrNotFound)
       
  1316             {
       
  1317             refreshMenu = ETrue;
       
  1318             } 
       
  1319         }
       
  1320     
       
  1321     return refreshMenu;
       
  1322     }
       
  1323   
       
  1324 
       
  1325 // ----------------------------------------------------------------------------
       
  1326 // CLogsBaseView::HandleListBoxEventL
       
  1327 //
       
  1328 // If touch support is on, we handle the touch related events here.
       
  1329 // ----------------------------------------------------------------------------
       
  1330 //
       
  1331 void CLogsBaseView::HandleListBoxEventL(
       
  1332     CEikListBox* aListBox,
       
  1333     TListBoxEvent aEventType)
       
  1334     { 
       
  1335     TRACE_ENTRY_POINT;
       
  1336     
       
  1337     LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
  1338             ( "CLogsBaseView::HandleListBoxEventL - aEventType:%d"), aEventType);
       
  1339     
       
  1340     if( AknLayoutUtils::PenEnabled() )  
       
  1341         {
       
  1342         switch ( aEventType )
       
  1343             {     
       
  1344             case EEventItemSingleClicked:
       
  1345                 {
       
  1346                 ProcessPointerEventL(aListBox->CurrentItemIndex());
       
  1347                 break;
       
  1348                 }
       
  1349             
       
  1350             case EEventPanningStarted:                         
       
  1351             case EEventPanningStopped:                       
       
  1352             case EEventFlickStarted:                 
       
  1353             case EEventFlickStopped:                       
       
  1354             case EEventPenDownOnItem:
       
  1355             case EEventItemDraggingActioned:     
       
  1356                 {
       
  1357                 HandleCommandL( ELogsCmdHandleTapFocusChange );    //Calls subclass impl if available            
       
  1358                 break;
       
  1359                 }
       
  1360                 
       
  1361             case EEventEnterKeyPressed:
       
  1362                 {
       
  1363                 TInt commandId( Cba()->ButtonGroup()->CommandId(
       
  1364                         CEikButtonGroupContainer::EMiddleSoftkeyPosition ) );
       
  1365                 ConstructDelayedL( EFalse );               
       
  1366                 ProcessCommandL( commandId );
       
  1367                 break;
       
  1368                 }
       
  1369             default:
       
  1370                break;
       
  1371             }
       
  1372       	}
       
  1373       	
       
  1374     TRACE_EXIT_POINT;  	
       
  1375     }
       
  1376 
       
  1377 // ----------------------------------------------------------------------------
       
  1378 // CLogsBaseView::EventListCurrent
       
  1379 // ----------------------------------------------------------------------------
       
  1380 //
       
  1381 TInt CLogsBaseView::EventListCurrent() const
       
  1382     {
       
  1383     return iEventListCurrent;
       
  1384     }
       
  1385 
       
  1386 // ----------------------------------------------------------------------------
       
  1387 // CLogsBaseView::EventListTop
       
  1388 // ----------------------------------------------------------------------------
       
  1389 //
       
  1390 TInt CLogsBaseView::EventListTop() const
       
  1391     {
       
  1392     return iEventListTop;
       
  1393     }
       
  1394 
       
  1395 // ----------------------------------------------------------------------------
       
  1396 // CLogsBaseView::SetEventListCurrent
       
  1397 // ----------------------------------------------------------------------------
       
  1398 //
       
  1399 void CLogsBaseView::SetEventListCurrent( TInt aIndex )
       
  1400     {
       
  1401     iEventListCurrent = aIndex;
       
  1402     }
       
  1403 
       
  1404 // ----------------------------------------------------------------------------
       
  1405 // CLogsBaseView::SetEventListTop
       
  1406 // ----------------------------------------------------------------------------
       
  1407 //
       
  1408 void CLogsBaseView::SetEventListTop( TInt aIndex )
       
  1409     {
       
  1410     iEventListTop = aIndex;
       
  1411     }
       
  1412 
       
  1413 // ----------------------------------------------------------------------------
       
  1414 // CLogsBaseView::DynInitMenuPaneL
       
  1415 // ----------------------------------------------------------------------------
       
  1416 //
       
  1417 void CLogsBaseView::DynInitMenuPaneL(
       
  1418     TInt /* aResourceId */,
       
  1419     CEikMenuPane* aMenuPane )
       
  1420     {
       
  1421     //First check have we already done construction fully. If not, then we first need to do it. 
       
  1422     ConstructDelayedL( EFalse );   //EFalse: perform immediately, ETrue: perform using idle time
       
  1423     TInt position = -1;
       
  1424 
       
  1425     if( aMenuPane->MenuItemExists( EAknCmdHelp, position ) )
       
  1426         {
       
  1427         if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
  1428             {
       
  1429             aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
       
  1430             }
       
  1431         else
       
  1432             {
       
  1433             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  1434             }
       
  1435         }
       
  1436     }
       
  1437         
       
  1438 // ----------------------------------------------------------------------------
       
  1439 // CLogsBaseView::DynInitMenuPaneEventL
       
  1440 // ----------------------------------------------------------------------------
       
  1441 //
       
  1442 void CLogsBaseView::DynInitMenuPaneEventL(
       
  1443     TInt aResourceId,
       
  1444     CEikMenuPane* aMenuPane,
       
  1445     const MLogsEventGetter* aEvent )
       
  1446     {
       
  1447     TRACE_ENTRY_POINT;
       
  1448     
       
  1449     CLogsBaseView::DynInitMenuPaneL( aResourceId, aMenuPane );//Don't call subclass again
       
  1450     
       
  1451     LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
  1452             ( "CLogsBaseView::DynInitMenuPaneEventL - iServiceHandler: 0x%x"), iServHandlerRef);
       
  1453 
       
  1454     //AIW knows its own submenu hooks, so we can return from here if AIW handled this.
       
  1455     if( iServHandlerRef->HandleSubmenuL(*aMenuPane) || iServHandlerRef->HandleSubmenuL(*aMenuPane) )
       
  1456         {
       
  1457         return;
       
  1458         }
       
  1459         
       
  1460     //Note that aEvent may NOT yet be available if asynch request(s) are not completed. 
       
  1461     TBool phoneNumberAvailable = PhoneNumberAvailable( aEvent );
       
  1462     TBool sipUriAvailable = SipUriAvailable( aEvent );
       
  1463     TBool isEmergencyCall = EFalse;    
       
  1464 
       
  1465     if( aEvent && aEvent->EventType() == ETypeEmerg ) 
       
  1466         {
       
  1467         isEmergencyCall = ETrue;    
       
  1468         }
       
  1469 
       
  1470     //Intitialise menupane resources
       
  1471     if( aResourceId == R_COMMON_EVENT_MENU_DELETE_EVENTS )
       
  1472         {        
       
  1473         // If no event data available, remove all event dependent options and exit
       
  1474         if( !aEvent )        
       
  1475             {            
       
  1476             aMenuPane->DeleteMenuItem( ELogsCmdMenuDelete );
       
  1477             aMenuPane->DeleteMenuItem( ELogsCmdMenuDeleteAll );
       
  1478             return;
       
  1479             }      
       
  1480         }   //R_COMMON_EVENT_MENU_DELETE_EVENTS
       
  1481 
       
  1482     else if( aResourceId == R_COMMON_EVENT_MENU_EDIT_CALLS )                //Rest of Stm main menu below CallUi and PoC parts
       
  1483         {        
       
  1484         // If no event data available, remove all event dependent options and exit
       
  1485         if( !aEvent )        
       
  1486             {            
       
  1487             aMenuPane->DeleteMenuItem( ELogsCmdMenuNumberSubMenu );          //Edit and copy phone number
       
  1488             aMenuPane->DeleteMenuItem( ELogsCmdMenuPocAddressSubMenu );
       
  1489             aMenuPane->DeleteMenuItem( ELogsCmdMenuVoipAddressSubMenu );                        
       
  1490             return;
       
  1491             }      
       
  1492 
       
  1493         //We have at least one event available on the list                              
       
  1494 
       
  1495         //Menu item for voice calls
       
  1496         if( !phoneNumberAvailable )
       
  1497             {
       
  1498             aMenuPane->DeleteMenuItem( ELogsCmdMenuNumberSubMenu );          //Edit and copy phone number
       
  1499             }
       
  1500 
       
  1501         /* FIXME: The below should not be needed as when both available we prefer showing/using msisdn. However,
       
  1502            if available, it's good to provide also possibility for user to see sip-uri in addition to msisdn
       
  1503         if( phoneNumberAvailable && sipUriAvailable )
       
  1504             {
       
  1505             // If both available (Phone number and SIP uri) show use address.
       
  1506             aMenuPane->DeleteMenuItem( ELogsCmdMenuNumberSubMenu );
       
  1507             }
       
  1508         */
       
  1509         
       
  1510         //Menu items for PoC and Voip calls
       
  1511         if( !sipUriAvailable )
       
  1512             {
       
  1513             aMenuPane->DeleteMenuItem( ELogsCmdMenuPocAddressSubMenu );
       
  1514             aMenuPane->DeleteMenuItem( ELogsCmdMenuVoipAddressSubMenu );  
       
  1515             }
       
  1516         else            
       
  1517             {
       
  1518             if( !aEvent->LogsEventData()->PoC() )
       
  1519                 {                                                                            
       
  1520                 aMenuPane->DeleteMenuItem( ELogsCmdMenuPocAddressSubMenu );
       
  1521                 }
       
  1522 
       
  1523             if( !aEvent->LogsEventData()->VoIP() )
       
  1524                 {
       
  1525                 aMenuPane->DeleteMenuItem( ELogsCmdMenuVoipAddressSubMenu );
       
  1526                 }                
       
  1527             }
       
  1528         }    //R_COMMON_EVENT_MENU_EDIT_CALLS
       
  1529 
       
  1530     else if( aResourceId == R_COMMON_CALLUI_SUBMENU )                       //1. CallUi menu 
       
  1531         {
       
  1532         if( !aEvent || ( !phoneNumberAvailable &&                           //If event data not (yet) read, no MSISDN or no voip-uri,
       
  1533                         ( !aEvent->LogsEventData()->VoIP() ||               //provide no call option
       
  1534                           !sipUriAvailable )))                 
       
  1535             {
       
  1536             aMenuPane->DeleteMenuItem( KAiwCmdCall );                       //This menuitem is provided by AIW/CallUi    
       
  1537             }
       
  1538         else 
       
  1539             {
       
  1540             DynInitAiwCallUiMenuPaneL( aResourceId, aMenuPane, ETrue, aEvent );//Init voice&video call option in AIW menu                
       
  1541             }
       
  1542         }   //R_COMMON_CALLUI_SUBMENU
       
  1543         
       
  1544     else if( aResourceId == R_COMMON_POC_SUBMENU )                          //2. PoC menu 
       
  1545         {
       
  1546         if( !aEvent ||                                                      //If event data not (yet) read or uri for voip,
       
  1547             aEvent->LogsEventData()->VoIP() ||                              //provide no Poc option. However if msisdn, poc
       
  1548             ( !sipUriAvailable && !phoneNumberAvailable ) ||                //is ok. 
       
  1549             isEmergencyCall )                                               //No Poc for emergency calls even if msisdn.
       
  1550             {
       
  1551             aMenuPane->DeleteMenuItem( KAiwCmdPoC );                        //This menuitem is provided by AIW/PocUi                            
       
  1552             }
       
  1553         else 
       
  1554             {
       
  1555             DynInitAiwPocMenuPaneL( aResourceId, aMenuPane, aEvent );       //Init (or remove) PoC option in AIW menu                
       
  1556             }
       
  1557         }   //R_COMMON_POC_SUBMENU
       
  1558 
       
  1559     else if( aResourceId == R_COMMON_SEND_MESSAGE_SUBMENU )                 //3. Send message menu 
       
  1560         {
       
  1561         //Add send message item if phone number available
       
  1562         if( !phoneNumberAvailable ||  
       
  1563             isEmergencyCall )                                               //Not for emergency calls.
       
  1564             {
       
  1565             aMenuPane->DeleteMenuItem( ELogsCmdMenuSendUi );      
       
  1566             }
       
  1567          else
       
  1568             {
       
  1569             TInt pos = 0;                                                   //Add send message item to menu above position pos                 
       
  1570             aMenuPane->ItemAndPos( ELogsCmdMenuSendUi, pos );                //Returns pointer to menu item 
       
  1571             aMenuPane->DeleteMenuItem( ELogsCmdMenuSendUi );                 //Delete marker item from menu      
       
  1572             TSendingCapabilities capabilities(0, 0, 0 );                    //No need here yet to tailor subitems in SendUi menu            
       
  1573             LogsAppUi()->SendUiL()->AddSendMenuItemL(*aMenuPane, 
       
  1574                                                      pos,                   //Position in menupane
       
  1575                                                      ELogsCmdMenuSendUi,     //Command id to be used for "Send" menu item
       
  1576                                                      capabilities );
       
  1577             aMenuPane->SetItemTextL( ELogsCmdMenuSendUi, iSendUiText->Des() );
       
  1578             aMenuPane->SetItemSpecific( ELogsCmdMenuSendUi, ETrue );
       
  1579             }
       
  1580         }
       
  1581 
       
  1582     else if( aResourceId == R_COMMON_SAVETOPBK_SUBMENU )                    //4. SaveToPbk menu 
       
  1583         {
       
  1584         if( (!phoneNumberAvailable && !sipUriAvailable) || 
       
  1585              isEmergencyCall )                                              //Not for emergency calls.
       
  1586             {
       
  1587             //Remove Phonebook's 'Copy to phonebook' submenu          
       
  1588             aMenuPane->DeleteMenuItem( KAiwCmdAssign );         //NEW impl            
       
  1589             }
       
  1590         else            
       
  1591             {
       
  1592 
       
  1593             //Add Phonebook's 'Copy to phonebook' submenu             
       
  1594             DynInitAiwSaveToPbkMenuPaneL( aResourceId, aMenuPane, aEvent, phoneNumberAvailable, sipUriAvailable );
       
  1595             }
       
  1596         }
       
  1597         
       
  1598     else if( aResourceId == R_COMMON_SHOW_MY_ADDRESS_MENU )                       
       
  1599         {
       
  1600         if( !aEvent || aEvent->LogsEventData()->MyAddress().Length() <= 0 )                                      
       
  1601             {
       
  1602             aMenuPane->DeleteMenuItem( ELogsCmdShowMyAddress );              //User's own voip adress
       
  1603             }
       
  1604         }
       
  1605    
       
  1606     TRACE_EXIT_POINT;        
       
  1607     }
       
  1608     
       
  1609 
       
  1610 // ----------------------------------------------------------------------------
       
  1611 // CLogsBaseView::SipUriAvailable
       
  1612 // ----------------------------------------------------------------------------
       
  1613 //
       
  1614 TBool CLogsBaseView::SipUriAvailable( const MLogsEventGetter* aEvent )
       
  1615     {  
       
  1616     if( !aEvent || 
       
  1617          aEvent->LogsEventData()->Url().Length() <= 0 ||
       
  1618          aEvent->LogsEventData()->Url().Length() > KLogsSipUriMaxLen ) //exeeds maxlen for buffers etc
       
  1619         {
       
  1620         return EFalse;  //no sip uri
       
  1621         }
       
  1622 
       
  1623     // Sip uri exists. However, if it equals to phonenumber, and it seems to
       
  1624     // be a valid phonenumber we don't consider a sip uri
       
  1625     // to exist but prefer msisdn number.        
       
  1626     else if (PhoneNumberAndSipAreEqual(aEvent)   &&
       
  1627     		 CommonPhoneParser::IsValidPhoneNumber( 
       
  1628     				 	aEvent->Number()->Des(),
       
  1629     					CommonPhoneParser::EPlainPhoneNumber ) )
       
  1630     	{
       
  1631     	// SIP URI and number are equal and number is a 
       
  1632     	// valid phonenumber, so consider SIP URI not to exist
       
  1633     	return EFalse;  	
       
  1634     	}
       
  1635 
       
  1636     //We have a unique sip uri
       
  1637     return ETrue;
       
  1638     }
       
  1639 
       
  1640 // ----------------------------------------------------------------------------
       
  1641 // CLogsBaseView::PhoneNumberAndSipAreEqual
       
  1642 // ----------------------------------------------------------------------------
       
  1643 //
       
  1644 TBool CLogsBaseView::PhoneNumberAndSipAreEqual(const MLogsEventGetter* aEvent)
       
  1645 	{       
       
  1646     TBuf<KLogsSipUriMaxLen> buf;
       
  1647 	    
       
  1648 	if( Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf) == KErrNone && 
       
  1649 	    aEvent->Number())        
       
  1650 		{
       
  1651 	    return ( *aEvent->Number() == buf );  
       
  1652 	    }
       
  1653 	else 
       
  1654 		{
       
  1655 		return EFalse;
       
  1656 		}	    	
       
  1657 	}
       
  1658 
       
  1659 // ----------------------------------------------------------------------------
       
  1660 // CLogsBaseView::PhoneNumberAvailable
       
  1661 // ----------------------------------------------------------------------------
       
  1662 //
       
  1663 TBool CLogsBaseView::PhoneNumberAvailable( const MLogsEventGetter* aEvent )
       
  1664     {
       
  1665     TBool numberAvailable = ETrue;
       
  1666     
       
  1667     // First check the number exists and all normal tests are passed.
       
  1668     if( !aEvent || !aEvent->Number()
       
  1669         || aEvent->Number()->Des().Length() > KLogsPhoneNumberMaxLen
       
  1670         || aEvent->EventType() == ETypeUnknown 
       
  1671         || aEvent->EventType() == ETypePrivate 
       
  1672         || aEvent->EventType() == ETypePayphone
       
  1673         || aEvent->EventType() == ETypeSAT                   //SAT: MO call/SMS without logged phonenumber (or URL) 
       
  1674         || aEvent->EventUid()  == KLogPacketDataEventTypeUid //Just in case would wrongly contain msisdn
       
  1675         || aEvent->EventUid()  == KLogsEngWlanEventTypeUid   //Just in case would wrongly contain msisdn
       
  1676         || aEvent->EventUid()  == KLogDataEventTypeUid       //No msisdn operations for data call 
       
  1677         || aEvent->EventUid()  == KLogFaxEventTypeUid )      //No msisdn operations for fax (this may change later
       
  1678         {                                                    //if sending fax from sendui is provided)
       
  1679         numberAvailable = EFalse;      
       
  1680         }
       
  1681  
       
  1682     // Phonenumber exists. However, if it equals to SIP URI, and it is not
       
  1683     // a valid phonenumber we don't consider a phonenumber to exist.
       
  1684     // Instead the SIP URI is preferred.  
       
  1685     else if (PhoneNumberAndSipAreEqual(aEvent)   &&
       
  1686         	 !CommonPhoneParser::IsValidPhoneNumber( 
       
  1687         			 aEvent->Number()->Des(),
       
  1688         			 CommonPhoneParser::EPlainPhoneNumber ) )  
       
  1689     	{
       
  1690     	// SIP URI and number are equal and number is not a 
       
  1691     	// valid phonenumber, so consider phonenumber not to exist
       
  1692     	numberAvailable = EFalse;     
       
  1693    	    }
       
  1694     
       
  1695     return numberAvailable;
       
  1696     }
       
  1697 
       
  1698 ////////////////////////////////////////////////////////////////////////////////////////////////////
       
  1699 
       
  1700 
       
  1701 
       
  1702 
       
  1703 // ----------------------------------------------------------------------------
       
  1704 // CLogsBaseView::DynInitAiwCallUiMenuPaneL
       
  1705 //
       
  1706 // Provide CallUI AIW functionality for making voice, video and VoIP calls
       
  1707 // ----------------------------------------------------------------------------
       
  1708 //
       
  1709 void CLogsBaseView::DynInitAiwCallUiMenuPaneL( 
       
  1710     TInt aResourceId,
       
  1711     CEikMenuPane* aMenuPane,
       
  1712     TBool aVideo,
       
  1713     const MLogsEventGetter* aEvent )
       
  1714     {
       
  1715     TRACE_ENTRY_POINT;
       
  1716     CAiwGenericParamList& paramList = iServHandlerRef->InParamListL();
       
  1717 
       
  1718     //Check do we provide only voice call (i.e. skip video call option)
       
  1719     if ( !aVideo ) 
       
  1720         {
       
  1721         TAiwVariant variant;
       
  1722         TAiwGenericParam param( EGenericParamPhoneNumber, variant );
       
  1723         paramList.AppendL( param );
       
  1724         }
       
  1725         
       
  1726     //Check do we provide VoiP call option     
       
  1727 
       
  1728     //FIXME: the idea of the commented if instead of the if below was to remove voip from callui when there's
       
  1729     //no voip activated in phone. However, in this case there wouldn't be any voip events either.
       
  1730     //So this would unnecessarily exclude voip calls in which both sip-uri and msisdn is available.
       
  1731     //if( aEvent && aEvent->LogsEventData()->VoIP() && SipUriAvailable( aEvent ) && !aEvent->Number() )
       
  1732  
       
  1733 // Sawfish VoIP changes  >>>>
       
  1734     TPtrC8 tempPtr( KNullDesC8 );
       
  1735     TInt result;
       
  1736     CLogsCntLinkChecker* contactCheckerPtr;
       
  1737     result = aEvent->LogsEventData()->GetContactLink( tempPtr );
       
  1738     
       
  1739     if ( KErrNone == result )
       
  1740         {   
       
  1741         contactCheckerPtr = Engine()->CntLinkCheckerL();
       
  1742         contactCheckerPtr->SetObserver( this );
       
  1743         if ( !contactCheckerPtr->IsSameContactLink( tempPtr ) )
       
  1744             {
       
  1745             // If current contact link is not the last one,
       
  1746             // need to reconfig CntLink checker.
       
  1747             iIsCheckedCntLinkInvaild = EFalse;
       
  1748             contactCheckerPtr->Stop(); 
       
  1749             MLogsReaderConfig* readerConfig = CLogsReaderConfigFactory::
       
  1750                     LogsReaderConfigLC( NULL, NULL, &tempPtr ); 
       
  1751             contactCheckerPtr->ConfigureL( readerConfig );
       
  1752             CleanupStack::PopAndDestroy();      //readerConfig
       
  1753             contactCheckerPtr->StartL();
       
  1754             
       
  1755             //if ( !MenuBar()->ItemSpecificCommandsEnabled() )
       
  1756             //    {
       
  1757             //    iIsCheckedCntLinkInvaild = !contactCheckerPtr->IsCntLinkValidSync( tempPtr );
       
  1758             //    }
       
  1759 
       
  1760             }
       
  1761         }
       
  1762     
       
  1763     if ( aEvent 
       
  1764          && aEvent->LogsEventData()->VoIP() 
       
  1765          && SipUriAvailable( aEvent ) 
       
  1766          && ( ( KErrNotFound == aEvent->LogsEventData()->GetContactLink( tempPtr ) 
       
  1767               && !tempPtr.Length() ) 
       
  1768               || iIsCheckedCntLinkInvaild ) )
       
  1769 // <<<<  Sawfish VoIP changes  
       
  1770         {
       
  1771         // If contact link is invalid, provide internet call only.
       
  1772         TAiwVariant variant;
       
  1773         TAiwGenericParam param( EGenericParamSIPAddress, variant );
       
  1774         paramList.AppendL( param );
       
  1775         }
       
  1776         
       
  1777     //Handle runtime variation of VIDEOCALL_MENU_VISIBILITY flag
       
  1778     VideoCallMenuVisibilityL(*aMenuPane);  
       
  1779     
       
  1780     //Add requested menu options to menu pane
       
  1781     iServHandlerRef->InitializeMenuPaneL(    
       
  1782         *aMenuPane,    //Handle of menu pane to initialise                                                  
       
  1783         aResourceId,   //MenuResourceId                                                                     
       
  1784         KAiwCmdCall,   //Base ID for the handler to generate menu IDs for placeholders                      
       
  1785         paramList );   //input parameter list for provider's parameters checking                  
       
  1786     
       
  1787     TRACE_EXIT_POINT;    
       
  1788     }
       
  1789 
       
  1790 // --------------------------------------------------------------------------
       
  1791 // CLogsBaseView::VideoCallMenuVisibilityL
       
  1792 // 
       
  1793 // Handles runtime variation of __VIDEOCALL_MENU_VISIBILITY feature flag 
       
  1794 // i.e. Video call and Voice call command lifted to the main menu level
       
  1795 // instead of a submenu. Disaples\keeps the cascade flag.
       
  1796 // 
       
  1797 // See error: JKLN-76XBYX  
       
  1798 // --------------------------------------------------------------------------
       
  1799 //
       
  1800 void CLogsBaseView::VideoCallMenuVisibilityL( CEikMenuPane& aMenuPane ) const
       
  1801     { 
       
  1802     // Set to true if context menu is opened and if VOIP support is ON.
       
  1803     // Avoids more than 4 entries in the context sensitive menu 
       
  1804     TBool contextMenuWithVoip = EFalse;
       
  1805     
       
  1806     if (FeatureManager::FeatureSupported(KFeatureIdCommonVoip) && 
       
  1807           (CurrentMenuType() == CEikMenuBar::EMenuContext) )
       
  1808         {
       
  1809         contextMenuWithVoip = ETrue;
       
  1810         }
       
  1811         
       
  1812     if ( FeatureManager::FeatureSupported(KFeatureIdVideocallMenuVisibility) &&
       
  1813          (contextMenuWithVoip == EFalse ) )
       
  1814         {          
       
  1815         TInt index = KErrNotFound;
       
  1816         if ( aMenuPane.MenuItemExists( KAiwCmdCall, index ) &&
       
  1817              index != KErrNotFound )
       
  1818             {
       
  1819             CEikMenuPaneItem::SData& itemData =
       
  1820                 aMenuPane.ItemDataByIndexL( index );
       
  1821             const TInt KDisableCascade = 0;
       
  1822             itemData.iCascadeId = KDisableCascade;  // disable cascade menu
       
  1823             }
       
  1824                  
       
  1825         }
       
  1826     }
       
  1827 
       
  1828 // ----------------------------------------------------------------------------
       
  1829 // CLogsBaseView::CurrentMenuType
       
  1830 // ----------------------------------------------------------------------------
       
  1831 //      
       
  1832 CEikMenuBar::TMenuType CLogsBaseView::CurrentMenuType() const
       
  1833     {
       
  1834     return iMenuType;
       
  1835     }
       
  1836      
       
  1837 // ----------------------------------------------------------------------------
       
  1838 // CLogsBaseView::SetCurrentMenuType
       
  1839 // ----------------------------------------------------------------------------
       
  1840 // 
       
  1841 void CLogsBaseView::SetCurrentMenuType(CEikMenuBar::TMenuType aMenuType)
       
  1842     {
       
  1843     iMenuType = aMenuType;   
       
  1844     }
       
  1845         
       
  1846 // ----------------------------------------------------------------------------
       
  1847 // CLogsBaseView::DynInitAiwPocMenuPaneL
       
  1848 //
       
  1849 // Let AIW initialise menu for making PoC calls
       
  1850 // ----------------------------------------------------------------------------
       
  1851 //
       
  1852 void CLogsBaseView::DynInitAiwPocMenuPaneL(
       
  1853     TInt aResourceId,
       
  1854     CEikMenuPane* aMenuPane,
       
  1855     const MLogsEventGetter* aEvent )
       
  1856     {
       
  1857     TRACE_ENTRY_POINT;
       
  1858     //Create CAiwGenericParamList for menu initialisation.
       
  1859     TAiwPocParameterData pocParameter;
       
  1860     pocParameter.iCommandId = 0;//Default, not used with menu construction.
       
  1861     pocParameter.iPreferredMenu = KAiwPoCMenuDataBased; 
       
  1862     TBool isParamListForPocOk( EFalse );
       
  1863     CAiwGenericParamList& paramList = GetAiwGenericParamListForPocL( aEvent, pocParameter, isParamListForPocOk );
       
  1864 
       
  1865     // Let provider add it's menu items to menu only if we got sensible paramList contents
       
  1866     if( isParamListForPocOk ) 
       
  1867         {
       
  1868         iServHandlerRef->InitializeMenuPaneL(
       
  1869             *aMenuPane,
       
  1870             aResourceId,
       
  1871             KAiwCmdPoC,  
       
  1872             paramList );
       
  1873         }
       
  1874      else 
       
  1875         {
       
  1876         aMenuPane->DeleteMenuItem( KAiwCmdPoC );         
       
  1877         }
       
  1878     TRACE_EXIT_POINT;    
       
  1879     }
       
  1880 
       
  1881 
       
  1882 // ----------------------------------------------------------------------------
       
  1883 // CLogsBaseView::GetAiwGenericParamListForPocL
       
  1884 //
       
  1885 // Initialises AiwGenericParamList for Poc menu and Poc call functions. This is
       
  1886 // used for DynInitMenuPane and AIW excecution preparations.
       
  1887 // ----------------------------------------------------------------------------
       
  1888 //
       
  1889 CAiwGenericParamList& CLogsBaseView::GetAiwGenericParamListForPocL(
       
  1890     const MLogsEventGetter* aEvent,         //In:  Event containing source data
       
  1891     TAiwPocParameterData& aPocParameter,    //In:  PocParameter data 
       
  1892     TBool& aIsParamListForPocOk,            //Out: Retuns ETrue if parameter can be used    
       
  1893 	const TDesC& aOverrideUsingThis,        //In:  Use this number/uri preferred instead of what is in aEvent
       
  1894 	TBool aOverrideIsNumber )               //In:  Type of string in aOverrideUsingThis
       
  1895     {
       
  1896     TRACE_ENTRY_POINT;
       
  1897     
       
  1898     __ASSERT_ALWAYS( aEvent != NULL, User::Leave( KErrArgument ) );
       
  1899 
       
  1900     TInt type( aEvent->LogsEventData()->Type() ); //PoC app uses type for selecting 1-to-1, group call etc     
       
  1901 
       
  1902     if( !( type >= EPoCNoOpTypeId && type < EEndOfPoCOpTypeIdRange )  )
       
  1903         {
       
  1904         User::Leave( KErrArgument );
       
  1905         }
       
  1906     
       
  1907     CAiwGenericParamList& params = iServHandlerRef->InParamListL(); //Ownership in Service Handler 
       
  1908     aPocParameter.iConsumerAppUid = TUid::Uid(KLogsAppUID3);
       
  1909     aPocParameter.iConsumerWindowGroup = CCoeEnv::Static()->RootWin().Identifier();
       
  1910     aPocParameter.iLogId = aEvent->LogId();       //PoC app uses LogId to map Log db entry to it's own log data
       
  1911     aPocParameter.iLogOperation = TPoCOperationTypeId( type );
       
  1912 
       
  1913     //PoC parameter data always included
       
  1914     TAiwGenericParam param = TAiwGenericParam( EGenericParamPoCData,
       
  1915                                                TAiwVariant( TAiwPocParameterDataPckg(aPocParameter)));
       
  1916     params.AppendL(param);            
       
  1917     TAiwGenericParam addressParam;
       
  1918     TBuf<KLogsSipUriMaxLen> buf;
       
  1919     aIsParamListForPocOk = ETrue;
       
  1920 
       
  1921     if( aOverrideUsingThis != KNullDesC )
       
  1922         {
       
  1923         //Use provided nbr or address instead what is in aEvent
       
  1924         addressParam = TAiwGenericParam( 
       
  1925             aOverrideIsNumber ? EGenericParamPhoneNumber : EGenericParamSIPAddress, 
       
  1926             aOverrideUsingThis );
       
  1927         }
       
  1928     else if( SipUriAvailable( aEvent ) )
       
  1929         {
       
  1930         // We prefer sip-uri over msisdn if both are available (if is uri & msisdn, Poc has made
       
  1931         // "best guess" for corresponding msisdn for possible subsequent cs calls.
       
  1932         User::LeaveIfError( Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf) );
       
  1933         addressParam = TAiwGenericParam( EGenericParamSIPAddress, buf );
       
  1934         }
       
  1935         
       
  1936     else if( PhoneNumberAvailable( aEvent ) )  
       
  1937         {
       
  1938         // Use msisdn only if uri not available
       
  1939         addressParam = TAiwGenericParam( EGenericParamPhoneNumber, aEvent->Number() );  
       
  1940         }
       
  1941     else
       
  1942         {
       
  1943         //ParamListForPoc is not ok, so it cannot be used.
       
  1944         aIsParamListForPocOk = EFalse;
       
  1945         }
       
  1946 
       
  1947     params.AppendL( addressParam ); //Takes own copy of addressParam
       
  1948     
       
  1949     TRACE_EXIT_POINT;  
       
  1950     return params;
       
  1951     }
       
  1952 
       
  1953 
       
  1954 // ----------------------------------------------------------------------------
       
  1955 // CLogsBaseView::DynInitAiwSaveToPbkMenuPaneL
       
  1956 //
       
  1957 // Provide SaveToPbk AIW functionality 
       
  1958 // ----------------------------------------------------------------------------
       
  1959 //
       
  1960 void CLogsBaseView::DynInitAiwSaveToPbkMenuPaneL(
       
  1961     TInt aResourceId,
       
  1962     CEikMenuPane* aMenuPane,
       
  1963     const MLogsEventGetter* aEvent,
       
  1964     TBool aPhoneNumberAvailable,
       
  1965     TBool aSipUriAvailable )
       
  1966     {
       
  1967     TRACE_ENTRY_POINT;  
       
  1968     using namespace AiwContactAssign;    
       
  1969 
       
  1970     CAiwGenericParamList& inParamList = iServHandlerRef->InParamListL();
       
  1971 
       
  1972     //Set flags to zero, otherwise provides only "Assing to" menu option.
       
  1973     TUint assignFlags = 0;  //TAssignFlags in AiwContactAssignDataTypes.h 
       
  1974     inParamList.AppendL(
       
  1975         TAiwGenericParam(
       
  1976             EGenericParamContactAssignData,     //AiwGenericParam.hrh
       
  1977             TAiwVariant(TAiwSingleContactAssignDataV1Pckg( 
       
  1978                 TAiwSingleContactAssignDataV1().SetFlags(assignFlags)))));                    
       
  1979 
       
  1980     if( aPhoneNumberAvailable )
       
  1981         {
       
  1982         inParamList.AppendL(
       
  1983             TAiwGenericParam(
       
  1984                 EGenericParamPhoneNumber,
       
  1985                 TAiwVariant( *(aEvent->Number()) )
       
  1986                 ));
       
  1987         }
       
  1988 
       
  1989     if( aSipUriAvailable )
       
  1990         {
       
  1991         TBuf<KLogsSipUriMaxLen> buf;    
       
  1992         if( Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf) == KErrNone )        
       
  1993             {
       
  1994             inParamList.AppendL(
       
  1995                 TAiwGenericParam(
       
  1996                     EGenericParamSIPAddress,
       
  1997                     TAiwVariant( buf )
       
  1998                     ));
       
  1999             }
       
  2000         }
       
  2001 
       
  2002    // Let provider add it's menu items to the menu
       
  2003   iServHandlerRef->InitializeMenuPaneL(
       
  2004       *aMenuPane,
       
  2005       aResourceId,
       
  2006       KAiwCmdAssign,
       
  2007       inParamList);    
       
  2008     TRACE_EXIT_POINT;   
       
  2009     }
       
  2010 
       
  2011 // ----------------------------------------------------------------------------
       
  2012 // CLogsBaseView::CurrentModel
       
  2013 // ----------------------------------------------------------------------------
       
  2014 //
       
  2015 MLogsModel* CLogsBaseView::CurrentModel()
       
  2016     {
       
  2017     return Engine()->Model( iModel );
       
  2018     }
       
  2019 
       
  2020 // ----------------------------------------------------------------------------
       
  2021 // CLogsBaseView::SendMessageCmdHandlerL
       
  2022 // ----------------------------------------------------------------------------
       
  2023 //
       
  2024 void CLogsBaseView::SendMessageCmdHandlerL( 
       
  2025     TInt  aCommandId ,
       
  2026     const MLogsEventGetter* aEvent )
       
  2027     {   
       
  2028     
       
  2029     TBool isRead = aEvent->Event()->IsRead();
       
  2030     TLogId logid = aEvent->LogId();
       
  2031     TInt duplicates = aEvent->Duplicates();
       
  2032     
       
  2033     //Check that event and phone number is available
       
  2034     TPtrC number( KNullDesC );
       
  2035     if( aEvent && aEvent->Number() )
       
  2036         {
       
  2037         number.Set( *(aEvent->Number()) );
       
  2038         }
       
  2039     else
       
  2040         {
       
  2041         return;    
       
  2042         } 
       
  2043     
       
  2044     CMessageData* messageData = CMessageData::NewL();
       
  2045     CleanupStack::PushL( messageData );
       
  2046     
       
  2047     TBuf<KLogsPhoneNumberMaxLen> nbrBuff;        
       
  2048     CPhoneNumberFormat::DTMFStrip( number, nbrBuff );
       
  2049     
       
  2050     //Append number and remote party (if available) to message data.
       
  2051     if( aEvent->RemoteParty())
       
  2052         {
       
  2053         messageData->AppendToAddressL( nbrBuff, *(aEvent->RemoteParty()) );   //Nbr & rem party
       
  2054         }
       
  2055      else
       
  2056         {
       
  2057         messageData->AppendToAddressL( nbrBuff );                             //Only nbr
       
  2058         }
       
  2059 
       
  2060 
       
  2061     //We're are interested only in msg type that support writing messages.
       
  2062     TSendingCapabilities capabilities(0,                                      //Max body size
       
  2063                                       0,                                      //Max msg size (inc. attachments)
       
  2064                                       TSendingCapabilities::ESupportsEditor );//Flags
       
  2065 
       
  2066     CArrayFixFlat<TUid>* servicesToDim = new (ELeave) CArrayFixFlat<TUid>( 5 );//Five services to dim
       
  2067     CleanupStack::PushL( servicesToDim );
       
  2068     
       
  2069 
       
  2070 //*******************************************************
       
  2071 // QUICK & DIRTY: 
       
  2072 // In case there is a need to quickly fix the SendUI error for not dimming the 
       
  2073 // 'Mail for Exchange' option, we can do that excplictly with the following uids.
       
  2074 //    
       
  2075 //  TInt mailForEUid = 0x102826F8;
       
  2076 //  servicesToDim->AppendL( TUid::Uid(mailForEUid ) );
       
  2077 //*******************************************************
       
  2078 
       
  2079 // In normal builds we can dim all the e-mail stuff with the 
       
  2080 // KSenduiTechnologyMailUid flag.
       
  2081 //"ESupportsEditor" takes care of removing infrared and bluetooth from menu, so no need to dim them 
       
  2082 #ifndef __IMAIL
       
  2083     servicesToDim->AppendL( KSenduiTechnologyMailUid  );  //SendUiConsts.h
       
  2084     servicesToDim->AppendL( KSenduiMtmPostcardUid    );       
       
  2085 #else
       
  2086 // In DCP builds we need to enable KSenduiMtmSmtpUid but 
       
  2087 // other email MTM's should be dimmed
       
  2088 // FIXME: we might need to dim more services.
       
  2089     servicesToDim->AppendL( KSenduiMtmImap4Uid       ); //SendUiConsts.h
       
  2090     servicesToDim->AppendL( KSenduiMtmPop3Uid        );
       
  2091     servicesToDim->AppendL( KSenduiMtmSyncMLEmailUid );
       
  2092     servicesToDim->AppendL( KSenduiMtmPostcardUid    );
       
  2093 #endif
       
  2094 
       
  2095 // Sawfish VoIP changes  >>>>
       
  2096     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip))
       
  2097         {
       
  2098         servicesToDim->AppendL( KSenduiTechnologyIMUid );
       
  2099         }
       
  2100 // <<<<  Sawfish VoIP changes  
       
  2101 
       
  2102 	// Calling ShowTypedQueryAndSendL to show the write query. Different menu options are 
       
  2103 	// be shown depending on wether the RD_UNIFIED_EDITOR flag is defined ot not, but we don't
       
  2104 	// need care about the flag here.
       
  2105     TUid uid;
       
  2106     SetToolbarState(ELogsHideItemsAndDrawOnlyBackground, EFalse); 
       
  2107     TRAPD(err,     
       
  2108         if (aCommandId == ELogsCmdMenuSendUi)           // with ELogsCmdMenuSendUi show query
       
  2109             {
       
  2110             uid = LogsAppUi()->SendUiL()->ShowTypedQueryL(CSendUi::EWriteMenu, NULL, capabilities, servicesToDim );
       
  2111             } 
       
  2112         else if (aCommandId == ELogsCmdToolBarSendUi)   // with ELogsCmdToolBarSendUi dont show query
       
  2113             {
       
  2114             uid = KSenduiMtmUniMessageUid;    
       
  2115             }
       
  2116         LogsAppUi()->SendUiL()->CreateAndSendMessageL(uid, messageData);
       
  2117         );
       
  2118     
       
  2119     SetToolbarState(ELogsUnHideItemsAndDrawOnlyBackground, ETrue);    
       
  2120     User::LeaveIfError(err);
       
  2121     ChangeTitlePaneTextToDefaultL();
       
  2122    
       
  2123     if (isRead == EFalse && uid != KNullUid && iModel == ELogsMissedModel)  // If not read, the New missed icon is shown. By setting event read
       
  2124         {                  // the new missed icon is not shown when control comes back to Logs 
       
  2125         Engine()->ClearNewMissedL()->SetNewMissedCallRead(logid, duplicates); 
       
  2126         }
       
  2127     CleanupStack::PopAndDestroy( servicesToDim );       
       
  2128     CleanupStack::PopAndDestroy( messageData ); 
       
  2129     
       
  2130     //If missed list, clear now new missed calls counter
       
  2131     ClearMissedCallNotificationsL();          
       
  2132     }
       
  2133 
       
  2134 // ----------------------------------------------------------------------------
       
  2135 // CLogsBaseView::ChangeTitlePaneTextToDefaultL
       
  2136 // ----------------------------------------------------------------------------
       
  2137 //
       
  2138 void CLogsBaseView::ChangeTitlePaneTextToDefaultL()
       
  2139     {
       
  2140     // base class has no implementation
       
  2141     }
       
  2142 
       
  2143 // ----------------------------------------------------------------------------
       
  2144 // CLogsBaseView::ClearMissedCallNotifications
       
  2145 //
       
  2146 // Clears missed call notifications for Voice and PoC
       
  2147 // ----------------------------------------------------------------------------
       
  2148 //
       
  2149 void CLogsBaseView::ClearMissedCallNotifications()
       
  2150     {
       
  2151      if( iModel == ELogsMissedModel )
       
  2152         {
       
  2153         TInt err;
       
  2154         TRAP( err, ClearMissedCallNotificationsL() ); //Clear new missed calls counter  
       
  2155         if( err ) 
       
  2156             {
       
  2157             CCoeEnv::Static()->HandleError( err );
       
  2158             }             
       
  2159         }
       
  2160     }
       
  2161 
       
  2162 // ----------------------------------------------------------------------------
       
  2163 // CLogsBaseView::ClearMissedCallNotificationsL
       
  2164 //
       
  2165 // Clears missed call notifications for Voice and PoC
       
  2166 // ----------------------------------------------------------------------------
       
  2167 //
       
  2168 void CLogsBaseView::ClearMissedCallNotificationsL()
       
  2169     {
       
  2170     if( iModel != ELogsMissedModel )
       
  2171         {
       
  2172         return;
       
  2173         }
       
  2174 
       
  2175     //1. Reset cs and voip missed calls information
       
  2176     Engine()->SharedDataL()->NewMissedCalls( ETrue );  //ETrue: clears the count of missed calls.
       
  2177         
       
  2178     //2. Reset missed Poc call info + notification (needs currently be done separately, 
       
  2179     //   the ResetSoftNotificationL does not do this fully).
       
  2180     Engine()->SystemAgentL()->ResetNewMissedPocCalls();   
       
  2181 
       
  2182 #ifdef __OMA_POC   
       
  2183     //   Clear missed poc call soft notification (no need to check are there any missed poc calls)
       
  2184     TUid provUid = { KS60PoCAiwProviderImplUid };   
       
  2185     
       
  2186     CPoCUiIntegrationServices* services = CPoCUiIntegrationServices::NewLC( provUid );
       
  2187     services->ResetSoftNotificationL( CPoCUiIntegrationServices::EPoCUiIntegrationMissedCall );
       
  2188     // services->ResetSoftNotificationL( CPoCUiIntegrationServices::EPoCUiIntegrationCallbackRequest );
       
  2189     CleanupStack::PopAndDestroy( services );       
       
  2190 #endif
       
  2191     
       
  2192     }
       
  2193 
       
  2194 // ----------------------------------------------------------------------------
       
  2195 // CLogsBaseView::CmdPrependCallL
       
  2196 //
       
  2197 // Provide the user option to edit the phone number or sip uri and make cellular, 
       
  2198 // voip or poc call using this number/uri.
       
  2199 // ----------------------------------------------------------------------------
       
  2200 //
       
  2201 void CLogsBaseView::CmdPrependCallL( 
       
  2202     TBool aPreferNumber,             //if both uri and number, prefer number
       
  2203     const MLogsEventGetter* aEvent ) 
       
  2204     {
       
  2205     TRACE_ENTRY_POINT;
       
  2206     if ( !aEvent )
       
  2207         {
       
  2208         return;    
       
  2209         }
       
  2210         
       
  2211     TInt length(0);
       
  2212     TBuf<KLogsSipUriMaxLen> buf;               
       
  2213 
       
  2214     CAiwDialData::TCallType callTypeForVoice( CAiwDialData::EAIWVideo );       
       
  2215     
       
  2216     //Select uri or phone number to edit according to availability & preference
       
  2217     if( ( aEvent->LogsEventData()->VoIP() || aEvent->LogsEventData()->PoC() ) && 
       
  2218           SipUriAvailable( aEvent ) && !aPreferNumber )
       
  2219         {
       
  2220         
       
  2221         callTypeForVoice = CAiwDialData::EAIWVoiP;           
       
  2222       
       
  2223         TInt ret = Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf);
       
  2224         if( ret != KErrNone && ret != KErrOverflow )        
       
  2225             {
       
  2226             return;    
       
  2227             }
       
  2228         length = buf.Length();  //Unicode characters            
       
  2229         }
       
  2230     else if ( aEvent->Number() )
       
  2231         {
       
  2232         buf = *(aEvent->Number());        
       
  2233         length = buf.Length() ;
       
  2234         }
       
  2235 
       
  2236     //Show to user for editing if proper number or uri available
       
  2237     if( length && 
       
  2238         ( (length <= KLogsPhoneNumberMaxLen) ||             //Max length for number
       
  2239           (length <= KLogsSipUriMaxLen && !aPreferNumber) ) //Max length for uri
       
  2240         )  
       
  2241         {
       
  2242         AknTextUtils::LanguageSpecificNumberConversion( buf );
       
  2243         CLogsPrependQuery* query = CLogsPrependQuery::NewL( buf );
       
  2244                        
       
  2245         CAiwGenericParamList* paramList = NULL;
       
  2246         TBool isParamListForPocOk( EFalse ); 
       
  2247         
       
  2248 		if( aPreferNumber)  
       
  2249 	        {
       
  2250 	        query->PrepareLC( R_STM_USE_NUMBER_QUERY ); 
       
  2251 	        }
       
  2252 	    else
       
  2253     	    {
       
  2254     	    query->PrepareLC( R_STM_USE_ADDRESS_QUERY );
       
  2255  			
       
  2256  			if( aEvent->LogsEventData()->PoC() )
       
  2257  				{		
       
  2258  				TAiwPocParameterData pocParameter;
       
  2259  						
       
  2260 // 				// Initialise parameter data to execute AIW command 
       
  2261  				InitPocParameterL( pocParameter, aEvent );       //Other params from aEvent except the buf                   
       
  2262  				paramList = &GetAiwGenericParamListForPocL( 
       
  2263  			         	aEvent, 
       
  2264  			         	pocParameter, 
       
  2265  			         	isParamListForPocOk,
       
  2266  			         	buf,
       
  2267  			         	aPreferNumber );	
       
  2268  			
       
  2269 				}
       
  2270     	    }
       
  2271 		
       
  2272         //Show number/address to edit it	        			
       
  2273         TInt queryAction;
       
  2274         queryAction = query->RunLD();
       
  2275         
       
  2276         AknTextUtils::ConvertDigitsTo( buf, EDigitTypeWestern ); 
       
  2277         
       
  2278         //Refresh contents in MLogsEventGetter. Otherwise it contains wrong data of last 
       
  2279         //event read from db done in background during execution of RunLD()
       
  2280         aEvent = CurrentModel()->At( iEventListCurrent );
       
  2281         
       
  2282         switch( queryAction )
       
  2283         	{
       
  2284         	case EAknSoftkeyCall:
       
  2285         		if( isParamListForPocOk )
       
  2286         			{
       
  2287         			CmdPocCallL( KAiwCmdPoC, EFalse, *paramList );   //EFalse: Direct request                        
       
  2288         			}
       
  2289         		else
       
  2290         			{
       
  2291                     // EFalse: Direct request (not made from menu).                  
       
  2292                     CmdCallL( 
       
  2293                         KAiwCmdCall, 
       
  2294                         EFalse, 
       
  2295                         buf, 
       
  2296                         callTypeForVoice,            
       
  2297                         aEvent
       
  2298                         );
       
  2299                     }
       
  2300                 break;
       
  2301 
       
  2302             default:
       
  2303                 break;
       
  2304             }
       
  2305         }
       
  2306     TRACE_EXIT_POINT;
       
  2307     }
       
  2308 
       
  2309 // ----------------------------------------------------------------------------
       
  2310 // CLogsBaseView::CmdAiwSrvCmdL
       
  2311 //
       
  2312 // Request an AIW-service from an AIW provider. The commandId relates to 
       
  2313 // Logs own commands.
       
  2314 // ----------------------------------------------------------------------------
       
  2315 //
       
  2316 void CLogsBaseView::CmdAiwSrvCmdL( 
       
  2317     TInt aCommandId,
       
  2318     const MLogsEventGetter* aEvent )
       
  2319     {
       
  2320     TRACE_ENTRY_POINT;
       
  2321     
       
  2322     if( !aEvent )
       
  2323         {
       
  2324         return; 
       
  2325         }
       
  2326 
       
  2327     switch( aCommandId )
       
  2328         {
       
  2329         case ELogsCmdSingleTapCall:					//Touch tapping to make a call 
       
  2330         case ELogsCmdSendKeyCall:                   //Send key pressing to make a call
       
  2331         case ELogsCmdLongSendKeyCall:            
       
  2332             //For PoC events make PoC call. Exception1: If phone number available, then 
       
  2333             //for long presses attempt cs video call instead. Exception2: Long taps cause
       
  2334             //always Poc calls for poc events.
       
  2335             if( aEvent->LogsEventData()->PoC() && 
       
  2336                 !( aCommandId == ELogsCmdLongSendKeyCall &&   
       
  2337                    PhoneNumberAvailable( aEvent ) ))
       
  2338                 {
       
  2339                 PreparePocCallL( KAiwCmdPoC,            
       
  2340                                  EFalse,            //EFalse: Direct request (not made from menu)
       
  2341                                  aEvent );
       
  2342                 }
       
  2343             else
       
  2344                 {
       
  2345                 TBool forceVideo( EFalse );
       
  2346 
       
  2347                 //For long press or single tap prefer video call but not for emergency calls
       
  2348                 if( (aCommandId == ELogsCmdLongSendKeyCall ||
       
  2349                     aEvent->LogsEventData()->VT() &&
       
  2350                     aCommandId == ELogsCmdSingleTapCall ) &&
       
  2351                     aEvent->EventType() != ETypeEmerg )
       
  2352                     {
       
  2353                     forceVideo = ETrue;
       
  2354                     }
       
  2355                 PrepareCallL( KAiwCmdCall, 
       
  2356                               EFalse,               //EFalse: Direct request (not made from menu)
       
  2357                               aEvent,
       
  2358                               forceVideo );         //ETrue=force video call, EFalse=show voice/video query to user:
       
  2359                 }
       
  2360             break;        
       
  2361                 
       
  2362         case ELogsCmdDeviceCallKey:                 //Special device key pressed to make a call,
       
  2363             PreparePocCallL( KAiwCmdPoC,            //only poc call is supported for this key.
       
  2364                              EFalse,                //EFalse: Direct request (not made from menu).
       
  2365                              aEvent );   
       
  2366                              
       
  2367             break;
       
  2368         }
       
  2369     TRACE_EXIT_POINT;    
       
  2370     }
       
  2371 
       
  2372 // ----------------------------------------------------------------------------
       
  2373 // CLogsBaseView::CmdAiwMenuCmdL
       
  2374 //
       
  2375 // Forward an AIW-menu based command to corresponding AIW-provider. The commandId relates to 
       
  2376 // AIW's menu item already shown by AIW provider to user
       
  2377 // ----------------------------------------------------------------------------
       
  2378 //
       
  2379 void CLogsBaseView::CmdAiwMenuCmdL( 
       
  2380     TInt aCommandId, 
       
  2381     const MLogsEventGetter* aEvent )
       
  2382     {
       
  2383     TRACE_ENTRY_POINT;
       
  2384     
       
  2385     if( !aEvent || !iServHandlerRef )
       
  2386         {
       
  2387         return; 
       
  2388         }
       
  2389 
       
  2390     TInt srvCmd = iServHandlerRef->ServiceCmdByMenuCmd( aCommandId );
       
  2391     
       
  2392     switch( srvCmd )    //AiwCommon.hrh
       
  2393         {
       
  2394         case KErrNotFound:    
       
  2395             break;                
       
  2396 
       
  2397         case KAiwCmdCall:    
       
  2398             PrepareCallL( aCommandId, ETrue, aEvent );    //Try to make voice call.
       
  2399             break;                
       
  2400 
       
  2401         case KAiwCmdPoC:  
       
  2402             PreparePocCallL( aCommandId, ETrue, aEvent ); //Try to make PoC call.
       
  2403             break;   
       
  2404 
       
  2405         case KAiwCmdAssign:
       
  2406             // prevent the model being activated twice: 
       
  2407             // from HandleGainingForeground and HandleNotifyL  
       
  2408             iFocusChangeControl = ELogsNoChange_PbkUpdPending;      
       
  2409             CmdSaveToVirtualPhonebookL( aCommandId, ETrue, aEvent );
       
  2410             break;
       
  2411             
       
  2412         default:
       
  2413             // do nothing
       
  2414             break;       
       
  2415         }
       
  2416     
       
  2417      // Reset focus when calling from dialled calls view.       
       
  2418      if( iModel == ELogsDialledModel && 
       
  2419          ( srvCmd == KAiwCmdCall || srvCmd == KAiwCmdPoC ) ) 
       
  2420         {         
       
  2421         iFocusChangeControl = ELogsOkToChange;
       
  2422         }    
       
  2423         
       
  2424     TRACE_EXIT_POINT;   
       
  2425     }
       
  2426 
       
  2427 // ----------------------------------------------------------------------------
       
  2428 // CLogsBaseView::PreparePocCallL
       
  2429 //
       
  2430 // Prepares a PoC call.
       
  2431 // ----------------------------------------------------------------------------
       
  2432 //
       
  2433 void CLogsBaseView::PreparePocCallL( 
       
  2434     TInt aCommandId, 
       
  2435     TBool aCalledForMenu,
       
  2436     const MLogsEventGetter* aEvent )                  
       
  2437     {
       
  2438     TBool isRead = aEvent->Event()->IsRead();
       
  2439     TLogId logid = aEvent->LogId();
       
  2440     TInt duplicates = aEvent->Duplicates();
       
  2441     
       
  2442     // Initialise PocParameterData for GenericParamList to execute AIW command    
       
  2443     TAiwPocParameterData pocParameter;
       
  2444     if ( aCalledForMenu )
       
  2445         {
       
  2446         pocParameter.iCommandId = aCommandId;
       
  2447         }
       
  2448     else
       
  2449         {
       
  2450         InitPocParameterL( pocParameter, aEvent );
       
  2451         }    
       
  2452     
       
  2453     TBool isParamListForPocOk( EFalse );
       
  2454     CAiwGenericParamList& paramList = GetAiwGenericParamListForPocL( aEvent, pocParameter, isParamListForPocOk );
       
  2455     
       
  2456     // Let's make call only if we got sensible paramList contents    
       
  2457     if( isParamListForPocOk ) 
       
  2458         {
       
  2459         CmdPocCallL( aCommandId, aCalledForMenu, paramList );    
       
  2460         }
       
  2461     
       
  2462     if (isRead == EFalse && iModel == ELogsMissedModel)  // If not read, the New missed icon is shown. By setting event read
       
  2463         {                  // the new missed icon is not shown when control comes back to Logs 
       
  2464         Engine()->ClearNewMissedL()->SetNewMissedCallRead(logid, duplicates); 
       
  2465         }    
       
  2466     }
       
  2467     
       
  2468 // ----------------------------------------------------------------------------
       
  2469 // CLogsBaseView::InitPocParameterL
       
  2470 //
       
  2471 // Initialise PocParameterData.
       
  2472 // ----------------------------------------------------------------------------
       
  2473 //
       
  2474 TAiwPocParameterData& CLogsBaseView::InitPocParameterL( 
       
  2475     TAiwPocParameterData& aPocParameter, 
       
  2476     const MLogsEventGetter* aEvent )                  
       
  2477     {
       
  2478     TInt type( aEvent->LogsEventData()->Type() ); //PoC app uses type for selecting 1-to-1, group call etc     
       
  2479 
       
  2480     if( !( type >= EPoCNoOpTypeId && type < EEndOfPoCOpTypeIdRange )  )
       
  2481         {
       
  2482         User::Leave( KErrArgument );
       
  2483         }
       
  2484     
       
  2485     aPocParameter.iLogOperation = TPoCOperationTypeId( type );
       
  2486     aPocParameter.iCommandId = 0;
       
  2487 
       
  2488     // Check the type of the logged PoC call to be able to send correct 
       
  2489     // command to PoC AIW. This is done because the call can be made from 
       
  2490     // menu which always has an associated command and by PTT-key which
       
  2491     // doesn't have a command.
       
  2492     switch ( type )
       
  2493         {
       
  2494         case EPoC1to1MO: // Initiated 1-to-1 call.
       
  2495         case EPoC1to1MT: // Received 1-to-1 call.
       
  2496             {
       
  2497             // This must be always set also for non menu-based 
       
  2498             // PoC AIW service requests.
       
  2499             aPocParameter.iCommandId = EAiwPoCCmdTalk1to1;
       
  2500             break;
       
  2501             }
       
  2502         case EPoCAdhocDialoutGroupMO:   // Initiated dial-out call.
       
  2503         case EPoCPredefDialoutGroupMO:  // Initiated predefined dial-out call.
       
  2504             {
       
  2505             aPocParameter.iCommandId = EAiwPoCCmdTalkMany;
       
  2506             break;
       
  2507             }
       
  2508         case EPoCNoOpTypeId:            // When only msisdn available
       
  2509             {
       
  2510             aPocParameter.iCommandId = EAiwPoCCmdTalk1to1;
       
  2511             break;
       
  2512             }
       
  2513         default:
       
  2514         case EPoCCallbackRequestMO:
       
  2515         case EPoCCallbackRequestMT:
       
  2516         case EPoCAdhocDialoutGroupMT:
       
  2517         case EPoCPredefDialoutGroupMT:
       
  2518         case EPoCDialinGroupMO:
       
  2519             {
       
  2520             // No handling at the moment since above events are not
       
  2521             // stored to system log. Maybe in future in OMA PoC these 
       
  2522             // will be used aswell. Meanwhile use the 1-to-1 as default.
       
  2523             aPocParameter.iCommandId = EAiwPoCCmdTalk1to1;
       
  2524             break;
       
  2525             }
       
  2526         }
       
  2527 
       
  2528     __ASSERT_ALWAYS( aPocParameter.iCommandId > 0, User::Leave( KErrNotFound ) );
       
  2529     
       
  2530     return aPocParameter;
       
  2531     }
       
  2532     
       
  2533 // ----------------------------------------------------------------------------
       
  2534 // CLogsBaseView::CmdPocCallL
       
  2535 //
       
  2536 // Perform PoC call.
       
  2537 // ----------------------------------------------------------------------------
       
  2538 //
       
  2539 void CLogsBaseView::CmdPocCallL( 
       
  2540     TInt aCommandId, 
       
  2541     TBool aCalledForMenu,
       
  2542     CAiwGenericParamList& aParamList )
       
  2543     {
       
  2544     if ( !aCalledForMenu )    
       
  2545         {
       
  2546         // Execute direct command to PoC AIW. In this case no 
       
  2547         // Logs PoC AIW menu is displayed; call is intiated
       
  2548         // using the PTT-key.
       
  2549         iServHandlerRef->ExecuteServiceCmdL(
       
  2550             aCommandId, 
       
  2551             aParamList,
       
  2552             iServHandlerRef->OutParamListL(),
       
  2553             0,
       
  2554             NULL ); // Callback is NULL as no dial results wanted.
       
  2555         }
       
  2556     else
       
  2557         {
       
  2558         // Execute Menu based command to PoC AIW. The Logs PoC AIW menu
       
  2559         // has already displayed to user and user has selected a command
       
  2560         // from the menu.
       
  2561         iServHandlerRef->ExecuteMenuCmdL(
       
  2562             aCommandId,
       
  2563             aParamList,
       
  2564             iServHandlerRef->OutParamListL(),
       
  2565             0,
       
  2566             NULL ); // Callback is NULL as no dial results wanted.
       
  2567         }
       
  2568         
       
  2569     //If missed list, clear now new missed calls counter
       
  2570     ClearMissedCallNotificationsL();          
       
  2571     }
       
  2572 
       
  2573 // ----------------------------------------------------------------------------
       
  2574 // CLogsBaseView::PrepareCallL
       
  2575 //
       
  2576 // Perform Voice, video or VoIP call.
       
  2577 // ----------------------------------------------------------------------------
       
  2578 //
       
  2579 void CLogsBaseView::PrepareCallL( 
       
  2580     TInt aCommandId, 
       
  2581     TBool aCalledForMenu,
       
  2582     const MLogsEventGetter* aEvent,
       
  2583     TBool aForceVideo )             //Forces video call for non-voip events
       
  2584     {
       
  2585     //Quit if no event, phone number or sip uri
       
  2586     if( !aEvent || (!SipUriAvailable( aEvent ) && !PhoneNumberAvailable( aEvent ) ))
       
  2587         {
       
  2588         return;
       
  2589         }
       
  2590 
       
  2591     TBool isRead = aEvent->Event()->IsRead();
       
  2592     TLogId logid = aEvent->LogId();
       
  2593     TInt duplicates = aEvent->Duplicates();
       
  2594 
       
  2595     CAiwDialData::TCallType callType( CAiwDialData::EAIWVoice );
       
  2596 
       
  2597     if( aEvent->LogsEventData()->VoIP() )
       
  2598         {
       
  2599         callType = CAiwDialData::EAIWVoiP;
       
  2600         }
       
  2601     else if( aForceVideo )
       
  2602         {
       
  2603         callType = CAiwDialData::EAIWForcedVideo;
       
  2604         }
       
  2605     else if( aEvent->LogsEventData()->VT() )
       
  2606         {
       
  2607         callType = CAiwDialData::EAIWVideo;
       
  2608         }
       
  2609 
       
  2610     //Create temporary TBuf that is transferred to CmdCallL in case sip-uri. This is ok as no asynch operations in 
       
  2611     //CmdCallL, so tmp is alive long enough. Also stack consumption should not be too big, so no need for heap allocation.
       
  2612     TBuf<KLogsSipUriMaxLen> buf;    
       
  2613     
       
  2614     TPtrC tmp;    
       
  2615     
       
  2616     if( aEvent->LogsEventData()->VoIP() )
       
  2617         {
       
  2618         //In VoIP we prefer primarily try to use sip uri if available
       
  2619         if( SipUriAvailable( aEvent ) )
       
  2620             {
       
  2621             if( Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf) != KErrNone )     
       
  2622                 {
       
  2623                 return;
       
  2624                 }
       
  2625             tmp.Set( buf ); // sip-uri
       
  2626             }
       
  2627         else
       
  2628             {
       
  2629             tmp.Set( *( aEvent->Number() ) );
       
  2630             }
       
  2631         }
       
  2632      else
       
  2633         {
       
  2634         //For voice and video calls use number
       
  2635         tmp.Set( *( aEvent->Number() ) );
       
  2636         }
       
  2637     CmdCallL( aCommandId,
       
  2638               aCalledForMenu,
       
  2639               tmp, // *(event->Number()) or sip-uri
       
  2640               callType,
       
  2641               aEvent
       
  2642               );     
       
  2643               
       
  2644     if (isRead == EFalse && iModel == ELogsMissedModel)  // If not read, the New missed icon is shown. By setting event read
       
  2645         {                  // the new missed icon is not shown when control comes back to Logs 
       
  2646         Engine()->ClearNewMissedL()->SetNewMissedCallRead(logid, duplicates); 
       
  2647         }    
       
  2648     }
       
  2649 
       
  2650 // ----------------------------------------------------------------------------
       
  2651 // CLogsBaseView::CmdCallL
       
  2652 //
       
  2653 // Perform Voice, video or VoIP call.
       
  2654 // ----------------------------------------------------------------------------
       
  2655 //
       
  2656 void CLogsBaseView::CmdCallL( 
       
  2657     TInt aCommandId, 
       
  2658     TBool aCalledForMenu,         
       
  2659     TPtrC aNumberOrUrl,
       
  2660     CAiwDialData::TCallType aCallType,
       
  2661     const MLogsEventGetter* aEvent    
       
  2662     )
       
  2663     {
       
  2664     TRACE_ENTRY_POINT;  
       
  2665     
       
  2666     if( !aNumberOrUrl.Length() )
       
  2667         {
       
  2668         return;
       
  2669         }
       
  2670     
       
  2671     LOGS_DEBUG_PRINT(LOGS_DEBUG_STRING
       
  2672             ( "CLogsBaseView::CmdCallL - iServiceHandler: 0x%x"), iServHandlerRef);
       
  2673                  
       
  2674     // We have a phone number or SIP URI, so let's set the dial data
       
  2675 
       
  2676 // Sawfish VoIP changes  >>>>
       
  2677     CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC();
       
  2678     dialData->SetPhoneNumberL( aNumberOrUrl );  
       
  2679     dialData->SetCallType( aCallType );
       
  2680     
       
  2681     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip))
       
  2682         {
       
  2683         MLogsEventData* eventData = aEvent->LogsEventData();
       
  2684         if ( eventData )
       
  2685             {
       
  2686             dialData->SetServiceId( eventData->ServiceId() );
       
  2687 
       
  2688             if ( aCalledForMenu )
       
  2689                 {
       
  2690                 // When call is initiated from log's menu
       
  2691                 // - User can select service from list
       
  2692                 dialData->SetServiceId( NULL );
       
  2693                 
       
  2694                 TPtrC8 ptrContactLink( KNullDesC8 );
       
  2695                 if ( KErrNone == eventData->GetContactLink( ptrContactLink ) )
       
  2696                     {    
       
  2697                     CLogsCntLinkChecker* contactCheckerPtr = Engine()->CntLinkCheckerL();
       
  2698                 
       
  2699                     SetInputBlockerL();
       
  2700                 
       
  2701                     // If contact link is valid, dialData use contack link instead of number.
       
  2702                     if ( contactCheckerPtr->IsCntLinkValidSync( ptrContactLink ) )
       
  2703                         {
       
  2704                         dialData->SetContactLinkL(ptrContactLink  );
       
  2705                         dialData->SetPhoneNumberL( KNullDesC );
       
  2706                     
       
  2707                         // EJZO-7RJB3V,the CallUI will invoke phonebook2 to show the call selector, that will
       
  2708                         // make logs receive ViewDeactivated/Lostforeground , then ViewActivated/Foreground events
       
  2709                         //that will cause the logs view flicking.So the hack will avoid this using the following flag                    
       
  2710                         iIgnoreViewDeactivatedHandling = ETrue;
       
  2711                         }
       
  2712                 
       
  2713                     RemoveInputBlocker();
       
  2714                     } 
       
  2715                 }
       
  2716             }
       
  2717         }
       
  2718 // <<<<  Sawfish VoIP changes  
       
  2719     
       
  2720     dialData->SetWindowGroup( AIWDialData::KAiwGoToIdle ); 
       
  2721     CAiwGenericParamList& paramList = iServHandlerRef->InParamListL();
       
  2722     dialData->FillInParamListL( paramList );
       
  2723     CleanupStack::PopAndDestroy( dialData );  
       
  2724     
       
  2725     // If this is an emergency number, initiate the call through the
       
  2726     // new emergency call API. We need to check the number, and not to trust 
       
  2727     // the aEventType as for example CLogsPrependQuery might change the number
       
  2728     ////
       
  2729     TBool isEmergencyNumber = EFalse;
       
  2730     if (aNumberOrUrl.Length() <= KPhCltEmergencyNumberSize)
       
  2731         {
       
  2732         iEmergencyCallAPI->IsEmergencyPhoneNumber(aNumberOrUrl, isEmergencyNumber);
       
  2733         }
       
  2734         
       
  2735    if (isEmergencyNumber)
       
  2736         {
       
  2737         // in case there is already a pending asynch request
       
  2738         // we just skip calling the api again to avoid leaves 
       
  2739         if ( !iEmergencyCallAPI->IsActive())
       
  2740             {    
       
  2741             iEmergencyCallAPI->DialEmergencyCallL(aNumberOrUrl);  
       
  2742             }
       
  2743         }
       
  2744     
       
  2745     // If not an emergency call, initiate call through CallUI
       
  2746     // CallUI should be able to handle emergency calls too, but the
       
  2747     // safest and preffered way is to use Emergency Call API 
       
  2748     ////    
       
  2749     else if( !aCalledForMenu )    
       
  2750         // Execute direct command (CallUI shows list query 
       
  2751         // if needed - i.e user has pressed Send key).
       
  2752         {
       
  2753         iServHandlerRef->ExecuteServiceCmdL(
       
  2754             aCommandId,
       
  2755             paramList,
       
  2756             iServHandlerRef->OutParamListL(),
       
  2757             0,
       
  2758             NULL ); //Callback is NULL as no dial results wanted.
       
  2759         }
       
  2760     else 
       
  2761         // Execute Menu based command (we have already shown 
       
  2762         // Logs-AIW menu to user, so no menus wanted anymore)
       
  2763         {
       
  2764         iServHandlerRef->ExecuteMenuCmdL(
       
  2765             aCommandId,
       
  2766             paramList,
       
  2767             iServHandlerRef->OutParamListL(), 
       
  2768             0,      
       
  2769             NULL ); //Callback is NULL as no dial results wanted.
       
  2770         }
       
  2771 
       
  2772     //If missed list, clear now new missed calls counter
       
  2773     ClearMissedCallNotificationsL();  
       
  2774     
       
  2775     TRACE_EXIT_POINT;         
       
  2776     }
       
  2777 
       
  2778 // ----------------------------------------------------------------------------
       
  2779 // CLogsBaseView::HandleEmergencyDialL
       
  2780 // ----------------------------------------------------------------------------
       
  2781 //
       
  2782 void CLogsBaseView::HandleEmergencyDialL( const TInt /*aStatus */)
       
  2783     {
       
  2784     // TODO: Show some note to user if there is error? 
       
  2785     }
       
  2786 
       
  2787 // ----------------------------------------------------------------------------
       
  2788 // CLogsBaseView::CmdCopyNumberL
       
  2789 // ----------------------------------------------------------------------------
       
  2790 //
       
  2791 void CLogsBaseView::CmdCopyNumberL( const MLogsEventGetter* aEvent )
       
  2792     {
       
  2793     CPlainText* plainText = CPlainText::NewL();
       
  2794     CleanupStack::PushL( plainText );    
       
  2795     
       
  2796     TInt length( 0 );
       
  2797     const HBufC* number = aEvent->Number();
       
  2798     
       
  2799     if( number )
       
  2800         {
       
  2801         length = number->Length();
       
  2802         }
       
  2803 
       
  2804     if( length && length <= KLogsPhoneNumberMaxLen )
       
  2805         {
       
  2806         TBuf<KLogsPhoneNumberMaxLen> buf = *(aEvent->Number());  
       
  2807         AknTextUtils::LanguageSpecificNumberConversion( buf );
       
  2808         plainText->InsertL( 0, buf );         
       
  2809         }
       
  2810         
       
  2811     CClipboard* cb = CClipboard::NewForWritingLC( iCoeEnv->FsSession() );
       
  2812     plainText->CopyToStoreL( cb->Store(), cb->StreamDictionary(), 0, 
       
  2813                                         plainText->DocumentLength() );
       
  2814     cb->CommitL();
       
  2815     CleanupStack::PopAndDestroy( 2 ); // plainText, cb
       
  2816     
       
  2817     CAknNoteDialog* noteDlg = new( ELeave ) CAknNoteDialog( CAknNoteDialog::ENoTone, 
       
  2818                                                             CAknNoteDialog::ELongTimeout );
       
  2819     noteDlg->ExecuteLD( R_NUMBER_COPIED_TO_CB_NOTE );
       
  2820     }    
       
  2821     
       
  2822 
       
  2823 // ----------------------------------------------------------------------------
       
  2824 // CLogsBaseView::CmdCopyAddressL
       
  2825 // ----------------------------------------------------------------------------
       
  2826 //
       
  2827 void CLogsBaseView::CmdCopyAddressL( const MLogsEventGetter* aEvent )
       
  2828     {
       
  2829     TBuf<KLogsSipUriMaxLen> buf;         
       
  2830     TInt ret = Engine()->ConvertToUnicode( aEvent->LogsEventData()->Url(), buf ); 
       
  2831     
       
  2832     if( ret != KErrNone && ret != KErrOverflow )        
       
  2833         {
       
  2834         return; //Converting uri to unicode failed
       
  2835         }
       
  2836     
       
  2837     CPlainText* plainText = CPlainText::NewL();
       
  2838     CleanupStack::PushL( plainText );    
       
  2839     TInt length( buf.Length() );
       
  2840 
       
  2841     if( length && length <= KLogsSipUriMaxLen ) 
       
  2842         {
       
  2843         TBuf<KLogsSipUriMaxLen> bufConv = buf; 
       
  2844         AknTextUtils::LanguageSpecificNumberConversion( bufConv );
       
  2845         plainText->InsertL( 0, bufConv );         
       
  2846         }
       
  2847         
       
  2848     CClipboard* cb = CClipboard::NewForWritingLC( iCoeEnv->FsSession() );
       
  2849     plainText->CopyToStoreL( cb->Store(), cb->StreamDictionary(), 0, 
       
  2850                                         plainText->DocumentLength() );
       
  2851     cb->CommitL();
       
  2852     CleanupStack::PopAndDestroy( 2 ); // plainText, cb
       
  2853     
       
  2854     HBufC* textBuf = NULL;
       
  2855 
       
  2856     if( aEvent->LogsEventData()->VoIP() )
       
  2857         {
       
  2858         textBuf = StringLoader::LoadLC( R_VOIP_ADDRESS_COPIED );            
       
  2859         }
       
  2860     else
       
  2861         {
       
  2862         textBuf = StringLoader::LoadLC( R_POC_ADDRESS_COPIED );                        
       
  2863         }
       
  2864 
       
  2865     //FIXME: The CAknInformationNote seems to overwritten by toolbar even if toolbar is requested
       
  2866     //to be hidden (compared to CAknNoteDialog above that works ok. If not later fixedby toolbar 
       
  2867     //itself, convert here to use CAknNoteDialogs also using note resoruces.
       
  2868     CAknInformationNote* noteDlg = new( ELeave ) CAknInformationNote( );
       
  2869     noteDlg->ExecuteLD( *textBuf );                                                                
       
  2870     CleanupStack::PopAndDestroy( textBuf );  
       
  2871     }
       
  2872 
       
  2873 
       
  2874 // ----------------------------------------------------------------------------
       
  2875 // CLogsBaseView::CmdShowMyAddressL
       
  2876 // ----------------------------------------------------------------------------
       
  2877 //
       
  2878 void CLogsBaseView::CmdShowMyAddressL( const MLogsEventGetter* aEvent )   
       
  2879     {
       
  2880     TBuf<KLogsSipUriMaxLen> buf;             
       
  2881     TInt ret = Engine()->ConvertToUnicode( aEvent->LogsEventData()->MyAddress(), buf );
       
  2882 
       
  2883     if( ret != KErrNone && ret != KErrOverflow )        
       
  2884         {
       
  2885         return; //Converting uri to unicode failed
       
  2886         }
       
  2887 
       
  2888     HBufC* textBuf = NULL;
       
  2889     textBuf = StringLoader::LoadLC( R_STM_MY_ADDRESS, buf );    
       
  2890     CAknNoteDialog* noteDlg = new ( ELeave ) CAknNoteDialog( );
       
  2891     CleanupStack::PushL( noteDlg );
       
  2892     noteDlg->SetTextL( *textBuf );
       
  2893     noteDlg->ExecuteLD( R_MY_ADDRESS_QUERY );	
       
  2894     CleanupStack::Pop( noteDlg ); 
       
  2895     CleanupStack::PopAndDestroy( textBuf );
       
  2896     }
       
  2897 
       
  2898 // ----------------------------------------------------------------------------
       
  2899 // CLogsBaseView::HandleNotifyL
       
  2900 //
       
  2901 // Handle AIW-notifications (from asynch ExecuteCmdL call)
       
  2902 // ----------------------------------------------------------------------------
       
  2903 //
       
  2904 TInt CLogsBaseView::HandleNotifyL(
       
  2905     TInt aCmdId, 
       
  2906     TInt aEventId,
       
  2907     CAiwGenericParamList& aEventParamList,
       
  2908     const CAiwGenericParamList& /* aInParamList */ )
       
  2909     {
       
  2910     //Only EGenericParamContactLinkArray available in aEventParamList so we use iNumberInPbkProcessing instead
       
  2911     
       
  2912     TInt retVal = 0;
       
  2913     //Currently we're only interested in result of contact addition to pbk
       
  2914     if( aCmdId == KAiwCmdAssign )    
       
  2915         {
       
  2916         switch( aEventId ) 
       
  2917             {
       
  2918             case KAiwEventStarted:
       
  2919                 break;
       
  2920             
       
  2921             // If selecting Options->Exit KAiwEventError will result but the contact may have 
       
  2922             // still been created so start updater
       
  2923             case KAiwEventError:
       
  2924             	{
       
  2925             	TInt aError = aEventParamList[0].Value().AsTInt32();
       
  2926             	iCoeEnv->HandleError( aError );
       
  2927             	}
       
  2928             case KAiwEventCompleted: // Asynch req completed. Right softkey "Done" selected for contact editor 
       
  2929                 {
       
  2930                 //Enable UI for db-originated changes (however focus needs to be kept unchanged)
       
  2931                 CurrentModel()->DoActivateL( MLogsModel::EActivateOnly );
       
  2932                 
       
  2933                 //If number was updated to pbk, update it to Logs too (number preferred over sip uri)
       
  2934                 if( iNumberInPbkProcessing )
       
  2935                     {  
       
  2936                     Engine()->EventUpdaterL()->Stop();  //Stop previous updating process
       
  2937                     MLogsReaderConfig* readerConfig = CLogsReaderConfigFactory::
       
  2938                             LogsReaderConfigLC( iNumberInPbkProcessing ); 
       
  2939                     Engine()->EventUpdaterL()->ConfigureL( readerConfig );
       
  2940                     CleanupStack::PopAndDestroy();      //readerConfig
       
  2941                     Engine()->EventUpdaterL()->StartL();//Start asynch process of reading the name from Pbk, updating Logs event 
       
  2942                                                         //and eventually notification of changed db data to respective Logs view.
       
  2943                     //Note: UI Data refresh is started in CLogsEngine::StateChangedL when event updater is finished                                                        
       
  2944                     
       
  2945                     }
       
  2946                 else if( iUriInPbkProcessing )
       
  2947                     {
       
  2948                     //We don't support updating URIs, so nothing done, just refresh the model. 
       
  2949                     CurrentModel()->DoActivateL( MLogsModel::ERefresh );
       
  2950                     }
       
  2951                 
       
  2952                 delete iNumberInPbkProcessing;
       
  2953                 delete iUriInPbkProcessing;    
       
  2954                 iNumberInPbkProcessing = NULL;
       
  2955                 iUriInPbkProcessing = NULL;  
       
  2956                 ClearAiwCallParams();
       
  2957         
       
  2958                 break; 
       
  2959                 }
       
  2960             
       
  2961             case KAiwEventQueryExit: // Contact could still be created so start updater
       
  2962                 {
       
  2963                 // Fix for EPZO-6YWDXY: we must return "true" for the  
       
  2964                 // phonebook to know it can exit 
       
  2965                 retVal = 1;// "ETrue" 
       
  2966                 break;
       
  2967                 }   
       
  2968                 
       
  2969             case KAiwEventCanceled:   //Cancel pressed in Pbk UI
       
  2970                 {
       
  2971                 delete iNumberInPbkProcessing;
       
  2972                 delete iUriInPbkProcessing;    
       
  2973                 iNumberInPbkProcessing = NULL;
       
  2974                 iUriInPbkProcessing = NULL;   
       
  2975                 ClearAiwCallParams();   
       
  2976                                
       
  2977                 if ( LogsAppUi()->ActiveViewId() == Id().iUid && 
       
  2978                      LogsAppUi()->ExecutionMode() == ELogsInForeground )
       
  2979                     {       
       
  2980                     //Refresh UI
       
  2981                     CurrentModel()->DoActivateL( iResetAndRefreshOnHandleNotify );   
       
  2982                     }      
       
  2983              
       
  2984                 iResetAndRefreshOnHandleNotify = MLogsModel::ERefresh;
       
  2985                 break;  
       
  2986                 }
       
  2987             case KAiwEventOutParamCheck:
       
  2988             case KAiwEventInParamCheck:        
       
  2989             case KAiwEventStopped:
       
  2990             
       
  2991             default:
       
  2992                 {
       
  2993                 //Refresh UI
       
  2994                 CurrentModel()->DoActivateL( MLogsModel::ERefresh );                      
       
  2995                 break;  
       
  2996                 }
       
  2997             }
       
  2998         
       
  2999         // Remove inputblocker if still exists
       
  3000         RemoveInputBlocker();
       
  3001         MenuBar()->StopDisplayingMenuBar();
       
  3002         }
       
  3003     
       
  3004     return retVal;    
       
  3005     }
       
  3006 
       
  3007 // ----------------------------------------------------------------------------
       
  3008 // CLogsBaseView::IsOkToShowContextMenu
       
  3009 // ----------------------------------------------------------------------------
       
  3010 //
       
  3011 TBool CLogsBaseView::IsOkToShowContextMenu( const MLogsEventGetter* aEvent )
       
  3012     {
       
  3013     //aEvent may not yet be available
       
  3014     if( !aEvent || aEvent->EventType() == ETypeEmerg ) 
       
  3015         {
       
  3016         return EFalse;    
       
  3017         }
       
  3018         
       
  3019     if( PhoneNumberAvailable( aEvent ) || SipUriAvailable( aEvent ) ) 
       
  3020         {
       
  3021         return ETrue;    
       
  3022         }
       
  3023         
       
  3024     return EFalse;
       
  3025     }
       
  3026 
       
  3027 // ----------------------------------------------------------------------------
       
  3028 // CLogsBaseView::HandleControlEventL
       
  3029 //
       
  3030 // from MCoeControlObserver        
       
  3031 // ----------------------------------------------------------------------------
       
  3032 //
       
  3033 void CLogsBaseView::HandleControlEventL( 
       
  3034     CCoeControl* /* aControl */, 
       
  3035     TCoeEvent /* aEventType */ ) 
       
  3036     {
       
  3037     }
       
  3038 
       
  3039 // ----------------------------------------------------------------------------
       
  3040 // CLogsBaseView::SetToolbarItems
       
  3041 // ----------------------------------------------------------------------------
       
  3042 //
       
  3043 void CLogsBaseView::SetToolbarItems( 
       
  3044     const MLogsEventGetter* aEvent )
       
  3045     {
       
  3046     TRACE_ENTRY_POINT;  
       
  3047     
       
  3048     if (AknLayoutUtils::PenEnabled() )
       
  3049         {  
       
  3050         CAknToolbar* toolbar  = Toolbar();
       
  3051         if( !toolbar  ) 
       
  3052             {
       
  3053             return;    
       
  3054             }
       
  3055 
       
  3056         //aEvent may not yet be available, show only open pbk selection then
       
  3057         if( !aEvent ) 
       
  3058             {
       
  3059             toolbar->SetItemDimmed( ELogsCmdSendKeyCall, ETrue, EFalse );
       
  3060             toolbar->SetItemDimmed( ELogsCmdToolBarSendUi, ETrue, EFalse );
       
  3061             }
       
  3062         else 
       
  3063             {
       
  3064             TBool emerg( aEvent->EventType() == ETypeEmerg );
       
  3065             TBool nbr( PhoneNumberAvailable( aEvent ));    
       
  3066             TBool voipUri( SipUriAvailable( aEvent ) && aEvent->LogsEventData()->VoIP() );
       
  3067             TBool pocUri( SipUriAvailable( aEvent ) && aEvent->LogsEventData()->PoC() );    
       
  3068             toolbar->SetItemDimmed( ELogsCmdSendKeyCall,     !nbr && !voipUri && !pocUri,  EFalse );
       
  3069             toolbar->SetItemDimmed( ELogsCmdToolBarSendUi,     !nbr || emerg, EFalse  );      
       
  3070             }
       
  3071 
       
  3072         //aToolbar->DrawNow();
       
  3073         toolbar->DrawDeferred();
       
  3074         } 
       
  3075     TRACE_EXIT_POINT;  
       
  3076     }
       
  3077 
       
  3078 //  End of File
       
  3079 
       
  3080