phoneuis/easydialing/src/easydialingplugin.cpp
branchRCL_3
changeset 23 40a3f856b14d
parent 20 3c221667e687
equal deleted inserted replaced
22:94dc1107e8b2 23:40a3f856b14d
    44 #include <CPsPattern.h>
    44 #include <CPsPattern.h>
    45 #include <CPsRequestHandler.h>
    45 #include <CPsRequestHandler.h>
    46 
    46 
    47 // Virtual phonebook header files
    47 // Virtual phonebook header files
    48 #include <VPbkContactStoreUris.h>
    48 #include <VPbkContactStoreUris.h>
    49 #include <CVPbkContactStoreUriArray.h>
       
    50 #include <TVPbkContactStoreUriPtr.h>
       
    51 #include <CVPbkContactLinkArray.h>
       
    52 #include <VPbkEng.rsg> // contains virtual phonebook data fields
    49 #include <VPbkEng.rsg> // contains virtual phonebook data fields
    53 #include <phoneui.rsg> 
    50 #include <phoneui.rsg> 
    54 
    51 
    55 // CCA Launcher header files.
    52 // CCA Launcher header files.
    56 #include <ccafactory.h>
    53 #include <ccafactory.h>
   179 // engine and initialises all member data.
   176 // engine and initialises all member data.
   180 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   181 //
   178 //
   182 void CEasyDialingPlugin::ConstructL()
   179 void CEasyDialingPlugin::ConstructL()
   183     {
   180     {
   184     // Create a contact store array.
   181     iLongTapped = EFalse;
   185     HBufC* defaultCdb = VPbkContactStoreUris::DefaultCntDbUri().AllocLC();
   182     // Create contact data manager.
   186     iContactDataStores.AppendL( defaultCdb );
   183     iContactDataManager = CEasyDialingContactDataManager::NewL();
   187     CleanupStack::Pop( defaultCdb );
   184     iContactDataManager->SetObserver( this );
   188 
       
   189     // Create a contact manager instance.
       
   190     iContactStoreUriArray = CVPbkContactStoreUriArray::NewL();
       
   191     iContactStoreUriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) );
       
   192     iContactManager = CVPbkContactManager::NewL( *iContactStoreUriArray );
       
   193     
       
   194     iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager);
       
   195     iContactDataManager->ConstructL();
       
   196     iContactDataManager->SetObserver(this);
       
   197 
   185 
   198     // Find a handle to ca launcher extension MCCAConnectionExt.
   186     // Find a handle to ca launcher extension MCCAConnectionExt.
   199     // Easydialing has to use the extension API, because it needs function CloseAppL
   187     // Easydialing has to use the extension API, because it needs function CloseAppL
   200     // only found in extension.
   188     // only found in extension.
   201     // MCCAConnection extension has to be obtained through MCCAParameter extension,
   189     // MCCAConnection extension has to be obtained through MCCAParameter extension,
   209     
   197     
   210     // Cast the pointer into contact launcher object. 
   198     // Cast the pointer into contact launcher object. 
   211     User::LeaveIfNull( any );
   199     User::LeaveIfNull( any );
   212     iContactLauncher = static_cast<MCCAConnectionExt*>( any );
   200     iContactLauncher = static_cast<MCCAConnectionExt*>( any );
   213     
   201     
   214     iCenrepListener = CEasyDialingCenrepListener::NewL(this);
   202     iCenrepListener = CEasyDialingCenrepListener::NewL( this );
   215    
   203    
   216     iContactorService = CEDContactorService::NewL( this );
   204     iContactorService = CEDContactorService::NewL( this );
   217 
   205 
   218     // EasyDialing resource file is attempted to be read from the same directory where the
   206     // EasyDialing resource file is attempted to be read from the same directory where the
   219     // executed binary is located
   207     // executed binary is located
   240     iObservers.Reset();
   228     iObservers.Reset();
   241     
   229     
   242     delete iCenrepListener;
   230     delete iCenrepListener;
   243     delete iContactDataManager;
   231     delete iContactDataManager;
   244     delete iPredictiveSearchQuery;
   232     delete iPredictiveSearchQuery;
   245     delete iContactManager;
       
   246     delete iContactStoreUriArray;
       
   247     iContactDataStores.ResetAndDestroy();
   233     iContactDataStores.ResetAndDestroy();
   248 
   234 
   249     if ( iPredictiveContactSearchHandler )
   235     if ( iPredictiveContactSearchHandler )
   250         {
   236         {
   251         iPredictiveContactSearchHandler->RemoveObserver(this);
   237         iPredictiveContactSearchHandler->RemoveObserver(this);
   404 void CEasyDialingPlugin::InitPredictiveContactSearchL()
   390 void CEasyDialingPlugin::InitPredictiveContactSearchL()
   405     {
   391     {
   406     iPredictiveContactSearchHandler = CPSRequestHandler::NewL();
   392     iPredictiveContactSearchHandler = CPSRequestHandler::NewL();
   407     iPredictiveContactSearchHandler->AddObserverL(this);
   393     iPredictiveContactSearchHandler->AddObserverL(this);
   408 
   394 
   409     // Put the searched contact fields into array.
       
   410     RArray<TInt> contact_fields;
       
   411     CleanupClosePushL(contact_fields);
       
   412 
       
   413     // Check which relevant contact fields are indexed in PCS search.
   395     // Check which relevant contact fields are indexed in PCS search.
   414     iFirstNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_FIRSTNAME );
   396     iFirstNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_FIRSTNAME );
   415     iLastNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_LASTNAME );
   397     iLastNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_LASTNAME );
   416     iCompanyNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_COMPANYNAME );
   398     iCompanyNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_COMPANYNAME );
   417 
   399 
   431         OstTrace0( TRACE_ERROR, CEASYDIALINGPLUGIN_INITPREDICTIVECONTACTSEARCHL_ERROR_NO_LAST_NAME, "ERROR, PCS does not support last name indexing!" );
   413         OstTrace0( TRACE_ERROR, CEASYDIALINGPLUGIN_INITPREDICTIVECONTACTSEARCHL_ERROR_NO_LAST_NAME, "ERROR, PCS does not support last name indexing!" );
   432         LOGSTRING("EasyDialingPlugin: PCS does not support last name indexing => Leave");
   414         LOGSTRING("EasyDialingPlugin: PCS does not support last name indexing => Leave");
   433         User::Leave( KErrEasyDialingNoLastNamePCSIndexing );
   415         User::Leave( KErrEasyDialingNoLastNamePCSIndexing );
   434         }
   416         }
   435 
   417 
       
   418     SetupPcsSettingsL();
       
   419 
       
   420     iPredictiveSearchQuery = CPsQuery::NewL();
       
   421     }
       
   422 
       
   423 // -----------------------------------------------------------------------------
       
   424 // SetupPcsSettingsL
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 void CEasyDialingPlugin::SetupPcsSettingsL()
       
   428     {
       
   429     // Get current store configuration from Phonebook settings
       
   430     iContactDataStores.ResetAndDestroy();
       
   431     iContactDataManager->GetCurrentStoreUrisL( iContactDataStores );
       
   432     
       
   433     // Put the searched contact fields into array.
       
   434     RArray<TInt> contact_fields;
       
   435     CleanupClosePushL(contact_fields);
       
   436 
   436     // First name, last name and company name (if supported) are used in PCS search.
   437     // First name, last name and company name (if supported) are used in PCS search.
   437     contact_fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME);
   438     contact_fields.Append( R_VPBK_FIELD_TYPE_FIRSTNAME );
   438     contact_fields.Append(R_VPBK_FIELD_TYPE_LASTNAME);
   439     contact_fields.Append( R_VPBK_FIELD_TYPE_LASTNAME );
   439     if ( iCompanyNamePCSIndex != KErrNotFound )
   440     contact_fields.Append( R_VPBK_FIELD_TYPE_COMPANYNAME );
   440         {
   441 
   441         contact_fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME);
   442     // Create and fill PS settings object.
   442         }
   443     CPsSettings* ps_settings = CPsSettings::NewL();
   443 
   444     CleanupStack::PushL( ps_settings );
       
   445 
       
   446     ps_settings->SetSearchUrisL( iContactDataStores );
       
   447     ps_settings->SetMaxResults( KEDMaximumMatchingContactsCount );
       
   448     ps_settings->SetSortType( EAlphabetical );
       
   449     ps_settings->SetDisplayFieldsL( contact_fields );
       
   450 
       
   451     // Set the PCS settings.
       
   452     iPredictiveContactSearchHandler->SetSearchSettingsL( *ps_settings );
       
   453 
       
   454     CleanupStack::PopAndDestroy( ps_settings );
       
   455     CleanupStack::PopAndDestroy( &contact_fields );
       
   456 
       
   457     // Set the sort order. This must happen after the contact store settings
       
   458     // are up-to-date.
   444     SetSortOrderL( iContactDataManager->NameOrder() );
   459     SetSortOrderL( iContactDataManager->NameOrder() );
   445 
       
   446     // Create and fill ps settings object.
       
   447     CPsSettings* ps_settings = CPsSettings::NewL();
       
   448     CleanupStack::PushL(ps_settings);
       
   449 
       
   450     ps_settings->SetSearchUrisL(iContactDataStores);
       
   451     ps_settings->SetMaxResults(KEDMaximumMatchingContactsCount);
       
   452     ps_settings->SetSortType(EAlphabetical);
       
   453     ps_settings->SetDisplayFieldsL(contact_fields);
       
   454 
       
   455     // Set the PCS settings.
       
   456     iPredictiveContactSearchHandler->SetSearchSettingsL(*ps_settings);
       
   457 
       
   458     CleanupStack::PopAndDestroy(ps_settings);
       
   459     CleanupStack::PopAndDestroy(&contact_fields);
       
   460 
       
   461     iPredictiveSearchQuery = CPsQuery::NewL();
       
   462     }
   460     }
   463 
   461 
   464 // -----------------------------------------------------------------------------
   462 // -----------------------------------------------------------------------------
   465 // SetSortOrderL
   463 // SetSortOrderL
   466 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   469     {
   467     {
   470     RArray<TInt> fields;
   468     RArray<TInt> fields;
   471     CleanupClosePushL( fields );
   469     CleanupClosePushL( fields );
   472     if ( aNameOrder == CEasyDialingContactDataManager::EFirstnameLastname )
   470     if ( aNameOrder == CEasyDialingContactDataManager::EFirstnameLastname )
   473         {
   471         {
   474         fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME);
   472         fields.AppendL( R_VPBK_FIELD_TYPE_FIRSTNAME );
   475         fields.Append(R_VPBK_FIELD_TYPE_LASTNAME);
   473         fields.AppendL( R_VPBK_FIELD_TYPE_LASTNAME );
   476         }
   474         }
   477     else
   475     else
   478         {
   476         {
   479         fields.Append(R_VPBK_FIELD_TYPE_LASTNAME);
   477         fields.AppendL( R_VPBK_FIELD_TYPE_LASTNAME );
   480         fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME);
   478         fields.AppendL( R_VPBK_FIELD_TYPE_FIRSTNAME );
   481         }
   479         }
   482     if ( iCompanyNamePCSIndex != KErrNotFound )
   480     fields.AppendL( R_VPBK_FIELD_TYPE_COMPANYNAME );
   483         {
   481     
   484         fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME);
   482     // Set the same order for each contact store. PCS automatically ignores
   485         }
   483     // fields not supported by the given store.
   486     iPredictiveContactSearchHandler->ChangeSortOrderL( *iContactDataStores[0], fields );
   484     for ( TInt i = 0 ; i < iContactDataStores.Count() ; ++i )
       
   485         {
       
   486         iPredictiveContactSearchHandler->ChangeSortOrderL( *iContactDataStores[i], fields );
       
   487         }
   487     CleanupStack::PopAndDestroy( &fields );
   488     CleanupStack::PopAndDestroy( &fields );
   488     }
   489     }
   489 
   490 
   490 // -----------------------------------------------------------------------------
   491 // -----------------------------------------------------------------------------
   491 // OfferKeyEventL
   492 // OfferKeyEventL
   844     {
   845     {
   845     TRAP_IGNORE( DoHandleContactsChangedL() );
   846     TRAP_IGNORE( DoHandleContactsChangedL() );
   846     }
   847     }
   847 
   848 
   848 // -----------------------------------------------------------------------------
   849 // -----------------------------------------------------------------------------
       
   850 // StoreConfigurationChanged
       
   851 // From MContactDataManagerObserver
       
   852 // -----------------------------------------------------------------------------
       
   853 //
       
   854 void CEasyDialingPlugin::StoreConfigurationChanged()
       
   855     {
       
   856     TRAP_IGNORE( 
       
   857         // Reconfigure PCS to update its store settings
       
   858         SetupPcsSettingsL();
       
   859         // Contacts available have changed and a new search is needed if we have
       
   860         // previous results shown.
       
   861         DoHandleContactsChangedL() 
       
   862         );
       
   863     }
       
   864 
       
   865 // -----------------------------------------------------------------------------
   849 // InformContactorEvent
   866 // InformContactorEvent
   850 // From MEDContactorObserver
   867 // From MEDContactorObserver
   851 // -----------------------------------------------------------------------------
   868 // -----------------------------------------------------------------------------
   852 //
   869 //
   853 void CEasyDialingPlugin::InformContactorEvent( MEDContactorObserver::TEvent aEvent )
   870 void CEasyDialingPlugin::InformContactorEvent( MEDContactorObserver::TEvent aEvent )
   913         
   930         
   914         // The PCS mode used with character is based on character itself,
   931         // The PCS mode used with character is based on character itself,
   915         // not to the keyboard it is made with. While this is not strictly
   932         // not to the keyboard it is made with. While this is not strictly
   916         // identical to checking the used keyboard, this behaves identically
   933         // identical to checking the used keyboard, this behaves identically
   917         // in most of the normal cases, and makes the logic simpler.
   934         // in most of the normal cases, and makes the logic simpler.
   918         if ( IsItuTCharacter( iSearchString[i] ) )
   935         // In case of hybrid mode keyboard, use always predictive default 
       
   936         // keyboard.
       
   937         if ( iKeyboardMode == EDefaultKeyboard && 
       
   938              IsItuTCharacter( iSearchString[i] ) )
   919             {
   939             {
   920             item->SetMode( EPredictiveItuT );
   940             item->SetMode( EPredictiveItuT );
   921             }
   941             }
   922         else 
   942         else 
   923             {
   943             {
  1003 TInt CEasyDialingPlugin::FindContactFieldPCSIndexL( TInt aIndex )
  1023 TInt CEasyDialingPlugin::FindContactFieldPCSIndexL( TInt aIndex )
  1004     {
  1024     {
  1005     RArray<TInt> fieldOrder;
  1025     RArray<TInt> fieldOrder;
  1006     CleanupClosePushL( fieldOrder );
  1026     CleanupClosePushL( fieldOrder );
  1007 
  1027 
  1008     // Current implementation searches only from default database.
  1028     // PCS uses the same data plugin for all the Phonebook databases
  1009     // Later this may be expanded to search SIM contacts as well.
  1029     // (i.e. phone contacts, SIM contacts, SDN contacts), and there can be only
       
  1030     // one data order per plugin. Thus, data order for all databases supported
       
  1031     // by us is the same, and it's enough to ask data order just for the default CDB.
  1010     const TDesC& defaultCdb = VPbkContactStoreUris::DefaultCntDbUri();
  1032     const TDesC& defaultCdb = VPbkContactStoreUris::DefaultCntDbUri();
  1011 
  1033 
  1012     iPredictiveContactSearchHandler->GetDataOrderL( defaultCdb, fieldOrder );
  1034     iPredictiveContactSearchHandler->GetDataOrderL( defaultCdb, fieldOrder );
  1013     TInt pcsIndex = fieldOrder.Find( aIndex );
  1035     TInt pcsIndex = fieldOrder.Find( aIndex );
  1014 
  1036 
  1070     for ( TInt i = 0; i < numberOfPCSMatches; i++ )
  1092     for ( TInt i = 0; i < numberOfPCSMatches; i++ )
  1071         {
  1093         {
  1072         TInt indexFromEnd = numberOfPCSMatches - i - 1;
  1094         TInt indexFromEnd = numberOfPCSMatches - i - 1;
  1073 
  1095 
  1074         MVPbkContactLink* link = iPredictiveContactSearchHandler->ConvertToVpbkLinkLC(
  1096         MVPbkContactLink* link = iPredictiveContactSearchHandler->ConvertToVpbkLinkLC(
  1075                 *(aResults[indexFromEnd]), *iContactManager );
  1097                 *(aResults[indexFromEnd]), iContactDataManager->ContactManager() );
  1076         if ( !iContactDataManager->IsFavL( link ) )
  1098         if ( !iContactDataManager->IsFavL( link ) )
  1077             {
  1099             {
  1078             // handle favourites separately, in another loop
  1100             // handle favourites separately, in another loop
  1079             HBufC* contactString = CreateContactStringLC( aResults[ indexFromEnd ], nameOrder );
  1101             HBufC* contactString = CreateContactStringLC( aResults[ indexFromEnd ], nameOrder );
  1080             CreateListBoxContactStringL( *contactString, link, matchThumbnails, EFalse );
  1102             CreateListBoxContactStringL( *contactString, link, matchThumbnails, EFalse );
  1437             voiceCall = iContactDataManager->VoiceCallAvailable( index );
  1459             voiceCall = iContactDataManager->VoiceCallAvailable( index );
  1438             videoCall = iContactDataManager->VideoCallAvailable( index );
  1460             videoCall = iContactDataManager->VideoCallAvailable( index );
  1439             message = iContactDataManager->UniEditorAvailable( index );
  1461             message = iContactDataManager->UniEditorAvailable( index );
  1440             }
  1462             }
  1441             
  1463             
  1442         // Call menu item is not show if neither voice call nor video call are possible. 
  1464         
  1443         aMenuPane.SetItemDimmed( EEasyDialingVoiceCall, !voiceCall && !videoCall ); 
  1465         aMenuPane.SetItemDimmed( EEasyDialingVoiceCall, !voiceCall ); 
       
  1466         aMenuPane.SetItemDimmed( EEasyDialingVideoCall, !videoCall ); 
  1444         aMenuPane.SetItemDimmed( EEasyDialingSendMessage, !message ); 
  1467         aMenuPane.SetItemDimmed( EEasyDialingSendMessage, !message ); 
  1445         
  1468         
  1446         LOGSTRING("EasyDialingPlugin::InitializeMenuPaneL: InitializeMenuPaneL done" );
  1469         LOGSTRING("EasyDialingPlugin::InitializeMenuPaneL: InitializeMenuPaneL done" );
  1447         
  1470         
  1448         return ETrue;  
  1471         return ETrue;  
  1449         }
  1472         }
  1450     
  1473     
  1451     else if ( aMenuResourceId == R_EASYDIALING_OPTIONS_CALL_MENU )
       
  1452         {
       
  1453         TBool voiceCall = EFalse;
       
  1454         TBool videoCall = EFalse;
       
  1455         
       
  1456         if ( iContactListBox->CurrentItemIndex() >= 0 ) 
       
  1457             {
       
  1458             TInt index = iContactListBox->CurrentContactDataIndex();
       
  1459             
       
  1460             voiceCall = iContactDataManager->VoiceCallAvailable( index );
       
  1461             videoCall = iContactDataManager->VideoCallAvailable( index );
       
  1462             }
       
  1463         
       
  1464         aMenuPane.SetItemDimmed( EEasyDialingVoiceCall, !voiceCall ); 
       
  1465         aMenuPane.SetItemDimmed( EEasyDialingVideoCall, !videoCall ); 
       
  1466 
       
  1467         LOGSTRING("EasyDialingPlugin::InitializeMenuPaneL: InitializeMenuPaneL for call submenu done" );
       
  1468         
       
  1469         return ETrue;
       
  1470         }
       
  1471     
       
  1472     else if ( aMenuResourceId == R_EASYDIALING_OPTIONS_ON_OFF_CASCADE_MENU )
  1474     else if ( aMenuResourceId == R_EASYDIALING_OPTIONS_ON_OFF_CASCADE_MENU )
  1473         {
  1475         {
  1474         if ( IsEnabled() )
  1476         if ( IsEnabled() )
  1475             {
  1477             {
  1476             aMenuPane.SetItemButtonState( EEasyDialingOn, EEikMenuItemSymbolOn );
  1478             aMenuPane.SetItemButtonState( EEasyDialingOn, EEikMenuItemSymbolOn );
  1510         // Vkb status flag should be updated always too (invokes no action).
  1512         // Vkb status flag should be updated always too (invokes no action).
  1511         return ETrue;
  1513         return ETrue;
  1512         }
  1514         }
  1513  
  1515  
  1514     
  1516     
  1515     TBool ret(EFalse);
  1517     TBool ret(ETrue);
  1516     
  1518     
  1517     switch ( aCommand )
  1519     switch ( aCommand )
  1518         {
  1520         {
  1519         case EEasyDialingOpenContact:
  1521         case EEasyDialingOpenContact:
  1520             
  1522             
  1521             iRememberFocus = ETrue;
  1523             iRememberFocus = ETrue;
  1522             AsyncActionLaunchL( ELaunchCurrentContact );
  1524             AsyncActionLaunchL( ELaunchCurrentContact );
  1523             ret = ETrue;
       
  1524             break;
  1525             break;
  1525 
  1526 
  1526         // EEasyDialingEnterKeyAction is sent when Enter key is pressed.
  1527         // EEasyDialingEnterKeyAction is sent when Enter key is pressed.
  1527         // EEasyDialingMakeCall is sent when send key or send toolbar button or send menu item is pressed.
  1528         // EEasyDialingMakeCall is sent when send key or send toolbar button or send menu item is pressed.
  1528         case EEasyDialingVoiceCall: // fall through
  1529         case EEasyDialingVoiceCall: // fall through
  1529         case EEasyDialingEnterKeyAction:
  1530         case EEasyDialingEnterKeyAction:
  1530             // Make a call.
  1531             // Make a call.
  1531             iRememberFocus = ETrue;
  1532             iRememberFocus = ETrue;
  1532             AsyncActionLaunchL( ECallCurrentContact );
  1533             AsyncActionLaunchL( ECallCurrentContact );
  1533             ret = ETrue;
       
  1534             break;
  1534             break;
  1535             
  1535             
  1536         // Video call is selectable only through menu.
  1536         // Video call is selectable only through menu.
  1537         case EEasyDialingVideoCall:
  1537         case EEasyDialingVideoCall:
  1538             // Make a video call.
  1538             // Make a video call.
  1539             iRememberFocus = ETrue;
  1539             iRememberFocus = ETrue;
  1540             AsyncActionLaunchL( EVideoCallCurrentContact );
  1540             AsyncActionLaunchL( EVideoCallCurrentContact );
  1541             ret = ETrue;
       
  1542             break;
  1541             break;
  1543                 
  1542                 
  1544         // Uni-editor message is selectable only through menu.
  1543         // Uni-editor message is selectable only through menu.
  1545         case EEasyDialingSendMessage:
  1544         case EEasyDialingSendMessage:
  1546             // Create a message.
  1545             // Create a message.
  1547             iRememberFocus = ETrue;
  1546             iRememberFocus = ETrue;
  1548             AsyncActionLaunchL( ESendMessageCurrentContact );
  1547             AsyncActionLaunchL( ESendMessageCurrentContact );
  1549             ret = ETrue;
       
  1550             break;
  1548             break;
  1551                     
  1549                     
  1552         // EEasyDialingCallHandlingActivated is sent when the in-call-ui of telephony gets activated
  1550         // EEasyDialingCallHandlingActivated is sent when the in-call-ui of telephony gets activated
  1553         case EEasyDialingCallHandlingActivated:
  1551         case EEasyDialingCallHandlingActivated:
  1554             
  1552             
  1561             if ( iContactLauncherActive )
  1559             if ( iContactLauncherActive )
  1562                 {
  1560                 {
  1563                 iNewSearchNeeded = EFalse;
  1561                 iNewSearchNeeded = EFalse;
  1564                 iContactLauncher->CloseAppL();
  1562                 iContactLauncher->CloseAppL();
  1565                 }
  1563                 }
  1566             ret = ETrue;
       
  1567             break;
  1564             break;
  1568             
  1565             
  1569         case EEasyDialingOn:
  1566         case EEasyDialingOn:
  1570             
  1567             
  1571             iCenrepListener->SetEasyDialingSettingsValue( 1 );
  1568             iCenrepListener->SetEasyDialingSettingsValue( 1 );
  1572             ret = ETrue;
       
  1573             break;
  1569             break;
  1574 
  1570 
  1575         case EEasyDialingOff:
  1571         case EEasyDialingOff:
  1576             
  1572             
  1577             iCenrepListener->SetEasyDialingSettingsValue( 0 );
  1573             iCenrepListener->SetEasyDialingSettingsValue( 0 );
  1578             ret = ETrue;
       
  1579             break;    
  1574             break;    
  1580             
  1575             
  1581         case EEasyDialingClosePopup:
  1576         case EEasyDialingClosePopup:
  1582             
  1577             
  1583             // Not only Number Entry is removed but also closes down number selection popup in case it happens to be open.
  1578             // Not only Number Entry is removed but also closes down number selection popup in case it happens to be open.
  1584             iContactorService->CancelService();
  1579             iContactorService->CancelService();
  1585             ret = ETrue;
       
  1586             break;
  1580             break;
  1587             
  1581             
  1588         case EEasyDialingVkbOpened:
  1582         case EEasyDialingVkbOpened:
  1589             
  1583             
  1590             iVirtualKeyboardOpen = ETrue;
  1584             iVirtualKeyboardOpen = ETrue;
  1591             ret = ETrue;
       
  1592             break;
  1585             break;
  1593                   
  1586                   
  1594         case EEasyDialingVkbClosed:
  1587         case EEasyDialingVkbClosed:
  1595             
  1588             
  1596             iVirtualKeyboardOpen = EFalse;
  1589             iVirtualKeyboardOpen = EFalse;
  1597             ret = ETrue;
  1590             HandleGainingForeground();
  1598             break;
  1591             break;
  1599             
  1592             
  1600         default:
  1593         default:
       
  1594             ret = EFalse;
  1601             break;
  1595             break;
  1602         }
  1596         }
  1603     return ret;
  1597     return ret;
  1604     }
  1598     }
  1605 
  1599 
  1609 // -----------------------------------------------------------------------------
  1603 // -----------------------------------------------------------------------------
  1610 //
  1604 //
  1611 TBool CEasyDialingPlugin::IsEnabled() const
  1605 TBool CEasyDialingPlugin::IsEnabled() const
  1612     {
  1606     {
  1613     return ( iCenrepListener && iCenrepListener->Value() != 0 );
  1607     return ( iCenrepListener && iCenrepListener->Value() != 0 );
       
  1608     }
       
  1609 
       
  1610 // -----------------------------------------------------------------------------
       
  1611 // SetKeyboardMode
       
  1612 // Sets keyboard mode
       
  1613 // -----------------------------------------------------------------------------
       
  1614 //
       
  1615 void CEasyDialingPlugin::SetKeyboardMode( TKeyboardMode aMode )
       
  1616     {
       
  1617     iKeyboardMode = aMode;
  1614     }
  1618     }
  1615 
  1619 
  1616 // -----------------------------------------------------------------------------
  1620 // -----------------------------------------------------------------------------
  1617 // AsyncSimulateKeyEvent
  1621 // AsyncSimulateKeyEvent
  1618 // 
  1622 // 
  1723 // -----------------------------------------------------------------------------
  1727 // -----------------------------------------------------------------------------
  1724 // DoLaunchActionL
  1728 // DoLaunchActionL
  1725 //
  1729 //
  1726 // -----------------------------------------------------------------------------
  1730 // -----------------------------------------------------------------------------
  1727 //
  1731 //
  1728 void CEasyDialingPlugin::DoLaunchActionL( )
  1732 void CEasyDialingPlugin::DoLaunchActionL()
  1729     {
  1733     {
  1730     if ( iActionToBeLaunched == EInitializePcs )
  1734     if ( iActionToBeLaunched == EInitializePcs )
  1731         {
  1735         {
  1732         PERF_MEASURE_START
  1736         PERF_MEASURE_START
  1733         InitPredictiveContactSearchL();
  1737         InitPredictiveContactSearchL();
  1860             // 9.2. Selecting contact initiates call
  1864             // 9.2. Selecting contact initiates call
  1861             AsyncActionLaunchL( ECallCurrentContact );
  1865             AsyncActionLaunchL( ECallCurrentContact );
  1862             break;
  1866             break;
  1863 
  1867 
  1864         case KEasyDialingContactLongTapped:
  1868         case KEasyDialingContactLongTapped:
       
  1869             iLongTapped = ETrue;
  1865             AsyncActionLaunchL( ELaunchCurrentContact );
  1870             AsyncActionLaunchL( ELaunchCurrentContact );
  1866             break;
  1871             break;
  1867             
  1872             
  1868         // Pause contact data manager when panning and flicking listbox.
  1873         // Pause contact data manager when panning and flicking listbox.
  1869         // This ensures smooth and responsive listbox touch handling.
  1874         // This ensures smooth and responsive listbox touch handling.
  1881             iContactDataManager->Pause( EFalse );
  1886             iContactDataManager->Pause( EFalse );
  1882             
  1887             
  1883             // Touching the listbox always removes the visual focus from any list item.
  1888             // Touching the listbox always removes the visual focus from any list item.
  1884             // Move the focus away from the listbox after panning has ended to
  1889             // Move the focus away from the listbox after panning has ended to
  1885             // align our internal state with the visual lack of focus.
  1890             // align our internal state with the visual lack of focus.
  1886             if ( IsFocused() )
  1891             if ( IsFocused() && !iLongTapped )
  1887                 {
  1892                 {
  1888                 SetFocus( EFalse );
  1893                 SetFocus( EFalse );
  1889                 DrawDeferred();
  1894                 DrawDeferred();
  1890                 }
  1895                 }
       
  1896             iLongTapped = EFalse;
  1891             break;
  1897             break;
  1892             
  1898             
  1893         // We are not interested about the other listbox events.
  1899         // We are not interested about the other listbox events.
  1894         default:
  1900         default:
  1895             break;
  1901             break;
  1921         {
  1927         {
  1922         // The cached information in contact data manager may be outdated. Call to reload makes sure that when the 
  1928         // The cached information in contact data manager may be outdated. Call to reload makes sure that when the 
  1923         // search is made, all data is loaded again.
  1929         // search is made, all data is loaded again.
  1924         iContactDataManager->Reload();
  1930         iContactDataManager->Reload();
  1925         
  1931         
  1926         LaunchSearchL();
  1932         TRAP_IGNORE( LaunchSearchL() );
  1927         }
  1933         }
  1928     }
  1934     }
  1929 
  1935 
  1930 // -----------------------------------------------------------------------------
  1936 // -----------------------------------------------------------------------------
  1931 // HandleLosingForeground
  1937 // HandleLosingForeground
  1963 void CEasyDialingPlugin::DoHandleContactsChangedL()
  1969 void CEasyDialingPlugin::DoHandleContactsChangedL()
  1964     {
  1970     {
  1965     if ( iSearchString.Length() > 0 && IsEnabled() )
  1971     if ( iSearchString.Length() > 0 && IsEnabled() )
  1966         {
  1972         {
  1967         CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() );
  1973         CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() );
  1968         if ( appUi->IsForeground() )
  1974         if ( appUi->IsForeground() && !iVirtualKeyboardOpen )
  1969             {
  1975             {
  1970             // Do new search immediately, if contacts change while we are on the
  1976             // Do new search immediately, if contacts change while we are on the
  1971             // foreground. This can happen for example if view is switched to
  1977             // foreground. This can happen for example if view is switched to
  1972             // dialer while deletion of multiple contacts is still ongoing or if
  1978             // dialer while deletion of multiple contacts is still ongoing or if
  1973             // PCS takes so long to update the cache that view gets changed 
  1979             // PCS takes so long to update the cache that view gets changed