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