equal
deleted
inserted
replaced
22 #include "easydialinglogger.h" |
22 #include "easydialinglogger.h" |
23 #include "easydialingpanics.h" |
23 #include "easydialingpanics.h" |
24 #include "easydialingcenreplistener.h" |
24 #include "easydialingcenreplistener.h" |
25 #include "easydialingcontactdatamanager.h" |
25 #include "easydialingcontactdatamanager.h" |
26 #include "easydialingutils.h" |
26 #include "easydialingutils.h" |
|
27 #include "easydialingcommands.hrh" |
27 #include <easydialingpluginresources.rsg> |
28 #include <easydialingpluginresources.rsg> |
28 |
29 |
29 // AVKON and drawing header files |
30 // AVKON and drawing header files |
30 #include <gdi.h> |
31 #include <gdi.h> |
31 #include <aknlists.h> |
32 #include <aknlists.h> |
181 iContactManager = CVPbkContactManager::NewL( *iContactStoreUriArray ); |
182 iContactManager = CVPbkContactManager::NewL( *iContactStoreUriArray ); |
182 |
183 |
183 // Set contact store observer to listen to contact store events. |
184 // Set contact store observer to listen to contact store events. |
184 iContactManager->ContactStoresL().OpenAllL( *this ); |
185 iContactManager->ContactStoresL().OpenAllL( *this ); |
185 |
186 |
|
187 iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager); |
|
188 iContactDataManager->ConstructL(); |
|
189 iContactDataManager->SetObserver(this); |
|
190 |
186 PERF_MEASURE_START |
191 PERF_MEASURE_START |
187 |
192 |
188 InitPredictiveContactSearchL(); |
193 InitPredictiveContactSearchL(); |
189 |
194 |
190 PERF_MEASURE_STOP |
195 PERF_MEASURE_STOP |
204 // Cast the pointer into contact launcher object. |
209 // Cast the pointer into contact launcher object. |
205 User::LeaveIfNull( any ); |
210 User::LeaveIfNull( any ); |
206 iContactLauncher = static_cast<MCCAConnectionExt*>( any ); |
211 iContactLauncher = static_cast<MCCAConnectionExt*>( any ); |
207 |
212 |
208 iCenrepListener = CEasyDialingCenrepListener::NewL(this); |
213 iCenrepListener = CEasyDialingCenrepListener::NewL(this); |
209 |
|
210 iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager); |
|
211 iContactDataManager->ConstructL(); |
|
212 iContactDataManager->SetObserver(this); |
|
213 |
214 |
214 iContactorService = CEDContactorService::NewL( this ); |
215 iContactorService = CEDContactorService::NewL( this ); |
215 |
216 |
216 // EasyDialing resource file is attempted to be read from the same directory where the |
217 // EasyDialing resource file is attempted to be read from the same directory where the |
217 // executed binary is located |
218 // executed binary is located |
386 if ( iCompanyNamePCSIndex != KErrNotFound ) |
387 if ( iCompanyNamePCSIndex != KErrNotFound ) |
387 { |
388 { |
388 contact_fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME); |
389 contact_fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME); |
389 } |
390 } |
390 |
391 |
|
392 SetSortOrderL( iContactDataManager->NameOrder() ); |
|
393 |
391 // Create and fill ps settings object. |
394 // Create and fill ps settings object. |
392 CPsSettings* ps_settings = CPsSettings::NewL(); |
395 CPsSettings* ps_settings = CPsSettings::NewL(); |
393 CleanupStack::PushL(ps_settings); |
396 CleanupStack::PushL(ps_settings); |
394 |
397 |
395 ps_settings->SetSearchUrisL(iContactDataStores); |
398 ps_settings->SetSearchUrisL(iContactDataStores); |
402 |
405 |
403 CleanupStack::PopAndDestroy(ps_settings); |
406 CleanupStack::PopAndDestroy(ps_settings); |
404 CleanupStack::PopAndDestroy(&contact_fields); |
407 CleanupStack::PopAndDestroy(&contact_fields); |
405 |
408 |
406 iPredictiveSearchQuery = CPsQuery::NewL(); |
409 iPredictiveSearchQuery = CPsQuery::NewL(); |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // GetContactFields |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void CEasyDialingPlugin::SetSortOrderL( CEasyDialingContactDataManager::TNameOrder aNameOrder ) |
|
417 { |
|
418 RArray<TInt> fields; |
|
419 CleanupClosePushL( fields ); |
|
420 if ( aNameOrder == CEasyDialingContactDataManager::EFirstnameLastname ) |
|
421 { |
|
422 fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME); |
|
423 fields.Append(R_VPBK_FIELD_TYPE_LASTNAME); |
|
424 } |
|
425 else |
|
426 { |
|
427 fields.Append(R_VPBK_FIELD_TYPE_LASTNAME); |
|
428 fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME); |
|
429 } |
|
430 if ( iCompanyNamePCSIndex != KErrNotFound ) |
|
431 { |
|
432 fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME); |
|
433 } |
|
434 iPredictiveContactSearchHandler->ChangeSortOrderL( *iContactDataStores[0], fields ); |
|
435 CleanupStack::PopAndDestroy(); //fields |
407 } |
436 } |
408 |
437 |
409 // ----------------------------------------------------------------------------- |
438 // ----------------------------------------------------------------------------- |
410 // OfferKeyEventL |
439 // OfferKeyEventL |
411 // Check the received keypad event and performs user |
440 // Check the received keypad event and performs user |
750 { |
779 { |
751 iContactListBox->DrawDeferred(); |
780 iContactListBox->DrawDeferred(); |
752 } |
781 } |
753 |
782 |
754 // ----------------------------------------------------------------------------- |
783 // ----------------------------------------------------------------------------- |
|
784 // NameOrderChanged |
|
785 // From MContactDataManagerObserver |
|
786 // ----------------------------------------------------------------------------- |
|
787 // |
|
788 void CEasyDialingPlugin::NameOrderChanged() |
|
789 { |
|
790 if ( iPredictiveContactSearchHandler ) |
|
791 { |
|
792 TRAP_IGNORE( SetSortOrderL( iContactDataManager->NameOrder() ) ); |
|
793 } |
|
794 } |
|
795 |
|
796 // ----------------------------------------------------------------------------- |
755 // InformContactorEvent |
797 // InformContactorEvent |
756 // From MEDContactorObserver |
798 // From MEDContactorObserver |
757 // ----------------------------------------------------------------------------- |
799 // ----------------------------------------------------------------------------- |
758 // |
800 // |
759 void CEasyDialingPlugin::InformContactorEvent( MEDContactorObserver::TEvent aEvent ) |
801 void CEasyDialingPlugin::InformContactorEvent( MEDContactorObserver::TEvent aEvent ) |
803 { |
845 { |
804 if ( iSearchString.Length() == 0 ) |
846 if ( iSearchString.Length() == 0 ) |
805 { |
847 { |
806 return; |
848 return; |
807 } |
849 } |
808 |
850 |
809 iDiscardCompletingSearches = EFalse; |
851 iDiscardCompletingSearches = EFalse; |
810 iNewSearchNeeded = EFalse; |
852 iNewSearchNeeded = EFalse; |
811 |
853 |
812 iPredictiveSearchQuery->Reset(); |
854 iPredictiveSearchQuery->Reset(); |
813 |
855 |
966 LOGSTRING1("EasyDialingPlugin: Matching results from PCS: %d", numberOfPCSMatches ); |
1008 LOGSTRING1("EasyDialingPlugin: Matching results from PCS: %d", numberOfPCSMatches ); |
967 |
1009 |
968 if ( numberOfPCSMatches > 0 ) |
1010 if ( numberOfPCSMatches > 0 ) |
969 { |
1011 { |
970 // retrieve the name order before adding |
1012 // retrieve the name order before adding |
971 CPbkContactEngine* pbkEngine = CPbkContactEngine::NewL(); |
1013 CEasyDialingContactDataManager::TNameOrder nameOrder = iContactDataManager->NameOrder(); |
972 CleanupStack::PushL( pbkEngine ); |
|
973 CPbkContactEngine::TPbkNameOrder nameOrder = pbkEngine->NameDisplayOrderL(); |
|
974 CleanupStack::PopAndDestroy( pbkEngine ); |
|
975 |
1014 |
976 // map results to old contact match data |
1015 // map results to old contact match data |
977 for( TInt i = 0; i < numberOfPCSMatches; i++ ) |
1016 for( TInt i = 0; i < numberOfPCSMatches; i++ ) |
978 { |
1017 { |
979 TInt indexFromEnd = numberOfPCSMatches - i - 1; |
1018 TInt indexFromEnd = numberOfPCSMatches - i - 1; |
993 LOGSTRING2("EasyDialingPlugin: Contact #%d: '%S'", i+1, &iContactStringCreationBuffer ); |
1032 LOGSTRING2("EasyDialingPlugin: Contact #%d: '%S'", i+1, &iContactStringCreationBuffer ); |
994 } |
1033 } |
995 |
1034 |
996 TInt numberOfFavs( iContactDataManager->NumberOfFavsL() ); |
1035 TInt numberOfFavs( iContactDataManager->NumberOfFavsL() ); |
997 TBuf<KBufferMaxLen> results; |
1036 TBuf<KBufferMaxLen> results; |
998 for ( TInt i = 0; i < numberOfFavs; i++ ) |
1037 for ( TInt i = numberOfFavs - 1; i >= 0; i-- ) |
999 { |
1038 { |
1000 // check if this fav matches the search |
1039 // check if this fav matches the search |
1001 HBufC* favContactString = iContactDataManager->FavContactStringLC( i, nameOrder ); |
1040 HBufC* favContactString = iContactDataManager->FavContactStringLC( i, nameOrder ); |
1002 results = KNullDesC; |
1041 results = KNullDesC; |
1003 iPredictiveContactSearchHandler->LookupMatchL( |
1042 iPredictiveContactSearchHandler->LookupMatchL( |
1167 // ----------------------------------------------------------------------------- |
1206 // ----------------------------------------------------------------------------- |
1168 // CreateContactStringLC |
1207 // CreateContactStringLC |
1169 // |
1208 // |
1170 // ----------------------------------------------------------------------------- |
1209 // ----------------------------------------------------------------------------- |
1171 // |
1210 // |
1172 HBufC* CEasyDialingPlugin::CreateContactStringLC( CPsClientData* aResult, CPbkContactEngine::TPbkNameOrder aNameOrder ) |
1211 HBufC* CEasyDialingPlugin::CreateContactStringLC( CPsClientData* aResult, |
|
1212 CEasyDialingContactDataManager::TNameOrder aNameOrder ) |
1173 { |
1213 { |
1174 TPtr firstName = aResult->Data( iFirstNamePCSIndex )->Des(); |
1214 TPtr firstName = aResult->Data( iFirstNamePCSIndex )->Des(); |
1175 TPtr lastName = aResult->Data( iLastNamePCSIndex )->Des(); |
1215 TPtr lastName = aResult->Data( iLastNamePCSIndex )->Des(); |
1176 TPtr companyName( NULL, 0 ); |
1216 TPtr companyName( NULL, 0 ); |
1177 |
1217 |
1439 |
1479 |
1440 case EEasyDialingClosePopup: |
1480 case EEasyDialingClosePopup: |
1441 |
1481 |
1442 // Not only Number Entry is removed but also closes down number selection popup in case it happens to be open. |
1482 // Not only Number Entry is removed but also closes down number selection popup in case it happens to be open. |
1443 iContactorService->CancelService(); |
1483 iContactorService->CancelService(); |
1444 ret = ETrue; |
1484 ret = ETrue; |
1445 break; |
1485 break; |
1446 |
1486 |
1447 default: |
1487 default: |
1448 break; |
1488 break; |
1449 } |
1489 } |
1605 CleanupStack::PopAndDestroy( contact8 ); |
1645 CleanupStack::PopAndDestroy( contact8 ); |
1606 __ASSERT_DEBUG( EFalse, EasyDialingPanic( EEasyDialingActionNotSupported ) ); |
1646 __ASSERT_DEBUG( EFalse, EasyDialingPanic( EEasyDialingActionNotSupported ) ); |
1607 return; |
1647 return; |
1608 } |
1648 } |
1609 |
1649 |
1610 CEDContactorService::TCSParameter param( selector, *contact8, 0, *fullName ); |
1650 CEDContactorService::TCSParameter param( selector, *contact8, |
|
1651 CEDContactorService::TCSParameter::EEnableDefaults, |
|
1652 *fullName ); |
1611 |
1653 |
1612 iContactorService->ExecuteServiceL( param ); |
1654 iContactorService->ExecuteServiceL( param ); |
1613 |
1655 |
1614 CleanupStack::PopAndDestroy( fullName ); |
1656 CleanupStack::PopAndDestroy( fullName ); |
1615 CleanupStack::PopAndDestroy( contact8 ); |
1657 CleanupStack::PopAndDestroy( contact8 ); |