274 |
274 |
275 /** |
275 /** |
276 * Background Task Handler. |
276 * Background Task Handler. |
277 */ |
277 */ |
278 NONSHARABLE_CLASS(CPbk2NamesListControlBgTask) : public CActive |
278 NONSHARABLE_CLASS(CPbk2NamesListControlBgTask) : public CActive |
279 { |
279 { |
280 |
280 |
281 public: |
281 public: |
282 CPbk2NamesListControlBgTask( CPbk2NamesListControl& aControl ); |
282 CPbk2NamesListControlBgTask( CPbk2NamesListControl& aControl ); |
283 ~CPbk2NamesListControlBgTask(); |
283 ~CPbk2NamesListControlBgTask(); |
284 |
284 |
285 void AddEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ); |
285 void AddEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ); |
286 void ClearAllEvents(); |
286 void ClearAllEvents(); |
287 void RemoveEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ); |
287 void RemoveEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ); |
288 |
288 |
289 private: // From CActive |
289 private: // From CActive |
290 void DoCancel(); |
290 void DoCancel(); |
291 void RunL(); |
291 void RunL(); |
292 TInt RunError(TInt aError); |
292 TInt RunError(TInt aError); |
293 |
293 |
294 private: |
294 private: |
295 //Owns |
295 //Owns |
296 RArray <CPbk2NamesListControl::TPbk2NamesListBgEvents> iEventQueue; |
296 RArray <CPbk2NamesListControl::TPbk2NamesListBgEvents> iEventQueue; |
297 |
297 |
298 //doesnt Own |
298 //doesnt Own |
299 CPbk2NamesListControl& iControl; |
299 CPbk2NamesListControl& iControl; |
300 }; |
300 }; |
301 |
301 |
302 /** |
302 /** |
314 /** |
314 /** |
315 * Destructor. |
315 * Destructor. |
316 */ |
316 */ |
317 ~CPbk2HandleMassUpdate(); |
317 ~CPbk2HandleMassUpdate(); |
318 |
318 |
319 public: |
319 public: |
320 /** |
320 /** |
321 * Call this function after each update event. |
321 * Call this function after each update event. |
322 * @return ETrue if this event is part of a mass update. |
322 * @return ETrue if this event is part of a mass update. |
323 */ |
323 */ |
324 TBool MassUpdateCheckThis(); |
324 TBool MassUpdateCheckThis(); |
325 |
325 |
326 /** |
326 /** |
327 * Call this function to check if mass update process is ongoing. |
327 * Call this function to check if mass update process is ongoing. |
328 * @return ETrue if mass update process is ongoing. |
328 * @return ETrue if mass update process is ongoing. |
329 */ |
329 */ |
330 TBool MassUpdateDetected(); |
330 TBool MassUpdateDetected(); |
331 |
331 |
332 private: |
332 private: |
333 CPbk2HandleMassUpdate(CEikListBox& iListBox); |
333 CPbk2HandleMassUpdate(CEikListBox& iListBox); |
334 void ConstructL(); |
334 void ConstructL(); |
335 TBool HandleMassUpdateCheckL(); |
335 TBool HandleMassUpdateCheckL(); |
336 void HandleMassUpdateCheckReset(); |
336 void HandleMassUpdateCheckReset(); |
337 void HandleMassUpdateDone(); |
337 void HandleMassUpdateDone(); |
338 static TInt HandleMassUpdateTimerCallBack(TAny* aAny); |
338 static TInt HandleMassUpdateTimerCallBack(TAny* aAny); |
339 |
339 |
340 private: |
340 private: |
341 CEikListBox& iListBox; |
341 CEikListBox& iListBox; |
342 TBool iHandleMassUpdate; |
342 TBool iHandleMassUpdate; |
343 TTime iHandleMassUpdateFirst; |
343 TTime iHandleMassUpdateFirst; |
344 TTime iHandleMassUpdatePrev; |
344 TTime iHandleMassUpdatePrev; |
345 TInt iHandleMassUpdateCount; |
345 TInt iHandleMassUpdateCount; |
346 CPeriodic* iHandleMassUpdateTimer; |
346 CPeriodic* iHandleMassUpdateTimer; |
347 CAknWaitDialog* iHandleMassUpdateDialog; |
347 CAknWaitDialog* iHandleMassUpdateDialog; |
348 }; |
348 }; |
349 |
349 |
350 // -------------------------------------------------------------------------- |
350 // -------------------------------------------------------------------------- |
351 // CPbk2UiControlEventSender::CPbk2UiControlEventSender |
351 // CPbk2UiControlEventSender::CPbk2UiControlEventSender |
352 // -------------------------------------------------------------------------- |
352 // -------------------------------------------------------------------------- |
641 // -------------------------------------------------------------------------- |
641 // -------------------------------------------------------------------------- |
642 // |
642 // |
643 CPbk2HandleMassUpdate::~CPbk2HandleMassUpdate() |
643 CPbk2HandleMassUpdate::~CPbk2HandleMassUpdate() |
644 { |
644 { |
645 delete iHandleMassUpdateDialog; |
645 delete iHandleMassUpdateDialog; |
646 delete iHandleMassUpdateTimer; |
646 delete iHandleMassUpdateTimer; |
647 } |
647 } |
648 |
648 |
649 // -------------------------------------------------------------------------- |
649 // -------------------------------------------------------------------------- |
650 // CPbk2HandleMassUpdate::CPbk2HandleMassUpdate |
650 // CPbk2HandleMassUpdate::CPbk2HandleMassUpdate |
651 // -------------------------------------------------------------------------- |
651 // -------------------------------------------------------------------------- |
652 // |
652 // |
653 CPbk2HandleMassUpdate::CPbk2HandleMassUpdate(CEikListBox& aListBox) : |
653 CPbk2HandleMassUpdate::CPbk2HandleMassUpdate(CEikListBox& aListBox) : |
654 iListBox(aListBox) |
654 iListBox(aListBox) |
655 { |
655 { |
656 } |
656 } |
657 |
657 |
658 // -------------------------------------------------------------------------- |
658 // -------------------------------------------------------------------------- |
659 // CPbk2HandleMassUpdate::ConstructL |
659 // CPbk2HandleMassUpdate::ConstructL |
660 // -------------------------------------------------------------------------- |
660 // -------------------------------------------------------------------------- |
661 // |
661 // |
662 void CPbk2HandleMassUpdate::ConstructL() |
662 void CPbk2HandleMassUpdate::ConstructL() |
663 { |
663 { |
664 iHandleMassUpdateTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
664 iHandleMassUpdateTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
665 } |
665 } |
666 |
666 |
667 // -------------------------------------------------------------------------- |
667 // -------------------------------------------------------------------------- |
668 // CPbk2HandleMassUpdate::HandleMassUpdateCheckThis |
668 // CPbk2HandleMassUpdate::HandleMassUpdateCheckThis |
669 // |
669 // |
670 // Functionality to detect mass updates done to contact database and to prevent |
670 // Functionality to detect mass updates done to contact database and to prevent |
673 // -------------------------------------------------------------------------- |
673 // -------------------------------------------------------------------------- |
674 // |
674 // |
675 TBool CPbk2HandleMassUpdate::MassUpdateCheckThis() |
675 TBool CPbk2HandleMassUpdate::MassUpdateCheckThis() |
676 { |
676 { |
677 TBool ret(EFalse); |
677 TBool ret(EFalse); |
678 const TInt KNbrUpdBeforeMassCheck(5); |
678 const TInt KNbrUpdBeforeMassCheck(5); |
679 iHandleMassUpdateTimer->Cancel(); |
679 iHandleMassUpdateTimer->Cancel(); |
680 |
680 |
681 if( iHandleMassUpdateCount > KNbrUpdBeforeMassCheck ) |
681 if( iHandleMassUpdateCount > KNbrUpdBeforeMassCheck ) |
682 { |
682 { |
683 //candidates to be checked are they continual of a mass update |
683 //candidates to be checked are they continual of a mass update |
684 TRAP_IGNORE(ret = HandleMassUpdateCheckL()); |
684 TRAP_IGNORE(ret = HandleMassUpdateCheckL()); |
685 } |
685 } |
686 else if( iHandleMassUpdateCount > 0 ) |
686 else if( iHandleMassUpdateCount > 0 ) |
687 { |
687 { |
688 //Subsequent updates that are handled normally even if |
688 //Subsequent updates that are handled normally even if |
689 // they would be first ones in a mass update burst |
689 // they would be first ones in a mass update burst |
690 iHandleMassUpdateCount++; |
690 iHandleMassUpdateCount++; |
691 iHandleMassUpdatePrev.UniversalTime(); |
691 iHandleMassUpdatePrev.UniversalTime(); |
692 } |
692 } |
693 else |
693 else |
694 { |
694 { |
695 //very first update, set time & counter |
695 //very first update, set time & counter |
696 HandleMassUpdateCheckReset(); |
696 HandleMassUpdateCheckReset(); |
697 } |
697 } |
698 return ret; |
698 return ret; |
699 } |
699 } |
700 |
700 |
701 // -------------------------------------------------------------------------- |
701 // -------------------------------------------------------------------------- |
702 // CPbk2HandleMassUpdate::MassUpdateDetected |
702 // CPbk2HandleMassUpdate::MassUpdateDetected |
703 // -------------------------------------------------------------------------- |
703 // -------------------------------------------------------------------------- |
704 // |
704 // |
705 TBool CPbk2HandleMassUpdate::MassUpdateDetected() |
705 TBool CPbk2HandleMassUpdate::MassUpdateDetected() |
712 // -------------------------------------------------------------------------- |
712 // -------------------------------------------------------------------------- |
713 // |
713 // |
714 TBool CPbk2HandleMassUpdate::HandleMassUpdateCheckL() |
714 TBool CPbk2HandleMassUpdate::HandleMassUpdateCheckL() |
715 { |
715 { |
716 //KDeltaAverage time per update to be considered as mass |
716 //KDeltaAverage time per update to be considered as mass |
717 //update. One occasional update can take KDeltaMax time as long as |
717 //update. One occasional update can take KDeltaMax time as long as |
718 //average time not exeeded (therefore timeout for the very first updates in |
718 //average time not exeeded (therefore timeout for the very first updates in |
719 //practice is also KDeltaAverage). |
719 //practice is also KDeltaAverage). |
720 const TInt64 KDeltaAverage(2000000); |
720 const TInt64 KDeltaAverage(2000000); |
721 const TInt64 KDeltaMax(KDeltaAverage * 2); |
721 const TInt64 KDeltaMax(KDeltaAverage * 2); |
722 const TTimeIntervalMicroSeconds KMaxPrev(KDeltaMax); |
722 const TTimeIntervalMicroSeconds KMaxPrev(KDeltaMax); |
723 TBool ret(EFalse); |
723 TBool ret(EFalse); |
724 |
724 |
725 TTime now; |
725 TTime now; |
726 now.UniversalTime(); |
726 now.UniversalTime(); |
727 TTimeIntervalMicroSeconds fs = now.MicroSecondsFrom(iHandleMassUpdateFirst); |
727 TTimeIntervalMicroSeconds fs = now.MicroSecondsFrom(iHandleMassUpdateFirst); |
728 TTimeIntervalMicroSeconds ps = now.MicroSecondsFrom(iHandleMassUpdatePrev); |
728 TTimeIntervalMicroSeconds ps = now.MicroSecondsFrom(iHandleMassUpdatePrev); |
729 TTimeIntervalMicroSeconds maxCumu(KDeltaAverage * iHandleMassUpdateCount); |
729 TTimeIntervalMicroSeconds maxCumu(KDeltaAverage * iHandleMassUpdateCount); |
730 |
730 |
731 if( fs < maxCumu && ps < KMaxPrev ) |
731 if( fs < maxCumu && ps < KMaxPrev ) |
732 { |
732 { |
733 //mass update burst ongoing |
733 //mass update burst ongoing |
734 iHandleMassUpdate=ETrue; |
734 iHandleMassUpdate=ETrue; |
735 iHandleMassUpdateCount++; |
735 iHandleMassUpdateCount++; |
736 iHandleMassUpdatePrev.UniversalTime(); |
736 iHandleMassUpdatePrev.UniversalTime(); |
737 iListBox.UpdateScrollBarsL(); |
737 iListBox.UpdateScrollBarsL(); |
738 |
738 |
739 if( !iHandleMassUpdateDialog ) |
739 if( !iHandleMassUpdateDialog ) |
740 { |
740 { |
741 iHandleMassUpdateDialog = new(ELeave) CAknWaitDialog |
741 iHandleMassUpdateDialog = new(ELeave) CAknWaitDialog |
742 (reinterpret_cast<CEikDialog**>(&iHandleMassUpdateDialog), EFalse); |
742 (reinterpret_cast<CEikDialog**>(&iHandleMassUpdateDialog), EFalse); |
743 iHandleMassUpdateDialog->SetTone(CAknNoteDialog::ENoTone); |
743 iHandleMassUpdateDialog->SetTone(CAknNoteDialog::ENoTone); |
744 iHandleMassUpdateDialog->ExecuteLD(R_QTN_GEN_NOTE_SYNCHRONIZING_PROGRESS); |
744 iHandleMassUpdateDialog->ExecuteLD(R_QTN_GEN_NOTE_SYNCHRONIZING_PROGRESS); |
745 //ExecuteLD above handles validity of pointer iHandleMassUpdateDialog plus |
745 //ExecuteLD above handles validity of pointer iHandleMassUpdateDialog plus |
746 //cleanupstack |
746 //cleanupstack |
747 } |
747 } |
748 |
748 |
749 TCallBack callback(HandleMassUpdateTimerCallBack, this); |
749 TCallBack callback(HandleMassUpdateTimerCallBack, this); |
750 TTimeIntervalMicroSeconds32 delta32(KDeltaMax); |
750 TTimeIntervalMicroSeconds32 delta32(KDeltaMax); |
751 iHandleMassUpdateTimer->Start( delta32, delta32, callback ); |
751 iHandleMassUpdateTimer->Start( delta32, delta32, callback ); |
752 ret = ETrue; |
752 ret = ETrue; |
753 } |
753 } |
754 else if(iHandleMassUpdate) |
754 else if(iHandleMassUpdate) |
755 { |
755 { |
756 //mass update burst ended |
756 //mass update burst ended |
757 HandleMassUpdateDone(); |
757 HandleMassUpdateDone(); |
758 ret = ETrue; |
758 ret = ETrue; |
759 } |
759 } |
760 else |
760 else |
761 { |
761 { |
762 //just normal update, set time & counter |
762 //just normal update, set time & counter |
763 HandleMassUpdateCheckReset(); |
763 HandleMassUpdateCheckReset(); |
769 // CPbk2HandleMassUpdate::HandleMassUpdateCheckReset |
769 // CPbk2HandleMassUpdate::HandleMassUpdateCheckReset |
770 // ---------------------------------------------------------------------------- |
770 // ---------------------------------------------------------------------------- |
771 // |
771 // |
772 void CPbk2HandleMassUpdate::HandleMassUpdateCheckReset() |
772 void CPbk2HandleMassUpdate::HandleMassUpdateCheckReset() |
773 { |
773 { |
774 iHandleMassUpdate=EFalse; |
774 iHandleMassUpdate=EFalse; |
775 iHandleMassUpdateCount = 1; //set as first candidate for next burst |
775 iHandleMassUpdateCount = 1; //set as first candidate for next burst |
776 iHandleMassUpdateFirst.UniversalTime(); |
776 iHandleMassUpdateFirst.UniversalTime(); |
777 iHandleMassUpdatePrev=iHandleMassUpdateFirst; |
777 iHandleMassUpdatePrev=iHandleMassUpdateFirst; |
778 } |
778 } |
779 |
779 |
780 // ---------------------------------------------------------------------------- |
780 // ---------------------------------------------------------------------------- |
781 // CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack |
781 // CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack |
782 // ---------------------------------------------------------------------------- |
782 // ---------------------------------------------------------------------------- |
783 // |
783 // |
784 TInt CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack(TAny* aAny) |
784 TInt CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack(TAny* aAny) |
785 { |
785 { |
786 CPbk2HandleMassUpdate* self = static_cast<CPbk2HandleMassUpdate*>( aAny ); |
786 CPbk2HandleMassUpdate* self = static_cast<CPbk2HandleMassUpdate*>( aAny ); |
787 self->iHandleMassUpdateTimer->Cancel(); |
787 self->iHandleMassUpdateTimer->Cancel(); |
788 self->HandleMassUpdateDone(); |
788 self->HandleMassUpdateDone(); |
789 return KErrNone; |
789 return KErrNone; |
790 } |
790 } |
791 |
791 |
792 // ---------------------------------------------------------------------------- |
792 // ---------------------------------------------------------------------------- |
793 // CPbk2HandleMassUpdate::HandleMassUpdateDone |
793 // CPbk2HandleMassUpdate::HandleMassUpdateDone |
794 // ---------------------------------------------------------------------------- |
794 // ---------------------------------------------------------------------------- |
795 // |
795 // |
796 void CPbk2HandleMassUpdate::HandleMassUpdateDone() |
796 void CPbk2HandleMassUpdate::HandleMassUpdateDone() |
797 { |
797 { |
798 if( iHandleMassUpdateDialog ) |
798 if( iHandleMassUpdateDialog ) |
799 { |
799 { |
800 TRAP_IGNORE(iHandleMassUpdateDialog->ProcessFinishedL()); |
800 TRAP_IGNORE(iHandleMassUpdateDialog->ProcessFinishedL()); |
801 //The below 2 lines just in case... ProcessFinishedL already took care of these |
801 //The below 2 lines just in case... ProcessFinishedL already took care of these |
802 delete iHandleMassUpdateDialog; |
802 delete iHandleMassUpdateDialog; |
803 iHandleMassUpdateDialog = NULL; |
803 iHandleMassUpdateDialog = NULL; |
804 } |
804 } |
805 |
805 |
806 HandleMassUpdateCheckReset(); |
806 HandleMassUpdateCheckReset(); |
807 iListBox.SetCurrentItemIndex(0); |
807 iListBox.SetCurrentItemIndex(0); |
808 iListBox.SetTopItemIndex(0); |
808 iListBox.SetTopItemIndex(0); |
809 } |
809 } |
810 |
810 |
811 ///////////////////////// End of helper classes ///////////////////////////// |
811 ///////////////////////// End of helper classes ///////////////////////////// |
812 |
812 |
813 |
813 |
814 // -------------------------------------------------------------------------- |
814 // -------------------------------------------------------------------------- |
815 // CPbk2NamesListControl::CPbk2NamesListControl |
815 // CPbk2NamesListControl::CPbk2NamesListControl |
856 // -------------------------------------------------------------------------- |
856 // -------------------------------------------------------------------------- |
857 // |
857 // |
858 CPbk2NamesListControl::~CPbk2NamesListControl() |
858 CPbk2NamesListControl::~CPbk2NamesListControl() |
859 { |
859 { |
860 ClearMarkedContactsInfo(); |
860 ClearMarkedContactsInfo(); |
861 |
861 |
862 if (iBgTask) |
862 if (iBgTask) |
863 { |
863 { |
864 delete iBgTask; |
864 delete iBgTask; |
865 iBgTask = NULL; |
865 iBgTask = NULL; |
866 } |
866 } |
867 |
867 |
868 if ( iViewStack && iStackObserver ) |
868 if ( iViewStack && iStackObserver ) |
869 { |
869 { |
870 iViewStack->RemoveStackObserver( *iStackObserver ); |
870 iViewStack->RemoveStackObserver( *iStackObserver ); |
871 } |
871 } |
872 |
872 |
873 if( iThumbManager ) |
873 if( iThumbManager ) |
874 { |
874 { |
875 TRAP_IGNORE( iThumbManager->SetContactViewL( NULL ) ); |
875 TRAP_IGNORE( iThumbManager->SetContactViewL( NULL ) ); |
876 iThumbManager->RemoveObserver(); |
876 iThumbManager->RemoveObserver(); |
877 } |
877 } |
878 |
878 |
879 if (iCommand) |
879 if (iCommand) |
880 { |
880 { |
881 // inform the command that the control is deleted |
881 // inform the command that the control is deleted |
882 iCommand->ResetUiControl(*this); |
882 iCommand->ResetUiControl(*this); |
883 } |
883 } |
969 CCoeEnv::Static()->CreateResourceReaderLC(resReader, aResourceId); |
973 CCoeEnv::Static()->CreateResourceReaderLC(resReader, aResourceId); |
970 ConstructFromResourceL(resReader); |
974 ConstructFromResourceL(resReader); |
971 CleanupStack::PopAndDestroy(); // resReader |
975 CleanupStack::PopAndDestroy(); // resReader |
972 FeatureManager::InitializeLibL(); |
976 FeatureManager::InitializeLibL(); |
973 iFeatureManagerInitilized = ETrue; |
977 iFeatureManagerInitilized = ETrue; |
974 iCheckMassUpdate = CPbk2HandleMassUpdate::NewL(*iListBox); //iListbox created in ConstructFromResourceL |
|
975 } |
978 } |
976 |
979 |
977 // -------------------------------------------------------------------------- |
980 // -------------------------------------------------------------------------- |
978 // CPbk2NamesListControl::ConstructFromResourceL |
981 // CPbk2NamesListControl::ConstructFromResourceL |
979 // -------------------------------------------------------------------------- |
982 // -------------------------------------------------------------------------- |
1026 if( !iThumbManager ) |
1029 if( !iThumbManager ) |
1027 { |
1030 { |
1028 iThumbManager = CPbk2ThumbnailManager::NewL( iContactManager ); |
1031 iThumbManager = CPbk2ThumbnailManager::NewL( iContactManager ); |
1029 iOwnThumbManager = ETrue; |
1032 iOwnThumbManager = ETrue; |
1030 } |
1033 } |
1031 |
1034 |
1032 iDoubleListBox = CPbk2ContactViewDoubleListBox::NewL |
1035 iDoubleListBox = CPbk2ContactViewDoubleListBox::NewL |
1033 ( *this, aReader, iContactManager, |
1036 ( *this, aReader, iContactManager, |
1034 *iViewStack, iNameFormatter, iStoreProperties, |
1037 *iViewStack, iNameFormatter, iStoreProperties, |
1035 iUiExtension, *iSearchFilter, *iThumbManager ); |
1038 iUiExtension, *iSearchFilter, *iThumbManager ); |
1036 |
1039 |
1057 iListBox->SetObserver( this ); |
1060 iListBox->SetObserver( this ); |
1058 iListBox->SetScrollEventObserver( this ); |
1061 iListBox->SetScrollEventObserver( this ); |
1059 iListBox->SetListBoxObserver(this); |
1062 iListBox->SetListBoxObserver(this); |
1060 iUiExtension->SetContactUiControlUpdate( this ); |
1063 iUiExtension->SetContactUiControlUpdate( this ); |
1061 // set command item updater |
1064 // set command item updater |
1062 TAny* ext = iUiExtension->ContactUiControlExtensionExtension( |
1065 TAny* ext = iUiExtension->ContactUiControlExtensionExtension( |
1063 TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) ); |
1066 TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) ); |
1064 if( ext ) |
1067 if( ext ) |
1065 { |
1068 { |
1066 static_cast<MPbk2ContactUiControlDoubleListboxExtension*>(ext)-> |
1069 static_cast<MPbk2ContactUiControlDoubleListboxExtension*>(ext)-> |
1067 SetCommandItemUpdater( this ); |
1070 SetCommandItemUpdater( this ); |
1068 } |
1071 } |
1069 |
1072 |
1070 if ( iListBox->Flags() & KPbk2ContactViewListControlFindBox ) |
1073 if ( iListBox->Flags() & KPbk2ContactViewListControlFindBox ) |
1071 { |
1074 { |
1072 // Create a find box |
1075 // Create a find box |
1073 if ( iSearchFilter->IsPredictiveActivated() ) |
1076 if ( iSearchFilter->IsPredictiveActivated() ) |
1074 { |
1077 { |
1161 TRAP_IGNORE( iViewStack->AddObserverL( *this ) ); |
1165 TRAP_IGNORE( iViewStack->AddObserverL( *this ) ); |
1162 |
1166 |
1163 const TInt firstContactIndex = 0; |
1167 const TInt firstContactIndex = 0; |
1164 // Best effort: try to reset the focus. |
1168 // Best effort: try to reset the focus. |
1165 TRAP_IGNORE( iCurrentState->SetFocusedContactIndexL( firstContactIndex ) ); |
1169 TRAP_IGNORE( iCurrentState->SetFocusedContactIndexL( firstContactIndex ) ); |
1166 //scroll listbox into beginning (ignore focus that may be below promotion items) |
1170 //scroll listbox into beginning (ignore focus that may be below promotion items) |
1167 iListBox->SetTopItemIndex(firstContactIndex); |
1171 iListBox->SetTopItemIndex(firstContactIndex); |
1168 |
1172 |
1169 // Switch to the background state. This enables the next state to avtivate fully (ActivateStateL()) once phonebook |
1173 // Switch to the background state. This enables the next state to avtivate fully (ActivateStateL()) once phonebook |
1170 // comes from the background. |
1174 // comes from the background. |
1171 TRAP_IGNORE( iCurrentState = &iStateFactory->ActivateHiddenStateL( iCurrentState ); ); |
1175 TRAP_IGNORE( iCurrentState = &iStateFactory->ActivateHiddenStateL( iCurrentState ); ); |
1172 |
1176 |
1173 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2NamesListControl::Reset() - OUT")); |
1177 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2NamesListControl::Reset() - OUT")); |
2004 HandleError(aError); |
2008 HandleError(aError); |
2005 Reset(); |
2009 Reset(); |
2006 } |
2010 } |
2007 |
2011 |
2008 // -------------------------------------------------------------------------- |
2012 // -------------------------------------------------------------------------- |
|
2013 // CPbk2NamesListControl::ContactViewObserverExtension |
|
2014 // -------------------------------------------------------------------------- |
|
2015 // |
|
2016 TAny* CPbk2NamesListControl::ContactViewObserverExtension( TUid aExtensionUid ) |
|
2017 { |
|
2018 if( aExtensionUid == KVPbkContactViewObserverExtension2Uid ) |
|
2019 { |
|
2020 return static_cast<MVPbkContactViewObserverExtension*>( this ); |
|
2021 } |
|
2022 return NULL; |
|
2023 } |
|
2024 |
|
2025 // -------------------------------------------------------------------------- |
|
2026 // CPbk2NamesListControl::FilteredContactRemovedFromView |
|
2027 // -------------------------------------------------------------------------- |
|
2028 // |
|
2029 void CPbk2NamesListControl::FilteredContactRemovedFromView( |
|
2030 MVPbkContactViewBase& /*aView*/ ) |
|
2031 { |
|
2032 DrawDeferred(); |
|
2033 } |
|
2034 |
|
2035 // -------------------------------------------------------------------------- |
2009 // CPbk2NamesListControl::FocusedItemPointed |
2036 // CPbk2NamesListControl::FocusedItemPointed |
2010 // -------------------------------------------------------------------------- |
2037 // -------------------------------------------------------------------------- |
2011 // |
2038 // |
2012 TBool CPbk2NamesListControl::FocusedItemPointed() |
2039 TBool CPbk2NamesListControl::FocusedItemPointed() |
2013 { |
2040 { |
2156 // CPbk2NamesListControl::DoContactAddedToBaseView |
2183 // CPbk2NamesListControl::DoContactAddedToBaseView |
2157 // -------------------------------------------------------------------------- |
2184 // -------------------------------------------------------------------------- |
2158 // |
2185 // |
2159 void CPbk2NamesListControl::DoHandleContactAdditionL( TInt aIndex ) |
2186 void CPbk2NamesListControl::DoHandleContactAdditionL( TInt aIndex ) |
2160 { |
2187 { |
2161 //Prevent messing with focus with always-on when Phonebook hidden in |
2188 //Prevent messing with focus with always-on when Phonebook hidden in |
2162 //reseted state. Otherwise background-added contacts will change focus. |
2189 //reseted state. Otherwise background-added contacts will change focus. |
2163 //This would cause Phonebook not to look like freshly started when opened again. |
2190 //This would cause Phonebook not to look like freshly started when opened again. |
2164 //And also make sure foreground-added contact will show the new contact |
2191 //And also make sure foreground-added contact will show the new contact |
2165 //even though the focus is not seen. |
2192 //even though the focus is not seen. |
2166 if( (static_cast<CPbk2AppUi*>( |
2193 if( (static_cast<CPbk2AppUi*>( |
2167 CEikonEnv::Static()->AppUi()))->IsForeground() ) |
2194 CEikonEnv::Static()->AppUi()))->IsForeground() ) |
2168 { |
2195 { |
2169 SelectAndChangeReadyStateL(); |
2196 SelectAndChangeReadyStateL(); |
2170 } |
2197 } |
2171 |
2198 |
2172 if( !iCheckMassUpdate->MassUpdateDetected() ) |
2199 if( !iCheckMassUpdate->MassUpdateDetected() ) |
2173 { |
2200 { |
2174 iCurrentState->HandleContactViewEventL |
2201 iCurrentState->HandleContactViewEventL |
2175 ( MPbk2NamesListState::EItemAdded, aIndex ); |
2202 ( MPbk2NamesListState::EItemAdded, aIndex ); |
2444 if ( iSearchFilter ) |
2471 if ( iSearchFilter ) |
2445 { |
2472 { |
2446 iSearchFilter->HandleForegroundEventL( aForeground ); |
2473 iSearchFilter->HandleForegroundEventL( aForeground ); |
2447 } |
2474 } |
2448 } |
2475 } |
2449 |
2476 |
2450 // --------------------------------------------------------------------------- |
2477 // --------------------------------------------------------------------------- |
2451 // CPbk2NamesListControl::StoreMarkedContactsAndResetViewL |
2478 // CPbk2NamesListControl::StoreMarkedContactsAndResetViewL |
2452 // --------------------------------------------------------------------------- |
2479 // --------------------------------------------------------------------------- |
2453 // |
2480 // |
2454 void CPbk2NamesListControl::StoreMarkedContactsAndResetViewL() |
2481 void CPbk2NamesListControl::StoreMarkedContactsAndResetViewL() |
2455 { |
2482 { |
2456 delete iSelectedLinkArray; |
2483 delete iSelectedLinkArray; |
2457 iSelectedLinkArray = NULL; |
2484 iSelectedLinkArray = NULL; |
2458 |
2485 |
2459 iSelectedLinkArray = iCurrentState->SelectedContactsL(); |
2486 iSelectedLinkArray = iCurrentState->SelectedContactsL(); |
2460 } |
2487 } |
2461 |
2488 |
2462 |
2489 |
2463 // --------------------------------------------------------------------------- |
2490 // --------------------------------------------------------------------------- |
2464 // CPbk2NamesListControl::RestoreMarkedContactsL |
2491 // CPbk2NamesListControl::RestoreMarkedContactsL |
2465 // --------------------------------------------------------------------------- |
2492 // --------------------------------------------------------------------------- |
2466 // |
2493 // |
2467 void CPbk2NamesListControl::RestoreMarkedContactsL() |
2494 void CPbk2NamesListControl::RestoreMarkedContactsL() |
2468 { |
2495 { |
2469 //Set the Marked Contacts |
2496 //Set the Marked Contacts |
2470 if ( iSelectedLinkArray ) |
2497 if ( iSelectedLinkArray ) |
2471 { |
2498 { |
2472 for ( TInt index = 0; index<iSelectedLinkArray->Count(); index++ ) |
2499 for ( TInt index = 0; index<iSelectedLinkArray->Count(); index++ ) |
2473 { |
2500 { |
2474 iCurrentState->SetSelectedContactL( iSelectedLinkArray->At(index), ETrue ); |
2501 iCurrentState->SetSelectedContactL( iSelectedLinkArray->At(index), ETrue ); |
2475 } |
2502 } |
2476 } |
2503 } |
2477 |
2504 |
2478 delete iSelectedLinkArray; |
2505 delete iSelectedLinkArray; |
2479 iSelectedLinkArray = NULL; |
2506 iSelectedLinkArray = NULL; |
2480 } |
2507 } |
2481 |
2508 |
2482 // --------------------------------------------------------------------------- |
2509 // --------------------------------------------------------------------------- |
2483 // CPbk2NamesListControl::ClearMarkedContactsInfo |
2510 // CPbk2NamesListControl::ClearMarkedContactsInfo |
2484 // --------------------------------------------------------------------------- |
2511 // --------------------------------------------------------------------------- |
2485 // |
2512 // |
2486 void CPbk2NamesListControl::ClearMarkedContactsInfo() |
2513 void CPbk2NamesListControl::ClearMarkedContactsInfo() |
2487 { |
2514 { |
2488 if ( iBgTask ) |
2515 if ( iBgTask ) |
2489 { |
2516 { |
2490 iBgTask->ClearAllEvents(); |
2517 iBgTask->ClearAllEvents(); |
2491 } |
2518 } |
2492 delete iSelectedLinkArray; |
2519 delete iSelectedLinkArray; |
2541 // --------------------------------------------------------------------------- |
2568 // --------------------------------------------------------------------------- |
2542 // CPbk2NamesListControlBgTask::DoCancel |
2569 // CPbk2NamesListControlBgTask::DoCancel |
2543 // --------------------------------------------------------------------------- |
2570 // --------------------------------------------------------------------------- |
2544 // |
2571 // |
2545 void CPbk2NamesListControlBgTask::DoCancel() |
2572 void CPbk2NamesListControlBgTask::DoCancel() |
2546 { |
2573 { |
2547 } |
2574 } |
2548 |
2575 |
2549 // --------------------------------------------------------------------------- |
2576 // --------------------------------------------------------------------------- |
2550 // CPbk2NamesListControlBgTask::RunL |
2577 // CPbk2NamesListControlBgTask::RunL |
2551 // --------------------------------------------------------------------------- |
2578 // --------------------------------------------------------------------------- |
2552 // |
2579 // |
2553 void CPbk2NamesListControlBgTask::RunL() |
2580 void CPbk2NamesListControlBgTask::RunL() |
2554 { |
2581 { |
2555 |
2582 |
2556 if ( iEventQueue.Count() ) |
2583 if ( iEventQueue.Count() ) |
2557 { |
2584 { |
2558 switch ( iEventQueue[0] ) |
2585 switch ( iEventQueue[0] ) |
2559 { |
2586 { |
2560 case CPbk2NamesListControl::EStateSaveMarkedContacts: |
2587 case CPbk2NamesListControl::EStateSaveMarkedContacts: |
2561 iControl.StoreMarkedContactsAndResetViewL(); |
2588 iControl.StoreMarkedContactsAndResetViewL(); |
2562 iEventQueue.Remove( 0 ); |
2589 iEventQueue.Remove( 0 ); |
2563 break; |
2590 break; |
2564 |
2591 |
2565 case CPbk2NamesListControl::EStateRestoreMarkedContacts: |
2592 case CPbk2NamesListControl::EStateRestoreMarkedContacts: |
2566 iControl.RestoreMarkedContactsL(); |
2593 iControl.RestoreMarkedContactsL(); |
2567 iEventQueue.Remove( 0 ); |
2594 iEventQueue.Remove( 0 ); |
2568 break; |
2595 break; |
2569 |
2596 |
2570 case CPbk2NamesListControl::EStateBgTaskEmpty : |
2597 case CPbk2NamesListControl::EStateBgTaskEmpty : |
2571 default: |
2598 default: |
2572 iControl.ClearMarkedContactsInfo(); |
2599 iControl.ClearMarkedContactsInfo(); |
2573 break; |
2600 break; |
2574 } |
2601 } |
2575 } |
2602 } |
2576 } |
2603 } |