94 |
94 |
95 // CONST VALUES |
95 // CONST VALUES |
96 const TInt KControlBarTransitionTime = 250; |
96 const TInt KControlBarTransitionTime = 250; |
97 const TInt KMaxPreviewPaneLength = 60; |
97 const TInt KMaxPreviewPaneLength = 60; |
98 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
98 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
|
99 const TInt KNewMailTimerDelay = 20; // sleeping timer to start processing new messages |
|
100 const TInt KNewMailMaxBatch = 7; // number of new mails inserted into list at once |
99 static const TInt KMsgDeletionWaitNoteAmount = 5; |
101 static const TInt KMsgDeletionWaitNoteAmount = 5; |
100 _LIT( KMissingPreviewDataMarker, "..." ); |
102 _LIT( KMissingPreviewDataMarker, "..." ); |
101 |
103 |
102 static const TInt KMaxItemsFethed = 1000; |
104 static const TInt KMaxItemsFethed = 1000; |
103 static const TInt KCMsgBlock = 15; |
105 static const TInt KCMsgBlock = 15; |
104 static const TInt KCMsgMaxBlock = 120; |
106 static const TInt KCMsgBlockSort = 50; |
105 |
107 |
106 // --------------------------------------------------------------------------- |
108 // --------------------------------------------------------------------------- |
107 // Generic method for deleting a pointer and setting it NULL. |
109 // Generic method for deleting a pointer and setting it NULL. |
108 // --------------------------------------------------------------------------- |
110 // --------------------------------------------------------------------------- |
109 // |
111 // |
184 // |
186 // |
185 template <class T> void TDeleteTask<T>::Reset() |
187 template <class T> void TDeleteTask<T>::Reset() |
186 { |
188 { |
187 iEntries.Reset(); |
189 iEntries.Reset(); |
188 } |
190 } |
|
191 |
|
192 |
189 // CMailListModelUpdater |
193 // CMailListModelUpdater |
190 |
194 |
191 // --------------------------------------------------------------------------- |
195 |
192 // Constructor |
196 // --------------------------------------------------------------------------- |
|
197 // CMailListModelUpdater::NewL |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 CMailListModelUpdater* CMailListModelUpdater::NewL() |
|
201 { |
|
202 CMailListModelUpdater* self = new (ELeave) CMailListModelUpdater(); |
|
203 CleanupStack::PushL( self ); |
|
204 self->ConstructL(); |
|
205 CleanupStack::Pop( self ); |
|
206 |
|
207 return self; |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // CMailListModelUpdater::ConstructL |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CMailListModelUpdater::ConstructL() |
|
215 { |
|
216 User::LeaveIfError( iTimer.CreateLocal() ); |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CMailListModelUpdater::CMailListModelUpdater |
193 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
194 // |
222 // |
195 CMailListModelUpdater::CMailListModelUpdater() : CActive(EPriorityStandard) |
223 CMailListModelUpdater::CMailListModelUpdater() : CActive(EPriorityStandard) |
196 { |
224 { |
197 CActiveScheduler::Add(this); |
225 CActiveScheduler::Add(this); |
198 } |
226 iBlockSize = KCMsgBlock; |
199 |
227 } |
200 // --------------------------------------------------------------------------- |
228 |
201 // Destructor |
229 // --------------------------------------------------------------------------- |
|
230 // CMailListModelUpdater::~CMailListModelUpdater |
202 // --------------------------------------------------------------------------- |
231 // --------------------------------------------------------------------------- |
203 // |
232 // |
204 CMailListModelUpdater::~CMailListModelUpdater() |
233 CMailListModelUpdater::~CMailListModelUpdater() |
205 { |
234 { |
206 iObserver = NULL; |
235 iObserver = NULL; |
207 Cancel(); |
236 Cancel(); |
208 iSorting.Close(); |
237 iSorting.Close(); |
|
238 iTimer.Close(); |
209 } |
239 } |
210 |
240 |
211 // --------------------------------------------------------------------------- |
241 // --------------------------------------------------------------------------- |
212 // Returns arrays for sorting parameters. Updater owns the arrays because |
242 // Returns arrays for sorting parameters. Updater owns the arrays because |
213 // it has to stay alive as long as the iterator is being used. |
243 // it has to stay alive as long as the iterator is being used. |
222 // --------------------------------------------------------------------------- |
252 // --------------------------------------------------------------------------- |
223 // Update the mail list model from given iterator. Update progress will be |
253 // Update the mail list model from given iterator. Update progress will be |
224 // informed to the observer. |
254 // informed to the observer. |
225 // --------------------------------------------------------------------------- |
255 // --------------------------------------------------------------------------- |
226 // |
256 // |
227 void CMailListModelUpdater::UpdateModelL(MObserver& aObserver, MFSMailIterator* aIterator) |
257 void CMailListModelUpdater::UpdateModelL(MObserver& aObserver, |
|
258 MFSMailIterator* aIterator, TInt aBlockSize) |
228 { |
259 { |
229 Cancel(); |
260 Cancel(); |
230 iObserver = &aObserver; |
261 iObserver = &aObserver; |
231 iIterator = aIterator; |
262 iIterator = aIterator; |
232 Signal(EInitialize); |
263 Signal(EInitialize); |
|
264 iBlockSize = aBlockSize; |
233 } |
265 } |
234 |
266 |
235 // --------------------------------------------------------------------------- |
267 // --------------------------------------------------------------------------- |
236 // Internal method. Sets new state and signals itself. |
268 // Internal method. Sets new state and signals itself. |
237 // --------------------------------------------------------------------------- |
269 // --------------------------------------------------------------------------- |
238 // |
270 // |
239 void CMailListModelUpdater::Signal(TState aState, TInt aError) |
271 void CMailListModelUpdater::Signal(TState aState, TInt /*aError*/) |
240 { |
272 { |
|
273 const TInt KDelayInMicroSeconds = 5 * 1000; // 5 ms |
|
274 |
|
275 // timer used to get CAknWaitDialog animation working |
241 iState = aState; |
276 iState = aState; |
242 iStatus = KRequestPending; |
277 iTimer.After(iStatus, KDelayInMicroSeconds); |
243 SetActive(); |
278 SetActive(); |
244 TRequestStatus* status = &iStatus; |
279 |
245 User::RequestComplete(status, aError); |
280 |
|
281 //iState = aState; |
|
282 //iStatus = KRequestPending; |
|
283 //SetActive(); |
|
284 //TRequestStatus* status = &iStatus; |
|
285 //User::RequestComplete(status, aError); |
246 } |
286 } |
247 |
287 |
248 // --------------------------------------------------------------------------- |
288 // --------------------------------------------------------------------------- |
249 // Initialization state. Reset update and call UpdateBeginL() for the observer. |
289 // Initialization state. Reset update and call UpdateBeginL() for the observer. |
250 // --------------------------------------------------------------------------- |
290 // --------------------------------------------------------------------------- |
251 // |
291 // |
252 void CMailListModelUpdater::InitializeL() |
292 void CMailListModelUpdater::InitializeL() |
253 { |
293 { |
254 iBlockSize = KCMsgBlock; |
|
255 iParentId = KFsTreeRootID; |
294 iParentId = KFsTreeRootID; |
256 iId = TFSMailMsgId(); |
295 iId = TFSMailMsgId(); |
257 iItemsFetched = 0; |
296 iItemsFetched = 0; |
258 iObserver->UpdateBeginL(); |
297 iObserver->UpdateBeginL(); |
259 Signal(EFetch); |
298 Signal(EFetch); |
264 // fetch state again OR proceed to finalizing state. |
303 // fetch state again OR proceed to finalizing state. |
265 // --------------------------------------------------------------------------- |
304 // --------------------------------------------------------------------------- |
266 // |
305 // |
267 void CMailListModelUpdater::FetchL() |
306 void CMailListModelUpdater::FetchL() |
268 { |
307 { |
269 RPointerArray<CFSMailMessage> messages(iBlockSize); |
308 TInt blockSize = iBlockSize; |
|
309 if ( iItemsFetched == 0 ) |
|
310 { |
|
311 blockSize = KCMsgBlock; |
|
312 } |
|
313 |
|
314 RPointerArray<CFSMailMessage> messages(blockSize); |
270 CleanupClosePushL(messages); |
315 CleanupClosePushL(messages); |
271 const TBool moreMessages(iIterator->NextL(iId, iBlockSize, messages)); |
316 |
272 iBlockSize = Min(KCMsgMaxBlock, iBlockSize * 2); |
317 const TBool moreMessages(iIterator->NextL(iId, blockSize, messages)); |
|
318 |
273 if (messages.Count() > 0) |
319 if (messages.Count() > 0) |
274 { |
320 { |
275 iItemsFetched += messages.Count(); |
321 iItemsFetched += messages.Count(); |
276 iId = messages[messages.Count() - 1]->GetMessageId(); |
322 iId = messages[messages.Count() - 1]->GetMessageId(); |
277 iObserver->UpdateProgressL(iParentId, messages); |
323 iObserver->UpdateProgressL(iParentId, messages); |
278 } |
324 } |
|
325 |
279 CleanupStack::PopAndDestroy(); // messages.Close() |
326 CleanupStack::PopAndDestroy(); // messages.Close() |
|
327 |
280 if (moreMessages && iItemsFetched < KMaxItemsFethed) |
328 if (moreMessages && iItemsFetched < KMaxItemsFethed) |
281 { |
329 { |
282 Signal(EFetch); |
330 Signal(EFetch); |
283 } |
331 } |
284 else |
332 else |
356 if (iObserver) |
404 if (iObserver) |
357 { |
405 { |
358 iObserver->UpdateCancelled(IsUpdating()); |
406 iObserver->UpdateCancelled(IsUpdating()); |
359 } |
407 } |
360 Reset(); |
408 Reset(); |
361 } |
409 |
|
410 iTimer.Cancel(); |
|
411 } |
|
412 // --------------------------------------------------------------------------- |
|
413 // CMailListModelUpdater::RunError |
|
414 // --------------------------------------------------------------------------- |
|
415 // |
|
416 TInt CMailListModelUpdater::RunError(TInt aError) |
|
417 { |
|
418 if ( aError != KErrNone ) |
|
419 { |
|
420 TRAP_IGNORE( iObserver->UpdateErrorL( aError ) ); |
|
421 } |
|
422 |
|
423 return aError; |
|
424 } |
|
425 |
|
426 |
|
427 |
|
428 |
362 |
429 |
363 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
364 // Static constructor. |
431 // Static constructor. |
365 // --------------------------------------------------------------------------- |
432 // --------------------------------------------------------------------------- |
366 // |
433 // |
479 // Set empty text |
548 // Set empty text |
480 HBufC* emptyText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_EMPTY_MSG_LIST_TEXT ); |
549 HBufC* emptyText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_EMPTY_MSG_LIST_TEXT ); |
481 iMailTreeListVisualizer->SetEmptyListTextL( *emptyText ); |
550 iMailTreeListVisualizer->SetEmptyListTextL( *emptyText ); |
482 CleanupStack::PopAndDestroy( emptyText ); |
551 CleanupStack::PopAndDestroy( emptyText ); |
483 |
552 |
484 TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
553 iFocusedTextColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
485 iMailTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor ); |
554 iNormalTextColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
555 iNodeTextColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
|
556 iMailTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( iNormalTextColor ); |
486 |
557 |
487 // Set page up and page down keys |
558 // Set page up and page down keys |
488 iMailTreeListVisualizer->AddCustomPageUpKey( EStdKeyPageUp ); |
559 iMailTreeListVisualizer->AddCustomPageUpKey( EStdKeyPageUp ); |
489 iMailTreeListVisualizer->AddCustomPageDownKey( EStdKeyPageDown ); |
560 iMailTreeListVisualizer->AddCustomPageDownKey( EStdKeyPageDown ); |
490 |
561 |
571 delete iNewEmailText; |
642 delete iNewEmailText; |
572 |
643 |
573 // Don't construct this anywhere else than in constructor. |
644 // Don't construct this anywhere else than in constructor. |
574 // Don't delete anywhere else thatn here to avoid NULL checks. |
645 // Don't delete anywhere else thatn here to avoid NULL checks. |
575 delete iModel; |
646 delete iModel; |
576 |
647 |
577 delete iDeleteTask; |
648 delete iDeleteTask; |
|
649 DeleteSortWaitNote(); |
|
650 delete iNewMailTimer; |
|
651 iNewMailIds.Close(); |
578 } |
652 } |
579 |
653 |
580 void CFSEmailUiMailListVisualiser::PrepareForExit() |
654 void CFSEmailUiMailListVisualiser::PrepareForExit() |
581 { |
655 { |
582 FUNC_LOG; |
656 FUNC_LOG; |
583 iMailListModelUpdater->Cancel(); |
657 iMailListModelUpdater->Cancel(); |
584 if ( iMsgNoteTimer ) |
658 if ( iMsgNoteTimer ) |
585 { |
659 { |
586 iMsgNoteTimer->Cancel(); |
660 // delete also cancels timer |
587 SafeDelete(iMsgNoteTimer); |
661 SafeDelete(iMsgNoteTimer); |
588 } |
662 } |
589 if ( iDateChangeTimer ) |
663 if ( iDateChangeTimer ) |
590 { |
664 { |
591 iDateChangeTimer->Cancel(); |
665 // delete also cancels timer |
592 SafeDelete(iDateChangeTimer); |
666 SafeDelete(iDateChangeTimer); |
593 } |
667 } |
594 if ( iMailListUpdater ) |
668 if ( iMailListUpdater ) |
595 { |
669 { |
596 iMailListUpdater->Stop(); |
670 // delete also cancels timer |
597 SafeDelete(iMailListUpdater); |
671 SafeDelete(iMailListUpdater); |
598 } |
672 } |
599 if ( iAsyncRedrawer ) |
673 if ( iAsyncRedrawer ) |
600 { |
674 { |
601 iAsyncRedrawer->Cancel(); |
|
602 SafeDelete(iAsyncRedrawer); |
675 SafeDelete(iAsyncRedrawer); |
603 } |
676 } |
604 if ( iAsyncCallback ) |
677 if ( iAsyncCallback ) |
605 { |
678 { |
606 iAsyncCallback->Cancel(); |
|
607 SafeDelete(iAsyncCallback); |
679 SafeDelete(iAsyncCallback); |
608 } |
680 } |
609 if ( iMailList ) |
681 if ( iMailList ) |
610 { |
682 { |
611 iMailList->RemoveObserver( *this ); |
683 iMailList->RemoveObserver( *this ); |
612 } |
684 } |
613 if ( iControlBarControl ) |
685 if ( iControlBarControl ) |
614 { |
686 { |
615 iControlBarControl->RemoveObserver( *this ); |
687 iControlBarControl->RemoveObserver( *this ); |
616 } |
688 } |
|
689 |
|
690 if ( iNewMailTimer ) |
|
691 { |
|
692 // delete also cancels timer |
|
693 SafeDelete( iNewMailTimer ); |
|
694 } |
|
695 |
617 SafeDelete(iMailFolder); |
696 SafeDelete(iMailFolder); |
618 iTreeItemArray.Reset(); |
697 iTreeItemArray.Reset(); |
619 // Reset, not delete to avoid NULL checks. |
698 // Reset, not delete to avoid NULL checks. |
620 iModel->Reset(); |
699 iModel->Reset(); |
621 // Resources freed, new start required |
700 // Resources freed, new start required |
637 // --------------------------------------------------------------------------- |
716 // --------------------------------------------------------------------------- |
638 // |
717 // |
639 void CFSEmailUiMailListVisualiser::UpdateErrorL(TInt aError) |
718 void CFSEmailUiMailListVisualiser::UpdateErrorL(TInt aError) |
640 { |
719 { |
641 FUNC_LOG; |
720 FUNC_LOG; |
|
721 |
|
722 DeleteSortWaitNote(); |
642 User::Leave(aError); |
723 User::Leave(aError); |
643 } |
724 } |
644 |
725 |
645 // --------------------------------------------------------------------------- |
726 // --------------------------------------------------------------------------- |
646 // @see CMailListModelUpdater::MObserver::UpdateBeginL |
727 // @see CMailListModelUpdater::MObserver::UpdateBeginL |
647 // --------------------------------------------------------------------------- |
728 // --------------------------------------------------------------------------- |
648 // |
729 // |
649 void CFSEmailUiMailListVisualiser::UpdateBeginL() |
730 void CFSEmailUiMailListVisualiser::UpdateBeginL() |
650 { |
731 { |
651 FUNC_LOG; |
732 FUNC_LOG; |
|
733 iMailList->BeginUpdate(); |
|
734 iMailList->RemoveAllL(); |
|
735 iTreeItemArray.Reset(); |
652 iModel->Reset(); |
736 iModel->Reset(); |
653 iTreeItemArray.Reset(); |
737 iMailList->EndUpdateL(); |
|
738 |
|
739 SetListAndCtrlBarFocusL(); |
654 } |
740 } |
655 |
741 |
656 // --------------------------------------------------------------------------- |
742 // --------------------------------------------------------------------------- |
657 // @see CMailListModelUpdater::MObserver::UpdateProgressL |
743 // @see CMailListModelUpdater::MObserver::UpdateProgressL |
658 // --------------------------------------------------------------------------- |
744 // --------------------------------------------------------------------------- |
659 // |
745 // |
660 void CFSEmailUiMailListVisualiser::UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages) |
746 void CFSEmailUiMailListVisualiser::UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages) |
661 { |
747 { |
662 FUNC_LOG; |
748 FUNC_LOG; |
|
749 |
663 const TInt itemsInModel(iModel->Count()); |
750 const TInt itemsInModel(iModel->Count()); |
664 CreateModelItemsL(aMessages); |
751 CreateModelItemsL(aMessages); |
665 RefreshListItemsL(aParentId, itemsInModel, iModel->Count()); |
752 RefreshListItemsL(aParentId, itemsInModel, iModel->Count()); |
666 } |
753 } |
667 |
754 |
683 { |
777 { |
684 iMailList->SetFocusedItemL( iTreeItemArray[0].iListItemId ); |
778 iMailList->SetFocusedItemL( iTreeItemArray[0].iListItemId ); |
685 } |
779 } |
686 } |
780 } |
687 SetListAndCtrlBarFocusL(); |
781 SetListAndCtrlBarFocusL(); |
688 if(!CheckAutoSyncSettingL()) |
782 |
|
783 if( !CheckAutoSyncSettingL() && !sorting ) |
689 { |
784 { |
690 iAppUi.StartMonitoringL(); |
785 iAppUi.StartMonitoringL(); |
691 } |
786 } |
|
787 |
692 TIMESTAMP( "Locally stored messages fetched for message list" ); |
788 TIMESTAMP( "Locally stored messages fetched for message list" ); |
693 } |
789 } |
694 |
790 |
695 // --------------------------------------------------------------------------- |
791 // --------------------------------------------------------------------------- |
696 // @see CMailListModelUpdater::MObserver::UpdateCancelled |
792 // @see CMailListModelUpdater::MObserver::UpdateCancelled |
697 // --------------------------------------------------------------------------- |
793 // --------------------------------------------------------------------------- |
698 // |
794 // |
699 void CFSEmailUiMailListVisualiser::UpdateCancelled(const TBool aForceRefresh) |
795 void CFSEmailUiMailListVisualiser::UpdateCancelled(const TBool aForceRefresh) |
700 { |
796 { |
701 FUNC_LOG; |
797 FUNC_LOG; |
|
798 |
702 iForceRefresh = aForceRefresh; |
799 iForceRefresh = aForceRefresh; |
|
800 DeleteSortWaitNote(); |
|
801 } |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // CFSEmailUiMailListVisualiser::DeleteSortWaitNote |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 void CFSEmailUiMailListVisualiser::DeleteSortWaitNote() |
|
808 { |
|
809 if ( iSortWaitNote ) |
|
810 { |
|
811 TRAP_IGNORE( iSortWaitNote->ProcessFinishedL() ); |
|
812 iSortWaitNote = NULL; |
|
813 } |
|
814 } |
|
815 |
|
816 |
|
817 // --------------------------------------------------------------------------- |
|
818 // Asynchronous mail list model sort. |
|
819 // --------------------------------------------------------------------------- |
|
820 // |
|
821 void CFSEmailUiMailListVisualiser::SortMailListModelAsyncL() |
|
822 { |
|
823 FUNC_LOG; |
|
824 |
|
825 DeleteSortWaitNote(); |
|
826 |
|
827 TBool ret = UpdateMailListModelAsyncL( KCMsgBlockSort ); |
|
828 |
|
829 if ( ret ) |
|
830 { |
|
831 TFsEmailUiUtility::ShowWaitNoteL( iSortWaitNote, R_FSE_WAIT_SORTING_TEXT, EFalse, ETrue ); |
|
832 } |
703 } |
833 } |
704 |
834 |
705 // --------------------------------------------------------------------------- |
835 // --------------------------------------------------------------------------- |
706 // Asynchronous mail list model update. |
836 // Asynchronous mail list model update. |
707 // --------------------------------------------------------------------------- |
837 // --------------------------------------------------------------------------- |
708 // |
838 // |
709 void CFSEmailUiMailListVisualiser::UpdateMailListModelAsyncL() |
839 TBool CFSEmailUiMailListVisualiser::UpdateMailListModelAsyncL(TInt aBlockSize) |
710 { |
840 { |
711 FUNC_LOG; |
841 FUNC_LOG; |
|
842 TBool ret = EFalse; |
712 if ( iMailFolder ) |
843 if ( iMailFolder ) |
713 { |
844 { |
714 TFSMailDetails details( EFSMsgDataEnvelope ); |
845 TFSMailDetails details( EFSMsgDataEnvelope ); |
715 RArray<TFSMailSortCriteria>& sorting(iMailListModelUpdater->Sorting()); |
846 RArray<TFSMailSortCriteria>& sorting(iMailListModelUpdater->Sorting()); |
716 sorting.AppendL( iCurrentSortCriteria ); |
847 sorting.AppendL( iCurrentSortCriteria ); |
721 secondarySortCriteria.iField = EFSMailSortByDate; |
852 secondarySortCriteria.iField = EFSMailSortByDate; |
722 secondarySortCriteria.iOrder = EFSMailDescending; |
853 secondarySortCriteria.iOrder = EFSMailDescending; |
723 sorting.AppendL( secondarySortCriteria ); |
854 sorting.AppendL( secondarySortCriteria ); |
724 } |
855 } |
725 // List all or maximum number of messages |
856 // List all or maximum number of messages |
726 iMailListModelUpdater->UpdateModelL(*this, iMailFolder->ListMessagesL(details, sorting)); |
857 iMailListModelUpdater->UpdateModelL(*this, iMailFolder->ListMessagesL(details, sorting), aBlockSize); |
|
858 ret = ETrue; |
727 } |
859 } |
728 else |
860 else |
729 { |
861 { |
730 UpdateCompleteL(); |
862 UpdateCompleteL(); |
731 } |
863 } |
|
864 |
|
865 return ret; |
732 } |
866 } |
733 |
867 |
734 // --------------------------------------------------------------------------- |
868 // --------------------------------------------------------------------------- |
735 // |
869 // |
736 // |
870 // |
811 { |
945 { |
812 if (iModel->Count()) |
946 if (iModel->Count()) |
813 { |
947 { |
814 CFSMailMessage* nextMessage = aMessages[0]; |
948 CFSMailMessage* nextMessage = aMessages[0]; |
815 CFSEmailUiMailListModelItem* previousMessage(static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(iModel->Count() - 1))); |
949 CFSEmailUiMailListModelItem* previousMessage(static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(iModel->Count() - 1))); |
816 TBool needANewDivider = |
950 if ( previousMessage ) // Safety |
817 !MessagesBelongUnderSameSeparatorL( previousMessage->MessagePtr(), *nextMessage ); |
951 { |
818 if ( needANewDivider ) |
952 TBool needANewDivider = |
819 { |
953 !MessagesBelongUnderSameSeparatorL( previousMessage->MessagePtr(), *nextMessage ); |
820 newItem = CreateSeparatorModelItemLC( *nextMessage ); |
954 if ( needANewDivider ) |
821 iModel->AppendL( newItem ); |
955 { |
822 CleanupStack::Pop( newItem ); |
956 newItem = CreateSeparatorModelItemLC( *nextMessage ); |
|
957 iModel->AppendL( newItem ); |
|
958 CleanupStack::Pop( newItem ); |
|
959 } |
823 } |
960 } |
824 } |
961 } |
825 else |
962 else |
826 { |
963 { |
827 newItem = CreateSeparatorModelItemLC( *aMessages[0] ); |
964 newItem = CreateSeparatorModelItemLC( *aMessages[0] ); |
1082 { |
1219 { |
1083 // Set extended status before inserting messages |
1220 // Set extended status before inserting messages |
1084 SetMailListItemsExtendedL(); |
1221 SetMailListItemsExtendedL(); |
1085 TInt count(0); |
1222 TInt count(0); |
1086 count = aMessages.Count(); |
1223 count = aMessages.Count(); |
|
1224 |
1087 for ( TInt i = 0 ; i < count ; ++i ) |
1225 for ( TInt i = 0 ; i < count ; ++i ) |
1088 { |
1226 { |
1089 // Make sure we don't add duplicate items. |
1227 // Make sure we don't add duplicate items. |
1090 TInt existingIdx = ItemIndexFromMessageId( aMessages[i] ); |
1228 TInt existingIdx = ItemIndexFromMessageId( aMessages[i] ); |
1091 if ( existingIdx < 0 ) |
1229 if ( existingIdx < 0 ) |
1092 { |
1230 { |
1093 CFSMailMessage* msgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
1231 iNewMailIds.Append( aMessages[ i ] ); |
1094 iMailFolder->GetFolderId(), |
1232 } |
1095 aMessages[i] , |
1233 } |
1096 EFSMsgDataEnvelope ); |
1234 |
1097 if (msgPtr == NULL) |
1235 // if iNewMailIds is not empty - start timer |
1098 { |
1236 if ( !iNewMailTimer->IsActive() && iNewMailIds.Count() ) |
1099 User::Leave(KErrNotFound); |
1237 { |
1100 } |
1238 iNewMailTimer->Start( KNewMailTimerDelay ); |
1101 CleanupStack::PushL( msgPtr ); |
1239 } |
1102 //first item - show scrollbar |
1240 } |
1103 //last item - updete scrollbar |
1241 } |
1104 TBool allowRefresh = ( i == 0 || i == count - 1 ); |
1242 |
1105 InsertNewMessageL( msgPtr, allowRefresh ); |
1243 |
1106 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
1244 // --------------------------------------------------------------------------- |
1107 } |
1245 // TimerEventL |
1108 } |
1246 // |
|
1247 // --------------------------------------------------------------------------- |
|
1248 // |
|
1249 void CFSEmailUiMailListVisualiser::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
|
1250 { |
|
1251 TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() ); |
|
1252 CFSMailClient* mailClient = iAppUi.GetMailClient(); |
|
1253 |
|
1254 for ( TInt i = 0; i < count; i++ ) |
|
1255 { |
|
1256 CFSMailMessage* msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
|
1257 iMailFolder->GetFolderId(), |
|
1258 iNewMailIds[ 0 ], |
|
1259 EFSMsgDataEnvelope ); |
|
1260 if ( msgPtr != NULL ) |
|
1261 { |
|
1262 CleanupStack::PushL( msgPtr ); |
|
1263 //first item - show scrollbar |
|
1264 //last item - update scrollbar |
|
1265 TBool allowRefresh = ( i == 0 || i == count - 1 ); |
|
1266 InsertNewMessageL( msgPtr, allowRefresh ); |
|
1267 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
|
1268 } |
|
1269 // pop processed id from the queue, this is single thread operation |
|
1270 iNewMailIds.Remove( 0 ); |
|
1271 } |
|
1272 |
|
1273 // if timer stoped then restart if more messages available |
|
1274 if ( iNewMailIds.Count() && ! iNewMailTimer->IsActive() ) |
|
1275 { |
|
1276 iNewMailTimer->Start( KNewMailTimerDelay ); |
1109 } |
1277 } |
1110 } |
1278 } |
1111 |
1279 |
1112 // --------------------------------------------------------------------------- |
1280 // --------------------------------------------------------------------------- |
1113 // InsertNewMessageL |
1281 // InsertNewMessageL |
1529 |
1697 |
1530 // NOW WE HAVE A VALID MAILBOX AND FOLDER ID. |
1698 // NOW WE HAVE A VALID MAILBOX AND FOLDER ID. |
1531 // Tries to create an extension for the Ozone plugin |
1699 // Tries to create an extension for the Ozone plugin |
1532 CreateExtensionL(); |
1700 CreateExtensionL(); |
1533 |
1701 |
|
1702 // if mailbox changed stop timer driven insertion of new mails into list |
|
1703 if ( activationData.iMailBoxId != prevMailBoxId ) |
|
1704 { |
|
1705 iNewMailTimer->Cancel(); |
|
1706 iNewMailIds.Reset(); |
|
1707 } |
|
1708 |
1534 // CHECK IF MODEL NEEDS TO BE UPDATED |
1709 // CHECK IF MODEL NEEDS TO BE UPDATED |
1535 if ( activationData.iMailBoxId != prevMailBoxId || |
1710 if ( activationData.iMailBoxId != prevMailBoxId || |
1536 activationData.iFolderId != prevFolderId || |
1711 activationData.iFolderId != prevFolderId || |
1537 activationData.iRequestRefresh || |
1712 activationData.iRequestRefresh || |
1538 iForceRefresh ) |
1713 iForceRefresh ) |
1593 { |
1768 { |
1594 UpdateMailListModelL(); |
1769 UpdateMailListModelL(); |
1595 } |
1770 } |
1596 else |
1771 else |
1597 { |
1772 { |
1598 UpdateMailListModelAsyncL(); |
1773 UpdateMailListModelAsyncL( KCMsgBlockSort ); |
1599 } |
1774 } |
1600 } |
1775 } |
1601 else if(refreshState == EFocusChangeNeeded) |
1776 else if(refreshState == EFocusChangeNeeded) |
1602 {//Move focus to the beginning of the list |
1777 {//Move focus to the beginning of the list |
1603 TInt firstIndex(0); |
1778 TInt firstIndex(0); |
1604 TFsTreeItemId firstItemId = iMailList->Child( KFsTreeRootID, firstIndex ); |
1779 TFsTreeItemId firstItemId(KFsTreeNoneID); |
|
1780 if ( iMailList->CountChildren( KFsTreeRootID ) ) |
|
1781 { |
|
1782 firstItemId = iMailList->Child( KFsTreeRootID, firstIndex ); |
|
1783 } |
1605 iMailTreeListVisualizer->SetFocusedItemL( firstItemId, EFalse ); |
1784 iMailTreeListVisualizer->SetFocusedItemL( firstItemId, EFalse ); |
1606 //if the view is already active don't update the list so it won't "blink" |
1785 //if the view is already active don't update the list so it won't "blink" |
1607 //when the view is activated. |
1786 //when the view is activated. |
1608 if(!iThisViewActive) |
1787 if(!iThisViewActive) |
1609 { |
1788 { |
1610 iMailList->ShowListL(); |
1789 iMailList->ShowListL(); |
1611 } |
1790 } |
1612 } |
1791 } |
1613 // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED. |
1792 // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED. |
1614 else |
1793 else |
1615 { |
1794 { |
1616 iMailList->ShowListL(); |
1795 iMailList->ShowListL(); |
2067 if ( !iMailList->IsNode(iTreeItemArray[i].iListItemId ) && |
2246 if ( !iMailList->IsNode(iTreeItemArray[i].iListItemId ) && |
2068 iMailList->IsMarked( iTreeItemArray[i].iListItemId )) |
2247 iMailList->IsMarked( iTreeItemArray[i].iListItemId )) |
2069 { |
2248 { |
2070 CFSEmailUiMailListModelItem* item = |
2249 CFSEmailUiMailListModelItem* item = |
2071 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(i) ); |
2250 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(i) ); |
2072 CFSMailMessage* confirmedMsgPtr(0); |
2251 if ( item ) // Safety |
2073 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |
|
2074 iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope ); |
|
2075 TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read ); |
|
2076 delete confirmedMsgPtr; |
|
2077 if ( !isReadMessage ) |
|
2078 { |
2252 { |
2079 ret = EFalse; |
2253 CFSMailMessage* confirmedMsgPtr(0); |
2080 break; |
2254 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |
|
2255 iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope ); |
|
2256 TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read ); |
|
2257 delete confirmedMsgPtr; |
|
2258 if ( !isReadMessage ) |
|
2259 { |
|
2260 ret = EFalse; |
|
2261 break; |
|
2262 } |
2081 } |
2263 } |
2082 } |
2264 } |
2083 } |
2265 } |
2084 } |
2266 } |
2085 return ret; |
2267 return ret; |
2103 if ( !iMailList->IsNode(iTreeItemArray[i].iListItemId ) && |
2285 if ( !iMailList->IsNode(iTreeItemArray[i].iListItemId ) && |
2104 iMailList->IsMarked( iTreeItemArray[i].iListItemId )) |
2286 iMailList->IsMarked( iTreeItemArray[i].iListItemId )) |
2105 { |
2287 { |
2106 CFSEmailUiMailListModelItem* item = |
2288 CFSEmailUiMailListModelItem* item = |
2107 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(i) ); |
2289 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(i) ); |
2108 CFSMailMessage* confirmedMsgPtr(0); |
2290 if ( item ) // Safety |
2109 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |
|
2110 iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope ); |
|
2111 TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read ); |
|
2112 delete confirmedMsgPtr; |
|
2113 if ( isReadMessage ) |
|
2114 { |
2291 { |
2115 ret = EFalse; |
2292 CFSMailMessage* confirmedMsgPtr(0); |
2116 break; |
2293 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |
|
2294 iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope ); |
|
2295 TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read ); |
|
2296 delete confirmedMsgPtr; |
|
2297 if ( isReadMessage ) |
|
2298 { |
|
2299 ret = EFalse; |
|
2300 break; |
|
2301 } |
2117 } |
2302 } |
2118 } |
2303 } |
2119 } |
2304 } |
2120 } |
2305 } |
2121 return ret; |
2306 return ret; |
2655 // --------------------------------------------------------------------------- |
2840 // --------------------------------------------------------------------------- |
2656 // |
2841 // |
2657 TFsTreeItemId CFSEmailUiMailListVisualiser::InsertListItemL( TInt aModelIndex, |
2842 TFsTreeItemId CFSEmailUiMailListVisualiser::InsertListItemL( TInt aModelIndex, |
2658 TFsTreeItemId aParentNodeId, |
2843 TFsTreeItemId aParentNodeId, |
2659 TInt aChildIdx, /*= KErrNotFound*/ |
2844 TInt aChildIdx, /*= KErrNotFound*/ |
2660 TBool aAllowRefresh ) |
2845 TBool aAllowRefresh /*= ETrue*/ ) |
2661 { |
2846 { |
2662 FUNC_LOG; |
2847 FUNC_LOG; |
2663 TRect screenRec( iAppUi.ClientRect() ); |
|
2664 CFsTreePlainTwoLineItemData* itemData = NULL; |
2848 CFsTreePlainTwoLineItemData* itemData = NULL; |
2665 CFsTreePlainTwoLineItemVisualizer* itemVisualizer = NULL; |
2849 CFsTreePlainTwoLineItemVisualizer* itemVisualizer = NULL; |
2666 TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
2667 TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
2668 |
|
2669 CFSEmailUiMailListModelItem* item = |
2850 CFSEmailUiMailListModelItem* item = |
2670 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(aModelIndex) ); |
2851 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(aModelIndex) ); |
2671 |
2852 |
2672 // Create data |
2853 // Create data |
2673 itemData = CFsTreePlainTwoLineItemData::NewL(); |
2854 itemData = CFsTreePlainTwoLineItemData::NewL(); |
2689 TBool previewOn = ( iListMode == EListControlTypeDoubleLinePreviewOn || |
2870 TBool previewOn = ( iListMode == EListControlTypeDoubleLinePreviewOn || |
2690 iListMode == EListControlTypeSingleLinePreviewOn ); |
2871 iListMode == EListControlTypeSingleLinePreviewOn ); |
2691 itemVisualizer->SetPreviewPaneOn( previewOn ); |
2872 itemVisualizer->SetPreviewPaneOn( previewOn ); |
2692 itemVisualizer->SetExtendable( ETrue ); |
2873 itemVisualizer->SetExtendable( ETrue ); |
2693 |
2874 |
2694 itemVisualizer->SetFocusedStateTextColor( focusedColor ); |
2875 // Set correct skin text colors for the list items |
2695 itemVisualizer->SetNormalStateTextColor( normalColor ); |
2876 itemVisualizer->SetFocusedStateTextColor( iFocusedTextColor ); |
|
2877 itemVisualizer->SetNormalStateTextColor( iNormalTextColor ); |
2696 |
2878 |
2697 // Set font height |
2879 // Set font height |
2698 itemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
2880 itemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
2699 |
2881 |
2700 //Update icons and text bolding |
2882 //Update icons and text bolding |
2942 static_cast<CFsTreePlainTwoLineItemData*>( iTreeItemArray[idx].iTreeItemData ); |
3124 static_cast<CFsTreePlainTwoLineItemData*>( iTreeItemArray[idx].iTreeItemData ); |
2943 if ( data->PreviewPaneData() == KMissingPreviewDataMarker ) |
3125 if ( data->PreviewPaneData() == KMissingPreviewDataMarker ) |
2944 { |
3126 { |
2945 CFSEmailUiMailListModelItem* modelItem = |
3127 CFSEmailUiMailListModelItem* modelItem = |
2946 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(idx) ); |
3128 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(idx) ); |
2947 CFSMailMessage& msgRef = modelItem->MessagePtr(); |
3129 if ( modelItem ) // For safety |
2948 UpdatePreviewPaneTextForItemL( aListItemId, &msgRef ); |
|
2949 if ( aUpdateItem ) |
|
2950 { |
3130 { |
2951 iMailTreeListVisualizer->UpdateItemL( aListItemId ); |
3131 CFSMailMessage& msgRef = modelItem->MessagePtr(); |
|
3132 UpdatePreviewPaneTextForItemL( aListItemId, &msgRef ); |
|
3133 if ( aUpdateItem ) |
|
3134 { |
|
3135 iMailTreeListVisualizer->UpdateItemL( aListItemId ); |
|
3136 } |
2952 } |
3137 } |
2953 } |
3138 } |
2954 } |
3139 } |
2955 } |
3140 } |
2956 } |
3141 } |
2963 // --------------------------------------------------------------------------- |
3148 // --------------------------------------------------------------------------- |
2964 // |
3149 // |
2965 void CFSEmailUiMailListVisualiser::CreatePlainNodeL( const TDesC* aItemDataBuff, |
3150 void CFSEmailUiMailListVisualiser::CreatePlainNodeL( const TDesC* aItemDataBuff, |
2966 CFsTreePlainOneLineNodeData* &aItemData, |
3151 CFsTreePlainOneLineNodeData* &aItemData, |
2967 CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const |
3152 CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const |
2968 { |
3153 { |
2969 FUNC_LOG; |
3154 FUNC_LOG; |
2970 aItemData = CFsTreePlainOneLineNodeData::NewL(); |
3155 aItemData = CFsTreePlainOneLineNodeData::NewL(); |
2971 CleanupStack::PushL( aItemData ); |
3156 CleanupStack::PushL( aItemData ); |
2972 |
3157 |
2973 aItemData->SetDataL( *aItemDataBuff ); |
3158 aItemData->SetDataL( *aItemDataBuff ); |
2974 aItemData->SetIconExpanded( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeExpanded )); |
3159 aItemData->SetIconExpanded( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeExpanded )); |
2975 aItemData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed )); |
3160 aItemData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed )); |
2976 aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL(*iMailList->TreeControl()); |
3161 aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL(*iMailList->TreeControl()); |
2977 CleanupStack::PushL( aNodeVisualizer ); |
3162 CleanupStack::PushL( aNodeVisualizer ); |
2978 TRect screenRect = iAppUi.ClientRect(); |
|
2979 TInt nodeHeight = iAppUi.LayoutHandler()->OneLineListNodeHeight(); |
3163 TInt nodeHeight = iAppUi.LayoutHandler()->OneLineListNodeHeight(); |
2980 aNodeVisualizer->SetSize( TSize(screenRect.Width(), nodeHeight) ); |
3164 // use cached client rect instead of iAppUi.ClientRect() to save time |
|
3165 // ASSERT in debug to be sure that rects are these same |
|
3166 __ASSERT_DEBUG( iAppUi.ClientRect() == iCurrentClientRect, User::Invariant() ); |
|
3167 aNodeVisualizer->SetSize( TSize(iCurrentClientRect.Width(), nodeHeight) ); |
2981 aNodeVisualizer->SetExtendable(EFalse); |
3168 aNodeVisualizer->SetExtendable(EFalse); |
2982 // Set correct skin text colors for the list items |
3169 // Set correct skin text colors for the list items |
2983 TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
3170 aNodeVisualizer->SetFocusedStateTextColor( iFocusedTextColor ); |
2984 TRgb normalColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
3171 aNodeVisualizer->SetNormalStateTextColor( iNodeTextColor ); |
2985 aNodeVisualizer->SetFocusedStateTextColor( focusedColor ); |
3172 // Set font height |
2986 aNodeVisualizer->SetNormalStateTextColor( normalColor ); |
3173 aNodeVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
2987 // Set font height |
3174 // Set font always bolded in nodes |
2988 aNodeVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
3175 aNodeVisualizer->SetTextBold( ETrue ); |
2989 // Set font always bolded in nodes |
|
2990 aNodeVisualizer->SetTextBold( ETrue ); |
|
2991 |
3176 |
2992 //<cmail> |
3177 //<cmail> |
2993 CAlfBrush* titleDividerBgBrush = |
3178 CAlfBrush* titleDividerBgBrush = |
2994 iAppUi.FsTextureManager()->TitleDividerBgBrushL(); |
3179 iAppUi.FsTextureManager()->TitleDividerBgBrushL(); |
2995 // ownership is not transfered |
3180 // ownership is not transfered |
2996 aNodeVisualizer->SetBackgroundBrush( titleDividerBgBrush ); |
3181 aNodeVisualizer->SetBackgroundBrush( titleDividerBgBrush ); |
2997 //</cmail> |
3182 //</cmail> |
2998 |
3183 |
2999 CleanupStack::Pop( aNodeVisualizer ); |
3184 CleanupStack::Pop( aNodeVisualizer ); |
3000 CleanupStack::Pop( aItemData ); |
3185 CleanupStack::Pop( aItemData ); |
3001 } |
3186 } |
3002 |
3187 |
3003 // --------------------------------------------------------------------------- |
3188 // --------------------------------------------------------------------------- |
3004 // |
3189 // |
3005 // |
3190 // |
3006 // --------------------------------------------------------------------------- |
3191 // --------------------------------------------------------------------------- |
3071 UpdateThemeL(); |
3256 UpdateThemeL(); |
3072 } |
3257 } |
3073 else if ( aType == EScreenLayoutChanged ) |
3258 else if ( aType == EScreenLayoutChanged ) |
3074 { |
3259 { |
3075 UpdateButtonTextsL(); |
3260 UpdateButtonTextsL(); |
|
3261 |
|
3262 iAppUi.FsTextureManager()->ClearTextureByIndex( EListControlBarMailboxDefaultIcon ); |
|
3263 iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) ); |
|
3264 iAppUi.FsTextureManager()->ClearTextureByIndex( EListTextureCreateNewMessageIcon ); |
|
3265 iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) ); |
|
3266 iAppUi.FsTextureManager()->ClearTextureByIndex( GetSortButtonTextureIndex() ); |
|
3267 iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ) ); |
|
3268 |
|
3269 ScaleControlBarL(); |
3076 } |
3270 } |
3077 } |
3271 } |
3078 |
3272 |
3079 // --------------------------------------------------------------------------- |
3273 // --------------------------------------------------------------------------- |
3080 // Update texts for command area buttons |
3274 // Update texts for command area buttons |
3443 // |
3637 // |
3444 void CFSEmailUiMailListVisualiser::UpdateThemeL(const TBool aSystemUpdate) |
3638 void CFSEmailUiMailListVisualiser::UpdateThemeL(const TBool aSystemUpdate) |
3445 { |
3639 { |
3446 iSkinChanged = iSkinChanged || aSystemUpdate; |
3640 iSkinChanged = iSkinChanged || aSystemUpdate; |
3447 |
3641 |
3448 TRgb focusedTextColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
3642 iFocusedTextColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
3449 TRgb normalTextColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
3643 iNormalTextColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
3450 |
3644 iNodeTextColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
3451 iNewEmailButton->SetNormalTextColor( normalTextColor ); |
3645 |
3452 iNewEmailButton->SetFocusedTextColor( focusedTextColor ); |
3646 iNewEmailButton->SetNormalTextColor( iNormalTextColor ); |
3453 |
3647 iNewEmailButton->SetFocusedTextColor( iFocusedTextColor ); |
3454 iFolderListButton->SetNormalTextColor( normalTextColor ); |
3648 |
3455 iFolderListButton->SetFocusedTextColor( focusedTextColor ); |
3649 iFolderListButton->SetNormalTextColor( iNormalTextColor ); |
3456 |
3650 iFolderListButton->SetFocusedTextColor( iFocusedTextColor ); |
3457 iSortButton->SetNormalTextColor( normalTextColor ); |
3651 |
3458 iSortButton->SetFocusedTextColor( focusedTextColor ); |
3652 iSortButton->SetNormalTextColor( iNormalTextColor ); |
|
3653 iSortButton->SetFocusedTextColor( iFocusedTextColor ); |
3459 |
3654 |
3460 //sometimes theme wasn't properly refreshed on buttons, this helps |
3655 //sometimes theme wasn't properly refreshed on buttons, this helps |
3461 iNewEmailButton->HideButton(); |
3656 iNewEmailButton->HideButton(); |
3462 iNewEmailButton->ShowButtonL(); |
3657 iNewEmailButton->ShowButtonL(); |
3463 |
3658 |
4774 if ( iModel->Count() ) |
4969 if ( iModel->Count() ) |
4775 { |
4970 { |
4776 CFSEmailUiMailListModelItem* item = |
4971 CFSEmailUiMailListModelItem* item = |
4777 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
4972 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
4778 |
4973 |
4779 if ( item->ModelItemType() == ETypeMailItem ) // Separators are not markable |
4974 if ( item && item->ModelItemType() == ETypeMailItem ) // Separators are not markable |
4780 { |
4975 { |
4781 if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) |
4976 if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) |
4782 { |
4977 { |
4783 iMailList->MarkItemL( iMailList->FocusedItem(), EFalse ); |
4978 iMailList->MarkItemL( iMailList->FocusedItem(), EFalse ); |
4784 iListMarkItemsState = EFalse; |
4979 iListMarkItemsState = EFalse; |
5915 if ( iModel->Count() ) |
6110 if ( iModel->Count() ) |
5916 // </cmail> |
6111 // </cmail> |
5917 { |
6112 { |
5918 CFSEmailUiMailListModelItem* selectedItem = |
6113 CFSEmailUiMailListModelItem* selectedItem = |
5919 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( aIndex )); |
6114 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( aIndex )); |
5920 CFSMailMessage& msgPtr = selectedItem->MessagePtr(); |
6115 if ( selectedItem ) // Safety |
5921 TBool msgWasReadBefore = msgPtr.IsFlagSet( EFSMsgFlag_Read ); |
6116 { |
5922 if ( aRead != msgWasReadBefore ) |
6117 CFSMailMessage& msgPtr = selectedItem->MessagePtr(); |
5923 { |
6118 TBool msgWasReadBefore = msgPtr.IsFlagSet( EFSMsgFlag_Read ); |
5924 if ( aRead ) |
6119 if ( aRead != msgWasReadBefore ) |
5925 { |
6120 { |
5926 // Send flags, local and server |
6121 if ( aRead ) |
5927 msgPtr.SetFlag( EFSMsgFlag_Read ); |
6122 { |
5928 } |
6123 // Send flags, local and server |
5929 else |
6124 msgPtr.SetFlag( EFSMsgFlag_Read ); |
5930 { |
6125 } |
5931 // Send flags, local and server |
6126 else |
5932 msgPtr.ResetFlag( EFSMsgFlag_Read ); |
6127 { |
5933 } |
6128 // Send flags, local and server |
5934 msgPtr.SaveMessageL(); // Save flag |
6129 msgPtr.ResetFlag( EFSMsgFlag_Read ); |
5935 |
6130 } |
5936 // Switch icon to correct one if mail list is visible |
6131 msgPtr.SaveMessageL(); // Save flag |
5937 TBool needRefresh = ( iAppUi.CurrentActiveView()->Id() == MailListId ); |
6132 |
5938 UpdateMsgIconAndBoldingL( aIndex, needRefresh); |
6133 // Switch icon to correct one if mail list is visible |
5939 |
6134 TBool needRefresh = ( iAppUi.CurrentActiveView()->Id() == MailListId ); |
5940 if ( iCurrentSortCriteria.iField == EFSMailSortByUnread ) |
6135 UpdateMsgIconAndBoldingL( aIndex, needRefresh); |
5941 { |
6136 |
5942 // Attribute affecting the current sorting order has been changed. |
6137 if ( iCurrentSortCriteria.iField == EFSMailSortByUnread ) |
5943 // Thus, the list order may now be incorrect. |
6138 { |
5944 iListOrderMayBeOutOfDate = ETrue; |
6139 // Attribute affecting the current sorting order has been changed. |
|
6140 // Thus, the list order may now be incorrect. |
|
6141 iListOrderMayBeOutOfDate = ETrue; |
|
6142 } |
5945 } |
6143 } |
5946 } |
6144 } |
5947 } |
6145 } |
5948 } |
6146 } |
5949 |
6147 |
5997 if ( aIndex >= 0 && aIndex < iModel->Count() ) |
6195 if ( aIndex >= 0 && aIndex < iModel->Count() ) |
5998 // </cmail> |
6196 // </cmail> |
5999 { |
6197 { |
6000 CFSEmailUiMailListModelItem* modelItem = |
6198 CFSEmailUiMailListModelItem* modelItem = |
6001 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( aIndex ) ); |
6199 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( aIndex ) ); |
6002 if ( modelItem->ModelItemType() == ETypeMailItem ) |
6200 if ( modelItem && modelItem->ModelItemType() == ETypeMailItem ) |
6003 { |
6201 { |
6004 // This is beacause message deleted event migh have occured. |
6202 // This is beacause message deleted event migh have occured. |
6005 CFSMailMessage* confirmedMsgPtr = NULL; |
6203 CFSMailMessage* confirmedMsgPtr = NULL; |
6006 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
6204 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
6007 iMailFolder->GetFolderId(), |
6205 iMailFolder->GetFolderId(), |
6054 if ( iModel->Count() ) |
6252 if ( iModel->Count() ) |
6055 // </cmail> |
6253 // </cmail> |
6056 { |
6254 { |
6057 CFSEmailUiMailListModelItem* item = |
6255 CFSEmailUiMailListModelItem* item = |
6058 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( HighlightedIndex() ) ); |
6256 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( HighlightedIndex() ) ); |
6059 if ( item->ModelItemType() == ETypeMailItem ) |
6257 if ( item && item->ModelItemType() == ETypeMailItem ) |
6060 { |
6258 { |
6061 // This is beacause message deleted event migh have occured. |
6259 // This is beacause message deleted event migh have occured. |
6062 CFSMailMessage* confirmedMsgPtr = NULL; |
6260 CFSMailMessage* confirmedMsgPtr = NULL; |
6063 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
6261 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
6064 iMailFolder->GetFolderId(), |
6262 iMailFolder->GetFolderId(), |
6106 if ( mailItemIdx >= 0 ) |
6304 if ( mailItemIdx >= 0 ) |
6107 { |
6305 { |
6108 CFSEmailUiMailListModelItem* item = |
6306 CFSEmailUiMailListModelItem* item = |
6109 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( mailItemIdx ) ); |
6307 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( mailItemIdx ) ); |
6110 |
6308 |
6111 // Update all flags |
6309 if ( item ) // For safety |
6112 TUint32 prevFlags = item->MessagePtr().GetFlags(); |
6310 { |
6113 TUint32 newFlags = aMsgPtr->GetFlags(); |
6311 // Update all flags |
6114 if ( prevFlags != newFlags ) |
6312 TUint32 prevFlags = item->MessagePtr().GetFlags(); |
6115 { |
6313 TUint32 newFlags = aMsgPtr->GetFlags(); |
6116 item->MessagePtr().ResetFlag( prevFlags ); |
6314 if ( prevFlags != newFlags ) |
6117 item->MessagePtr().SetFlag( newFlags ); |
6315 { |
6118 |
6316 item->MessagePtr().ResetFlag( prevFlags ); |
6119 // Save changed flags in internal model array |
6317 item->MessagePtr().SetFlag( newFlags ); |
6120 item->MessagePtr().SaveMessageL(); |
6318 |
6121 } |
6319 // Save changed flags in internal model array |
6122 |
6320 item->MessagePtr().SaveMessageL(); |
6123 // Update the list item graphics |
6321 } |
6124 UpdateMsgIconAndBoldingL( mailItemIdx ); |
6322 |
6125 } |
6323 // Update the list item graphics |
|
6324 UpdateMsgIconAndBoldingL( mailItemIdx ); |
|
6325 } |
|
6326 } |
6126 } |
6327 } |
6127 } |
6328 } |
6128 |
6329 |
6129 // --------------------------------------------------------------------------- |
6330 // --------------------------------------------------------------------------- |
6130 // UpdateMsgIconAndBoldingL |
6331 // UpdateMsgIconAndBoldingL |
6516 const TInt modelCount( iModel->Count() ); |
6717 const TInt modelCount( iModel->Count() ); |
6517 for( TInt i( 0 ) ; i < modelCount ; ++i ) |
6718 for( TInt i( 0 ) ; i < modelCount ; ++i ) |
6518 { |
6719 { |
6519 CFSEmailUiMailListModelItem* item = |
6720 CFSEmailUiMailListModelItem* item = |
6520 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) ); |
6721 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) ); |
6521 if ( aListId == item->CorrespondingListId() ) |
6722 if ( item && aListId == item->CorrespondingListId() ) |
6522 { |
6723 { |
6523 msgId = item->MessagePtr().GetMessageId(); |
6724 msgId = item->MessagePtr().GetMessageId(); |
6524 // if list id points to separator |
6725 // if list id points to separator |
6525 // set flag on. This is made for improving focus handling. |
6726 // set flag on. This is made for improving focus handling. |
6526 if( item->ModelItemType() == ETypeSeparator ) |
6727 if( item->ModelItemType() == ETypeSeparator ) |
6640 for ( TInt i( 0 ); i < modelCount ; ++i ) |
6841 for ( TInt i( 0 ); i < modelCount ; ++i ) |
6641 { |
6842 { |
6642 CFSEmailUiMailListModelItem* item = |
6843 CFSEmailUiMailListModelItem* item = |
6643 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) ); |
6844 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) ); |
6644 // when the item is a separator check whether its MessagePtr is valid (actually it's a reference) |
6845 // when the item is a separator check whether its MessagePtr is valid (actually it's a reference) |
6645 if( &(item->MessagePtr()) != NULL) |
6846 if( item && &(item->MessagePtr()) != NULL) |
6646 { |
6847 { |
6647 if ( aMessageId == item->MessagePtr().GetMessageId() ) |
6848 if ( aMessageId == item->MessagePtr().GetMessageId() ) |
6648 { |
|
6649 TModelItemType itemType = item->ModelItemType(); |
|
6650 TBool separator( aMessageId.IsSeparator() ); |
|
6651 |
|
6652 // Because separator and the first message after separator |
|
6653 // have same message id, we need to separate these cases |
|
6654 // and that is made with separator flag which is stored to |
|
6655 // TFSMailMsgId object. If separator flag is on item need to be |
|
6656 // separator if it is not on item needs to be mail item. |
|
6657 if( ( separator && itemType == ETypeSeparator ) || |
|
6658 ( !separator && itemType == ETypeMailItem ) ) |
|
6659 { |
6849 { |
6660 idx = i; |
6850 TModelItemType itemType = item->ModelItemType(); |
6661 break; |
6851 TBool separator( aMessageId.IsSeparator() ); |
|
6852 |
|
6853 // Because separator and the first message after separator |
|
6854 // have same message id, we need to separate these cases |
|
6855 // and that is made with separator flag which is stored to |
|
6856 // TFSMailMsgId object. If separator flag is on item need to be |
|
6857 // separator if it is not on item needs to be mail item. |
|
6858 if( ( separator && itemType == ETypeSeparator ) || |
|
6859 ( !separator && itemType == ETypeMailItem ) ) |
|
6860 { |
|
6861 idx = i; |
|
6862 break; |
|
6863 } |
6662 } |
6864 } |
6663 } |
6865 } |
6664 } |
6866 } |
6665 } |
|
6666 } |
6867 } |
6667 return idx; |
6868 return idx; |
6668 } |
6869 } |
6669 |
6870 |
6670 // --------------------------------------------------------------------------- |
6871 // --------------------------------------------------------------------------- |
6982 |
7183 |
6983 iFocusedControl = EControlBarComponent; |
7184 iFocusedControl = EControlBarComponent; |
6984 iMailList->SetFocusedL( EFalse ); |
7185 iMailList->SetFocusedL( EFalse ); |
6985 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
7186 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
6986 |
7187 |
|
7188 SortMailListModelAsyncL(); // sort can take long time |
6987 // <cmail> |
7189 // <cmail> |
6988 if ( iMailListUpdater ) |
7190 //if ( iMailListUpdater ) |
6989 { |
7191 // { |
6990 // Start updating mail list with sorting parameter. |
7192 // Start updating mail list with sorting parameter. |
6991 iMailListUpdater->StartL( ETrue ); |
7193 // iMailListUpdater->StartL( ETrue ); |
6992 } |
7194 // } |
6993 // </cmail> |
7195 // </cmail> |
6994 SetMskL(); |
7196 SetMskL(); |
6995 } |
7197 } |
6996 |
7198 |
6997 // --------------------------------------------------------------------------- |
7199 // --------------------------------------------------------------------------- |
7033 TInt idx = ModelIndexFromListId( aMailItem ); |
7235 TInt idx = ModelIndexFromListId( aMailItem ); |
7034 if ( idx >= 0 ) |
7236 if ( idx >= 0 ) |
7035 { |
7237 { |
7036 CFSEmailUiMailListModelItem* item = |
7238 CFSEmailUiMailListModelItem* item = |
7037 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(idx) ); |
7239 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(idx) ); |
7038 if ( item->ModelItemType() == ETypeMailItem ) |
7240 if ( item && item->ModelItemType() == ETypeMailItem ) |
7039 { |
7241 { |
7040 // First make sure that the highlighted message really exists in the store |
7242 // First make sure that the highlighted message really exists in the store |
7041 // Get confirmed msg ptr |
7243 // Get confirmed msg ptr |
7042 CFSMailMessage* confirmedMsgPtr(0); |
7244 CFSMailMessage* confirmedMsgPtr(0); |
7043 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |
7245 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |