1 /* |
1 /* |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Symbian Foundation License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
73 class CESMRIcalViewer; |
73 class CESMRIcalViewer; |
74 class CAknWaitDialog; |
74 class CAknWaitDialog; |
75 class CDateChangeTimer; |
75 class CDateChangeTimer; |
76 class CFsTreePlainTwoLineItemData; |
76 class CFsTreePlainTwoLineItemData; |
77 class CFsTreePlainTwoLineItemVisualizer; |
77 class CFsTreePlainTwoLineItemVisualizer; |
78 //<cmail> |
|
79 class CEUiEmailListTouchManager; |
78 class CEUiEmailListTouchManager; |
80 //</cmail> |
79 class MFSMailIterator; |
81 class CAknStylusPopUpMenu; |
80 class CAknStylusPopUpMenu; |
|
81 |
|
82 /** |
|
83 * CMailListModelUpdater |
|
84 * |
|
85 * Asynchronous mail list updater. |
|
86 * |
|
87 */ |
|
88 class CMailListModelUpdater : public CActive |
|
89 { |
|
90 private: |
|
91 |
|
92 // Updater state |
|
93 enum TState |
|
94 { |
|
95 // Idle state. Updater is doing nothing. |
|
96 EIdle, |
|
97 // Initializing state. Get ready for the update. |
|
98 EInitialize, |
|
99 // Fetching state. Fetch the messages for the model. |
|
100 EFetch, |
|
101 // Finalizing state. Model update done. |
|
102 EFinalize |
|
103 }; |
|
104 |
|
105 public: |
|
106 |
|
107 // Updater observer |
|
108 class MObserver |
|
109 { |
|
110 public: |
|
111 /** |
|
112 * Called when an error has occured. |
|
113 */ |
|
114 virtual void UpdateErrorL(TInt aError) = 0; |
|
115 |
|
116 /** |
|
117 * Called when update begins. |
|
118 */ |
|
119 virtual void UpdateBeginL() = 0; |
|
120 |
|
121 /** |
|
122 * Called when new messages fetched. |
|
123 */ |
|
124 virtual void UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages) = 0; |
|
125 |
|
126 /** |
|
127 * Called when update is completed. |
|
128 */ |
|
129 virtual void UpdateCompleteL() = 0; |
|
130 |
|
131 /** |
|
132 * Update cancelled. |
|
133 * @param aForceRefresh If ETrue, model will be fully refreshed on next activation. |
|
134 */ |
|
135 virtual void UpdateCancelled(const TBool aForceRefresh) = 0; |
|
136 }; |
|
137 |
|
138 public: |
|
139 |
|
140 /** |
|
141 * Constructor |
|
142 */ |
|
143 CMailListModelUpdater(); |
|
144 |
|
145 /** |
|
146 * Destructor |
|
147 */ |
|
148 ~CMailListModelUpdater(); |
|
149 |
|
150 public: |
|
151 |
|
152 /** |
|
153 * Reference to sorting criteria array. |
|
154 */ |
|
155 RArray<TFSMailSortCriteria>& Sorting(); |
|
156 |
|
157 /** |
|
158 * Update model. |
|
159 */ |
|
160 void UpdateModelL(MObserver& aObserver, MFSMailIterator* aIterator); |
|
161 |
|
162 /** |
|
163 * Returns ETrue if updating. |
|
164 */ |
|
165 TBool IsUpdating() const; |
|
166 |
|
167 public: // from CActive |
|
168 |
|
169 /** |
|
170 * @see CActive::RunL |
|
171 */ |
|
172 void RunL(); |
|
173 |
|
174 /** |
|
175 * @see CActive::DoCancel |
|
176 */ |
|
177 void DoCancel(); |
|
178 |
|
179 private: |
|
180 |
|
181 /** |
|
182 * Signal self with given error code and set a new state. |
|
183 */ |
|
184 void Signal(TState aState, TInt aError = KErrNone); |
|
185 |
|
186 /** |
|
187 * Initialize update. |
|
188 */ |
|
189 void InitializeL(); |
|
190 |
|
191 /** |
|
192 * Fetch one step. |
|
193 */ |
|
194 void FetchL(); |
|
195 |
|
196 /** |
|
197 * Finalize update. |
|
198 */ |
|
199 void FinalizeL(); |
|
200 |
|
201 /** |
|
202 * Reset to uninitialized state. |
|
203 */ |
|
204 void Reset(); |
|
205 |
|
206 private: |
|
207 |
|
208 RArray<TFSMailSortCriteria> iSorting; |
|
209 TFSMailMsgId iId; |
|
210 TState iState; |
|
211 TInt iItemsFetched; |
|
212 MObserver* iObserver; |
|
213 MFSMailIterator* iIterator; |
|
214 TFsTreeItemId iParentId; |
|
215 TInt iBlockSize; |
|
216 }; |
82 |
217 |
83 struct SMailListItem |
218 struct SMailListItem |
84 { |
219 { |
85 TFsTreeItemId iListItemId; |
220 TFsTreeItemId iListItemId; |
86 MFsTreeItemData* iTreeItemData; |
221 MFsTreeItemData* iTreeItemData; |
120 class CFSEmailUiMailListVisualiser : public CFsEmailUiViewBase, |
255 class CFSEmailUiMailListVisualiser : public CFsEmailUiViewBase, |
121 public MFsControlBarObserver, |
256 public MFsControlBarObserver, |
122 public MFSEmailUiFolderListCallback, |
257 public MFSEmailUiFolderListCallback, |
123 public MFSEmailUiSortListCallback, |
258 public MFSEmailUiSortListCallback, |
124 public MFsTreeListObserver, |
259 public MFsTreeListObserver, |
125 public MFSEmailUiContactHandlerObserver |
260 public MFSEmailUiContactHandlerObserver, |
|
261 public CMailListModelUpdater::MObserver |
126 // </cmail> |
262 // </cmail> |
127 { |
263 { |
128 friend class CMailListUpdater; |
264 friend class CMailListUpdater; |
129 public: |
265 public: |
130 static CFSEmailUiMailListVisualiser* NewL(CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup); |
266 static CFSEmailUiMailListVisualiser* NewL(CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup); |
308 // Refresh funcions |
444 // Refresh funcions |
309 void InsertNewMessagesL( const RArray<TFSMailMsgId>& aMessages ); |
445 void InsertNewMessagesL( const RArray<TFSMailMsgId>& aMessages ); |
310 void InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh ); // ownership is transferred |
446 void InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh ); // ownership is transferred |
311 |
447 |
312 void RefreshListItemsL(); |
448 void RefreshListItemsL(); |
|
449 void RefreshListItemsL(TFsTreeItemId& aLatestNodeId, |
|
450 const TInt aStartIndex, const TInt aEndIndex); |
313 // Refresh the list order only |
451 // Refresh the list order only |
314 void RefreshOrderL(); |
452 void RefreshOrderL(); |
315 |
453 |
316 // To start refreshing asynchronously |
454 // To start refreshing asynchronously |
317 void RefreshDeferred( TFSMailMsgId* aFocusToMessage = NULL ); |
455 void RefreshDeferred( TFSMailMsgId* aFocusToMessage = NULL ); |
323 TFsTreeItemId InsertNodeItemL( TInt aModelIndex, TInt aChildIndex = KErrNotFound, const TBool aAllowRefresh = EFalse ); |
461 TFsTreeItemId InsertNodeItemL( TInt aModelIndex, TInt aChildIndex = KErrNotFound, const TBool aAllowRefresh = EFalse ); |
324 // Create and insert one list item according the given model item. The item is added under the given node. |
462 // Create and insert one list item according the given model item. The item is added under the given node. |
325 // Omitting the argument aChildIdx causes the new item to be appended as last child of the node. |
463 // Omitting the argument aChildIdx causes the new item to be appended as last child of the node. |
326 TFsTreeItemId InsertListItemL( TInt aModelIndex, TFsTreeItemId aParentNodeId, TInt aChildIdx = KErrNotFound, TBool aAllowRefresh = ETrue ); |
464 TFsTreeItemId InsertListItemL( TInt aModelIndex, TFsTreeItemId aParentNodeId, TInt aChildIdx = KErrNotFound, TBool aAllowRefresh = ETrue ); |
327 |
465 |
|
466 // from CMailListModelUpdater::MObserver |
|
467 |
|
468 /** |
|
469 * @see CMailListModelUpdater::MObserver::UpdateErrorL |
|
470 */ |
|
471 void UpdateErrorL(TInt aError); |
|
472 |
|
473 /** |
|
474 * @see CMailListModelUpdater::MObserver::UpdateBeginL |
|
475 */ |
|
476 void UpdateBeginL(); |
|
477 |
|
478 /** |
|
479 * @see CMailListModelUpdater::MObserver::UpdateProgressL |
|
480 */ |
|
481 void UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages); |
|
482 |
|
483 /** |
|
484 * @see CMailListModelUpdater::MObserver::UpdateCompleteL |
|
485 */ |
|
486 void UpdateCompleteL(); |
|
487 |
|
488 /** |
|
489 * @see CMailListModelUpdater::MObserver::UpdateCancelled |
|
490 */ |
|
491 void UpdateCancelled(const TBool aForceRefresh); |
|
492 |
328 // Mail model update |
493 // Mail model update |
|
494 void UpdateMailListModelAsyncL(); |
329 void UpdateMailListModelL(); |
495 void UpdateMailListModelL(); |
330 void CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages ); |
496 void CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages ); |
331 |
497 |
332 // Create title divider model item for the given message. Separator text depends on active sorting mode. |
498 // Create title divider model item for the given message. Separator text depends on active sorting mode. |
333 CFSEmailUiMailListModelItem* CreateSeparatorModelItemLC( CFSMailMessage& aMessage ) const; |
499 CFSEmailUiMailListModelItem* CreateSeparatorModelItemLC( CFSMailMessage& aMessage ) const; |
614 |
780 |
615 TBool iShowReplyAll; |
781 TBool iShowReplyAll; |
616 // Was focus visible in the ListView. |
782 // Was focus visible in the ListView. |
617 TBool iLastFocus; |
783 TBool iLastFocus; |
618 //used to prevent Call application execution (on keyup of call button) when call to contact required |
784 //used to prevent Call application execution (on keyup of call button) when call to contact required |
619 TBool iConsumeStdKeyYes_KeyUp; |
785 TBool iConsumeStdKeyYes_KeyUp; |
|
786 CMailListModelUpdater* iMailListModelUpdater; |
|
787 TBool iForceRefresh; |
620 }; |
788 }; |
621 |
789 |
622 |
790 |
623 // Definition of the mail updater timer. This timer is used for |
791 // Definition of the mail updater timer. This timer is used for |
624 // delayed drawing of the mail list to avoid viewsrv:11 panics. |
792 // delayed drawing of the mail list to avoid viewsrv:11 panics. |