95 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
95 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
96 static const TInt KMsgDeletionWaitNoteAmount = 5; |
96 static const TInt KMsgDeletionWaitNoteAmount = 5; |
97 _LIT( KMissingPreviewDataMarker, "..." ); |
97 _LIT( KMissingPreviewDataMarker, "..." ); |
98 |
98 |
99 static const TInt KMaxItemsFethed = 1000; |
99 static const TInt KMaxItemsFethed = 1000; |
100 static const TInt KCMsgBlock = 100; |
100 static const TInt KCMsgBlock = 15; |
|
101 static const TInt KCMsgMaxBlock = 120; |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // Generic method for deleting a pointer and setting it NULL. |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 template <class T> void SafeDelete(T*& ptr) |
|
108 { |
|
109 delete ptr; |
|
110 ptr = NULL; |
|
111 } |
|
112 |
|
113 // CMailListModelUpdater |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // Constructor |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 CMailListModelUpdater::CMailListModelUpdater() : CActive(EPriorityStandard) |
|
120 { |
|
121 CActiveScheduler::Add(this); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // Destructor |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 CMailListModelUpdater::~CMailListModelUpdater() |
|
129 { |
|
130 iObserver = NULL; |
|
131 Cancel(); |
|
132 iSorting.Close(); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Returns arrays for sorting parameters. Updater owns the arrays because |
|
137 // it has to stay alive as long as the iterator is being used. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 RArray<TFSMailSortCriteria>& CMailListModelUpdater::Sorting() |
|
141 { |
|
142 iSorting.Reset(); |
|
143 return iSorting; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // Update the mail list model from given iterator. Update progress will be |
|
148 // informed to the observer. |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CMailListModelUpdater::UpdateModelL(MObserver& aObserver, MFSMailIterator* aIterator) |
|
152 { |
|
153 Cancel(); |
|
154 iObserver = &aObserver; |
|
155 iIterator = aIterator; |
|
156 Signal(EInitialize); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // Internal method. Sets new state and signals itself. |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CMailListModelUpdater::Signal(TState aState, TInt aError) |
|
164 { |
|
165 iState = aState; |
|
166 iStatus = KRequestPending; |
|
167 SetActive(); |
|
168 TRequestStatus* status = &iStatus; |
|
169 User::RequestComplete(status, aError); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // Initialization state. Reset update and call UpdateBeginL() for the observer. |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CMailListModelUpdater::InitializeL() |
|
177 { |
|
178 iBlockSize = KCMsgBlock; |
|
179 iParentId = KFsTreeRootID; |
|
180 iId = TFSMailMsgId(); |
|
181 iItemsFetched = 0; |
|
182 iObserver->UpdateBeginL(); |
|
183 Signal(EFetch); |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // Fetch state. Fetch next messages and if there is more messages signal |
|
188 // fetch state again OR proceed to finalizing state. |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CMailListModelUpdater::FetchL() |
|
192 { |
|
193 RPointerArray<CFSMailMessage> messages(iBlockSize); |
|
194 CleanupClosePushL(messages); |
|
195 const TBool moreMessages(iIterator->NextL(iId, iBlockSize, messages)); |
|
196 iBlockSize = Min(KCMsgMaxBlock, iBlockSize * 2); |
|
197 if (messages.Count() > 0) |
|
198 { |
|
199 iItemsFetched += messages.Count(); |
|
200 iId = messages[messages.Count() - 1]->GetMessageId(); |
|
201 iObserver->UpdateProgressL(iParentId, messages); |
|
202 } |
|
203 CleanupStack::PopAndDestroy(); // messages.Close() |
|
204 if (moreMessages && iItemsFetched < KMaxItemsFethed) |
|
205 { |
|
206 Signal(EFetch); |
|
207 } |
|
208 else |
|
209 { |
|
210 Signal(EFinalize); |
|
211 } |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // Finalizing state. Notify observer that model update has been done and |
|
216 // free the resources. |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void CMailListModelUpdater::FinalizeL() |
|
220 { |
|
221 iObserver->UpdateCompleteL(); |
|
222 Reset(); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // If the state is anything but EIdle, returns ETrue. |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 TBool CMailListModelUpdater::IsUpdating() const |
|
230 { |
|
231 return iState > EIdle; |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // Reset the state to EIdle and free resources. |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 void CMailListModelUpdater::Reset() |
|
239 { |
|
240 iSorting.Reset(); |
|
241 SafeDelete(iIterator); |
|
242 iState = EIdle; |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // Active objects RunL() |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 void CMailListModelUpdater::RunL() |
|
250 { |
|
251 const TInt error(iStatus.Int()); |
|
252 if (!error) |
|
253 { |
|
254 switch (iState) |
|
255 { |
|
256 case EInitialize: |
|
257 InitializeL(); |
|
258 break; |
|
259 case EFetch: |
|
260 FetchL(); |
|
261 break; |
|
262 case EFinalize: |
|
263 default: |
|
264 FinalizeL(); |
|
265 break; |
|
266 } |
|
267 } |
|
268 else |
|
269 { |
|
270 iObserver->UpdateErrorL(error); |
|
271 } |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // Update has been cancelled. Inform the observer and free resources. |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void CMailListModelUpdater::DoCancel() |
|
279 { |
|
280 if (iObserver) |
|
281 { |
|
282 iObserver->UpdateCancelled(IsUpdating()); |
|
283 } |
|
284 Reset(); |
|
285 } |
101 |
286 |
102 // --------------------------------------------------------------------------- |
287 // --------------------------------------------------------------------------- |
103 // Static constructor. |
288 // Static constructor. |
104 // --------------------------------------------------------------------------- |
289 // --------------------------------------------------------------------------- |
105 // |
290 // |
312 } |
495 } |
313 |
496 |
314 void CFSEmailUiMailListVisualiser::PrepareForExit() |
497 void CFSEmailUiMailListVisualiser::PrepareForExit() |
315 { |
498 { |
316 FUNC_LOG; |
499 FUNC_LOG; |
|
500 iMailListModelUpdater->Cancel(); |
317 if ( iMsgNoteTimer ) |
501 if ( iMsgNoteTimer ) |
318 { |
502 { |
319 iMsgNoteTimer->Cancel(); |
503 iMsgNoteTimer->Cancel(); |
320 delete iMsgNoteTimer; |
504 SafeDelete(iMsgNoteTimer); |
321 iMsgNoteTimer = NULL; |
|
322 } |
505 } |
323 if ( iDateChangeTimer ) |
506 if ( iDateChangeTimer ) |
324 { |
507 { |
325 iDateChangeTimer->Cancel(); |
508 iDateChangeTimer->Cancel(); |
326 delete iDateChangeTimer; |
509 SafeDelete(iDateChangeTimer); |
327 iDateChangeTimer = NULL; |
|
328 } |
510 } |
329 if ( iMailListUpdater ) |
511 if ( iMailListUpdater ) |
330 { |
512 { |
331 iMailListUpdater->Stop(); |
513 iMailListUpdater->Stop(); |
332 delete iMailListUpdater; |
514 SafeDelete(iMailListUpdater); |
333 iMailListUpdater = NULL; |
|
334 } |
515 } |
335 if ( iAsyncRedrawer ) |
516 if ( iAsyncRedrawer ) |
336 { |
517 { |
337 iAsyncRedrawer->Cancel(); |
518 iAsyncRedrawer->Cancel(); |
338 delete iAsyncRedrawer; |
519 SafeDelete(iAsyncRedrawer); |
339 iAsyncRedrawer = NULL; |
|
340 } |
520 } |
341 if ( iAsyncCallback ) |
521 if ( iAsyncCallback ) |
342 { |
522 { |
343 iAsyncCallback->Cancel(); |
523 iAsyncCallback->Cancel(); |
344 delete iAsyncCallback; |
524 SafeDelete(iAsyncCallback); |
345 iAsyncCallback = NULL; |
|
346 } |
525 } |
347 if ( iMailList ) |
526 if ( iMailList ) |
348 { |
527 { |
349 iMailList->RemoveObserver( *this ); |
528 iMailList->RemoveObserver( *this ); |
350 } |
529 } |
351 if ( iControlBarControl ) |
530 if ( iControlBarControl ) |
352 { |
531 { |
353 iControlBarControl->RemoveObserver( *this ); |
532 iControlBarControl->RemoveObserver( *this ); |
354 } |
533 } |
355 // <cmail> |
534 SafeDelete(iMailFolder); |
356 iTreeItemArray.Reset(); |
535 iTreeItemArray.Reset(); |
357 if ( iMailFolder ) |
|
358 { |
|
359 delete iMailFolder; |
|
360 iMailFolder = NULL; |
|
361 } |
|
362 // Reset, not delete to avoid NULL checks. |
536 // Reset, not delete to avoid NULL checks. |
363 iModel->Reset(); |
537 iModel->Reset(); |
364 // </cmail> |
|
365 } |
538 } |
366 |
539 |
367 // --------------------------------------------------------------------------- |
540 // --------------------------------------------------------------------------- |
368 // Returns reference to mail list. |
541 // Returns reference to mail list. |
369 // --------------------------------------------------------------------------- |
542 // --------------------------------------------------------------------------- |
373 FUNC_LOG; |
546 FUNC_LOG; |
374 return *iMailList; |
547 return *iMailList; |
375 } |
548 } |
376 |
549 |
377 // --------------------------------------------------------------------------- |
550 // --------------------------------------------------------------------------- |
|
551 // @see CMailListModelUpdater::MObserver::UpdateErrorL |
|
552 // --------------------------------------------------------------------------- |
|
553 // |
|
554 void CFSEmailUiMailListVisualiser::UpdateErrorL(TInt aError) |
|
555 { |
|
556 FUNC_LOG; |
|
557 User::Leave(aError); |
|
558 } |
|
559 |
|
560 // --------------------------------------------------------------------------- |
|
561 // @see CMailListModelUpdater::MObserver::UpdateBeginL |
|
562 // --------------------------------------------------------------------------- |
|
563 // |
|
564 void CFSEmailUiMailListVisualiser::UpdateBeginL() |
|
565 { |
|
566 FUNC_LOG; |
|
567 iModel->Reset(); |
|
568 iTreeItemArray.Reset(); |
|
569 } |
|
570 |
|
571 // --------------------------------------------------------------------------- |
|
572 // @see CMailListModelUpdater::MObserver::UpdateProgressL |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 void CFSEmailUiMailListVisualiser::UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages) |
|
576 { |
|
577 FUNC_LOG; |
|
578 const TInt itemsInModel(iModel->Count()); |
|
579 CreateModelItemsL(aMessages); |
|
580 RefreshListItemsL(aParentId, itemsInModel, iModel->Count()); |
|
581 } |
|
582 |
|
583 // --------------------------------------------------------------------------- |
|
584 // @see CMailListModelUpdater::MObserver::UpdateCompleteL |
|
585 // --------------------------------------------------------------------------- |
|
586 // |
|
587 void CFSEmailUiMailListVisualiser::UpdateCompleteL() |
|
588 { |
|
589 FUNC_LOG; |
|
590 if ( !iModel->Count() ) |
|
591 { |
|
592 iFocusedControl = EControlBarComponent; |
|
593 } |
|
594 else |
|
595 { |
|
596 iFocusedControl = EMailListComponent; |
|
597 if (iMailList->FocusedItem() == KFsTreeNoneID) |
|
598 { |
|
599 iMailList->SetFocusedItemL( iTreeItemArray[0].iListItemId ); |
|
600 } |
|
601 } |
|
602 SetListAndCtrlBarFocusL(); |
|
603 iAppUi.StartMonitoringL(); |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------------------------- |
|
607 // @see CMailListModelUpdater::MObserver::UpdateCancelled |
|
608 // --------------------------------------------------------------------------- |
|
609 // |
|
610 void CFSEmailUiMailListVisualiser::UpdateCancelled(const TBool aForceRefresh) |
|
611 { |
|
612 FUNC_LOG; |
|
613 iForceRefresh = aForceRefresh; |
|
614 } |
|
615 |
|
616 // --------------------------------------------------------------------------- |
|
617 // Asynchronous mail list model update. |
|
618 // --------------------------------------------------------------------------- |
|
619 // |
|
620 void CFSEmailUiMailListVisualiser::UpdateMailListModelAsyncL() |
|
621 { |
|
622 FUNC_LOG; |
|
623 if ( iMailFolder ) |
|
624 { |
|
625 TFSMailDetails details( EFSMsgDataEnvelope ); |
|
626 RArray<TFSMailSortCriteria>& sorting(iMailListModelUpdater->Sorting()); |
|
627 sorting.AppendL( iCurrentSortCriteria ); |
|
628 if ( iCurrentSortCriteria.iField != EFSMailSortByDate ) |
|
629 { |
|
630 // Add date+descending as secondary sort criteria if primary field is something else than date |
|
631 TFSMailSortCriteria secondarySortCriteria; |
|
632 secondarySortCriteria.iField = EFSMailSortByDate; |
|
633 secondarySortCriteria.iOrder = EFSMailDescending; |
|
634 sorting.AppendL( secondarySortCriteria ); |
|
635 } |
|
636 // List all or maximum number of messages |
|
637 iMailListModelUpdater->UpdateModelL(*this, iMailFolder->ListMessagesL(details, sorting)); |
|
638 } |
|
639 else |
|
640 { |
|
641 UpdateCompleteL(); |
|
642 } |
|
643 } |
|
644 |
|
645 // --------------------------------------------------------------------------- |
378 // |
646 // |
379 // |
647 // |
380 // --------------------------------------------------------------------------- |
648 // --------------------------------------------------------------------------- |
381 // |
649 // |
382 void CFSEmailUiMailListVisualiser::UpdateMailListModelL() |
650 void CFSEmailUiMailListVisualiser::UpdateMailListModelL() |
383 { |
651 { |
384 FUNC_LOG; |
652 FUNC_LOG; |
|
653 // Make sure asynchronous update is not going on |
|
654 iMailListModelUpdater->Cancel(); |
385 // Reset model with each update |
655 // Reset model with each update |
386 iModel->Reset(); |
656 iModel->Reset(); |
387 |
|
388 if ( iMailFolder ) |
657 if ( iMailFolder ) |
389 { |
658 { |
390 // Update folder if provided, otherwise use current folder |
659 // Update folder if provided, otherwise use current folder |
391 RPointerArray<CFSMailMessage> folderMessages( KCMsgBlock ); |
660 RPointerArray<CFSMailMessage> folderMessages( KCMsgBlock ); |
392 CleanupClosePushL( folderMessages ); |
661 CleanupClosePushL( folderMessages ); |
444 // |
713 // |
445 void CFSEmailUiMailListVisualiser::CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages ) |
714 void CFSEmailUiMailListVisualiser::CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages ) |
446 { |
715 { |
447 FUNC_LOG; |
716 FUNC_LOG; |
448 // New Items |
717 // New Items |
449 CFSEmailUiMailListModelItem* newItem = NULL; |
718 CFSEmailUiMailListModelItem* newItem(NULL); |
450 |
719 |
451 // Draw first separator if there are messages. |
720 // Draw first separator if there are messages. |
452 if ( aMessages.Count() && iNodesInUse == EListControlSeparatorEnabled ) |
721 if ( aMessages.Count() && iNodesInUse == EListControlSeparatorEnabled ) |
453 { |
722 { |
|
723 if (iModel->Count()) |
|
724 { |
|
725 CFSMailMessage* nextMessage = aMessages[0]; |
|
726 CFSEmailUiMailListModelItem* previousMessage(static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(iModel->Count() - 1))); |
|
727 TBool needANewDivider = |
|
728 !MessagesBelongUnderSameSeparatorL( previousMessage->MessagePtr(), *nextMessage ); |
|
729 if ( needANewDivider ) |
|
730 { |
|
731 newItem = CreateSeparatorModelItemLC( *nextMessage ); |
|
732 iModel->AppendL( newItem ); |
|
733 CleanupStack::Pop( newItem ); |
|
734 } |
|
735 } |
|
736 else |
|
737 { |
454 newItem = CreateSeparatorModelItemLC( *aMessages[0] ); |
738 newItem = CreateSeparatorModelItemLC( *aMessages[0] ); |
455 iModel->AppendL( newItem ); |
739 iModel->AppendL( newItem ); |
456 CleanupStack::Pop( newItem ); |
740 CleanupStack::Pop( newItem ); |
|
741 } |
457 } |
742 } |
458 |
743 |
459 // Start appending items |
744 // Start appending items |
460 for (int i = 0; i < aMessages.Count(); i++) |
745 for (int i = 0; i < aMessages.Count(); i++) |
461 { |
746 { |
1114 // NOW WE HAVE A VALID MAILBOX AND FOLDER ID. |
1400 // NOW WE HAVE A VALID MAILBOX AND FOLDER ID. |
1115 |
1401 |
1116 // CHECK IF MODEL NEEDS TO BE UPDATED |
1402 // CHECK IF MODEL NEEDS TO BE UPDATED |
1117 if ( activationData.iMailBoxId != prevMailBoxId || |
1403 if ( activationData.iMailBoxId != prevMailBoxId || |
1118 activationData.iFolderId != prevFolderId || |
1404 activationData.iFolderId != prevFolderId || |
1119 activationData.iRequestRefresh ) |
1405 activationData.iRequestRefresh || |
|
1406 iForceRefresh ) |
1120 { |
1407 { |
|
1408 iForceRefresh = EFalse; |
1121 // Set initial sort criteria when folder is changed |
1409 // Set initial sort criteria when folder is changed |
1122 iCurrentSortCriteria.iField = EFSMailSortByDate; |
1410 iCurrentSortCriteria.iField = EFSMailSortByDate; |
1123 iCurrentSortCriteria.iOrder = EFSMailDescending; |
1411 iCurrentSortCriteria.iOrder = EFSMailDescending; |
1124 SetSortButtonTextAndIconL(); |
1412 SetSortButtonTextAndIconL(); |
1125 |
1413 |
1126 delete iMailFolder; |
1414 SafeDelete(iMailFolder); |
1127 iMailFolder = NULL; |
|
1128 TRAP_IGNORE( iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( |
1415 TRAP_IGNORE( iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( |
1129 activationData.iMailBoxId, activationData.iFolderId ) ); |
1416 activationData.iMailBoxId, activationData.iFolderId ) ); |
1130 if ( !iMailFolder ) |
1417 if ( !iMailFolder ) |
1131 { |
1418 { |
|
1419 if ( forwardNavigation ) |
|
1420 { |
|
1421 iAppUi.StartMonitoringL(); |
|
1422 } |
1132 // Safety, try to revert back to standard folder inbox |
1423 // Safety, try to revert back to standard folder inbox |
1133 TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox ); |
1424 TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox ); |
1134 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( activationData.iMailBoxId, inboxId ); |
1425 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( activationData.iMailBoxId, inboxId ); |
1135 } |
1426 } |
1136 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
1427 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
1148 SetBrandedMailBoxIconL(); |
1439 SetBrandedMailBoxIconL(); |
1149 |
1440 |
1150 // Check sync icon timer and sync status |
1441 // Check sync icon timer and sync status |
1151 ConnectionIconHandling(); |
1442 ConnectionIconHandling(); |
1152 |
1443 |
1153 iMailList->HideListL(); |
|
1154 iMailList->ShowListL(); |
|
1155 |
|
1156 // REBUILD TREE LIST IF NECESSARY |
1444 // REBUILD TREE LIST IF NECESSARY |
1157 if ( refreshNeeded ) |
1445 if ( refreshNeeded ) |
1158 { |
1446 { |
1159 // Try to maintain previously active item if possible. |
1447 // Try to maintain previously active item if possible. |
1160 // This is of course not possible if folder has changed. |
1448 // This is of course not possible if folder has changed. |
1161 TFSMailMsgId focused = MsgIdFromListId( iMailList->FocusedItem() ); |
1449 TFSMailMsgId focused = MsgIdFromListId( iMailList->FocusedItem() ); |
1162 |
1450 |
1163 // Clear any previous items from the screen and then make the view visible |
1451 // Clear any previous items from the screen and then make the view visible |
|
1452 iMailList->BeginUpdate(); |
1164 iMailList->RemoveAllL(); |
1453 iMailList->RemoveAllL(); |
1165 iTreeItemArray.Reset(); |
1454 iTreeItemArray.Reset(); |
1166 UpdateMailListModelL(); |
1455 iModel->Reset(); |
1167 RefreshDeferred( &focused ); |
1456 iMailList->EndUpdateL(); |
1168 } |
1457 iMailList->ShowListL(); |
1169 |
1458 |
|
1459 // If coming from wizard use synchronous list updating |
|
1460 if (activationData.iReturnAfterWizard) |
|
1461 { |
|
1462 UpdateMailListModelL(); |
|
1463 } |
|
1464 else |
|
1465 { |
|
1466 UpdateMailListModelAsyncL(); |
|
1467 } |
|
1468 } |
1170 // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED. |
1469 // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED. |
1171 else |
1470 else |
1172 { |
1471 { |
1173 // hide & show list to force it to adept to changed screen size |
1472 iMailList->ShowListL(); |
|
1473 if (forwardNavigation) |
|
1474 { |
|
1475 iAppUi.StartMonitoringL(); |
|
1476 } |
1174 SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted |
1477 SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted |
1175 UnmarkAllItemsL(); |
1478 UnmarkAllItemsL(); |
1176 |
|
1177 if ( aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) ) |
1479 if ( aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) ) |
1178 { |
1480 { |
1179 // Better to refresh launcher grid view because mailbox branding might be changed. |
1481 // Better to refresh launcher grid view because mailbox branding might be changed. |
1180 iAppUi.LauncherGrid().SetRefreshNeeded(); |
1482 iAppUi.LauncherGrid().SetRefreshNeeded(); |
1181 } |
1483 } |
1182 |
|
1183 // Check the validity of focused message, it may be deleted or |
1484 // Check the validity of focused message, it may be deleted or |
1184 // reply/forward, read/unread status might have changed in editor or viewer |
1485 // reply/forward, read/unread status might have changed in editor or viewer |
1185 UpdateItemAtIndexL( HighlightedIndex() ); |
1486 UpdateItemAtIndexL( HighlightedIndex() ); |
1186 SetMskL(); |
1487 SetMskL(); |
1187 } |
1488 } |
1759 // IMPLEMENTATION OF FILLING UP THE LIST |
2065 // IMPLEMENTATION OF FILLING UP THE LIST |
1760 TFsTreeItemId latestNodeId = KFsTreeRootID; // items will go under root node if no other nodes found in the model |
2066 TFsTreeItemId latestNodeId = KFsTreeRootID; // items will go under root node if no other nodes found in the model |
1761 CFSEmailUiMailListModelItem* item( NULL ); |
2067 CFSEmailUiMailListModelItem* item( NULL ); |
1762 SetMailListItemsExtendedL(); |
2068 SetMailListItemsExtendedL(); |
1763 |
2069 |
1764 TBool allowRefresh(EFalse); |
|
1765 TInt count(0); |
2070 TInt count(0); |
1766 count = iModel->Count(); |
2071 count = iModel->Count(); |
1767 for ( TInt i=0; i < count; i++ ) |
2072 for ( TInt i=0; i < count; i++ ) |
1768 { |
2073 { |
1769 item = static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
2074 item = static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
1770 |
2075 |
1771 if ( i == 0 || i == count - 1 ) |
2076 const TBool allowRefresh(i == 0 || (i == count - 1)); |
1772 {//first item - show scrollbar |
|
1773 //last item - update scrollbar |
|
1774 allowRefresh = ETrue; |
|
1775 } |
|
1776 else |
|
1777 {//rest of the messages - insert without updating |
|
1778 allowRefresh = EFalse; |
|
1779 } |
|
1780 |
2077 |
1781 // Append separator item text into the list |
2078 // Append separator item text into the list |
1782 if ( item && item->ModelItemType() == ETypeSeparator ) |
2079 if ( item && item->ModelItemType() == ETypeSeparator ) |
1783 { |
2080 { |
1784 latestNodeId = InsertNodeItemL( i, KErrNotFound, allowRefresh ); |
2081 latestNodeId = InsertNodeItemL( i, KErrNotFound, allowRefresh ); |
1789 InsertListItemL( i, latestNodeId, KErrNotFound, allowRefresh ); |
2086 InsertListItemL( i, latestNodeId, KErrNotFound, allowRefresh ); |
1790 } |
2087 } |
1791 } |
2088 } |
1792 } |
2089 } |
1793 |
2090 |
|
2091 // --------------------------------------------------------------------------- |
|
2092 // |
|
2093 // |
|
2094 // --------------------------------------------------------------------------- |
|
2095 // |
|
2096 void CFSEmailUiMailListVisualiser::RefreshListItemsL(TFsTreeItemId& aLatestNodeId, const TInt aStartIndex, const TInt aEndIndex) |
|
2097 { |
|
2098 FUNC_LOG; |
|
2099 // IMPLEMENTATION OF FILLING UP THE LIST |
|
2100 iMailList->BeginUpdate(); |
|
2101 CFSEmailUiMailListModelItem* item( NULL ); |
|
2102 if (aLatestNodeId == KFsTreeRootID && !aStartIndex) |
|
2103 { |
|
2104 iMailList->RemoveAllL(); |
|
2105 iTreeItemArray.Reset(); |
|
2106 SetMailListItemsExtendedL(); |
|
2107 } |
|
2108 for ( TInt i = aStartIndex; i < aEndIndex; i++ ) |
|
2109 { |
|
2110 item = static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
|
2111 // Append separator item text into the list |
|
2112 if ( item && item->ModelItemType() == ETypeSeparator ) |
|
2113 { |
|
2114 aLatestNodeId = InsertNodeItemL( i, KErrNotFound, EFalse ); |
|
2115 } |
|
2116 // Append mail item into the list |
|
2117 else if ( item && item->ModelItemType() == ETypeMailItem ) |
|
2118 { |
|
2119 InsertListItemL( i, aLatestNodeId, KErrNotFound, EFalse ); |
|
2120 } |
|
2121 } |
|
2122 iMailList->EndUpdateL(); |
|
2123 } |
1794 |
2124 |
1795 void CFSEmailUiMailListVisualiser::SetMailListItemsExtendedL() |
2125 void CFSEmailUiMailListVisualiser::SetMailListItemsExtendedL() |
1796 { |
2126 { |
1797 FUNC_LOG; |
2127 FUNC_LOG; |
1798 // Set items always extended in double line preview on mode. |
2128 // Set items always extended in double line preview on mode. |
7313 // ----------------------------------------------------------------------------- |
7662 // ----------------------------------------------------------------------------- |
7314 // |
7663 // |
7315 void CDateChangeTimer::RunL() |
7664 void CDateChangeTimer::RunL() |
7316 { |
7665 { |
7317 FUNC_LOG; |
7666 FUNC_LOG; |
|
7667 |
|
7668 if (iStatus.Int() != KErrNone) |
|
7669 { |
|
7670 INFO_1("### CDateChangeTimer::RunL (err=%d) ###", iStatus.Int()); |
|
7671 } |
|
7672 |
|
7673 |
|
7674 TBool dayChanged = EFalse; |
|
7675 TInt dayCount = DayCount(); |
|
7676 if (dayCount != iDayCount) |
|
7677 { |
|
7678 |
|
7679 iDayCount = dayCount; |
|
7680 dayChanged = ETrue; |
|
7681 } |
|
7682 |
|
7683 |
7318 if ( KErrCancel == iStatus.Int() ) |
7684 if ( KErrCancel == iStatus.Int() ) |
7319 { |
7685 { |
7320 ; |
7686 ; |
7321 } |
7687 } |
7322 // System time changed? |
7688 else if ( KErrAbort == iStatus.Int() ) // System time changed |
7323 else if ( KErrAbort == iStatus.Int() ) |
7689 { |
7324 { |
7690 if (dayChanged) |
|
7691 { |
|
7692 TRAP_IGNORE( iMailListVisualiser.NotifyDateChangedL() ); |
|
7693 } |
7325 Start(); |
7694 Start(); |
7326 } |
7695 } |
7327 // Interval is over |
7696 else // interval is over |
7328 else |
|
7329 { |
7697 { |
7330 // Update mail list and reissue the request for timer event |
7698 // Update mail list and reissue the request for timer event |
7331 TRAP_IGNORE( iMailListVisualiser.NotifyDateChangedL() ); |
7699 TRAP_IGNORE( iMailListVisualiser.NotifyDateChangedL() ); |
7332 Start(); |
7700 Start(); |
7333 } |
7701 } |
7334 } |
7702 |
|
7703 } |
|
7704 |
|
7705 |
|
7706 TInt CDateChangeTimer::DayCount() |
|
7707 { |
|
7708 TTime now; |
|
7709 now.HomeTime(); |
|
7710 TTime minTime = Time::MinTTime(); |
|
7711 TTimeIntervalDays days = now.DaysFrom(minTime); |
|
7712 return days.Int(); |
|
7713 } |
|
7714 |
|
7715 |
|
7716 |
|
7717 |
|
7718 |
|
7719 |
|
7720 |
|
7721 |