113 User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) ); |
113 User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) ); |
114 CleanupStack::PopAndDestroy( cenrep ); |
114 CleanupStack::PopAndDestroy( cenrep ); |
115 |
115 |
116 iPbkSettings = PbkGlobalSettingFactory::CreatePersistentSettingL(); |
116 iPbkSettings = PbkGlobalSettingFactory::CreatePersistentSettingL(); |
117 iPbkSettings->ConnectL( MPbkGlobalSetting::EGeneralSettingCategory ); |
117 iPbkSettings->ConnectL( MPbkGlobalSetting::EGeneralSettingCategory ); |
118 |
|
119 /* |
|
120 * Phonebook name ordering flag, integer value, possible values: |
|
121 * 0: name order Lastname Firstname |
|
122 * 1: name order Firstname Lastname |
|
123 * 2: name order undefined |
|
124 */ |
|
125 TInt nameOrderSetting; |
|
126 iPbkSettings->Get( MPbkGlobalSetting::ENameOrdering, nameOrderSetting ); |
|
127 iNameOrder = ( nameOrderSetting == 0 ? ELastnameFirstname : EFirstnameLastname ); |
|
128 iPbkSettings->RegisterObserverL( this ); |
118 iPbkSettings->RegisterObserverL( this ); |
|
119 |
|
120 // Get name order from Phonebook settings |
|
121 UpdateNameOrderL(); |
129 } |
122 } |
130 |
123 |
131 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
132 // CEasyDialingContactDataManager::SetObserver |
125 // CEasyDialingContactDataManager::SetObserver |
133 // --------------------------------------------------------------------------- |
126 // --------------------------------------------------------------------------- |
260 // CEasyDialingContactDataManager::FavLinkLC |
253 // CEasyDialingContactDataManager::FavLinkLC |
261 // --------------------------------------------------------------------------- |
254 // --------------------------------------------------------------------------- |
262 // |
255 // |
263 MVPbkContactLink* CEasyDialingContactDataManager::FavLinkLC( TInt aIndex ) |
256 MVPbkContactLink* CEasyDialingContactDataManager::FavLinkLC( TInt aIndex ) |
264 { |
257 { |
265 if ( !iFavsView ) |
258 if ( !iFavsView || !iFavsViewReady ) |
266 { |
259 { |
267 // LC function should not return normally unless it has actually |
260 // LC function should not return normally unless it has actually |
268 // put something to cleanup stack |
261 // put something to cleanup stack |
269 User::Leave( KErrNotFound ); |
262 User::Leave( KErrNotFound ); |
270 } |
263 } |
448 // |
441 // |
449 void CEasyDialingContactDataManager::SettingChangedL( MPbkGlobalSetting::TPbkGlobalSetting aKey ) |
442 void CEasyDialingContactDataManager::SettingChangedL( MPbkGlobalSetting::TPbkGlobalSetting aKey ) |
450 { |
443 { |
451 if ( aKey == MPbkGlobalSetting::ENameOrdering ) |
444 if ( aKey == MPbkGlobalSetting::ENameOrdering ) |
452 { |
445 { |
453 TInt nameOrderSetting; |
446 UpdateNameOrderL(); |
454 iPbkSettings->Get( MPbkGlobalSetting::ENameOrdering, nameOrderSetting ); |
|
455 iNameOrder = ( nameOrderSetting == 0 ? ELastnameFirstname : EFirstnameLastname ); |
|
456 if ( iObserver ) |
447 if ( iObserver ) |
457 { |
448 { |
458 iObserver->NameOrderChanged(); |
449 iObserver->NameOrderChanged(); |
|
450 } |
|
451 } |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------------------------- |
|
455 // CEasyDialingContactDataManager::UpdateNameOrderL |
|
456 // Update name order according to Phonebook setting |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 void CEasyDialingContactDataManager::UpdateNameOrderL() |
|
460 { |
|
461 /* |
|
462 * Phonebook name ordering flag, integer value, possible values: |
|
463 * 0: name order Lastname Firstname |
|
464 * 1: name order Firstname Lastname |
|
465 * 2: name order undefined |
|
466 */ |
|
467 TInt nameOrderSetting; |
|
468 iPbkSettings->Get( MPbkGlobalSetting::ENameOrdering, nameOrderSetting ); |
|
469 |
|
470 switch ( nameOrderSetting ) |
|
471 { |
|
472 case 0: |
|
473 { |
|
474 iNameOrder = ELastnameFirstname; |
|
475 break; |
|
476 } |
|
477 case 1: |
|
478 { |
|
479 iNameOrder = EFirstnameLastname; |
|
480 break; |
|
481 } |
|
482 case 2: |
|
483 default: |
|
484 { |
|
485 // Decide name order based on UI language: lastname-firstname |
|
486 // for Chinese, firstname-lastname for the rest of languages. |
|
487 TLanguage uiLang = User::Language(); |
|
488 if ( uiLang == ELangPrcChinese || |
|
489 uiLang == ELangHongKongChinese || |
|
490 uiLang == ELangTaiwanChinese ) |
|
491 { |
|
492 iNameOrder = ELastnameFirstname; |
|
493 } |
|
494 else |
|
495 { |
|
496 iNameOrder = EFirstnameLastname; |
|
497 } |
459 } |
498 } |
460 } |
499 } |
461 } |
500 } |
462 |
501 |
463 // --------------------------------------------------------------------------- |
502 // --------------------------------------------------------------------------- |
592 iWaitingContacts.Reset(); |
631 iWaitingContacts.Reset(); |
593 delete iImageOperation; |
632 delete iImageOperation; |
594 iImageOperation = NULL; |
633 iImageOperation = NULL; |
595 delete iContactOperation; |
634 delete iContactOperation; |
596 iContactOperation = NULL; |
635 iContactOperation = NULL; |
597 if (iObserver) |
636 |
|
637 // Also mark all contact data as loaded. Otherwise it would just be |
|
638 // loaded again, which would cause infinite loop if there is a permanent |
|
639 // problem. |
|
640 for ( TInt i = 0; i < iContactDataArray.Count(); i++ ) |
|
641 { |
|
642 iContactDataArray[i]->LoadingComplete(); |
|
643 } |
|
644 |
|
645 if ( iObserver ) |
598 { |
646 { |
599 iObserver->AllContactDataLoaded(); |
647 iObserver->AllContactDataLoaded(); |
600 } |
648 } |
601 } |
649 } |
602 |
650 |
680 { |
729 { |
681 delete iFavsOperation; |
730 delete iFavsOperation; |
682 iFavsOperation = NULL; |
731 iFavsOperation = NULL; |
683 delete iFavsView; |
732 delete iFavsView; |
684 iFavsView = aOperationResult; |
733 iFavsView = aOperationResult; |
|
734 iFavsViewReady = ETrue; |
|
735 |
|
736 // Leave can be safely ignored. Notifications of favourites view changes |
|
737 // will not work, but otherwise Easydialing will work correctly. |
|
738 TRAP_IGNORE( iFavsView->AddObserverL( *this ) ); |
685 |
739 |
686 InitReady(); |
740 InitReady(); |
|
741 } |
|
742 |
|
743 // --------------------------------------------------------------------------- |
|
744 // CEasyDialingContactDataManager::ContactViewReady |
|
745 // From MVPbkContactViewObserver. |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CEasyDialingContactDataManager::ContactViewReady( |
|
749 MVPbkContactViewBase& aView ) |
|
750 { |
|
751 LOGSTRING("CEasyDialingContactDataManager: ContactViewReady"); |
|
752 |
|
753 if ( iFavsView == &aView ) |
|
754 { |
|
755 iFavsViewReady = ETrue; |
|
756 } |
|
757 } |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // CEasyDialingContactDataManager::ContactViewUnavailable |
|
761 // From MVPbkContactViewObserver. |
|
762 // --------------------------------------------------------------------------- |
|
763 // |
|
764 void CEasyDialingContactDataManager::ContactViewUnavailable( |
|
765 MVPbkContactViewBase& aView ) |
|
766 { |
|
767 LOGSTRING("CEasyDialingContactDataManager: ContactViewUnavailable"); |
|
768 |
|
769 if ( iFavsView == &aView ) |
|
770 { |
|
771 iFavsViewReady = EFalse; |
|
772 } |
|
773 } |
|
774 |
|
775 // --------------------------------------------------------------------------- |
|
776 // CEasyDialingContactDataManager::ContactAddedToView |
|
777 // From MVPbkContactViewObserver. |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 void CEasyDialingContactDataManager::ContactAddedToView( |
|
781 MVPbkContactViewBase& aView, |
|
782 TInt /*aIndex*/, |
|
783 const MVPbkContactLink& /*aContactLink*/ ) |
|
784 { |
|
785 LOGSTRING("CEasyDialingContactDataManager: ContactAddedToView"); |
|
786 |
|
787 if ( iFavsView == &aView ) |
|
788 { |
|
789 iObserver->FavouritesChanged(); |
|
790 } |
|
791 } |
|
792 |
|
793 // --------------------------------------------------------------------------- |
|
794 // CEasyDialingContactDataManager::ContactRemovedFromView |
|
795 // From MVPbkContactViewObserver. |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 void CEasyDialingContactDataManager::ContactRemovedFromView( |
|
799 MVPbkContactViewBase& aView, |
|
800 TInt /*aIndex*/, |
|
801 const MVPbkContactLink& /*aContactLink*/ ) |
|
802 { |
|
803 LOGSTRING("CEasyDialingContactDataManager: ContactRemovedFromView"); |
|
804 |
|
805 if ( iFavsView == &aView ) |
|
806 { |
|
807 iObserver->FavouritesChanged(); |
|
808 } |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // CEasyDialingContactDataManager::ContactViewError |
|
813 // From MVPbkContactViewObserver. |
|
814 // --------------------------------------------------------------------------- |
|
815 // |
|
816 void CEasyDialingContactDataManager::ContactViewError( |
|
817 MVPbkContactViewBase& aView, |
|
818 TInt /*aError*/, |
|
819 TBool /*aErrorNotified*/ ) |
|
820 { |
|
821 LOGSTRING("CEasyDialingContactDataManager: ContactViewError"); |
|
822 |
|
823 if ( iFavsView == &aView ) |
|
824 { |
|
825 iFavsViewReady = EFalse; |
|
826 } |
687 } |
827 } |
688 |
828 |
689 // --------------------------------------------------------------------------- |
829 // --------------------------------------------------------------------------- |
690 // CEasyDialingContactDataManager::DoHandleContactOperationCompleteL |
830 // CEasyDialingContactDataManager::DoHandleContactOperationCompleteL |
691 // --------------------------------------------------------------------------- |
831 // --------------------------------------------------------------------------- |
729 InformObserver(); |
869 InformObserver(); |
730 } |
870 } |
731 } |
871 } |
732 else |
872 else |
733 { |
873 { |
734 // Protective coding. If aContact is NULL, act like opening the contact link failed. |
874 // Opening contact failed. Mark contact data loaded, so it's not opened again. |
735 CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
875 CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
736 tn->LoadingComplete(); |
876 tn->LoadingComplete(); |
737 LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
877 LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
738 iWaitingContacts.Remove(0); |
878 iWaitingContacts.Remove(0); |
739 LoadNextContactDataL(); |
879 LoadNextContactDataL(); |
798 // CEasyDialingContactDataManager::VPbkSingleContactOperationFailed |
938 // CEasyDialingContactDataManager::VPbkSingleContactOperationFailed |
799 // --------------------------------------------------------------------------- |
939 // --------------------------------------------------------------------------- |
800 // |
940 // |
801 void CEasyDialingContactDataManager::VPbkSingleContactOperationFailed( |
941 void CEasyDialingContactDataManager::VPbkSingleContactOperationFailed( |
802 MVPbkContactOperationBase& /*aOperation*/, |
942 MVPbkContactOperationBase& /*aOperation*/, |
803 TInt aError ) |
943 TInt /*aError*/ ) |
804 { |
944 { |
805 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed"); |
945 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed"); |
806 delete iContactOperation; |
946 delete iContactOperation; |
807 iContactOperation = NULL; |
947 iContactOperation = NULL; |
808 HandleError(aError); |
948 TInt index = iWaitingContacts[0]; |
|
949 LOGSTRING1("VPbkSingleContactOperationFailed, Index=%d", index); |
|
950 TRAPD(err, DoHandleContactOperationCompleteL(NULL, index)); |
|
951 if (err) |
|
952 { |
|
953 HandleError(err); |
|
954 } |
809 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed Exit"); |
955 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed Exit"); |
810 } |
956 } |
811 |
957 |
812 // --------------------------------------------------------------------------- |
958 // --------------------------------------------------------------------------- |
813 // CEasyDialingContactDataManager::InformObserver |
959 // CEasyDialingContactDataManager::InformObserver |
834 // CEasyDialingContactDataManager::GetContactThumbnailSetting |
980 // CEasyDialingContactDataManager::GetContactThumbnailSetting |
835 // --------------------------------------------------------------------------- |
981 // --------------------------------------------------------------------------- |
836 // |
982 // |
837 TBool CEasyDialingContactDataManager::GetContactThumbnailSetting( ) |
983 TBool CEasyDialingContactDataManager::GetContactThumbnailSetting( ) |
838 { |
984 { |
839 return iContactThumbnailSetting; |
985 return iContactThumbnailSetting; |
840 } |
986 } |
841 |
987 |
842 // --------------------------------------------------------------------------- |
988 // --------------------------------------------------------------------------- |
843 // CEasyDialingContactDataManager::Reload |
989 // CEasyDialingContactDataManager::Reload |
844 // --------------------------------------------------------------------------- |
990 // --------------------------------------------------------------------------- |
845 // |
991 // |
846 void CEasyDialingContactDataManager::Reload( ) |
992 void CEasyDialingContactDataManager::Reload( ) |
847 { |
993 { |
848 LOGSTRING("CEasyDialingContactDataManager: Reload"); |
994 LOGSTRING("CEasyDialingContactDataManager: Reload"); |
|
995 |
849 for ( TInt i = 0 ; i < iContactDataArray.Count() ; i++ ) |
996 for ( TInt i = 0 ; i < iContactDataArray.Count() ; i++ ) |
850 { |
997 { |
851 iContactDataArray[ i ]->DeleteThumbnail(); |
998 iContactDataArray[ i ]->DeleteThumbnail(); |
852 } |
999 } |
853 } |
1000 } |
854 |
1001 |
855 // TODO: open item: sorting of favourites |
|
856 |
1002 |
857 // End of File |
1003 // End of File |
858 |
1004 |