|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file implements classes CFSEmailUiMailListVisualiser, CMailListUpdater, CMsgMovedNoteTimer, CDateChangeTimer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include "emailtrace.h" |
|
21 #include <freestyleemailui.mbg> |
|
22 #include <AknUtils.h> |
|
23 #include <gulicon.h> |
|
24 #include <StringLoader.h> |
|
25 #include <FreestyleEmailUi.rsg> |
|
26 //<cmail> |
|
27 #include <featmgr.h> |
|
28 //</cmail> |
|
29 #include "CFSMailClient.h" |
|
30 #include "CFSMailBox.h" |
|
31 #include "CFSMailFolder.h" |
|
32 #include "fscontrolbar.h" |
|
33 #include "fscontrolbuttoninterface.h" |
|
34 #include "fstreelist.h" |
|
35 #include "fstreevisualizerbase.h" |
|
36 #include "fstreeplainonelinenodedata.h" |
|
37 #include "fstreeplainonelinenodevisualizer.h" |
|
38 #include "fstreeplaintwolineitemdata.h" |
|
39 #include "fstreeplaintwolineitemvisualizer.h" |
|
40 #include "CFSMailCommon.h" |
|
41 #include "ceuiemaillisttouchmanager.h" |
|
42 //</cmail> |
|
43 #include "FSEmailBuildFlags.h" |
|
44 //<cmail> |
|
45 #include "cfsccontactactionmenu.h" |
|
46 #include "mfsccontactactionmenumodel.h" |
|
47 //</cmail> |
|
48 |
|
49 #include <hlplch.h> |
|
50 #include <AknIconArray.h> |
|
51 // <cmail> SF |
|
52 #include <alf/alfdecklayout.h> |
|
53 #include <alf/alfcontrolgroup.h> |
|
54 #include <alf/alfframebrush.h> |
|
55 #include <alf/alfevent.h> |
|
56 #include <alf/alfstatic.h> |
|
57 // </cmail> |
|
58 |
|
59 #include <aknnotewrappers.h> |
|
60 #include <msvapi.h> |
|
61 #include <akntitle.h> |
|
62 //<cmail> |
|
63 #include "ESMailSettingsPluginUids.hrh" |
|
64 #include "ESMailSettingsPlugin.h" |
|
65 #include "MFSMailBrandManager.h" |
|
66 //</cmail> |
|
67 #include <AknWaitDialog.h> |
|
68 // <cmail> |
|
69 #include <aknlayoutscalable_apps.cdl.h> |
|
70 #include <layoutmetadata.cdl.h> |
|
71 #include <csxhelp/cmail.hlp.hrh> |
|
72 // </cmail> |
|
73 // Meeting request |
|
74 #include <MeetingRequestUids.hrh> |
|
75 // <cmail> |
|
76 #include "cesmricalviewer.h" |
|
77 //</cmail> |
|
78 #include <aknstyluspopupmenu.h> |
|
79 |
|
80 // INTERNAL INCLUDES |
|
81 #include "FreestyleEmailUiUtilities.h" |
|
82 #include "FreestyleEmailUiLiterals.h" |
|
83 #include "FreestyleEmailUiLayoutHandler.h" |
|
84 #include "FreestyleEmailUiMailListModel.h" |
|
85 #include "FreestyleEmailUiMailListVisualiser.h" |
|
86 #include "FreestyleEmailUiFileSystemInfo.h" |
|
87 #include "FreestyleEmailUiAppui.h" |
|
88 #include "FreestyleEmailUi.hrh" |
|
89 #include "FreestyleEmailUiTextureManager.h" |
|
90 #include "FreestyleEmailUiMailListControl.h" |
|
91 #include "FreestyleEmailUiMailViewerVisualiser.h" |
|
92 #include "FreestyleEmailUiStatusIndicator.h" |
|
93 #include "FreestyleEmailCenRepHandler.h" |
|
94 #include "FreestyleEmailUiFolderListVisualiser.h" |
|
95 #include "FreestyleEmailUiShortcutBinding.h" |
|
96 #include "FreestyleEmailUiMsgDetailsVisualiser.h" |
|
97 #include "FreestyleEmailDownloadInformationMediator.h" |
|
98 #include "FreestyleEmailUiContactHandler.h" |
|
99 #include "FreestyleEmailUiLauncherGridVisualiser.h" |
|
100 #include "FreestyleEmailUiHtmlViewerView.h" |
|
101 #include "FSDelayedLoader.h" |
|
102 #include "FSEmail.pan" |
|
103 |
|
104 // CONST VALUES |
|
105 const TInt KControlBarTransitionTime = 250; |
|
106 //<cmail> |
|
107 //const TInt KFirstButtonStartPosX = 25; |
|
108 //const TInt KControlBarMailboxIconWidth = 20; |
|
109 //const TInt KControlButtonPosY = 3; |
|
110 //const TInt KControlButtonSeparation = 10; |
|
111 //</cmail> |
|
112 const TInt KMaxPreviewPaneLength = 60; |
|
113 //const TInt KInitialPreviewUpdate = 5; |
|
114 //const TInt KSyncIconTimerDelay = 18000; |
|
115 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
|
116 static const TInt KMsgDeletionWaitNoteAmount = 5; |
|
117 _LIT( KMissingPreviewDataMarker, "..." ); |
|
118 |
|
119 static const TInt KMaxItemsFethed = 1000; |
|
120 static const TInt KCMsgBlock = 100; |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // Static constructor. |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CFSEmailUiMailListVisualiser* CFSEmailUiMailListVisualiser::NewL(CAlfEnv& aEnv, |
|
127 CFreestyleEmailUiAppUi* aAppUi, |
|
128 CAlfControlGroup& aMailListControlGroup ) |
|
129 { |
|
130 FUNC_LOG; |
|
131 CFSEmailUiMailListVisualiser* self = CFSEmailUiMailListVisualiser::NewLC(aEnv, aAppUi, aMailListControlGroup ); |
|
132 CleanupStack::Pop(self); |
|
133 return self; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Static constructor. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 CFSEmailUiMailListVisualiser* CFSEmailUiMailListVisualiser::NewLC(CAlfEnv& aEnv, |
|
141 CFreestyleEmailUiAppUi* aAppUi, |
|
142 CAlfControlGroup& aMailListControlGroup) |
|
143 { |
|
144 FUNC_LOG; |
|
145 CFSEmailUiMailListVisualiser* self = |
|
146 new (ELeave) CFSEmailUiMailListVisualiser( aEnv, aAppUi, aMailListControlGroup ); |
|
147 CleanupStack::PushL( self ); |
|
148 self->ConstructL(); |
|
149 return self; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // Second phase constructor. |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CFSEmailUiMailListVisualiser::ConstructL() |
|
157 { |
|
158 FUNC_LOG; |
|
159 |
|
160 BaseConstructL( R_FSEMAILUI_MAIL_LIST_VIEW ); |
|
161 |
|
162 // Don't construct this anywhere else than here. |
|
163 // Don't delete this until in the destructor to avoid NULL checks. |
|
164 iModel = CFSEmailUiMailListModel::NewL( &iAppUi ); |
|
165 |
|
166 // Set list as initial focused control |
|
167 iFocusedControl = EMailListComponent; |
|
168 iThisViewActive = EFalse; |
|
169 iSkinChanged = EFalse; |
|
170 |
|
171 iFirstStartCompleted = EFalse; |
|
172 |
|
173 iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard ); |
|
174 iAsyncRedrawer = new (ELeave) CAsyncCallBack( CActive::EPriorityLow ); |
|
175 } |
|
176 |
|
177 // CFSEmailUiMailListVisualiser::DoFirstStartL() |
|
178 // Purpose of this function is to do first start things only when list is |
|
179 // really needed to be shown. Implemented to make app startuo faster. |
|
180 void CFSEmailUiMailListVisualiser::DoFirstStartL() |
|
181 { |
|
182 FUNC_LOG; |
|
183 // Create mail list updater timer |
|
184 iMailListUpdater = CMailListUpdater::NewL( this ); |
|
185 |
|
186 // Set initial sort criteria |
|
187 iCurrentSortCriteria.iField = EFSMailSortByDate; |
|
188 iCurrentSortCriteria.iOrder = EFSMailDescending; |
|
189 |
|
190 // Create screen control and anchor layout |
|
191 iMailListControl = CFreestyleEmailUiMailListControl::NewL( iEnv, this ); |
|
192 iScreenAnchorLayout = CAlfAnchorLayout::AddNewL( *iMailListControl ); |
|
193 iScreenAnchorLayout->SetFlags(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
194 |
|
195 //<cmail> |
|
196 iTouchManager = CEUiEmailListTouchManager::NewL(*this); |
|
197 //</cmail> |
|
198 |
|
199 // Create control bar control and append to control group and anchor layout |
|
200 iControlBarControl = CFsControlBar::NewL( iEnv ); |
|
201 iControlBarControl->AddObserverL( *this ); |
|
202 //<cmail> |
|
203 iControlBarControl->AddObserverL( *iTouchManager ); |
|
204 //</cmail> |
|
205 |
|
206 CreateControlBarLayoutL(); |
|
207 SetMailListLayoutAnchors(); |
|
208 |
|
209 iControlBarControl->SetSelectorTransitionTimeL( KControlBarTransitionTime ); |
|
210 iControlBarControl->ClearBackgroundColor(); |
|
211 iControlBarLayout = CAlfDeckLayout::AddNewL( *iControlBarControl, iScreenAnchorLayout ); |
|
212 iControlBarVisual = iControlBarControl->Visual(); |
|
213 |
|
214 // Create list and append to control group and anchor layout |
|
215 |
|
216 iListLayout = CAlfDeckLayout::AddNewL( *iMailListControl, iScreenAnchorLayout ); |
|
217 iMailTreeListVisualizer = CFsTreeVisualizerBase::NewL(iMailListControl, *iListLayout); |
|
218 iMailTreeListVisualizer->SetFlipState( iKeyboardFlipOpen ); |
|
219 iMailTreeListVisualizer->SetFocusVisibility( iFocusVisible ); |
|
220 iMailList = CFsTreeList::NewL(*iMailTreeListVisualizer, iEnv ); |
|
221 |
|
222 // Set mark type and icon |
|
223 iMailList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable ); |
|
224 iMailList->SetIndentationL(0); |
|
225 |
|
226 //<cmail> Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in |
|
227 // opposite order. |
|
228 ControlGroup().AppendL( iMailListControl ); |
|
229 ControlGroup().AppendL( iControlBarControl ); |
|
230 ControlGroup().AppendL( iMailList->TreeControl() ); |
|
231 //</cmail> |
|
232 |
|
233 iTreeItemArray.Reset(); |
|
234 |
|
235 // Set empty text |
|
236 HBufC* emptyText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_EMPTY_MSG_LIST_TEXT ); |
|
237 iMailTreeListVisualizer->SetEmptyListTextL( *emptyText ); |
|
238 CleanupStack::PopAndDestroy( emptyText ); |
|
239 |
|
240 TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
241 iMailTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor ); |
|
242 |
|
243 // Set page up and page down keys |
|
244 iMailTreeListVisualizer->AddCustomPageUpKey( EStdKeyPageUp ); |
|
245 iMailTreeListVisualizer->AddCustomPageDownKey( EStdKeyPageDown ); |
|
246 |
|
247 // Set selector brushes |
|
248 CAlfBrush* listSelectorBrush = iAppUi.FsTextureManager()->ListSelectorBrushL(); // not owned |
|
249 iMailTreeListVisualizer->SetSelectorPropertiesL( listSelectorBrush, 1.0, CFsTreeVisualizerBase::EFsSelectorMoveSmoothly ); |
|
250 |
|
251 CAlfBrush* cbSelectorBrush = iAppUi.FsTextureManager()->NewCtrlBarSelectorBrushLC(); |
|
252 iControlBarControl->SetSelectorImageL( cbSelectorBrush ); |
|
253 CleanupStack::Pop( cbSelectorBrush ); // ownership transferred to control bar |
|
254 |
|
255 // Set menu, mark and background icons |
|
256 iMailTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) ); |
|
257 iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) ); |
|
258 //<cmail> s60 skin support |
|
259 //iMailTreeListVisualizer->SetBackgroundTextureL( iAppUi.FsTextureManager()->TextureByIndex( EBackgroundTextureMailList ) ); |
|
260 //</cmail> |
|
261 iMailList->AddObserverL( *this ); |
|
262 //<cmail> |
|
263 iMailList->AddObserverL( *iTouchManager ); |
|
264 //</cmail> |
|
265 // Initializing the default stylus long tap popup menu |
|
266 if( !iStylusPopUpMenu ) |
|
267 { |
|
268 TPoint point( 0, 0 ); |
|
269 iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this , point ); |
|
270 TResourceReader reader; |
|
271 iCoeEnv->CreateResourceReaderLC( reader, |
|
272 R_STYLUS_POPUP_MENU_MESSAGE_LIST_VIEW ); |
|
273 iStylusPopUpMenu->ConstructFromResourceL( reader ); |
|
274 CleanupStack::PopAndDestroy(); |
|
275 } |
|
276 |
|
277 iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iMailList ); |
|
278 |
|
279 iDateChangeTimer = CDateChangeTimer::NewL( *this ); |
|
280 iDateChangeTimer->Start(); |
|
281 |
|
282 UpdateMailListSettingsL(); |
|
283 |
|
284 iMailList->SetIndentationL(0); |
|
285 iMailList->SetLoopingType( EFsTreeListLoopingDisabled ); |
|
286 iMailTreeListVisualizer->SetItemExpansionDelay( iAppUi.LayoutHandler()->ListItemExpansionDelay() ); |
|
287 iMailList->SetScrollTime( iAppUi.LayoutHandler()->ListScrollingTime(), 0.5 ); |
|
288 |
|
289 iFirstStartCompleted = ETrue; |
|
290 } |
|
291 |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // Constructor. |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 CFSEmailUiMailListVisualiser::CFSEmailUiMailListVisualiser( CAlfEnv& aEnv, |
|
298 CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup ) |
|
299 : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ), |
|
300 iEnv( aEnv ), |
|
301 iListMarkItemsState( ETrue ), //Initlly list has no markings |
|
302 iMoveToFolderOngoing( EFalse ) |
|
303 { |
|
304 FUNC_LOG; |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------------------------- |
|
308 // Destructor. |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 CFSEmailUiMailListVisualiser::~CFSEmailUiMailListVisualiser() |
|
312 { |
|
313 FUNC_LOG; |
|
314 //<cmail> |
|
315 if ( iMailFolder ) |
|
316 { |
|
317 delete iMailFolder; |
|
318 iMailFolder = NULL; |
|
319 } |
|
320 |
|
321 delete iTouchManager; |
|
322 delete iStylusPopUpMenu; |
|
323 //</cmail> |
|
324 delete iMailList; |
|
325 |
|
326 // Don't construct this anywhere else than in constructor. |
|
327 // Don't delete anywhere else thatn here to avoid NULL checks. |
|
328 delete iModel; |
|
329 } |
|
330 |
|
331 void CFSEmailUiMailListVisualiser::PrepareForExit() |
|
332 { |
|
333 FUNC_LOG; |
|
334 if ( iMsgNoteTimer ) |
|
335 { |
|
336 iMsgNoteTimer->Cancel(); |
|
337 delete iMsgNoteTimer; |
|
338 iMsgNoteTimer = NULL; |
|
339 } |
|
340 if ( iDateChangeTimer ) |
|
341 { |
|
342 iDateChangeTimer->Cancel(); |
|
343 delete iDateChangeTimer; |
|
344 iDateChangeTimer = NULL; |
|
345 } |
|
346 if ( iMailListUpdater ) |
|
347 { |
|
348 iMailListUpdater->Stop(); |
|
349 delete iMailListUpdater; |
|
350 iMailListUpdater = NULL; |
|
351 } |
|
352 if ( iAsyncRedrawer ) |
|
353 { |
|
354 iAsyncRedrawer->Cancel(); |
|
355 delete iAsyncRedrawer; |
|
356 iAsyncRedrawer = NULL; |
|
357 } |
|
358 if ( iAsyncCallback ) |
|
359 { |
|
360 iAsyncCallback->Cancel(); |
|
361 delete iAsyncCallback; |
|
362 iAsyncCallback = NULL; |
|
363 } |
|
364 if ( iMailList ) |
|
365 { |
|
366 iMailList->RemoveObserver( *this ); |
|
367 } |
|
368 if ( iControlBarControl ) |
|
369 { |
|
370 iControlBarControl->RemoveObserver( *this ); |
|
371 } |
|
372 // <cmail> |
|
373 iTreeItemArray.Reset(); |
|
374 if ( iMailFolder ) |
|
375 { |
|
376 delete iMailFolder; |
|
377 iMailFolder = NULL; |
|
378 } |
|
379 // Reset, not delete to avoid NULL checks. |
|
380 iModel->Reset(); |
|
381 // </cmail> |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // Returns reference to mail list. |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 CFsTreeList& CFSEmailUiMailListVisualiser::GetMailList() |
|
389 { |
|
390 FUNC_LOG; |
|
391 return *iMailList; |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 // |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 void CFSEmailUiMailListVisualiser::UpdateMailListModelL() |
|
400 { |
|
401 FUNC_LOG; |
|
402 // Reset model with each update |
|
403 iModel->Reset(); |
|
404 |
|
405 if ( iMailFolder ) |
|
406 { |
|
407 // Update folder if provided, otherwise use current folder |
|
408 RPointerArray<CFSMailMessage> folderMessages( KCMsgBlock ); |
|
409 CleanupClosePushL( folderMessages ); |
|
410 |
|
411 RPointerArray<CFSMailMessage> tempFolderMessages( KCMsgBlock ); |
|
412 CleanupClosePushL( tempFolderMessages ); |
|
413 |
|
414 TFSMailDetails details( EFSMsgDataEnvelope ); |
|
415 RArray<TFSMailSortCriteria> sorting; |
|
416 CleanupClosePushL( sorting ); |
|
417 sorting.Append( iCurrentSortCriteria ); |
|
418 if ( iCurrentSortCriteria.iField != EFSMailSortByDate ) |
|
419 { |
|
420 // Add date+descending as secondary sort criteria if primary field is something else than date |
|
421 TFSMailSortCriteria secondarySortCriteria; |
|
422 secondarySortCriteria.iField = EFSMailSortByDate; |
|
423 secondarySortCriteria.iOrder = EFSMailDescending; |
|
424 sorting.Append( secondarySortCriteria ); |
|
425 } |
|
426 |
|
427 // List all or maximum number of messages |
|
428 MFSMailIterator* iterator = iMailFolder->ListMessagesL( details, sorting ); |
|
429 CleanupDeletePushL( iterator ); // standard CleanupStack::PushL does not work with non-C-class pointer |
|
430 |
|
431 // Use iterator to get messages in peaces of KCMsgBlock to avoid OOM in FSStore |
|
432 TFSMailMsgId dummy; |
|
433 TBool moreMessagesToFollow = iterator->NextL( dummy, KCMsgBlock, folderMessages ); |
|
434 for ( TInt i = KCMsgBlock; i < KMaxItemsFethed && moreMessagesToFollow ; i += KCMsgBlock ) |
|
435 { |
|
436 tempFolderMessages.Reset(); |
|
437 moreMessagesToFollow = iterator->NextL( folderMessages[i-1]->GetMessageId(), KCMsgBlock, tempFolderMessages ); |
|
438 for ( TInt a=0 ; a<tempFolderMessages.Count() ; a++) |
|
439 { |
|
440 folderMessages.Append(tempFolderMessages[a]); |
|
441 } |
|
442 } |
|
443 |
|
444 CleanupStack::PopAndDestroy( iterator ); |
|
445 CleanupStack::PopAndDestroy( &sorting ); |
|
446 |
|
447 // Update mail list model based on sorting criteria |
|
448 CreateModelItemsL( folderMessages ); |
|
449 |
|
450 CleanupStack::PopAndDestroy( &tempFolderMessages ); |
|
451 CleanupStack::PopAndDestroy( &folderMessages ); |
|
452 } |
|
453 } |
|
454 |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // CreateModelItemsL |
|
458 // This function creates model items for the given messages and appends them |
|
459 // to the model. Also title divider items are created when necessary. |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CFSEmailUiMailListVisualiser::CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages ) |
|
463 { |
|
464 FUNC_LOG; |
|
465 // New Items |
|
466 CFSEmailUiMailListModelItem* newItem(NULL); |
|
467 |
|
468 // Draw first separator if there are messages. |
|
469 if ( aMessages.Count() && iNodesInUse == EListControlSeparatorEnabled ) |
|
470 { |
|
471 newItem = CreateSeparatorModelItemLC( *aMessages[0] ); |
|
472 iModel->AppendL( newItem ); |
|
473 CleanupStack::Pop( newItem ); |
|
474 } |
|
475 |
|
476 // Start appending items |
|
477 for (int i = 0; i < aMessages.Count(); i++) |
|
478 { |
|
479 CFSMailMessage* curMessage = aMessages[i]; |
|
480 if ( curMessage ) |
|
481 { |
|
482 newItem = CFSEmailUiMailListModelItem::NewL( curMessage, ETypeMailItem ); |
|
483 CleanupStack::PushL( newItem ); |
|
484 iModel->AppendL( newItem ); |
|
485 CleanupStack::Pop( newItem ); |
|
486 |
|
487 // Append new separator if needed |
|
488 if ( i != aMessages.Count()-1 && iNodesInUse == EListControlSeparatorEnabled ) |
|
489 { |
|
490 CFSMailMessage* nextMessage = aMessages[i+1]; // This msg is next in the list |
|
491 |
|
492 if ( nextMessage ) |
|
493 { |
|
494 TBool needANewDivider = |
|
495 !MessagesBelongUnderSameSeparatorL( *curMessage, *nextMessage ); |
|
496 if ( needANewDivider ) |
|
497 { |
|
498 newItem = CreateSeparatorModelItemLC( *nextMessage ); |
|
499 iModel->AppendL( newItem ); |
|
500 CleanupStack::Pop( newItem ); |
|
501 } |
|
502 } |
|
503 } |
|
504 } |
|
505 } |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // CreateSeparatorModelItemLC |
|
510 // Create separator model item for the given message. Separator text depends |
|
511 // on active sorting mode. |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 CFSEmailUiMailListModelItem* CFSEmailUiMailListVisualiser::CreateSeparatorModelItemLC( CFSMailMessage& aMessage ) const |
|
515 { |
|
516 FUNC_LOG; |
|
517 CFSEmailUiMailListModelItem* separator = |
|
518 CFSEmailUiMailListModelItem::NewL( &aMessage, ETypeSeparator ); |
|
519 CleanupStack::PushL( separator ); |
|
520 |
|
521 HBufC* separatorText = NULL; |
|
522 |
|
523 switch ( iCurrentSortCriteria.iField ) |
|
524 { |
|
525 case EFSMailSortByFlagStatus: |
|
526 { |
|
527 if ( aMessage.IsFlagSet( EFSMsgFlag_FollowUp ) ) |
|
528 { |
|
529 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_FOLLOW_UP ); |
|
530 } |
|
531 else if ( aMessage.IsFlagSet( EFSMsgFlag_FollowUpComplete ) ) |
|
532 { |
|
533 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_FLAG_COMPLETE ); |
|
534 } |
|
535 else |
|
536 { |
|
537 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_NO_FLAG ); |
|
538 } |
|
539 } |
|
540 break; |
|
541 case EFSMailSortByPriority: |
|
542 { |
|
543 if ( aMessage.IsFlagSet( EFSMsgFlag_Important ) ) |
|
544 { |
|
545 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_PRIO_HIGH ); |
|
546 } |
|
547 else if ( aMessage.IsFlagSet( EFSMsgFlag_Low ) ) |
|
548 { |
|
549 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_PRIO_LOW ); |
|
550 } |
|
551 else |
|
552 { |
|
553 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_PRIO_NORMAL ); |
|
554 } |
|
555 } |
|
556 break; |
|
557 case EFSMailSortByRecipient: |
|
558 case EFSMailSortBySender: |
|
559 { |
|
560 TInt folderType(EFSInbox); |
|
561 if( iMailFolder ) |
|
562 { |
|
563 folderType = iMailFolder->GetFolderType(); |
|
564 } |
|
565 TBool useRecipient = ( folderType == EFSSentFolder || |
|
566 folderType == EFSDraftsFolder || |
|
567 folderType == EFSOutbox ); |
|
568 |
|
569 CFSMailAddress* fromAddress(0); |
|
570 // Check address based on whether we are using recipient or sender sort |
|
571 if ( useRecipient ) |
|
572 { |
|
573 RPointerArray<CFSMailAddress>& toArray = aMessage.GetToRecipients(); |
|
574 if ( toArray.Count() ) |
|
575 { |
|
576 fromAddress = toArray[0]; |
|
577 } |
|
578 } |
|
579 else |
|
580 { |
|
581 fromAddress = aMessage.GetSender(); |
|
582 } |
|
583 TDesC* diplayName(0); |
|
584 if ( fromAddress ) |
|
585 { |
|
586 diplayName = &fromAddress->GetDisplayName(); |
|
587 } |
|
588 |
|
589 if ( fromAddress && diplayName && diplayName->Length() != 0 ) |
|
590 { |
|
591 separatorText = diplayName->AllocLC(); |
|
592 } |
|
593 else if ( fromAddress && fromAddress->GetEmailAddress().Length() != 0 ) |
|
594 { |
|
595 separatorText = fromAddress->GetEmailAddress().AllocLC(); |
|
596 } |
|
597 else |
|
598 { |
|
599 if ( useRecipient ) |
|
600 { |
|
601 separatorText = KNullDesC().AllocLC(); |
|
602 } |
|
603 else |
|
604 { |
|
605 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_MSG_DETAILS_NO_SENDER_INFO_AVAILABLE ); |
|
606 } |
|
607 } |
|
608 // Get rid of possible unwanted characters in display name |
|
609 if ( separatorText ) |
|
610 { |
|
611 TFsEmailUiUtility::StripDisplayName( *separatorText ); |
|
612 } |
|
613 } |
|
614 break; |
|
615 case EFSMailSortByAttachment: |
|
616 { |
|
617 if ( aMessage.IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
618 { |
|
619 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_ATTACHMENTS ); |
|
620 } |
|
621 else |
|
622 { |
|
623 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_NO_ATTACHMENTS ); |
|
624 } |
|
625 } |
|
626 break; |
|
627 case EFSMailSortByUnread: |
|
628 { |
|
629 if ( aMessage.IsFlagSet( EFSMsgFlag_Read ) ) |
|
630 { |
|
631 separatorText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SEPARATOR_READ_MSGS ); |
|
632 } |
|
633 else |
|
634 { |
|
635 separatorText = StringLoader::LoadLC(R_FREESTYLE_EMAIL_UI_SEPARATOR_UNREAD_MSGS); |
|
636 } |
|
637 } |
|
638 break; |
|
639 case EFSMailSortBySubject: |
|
640 { |
|
641 separatorText = TFsEmailUiUtility::CreateSubjectWithoutLocalisedPrefixLC( &aMessage ); |
|
642 } |
|
643 break; |
|
644 case EFSMailSortByDate: |
|
645 { |
|
646 TBool eventToday = EFalse; |
|
647 TBool eventYesterday = EFalse; |
|
648 HBufC* weekDay = TFsEmailUiUtility::WeekDayTextFromMsgLC( &aMessage, ETrue, EFalse, eventToday, eventYesterday ); |
|
649 if ( eventToday || eventYesterday ) |
|
650 { |
|
651 separatorText = weekDay; |
|
652 } |
|
653 else |
|
654 { |
|
655 HBufC* dateTextFromMsg = TFsEmailUiUtility::DateTextFromMsgLC( &aMessage ); |
|
656 separatorText = HBufC::NewL( weekDay->Length() + |
|
657 KSpace().Length() + |
|
658 dateTextFromMsg->Length() ); |
|
659 separatorText->Des().Append( *weekDay ); |
|
660 separatorText->Des().Append( KSpace ); |
|
661 separatorText->Des().Append( *dateTextFromMsg ); |
|
662 CleanupStack::PopAndDestroy( dateTextFromMsg ); |
|
663 CleanupStack::PopAndDestroy( weekDay ); |
|
664 CleanupStack::PushL( separatorText ); |
|
665 } |
|
666 } |
|
667 break; |
|
668 default: |
|
669 { |
|
670 separatorText = KNullDesC().AllocLC(); |
|
671 } |
|
672 break; |
|
673 } |
|
674 |
|
675 separator->SetSeparatorTextL( *separatorText ); |
|
676 CleanupStack::PopAndDestroy( separatorText ); |
|
677 |
|
678 return separator; |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // MessagesBelongUnderSameSeparatorL |
|
683 // Checks if the given messages belong under the same title divider. This |
|
684 // depends on the currect sorting mode. |
|
685 // --------------------------------------------------------------------------- |
|
686 // |
|
687 TBool CFSEmailUiMailListVisualiser::MessagesBelongUnderSameSeparatorL( |
|
688 const CFSMailMessage& aMessage1, |
|
689 const CFSMailMessage& aMessage2 ) const |
|
690 { |
|
691 FUNC_LOG; |
|
692 return CFSEmailUiMailListModel::MessagesBelongUnderSameSeparatorL( aMessage1, |
|
693 aMessage2, |
|
694 iCurrentSortCriteria.iField ); |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // InsertNewMessagesL |
|
699 // Gets new message items from the framework using the given IDs and inserts |
|
700 // them in the correct place within the mail list. Both model and tree list |
|
701 // are updated during this function. |
|
702 // --------------------------------------------------------------------------- |
|
703 // |
|
704 void CFSEmailUiMailListVisualiser::InsertNewMessagesL( const RArray<TFSMailMsgId>& aMessages ) |
|
705 { |
|
706 FUNC_LOG; |
|
707 iModel->SetSortCriteria( iCurrentSortCriteria ); |
|
708 |
|
709 // Do complete refresh in case the list is not currently correctly ordered |
|
710 // (alternatively, we could first reorder the existing items and then insert |
|
711 // the new ones) |
|
712 if ( iListOrderMayBeOutOfDate ) |
|
713 { |
|
714 if ( iMailListUpdater ) |
|
715 { |
|
716 if ( iMailListUpdater->IsActive() ) |
|
717 { |
|
718 iMailListUpdater->Stop(); |
|
719 } |
|
720 iMailListUpdater->StartL(); |
|
721 } |
|
722 } |
|
723 // Otherwise, just add the new items to correct places. |
|
724 else |
|
725 { |
|
726 // Set extended status before inserting messages |
|
727 SetMailListItemsExtendedL(); |
|
728 TInt count(0); |
|
729 count = aMessages.Count(); |
|
730 for ( TInt i = 0 ; i < count ; ++i ) |
|
731 { |
|
732 // Make sure we don't add duplicate items. |
|
733 TInt existingIdx = ItemIndexFromMessageId( aMessages[i] ); |
|
734 if ( existingIdx < 0 ) |
|
735 { |
|
736 CFSMailMessage* msgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
|
737 iMailFolder->GetFolderId(), |
|
738 aMessages[i] , |
|
739 EFSMsgDataEnvelope ); |
|
740 if (msgPtr == NULL) |
|
741 { |
|
742 User::Leave(KErrNotFound); |
|
743 } |
|
744 CleanupStack::PushL( msgPtr ); |
|
745 //first item - show scrollbar |
|
746 //last item - updete scrollbar |
|
747 TBool allowRefresh = ( i == 0 || i == count - 1 ); |
|
748 InsertNewMessageL( msgPtr, allowRefresh ); |
|
749 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
|
750 } |
|
751 } |
|
752 } |
|
753 } |
|
754 |
|
755 // --------------------------------------------------------------------------- |
|
756 // InsertNewMessageL |
|
757 // Creates a single new message item to the model and tree list from the given |
|
758 // message pointer. Ownership of the message is transferred. Also new |
|
759 // separator item is created if necessary. |
|
760 // --------------------------------------------------------------------------- |
|
761 // |
|
762 void CFSEmailUiMailListVisualiser::InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh ) |
|
763 { |
|
764 FUNC_LOG; |
|
765 // Use simple heuristic rule: if the first item is highlighted before the new |
|
766 // item is added, the highlight is forced to remain on the (possibly new) first |
|
767 // item. Otherwise the highligh stays on the same item as before. |
|
768 TBool firstItemWasFocused = |
|
769 ( iTreeItemArray.Count() && iTreeItemArray[0].iListItemId == iMailList->FocusedItem() ); |
|
770 |
|
771 CFSEmailUiMailListModelItem* newItem = |
|
772 CFSEmailUiMailListModelItem::NewLC( aNewMessage, ETypeMailItem ); |
|
773 TInt idx = KErrNotFound; |
|
774 TFsTreeItemId parentId = KFsTreeRootID; |
|
775 TInt childIdx = KErrNotFound; |
|
776 |
|
777 if ( !iNodesInUse ) |
|
778 { |
|
779 // Simple case: nodes are not in use. Just insert to correct place under root node. |
|
780 idx = iModel->GetInsertionPointL( *newItem ); |
|
781 childIdx = idx; |
|
782 } |
|
783 else |
|
784 { |
|
785 // More complicated case: nodes are in use. |
|
786 TInt parentIdx = KErrNotFound; |
|
787 idx = iModel->GetInsertionPointL( *newItem, childIdx, parentIdx ); |
|
788 |
|
789 CFSEmailUiMailListModelItem* parentNode = NULL; |
|
790 if ( parentIdx < 0 ) |
|
791 { |
|
792 // Suitable parent node for the new item was not found and has to be created. |
|
793 parentNode = CreateSeparatorModelItemLC( *aNewMessage ); |
|
794 iModel->InsertL( parentNode, idx ); |
|
795 CleanupStack::Pop( parentNode ); |
|
796 idx++; // The originally found index was used for the new node and the new item will reside in the next index |
|
797 |
|
798 // To insert the node item to the tree list, we need to figure out the index of the |
|
799 // new node under the root node. If the new item is not the last item in the list, |
|
800 // then the insertion location currently contains the node in front of which the new |
|
801 // node is inserted. |
|
802 if ( idx == iModel->Count() ) |
|
803 { |
|
804 InsertNodeItemL( idx-1, KErrNotFound, aAllowRefresh ); // append |
|
805 } |
|
806 else |
|
807 { |
|
808 CFSEmailUiMailListModelItem* nextNode = |
|
809 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(idx) ); |
|
810 TFsTreeItemId nextNodeId = nextNode->CorrespondingListId(); |
|
811 TInt nodeIdxUnderRoot = iMailList->ChildIndex( KFsTreeRootID, nextNodeId ); |
|
812 InsertNodeItemL( idx-1, nodeIdxUnderRoot, aAllowRefresh ); |
|
813 } |
|
814 } |
|
815 else |
|
816 { |
|
817 // Suitable parent node exists and was found |
|
818 parentNode = static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(parentIdx) ); |
|
819 } |
|
820 parentId = parentNode->CorrespondingListId(); |
|
821 } |
|
822 |
|
823 // Insert the model item |
|
824 iModel->InsertL( newItem, idx ); |
|
825 CleanupStack::Pop( newItem ); |
|
826 |
|
827 // Insert the tree list item |
|
828 InsertListItemL( idx, parentId, childIdx, aAllowRefresh ); |
|
829 |
|
830 // Move focus after insertion if necessary |
|
831 if ( firstItemWasFocused ) |
|
832 { |
|
833 TFsTreeItemId firstItemId = iMailList->Child( KFsTreeRootID, 0 ); |
|
834 TFsTreeItemId focusedId = iMailList->FocusedItem(); |
|
835 |
|
836 if ( firstItemId != focusedId ) |
|
837 { |
|
838 // Set the first item as focused and set |
|
839 // list/ctrl bar focus according iFocusedControl |
|
840 // <cmail> |
|
841 //iMailList->SetFocusedItemL( firstItemId ); |
|
842 iMailTreeListVisualizer->SetFocusedItemL( firstItemId, EFalse ); |
|
843 // </cmail> |
|
844 SetListAndCtrlBarFocusL(); |
|
845 } |
|
846 } |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------------------------- |
|
850 // HighlightedIndex |
|
851 // This function return highlighted inxed |
|
852 // --------------------------------------------------------------------------- |
|
853 // |
|
854 TInt CFSEmailUiMailListVisualiser::HighlightedIndex() const |
|
855 { |
|
856 FUNC_LOG; |
|
857 TFsTreeItemId focusedId = static_cast<TFsTreeItemId>( iMailList->FocusedItem() ); |
|
858 // Map id to the index in model |
|
859 TInt ret( KErrNotFound ); |
|
860 if ( focusedId != KFsTreeNoneID ) |
|
861 { |
|
862 for ( TInt i=0; i<iTreeItemArray.Count();i++ ) |
|
863 { |
|
864 if ( focusedId == iTreeItemArray[i].iListItemId ) |
|
865 { |
|
866 ret = i; |
|
867 break; |
|
868 } |
|
869 } |
|
870 } |
|
871 return ret; |
|
872 } |
|
873 |
|
874 // --------------------------------------------------------------------------- |
|
875 // HighlightedIndex |
|
876 // Use this function to set highlighted inxed |
|
877 // --------------------------------------------------------------------------- |
|
878 // |
|
879 void CFSEmailUiMailListVisualiser::SetHighlightedIndexL( TInt aWantedIndex ) |
|
880 { |
|
881 FUNC_LOG; |
|
882 if ( aWantedIndex >= 0 ) |
|
883 { |
|
884 iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[aWantedIndex].iListItemId ); |
|
885 } |
|
886 } |
|
887 |
|
888 // --------------------------------------------------------------------------- |
|
889 // |
|
890 // |
|
891 // --------------------------------------------------------------------------- |
|
892 // |
|
893 TInt CFSEmailUiMailListVisualiser::NewEmailsInModelL() const |
|
894 { |
|
895 FUNC_LOG; |
|
896 // <cmail> |
|
897 TInt newCount(0); |
|
898 for ( TInt i=0; i<iModel->Count();i++) |
|
899 { |
|
900 CFSEmailUiMailListModelItem* item = |
|
901 static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
|
902 if ( item->ModelItemType() == ETypeMailItem ) |
|
903 { |
|
904 if ( !item->MessagePtr().IsFlagSet(EFSMsgFlag_Read) ) |
|
905 { |
|
906 newCount++; |
|
907 } |
|
908 } |
|
909 } |
|
910 return newCount; |
|
911 // </cmail> |
|
912 } |
|
913 |
|
914 // --------------------------------------------------------------------------- |
|
915 // |
|
916 // |
|
917 // --------------------------------------------------------------------------- |
|
918 // |
|
919 TInt CFSEmailUiMailListVisualiser::EmailsInModelL() const |
|
920 { |
|
921 FUNC_LOG; |
|
922 // <cmail> |
|
923 TInt ret(0); |
|
924 for ( TInt i=0; i<iModel->Count(); i++ ) |
|
925 { |
|
926 CFSEmailUiMailListModelItem* item = |
|
927 static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
|
928 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
929 { |
|
930 ret++; |
|
931 } |
|
932 } |
|
933 return ret; |
|
934 // </cmail> |
|
935 } |
|
936 |
|
937 |
|
938 // --------------------------------------------------------------------------- |
|
939 // |
|
940 // |
|
941 // --------------------------------------------------------------------------- |
|
942 // |
|
943 TUid CFSEmailUiMailListVisualiser::Id() const |
|
944 { |
|
945 FUNC_LOG; |
|
946 return MailListId; |
|
947 } |
|
948 |
|
949 // --------------------------------------------------------------------------- |
|
950 // |
|
951 // |
|
952 // --------------------------------------------------------------------------- |
|
953 // |
|
954 // <cmail> Toolbar |
|
955 /*void CFSEmailUiMailListVisualiser::DoActivateL(const TVwsViewId& aPrevViewId, |
|
956 TUid aCustomMessageId, |
|
957 const TDesC8& aCustomMessage)*/ |
|
958 // </cmail> Toolbar |
|
959 void CFSEmailUiMailListVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId, |
|
960 TUid aCustomMessageId, |
|
961 const TDesC8& aCustomMessage) |
|
962 { |
|
963 FUNC_LOG; |
|
964 iShowReplyAll = EFalse; |
|
965 |
|
966 if ( !iFirstStartCompleted ) |
|
967 { |
|
968 DoFirstStartL(); |
|
969 } |
|
970 |
|
971 // Make sure that pending popup is not displayd |
|
972 if ( iAppUi.FolderList().IsPopupShown() ) |
|
973 { |
|
974 iAppUi.FolderList().HidePopupL(); |
|
975 } |
|
976 |
|
977 // inform baseView if view entered with forward navigation |
|
978 TBool forwardNavigation = EFalse; |
|
979 if ( aCustomMessageId != KStartListReturnToPreviousFolder && |
|
980 aCustomMessageId != TUid::Uid(KMailSettingsReturnFromPluginSettings) ) |
|
981 { |
|
982 ViewEntered( aPrevViewId ); |
|
983 forwardNavigation = ETrue; |
|
984 } |
|
985 |
|
986 // Set control bar and list layout size always in activation |
|
987 TRect clientRect = iAppUi.ClientRect(); |
|
988 iScreenAnchorLayout->SetSize( clientRect.Size() ); |
|
989 SetMailListLayoutAnchors(); |
|
990 TInt listHeight = clientRect.Height() - iAppUi.LayoutHandler()->ControlBarHeight(); |
|
991 iListLayout->SetSize( TSize( clientRect.Width(), listHeight ) ); // needs to be set separately to avoid layout problems in some special cases |
|
992 ScaleControlBarL(); |
|
993 SetListAndCtrlBarFocusL(); |
|
994 |
|
995 // Update mail list settings and date formats, is done every time |
|
996 // the user might have changed these in settings, so the list needs to refresh |
|
997 // Store previous modes |
|
998 TInt prevListMode = iListMode; |
|
999 TInt prevNodesmode = iNodesInUse; |
|
1000 TAknUiZoom prevZoomLevel = iCurrentZoomLevel; |
|
1001 STimeDateFormats prevDateFormats = MailListTimeDateSettings(); |
|
1002 |
|
1003 // Get new settings and list drawing modes |
|
1004 CAknEnv::Static()->GetCurrentGlobalUiZoom( iCurrentZoomLevel ); |
|
1005 UpdateMailListSettingsL(); |
|
1006 UpdateMailListTimeDateSettings(); |
|
1007 |
|
1008 // Check for changed settings, in that case a complete list refresh is needed |
|
1009 TBool refreshNeeded(EFalse); |
|
1010 if ( iSkinChanged |
|
1011 || iDateChanged |
|
1012 || iListMode != prevListMode |
|
1013 || iNodesInUse != prevNodesmode |
|
1014 || iCurrentZoomLevel != prevZoomLevel |
|
1015 || prevDateFormats.iDateFormat != iDateFormats.iDateFormat |
|
1016 || prevDateFormats.iTimeFormat != iDateFormats.iTimeFormat |
|
1017 || prevDateFormats.iAmPmPosition != iDateFormats.iAmPmPosition |
|
1018 || prevDateFormats.iDateSeparator != iDateFormats.iDateSeparator |
|
1019 || prevDateFormats.iTimeSeparator != iDateFormats.iTimeSeparator ) |
|
1020 { |
|
1021 refreshNeeded = ETrue; |
|
1022 iSkinChanged = EFalse; |
|
1023 iDateChanged = EFalse; |
|
1024 } |
|
1025 |
|
1026 // Store previously used mailbox and folder IDs |
|
1027 TFSMailMsgId prevMailBoxId = iAppUi.GetActiveMailboxId(); |
|
1028 TFSMailMsgId prevFolderId = FolderId(); |
|
1029 |
|
1030 CFSMailClient* mailClient = iAppUi.GetMailClient(); |
|
1031 User::LeaveIfNull( mailClient ); // we can't go on if no mail client is available |
|
1032 |
|
1033 // FIGURE OUT WHICH FOLDER TO ACTIVATE |
|
1034 TMailListActivationData activationData; |
|
1035 |
|
1036 // Opening folder given in custom message |
|
1037 if ( aCustomMessage.Length() ) |
|
1038 { |
|
1039 TPckgBuf<TMailListActivationData> viewData; |
|
1040 viewData.Copy( aCustomMessage ); |
|
1041 activationData = viewData(); |
|
1042 } |
|
1043 |
|
1044 // Returning to previous folder |
|
1045 if ( aCustomMessageId == KStartListReturnToPreviousFolder || |
|
1046 aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) ) |
|
1047 { |
|
1048 activationData.iMailBoxId = prevMailBoxId; |
|
1049 activationData.iFolderId = prevFolderId; |
|
1050 } |
|
1051 |
|
1052 // Proper mailbox ID is not given in custom message. Try using MSV session. |
|
1053 if ( activationData.iMailBoxId.IsNullId() ) |
|
1054 { |
|
1055 CMsvSession* msvSession = iAppUi.GetMsvSession(); |
|
1056 CFSMailBox* mailBox = NULL; |
|
1057 |
|
1058 if ( msvSession ) |
|
1059 { |
|
1060 // MSV id is passed to us in aCustomMessageId when activation happens by email key |
|
1061 if ( aCustomMessageId != TUid::Null() ) |
|
1062 { |
|
1063 // <cmail> |
|
1064 TInt error = KErrNone; |
|
1065 TRAP( error, mailBox = TFsEmailUiUtility::GetMailboxForMtmIdL( *mailClient, *msvSession, aCustomMessageId.iUid ) ); |
|
1066 // </cmail> |
|
1067 if ( mailBox ) |
|
1068 { |
|
1069 activationData.iMailBoxId = mailBox->GetId(); |
|
1070 delete mailBox; |
|
1071 mailBox = NULL; |
|
1072 } |
|
1073 } |
|
1074 |
|
1075 // Try to get MCE default mailbox if we still haven't got any other box |
|
1076 if ( activationData.iMailBoxId.IsNullId() ) |
|
1077 { |
|
1078 // <cmail> |
|
1079 TInt error = KErrNone; |
|
1080 TRAP( error, mailBox = TFsEmailUiUtility::GetMceDefaultMailboxL( *mailClient, *msvSession ) ); |
|
1081 // </cmail> |
|
1082 if ( mailBox ) |
|
1083 { |
|
1084 activationData.iMailBoxId = mailBox->GetId(); |
|
1085 delete mailBox; |
|
1086 mailBox = NULL; |
|
1087 } |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 } |
|
1092 |
|
1093 // If still no mailbox then use first from the list of the framework |
|
1094 if ( activationData.iMailBoxId.IsNullId() ) |
|
1095 { |
|
1096 TFSMailMsgId id; |
|
1097 RPointerArray<CFSMailBox> mailboxes; |
|
1098 CleanupResetAndDestroyClosePushL( mailboxes ); |
|
1099 mailClient->ListMailBoxes( id, mailboxes ); |
|
1100 if ( mailboxes.Count() > 0 ) |
|
1101 { |
|
1102 activationData.iMailBoxId = mailboxes[0]->GetId(); |
|
1103 } |
|
1104 CleanupStack::PopAndDestroy( &mailboxes ); |
|
1105 } |
|
1106 |
|
1107 |
|
1108 // Check if we got any mailbox |
|
1109 if ( activationData.iMailBoxId.IsNullId() ) |
|
1110 { |
|
1111 // could not get mailbox so leave |
|
1112 User::Leave( KErrGeneral ); |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 // Set the active mailbox of AppUi. Do this also when mailbox hasn't actually |
|
1117 // changed to do the autoconnect when necessary and to verify that the previously |
|
1118 // active mailbox is still valid. |
|
1119 // Leave is caused if mailbox is no longer available, and BaseView will take care |
|
1120 // of the error handling. |
|
1121 iAppUi.SetActiveMailboxL( activationData.iMailBoxId, forwardNavigation ); |
|
1122 |
|
1123 // we got mailbox but no folder has been given => use Inbox |
|
1124 if ( activationData.iFolderId.IsNullId() || |
|
1125 activationData.iFolderId.Id() == 0 ) |
|
1126 { |
|
1127 activationData.iFolderId = iAppUi.GetActiveBoxInboxId(); |
|
1128 } |
|
1129 } |
|
1130 |
|
1131 // NOW WE HAVE A VALID MAILBOX AND FOLDER ID. |
|
1132 |
|
1133 // CHECK IF MODEL NEEDS TO BE UPDATED |
|
1134 if ( activationData.iMailBoxId != prevMailBoxId || |
|
1135 activationData.iFolderId != prevFolderId || |
|
1136 activationData.iRequestRefresh ) |
|
1137 { |
|
1138 // Set initial sort criteria when folder is changed |
|
1139 iCurrentSortCriteria.iField = EFSMailSortByDate; |
|
1140 iCurrentSortCriteria.iOrder = EFSMailDescending; |
|
1141 SetSortButtonTextAndIconL(); |
|
1142 |
|
1143 delete iMailFolder; |
|
1144 iMailFolder = NULL; |
|
1145 TRAP_IGNORE( iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( |
|
1146 activationData.iMailBoxId, activationData.iFolderId ) ); |
|
1147 if ( !iMailFolder ) |
|
1148 { |
|
1149 // Safety, try to revert back to standard folder inbox |
|
1150 TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox ); |
|
1151 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( activationData.iMailBoxId, inboxId ); |
|
1152 } |
|
1153 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
|
1154 iFolderListButton->SetTextL( *newFolderName ); |
|
1155 CleanupStack::PopAndDestroy( newFolderName ); |
|
1156 iMailList->SetFocusedItemL( KFsTreeNoneID ); |
|
1157 refreshNeeded = ETrue; |
|
1158 } |
|
1159 |
|
1160 // Set mailbox name to status pane |
|
1161 SetMailboxNameToStatusPaneL(); |
|
1162 |
|
1163 // Set branded watermark and mailbox icon |
|
1164 SetBrandedListWatermarkL(); |
|
1165 SetBrandedMailBoxIconL(); |
|
1166 |
|
1167 // Check sync icon timer and sync status |
|
1168 ConnectionIconHandling(); |
|
1169 |
|
1170 // <cmail> |
|
1171 iMailList->HideListL(); |
|
1172 iMailList->ShowListL(); |
|
1173 // </cmail> |
|
1174 // REBUILD TREE LIST IF NECESSARY |
|
1175 if ( refreshNeeded ) |
|
1176 { |
|
1177 // Try to maintain previously active item if possible. |
|
1178 // This is of course not possible if folder has changed. |
|
1179 TFSMailMsgId focused = MsgIdFromListId( iMailList->FocusedItem() ); |
|
1180 |
|
1181 // Clear any previous items from the screen and then make the view visible |
|
1182 iMailList->RemoveAllL(); |
|
1183 iTreeItemArray.Reset(); |
|
1184 UpdateMailListModelL(); |
|
1185 RefreshDeferred( &focused ); |
|
1186 } |
|
1187 |
|
1188 // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED. |
|
1189 else |
|
1190 { |
|
1191 // hide & show list to force it to adept to changed screen size |
|
1192 // <cmail> |
|
1193 /*if ( iCurrentClientRect != clientRect ) |
|
1194 { |
|
1195 iMailList->HideListL(); |
|
1196 iMailList->ShowListL(); */ |
|
1197 SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted |
|
1198 // } |
|
1199 // </cmail> |
|
1200 UnmarkAllItemsL(); |
|
1201 |
|
1202 if ( aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) ) |
|
1203 { |
|
1204 // Better to refresh launcher grid view because mailbox branding might be changed. |
|
1205 iAppUi.LauncherGrid().SetRefreshNeeded(); |
|
1206 } |
|
1207 |
|
1208 // Check the validity of focused message, it may be deleted or |
|
1209 // reply/forward, read/unread status might have changed in editor or viewer |
|
1210 UpdateItemAtIndexL( HighlightedIndex() ); |
|
1211 SetMskL(); |
|
1212 } |
|
1213 |
|
1214 iCurrentClientRect = clientRect; |
|
1215 iThisViewActive = ETrue; |
|
1216 |
|
1217 // Set email indicator off.. user has checked the new emails |
|
1218 TFsEmailUiUtility::ToggleEmailIconL(EFalse); |
|
1219 |
|
1220 iShiftDepressed = EFalse; // clear state just in case |
|
1221 |
|
1222 // Inform MR observer if needed, special MR case, returning from attachment list |
|
1223 iAppUi.MailViewer().CompletePendingMrCommand(); |
|
1224 // <cmail> |
|
1225 //Make sure that correct component is set to focused. |
|
1226 if ( iFocusedControl == EMailListComponent ) |
|
1227 SetTreeListFocusedL(); |
|
1228 else |
|
1229 SetControlBarFocusedL(); |
|
1230 // </cmail> |
|
1231 |
|
1232 iAppUi.ShowTitlePaneConnectionStatus(); |
|
1233 } |
|
1234 |
|
1235 // --------------------------------------------------------------------------- |
|
1236 // Sets status bar layout |
|
1237 // --------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CFSEmailUiMailListVisualiser::SetStatusBarLayout() |
|
1240 { |
|
1241 if ( StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT ) |
|
1242 { |
|
1243 TRAP_IGNORE( |
|
1244 StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )); |
|
1245 } |
|
1246 } |
|
1247 |
|
1248 |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // |
|
1251 // |
|
1252 // --------------------------------------------------------------------------- |
|
1253 // |
|
1254 void CFSEmailUiMailListVisualiser::ChildDoDeactivate() |
|
1255 { |
|
1256 FUNC_LOG; |
|
1257 if ( !iAppUi.AppUiExitOngoing() ) |
|
1258 { |
|
1259 TRAP_IGNORE( { |
|
1260 iMailList->SetFocusedL( EFalse ); |
|
1261 } ); |
|
1262 iMailTreeListVisualizer->NotifyControlVisibilityChange( EFalse ); |
|
1263 } |
|
1264 iThisViewActive = EFalse; |
|
1265 } |
|
1266 |
|
1267 // --------------------------------------------------------------------------- |
|
1268 // |
|
1269 // |
|
1270 // --------------------------------------------------------------------------- |
|
1271 // |
|
1272 CFSEmailUiMailListModel* CFSEmailUiMailListVisualiser::Model() |
|
1273 { |
|
1274 FUNC_LOG; |
|
1275 return iModel; |
|
1276 } |
|
1277 |
|
1278 // --------------------------------------------------------------------------- |
|
1279 // |
|
1280 // |
|
1281 // --------------------------------------------------------------------------- |
|
1282 // |
|
1283 TFSMailMsgId CFSEmailUiMailListVisualiser::FolderId() |
|
1284 { |
|
1285 FUNC_LOG; |
|
1286 TFSMailMsgId folderId; // constructs null ID |
|
1287 if ( iMailFolder ) |
|
1288 { |
|
1289 folderId = iMailFolder->GetFolderId(); |
|
1290 } |
|
1291 return folderId; |
|
1292 } |
|
1293 |
|
1294 // --------------------------------------------------------------------------- |
|
1295 // |
|
1296 // |
|
1297 // --------------------------------------------------------------------------- |
|
1298 // |
|
1299 void CFSEmailUiMailListVisualiser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
1300 { |
|
1301 FUNC_LOG; |
|
1302 CompletePendingRefresh(); |
|
1303 |
|
1304 // Get the list of items which will be targetted by the actions menu commands |
|
1305 RFsTreeItemIdList targetEntries; |
|
1306 CleanupClosePushL( targetEntries ); |
|
1307 GetActionsTargetEntriesL( targetEntries ); |
|
1308 |
|
1309 TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ); |
|
1310 TBool supportsFlag = TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ); |
|
1311 |
|
1312 TInt currentFolderType = KErrNotFound; |
|
1313 if ( iMailFolder ) |
|
1314 { |
|
1315 currentFolderType = iMailFolder->GetFolderType(); |
|
1316 } |
|
1317 |
|
1318 // MAIN MENU *************************************************************************** |
|
1319 if ( aResourceId == R_FSEMAILUI_MAILLIST_MENUPANE ) |
|
1320 { |
|
1321 if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration )) |
|
1322 { |
|
1323 // remove help support in pf5250 |
|
1324 aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue); |
|
1325 } |
|
1326 |
|
1327 // Checks if a device has a keyboard or not. |
|
1328 if( !iKeyboardFlipOpen ) |
|
1329 { |
|
1330 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue ); |
|
1331 aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue); |
|
1332 aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue ); |
|
1333 } |
|
1334 |
|
1335 // OFFLINE/ONLINE MENU SELECTION |
|
1336 TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus(); |
|
1337 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline ); |
|
1338 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline ); |
|
1339 |
|
1340 // Sync/cancel sync |
|
1341 TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync ); |
|
1342 if ( !supportsSync ) |
|
1343 { |
|
1344 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue ); |
|
1345 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
1346 } |
|
1347 else if ( GetLatestSyncState() ) |
|
1348 { |
|
1349 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
1350 } |
|
1351 else |
|
1352 { |
|
1353 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue ); |
|
1354 } |
|
1355 |
|
1356 //MESSAGEREADER MENU SELECTION |
|
1357 if ( iAppUi.MessageReaderSupportsFreestyle() ) |
|
1358 { |
|
1359 aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, EFalse ); |
|
1360 } |
|
1361 else |
|
1362 { |
|
1363 aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue ); |
|
1364 } |
|
1365 // Disable read in outbox and drafts |
|
1366 if ( currentFolderType == EFSDraftsFolder || |
|
1367 currentFolderType == EFSOutbox ) |
|
1368 { |
|
1369 aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue ); |
|
1370 } |
|
1371 |
|
1372 // EMPTY LIST, MOST OPTIONS ARE HIDDEN |
|
1373 if ( !iModel->Count() || !iMailFolder ) |
|
1374 { |
|
1375 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue ); |
|
1376 aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue ); |
|
1377 aMenuPane->SetItemDimmed( EFsEmailUiCmdMore, ETrue ); |
|
1378 aMenuPane->SetItemDimmed( EFsEmailUiCmdSearch, ETrue ); |
|
1379 aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue ); |
|
1380 } |
|
1381 |
|
1382 // NO TARGET ITEMS, E.G FOCUS ON DIVIDER AND NO MARKED ITEMS, ITEM RELATED OPTIONS ARE HIDDEN |
|
1383 else if ( !targetEntries.Count() ) |
|
1384 { |
|
1385 aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue ); |
|
1386 aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue ); |
|
1387 } |
|
1388 |
|
1389 // Open command is available only if there's exactly one target item |
|
1390 if ( targetEntries.Count() != 1 ) |
|
1391 { |
|
1392 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue ); |
|
1393 } |
|
1394 |
|
1395 // FOLDER SPECIFIC COMMAND HIDING |
|
1396 // In the outbox folder, Open command is inavailable in any case |
|
1397 if ( currentFolderType == EFSOutbox ) |
|
1398 { |
|
1399 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue ); |
|
1400 } |
|
1401 |
|
1402 // "Clear deleted folder" command is available only in Deleted folder |
|
1403 if ( currentFolderType != EFSDeleted || !iModel->Count() ) |
|
1404 { |
|
1405 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue ); |
|
1406 } |
|
1407 } |
|
1408 // MAIN MENU *************************************************************************** |
|
1409 |
|
1410 |
|
1411 // ACTIONS SUBMENU ********************************************************************* |
|
1412 if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS ) |
|
1413 { |
|
1414 // Actions menu should never be available when there's no marked or focused item(s) |
|
1415 __ASSERT_DEBUG( targetEntries.Count(), Panic(EFSEmailUiUnexpectedValue) ); |
|
1416 |
|
1417 CFSMailMessage* targetMessage = NULL; |
|
1418 if ( targetEntries.Count() == 1 ) |
|
1419 { |
|
1420 targetMessage = &MsgPtrFromListIdL( targetEntries[0] ); |
|
1421 } |
|
1422 |
|
1423 // Meeting request mode is in use when there's exactly one target item and it's a |
|
1424 // calendar message and MRUI is available. |
|
1425 TBool showMrActions = EFalse; |
|
1426 |
|
1427 if ( targetMessage && targetMessage->IsFlagSet( EFSMsgFlag_CalendarMsg ) && |
|
1428 iAppUi.MrViewerInstanceL() && |
|
1429 iAppUi.MrViewerInstanceL()->CanViewMessage( *targetMessage ) && |
|
1430 currentFolderType != EFSOutbox && |
|
1431 currentFolderType != EFSDraftsFolder ) |
|
1432 { |
|
1433 showMrActions = ETrue; |
|
1434 } |
|
1435 |
|
1436 // CALENDAR EVENT ACTIONS SUBMENU |
|
1437 if ( showMrActions ) |
|
1438 { |
|
1439 // Hide all the normal email message specific actions |
|
1440 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue ); |
|
1441 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue ); |
|
1442 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue ); |
|
1443 |
|
1444 // Hide the irrelevant MR actions |
|
1445 TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown ); |
|
1446 if ( iAppUi.MrViewerInstanceL() ) |
|
1447 { |
|
1448 TRAP_IGNORE( mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *targetMessage ) ); |
|
1449 } |
|
1450 switch ( mrMethod ) |
|
1451 { |
|
1452 case EESMRMeetingRequestMethodRequest: |
|
1453 { |
|
1454 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue); |
|
1455 } |
|
1456 break; |
|
1457 case EESMRMeetingRequestMethodCancellation: |
|
1458 { |
|
1459 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue); |
|
1460 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue); |
|
1461 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue); |
|
1462 |
|
1463 TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar ); |
|
1464 if( !supportsRemove ) |
|
1465 { |
|
1466 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue); |
|
1467 } |
|
1468 } |
|
1469 break; |
|
1470 case EESMRMeetingRequestMethodResponse: |
|
1471 case EESMRMeetingRequestMethodUnknown: |
|
1472 { |
|
1473 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue); |
|
1474 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue); |
|
1475 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue); |
|
1476 aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue); |
|
1477 } |
|
1478 break; |
|
1479 default: |
|
1480 break; |
|
1481 } |
|
1482 } |
|
1483 |
|
1484 // MAIL MESSAGE ACTIONS SUBMENU |
|
1485 else |
|
1486 { |
|
1487 // Hide all the calendar event options |
|
1488 aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsAccept, ETrue ); |
|
1489 aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsTentative, ETrue ); |
|
1490 aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsDecline, ETrue ); |
|
1491 aMenuPane->SetItemDimmed( EFsEmailUiCmdCalRemoveFromCalendar, ETrue ); |
|
1492 |
|
1493 // Hide the irrelevant reply / reply all / forward commands |
|
1494 TInt numRecipients(0); |
|
1495 if ( targetMessage ) |
|
1496 { |
|
1497 //Get # of recipients |
|
1498 numRecipients = TFsEmailUiUtility::CountRecipientsSmart( iAppUi, targetMessage ); |
|
1499 } |
|
1500 // All reply/forward options are hidden when multiple marked messages or folder is outbox or drafts |
|
1501 if ( targetEntries.Count() > 1 || |
|
1502 currentFolderType == EFSOutbox || |
|
1503 currentFolderType == EFSDraftsFolder ) |
|
1504 { |
|
1505 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue ); |
|
1506 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue ); |
|
1507 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue ); |
|
1508 } |
|
1509 |
|
1510 // Reply all is hidden also when the single target message has multiple recipients |
|
1511 else if ( !targetMessage || numRecipients <= 1 ) |
|
1512 { |
|
1513 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue ); |
|
1514 } |
|
1515 } |
|
1516 |
|
1517 // COMMON PART OF ACTIONS SUBMENU |
|
1518 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() ); |
|
1519 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() ); |
|
1520 |
|
1521 if ( !supportsMoving || !iMailFolder ) // Hide move from actions if not supported |
|
1522 { |
|
1523 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue ); |
|
1524 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue ); |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 // Moving supported, show/hide moving options depending on the current folder |
|
1529 // First check deleted items case, IMS does not support deleted sync |
|
1530 if ( currentFolderType == EFSDeleted ) |
|
1531 { |
|
1532 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue ); // Dim in deleted |
|
1533 } |
|
1534 // Then check for outbox case, move to drafts is allowed, other moves not |
|
1535 else if ( currentFolderType == EFSOutbox ) |
|
1536 { |
|
1537 // move from outbox to drafts is allowed |
|
1538 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, EFalse ); // Allow in outbox |
|
1539 // moving from outbox is not allowed otherwise |
|
1540 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue ); |
|
1541 } |
|
1542 // Handle rest of the folders |
|
1543 else |
|
1544 { |
|
1545 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue ); // Dim in other folders |
|
1546 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, EFalse ); |
|
1547 } |
|
1548 } |
|
1549 } |
|
1550 // ACTIONS SUBMENU ********************************************************************* |
|
1551 |
|
1552 |
|
1553 // MORE SUBMENU ************************************************************************ |
|
1554 if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MORE ) |
|
1555 { |
|
1556 TInt markedCount = CountMarkedItemsL(); |
|
1557 |
|
1558 // Checks if a device has a keyboard or not. |
|
1559 if( !iKeyboardFlipOpen ) |
|
1560 { |
|
1561 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue ); |
|
1562 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue ); |
|
1563 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue ); |
|
1564 aMenuPane->SetItemDimmed( EFsEmailUiCmdMessageDetails, ETrue ); |
|
1565 } |
|
1566 |
|
1567 // Hide expand/collapse all when not applicable |
|
1568 if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() ) |
|
1569 { |
|
1570 aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsCollapseAll, ETrue); |
|
1571 aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsExpandAll, ETrue); |
|
1572 } |
|
1573 else |
|
1574 { |
|
1575 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() ); |
|
1576 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() ); |
|
1577 } |
|
1578 |
|
1579 // Some commands are available only when there's exactly one target message |
|
1580 if ( targetEntries.Count() != 1 ) |
|
1581 { |
|
1582 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue ); |
|
1583 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue ); |
|
1584 aMenuPane->SetItemDimmed( EFsEmailUiCmdMessageDetails, ETrue ); |
|
1585 } |
|
1586 |
|
1587 // Hide mark/unmark all when not applicable |
|
1588 if ( markedCount == EmailsInModelL() ) // Hide mark all |
|
1589 { |
|
1590 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, ETrue ); |
|
1591 //aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmarkAll, EFalse ); |
|
1592 } |
|
1593 else if ( !markedCount ) // hide unmark all |
|
1594 { |
|
1595 //aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, EFalse ); |
|
1596 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmarkAll, ETrue ); |
|
1597 } |
|
1598 |
|
1599 // Hide followup flagging if not applicable |
|
1600 if ( !supportsFlag || !targetEntries.Count() ) |
|
1601 { |
|
1602 aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsFlag, ETrue); |
|
1603 } |
|
1604 |
|
1605 // Hide Download Manager if no downloads present |
|
1606 // <cmail> Prevent Download Manager opening with attachments |
|
1607 // if ( !iAppUi.DownloadInfoMediator() || !iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads() ) |
|
1608 // { |
|
1609 // aMenuPane->SetItemDimmed(EFsEmailUiCmdDownloadManager, ETrue); |
|
1610 // } |
|
1611 // </cmail> |
|
1612 |
|
1613 // Availability of the mark/unmark commands depends only on the focused item |
|
1614 if ( !iMailList || iMailList->FocusedItem() == KFsTreeNoneID || |
|
1615 iMailList->IsNode( iMailList->FocusedItem() ) ) |
|
1616 { |
|
1617 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue ); |
|
1618 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmark, ETrue ); |
|
1619 } |
|
1620 else if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) // Item was already marked |
|
1621 { |
|
1622 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue ); |
|
1623 } |
|
1624 else |
|
1625 { |
|
1626 aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmark, ETrue ); |
|
1627 } |
|
1628 |
|
1629 // Some commands are hidden in the outbox and drafts folders |
|
1630 if ( currentFolderType == EFSOutbox || |
|
1631 currentFolderType == EFSDraftsFolder ) |
|
1632 { |
|
1633 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue ); |
|
1634 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue ); |
|
1635 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue ); |
|
1636 } |
|
1637 } |
|
1638 // MORE SUBMENU ************************************************************************ |
|
1639 |
|
1640 |
|
1641 // SETTINGS SUBMENU ******************************************************************** |
|
1642 if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_SETTINGS ) |
|
1643 { |
|
1644 TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid(); |
|
1645 |
|
1646 CESMailSettingsPlugin* settingsPlugin = |
|
1647 static_cast<CESMailSettingsPlugin*>( iAppUi.View( pluginUid ) ); |
|
1648 |
|
1649 if ( !settingsPlugin ) |
|
1650 { |
|
1651 settingsPlugin = CESMailSettingsPlugin::NewL( pluginUid ); |
|
1652 CleanupStack::PushL( settingsPlugin ); |
|
1653 iAppUi.AddViewL( settingsPlugin ); |
|
1654 CleanupStack::Pop( settingsPlugin ); // ownership transferred |
|
1655 } |
|
1656 TInt count( settingsPlugin->MailSettingsSubviewCount() ); |
|
1657 if ( count > 0 ) |
|
1658 { |
|
1659 TInt index = 0; |
|
1660 while ( index < count ) |
|
1661 { |
|
1662 CEikMenuPaneItem::SData newMenuItem; |
|
1663 newMenuItem.iCommandId = EFsEmailUiCmdSettingsBaseCommandId + index; |
|
1664 newMenuItem.iCascadeId = 0; |
|
1665 newMenuItem.iFlags = 0; |
|
1666 newMenuItem.iText = settingsPlugin->MailSettingsSubviewCaption( |
|
1667 iAppUi.GetActiveMailboxId(), |
|
1668 index, |
|
1669 EFalse |
|
1670 ); |
|
1671 aMenuPane->InsertMenuItemL( |
|
1672 newMenuItem, |
|
1673 aMenuPane->NumberOfItemsInPane() ); |
|
1674 ++index; |
|
1675 } |
|
1676 } |
|
1677 else |
|
1678 { |
|
1679 // POP/IMAP mailbox settings |
|
1680 HBufC* ipsText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SETTINGS_IPS_TEXT ); |
|
1681 CEikMenuPaneItem::SData newMenuItem; |
|
1682 newMenuItem.iCommandId = EFsEmailUiCmdSettingsBaseCommandId; |
|
1683 newMenuItem.iCascadeId = 0; |
|
1684 newMenuItem.iFlags = 0; |
|
1685 newMenuItem.iText = *ipsText; |
|
1686 aMenuPane->InsertMenuItemL( |
|
1687 newMenuItem, |
|
1688 aMenuPane->NumberOfItemsInPane() ); |
|
1689 CleanupStack::PopAndDestroy( ipsText ); |
|
1690 } |
|
1691 } |
|
1692 // SETTINGS SUBMENU ******************************************************************** |
|
1693 |
|
1694 CleanupStack::PopAndDestroy( &targetEntries ); |
|
1695 |
|
1696 // Add shortcut hints |
|
1697 iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, |
|
1698 CFSEmailUiShortcutBinding::EContextMailList ); |
|
1699 } |
|
1700 |
|
1701 // --------------------------------------------------------------------------- |
|
1702 // |
|
1703 // |
|
1704 // --------------------------------------------------------------------------- |
|
1705 // |
|
1706 void CFSEmailUiMailListVisualiser::MarkAllItemsL() |
|
1707 { |
|
1708 FUNC_LOG; |
|
1709 if ( iTreeItemArray.Count() ) |
|
1710 { |
|
1711 for ( TInt i=0;i<iTreeItemArray.Count(); i++ ) |
|
1712 { |
|
1713 if ( !iMailList->IsNode(iTreeItemArray[i].iListItemId ) ) |
|
1714 { |
|
1715 iMailList->MarkItemL( iTreeItemArray[i].iListItemId, ETrue ); |
|
1716 } |
|
1717 } |
|
1718 } |
|
1719 } |
|
1720 |
|
1721 // --------------------------------------------------------------------------- |
|
1722 // |
|
1723 // |
|
1724 // --------------------------------------------------------------------------- |
|
1725 // |
|
1726 void CFSEmailUiMailListVisualiser::UnmarkAllItemsL() |
|
1727 { |
|
1728 FUNC_LOG; |
|
1729 for ( TInt i=0 ; i<iTreeItemArray.Count() ; i++ ) |
|
1730 { |
|
1731 if ( !iMailList->IsNode(iTreeItemArray[i].iListItemId) ) |
|
1732 { |
|
1733 iMailList->MarkItemL( iTreeItemArray[i].iListItemId, EFalse ); |
|
1734 } |
|
1735 } |
|
1736 } |
|
1737 |
|
1738 // --------------------------------------------------------------------------- |
|
1739 // |
|
1740 // |
|
1741 // --------------------------------------------------------------------------- |
|
1742 // |
|
1743 TInt CFSEmailUiMailListVisualiser::CountMarkedItemsL() |
|
1744 { |
|
1745 FUNC_LOG; |
|
1746 RFsTreeItemIdList markedEntries; |
|
1747 CleanupClosePushL( markedEntries ); |
|
1748 iMailList->GetMarkedItemsL( markedEntries ); |
|
1749 TInt count = markedEntries.Count(); |
|
1750 CleanupStack::PopAndDestroy( &markedEntries ); |
|
1751 return count; |
|
1752 } |
|
1753 |
|
1754 // --------------------------------------------------------------------------- |
|
1755 // |
|
1756 // |
|
1757 // --------------------------------------------------------------------------- |
|
1758 // |
|
1759 void CFSEmailUiMailListVisualiser::GetMarkedMessagesL( RArray<TFSMailMsgId>& aMessageIDs ) const |
|
1760 { |
|
1761 FUNC_LOG; |
|
1762 aMessageIDs.Reset(); |
|
1763 |
|
1764 RFsTreeItemIdList markedEntries; |
|
1765 CleanupClosePushL( markedEntries ); |
|
1766 iMailList->GetMarkedItemsL( markedEntries ); |
|
1767 |
|
1768 for ( TInt i=0 ; i<markedEntries.Count() ; ++i ) |
|
1769 { |
|
1770 // This could be optimized if we could be certain that the order of the |
|
1771 // marked entries is the same as the order in the message list. This is |
|
1772 // probably true, but the interface does not guarantee that. Now the |
|
1773 // time counsumption is Theta(n*m) while Theta(n+m) could be possible |
|
1774 TFSMailMsgId messageId = MsgIdFromListId( markedEntries[i] ); |
|
1775 if ( !messageId.IsNullId() ) |
|
1776 { |
|
1777 aMessageIDs.Append( messageId ); |
|
1778 } |
|
1779 } |
|
1780 |
|
1781 CleanupStack::PopAndDestroy( &markedEntries ); |
|
1782 } |
|
1783 |
|
1784 // --------------------------------------------------------------------------- |
|
1785 // |
|
1786 // |
|
1787 // --------------------------------------------------------------------------- |
|
1788 // |
|
1789 void CFSEmailUiMailListVisualiser::MarkMessagesIfFoundL( const RArray<TFSMailMsgId>& aMessageIDs ) |
|
1790 { |
|
1791 FUNC_LOG; |
|
1792 for ( TInt i=0 ; i<aMessageIDs.Count() ; ++i ) |
|
1793 { |
|
1794 // Same performance tweaking possibility is here that is commented in GetMarkedMessagesL(). |
|
1795 TInt index = ItemIndexFromMessageId( aMessageIDs[i] ); |
|
1796 if ( index >= 0 ) |
|
1797 { |
|
1798 iMailList->MarkItemL( iTreeItemArray[index].iListItemId, ETrue ); |
|
1799 } |
|
1800 } |
|
1801 } |
|
1802 |
|
1803 // --------------------------------------------------------------------------- |
|
1804 // |
|
1805 // |
|
1806 // --------------------------------------------------------------------------- |
|
1807 // |
|
1808 void CFSEmailUiMailListVisualiser::RefreshL( TFSMailMsgId* aFocusToMessage ) |
|
1809 { |
|
1810 FUNC_LOG; |
|
1811 iMailList->RemoveAllL(); |
|
1812 iTreeItemArray.Reset(); |
|
1813 |
|
1814 RefreshListItemsL(); |
|
1815 |
|
1816 if ( !iModel->Count() ) |
|
1817 { |
|
1818 iFocusedControl = EControlBarComponent; |
|
1819 // If focus is not visible, hide selector |
|
1820 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
1821 } |
|
1822 else |
|
1823 { |
|
1824 // Try to keep the previous list item if focused message ptr is given, |
|
1825 // and it's not NULL id |
|
1826 if ( aFocusToMessage && !aFocusToMessage->IsNullId() ) |
|
1827 { |
|
1828 TInt idx = ItemIndexFromMessageId( *aFocusToMessage ); |
|
1829 if ( idx >= 0 ) |
|
1830 { |
|
1831 iMailList->SetFocusedItemL( iTreeItemArray[idx].iListItemId ); |
|
1832 } |
|
1833 } |
|
1834 } |
|
1835 |
|
1836 SetListAndCtrlBarFocusL(); |
|
1837 SetMskL(); |
|
1838 |
|
1839 iListOrderMayBeOutOfDate = EFalse; |
|
1840 } |
|
1841 |
|
1842 void CFSEmailUiMailListVisualiser::RefreshOrderL() |
|
1843 { |
|
1844 FUNC_LOG; |
|
1845 if ( iTreeItemArray.Count() ) |
|
1846 { |
|
1847 TInt itemIdxUnderNode = -1; |
|
1848 TInt nodeIdx = -1; |
|
1849 TFsTreeItemId parentNodeId = KFsTreeRootID; |
|
1850 |
|
1851 //iMailList->HideListL( EFalse, EFalse ); |
|
1852 TFsTreeItemId prevFocus = iMailList->FocusedItem(); |
|
1853 iMailList->SetFocusedItemL( iTreeItemArray[0].iListItemId ); // Try to prevent over indexing in generic list |
|
1854 |
|
1855 // iTreeItemArray is recreated on reordering. |
|
1856 iTreeItemArray.Reset(); |
|
1857 SMailListItem mailListItem; |
|
1858 |
|
1859 for ( TInt i = 0 ; i < iModel->Count() ; ++i ) |
|
1860 { |
|
1861 CFSEmailUiMailListModelItem* item = static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) ); |
|
1862 TFsTreeItemId itemId = item->CorrespondingListId(); |
|
1863 |
|
1864 if ( item->ModelItemType() == ETypeSeparator ) |
|
1865 { |
|
1866 nodeIdx++; |
|
1867 itemIdxUnderNode = -1; |
|
1868 parentNodeId = itemId; |
|
1869 if ( iMailList->ChildIndex( itemId, KFsTreeRootID ) != nodeIdx ) |
|
1870 { |
|
1871 iMailList->MoveItemL( itemId, KFsTreeRootID, nodeIdx ); |
|
1872 } |
|
1873 } |
|
1874 else |
|
1875 { |
|
1876 itemIdxUnderNode++; |
|
1877 if ( iMailList->Parent(itemId) != parentNodeId || |
|
1878 iMailList->ChildIndex( parentNodeId, itemId ) != itemIdxUnderNode ) |
|
1879 { |
|
1880 iMailList->MoveItemL( itemId, parentNodeId, itemIdxUnderNode ); |
|
1881 } |
|
1882 } |
|
1883 |
|
1884 mailListItem.iListItemId = itemId; |
|
1885 mailListItem.iTreeItemData = &iMailList->ItemData(itemId); |
|
1886 mailListItem.iTreeItemVisualiser = &iMailList->ItemVisualizer(itemId); |
|
1887 iTreeItemArray.AppendL( mailListItem ); |
|
1888 } |
|
1889 |
|
1890 iMailList->SetFocusedItemL( prevFocus ); |
|
1891 //iMailList->ShowListL( EFalse, EFalse ); |
|
1892 } |
|
1893 iListOrderMayBeOutOfDate = EFalse; |
|
1894 } |
|
1895 |
|
1896 // --------------------------------------------------------------------------- |
|
1897 // Start refresh list items asynchronously |
|
1898 // |
|
1899 // --------------------------------------------------------------------------- |
|
1900 // |
|
1901 // |
|
1902 void CFSEmailUiMailListVisualiser::RefreshDeferred( TFSMailMsgId* aFocusToMessage /*= NULL*/ ) |
|
1903 { |
|
1904 FUNC_LOG; |
|
1905 if ( aFocusToMessage ) |
|
1906 { |
|
1907 iMsgToFocusAfterRedraw = *aFocusToMessage; |
|
1908 } |
|
1909 else |
|
1910 { |
|
1911 // SetNullId sets just the null id flag, |
|
1912 // so we need to null the actual id manually |
|
1913 iMsgToFocusAfterRedraw.SetId( 0 ); |
|
1914 iMsgToFocusAfterRedraw.SetNullId(); |
|
1915 } |
|
1916 // <cmail> |
|
1917 if ( iAsyncRedrawer ) |
|
1918 { |
|
1919 TCallBack asyncRefresh( DoRefresh, this ); |
|
1920 iAsyncRedrawer->Cancel(); |
|
1921 iAsyncRedrawer->Set( asyncRefresh ); |
|
1922 iAsyncRedrawer->CallBack(); |
|
1923 } |
|
1924 // </cmail> |
|
1925 } |
|
1926 |
|
1927 // --------------------------------------------------------------------------- |
|
1928 // Static wrapper function for RefreshL() to enable asynchronous calling |
|
1929 // |
|
1930 // --------------------------------------------------------------------------- |
|
1931 // |
|
1932 // |
|
1933 TInt CFSEmailUiMailListVisualiser::DoRefresh( TAny* aSelfPtr ) |
|
1934 { |
|
1935 FUNC_LOG; |
|
1936 CFSEmailUiMailListVisualiser* self = |
|
1937 static_cast< CFSEmailUiMailListVisualiser* >( aSelfPtr ); |
|
1938 TRAPD( err, self->RefreshL( &self->iMsgToFocusAfterRedraw ) ); |
|
1939 return err; |
|
1940 } |
|
1941 |
|
1942 // --------------------------------------------------------------------------- |
|
1943 // Force any pending refresh event to be completed immediately |
|
1944 // |
|
1945 // --------------------------------------------------------------------------- |
|
1946 // |
|
1947 // |
|
1948 void CFSEmailUiMailListVisualiser::CompletePendingRefresh() |
|
1949 { |
|
1950 FUNC_LOG; |
|
1951 |
|
1952 if ( iAsyncRedrawer && iAsyncRedrawer->IsActive() ) //<cmail> |
|
1953 { |
|
1954 iAsyncRedrawer->Cancel(); |
|
1955 DoRefresh( this ); |
|
1956 } |
|
1957 |
|
1958 } |
|
1959 |
|
1960 // --------------------------------------------------------------------------- |
|
1961 // |
|
1962 // |
|
1963 // --------------------------------------------------------------------------- |
|
1964 // |
|
1965 void CFSEmailUiMailListVisualiser::RefreshListItemsL() |
|
1966 { |
|
1967 FUNC_LOG; |
|
1968 // IMPLEMENTATION OF FILLING UP THE LIST |
|
1969 TFsTreeItemId latestNodeId = KFsTreeRootID; // items will go under root node if no other nodes found in the model |
|
1970 CFSEmailUiMailListModelItem* item( NULL ); |
|
1971 SetMailListItemsExtendedL(); |
|
1972 |
|
1973 TBool allowRefresh(EFalse); |
|
1974 TInt count(0); |
|
1975 count = iModel->Count(); |
|
1976 for ( TInt i=0; i < count; i++ ) |
|
1977 { |
|
1978 item = static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
|
1979 |
|
1980 if ( i == 0 || i == count - 1 ) |
|
1981 {//first item - show scrollbar |
|
1982 //last item - update scrollbar |
|
1983 allowRefresh = ETrue; |
|
1984 } |
|
1985 else |
|
1986 {//rest of the messages - insert without updating |
|
1987 allowRefresh = EFalse; |
|
1988 } |
|
1989 |
|
1990 // Append separator item text into the list |
|
1991 if ( item && item->ModelItemType() == ETypeSeparator ) |
|
1992 { |
|
1993 latestNodeId = InsertNodeItemL( i, KErrNotFound, allowRefresh ); |
|
1994 } |
|
1995 // Append mail item into the list |
|
1996 else if ( item && item->ModelItemType() == ETypeMailItem ) |
|
1997 { |
|
1998 InsertListItemL( i, latestNodeId, KErrNotFound, allowRefresh ); |
|
1999 } |
|
2000 } |
|
2001 } |
|
2002 |
|
2003 |
|
2004 void CFSEmailUiMailListVisualiser::SetMailListItemsExtendedL() |
|
2005 { |
|
2006 FUNC_LOG; |
|
2007 // Set items always extended in double line preview on mode. |
|
2008 if ( iListMode == EListControlTypeDoubleLinePreviewOn || |
|
2009 iListMode == EListControlTypeDoubleLinePreviewOff ) |
|
2010 { |
|
2011 if ( iMailTreeListVisualizer ) |
|
2012 { |
|
2013 iMailTreeListVisualizer->SetItemsAlwaysExtendedL( ETrue ); |
|
2014 } |
|
2015 } |
|
2016 else |
|
2017 { |
|
2018 // Set the extendedability and extended size |
|
2019 if ( iMailTreeListVisualizer ) |
|
2020 { |
|
2021 iMailTreeListVisualizer->SetItemsAlwaysExtendedL( EFalse ); |
|
2022 } |
|
2023 } |
|
2024 } |
|
2025 |
|
2026 |
|
2027 // --------------------------------------------------------------------------- |
|
2028 // Create and insert one list node item according to given model item. |
|
2029 // Omitting the argument aChildIdx causes the new node to be appended as last |
|
2030 // child of the root node. |
|
2031 // --------------------------------------------------------------------------- |
|
2032 // |
|
2033 TFsTreeItemId CFSEmailUiMailListVisualiser::InsertNodeItemL( TInt aModelIndex, |
|
2034 TInt aChildIndex, |
|
2035 const TBool aAllowRefresh ) |
|
2036 { |
|
2037 FUNC_LOG; |
|
2038 TFsTreeItemId nodeId; |
|
2039 CFsTreePlainOneLineNodeData* plainNodeData(0); |
|
2040 CFsTreePlainOneLineNodeVisualizer* plainNodeVisualizer(0); |
|
2041 |
|
2042 CFSEmailUiMailListModelItem* item = |
|
2043 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(aModelIndex) ); |
|
2044 |
|
2045 CreatePlainNodeL( item->SeparatorText(), plainNodeData, plainNodeVisualizer ); |
|
2046 CleanupStack::PushL( plainNodeData ); |
|
2047 CleanupStack::PushL( plainNodeVisualizer ); |
|
2048 // Set text aling for western or A&H layout |
|
2049 plainNodeVisualizer->SetTextAlign( EAlfAlignHLocale ); |
|
2050 //new node is expanded |
|
2051 plainNodeVisualizer->SetExpanded( ETrue ); |
|
2052 |
|
2053 // In mail list, scrollbar does not need to be updated after node, since node is always followed by item |
|
2054 if ( aChildIndex >= 0 ) |
|
2055 { |
|
2056 nodeId = iMailList->InsertNodeL( *plainNodeData, *plainNodeVisualizer, KFsTreeRootID, aChildIndex, aAllowRefresh ); |
|
2057 } |
|
2058 else |
|
2059 { |
|
2060 nodeId = iMailList->InsertNodeL( *plainNodeData, *plainNodeVisualizer, KFsTreeRootID, KErrNotFound, aAllowRefresh ); |
|
2061 } |
|
2062 |
|
2063 CleanupStack::Pop( 2, plainNodeData ); |
|
2064 |
|
2065 SMailListItem mailListItem; |
|
2066 mailListItem.iListItemId = nodeId; |
|
2067 mailListItem.iTreeItemData = plainNodeData; |
|
2068 mailListItem.iTreeItemVisualiser = plainNodeVisualizer; |
|
2069 iTreeItemArray.InsertL( mailListItem, aModelIndex ); |
|
2070 item->AddCorrespondingListId( nodeId ); |
|
2071 |
|
2072 return nodeId; |
|
2073 } |
|
2074 |
|
2075 // --------------------------------------------------------------------------- |
|
2076 // Create and insert one list item according the given model item. The item is |
|
2077 // added under the given node. Omitting the argument aChildIdx causes the new |
|
2078 // item to be appended as last child of the node. |
|
2079 // --------------------------------------------------------------------------- |
|
2080 // |
|
2081 TFsTreeItemId CFSEmailUiMailListVisualiser::InsertListItemL( TInt aModelIndex, |
|
2082 TFsTreeItemId aParentNodeId, |
|
2083 TInt aChildIdx, /*= KErrNotFound*/ |
|
2084 TBool aAllowRefresh ) |
|
2085 { |
|
2086 FUNC_LOG; |
|
2087 TRect screenRect = iAppUi.ClientRect(); |
|
2088 CFsTreePlainTwoLineItemData* itemData(0); |
|
2089 CFsTreePlainTwoLineItemVisualizer* itemVisualizer(0); |
|
2090 TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
2091 TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
2092 |
|
2093 CFSEmailUiMailListModelItem* item = |
|
2094 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(aModelIndex) ); |
|
2095 |
|
2096 // Create data |
|
2097 itemData = CFsTreePlainTwoLineItemData::NewL(); |
|
2098 CleanupStack::PushL(itemData); |
|
2099 |
|
2100 // Read the data from the message |
|
2101 UpdateItemDataL( itemData, &item->MessagePtr() ); |
|
2102 |
|
2103 // Set placeholder for body preview |
|
2104 itemData->SetPreviewPaneDataL( KMissingPreviewDataMarker ); |
|
2105 |
|
2106 // Create item visualiser |
|
2107 itemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL(*iMailList->TreeControl()); |
|
2108 CleanupStack::PushL( itemVisualizer ); |
|
2109 |
|
2110 // Enable menu icon |
|
2111 itemVisualizer->SetFlags( itemVisualizer->Flags() | KFsTreeListItemHasMenu ); |
|
2112 |
|
2113 itemVisualizer->SetTextAlign( EAlfAlignHLocale ); |
|
2114 |
|
2115 TBool previewOn = ( iListMode == EListControlTypeDoubleLinePreviewOn || |
|
2116 iListMode == EListControlTypeSingleLinePreviewOn ); |
|
2117 itemVisualizer->SetPreviewPaneOn( previewOn ); |
|
2118 itemVisualizer->SetExtendable( ETrue ); |
|
2119 |
|
2120 itemVisualizer->SetFocusedStateTextColor( focusedColor ); |
|
2121 itemVisualizer->SetNormalStateTextColor( normalColor ); |
|
2122 |
|
2123 // Set font height |
|
2124 itemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
2125 |
|
2126 //Update icons and text bolding |
|
2127 //DOES NOT update the item - will be drawn automatically (if needed) during InsertItemL |
|
2128 UpdateMsgIconAndBoldingL( itemData, itemVisualizer, &item->MessagePtr() ); |
|
2129 |
|
2130 // Insert or append under the given node |
|
2131 TFsTreeItemId itemId(0); |
|
2132 itemId = iMailList->InsertItemL( *itemData, *itemVisualizer, aParentNodeId, aChildIdx, aAllowRefresh ); |
|
2133 |
|
2134 // The visualizer and data are now owned by the iMailList and should be removed from |
|
2135 // the cleanup stack |
|
2136 CleanupStack::Pop( itemVisualizer ); |
|
2137 CleanupStack::Pop( itemData ); |
|
2138 |
|
2139 // Insert corresponding item to iTreeItemArray |
|
2140 SMailListItem mailListItem; |
|
2141 mailListItem.iListItemId = itemId; |
|
2142 mailListItem.iTreeItemData = itemData; |
|
2143 mailListItem.iTreeItemVisualiser = itemVisualizer; |
|
2144 iTreeItemArray.InsertL( mailListItem, aModelIndex ); |
|
2145 item->AddCorrespondingListId( itemId ); |
|
2146 |
|
2147 // Updating the preview pane must be handled separately in this case; |
|
2148 // generic logic in TreeListEvent handler doesn't work while we are |
|
2149 // still in the middle of adding the item. |
|
2150 if ( iMailList->FocusedItem() == itemId ) |
|
2151 { |
|
2152 UpdatePreviewPaneTextIfNecessaryL( itemId, ETrue ); |
|
2153 } |
|
2154 |
|
2155 return itemId; |
|
2156 } |
|
2157 |
|
2158 // --------------------------------------------------------------------------- |
|
2159 // |
|
2160 // |
|
2161 // --------------------------------------------------------------------------- |
|
2162 // |
|
2163 HBufC* CFSEmailUiMailListVisualiser::GetListFirstTextLineL( const CFSMailMessage* aMsgPtr ) |
|
2164 { |
|
2165 FUNC_LOG; |
|
2166 HBufC* ret( NULL ); |
|
2167 |
|
2168 TDesC* displayName( NULL ); |
|
2169 TDesC* emailAddress( NULL ); |
|
2170 |
|
2171 TInt folderType( EFSInbox ); |
|
2172 if( iMailFolder ) |
|
2173 { |
|
2174 folderType = iMailFolder->GetFolderType(); |
|
2175 } |
|
2176 |
|
2177 // Use sender in all other folders than outbox, sent, and drafts |
|
2178 if ( folderType != EFSOutbox && |
|
2179 folderType != EFSSentFolder && |
|
2180 folderType != EFSDraftsFolder ) |
|
2181 { |
|
2182 CFSMailAddress* fromAddress = aMsgPtr->GetSender(); |
|
2183 if ( fromAddress ) |
|
2184 { |
|
2185 displayName = &fromAddress->GetDisplayName(); |
|
2186 emailAddress = &fromAddress->GetEmailAddress(); |
|
2187 |
|
2188 if ( displayName && displayName->Length() != 0 ) |
|
2189 { |
|
2190 ret = displayName->AllocL(); |
|
2191 } |
|
2192 else if ( emailAddress && emailAddress->Length() != 0 ) |
|
2193 { |
|
2194 ret = emailAddress->AllocL(); |
|
2195 } |
|
2196 } |
|
2197 else // no fromAddress in that case we show "(No sender info available)", |
|
2198 // in case sender sends MR to himself/herself |
|
2199 { |
|
2200 ret = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_MSG_DETAILS_NO_SENDER_INFO_AVAILABLE); |
|
2201 } |
|
2202 } |
|
2203 // Use first recipient in case of outgoing folders |
|
2204 else // folderType == EFSOutbox || folderType == EFSSentFolder || folderType == EFSDraftsFolder |
|
2205 { |
|
2206 CFSMailMessage* msgPtr = const_cast<CFSMailMessage*>( aMsgPtr ); // there's no const function in FW to get recipient data |
|
2207 RPointerArray<CFSMailAddress>& toArray = msgPtr->GetToRecipients(); |
|
2208 if ( toArray.Count() ) |
|
2209 { |
|
2210 CFSMailAddress* toAddress = toArray[0]; // Use first |
|
2211 if ( toAddress ) |
|
2212 { |
|
2213 displayName = &toAddress->GetDisplayName(); |
|
2214 emailAddress = &toAddress->GetEmailAddress(); |
|
2215 |
|
2216 if ( displayName && displayName->Length() ) |
|
2217 { |
|
2218 ret = displayName->AllocL(); |
|
2219 } |
|
2220 else if ( emailAddress && emailAddress->Length() ) |
|
2221 { |
|
2222 ret = emailAddress->AllocL(); |
|
2223 } |
|
2224 } |
|
2225 } |
|
2226 } |
|
2227 |
|
2228 // Allocate empty string if everything else fails |
|
2229 if ( !ret ) |
|
2230 { |
|
2231 ret = KNullDesC().AllocL(); |
|
2232 } |
|
2233 |
|
2234 // Drop out unwanted characters from display name such as <> and "" |
|
2235 TFsEmailUiUtility::StripDisplayName( *ret ); |
|
2236 |
|
2237 return ret; |
|
2238 } |
|
2239 |
|
2240 // --------------------------------------------------------------------------- |
|
2241 // |
|
2242 // |
|
2243 // --------------------------------------------------------------------------- |
|
2244 // |
|
2245 void CFSEmailUiMailListVisualiser::UpdateItemDataL( CFsTreePlainTwoLineItemData* aData, const CFSMailMessage* aMsgPtr ) |
|
2246 { |
|
2247 FUNC_LOG; |
|
2248 // Set first line of data |
|
2249 HBufC* firstLineText = GetListFirstTextLineL( aMsgPtr ); |
|
2250 if ( firstLineText ) |
|
2251 { |
|
2252 CleanupStack::PushL( firstLineText ); |
|
2253 aData->SetDataL( *firstLineText ); |
|
2254 CleanupStack::PopAndDestroy( firstLineText ); |
|
2255 } |
|
2256 else |
|
2257 { |
|
2258 aData->SetDataL( KNullDesC ); |
|
2259 } |
|
2260 |
|
2261 // Set second line of data |
|
2262 HBufC* subjectText = TFsEmailUiUtility::CreateSubjectTextLC( aMsgPtr ); |
|
2263 aData->SetSecondaryDataL( *subjectText ); |
|
2264 CleanupStack::PopAndDestroy( subjectText ); |
|
2265 |
|
2266 // Set time item in mail |
|
2267 HBufC* timeText = NULL; |
|
2268 if ( iCurrentSortCriteria.iField == EFSMailSortByDate ) |
|
2269 { |
|
2270 timeText = TFsEmailUiUtility::ListMsgTimeTextFromMsgLC( aMsgPtr, iNodesInUse ); |
|
2271 } |
|
2272 else |
|
2273 { |
|
2274 // Use dates also in other sort criterias that sort by date. |
|
2275 timeText = TFsEmailUiUtility::ListMsgTimeTextFromMsgLC( aMsgPtr, EFalse ); |
|
2276 } |
|
2277 aData->SetDateTimeDataL( *timeText ); |
|
2278 CleanupStack::PopAndDestroy( timeText ); |
|
2279 } |
|
2280 |
|
2281 // --------------------------------------------------------------------------- |
|
2282 // |
|
2283 // |
|
2284 // --------------------------------------------------------------------------- |
|
2285 // |
|
2286 void CFSEmailUiMailListVisualiser::UpdatePreviewPaneTextForItemL( TInt aListItemId, CFSMailMessage* aMsgPtr ) |
|
2287 { |
|
2288 FUNC_LOG; |
|
2289 if ( aMsgPtr && ( iListMode == EListControlTypeSingleLinePreviewOn || |
|
2290 iListMode == EListControlTypeDoubleLinePreviewOn ) ) |
|
2291 { |
|
2292 CFsTreePlainTwoLineItemData* twoLineItemData = static_cast<CFsTreePlainTwoLineItemData*>( ItemDataFromItemId( aListItemId ) ); |
|
2293 UpdatePreviewPaneTextForItemL( twoLineItemData, aMsgPtr ); |
|
2294 } |
|
2295 } |
|
2296 |
|
2297 // --------------------------------------------------------------------------- |
|
2298 // |
|
2299 // |
|
2300 // --------------------------------------------------------------------------- |
|
2301 // |
|
2302 void CFSEmailUiMailListVisualiser::UpdatePreviewPaneTextForItemL( |
|
2303 CFsTreePlainTwoLineItemData* aTwoLineItemData, CFSMailMessage* aMsgPtr ) |
|
2304 { |
|
2305 FUNC_LOG; |
|
2306 // Preview pane data update |
|
2307 if ( aTwoLineItemData && aMsgPtr && ( iListMode == EListControlTypeSingleLinePreviewOn || |
|
2308 iListMode == EListControlTypeDoubleLinePreviewOn ) ) |
|
2309 { |
|
2310 TBool previewSet = EFalse; |
|
2311 CFSMailMessagePart* textPart = aMsgPtr->PlainTextBodyPartL(); |
|
2312 CleanupStack::PushL( textPart ); |
|
2313 if ( textPart && ( textPart->FetchLoadState() == EFSPartial || |
|
2314 textPart->FetchLoadState() == EFSFull ) ) |
|
2315 { |
|
2316 TInt previewSize = Min( KMaxPreviewPaneLength, textPart->FetchedContentSize() ); |
|
2317 HBufC* plainTextData16 = HBufC::NewLC( previewSize ); |
|
2318 TPtr textPtr = plainTextData16->Des(); |
|
2319 |
|
2320 // Getting the content needs to be trapped as it seems to leave in some error cases |
|
2321 // at least with IMAP |
|
2322 TRAP_IGNORE( textPart->GetContentToBufferL( textPtr, 0 ) ); // Zero is start offset |
|
2323 // Crop out line feed, paragraph break, and tabulator |
|
2324 TFsEmailUiUtility::FilterListItemTextL( textPtr ); |
|
2325 |
|
2326 if ( textPtr.Length() ) |
|
2327 { |
|
2328 aTwoLineItemData->SetPreviewPaneDataL( *plainTextData16 ); |
|
2329 previewSet = ETrue; |
|
2330 } |
|
2331 |
|
2332 CleanupStack::PopAndDestroy( plainTextData16 ); |
|
2333 } |
|
2334 |
|
2335 // Display message size in preview pane if we got no body content |
|
2336 if ( !previewSet ) |
|
2337 { |
|
2338 TUint contentSize = aMsgPtr->ContentSize(); |
|
2339 HBufC* sizeDesc = TFsEmailUiUtility::CreateSizeDescLC( contentSize ); |
|
2340 HBufC* msgSizeText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_PREV_PANE_MSG_SIZE, *sizeDesc ); |
|
2341 aTwoLineItemData->SetPreviewPaneDataL( *msgSizeText ); |
|
2342 CleanupStack::PopAndDestroy( msgSizeText ); |
|
2343 CleanupStack::PopAndDestroy( sizeDesc ); |
|
2344 } |
|
2345 CleanupStack::PopAndDestroy( textPart ); |
|
2346 } |
|
2347 } |
|
2348 |
|
2349 // --------------------------------------------------------------------------- |
|
2350 // |
|
2351 // |
|
2352 // --------------------------------------------------------------------------- |
|
2353 // |
|
2354 void CFSEmailUiMailListVisualiser::UpdatePreviewPaneTextIfNecessaryL( TFsTreeItemId aListItemId, TBool aUpdateItem ) |
|
2355 { |
|
2356 FUNC_LOG; |
|
2357 if ( iFirstStartCompleted && aListItemId != KFsTreeNoneID ) |
|
2358 { |
|
2359 if ( iListMode == EListControlTypeSingleLinePreviewOn || |
|
2360 iListMode == EListControlTypeDoubleLinePreviewOn ) |
|
2361 { |
|
2362 if ( !iMailList->IsNode( aListItemId ) ) |
|
2363 { |
|
2364 TInt idx = ModelIndexFromListId( aListItemId ); |
|
2365 if ( idx != KErrNotFound ) |
|
2366 { |
|
2367 CFsTreePlainTwoLineItemData* data = |
|
2368 static_cast<CFsTreePlainTwoLineItemData*>( iTreeItemArray[idx].iTreeItemData ); |
|
2369 if ( data->PreviewPaneData() == KMissingPreviewDataMarker ) |
|
2370 { |
|
2371 CFSEmailUiMailListModelItem* modelItem = |
|
2372 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(idx) ); |
|
2373 CFSMailMessage& msgRef = modelItem->MessagePtr(); |
|
2374 UpdatePreviewPaneTextForItemL( aListItemId, &msgRef ); |
|
2375 if ( aUpdateItem ) |
|
2376 { |
|
2377 iMailTreeListVisualizer->UpdateItemL( aListItemId ); |
|
2378 } |
|
2379 } |
|
2380 } |
|
2381 } |
|
2382 } |
|
2383 } |
|
2384 } |
|
2385 |
|
2386 // --------------------------------------------------------------------------- |
|
2387 // |
|
2388 // |
|
2389 // --------------------------------------------------------------------------- |
|
2390 // |
|
2391 void CFSEmailUiMailListVisualiser::CreatePlainNodeL( const TDesC* aItemDataBuff, |
|
2392 CFsTreePlainOneLineNodeData* &aItemData, |
|
2393 CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const |
|
2394 { |
|
2395 FUNC_LOG; |
|
2396 aItemData = CFsTreePlainOneLineNodeData::NewL(); |
|
2397 CleanupStack::PushL( aItemData ); |
|
2398 |
|
2399 aItemData->SetDataL( *aItemDataBuff ); |
|
2400 aItemData->SetIconExpanded( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeExpanded )); |
|
2401 aItemData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed )); |
|
2402 aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL(*iMailList->TreeControl()); |
|
2403 CleanupStack::PushL( aNodeVisualizer ); |
|
2404 TRect screenRect = iAppUi.ClientRect(); |
|
2405 TInt nodeHeight = iAppUi.LayoutHandler()->OneLineListNodeHeight(); |
|
2406 aNodeVisualizer->SetSize( TSize(screenRect.Width(), nodeHeight) ); |
|
2407 aNodeVisualizer->SetExtendable(EFalse); |
|
2408 // Set correct skin text colors for the list items |
|
2409 TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
2410 TRgb normalColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
|
2411 aNodeVisualizer->SetFocusedStateTextColor( focusedColor ); |
|
2412 aNodeVisualizer->SetNormalStateTextColor( normalColor ); |
|
2413 // Set font height |
|
2414 aNodeVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
2415 // Set font always bolded in nodes |
|
2416 aNodeVisualizer->SetTextBold( ETrue ); |
|
2417 |
|
2418 //<cmail> |
|
2419 CAlfBrush* titleDividerBgBrush = |
|
2420 iAppUi.FsTextureManager()->TitleDividerBgBrushL(); |
|
2421 // ownership is not transfered |
|
2422 aNodeVisualizer->SetBackgroundBrush( titleDividerBgBrush ); |
|
2423 //</cmail> |
|
2424 |
|
2425 CleanupStack::Pop( aNodeVisualizer ); |
|
2426 CleanupStack::Pop( aItemData ); |
|
2427 } |
|
2428 |
|
2429 // --------------------------------------------------------------------------- |
|
2430 // |
|
2431 // |
|
2432 // --------------------------------------------------------------------------- |
|
2433 // |
|
2434 void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType ) |
|
2435 { |
|
2436 FUNC_LOG; |
|
2437 CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType ); |
|
2438 |
|
2439 if ( iFirstStartCompleted ) // Safety |
|
2440 { |
|
2441 if ( aType == ESkinChanged ) |
|
2442 { |
|
2443 iSkinChanged = ETrue; |
|
2444 } |
|
2445 else |
|
2446 { |
|
2447 iMailTreeListVisualizer->HideList(); |
|
2448 // screen layout changed |
|
2449 iCurrentClientRect = iAppUi.ClientRect(); |
|
2450 iScreenAnchorLayout->SetSize( iCurrentClientRect.Size() ); |
|
2451 SetMailListLayoutAnchors(); |
|
2452 // Set branded watermark |
|
2453 SetBrandedListWatermarkL(); |
|
2454 iMailTreeListVisualizer->ShowListL(); |
|
2455 |
|
2456 ScaleControlBarL(); |
|
2457 SetBrandedMailBoxIconL(); |
|
2458 } |
|
2459 // Update the folder/sort popup layout in case it happened to be open |
|
2460 if ( iAppUi.FolderList().IsPopupShown() ) |
|
2461 { |
|
2462 iAppUi.FolderList().HandleDynamicVariantSwitchL( aType ); |
|
2463 } |
|
2464 } |
|
2465 } |
|
2466 |
|
2467 // --------------------------------------------------------------------------- |
|
2468 // |
|
2469 // |
|
2470 // --------------------------------------------------------------------------- |
|
2471 // |
|
2472 void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType ) |
|
2473 { |
|
2474 FUNC_LOG; |
|
2475 CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType ); |
|
2476 if ( aType == ESkinChanged ) |
|
2477 { |
|
2478 iSkinChanged = ETrue; |
|
2479 } |
|
2480 } |
|
2481 |
|
2482 // --------------------------------------------------------------------------- |
|
2483 // HandleForegroundEventL |
|
2484 // Function checks in foregroundevent that whether settings have changed and |
|
2485 // If there is a need to refresh the list. |
|
2486 // --------------------------------------------------------------------------- |
|
2487 // |
|
2488 void CFSEmailUiMailListVisualiser::HandleForegroundEventL() |
|
2489 { |
|
2490 FUNC_LOG; |
|
2491 if ( iFirstStartCompleted ) // Safety |
|
2492 { |
|
2493 // Update mail list settings and date formats, is done every time |
|
2494 // the user might have changed these in settings, so the list needs to refresh |
|
2495 // Store previous modes |
|
2496 TInt prevListMode = iListMode; |
|
2497 TInt prevNodesmode = iNodesInUse; |
|
2498 TAknUiZoom prevZoomLevel = iCurrentZoomLevel; |
|
2499 STimeDateFormats prevDateFormats = MailListTimeDateSettings(); |
|
2500 |
|
2501 // Get new settings and list drawing modes |
|
2502 CAknEnv::Static()->GetCurrentGlobalUiZoom( iCurrentZoomLevel ); |
|
2503 UpdateMailListSettingsL(); |
|
2504 UpdateMailListTimeDateSettings(); |
|
2505 |
|
2506 // Check sync icon timer and sync status |
|
2507 ConnectionIconHandling(); |
|
2508 |
|
2509 // Updates the folder list's size after the screensaver |
|
2510 iAppUi.FolderList().HandleForegroundEventL(); |
|
2511 |
|
2512 // Check for changed settings, in that case a complete list refresh is needed |
|
2513 if ( iSkinChanged |
|
2514 || iDateChanged |
|
2515 || iListMode != prevListMode |
|
2516 || iNodesInUse != prevNodesmode |
|
2517 || iCurrentZoomLevel != prevZoomLevel |
|
2518 || prevDateFormats.iDateFormat != iDateFormats.iDateFormat |
|
2519 || prevDateFormats.iTimeFormat != iDateFormats.iTimeFormat |
|
2520 || prevDateFormats.iAmPmPosition != iDateFormats.iAmPmPosition |
|
2521 || prevDateFormats.iDateSeparator != iDateFormats.iDateSeparator |
|
2522 || prevDateFormats.iTimeSeparator != iDateFormats.iTimeSeparator ) |
|
2523 { |
|
2524 // Store the list of marked items. The markings are erased when the list |
|
2525 // is repopulated and, hence, the markings need to be reset after the |
|
2526 // refreshing is done. The marked items must be identified by the message |
|
2527 // ID rather than with the list ID because refreshing may change the list IDs. |
|
2528 RArray<TFSMailMsgId> markedMessages; |
|
2529 CleanupClosePushL( markedMessages ); |
|
2530 GetMarkedMessagesL( markedMessages ); |
|
2531 // Store the message ID of the focused item |
|
2532 TFSMailMsgId msgIdBeforeRefresh = MsgIdFromListId( iMailList->FocusedItem() ); |
|
2533 TFsTreeItemId firstVisibleListId = iMailTreeListVisualizer->FirstVisibleItem(); |
|
2534 TInt modelFirstIndexBeforeUpdate = ModelIndexFromListId( firstVisibleListId ); |
|
2535 TInt highlightedIndexBeforeUpdate = HighlightedIndex(); |
|
2536 TInt modelCountBeforeUpdate = iModel->Count(); |
|
2537 |
|
2538 UpdateMailListModelL(); |
|
2539 if ( markedMessages.Count() ) |
|
2540 { |
|
2541 RefreshL( &msgIdBeforeRefresh ); |
|
2542 // Restore the marking status |
|
2543 MarkMessagesIfFoundL( markedMessages ); |
|
2544 } |
|
2545 else |
|
2546 { |
|
2547 RefreshDeferred( &msgIdBeforeRefresh ); |
|
2548 } |
|
2549 CleanupStack::PopAndDestroy( &markedMessages ); |
|
2550 iSkinChanged = EFalse; // Toggle handled |
|
2551 iDateChanged = EFalse; // Toggle handled |
|
2552 } |
|
2553 } |
|
2554 } |
|
2555 |
|
2556 |
|
2557 // --------------------------------------------------------------------------- |
|
2558 // |
|
2559 // |
|
2560 // --------------------------------------------------------------------------- |
|
2561 // |
|
2562 void CFSEmailUiMailListVisualiser::HandleCommandL( TInt aCommand ) |
|
2563 { |
|
2564 FUNC_LOG; |
|
2565 CompletePendingRefresh(); |
|
2566 |
|
2567 // custom command handling for launching plugin settings |
|
2568 if ( EFsEmailUiCmdSettingsBaseCommandId <= aCommand |
|
2569 && EFsEmailUiCmdSettingsBaseCommandIdMax > aCommand ) |
|
2570 { |
|
2571 CESMailSettingsPlugin::TSubViewActivationData activationData; |
|
2572 activationData.iAccount = iAppUi.GetActiveMailbox()->GetId(); |
|
2573 // which settings plugin subview will be activated |
|
2574 TInt selectedCommand = aCommand - EFsEmailUiCmdSettingsBaseCommandId; |
|
2575 activationData.iSubviewId = selectedCommand; |
|
2576 |
|
2577 TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid(); |
|
2578 |
|
2579 // If plugin view does not exist, create and register it to app ui. |
|
2580 if ( !iAppUi.View( pluginUid ) ) |
|
2581 { |
|
2582 CESMailSettingsPlugin* plugin = CESMailSettingsPlugin::NewL( pluginUid ); |
|
2583 CleanupStack::PushL( plugin ); |
|
2584 iAppUi.AddViewL( plugin ); // Ownership is transferred. |
|
2585 CleanupStack::Pop( plugin ); |
|
2586 } |
|
2587 TUid messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview ); |
|
2588 const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData> pluginMessagePkg( activationData ); |
|
2589 |
|
2590 StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
2591 iAppUi.EnterPluginSettingsViewL( pluginUid, messageId, pluginMessagePkg ); |
|
2592 } |
|
2593 |
|
2594 // Many commands may be targetted either to the focused item or to the marked item(s). |
|
2595 // Get list of marked or focused items. |
|
2596 RFsTreeItemIdList actionTargetItems; |
|
2597 CleanupClosePushL( actionTargetItems ); |
|
2598 GetActionsTargetEntriesL( actionTargetItems ); |
|
2599 |
|
2600 switch(aCommand) |
|
2601 { |
|
2602 case EAknSoftkeyOpen: |
|
2603 { |
|
2604 if (!iAppUi.IsTimerFocusShown()) |
|
2605 { |
|
2606 iAppUi.StartFocusRemovalTimer(); |
|
2607 break; |
|
2608 } |
|
2609 } |
|
2610 case EAknSoftkeySelect: |
|
2611 { |
|
2612 if ( iFocusedControl == EMailListComponent ) |
|
2613 { |
|
2614 CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex())); |
|
2615 // MAIL ITEM; OPEN MAIL |
|
2616 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
2617 { |
|
2618 CFSMailMessage* messagePtr = &item->MessagePtr(); |
|
2619 if ( messagePtr ) |
|
2620 { |
|
2621 OpenHighlightedMailL(); |
|
2622 } |
|
2623 } |
|
2624 } |
|
2625 } |
|
2626 break; |
|
2627 case EAknSoftkeyChange: |
|
2628 { |
|
2629 if (!iAppUi.IsTimerFocusShown()) |
|
2630 { |
|
2631 iAppUi.StartFocusRemovalTimer(); |
|
2632 break; |
|
2633 } |
|
2634 if ( iFocusedControl == EControlBarComponent ) |
|
2635 { |
|
2636 TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id(); |
|
2637 if ( focusedButtonId == iFolderListButtonId ) |
|
2638 { |
|
2639 //<cmail> |
|
2640 //Set touchmanager not active for preventing getting events. |
|
2641 DisableMailList(ETrue); |
|
2642 //</cmail> |
|
2643 iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton ); |
|
2644 } |
|
2645 else if ( focusedButtonId == iSortButtonId ) |
|
2646 { |
|
2647 TFSFolderType folderType; |
|
2648 if( iMailFolder ) |
|
2649 { |
|
2650 folderType = iMailFolder->GetFolderType(); |
|
2651 } |
|
2652 else |
|
2653 { |
|
2654 folderType = EFSInbox; |
|
2655 } |
|
2656 // <cmail> Sorting set possible even for empty mailbox |
|
2657 // Show sort if model has data. |
|
2658 //if ( iModel->Count() ) |
|
2659 // { |
|
2660 // </cmail> |
|
2661 //<cmail> |
|
2662 //Set touchmanager not active for preventing getting events. |
|
2663 DisableMailList(ETrue); |
|
2664 //</cmail> |
|
2665 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton ); |
|
2666 // <cmail> |
|
2667 // } |
|
2668 // </cmail> |
|
2669 } |
|
2670 } |
|
2671 } |
|
2672 break; |
|
2673 case EAknSoftkeyBack: |
|
2674 if ( !iAppUi.ViewSwitchingOngoing() ) |
|
2675 { |
|
2676 NavigateBackL(); |
|
2677 } |
|
2678 break; |
|
2679 case EEikCmdExit: |
|
2680 case EAknSoftkeyExit: |
|
2681 case EFsEmailUiCmdExit: |
|
2682 iAppUi.Exit(); |
|
2683 break; |
|
2684 case EFsEmailUiCmdCalActionsReplyAsMail: |
|
2685 case EFsEmailUiCmdActionsReply: |
|
2686 { |
|
2687 ReplyL( NULL ); // Function will check marked/highlighted msg |
|
2688 } |
|
2689 break; |
|
2690 case EFsEmailUiCmdActionsReplyAll: |
|
2691 { |
|
2692 ReplyAllL( NULL ); // Function will check marked/highlighted msg |
|
2693 } |
|
2694 break; |
|
2695 case EFsEmailUiCmdCalActionsForwardAsMail: |
|
2696 case EFsEmailUiCmdActionsForward: |
|
2697 { |
|
2698 ForwardL( NULL ); // Function will check marked/highlighted msg |
|
2699 } |
|
2700 break; |
|
2701 case EFsEmailUiCmdActionsCallSender: |
|
2702 { |
|
2703 if ( !iAppUi.ViewSwitchingOngoing() ) |
|
2704 { |
|
2705 if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox && |
|
2706 iMailFolder->GetFolderType() != EFSDraftsFolder ) |
|
2707 { |
|
2708 // Calling can happen only when there's exactly one message marked or in focus |
|
2709 if ( actionTargetItems.Count() == 1 ) |
|
2710 { |
|
2711 CFSMailMessage& message = MsgPtrFromListIdL( actionTargetItems[0] ); |
|
2712 CFSMailAddress* fromAddress = message.GetSender(); |
|
2713 TDesC* mailAddress(0); |
|
2714 if ( fromAddress ) |
|
2715 { |
|
2716 mailAddress = &fromAddress->GetEmailAddress(); |
|
2717 } |
|
2718 if ( mailAddress && mailAddress->Length() ) |
|
2719 { |
|
2720 if ( iMailFolder->GetFolderType() == EFSSentFolder ) |
|
2721 { |
|
2722 CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( |
|
2723 *mailAddress, iAppUi.GetActiveMailbox(), this, EFalse ); |
|
2724 } |
|
2725 else |
|
2726 { |
|
2727 CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( |
|
2728 *mailAddress, iAppUi.GetActiveMailbox(), this, ETrue ); |
|
2729 } |
|
2730 } |
|
2731 } |
|
2732 } |
|
2733 } |
|
2734 } |
|
2735 break; |
|
2736 case EFsEmailUiCmdMarkAsRead: |
|
2737 { |
|
2738 // Change status of marked or highlighted |
|
2739 if ( CountMarkedItemsL() ) |
|
2740 { |
|
2741 ChangeReadStatusOfMarkedL( ETrue ); |
|
2742 } |
|
2743 else |
|
2744 { |
|
2745 ChangeReadStatusOfHighlightedL( ETrue ); |
|
2746 } |
|
2747 } |
|
2748 break; |
|
2749 case EFsEmailUiCmdMarkAsUnread: |
|
2750 { |
|
2751 // Change status of marked or highlighted |
|
2752 if ( CountMarkedItemsL() ) |
|
2753 { |
|
2754 ChangeReadStatusOfMarkedL( EFalse ); |
|
2755 } |
|
2756 else |
|
2757 { |
|
2758 ChangeReadStatusOfHighlightedL( EFalse ); |
|
2759 } |
|
2760 } |
|
2761 break; |
|
2762 case EFsEmailUiCmdGoToTop: |
|
2763 { |
|
2764 // Safety check, ignore command if the list is empty |
|
2765 if( iTreeItemArray.Count() ) |
|
2766 { |
|
2767 if ( iFocusedControl != EMailListComponent ) |
|
2768 { |
|
2769 iFocusedControl = EMailListComponent; |
|
2770 iMailList->SetFocusedL( ETrue ); |
|
2771 iControlBarControl->SetFocusL( EFalse ); |
|
2772 } |
|
2773 // No need to check for nodes as in move to bottom. |
|
2774 iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[0].iListItemId ); |
|
2775 } |
|
2776 } |
|
2777 break; |
|
2778 case EFsEmailUiCmdGoToBottom: |
|
2779 { |
|
2780 // Safety check, ignore command if the list is empty |
|
2781 if( iTreeItemArray.Count() ) |
|
2782 { |
|
2783 if ( iFocusedControl != EMailListComponent ) |
|
2784 { |
|
2785 iFocusedControl = EMailListComponent; |
|
2786 iMailList->SetFocusedL( ETrue ); |
|
2787 iControlBarControl->SetFocusL( EFalse ); |
|
2788 } |
|
2789 |
|
2790 TFsTreeItemId bottomItem = iTreeItemArray[iTreeItemArray.Count()-1].iListItemId; |
|
2791 TFsTreeItemId parentItem = ParentNode( bottomItem ); // parent node of the bottom item |
|
2792 |
|
2793 // Check whether the parent is node and is collapsed |
|
2794 if ( parentItem>0 && !iMailList->IsExpanded( parentItem ) ) |
|
2795 { |
|
2796 bottomItem = parentItem; |
|
2797 } |
|
2798 iMailTreeListVisualizer->SetFocusedItemL( bottomItem ); |
|
2799 } |
|
2800 } |
|
2801 break; |
|
2802 case EFsEmailUiCmdPageUp: |
|
2803 { |
|
2804 TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 }; |
|
2805 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey ); |
|
2806 } |
|
2807 break; |
|
2808 case EFsEmailUiCmdPageDown: |
|
2809 { |
|
2810 TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 }; |
|
2811 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey ); |
|
2812 } |
|
2813 break; |
|
2814 case EFsEmailUiCmdActionsDeleteCalEvent: |
|
2815 case EFsEmailUiCmdActionsDelete: |
|
2816 { |
|
2817 TInt index = HighlightedIndex(); |
|
2818 CFSEmailUiMailListModelItem* item = |
|
2819 dynamic_cast<CFSEmailUiMailListModelItem*>( |
|
2820 iModel->Item( index ) ); |
|
2821 |
|
2822 // If selected item is separator (divider) mark/unmark all messages |
|
2823 // under it. |
|
2824 if ( item && item->ModelItemType() == ETypeSeparator ) |
|
2825 { |
|
2826 MarkItemsUnderSeparatorL( ETrue, index ); |
|
2827 } |
|
2828 |
|
2829 // Delete message only if mail list component is focused |
|
2830 // or if there are some marked items |
|
2831 TInt markedItems( CountMarkedItemsL() ); |
|
2832 |
|
2833 if ( iFocusedControl == EMailListComponent || markedItems ) |
|
2834 { |
|
2835 DeleteMessagesL(); |
|
2836 } |
|
2837 UnmarkAllItemsL(); |
|
2838 } |
|
2839 break; |
|
2840 case EFsEmailUiCmdCompose: |
|
2841 { |
|
2842 CreateNewMsgL(); |
|
2843 } |
|
2844 break; |
|
2845 case EFsEmailUiCmdMessageDetails: |
|
2846 { |
|
2847 // Message details can be viewed only when there's exactly one message marked or in focus |
|
2848 if ( actionTargetItems.Count() == 1 ) |
|
2849 { |
|
2850 CFSMailMessage& message = MsgPtrFromListIdL( actionTargetItems[0] ); |
|
2851 TMsgDetailsActivationData msgDetailsData; |
|
2852 msgDetailsData.iMailBoxId = iAppUi.GetActiveMailboxId(); |
|
2853 msgDetailsData.iFolderId = FolderId(); |
|
2854 msgDetailsData.iMessageId = message.GetMessageId(); |
|
2855 const TPckgBuf<TMsgDetailsActivationData> pkgOut( msgDetailsData ); |
|
2856 iAppUi.EnterFsEmailViewL( MsgDetailsViewId, KStartMsgDetailsToBeginning, pkgOut ); |
|
2857 } |
|
2858 } |
|
2859 break; |
|
2860 case EFsEmailUiCmdSettingsGlobal: |
|
2861 { |
|
2862 iAppUi.EnterFsEmailViewL( GlobalSettingsViewId ); |
|
2863 } |
|
2864 break; |
|
2865 case EFsEmailUiCmdSettingsService: |
|
2866 case EFsEmailUiCmdSettingsMailbox: |
|
2867 { |
|
2868 CESMailSettingsPlugin::TSubViewActivationData activationData; |
|
2869 activationData.iAccount = iAppUi.GetActiveMailbox()->GetId(); |
|
2870 activationData.iSubviewId = 0; |
|
2871 if ( EFsEmailUiCmdSettingsService == aCommand ) |
|
2872 { |
|
2873 activationData.iSubviewId = 1; |
|
2874 } |
|
2875 |
|
2876 TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid(); |
|
2877 // register plugin view if not exists so that activation can be made |
|
2878 if ( !iAppUi.View( pluginUid ) ) |
|
2879 { |
|
2880 CESMailSettingsPlugin* plugin = CESMailSettingsPlugin::NewL( pluginUid ); |
|
2881 CleanupStack::PushL( plugin ); |
|
2882 iAppUi.AddViewL( plugin ); |
|
2883 CleanupStack::Pop( plugin ); |
|
2884 } |
|
2885 TUid messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview ); |
|
2886 const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData> pluginMessagePkg( activationData ); |
|
2887 iAppUi.EnterPluginSettingsViewL( pluginUid, messageId, pluginMessagePkg ); |
|
2888 } |
|
2889 break; |
|
2890 case EFsEmailUiCmdOpen: |
|
2891 case EFsEmailUiCmdActionsOpen: |
|
2892 { |
|
2893 if ( iFocusedControl == EMailListComponent ) |
|
2894 { |
|
2895 // Opening can happen only when there's exactly one message marked or in focus |
|
2896 if ( actionTargetItems.Count() == 1 ) |
|
2897 { |
|
2898 OpenMailItemL( actionTargetItems[0] ); |
|
2899 } |
|
2900 } |
|
2901 } |
|
2902 break; |
|
2903 case EFsEmailUiCmdActionsFlag: |
|
2904 { |
|
2905 SetMessageFollowupFlagL(); |
|
2906 } |
|
2907 break; |
|
2908 case EFsEmailUiCmdActionsCollapseAll: |
|
2909 // Safety check, ignore command if the list is empty |
|
2910 if( iMailList->Count() ) |
|
2911 { |
|
2912 CollapseAllNodesL(); |
|
2913 } |
|
2914 break; |
|
2915 case EFsEmailUiCmdActionsExpandAll: |
|
2916 // Safety check, ignore command if the list is empty |
|
2917 if( iMailList->Count() ) |
|
2918 { |
|
2919 ExpandAllNodesL(); |
|
2920 } |
|
2921 break; |
|
2922 case EFsEmailUiCmdCollapse: |
|
2923 if (!iAppUi.IsTimerFocusShown()) |
|
2924 { |
|
2925 iAppUi.StartFocusRemovalTimer(); |
|
2926 break; |
|
2927 } |
|
2928 // Safety check, ignore command if the list is empty |
|
2929 if( iMailList->Count() ) |
|
2930 { |
|
2931 ExpandOrCollapseL(); |
|
2932 } |
|
2933 break; |
|
2934 case EFsEmailUiCmdExpand: |
|
2935 if (!iAppUi.IsTimerFocusShown()) |
|
2936 { |
|
2937 iAppUi.StartFocusRemovalTimer(); |
|
2938 break; |
|
2939 } |
|
2940 // Safety check, ignore command if the list is empty |
|
2941 if( iMailList->Count() ) |
|
2942 { |
|
2943 ExpandOrCollapseL(); |
|
2944 } |
|
2945 break; |
|
2946 case EFsEmailUiCmdSearch: |
|
2947 { |
|
2948 TSearchListActivationData tmp; |
|
2949 tmp.iMailBoxId = iAppUi.GetActiveMailbox()->GetId(); |
|
2950 const TPckgBuf<TSearchListActivationData> pkgOut( tmp ); |
|
2951 iAppUi.EnterFsEmailViewL( SearchListViewId, KStartNewSearch, pkgOut ); |
|
2952 } |
|
2953 break; |
|
2954 // <cmail> Prevent Download Manager opening with attachments |
|
2955 // case EFsEmailUiCmdDownloadManager: |
|
2956 // iAppUi.EnterFsEmailViewL( DownloadManagerViewId ); |
|
2957 // break; |
|
2958 // </cmail> |
|
2959 case EFsEmailUiCmdMarkMark: |
|
2960 { |
|
2961 iListMarkItemsState = ETrue; // shift-scrolling does marking after one item is marked |
|
2962 iMailList->MarkItemL( iMailList->FocusedItem(), ETrue ); |
|
2963 } |
|
2964 break; |
|
2965 case EFsEmailUiCmdMarkMarkAll: |
|
2966 { |
|
2967 MarkAllItemsL(); |
|
2968 } |
|
2969 break; |
|
2970 case EFsEmailUiCmdMarkUnmark: |
|
2971 { |
|
2972 iListMarkItemsState = EFalse; // shift-scrolling does unmarking after one item is unmarked |
|
2973 iMailList->MarkItemL( iMailList->FocusedItem(), EFalse ); |
|
2974 } |
|
2975 break; |
|
2976 case EFsEmailUiCmdMarkUnmarkAll: |
|
2977 { |
|
2978 UnmarkAllItemsL(); |
|
2979 } |
|
2980 break; |
|
2981 case EFsEmailUiCmdReadEmail: |
|
2982 { |
|
2983 iAppUi.StartReadingEmailsL(); |
|
2984 } |
|
2985 break; |
|
2986 case EFsEmailUiCmdSync: |
|
2987 { |
|
2988 TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync ); |
|
2989 if ( supportsSync ) |
|
2990 { |
|
2991 //If synchronizing is ongoing and a new sync is started we ignore it |
|
2992 if(!GetLatestSyncState()) |
|
2993 { |
|
2994 iAppUi.SyncActiveMailBoxL(); |
|
2995 // Sync was started by the user |
|
2996 ManualMailBoxSync(ETrue); |
|
2997 iAppUi.ManualMailBoxSync( ETrue ); |
|
2998 } |
|
2999 } |
|
3000 } |
|
3001 break; |
|
3002 case EFsEmailUiCmdCancelSync: |
|
3003 { |
|
3004 TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync ); |
|
3005 if ( supportsSync ) |
|
3006 { |
|
3007 iAppUi.StopActiveMailBoxSyncL(); |
|
3008 CFSMailBox* mb = iAppUi.GetActiveMailbox(); |
|
3009 TDesC* mbName = &mb->GetName(); |
|
3010 } |
|
3011 } |
|
3012 break; |
|
3013 case EFsEmailUiCmdGoOffline: |
|
3014 { |
|
3015 iAppUi.GetActiveMailbox()->GoOfflineL(); |
|
3016 } |
|
3017 break; |
|
3018 case EFsEmailUiCmdGoOnline: |
|
3019 { |
|
3020 CFSMailBox* mb = iAppUi.GetActiveMailbox(); |
|
3021 TDesC* mbName = &mb->GetName(); |
|
3022 iAppUi.ManualMailBoxSync( ETrue ); |
|
3023 mb->GoOnlineL(); |
|
3024 } |
|
3025 break; |
|
3026 case EFsEmailUiCmdHelp: |
|
3027 { |
|
3028 |
|
3029 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID ); |
|
3030 } |
|
3031 break; |
|
3032 |
|
3033 |
|
3034 case EFsEmailUiCmdActionsAddContact: |
|
3035 { |
|
3036 // contact can be got from message only when there's exactly one target message |
|
3037 if ( actionTargetItems.Count() == 1 && iMailFolder ) |
|
3038 { |
|
3039 CFSMailMessage& message = MsgPtrFromListIdL( actionTargetItems[0] ); |
|
3040 |
|
3041 CFSMailAddress* addressToBeStored(0); |
|
3042 TInt folderType = iMailFolder->GetFolderType(); |
|
3043 // Use first to recepient in outbox, drafts and sent if found. |
|
3044 if ( folderType == EFSOutbox || folderType == EFSDraftsFolder || folderType == EFSSentFolder ) |
|
3045 { |
|
3046 RPointerArray<CFSMailAddress>& toArray = message.GetToRecipients(); |
|
3047 if ( toArray.Count() ) |
|
3048 { |
|
3049 addressToBeStored = toArray[0]; |
|
3050 } |
|
3051 } |
|
3052 // Use sender in all other "normal" folders |
|
3053 else |
|
3054 { |
|
3055 addressToBeStored = message.GetSender(); |
|
3056 } |
|
3057 TDesC* emailAddressText(0); |
|
3058 if ( addressToBeStored ) |
|
3059 { |
|
3060 emailAddressText = &addressToBeStored->GetEmailAddress(); |
|
3061 } |
|
3062 if ( emailAddressText && emailAddressText->Length() ) |
|
3063 { |
|
3064 TAddToContactsType type; |
|
3065 //Query to "update existing" or "Create new" --> EFALSE = user choosed "cancel" |
|
3066 if ( CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddtoContactsQueryL( type ) ) |
|
3067 { |
|
3068 CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL( |
|
3069 *emailAddressText, EContactUpdateEmail, type, this ); |
|
3070 } |
|
3071 } |
|
3072 } |
|
3073 } |
|
3074 break; |
|
3075 case EFsEmailUiCmdActionsMove: |
|
3076 case EFsEmailUiCmdActionsMoveMessage: |
|
3077 { |
|
3078 TFSMailMsgId folderID; |
|
3079 folderID.SetNullId(); // Selection is popped up with NULL |
|
3080 MoveMsgsToFolderL( folderID ); |
|
3081 } |
|
3082 break; |
|
3083 case EFsEmailUiCmdActionsMoveToDrafts: |
|
3084 { |
|
3085 MoveMessagesToDraftsL(); |
|
3086 } |
|
3087 break; |
|
3088 case EFsEmailUiCmdActionsCopyMessage: |
|
3089 { |
|
3090 } |
|
3091 break; |
|
3092 case EFsEmailUiCmdActionsCollapseExpandAllToggle: |
|
3093 { |
|
3094 ShortcutCollapseExpandAllToggleL(); |
|
3095 } |
|
3096 break; |
|
3097 case EFsEmailUiCmdMarkAsReadUnreadToggle: |
|
3098 { |
|
3099 ShortcutReadUnreadToggleL(); |
|
3100 } |
|
3101 break; |
|
3102 case EFsEmailUiCmdMarkUnmarkToggle: |
|
3103 { |
|
3104 TInt focusedItem = iMailList->FocusedItem(); |
|
3105 if ( focusedItem > 0 && iFocusedControl == EMailListComponent ) |
|
3106 { |
|
3107 CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex())); |
|
3108 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
3109 { |
|
3110 if ( iMailList->IsMarked( focusedItem ) ) |
|
3111 { |
|
3112 HandleCommandL(EFsEmailUiCmdMarkUnmark); |
|
3113 } |
|
3114 else |
|
3115 { |
|
3116 HandleCommandL(EFsEmailUiCmdMarkMark); |
|
3117 } |
|
3118 } |
|
3119 else if ( item->ModelItemType() == ETypeSeparator ) |
|
3120 { |
|
3121 // Mark items. |
|
3122 MarkItemsUnderSeparatorL( ETrue, HighlightedIndex() ); |
|
3123 iListMarkItemsState = ETrue; // Enable mark mode |
|
3124 } |
|
3125 } |
|
3126 } |
|
3127 break; |
|
3128 case EFsEmailUiCmdGoToSwitchFolder: |
|
3129 { |
|
3130 iControlBarControl->SetFocusByIdL( iFolderListButtonId ); |
|
3131 iFocusedControl = EControlBarComponent; |
|
3132 iMailList->SetFocusedL( EFalse ); |
|
3133 } |
|
3134 break; |
|
3135 case EFsEmailUiCmdGoToSwitchSorting: |
|
3136 { |
|
3137 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
|
3138 iFocusedControl = EControlBarComponent; |
|
3139 iMailList->SetFocusedL( EFalse ); |
|
3140 } |
|
3141 break; |
|
3142 case EFsEmailUiCmdCalActionsAccept: |
|
3143 case EFsEmailUiCmdCalActionsTentative: |
|
3144 case EFsEmailUiCmdCalActionsDecline: |
|
3145 case EFsEmailUiCmdCalRemoveFromCalendar: |
|
3146 { |
|
3147 if ( actionTargetItems.Count() == 1 ) |
|
3148 { |
|
3149 TInt mrItemIdx = ModelIndexFromListId( actionTargetItems[0] ); |
|
3150 CFSEmailUiMailListModelItem* item = |
|
3151 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item(mrItemIdx) ); |
|
3152 if ( item && item->MessagePtr().IsFlagSet( EFSMsgFlag_CalendarMsg ) ) |
|
3153 { |
|
3154 // Respond to meeting request |
|
3155 if ( iAppUi.MrViewerInstanceL() && iAppUi.MrViewerInstanceL()->CanViewMessage( item->MessagePtr() ) ) |
|
3156 { |
|
3157 ChangeReadStatusOfHighlightedL( ETrue ); |
|
3158 iAppUi.MailViewer().HandleMrCommandL( aCommand, |
|
3159 iAppUi.GetActiveMailbox()->GetId(), |
|
3160 FolderId(), |
|
3161 item->MessagePtr().GetMessageId() ); |
|
3162 } |
|
3163 } |
|
3164 } |
|
3165 } |
|
3166 break; |
|
3167 case EFsEmailUiCmdActionsEmptyDeleted: |
|
3168 { |
|
3169 // <cmail> |
|
3170 if ( iMailFolder && iMailFolder->GetFolderType() == EFSDeleted && |
|
3171 iModel->Count() != 0 ) |
|
3172 // </cmail> |
|
3173 { |
|
3174 TBool okToDelete( EFalse ); |
|
3175 HBufC* msg = StringLoader::LoadLC( R_FREESTYLE_EMAIL_QUERY_NOTE_PERMANENTLY_DELETE ); |
|
3176 CAknQueryDialog *queryNote = new ( ELeave ) CAknQueryDialog(); |
|
3177 CleanupStack::PushL( queryNote ); |
|
3178 queryNote->SetPromptL( *msg ); |
|
3179 CleanupStack::Pop( queryNote ); |
|
3180 CleanupStack::PopAndDestroy( msg ); |
|
3181 okToDelete = queryNote->ExecuteLD( R_FSEMAIL_QUERY_DIALOG ); |
|
3182 if ( okToDelete ) |
|
3183 { |
|
3184 // Empty deleted items folder |
|
3185 RArray<TFSMailMsgId> msgIds; |
|
3186 CleanupClosePushL( msgIds ); |
|
3187 for ( TInt i=0 ; i<iModel->Count();i++ ) |
|
3188 { |
|
3189 CFSEmailUiMailListModelItem* item = |
|
3190 static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i)); |
|
3191 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
3192 { |
|
3193 msgIds.Append( item->MessagePtr().GetMessageId() ); |
|
3194 } |
|
3195 } |
|
3196 TFSMailMsgId folderId = FolderId(); |
|
3197 TFSMailMsgId mailBox = iAppUi.GetActiveMailbox()->GetId(); |
|
3198 iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds ); |
|
3199 RemoveMsgItemsFromListIfFoundL( msgIds ); |
|
3200 CleanupStack::PopAndDestroy( &msgIds ); |
|
3201 } |
|
3202 } |
|
3203 } |
|
3204 break; |
|
3205 default: |
|
3206 break; |
|
3207 } |
|
3208 CleanupStack::PopAndDestroy( &actionTargetItems ); |
|
3209 } |
|
3210 |
|
3211 // --------------------------------------------------------------------------- |
|
3212 // |
|
3213 // |
|
3214 // --------------------------------------------------------------------------- |
|
3215 // |
|
3216 TInt CFSEmailUiMailListVisualiser::MoveMsgsToFolderL( const TFSMailMsgId& aDestinationFolderId ) |
|
3217 { |
|
3218 FUNC_LOG; |
|
3219 TInt ret(KErrGeneral); |
|
3220 RFsTreeItemIdList targetEntries; |
|
3221 CleanupClosePushL( targetEntries ); |
|
3222 GetActionsTargetEntriesL( targetEntries ); |
|
3223 TBool supportsMove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ); |
|
3224 // Moving is not possible, if there are no items or the focus is on separator and |
|
3225 // there are no marked items. In outbox, moving is allowed only to the drafts folder; |
|
3226 // folder selection popup is not allowed. |
|
3227 // These have to be checked before launching the folder view. |
|
3228 if ( targetEntries.Count() && supportsMove ) |
|
3229 { |
|
3230 TBool outbox = (iMailFolder && iMailFolder->GetFolderType() == EFSOutbox); |
|
3231 |
|
3232 if ( !(outbox && aDestinationFolderId.IsNullId()) ) |
|
3233 { |
|
3234 // If destination folder is not set, it needs to be asked messages are moved after callbak |
|
3235 if ( aDestinationFolderId.IsNullId() ) |
|
3236 { |
|
3237 // Activate folder selection view and handle moving after callback gets destination |
|
3238 iMoveToFolderOngoing = ETrue; |
|
3239 TFolderListActivationData folderListData; |
|
3240 folderListData.iCallback = this; |
|
3241 folderListData.iSourceFolderType = iMailFolder->GetFolderType(); |
|
3242 const TPckgBuf<TFolderListActivationData> pkgOut( folderListData ); |
|
3243 if ( targetEntries.Count() == 1 ) |
|
3244 { |
|
3245 iAppUi.EnterFsEmailViewL( FolderListId, KFolderListMoveMessage, pkgOut ); |
|
3246 } |
|
3247 else |
|
3248 { |
|
3249 iAppUi.EnterFsEmailViewL( FolderListId, KFolderListMoveMessages, pkgOut ); |
|
3250 } |
|
3251 ret = KErrNotReady; |
|
3252 } |
|
3253 // Destination folder is set, move message(s) immediately |
|
3254 else |
|
3255 { |
|
3256 iMoveToFolderOngoing = EFalse; |
|
3257 // Get message IDs from target list IDs |
|
3258 RArray<TFSMailMsgId> msgIds; |
|
3259 CleanupClosePushL( msgIds ); |
|
3260 for ( TInt i = 0 ; i < targetEntries.Count() ; i++) |
|
3261 { |
|
3262 msgIds.Append( MsgIdFromListId( targetEntries[i] ) ); |
|
3263 } |
|
3264 |
|
3265 if ( iMailFolder && msgIds.Count() ) // Something to move |
|
3266 { |
|
3267 // check that source and destination are different |
|
3268 if( iMailFolder->GetFolderId() != aDestinationFolderId ) |
|
3269 { |
|
3270 // Trap is needed because protocol might return KErrNotSupported |
|
3271 // If move away from current folder is not supprted |
|
3272 TRAPD( errMove, iAppUi.GetActiveMailbox()->MoveMessagesL( msgIds, iMailFolder->GetFolderId(), aDestinationFolderId ) ); |
|
3273 if ( errMove != KErrNotSupported ) |
|
3274 { |
|
3275 if ( errMove == KErrNone ) |
|
3276 { |
|
3277 RemoveMsgItemsFromListIfFoundL( msgIds ); |
|
3278 if ( !iMsgNoteTimer ) |
|
3279 { |
|
3280 iMsgNoteTimer = CMsgMovedNoteTimer::NewL( &iAppUi, this ); |
|
3281 } |
|
3282 iMsgNoteTimer->Cancel(); |
|
3283 iMsgNoteTimer->Start( msgIds.Count(), aDestinationFolderId ); |
|
3284 ret = KErrNone; |
|
3285 } |
|
3286 else |
|
3287 { |
|
3288 User::Leave(errMove); |
|
3289 } |
|
3290 } |
|
3291 } |
|
3292 } |
|
3293 CleanupStack::PopAndDestroy( &msgIds ); |
|
3294 } |
|
3295 } |
|
3296 } |
|
3297 CleanupStack::PopAndDestroy( &targetEntries ); |
|
3298 return ret; |
|
3299 } |
|
3300 |
|
3301 // --------------------------------------------------------------------------- |
|
3302 // |
|
3303 // |
|
3304 // --------------------------------------------------------------------------- |
|
3305 // |
|
3306 void CFSEmailUiMailListVisualiser::MoveMessagesToDraftsL() |
|
3307 { |
|
3308 FUNC_LOG; |
|
3309 if ( iMailFolder && iMailFolder->GetFolderType() == EFSOutbox ) // Move to drafts should only be available from outbox, safety |
|
3310 { |
|
3311 MoveMsgsToFolderL( iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSDraftsFolder ) ); |
|
3312 } |
|
3313 } |
|
3314 |
|
3315 // --------------------------------------------------------------------------- |
|
3316 // |
|
3317 // |
|
3318 // --------------------------------------------------------------------------- |
|
3319 // |
|
3320 void CFSEmailUiMailListVisualiser::CollapseAllNodesL() |
|
3321 { |
|
3322 FUNC_LOG; |
|
3323 // Safety check, ignore command if the list is empty |
|
3324 if ( iMailList->Count() ) |
|
3325 { |
|
3326 iMailTreeListVisualizer->CollapseAllL(); |
|
3327 } |
|
3328 } |
|
3329 |
|
3330 // --------------------------------------------------------------------------- |
|
3331 // |
|
3332 // |
|
3333 // --------------------------------------------------------------------------- |
|
3334 // |
|
3335 void CFSEmailUiMailListVisualiser::ExpandAllNodesL() |
|
3336 { |
|
3337 FUNC_LOG; |
|
3338 // Safety check, ignore command if the list is empty |
|
3339 if ( iMailList->Count() ) |
|
3340 { |
|
3341 TFsTreeItemId prevId = iMailList->FocusedItem(); |
|
3342 iMailTreeListVisualizer->ExpandAllL(); |
|
3343 iMailTreeListVisualizer->SetFocusedItemL( prevId ); |
|
3344 } |
|
3345 } |
|
3346 |
|
3347 void CFSEmailUiMailListVisualiser::ExpandOrCollapseL() |
|
3348 { |
|
3349 FUNC_LOG; |
|
3350 CFSEmailUiMailListModelItem* item = |
|
3351 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
3352 if ( item && item->ModelItemType() == ETypeSeparator ) |
|
3353 { |
|
3354 if ( iMailList->IsExpanded( iMailList->FocusedItem() ) ) |
|
3355 { |
|
3356 //ChangeMskCommandL( R_FSE_QTN_MSK_COLLAPSE ); |
|
3357 iMailList->CollapseNodeL( iMailList->FocusedItem() ); |
|
3358 } |
|
3359 else |
|
3360 { |
|
3361 //ChangeMskCommandL( R_FSE_QTN_MSK_EXPAND ); |
|
3362 iMailList->ExpandNodeL( iMailList->FocusedItem() ); |
|
3363 } |
|
3364 } |
|
3365 } |
|
3366 |
|
3367 // --------------------------------------------------------------------------- |
|
3368 // |
|
3369 // |
|
3370 // --------------------------------------------------------------------------- |
|
3371 // |
|
3372 void CFSEmailUiMailListVisualiser::SetMessageFollowupFlagL() |
|
3373 { |
|
3374 FUNC_LOG; |
|
3375 if ( TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ) ) |
|
3376 { |
|
3377 RFsTreeItemIdList targetItems; |
|
3378 CleanupClosePushL( targetItems ); |
|
3379 GetActionsTargetEntriesL( targetItems ); |
|
3380 |
|
3381 // If there are marked or focused item(s) |
|
3382 if ( targetItems.Count() ) |
|
3383 { |
|
3384 // Convert list IDs to message IDs because it's possible that list refresh |
|
3385 // causes list IDs to change while the flag dialog is open |
|
3386 RArray< TFSMailMsgId > targetMsgIds; |
|
3387 CleanupClosePushL( targetMsgIds ); |
|
3388 for ( TInt i = 0 ; i < targetItems.Count() ; ++i ) |
|
3389 { |
|
3390 TFSMailMsgId msgId = MsgIdFromIndex( ModelIndexFromListId( targetItems[i] ) ); |
|
3391 targetMsgIds.AppendL( msgId ); |
|
3392 } |
|
3393 |
|
3394 TFollowUpNewState newFollowUpState = EFollowUpNoChanges; |
|
3395 if ( TFsEmailUiUtility::RunFollowUpListDialogL( newFollowUpState ) ) |
|
3396 { |
|
3397 // Update the target messages |
|
3398 for ( TInt i = 0 ; i < targetMsgIds.Count() ; ++i ) |
|
3399 { |
|
3400 // Confirm that message is still in the list after selection has closed |
|
3401 TInt itemIndex = ItemIndexFromMessageId( targetMsgIds[i] ); |
|
3402 CFSEmailUiMailListModelItem* modelItem = |
|
3403 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( itemIndex ) ); |
|
3404 CFSMailMessage* confirmedPtr = NULL; // owned by the model |
|
3405 if ( modelItem ) |
|
3406 { |
|
3407 confirmedPtr = &modelItem->MessagePtr(); |
|
3408 } |
|
3409 if ( confirmedPtr ) |
|
3410 { |
|
3411 // Store flags to confirmed pointer for saving |
|
3412 TInt currentFlags = confirmedPtr->GetFlags(); |
|
3413 switch ( newFollowUpState ) |
|
3414 { |
|
3415 case EFollowUp: |
|
3416 { |
|
3417 confirmedPtr->SetFlag( EFSMsgFlag_FollowUp ); |
|
3418 confirmedPtr->ResetFlag( EFSMsgFlag_FollowUpComplete ); |
|
3419 } |
|
3420 break; |
|
3421 case EFollowUpComplete: |
|
3422 { |
|
3423 confirmedPtr->SetFlag( EFSMsgFlag_FollowUpComplete ); |
|
3424 confirmedPtr->ResetFlag( EFSMsgFlag_FollowUp ); |
|
3425 } |
|
3426 break; |
|
3427 case EFollowUpClear: |
|
3428 { |
|
3429 confirmedPtr->ResetFlag( EFSMsgFlag_FollowUp | EFSMsgFlag_FollowUpComplete ); |
|
3430 } |
|
3431 break; |
|
3432 } |
|
3433 |
|
3434 TInt newFlags = confirmedPtr->GetFlags(); |
|
3435 if ( newFlags != currentFlags ) |
|
3436 { |
|
3437 // Save confirmed message |
|
3438 confirmedPtr->SaveMessageL(); |
|
3439 |
|
3440 // Update flag icon |
|
3441 UpdateMsgIconAndBoldingL( itemIndex ); |
|
3442 |
|
3443 // In case we are in flag sort mode, resetting the flag may cause the list order to be out of date. |
|
3444 if ( iCurrentSortCriteria.iField == EFSMailSortByFlagStatus ) |
|
3445 { |
|
3446 iListOrderMayBeOutOfDate = ETrue; |
|
3447 } |
|
3448 } |
|
3449 } |
|
3450 } |
|
3451 } |
|
3452 CleanupStack::PopAndDestroy( &targetMsgIds ); |
|
3453 } |
|
3454 CleanupStack::PopAndDestroy( &targetItems ); |
|
3455 } |
|
3456 } |
|
3457 |
|
3458 // --------------------------------------------------------------------------- |
|
3459 // |
|
3460 // |
|
3461 // --------------------------------------------------------------------------- |
|
3462 // |
|
3463 void CFSEmailUiMailListVisualiser::SetViewSoftkeysL( TInt aResourceId ) |
|
3464 { |
|
3465 FUNC_LOG; |
|
3466 Cba()->SetCommandSetL( aResourceId ); |
|
3467 Cba()->DrawDeferred(); |
|
3468 } |
|
3469 |
|
3470 // --------------------------------------------------------------------------- |
|
3471 // Method to set Middle SoftKey |
|
3472 // --------------------------------------------------------------------------- |
|
3473 // |
|
3474 void CFSEmailUiMailListVisualiser::SetMskL() |
|
3475 { |
|
3476 FUNC_LOG; |
|
3477 // Get the mail list count |
|
3478 TInt listCount(0); |
|
3479 if ( iMailList ) |
|
3480 { |
|
3481 listCount = iMailList->Count(); |
|
3482 } |
|
3483 |
|
3484 if ( iFocusedControl == EControlBarComponent ) |
|
3485 { |
|
3486 /* <cmail> Sorting enabled also for empty list |
|
3487 // Sort menu can't be opened if mail list is empty. Hide MSK label in that case. |
|
3488 if ( !listCount && iControlBarControl->GetFocusedButton() == iSortButton ) |
|
3489 { |
|
3490 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
3491 } |
|
3492 else |
|
3493 </cmail> */ |
|
3494 { |
|
3495 ChangeMskCommandL( R_FSE_QTN_MSK_CHANGE ); |
|
3496 } |
|
3497 } |
|
3498 else if ( iFocusedControl == EMailListComponent ) |
|
3499 { |
|
3500 if ( listCount ) // Safety check |
|
3501 { |
|
3502 CFSEmailUiMailListModelItem* item = |
|
3503 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item(HighlightedIndex()) ); |
|
3504 // SHIFT DEPRESSED. SELECTION KEY DOES MARK/UNMARK |
|
3505 if ( iShiftDepressed ) |
|
3506 { |
|
3507 // Nodes may not be marked |
|
3508 if ( iMailList->IsNode( iMailList->FocusedItem() ) ) |
|
3509 { |
|
3510 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
3511 } |
|
3512 else |
|
3513 { |
|
3514 if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) |
|
3515 { |
|
3516 ChangeMskCommandL( R_FSE_QTN_MSK_UNMARK ); |
|
3517 } |
|
3518 else |
|
3519 { |
|
3520 ChangeMskCommandL( R_FSE_QTN_MSK_MARK ); |
|
3521 } |
|
3522 } |
|
3523 } |
|
3524 else |
|
3525 { |
|
3526 // MAIL ITEM; OPEN MAIL |
|
3527 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
3528 { |
|
3529 CFSMailMessage* messagePtr = &item->MessagePtr(); |
|
3530 if ( messagePtr ) |
|
3531 { |
|
3532 if ( iMailFolder && iMailFolder->GetFolderType() == EFSOutbox ) |
|
3533 { |
|
3534 ChangeMskCommandL( R_FSE_QTN_MSK_OPEN_BLOCKED ); |
|
3535 } |
|
3536 else |
|
3537 { |
|
3538 ChangeMskCommandL( R_FSE_QTN_MSK_OPEN ); |
|
3539 } |
|
3540 } |
|
3541 } |
|
3542 |
|
3543 // SEPARAOR ITEM; COLLAPSE / EXPAND NODE |
|
3544 else if ( item && item->ModelItemType() == ETypeSeparator ) |
|
3545 { |
|
3546 if( iMailList->IsNode( iMailList->FocusedItem() ) ) |
|
3547 { |
|
3548 if ( iMailList->IsExpanded( iMailList->FocusedItem() ) ) |
|
3549 { |
|
3550 ChangeMskCommandL( R_FSE_QTN_MSK_COLLAPSE ); |
|
3551 } |
|
3552 else |
|
3553 { |
|
3554 ChangeMskCommandL( R_FSE_QTN_MSK_EXPAND ); |
|
3555 } |
|
3556 } |
|
3557 } |
|
3558 } |
|
3559 } |
|
3560 } |
|
3561 } |
|
3562 |
|
3563 // --------------------------------------------------------------------------- |
|
3564 // |
|
3565 // |
|
3566 // --------------------------------------------------------------------------- |
|
3567 // |
|
3568 TBool CFSEmailUiMailListVisualiser::OfferEventL(const TAlfEvent& aEvent) |
|
3569 { |
|
3570 FUNC_LOG; |
|
3571 TBool result( EFalse ); |
|
3572 |
|
3573 if ( !aEvent.IsKeyEvent() ) |
|
3574 { |
|
3575 // Only handle key events |
|
3576 if ( aEvent.IsPointerEvent() ) |
|
3577 { |
|
3578 switch( iFocusedControl ) |
|
3579 { |
|
3580 case EMailListComponent: |
|
3581 { |
|
3582 result = iMailList->TreeControl()->OfferEventL( aEvent ); |
|
3583 break; |
|
3584 } |
|
3585 case EControlBarComponent: |
|
3586 { |
|
3587 result = static_cast<CAlfControl*>( |
|
3588 iControlBarControl )->OfferEventL( aEvent ); |
|
3589 break; |
|
3590 } |
|
3591 default: |
|
3592 { |
|
3593 break; |
|
3594 } |
|
3595 } |
|
3596 } |
|
3597 return result; |
|
3598 } |
|
3599 |
|
3600 TInt scanCode = aEvent.KeyEvent().iScanCode; |
|
3601 // Swap right and left controls in mirrored layout |
|
3602 if ( AknLayoutUtils::LayoutMirrored() ) |
|
3603 { |
|
3604 if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow; |
|
3605 else if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow; |
|
3606 } |
|
3607 |
|
3608 // Toggle mark items state when shift key is pressed or released |
|
3609 if ( iFocusedControl == EMailListComponent && |
|
3610 ( scanCode == EStdKeyLeftShift || |
|
3611 scanCode == EStdKeyRightShift || |
|
3612 scanCode == EStdKeyHash ) ) |
|
3613 { |
|
3614 if ( aEvent.Code() == EEventKeyDown ) |
|
3615 { |
|
3616 iShiftDepressed = ETrue; |
|
3617 iOtherKeyPressedWhileShiftDepressed = EFalse; |
|
3618 if ( iModel->Count() && iMailList->IsMarked( iMailList->FocusedItem() ) ) |
|
3619 { |
|
3620 iListMarkItemsState = EFalse; // Unmark state |
|
3621 } |
|
3622 else |
|
3623 { |
|
3624 iListMarkItemsState = ETrue; // Mark items state |
|
3625 } |
|
3626 } |
|
3627 else if ( aEvent.Code() == EEventKeyUp ) |
|
3628 { |
|
3629 iShiftDepressed = EFalse; |
|
3630 } |
|
3631 } |
|
3632 |
|
3633 // If any other key event is gained while hash is depressed, the hash key is used only |
|
3634 // as shift and not as individual key. |
|
3635 if ( iShiftDepressed && scanCode && |
|
3636 scanCode != EStdKeyHash && scanCode != EStdKeyLeftShift && scanCode != EStdKeyRightShift ) |
|
3637 { |
|
3638 iOtherKeyPressedWhileShiftDepressed = ETrue; |
|
3639 } |
|
3640 |
|
3641 // MSK label can now be updated when shift key has been handled |
|
3642 SetMskL(); |
|
3643 |
|
3644 if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey ) |
|
3645 { |
|
3646 TBool shiftState = (aEvent.KeyEvent().iModifiers & EModifierShift ); |
|
3647 |
|
3648 // Do the (un)marking if in shift state and suitable key is received |
|
3649 if ( shiftState ) |
|
3650 { |
|
3651 switch ( aEvent.KeyEvent().iScanCode ) |
|
3652 { |
|
3653 case EStdKeyDownArrow: |
|
3654 case EStdKeyUpArrow: |
|
3655 { |
|
3656 DoScrollMarkUnmarkL(); |
|
3657 result = EFalse; // event is not consumed yet, because it must also move the cursor |
|
3658 } |
|
3659 break; |
|
3660 case EStdKeyEnter: |
|
3661 case EStdKeyDevice3: |
|
3662 { |
|
3663 if ( !aEvent.KeyEvent().iRepeats ) // no repeated (un)marking by holding selection key depressed |
|
3664 { |
|
3665 // The selection key always toggles the marking state of the current item. |
|
3666 // It also toggles the scroll marking/unmarking state. |
|
3667 if ( iModel->Count() ) |
|
3668 { |
|
3669 CFSEmailUiMailListModelItem* item = |
|
3670 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
3671 |
|
3672 if ( item->ModelItemType() == ETypeMailItem ) // Separators are not markable |
|
3673 { |
|
3674 if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) |
|
3675 { |
|
3676 iMailList->MarkItemL( iMailList->FocusedItem(), EFalse ); |
|
3677 iListMarkItemsState = EFalse; |
|
3678 } |
|
3679 else |
|
3680 { |
|
3681 iMailList->MarkItemL( iMailList->FocusedItem(), ETrue ); |
|
3682 iListMarkItemsState = ETrue; |
|
3683 } |
|
3684 } |
|
3685 } |
|
3686 } |
|
3687 result = ETrue; // shift + selection is always consumed |
|
3688 } |
|
3689 break; |
|
3690 default: |
|
3691 break; |
|
3692 } |
|
3693 |
|
3694 } |
|
3695 |
|
3696 // If event not handled by now |
|
3697 if ( !result ) |
|
3698 { |
|
3699 // Handle possible focus visibility change |
|
3700 if ((scanCode == EStdKeyRightArrow) |
|
3701 || (scanCode == EStdKeyLeftArrow) |
|
3702 || (scanCode == EStdKeyUpArrow) |
|
3703 || (scanCode == EStdKeyDownArrow) |
|
3704 || (scanCode == EStdKeyEnter) |
|
3705 || (scanCode == EStdKeyDeviceA) |
|
3706 || (scanCode ==EStdKeyDevice3)) |
|
3707 { |
|
3708 TBool wasActive = iAppUi.StartFocusRemovalTimer(); |
|
3709 |
|
3710 // If the focus was not active already, ignore the key press |
|
3711 if( !wasActive ) |
|
3712 { |
|
3713 return ETrue; |
|
3714 } |
|
3715 } |
|
3716 |
|
3717 switch ( scanCode ) |
|
3718 { |
|
3719 case EStdKeyDevice3: // CENTER CLICK |
|
3720 case EStdKeyEnter: // ENTER EITHER SELECTS ITEM IN TOOLBAR OR OPENS MAIL |
|
3721 case EStdKeyNkpEnter: |
|
3722 case EAknSoftkeySelect: |
|
3723 { |
|
3724 SetMskL(); |
|
3725 if ( iFocusedControl == EMailListComponent ) |
|
3726 { |
|
3727 TInt modelCount(0); |
|
3728 // <cmail> |
|
3729 modelCount = iModel->Count(); |
|
3730 // </cmail> |
|
3731 if ( modelCount ) // Safety check |
|
3732 { |
|
3733 CFSEmailUiMailListModelItem* item = |
|
3734 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
3735 // MAIL ITEM; OPEN MAIL |
|
3736 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
3737 { |
|
3738 CFSMailMessage* messagePtr = &item->MessagePtr(); |
|
3739 if ( messagePtr ) |
|
3740 { |
|
3741 OpenHighlightedMailL(); |
|
3742 return EKeyWasConsumed; |
|
3743 } |
|
3744 } |
|
3745 // SEPARAOR ITEM; COLLAPSE / EXPAND NODE |
|
3746 else if ( item && item->ModelItemType() == ETypeSeparator ) |
|
3747 { |
|
3748 if ( iMailList->IsExpanded( iMailList->FocusedItem()) ) |
|
3749 { |
|
3750 ExpandOrCollapseL(); |
|
3751 } |
|
3752 else |
|
3753 { |
|
3754 ExpandOrCollapseL(); |
|
3755 } |
|
3756 return EKeyWasConsumed; |
|
3757 } |
|
3758 } |
|
3759 } |
|
3760 else |
|
3761 { |
|
3762 TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id(); |
|
3763 if ( focusedButtonId == iNewEmailButtonId ) |
|
3764 { |
|
3765 HandleCommandL(EFsEmailUiCmdCompose); |
|
3766 } |
|
3767 else if ( focusedButtonId == iFolderListButtonId ) |
|
3768 { |
|
3769 //<cmail> |
|
3770 //Set touchmanager not active for preventing getting events. |
|
3771 DisableMailList(ETrue); |
|
3772 //</cmail> |
|
3773 iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton ); |
|
3774 } |
|
3775 else if ( focusedButtonId == iSortButtonId ) |
|
3776 { |
|
3777 TFSFolderType folderType; |
|
3778 if( iMailFolder ) |
|
3779 { |
|
3780 folderType = iMailFolder->GetFolderType(); |
|
3781 } |
|
3782 else |
|
3783 { |
|
3784 folderType = EFSInbox; |
|
3785 } |
|
3786 // Show sort if model has data. |
|
3787 if ( iModel->Count() ) |
|
3788 { |
|
3789 //<cmail> |
|
3790 //Set touchmanager not active for preventing getting events. |
|
3791 DisableMailList(ETrue); |
|
3792 //</cmail> |
|
3793 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton ); |
|
3794 } |
|
3795 else |
|
3796 { |
|
3797 // hide selector focus if popup is not opened |
|
3798 // and selection was not made via HW-keys |
|
3799 iControlBarControl->MakeSelectorVisible( |
|
3800 IsFocusShown() ); |
|
3801 } |
|
3802 } |
|
3803 return ETrue;//iControlBar->OfferEventL( aEvent ); |
|
3804 } |
|
3805 } |
|
3806 break; |
|
3807 case EStdKeyLeftArrow: |
|
3808 { |
|
3809 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
3810 if( iControlBarControl && iFocusedControl == EMailListComponent ) |
|
3811 { |
|
3812 HandleCommandL( EFsEmailUiCmdGoToSwitchSorting ); |
|
3813 result = ETrue; |
|
3814 } |
|
3815 else if( ( iControlBarControl ) && |
|
3816 ( iFocusedControl == EControlBarComponent ) ) |
|
3817 { |
|
3818 |
|
3819 TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id(); |
|
3820 if ( focusedButtonId == iFolderListButtonId ) |
|
3821 { |
|
3822 if ( iModel->Count() ) |
|
3823 { |
|
3824 iFocusedControl = EMailListComponent; |
|
3825 result = EFalse; |
|
3826 } |
|
3827 else |
|
3828 { |
|
3829 iFocusedControl = EControlBarComponent; |
|
3830 result = ETrue; // Do not set focus to empty list |
|
3831 } |
|
3832 } |
|
3833 else |
|
3834 { |
|
3835 iFocusedControl = EControlBarComponent; |
|
3836 result = EFalse; |
|
3837 } |
|
3838 } |
|
3839 else |
|
3840 { |
|
3841 iFocusedControl = EMailListComponent; |
|
3842 result = EFalse; |
|
3843 } |
|
3844 SetMskL(); |
|
3845 } |
|
3846 break; |
|
3847 case EStdKeyRightArrow: |
|
3848 { |
|
3849 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
3850 // Show toolbar if there is data on the list |
|
3851 // <cmail> |
|
3852 if ( iFocusedControl == EMailListComponent && iModel->Count() ) |
|
3853 // </cmail> |
|
3854 { |
|
3855 RFsTreeItemIdList targetEntries; |
|
3856 CleanupClosePushL( targetEntries ); |
|
3857 GetActionsTargetEntriesL( targetEntries ); |
|
3858 TInt targetCount = targetEntries.Count(); |
|
3859 CleanupStack::PopAndDestroy( &targetEntries ); |
|
3860 |
|
3861 if ( targetCount ) |
|
3862 { |
|
3863 LaunchStylusPopupMenuL(); |
|
3864 result = ETrue; |
|
3865 } |
|
3866 } |
|
3867 else if( ( iControlBarControl ) && |
|
3868 ( iFocusedControl == EControlBarComponent ) ) |
|
3869 { |
|
3870 TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id(); |
|
3871 if ( focusedButtonId == iFolderListButtonId ) |
|
3872 { |
|
3873 iFocusedControl = EControlBarComponent; |
|
3874 result = EFalse; |
|
3875 } |
|
3876 else |
|
3877 { |
|
3878 if ( iModel->Count() ) // Check for empty folder |
|
3879 { |
|
3880 iFocusedControl = EMailListComponent; |
|
3881 result = EFalse; |
|
3882 } |
|
3883 else |
|
3884 { |
|
3885 iFocusedControl = EControlBarComponent; |
|
3886 result = ETrue; // Do not set focus to empty list |
|
3887 } |
|
3888 } ; |
|
3889 } |
|
3890 else |
|
3891 { |
|
3892 iFocusedControl = EMailListComponent; |
|
3893 result = EFalse; |
|
3894 } |
|
3895 SetMskL(); |
|
3896 } |
|
3897 break; |
|
3898 case EStdKeyDownArrow: |
|
3899 { |
|
3900 if ( iFocusedControl == EMailListComponent ) |
|
3901 { |
|
3902 result = iMailList->TreeControl()->OfferEventL(aEvent); |
|
3903 if ( shiftState ) |
|
3904 { |
|
3905 DoScrollMarkUnmarkL(); // marking is done after moving the cursor |
|
3906 } |
|
3907 } |
|
3908 // <cmail> |
|
3909 else if ( iFocusedControl == EControlBarComponent && iModel->Count() == 0 ) |
|
3910 { |
|
3911 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
3912 result = ETrue; // Do not set focus to empty list |
|
3913 } |
|
3914 else if ( iFocusedControl == EControlBarComponent && iModel->Count() != 0 ) |
|
3915 // </cmail> |
|
3916 { |
|
3917 iFocusedControl = EMailListComponent; |
|
3918 |
|
3919 result = iMailList->TreeControl()->OfferEventL(aEvent); |
|
3920 if ( shiftState ) |
|
3921 { |
|
3922 DoScrollMarkUnmarkL(); // marking is done after moving the cursor |
|
3923 } |
|
3924 } |
|
3925 else |
|
3926 { |
|
3927 result = EFalse; |
|
3928 } |
|
3929 SetMskL(); |
|
3930 } |
|
3931 break; |
|
3932 case EStdKeyUpArrow: |
|
3933 { |
|
3934 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
3935 if ( iFocusedControl == EMailListComponent ) |
|
3936 { |
|
3937 if ( HighlightedIndex() == 0 ) |
|
3938 { |
|
3939 HandleCommandL( EFsEmailUiCmdGoToSwitchFolder ); |
|
3940 result = ETrue; |
|
3941 } |
|
3942 else |
|
3943 { |
|
3944 result = iMailList->TreeControl()->OfferEventL(aEvent); |
|
3945 if ( shiftState ) |
|
3946 { |
|
3947 DoScrollMarkUnmarkL(); // marking is done after moving the cursor |
|
3948 } |
|
3949 SetMskL(); |
|
3950 } |
|
3951 } |
|
3952 else if (iFocusedControl == EControlBarComponent) |
|
3953 { |
|
3954 result = ETrue; |
|
3955 } |
|
3956 else |
|
3957 { |
|
3958 result = EFalse; |
|
3959 } |
|
3960 } |
|
3961 break; |
|
3962 case EStdKeyYes: |
|
3963 { |
|
3964 if ( !iAppUi.ViewSwitchingOngoing() ) |
|
3965 { |
|
3966 if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox && |
|
3967 iMailFolder->GetFolderType() != EFSDraftsFolder ) |
|
3968 { |
|
3969 TInt modelCount = iModel->Count(); |
|
3970 if ( modelCount ) // Safety check |
|
3971 { |
|
3972 CFSEmailUiMailListModelItem* item = |
|
3973 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
3974 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
3975 { |
|
3976 CFSMailAddress* fromAddress = item->MessagePtr().GetSender(); |
|
3977 TDesC* mailAddress(0); |
|
3978 if ( fromAddress ) |
|
3979 { |
|
3980 mailAddress = &fromAddress->GetEmailAddress(); |
|
3981 } |
|
3982 if ( mailAddress && mailAddress->Length() ) |
|
3983 { |
|
3984 if ( iMailFolder->GetFolderType() == EFSSentFolder ) |
|
3985 { |
|
3986 CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( |
|
3987 *mailAddress, iAppUi.GetActiveMailbox(), this, EFalse ); |
|
3988 } |
|
3989 else |
|
3990 { |
|
3991 CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( |
|
3992 *mailAddress, iAppUi.GetActiveMailbox(), this, ETrue ); |
|
3993 } |
|
3994 } |
|
3995 } |
|
3996 } |
|
3997 } |
|
3998 } |
|
3999 } |
|
4000 break; |
|
4001 case EStdKeyHash: |
|
4002 { |
|
4003 // Consume hash key events before they go to our shortcut framework. We do not want |
|
4004 // to react to those until the in the key up event. There hash key works as mark/unmark shortcut only |
|
4005 // if it hasn't been used as shift modifier. |
|
4006 result = ETrue; |
|
4007 } |
|
4008 break; |
|
4009 //<cmail> |
|
4010 // Backspace (C key) must be handled on Key-Down instead of Key-Up |
|
4011 // ( this was the reason that deleted two emails from opened mail in viewer ) |
|
4012 case EStdKeyBackspace: |
|
4013 { |
|
4014 TInt shortcutCommand = iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(), |
|
4015 CFSEmailUiShortcutBinding::EContextMailList ); |
|
4016 |
|
4017 if ( shortcutCommand != KErrNotFound ) |
|
4018 { |
|
4019 HandleCommandL( shortcutCommand ); |
|
4020 result = ETrue; |
|
4021 } |
|
4022 else result = EFalse; |
|
4023 } |
|
4024 break; |
|
4025 //</cmail> |
|
4026 default: |
|
4027 { |
|
4028 if ( iFocusedControl == EMailListComponent ) |
|
4029 { |
|
4030 result = iMailList->TreeControl()->OfferEventL(aEvent); |
|
4031 } |
|
4032 else |
|
4033 { |
|
4034 result = EFalse; |
|
4035 } |
|
4036 } |
|
4037 break; |
|
4038 } |
|
4039 } |
|
4040 } |
|
4041 else if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKeyUp ) |
|
4042 { |
|
4043 // Check keyboard shortcuts on key up events. These can't be checked on key event |
|
4044 // because half-QWERTY keyboad has shortcuts also on shift and chr keys which do |
|
4045 // no send any key events, only key down and key up. |
|
4046 TInt shortcutCommand = |
|
4047 iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(), |
|
4048 CFSEmailUiShortcutBinding::EContextMailList ); |
|
4049 // Hash/shift key of ITU-T and half-QWERTY keyboards is an exception case to other |
|
4050 // shortcuts: it is handled only if it hasn't been used as shift modifier |
|
4051 if ( (scanCode == EStdKeyHash || scanCode == EStdKeyLeftShift || scanCode == EStdKeyRightShift) && |
|
4052 iOtherKeyPressedWhileShiftDepressed ) |
|
4053 { |
|
4054 shortcutCommand = KErrNotFound; |
|
4055 } |
|
4056 |
|
4057 //<cmail> // block Backspace (C key) handle on Key-Up |
|
4058 if ( scanCode == EStdKeyBackspace) shortcutCommand = KErrNotFound; // handled on Key-Down, see above |
|
4059 //</cmail> |
|
4060 |
|
4061 if ( shortcutCommand != KErrNotFound ) |
|
4062 { |
|
4063 HandleCommandL( shortcutCommand ); |
|
4064 result = ETrue; |
|
4065 } |
|
4066 else |
|
4067 { |
|
4068 result = EFalse; |
|
4069 } |
|
4070 } |
|
4071 |
|
4072 return result; |
|
4073 } |
|
4074 |
|
4075 //<cmail> |
|
4076 // --------------------------------------------------------------------------- |
|
4077 // CFSEmailUiMailListVisualiser::DoHandleListItemOpenL |
|
4078 // --------------------------------------------------------------------------- |
|
4079 // |
|
4080 void CFSEmailUiMailListVisualiser::DoHandleListItemOpenL() |
|
4081 { |
|
4082 FUNC_LOG; |
|
4083 if ( 0 < iModel->Count() ) // Safety check |
|
4084 { |
|
4085 CFSEmailUiMailListModelItem* item = |
|
4086 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
4087 // MAIL ITEM; OPEN MAIL |
|
4088 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
4089 { |
|
4090 CFSMailMessage* messagePtr = &item->MessagePtr(); |
|
4091 if ( messagePtr ) |
|
4092 { |
|
4093 OpenHighlightedMailL(); |
|
4094 } |
|
4095 } |
|
4096 // SEPARATOR ITEM; COLLAPSE / EXPAND NODE |
|
4097 else if ( item && item->ModelItemType() == ETypeSeparator ) |
|
4098 { |
|
4099 ExpandOrCollapseL(); |
|
4100 SetMskL(); |
|
4101 } |
|
4102 } |
|
4103 } |
|
4104 |
|
4105 // --------------------------------------------------------------------------- |
|
4106 // CFSEmailUiMailListVisualiser::DoHandleControlBarOpenL |
|
4107 // --------------------------------------------------------------------------- |
|
4108 // |
|
4109 void CFSEmailUiMailListVisualiser::DoHandleControlBarOpenL( TInt aControlBarButtonId ) |
|
4110 { |
|
4111 FUNC_LOG; |
|
4112 |
|
4113 if ( aControlBarButtonId == iNewEmailButtonId ) |
|
4114 { |
|
4115 HandleCommandL(EFsEmailUiCmdCompose); |
|
4116 } |
|
4117 else if ( aControlBarButtonId == iFolderListButtonId ) |
|
4118 { |
|
4119 //FOLDERLIST |
|
4120 //Set touchmanager not active for preventing getting events. |
|
4121 DisableMailList(ETrue); |
|
4122 iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton ); |
|
4123 } |
|
4124 else if ( aControlBarButtonId == iSortButtonId ) |
|
4125 { |
|
4126 //SORTLIST |
|
4127 TFSFolderType folderType; |
|
4128 if ( iMailFolder ) |
|
4129 { |
|
4130 folderType = iMailFolder->GetFolderType(); |
|
4131 } |
|
4132 else |
|
4133 { |
|
4134 folderType = EFSInbox; |
|
4135 } |
|
4136 if ( iModel->Count() ) |
|
4137 { |
|
4138 //Set touchmanager not active for preventing getting events. |
|
4139 DisableMailList(ETrue); |
|
4140 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton ); |
|
4141 } |
|
4142 else |
|
4143 { |
|
4144 // hide selector focus if popup is not opened and selection was not |
|
4145 // made via HW-keys |
|
4146 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
4147 } |
|
4148 } |
|
4149 } |
|
4150 |
|
4151 // --------------------------------------------------------------------------- |
|
4152 // CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL |
|
4153 // --------------------------------------------------------------------------- |
|
4154 // |
|
4155 void CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL() |
|
4156 { |
|
4157 FUNC_LOG; |
|
4158 |
|
4159 if ( 0 < iModel->Count() ) // Safety check |
|
4160 { |
|
4161 RFsTreeItemIdList markedEntries; |
|
4162 iMailList->GetMarkedItemsL( markedEntries ); |
|
4163 if ( markedEntries.Count() >= 0 ) |
|
4164 { |
|
4165 LaunchStylusPopupMenuL(); |
|
4166 } |
|
4167 } |
|
4168 } |
|
4169 |
|
4170 // --------------------------------------------------------------------------- |
|
4171 // CFSEmailUiMailListVisualiser::GetFocusedControl |
|
4172 // --------------------------------------------------------------------------- |
|
4173 // |
|
4174 TInt CFSEmailUiMailListVisualiser::GetFocusedControl() const |
|
4175 { |
|
4176 FUNC_LOG; |
|
4177 return iFocusedControl; |
|
4178 } |
|
4179 |
|
4180 // --------------------------------------------------------------------------- |
|
4181 // CFSEmailUiMailListVisualiser::SetControlBarFocusedL |
|
4182 // --------------------------------------------------------------------------- |
|
4183 // |
|
4184 void CFSEmailUiMailListVisualiser::SetControlBarFocusedL() |
|
4185 { |
|
4186 FUNC_LOG; |
|
4187 iFocusedControl = EControlBarComponent; |
|
4188 iMailList->SetFocusedL( EFalse ); |
|
4189 SetMskL(); |
|
4190 } |
|
4191 |
|
4192 // --------------------------------------------------------------------------- |
|
4193 // CFSEmailUiMailListVisualiser::SetTreeListFocusedL |
|
4194 // --------------------------------------------------------------------------- |
|
4195 // |
|
4196 void CFSEmailUiMailListVisualiser::SetTreeListFocusedL() |
|
4197 { |
|
4198 FUNC_LOG; |
|
4199 iFocusedControl = EMailListComponent; |
|
4200 iMailList->SetFocusedL( ETrue ); |
|
4201 iControlBarControl->SetFocusL( EFalse ); |
|
4202 SetMskL(); |
|
4203 } |
|
4204 |
|
4205 // ----------------------------------------------------------------------------- |
|
4206 // CFSEmailUiMailListVisualiser::FlipStateChangedL |
|
4207 // ----------------------------------------------------------------------------- |
|
4208 // |
|
4209 void CFSEmailUiMailListVisualiser::FlipStateChangedL( TBool aKeyboardFlipOpen ) |
|
4210 { |
|
4211 FUNC_LOG; |
|
4212 CFsEmailUiViewBase::FlipStateChangedL( aKeyboardFlipOpen ); |
|
4213 iMailTreeListVisualizer->SetFlipState( iKeyboardFlipOpen ); |
|
4214 } |
|
4215 |
|
4216 // ----------------------------------------------------------------------------- |
|
4217 // CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange |
|
4218 // ----------------------------------------------------------------------------- |
|
4219 // |
|
4220 void CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange( TBool aShow ) |
|
4221 { |
|
4222 FUNC_LOG; |
|
4223 CFsEmailUiViewBase::HandleTimerFocusStateChange( aShow ); |
|
4224 if( iFocusedControl == EControlBarComponent ) |
|
4225 { |
|
4226 iControlBarControl->MakeSelectorVisible( aShow ); |
|
4227 } |
|
4228 iMailTreeListVisualizer->SetFocusVisibility( aShow ); |
|
4229 } |
|
4230 |
|
4231 // --------------------------------------------------------------------------- |
|
4232 // CFSEmailUiMailListVisualiser::DisableMailList |
|
4233 // --------------------------------------------------------------------------- |
|
4234 // |
|
4235 void CFSEmailUiMailListVisualiser::DisableMailList( TBool aValue ) |
|
4236 { |
|
4237 FUNC_LOG; |
|
4238 iTouchManager->SetDisabled( aValue ); |
|
4239 iControlBarControl->EnableTouch( (aValue) ? EFalse : ETrue ); |
|
4240 } |
|
4241 //</cmail> |
|
4242 |
|
4243 // --------------------------------------------------------------------------- |
|
4244 // |
|
4245 // |
|
4246 // --------------------------------------------------------------------------- |
|
4247 // |
|
4248 void CFSEmailUiMailListVisualiser::ShortcutCollapseExpandAllToggleL() |
|
4249 { |
|
4250 FUNC_LOG; |
|
4251 if ( !AllNodesCollapsed() ) |
|
4252 { |
|
4253 CollapseAllNodesL(); |
|
4254 } |
|
4255 else |
|
4256 { |
|
4257 ExpandAllNodesL(); |
|
4258 } |
|
4259 } |
|
4260 |
|
4261 // --------------------------------------------------------------------------- |
|
4262 // |
|
4263 // |
|
4264 // --------------------------------------------------------------------------- |
|
4265 // |
|
4266 TBool CFSEmailUiMailListVisualiser::AllNodesCollapsed() const |
|
4267 { |
|
4268 FUNC_LOG; |
|
4269 for ( TInt i=0;i<iTreeItemArray.Count();i++) |
|
4270 { |
|
4271 if ( iMailList->IsNode( iTreeItemArray[i].iListItemId ) ) |
|
4272 { |
|
4273 if ( iMailList->IsExpanded( iTreeItemArray[i].iListItemId ) ) |
|
4274 { |
|
4275 return EFalse; |
|
4276 } |
|
4277 } |
|
4278 } |
|
4279 |
|
4280 return ETrue; |
|
4281 } |
|
4282 |
|
4283 // --------------------------------------------------------------------------- |
|
4284 // |
|
4285 // |
|
4286 // --------------------------------------------------------------------------- |
|
4287 // |
|
4288 TBool CFSEmailUiMailListVisualiser::AllNodesExpanded() const |
|
4289 { |
|
4290 FUNC_LOG; |
|
4291 for ( TInt i=0;i<iTreeItemArray.Count();i++) |
|
4292 { |
|
4293 if ( iMailList->IsNode( iTreeItemArray[i].iListItemId ) ) |
|
4294 { |
|
4295 if ( !iMailList->IsExpanded( iTreeItemArray[i].iListItemId ) ) |
|
4296 { |
|
4297 return EFalse; |
|
4298 } |
|
4299 } |
|
4300 } |
|
4301 |
|
4302 return ETrue; |
|
4303 } |
|
4304 |
|
4305 // --------------------------------------------------------------------------- |
|
4306 // CFSEmailUiMailListVisualiser::IsMarkAsReadAvailableL() |
|
4307 // Function checks if mark as read option should be available for user |
|
4308 // --------------------------------------------------------------------------- |
|
4309 // |
|
4310 TBool CFSEmailUiMailListVisualiser::IsMarkAsReadAvailableL() const |
|
4311 { |
|
4312 FUNC_LOG; |
|
4313 TBool available = EFalse; |
|
4314 |
|
4315 // In outbox the mark as read is always inavailable |
|
4316 if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox ) |
|
4317 { |
|
4318 RFsTreeItemIdList targetEntries; |
|
4319 CleanupClosePushL( targetEntries ); |
|
4320 GetActionsTargetEntriesL( targetEntries ); |
|
4321 |
|
4322 // Mark as read is available if at least one of the target entries is unread |
|
4323 for ( TInt i = 0 ; i < targetEntries.Count() ; ++i ) |
|
4324 { |
|
4325 const CFSMailMessage& message = MsgPtrFromListIdL( targetEntries[i] ); |
|
4326 if ( !message.IsFlagSet(EFSMsgFlag_Read) ) |
|
4327 { |
|
4328 available = ETrue; |
|
4329 break; |
|
4330 } |
|
4331 } |
|
4332 |
|
4333 CleanupStack::PopAndDestroy( &targetEntries ); |
|
4334 } |
|
4335 |
|
4336 return available; |
|
4337 } |
|
4338 |
|
4339 // --------------------------------------------------------------------------- |
|
4340 // CFSEmailUiMailListVisualiser::IsMarkAsUnreadAvailableL() |
|
4341 // Function checks if mark as unread option should be available for user |
|
4342 // --------------------------------------------------------------------------- |
|
4343 // |
|
4344 TBool CFSEmailUiMailListVisualiser::IsMarkAsUnreadAvailableL() const |
|
4345 { |
|
4346 FUNC_LOG; |
|
4347 TBool available = EFalse; |
|
4348 |
|
4349 // In outbox the mark as unread is always inavailable |
|
4350 if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox ) |
|
4351 { |
|
4352 RFsTreeItemIdList targetEntries; |
|
4353 CleanupClosePushL( targetEntries ); |
|
4354 GetActionsTargetEntriesL( targetEntries ); |
|
4355 |
|
4356 // Mark as unread is available if at least one of the target entries is read |
|
4357 for ( TInt i = 0 ; i < targetEntries.Count() ; ++i ) |
|
4358 { |
|
4359 const CFSMailMessage& message = MsgPtrFromListIdL( targetEntries[i] ); |
|
4360 if ( message.IsFlagSet(EFSMsgFlag_Read) ) |
|
4361 { |
|
4362 available = ETrue; |
|
4363 break; |
|
4364 } |
|
4365 } |
|
4366 |
|
4367 CleanupStack::PopAndDestroy( &targetEntries ); |
|
4368 } |
|
4369 |
|
4370 return available; |
|
4371 } |
|
4372 |
|
4373 // --------------------------------------------------------------------------- |
|
4374 // Utility function to get list of entries which will be targeted by the |
|
4375 // Actions menu commands. The list contains either marked entries or the |
|
4376 // focused message entry or is empty. |
|
4377 // --------------------------------------------------------------------------- |
|
4378 void CFSEmailUiMailListVisualiser::GetActionsTargetEntriesL( RFsTreeItemIdList& aListItems ) const |
|
4379 { |
|
4380 FUNC_LOG; |
|
4381 if ( iMailList ) |
|
4382 { |
|
4383 iMailList->GetMarkedItemsL( aListItems ); |
|
4384 |
|
4385 // If there are no marked entries the command target is the focused item. |
|
4386 if ( !aListItems.Count() ) |
|
4387 { |
|
4388 TFsTreeItemId focusedId = iMailList->FocusedItem(); |
|
4389 if ( iFocusedControl == EMailListComponent && |
|
4390 focusedId != KFsTreeNoneID && |
|
4391 !iMailList->IsNode( focusedId ) ) |
|
4392 { |
|
4393 aListItems.AppendL( focusedId ); |
|
4394 } |
|
4395 } |
|
4396 } |
|
4397 } |
|
4398 |
|
4399 // --------------------------------------------------------------------------- |
|
4400 // |
|
4401 // |
|
4402 // --------------------------------------------------------------------------- |
|
4403 // |
|
4404 void CFSEmailUiMailListVisualiser::ShortcutReadUnreadToggleL() |
|
4405 { |
|
4406 FUNC_LOG; |
|
4407 // Setting the read status is not possible in outbox |
|
4408 // <cmail> |
|
4409 if ( iModel->Count() && iMailFolder && iMailFolder->GetFolderType() != EFSOutbox ) |
|
4410 // </cmail> |
|
4411 { |
|
4412 RFsTreeItemIdList targetEntries; |
|
4413 CleanupClosePushL( targetEntries ); |
|
4414 GetActionsTargetEntriesL( targetEntries ); |
|
4415 TInt targetCount = targetEntries.Count(); |
|
4416 |
|
4417 // figure out are we marking items as read or unread |
|
4418 TBool toggleAsRead(ETrue); |
|
4419 for ( TInt i=0 ; i<targetCount ; i++ ) |
|
4420 { |
|
4421 CFSMailMessage& msgPtr = MsgPtrFromListIdL( targetEntries[i] ); |
|
4422 if ( msgPtr.IsFlagSet(EFSMsgFlag_Read) ) |
|
4423 { |
|
4424 toggleAsRead = EFalse; |
|
4425 break; |
|
4426 } |
|
4427 } |
|
4428 |
|
4429 // change the status of the target items |
|
4430 for ( TInt i=0 ; i<targetCount ; i++ ) |
|
4431 { |
|
4432 TInt msgIndex = ModelIndexFromListId( targetEntries[i] ); |
|
4433 ChangeReadStatusOfIndexL( toggleAsRead, msgIndex ); |
|
4434 } |
|
4435 |
|
4436 CleanupStack::PopAndDestroy( &targetEntries ); |
|
4437 } |
|
4438 } |
|
4439 |
|
4440 // --------------------------------------------------------------------------- |
|
4441 // |
|
4442 // |
|
4443 // --------------------------------------------------------------------------- |
|
4444 // |
|
4445 void CFSEmailUiMailListVisualiser::HandleControlBarEvent( TFsControlBarEvent aEvent, TInt aData ) |
|
4446 { |
|
4447 FUNC_LOG; |
|
4448 if ( aEvent == EEventFocusLostAtBottom || |
|
4449 aEvent == EEventFocusLostAtSide ) |
|
4450 { |
|
4451 iFocusedControl = EMailListComponent; |
|
4452 TRAP_IGNORE( iMailList->SetFocusedL( ETrue ) ); |
|
4453 } |
|
4454 else if ( aEvent == EEventFocusGained ) |
|
4455 { |
|
4456 } |
|
4457 else if ( aEvent == EEventButtonPressed ) |
|
4458 { |
|
4459 // Handle 2 control buttons |
|
4460 if ( aData == iFolderListButtonId ) |
|
4461 { |
|
4462 } |
|
4463 else if ( aData == iSortButtonId ) |
|
4464 { |
|
4465 } |
|
4466 } |
|
4467 } |
|
4468 |
|
4469 // --------------------------------------------------------------------------- |
|
4470 // |
|
4471 // |
|
4472 // --------------------------------------------------------------------------- |
|
4473 // |
|
4474 void CFSEmailUiMailListVisualiser::CreateControlBarLayoutL() |
|
4475 { |
|
4476 FUNC_LOG; |
|
4477 TRect screenRect = iAppUi.ClientRect(); |
|
4478 iControlBarControl->SetWidthL( screenRect.Width() ); |
|
4479 //<cmail> ?? |
|
4480 //TInt normalButtonWidth = ( screenRect.Width() - KFirstButtonStartPosX*2 - 10 ) / 2; |
|
4481 //</cmail> |
|
4482 // Mailbox icon |
|
4483 iImageButtonId = iControlBarControl->AddButtonL( ECBTypeIconOnly ); |
|
4484 iIconButton = iControlBarControl->ButtonById( iImageButtonId ); |
|
4485 // <cmail> Use layout data instead of hardcoded values |
|
4486 const TRect iconButtonRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() ); |
|
4487 iIconButton->SetPos( iconButtonRect.iTl ); |
|
4488 iIconButton->SetSize( iconButtonRect.Size() ); |
|
4489 ControlGroup().AppendL(iIconButton->AsAlfControl()); |
|
4490 // </cmail> |
|
4491 |
|
4492 // Folder list button |
|
4493 iFolderListButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconB ); |
|
4494 iFolderListButton = iControlBarControl->ButtonById( iFolderListButtonId ); |
|
4495 // <cmail> Use layout data instead of hardcoded values |
|
4496 const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() ); |
|
4497 iFolderListButton->SetPos( folderButtonRect.iTl ); |
|
4498 iFolderListButton->SetSize( folderButtonRect.Size() ); |
|
4499 ControlGroup().AppendL(iFolderListButton->AsAlfControl()); |
|
4500 // </cmail> |
|
4501 |
|
4502 // Sort order button |
|
4503 iSortButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconB ); |
|
4504 iSortButton = iControlBarControl->ButtonById( iSortButtonId ); |
|
4505 // <cmail> Use layout data instead of hardcoded values |
|
4506 const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() ); |
|
4507 iSortButton->SetPos( sortButtonRect.iTl ); |
|
4508 iSortButton->SetSize( sortButtonRect.Size() ); |
|
4509 ControlGroup().AppendL(iSortButton->AsAlfControl()); |
|
4510 // </cmail> |
|
4511 |
|
4512 // Set the text alignment according the layout |
|
4513 TAlfAlignHorizontal horizontalAlign = EAlfAlignHLeft; |
|
4514 if ( AknLayoutUtils::LayoutMirrored() ) |
|
4515 { |
|
4516 horizontalAlign = EAlfAlignHRight; |
|
4517 } |
|
4518 iFolderListButton->SetElemAlignL( |
|
4519 ECBElemLabelFirstLine, |
|
4520 horizontalAlign, |
|
4521 EAlfAlignVCenter ); |
|
4522 iSortButton->SetElemAlignL( |
|
4523 ECBElemLabelFirstLine, |
|
4524 horizontalAlign, |
|
4525 EAlfAlignVCenter ); |
|
4526 |
|
4527 // Show the buttons |
|
4528 iIconButton->ClearBackgroundColor(); |
|
4529 iIconButton->SetDimmed(); |
|
4530 iFolderListButton->ShowButtonL(); |
|
4531 iSortButton->ShowButtonL(); |
|
4532 |
|
4533 // Button background images |
|
4534 iFolderListButton->ClearBackgroundColor(); |
|
4535 iSortButton->ClearBackgroundColor(); |
|
4536 |
|
4537 // Icons and sort button text |
|
4538 iIconButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) ); |
|
4539 SetSortButtonTextAndIconL(); |
|
4540 |
|
4541 //iControlBarControl->SetSelectorBorders(-2,-2,-2,-2 ); // CHECKLATER - commented out 'cause fixing things is hard - check later to replace (?) it |
|
4542 } |
|
4543 |
|
4544 // --------------------------------------------------------------------------- |
|
4545 // |
|
4546 // |
|
4547 // --------------------------------------------------------------------------- |
|
4548 // |
|
4549 void CFSEmailUiMailListVisualiser::ScaleControlBarL() |
|
4550 { |
|
4551 FUNC_LOG; |
|
4552 TRect screenRect = iAppUi.ClientRect(); |
|
4553 |
|
4554 // First set widht and height |
|
4555 iControlBarControl->SetHeightL( iAppUi.LayoutHandler()->ControlBarHeight() ); |
|
4556 iControlBarControl->SetWidthL( screenRect.Width() ); |
|
4557 |
|
4558 const TRect iconButtonRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() ); |
|
4559 iIconButton->SetPos( iconButtonRect.iTl ); |
|
4560 iIconButton->SetSize( iconButtonRect.Size() ); |
|
4561 |
|
4562 const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() ); |
|
4563 iFolderListButton->SetPos( folderButtonRect.iTl ); |
|
4564 iFolderListButton->SetSize( folderButtonRect.Size() ); |
|
4565 |
|
4566 const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() ); |
|
4567 iSortButton->SetPos( sortButtonRect.iTl ); |
|
4568 iSortButton->SetSize( sortButtonRect.Size() ); |
|
4569 |
|
4570 // Bar background |
|
4571 CAlfTexture& barBg = iAppUi.FsTextureManager()->TextureByIndex( EMailListBarBgIcon ); |
|
4572 TSize cbBgSize; |
|
4573 cbBgSize.SetSize( screenRect.Width(), iAppUi.LayoutHandler()->ControlBarHeight() ); |
|
4574 barBg.Size().SetSize( cbBgSize.iWidth, cbBgSize.iHeight ); |
|
4575 // <cmail> S60 Skin support |
|
4576 //iControlBarControl->SetBackgroundImageL( barBg ); |
|
4577 //</cmail> |
|
4578 |
|
4579 // Button background |
|
4580 CAlfTexture& buttonBg = iAppUi.FsTextureManager()->TextureByIndex( EListTextureControlButton ); |
|
4581 //<cmail> |
|
4582 buttonBg.Size().SetSize( iAppUi.LayoutHandler()->GetControlBarFolderListButtonSize().iWidth, iAppUi.LayoutHandler()->GetControlBarFolderListButtonSize().iHeight ); |
|
4583 //</cmail> |
|
4584 |
|
4585 // construct main text display window |
|
4586 // <cmail> Use layout data instead of hard-coded values |
|
4587 // const CFont* font = iEikonEnv->NormalFont(); |
|
4588 // TFontSpec fontSpec = font->FontSpecInTwips(); |
|
4589 //fontSpec.iHeight = iAppUi.LayoutHandler()->ControlBarTextHeight(); |
|
4590 |
|
4591 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
4592 TAknLayoutText textLayout; |
|
4593 textLayout.LayoutText(TRect(0,0,0,0), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_ddmenu_pane_t1(var)); |
|
4594 iFolderListButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() ); |
|
4595 iSortButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() ); |
|
4596 // </cmail> |
|
4597 |
|
4598 TRgb normalStateButtonTextColor( KRgbBlack ); |
|
4599 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
4600 normalStateButtonTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG6 ); |
|
4601 |
|
4602 iFolderListButton->SetNormalTextColor( normalStateButtonTextColor ); |
|
4603 iFolderListButton->SetFocusedTextColor( iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor() ); |
|
4604 |
|
4605 iSortButton->SetNormalTextColor( normalStateButtonTextColor ); |
|
4606 iSortButton->SetFocusedTextColor( iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor() ); |
|
4607 |
|
4608 CAlfImageBrush* folderBtnBrush = iAppUi.FsTextureManager()->NewControlBarButtonBgBrushLC(); |
|
4609 iFolderListButton->SetBackgroundImageL( folderBtnBrush ); |
|
4610 CleanupStack::Pop( folderBtnBrush ); |
|
4611 |
|
4612 CAlfImageBrush* sortBtnBrush = iAppUi.FsTextureManager()->NewControlBarButtonBgBrushLC(); |
|
4613 iSortButton->SetBackgroundImageL( sortBtnBrush ); |
|
4614 CleanupStack::Pop( sortBtnBrush ); |
|
4615 |
|
4616 iIconButton->ShowButtonL(); |
|
4617 iFolderListButton->ShowButtonL(); |
|
4618 iSortButton->ShowButtonL(); |
|
4619 |
|
4620 iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarDescendingArrowTexture ), ECBElemIconB ); |
|
4621 } |
|
4622 |
|
4623 // --------------------------------------------------------------------------- |
|
4624 // |
|
4625 // |
|
4626 // --------------------------------------------------------------------------- |
|
4627 // |
|
4628 void CFSEmailUiMailListVisualiser::SetSortButtonTextAndIconL() |
|
4629 { |
|
4630 FUNC_LOG; |
|
4631 HBufC* buttonText(0); |
|
4632 switch ( iCurrentSortCriteria.iField ) |
|
4633 { |
|
4634 case EFSMailSortBySubject: |
|
4635 { |
|
4636 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT ); |
|
4637 } |
|
4638 break; |
|
4639 case EFSMailSortByAttachment: |
|
4640 { |
|
4641 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT ); |
|
4642 } |
|
4643 break; |
|
4644 case EFSMailSortByFlagStatus: |
|
4645 { |
|
4646 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG ); |
|
4647 } |
|
4648 break; |
|
4649 case EFSMailSortByRecipient: |
|
4650 case EFSMailSortBySender: |
|
4651 { |
|
4652 TFSFolderType folderType( EFSInbox ); |
|
4653 if( iMailFolder ) |
|
4654 { |
|
4655 folderType = iMailFolder->GetFolderType(); |
|
4656 } |
|
4657 switch( folderType ) |
|
4658 { |
|
4659 case EFSSentFolder: |
|
4660 case EFSDraftsFolder: |
|
4661 case EFSOutbox: |
|
4662 { |
|
4663 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT ); |
|
4664 } |
|
4665 break; |
|
4666 default: |
|
4667 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER ); |
|
4668 break; |
|
4669 } |
|
4670 } |
|
4671 break; |
|
4672 case EFSMailSortByPriority: |
|
4673 { |
|
4674 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY ); |
|
4675 } |
|
4676 break; |
|
4677 case EFSMailSortByUnread: |
|
4678 { |
|
4679 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD ); |
|
4680 } |
|
4681 break; |
|
4682 case EFSMailSortByDate: |
|
4683 default: |
|
4684 { |
|
4685 buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE ); |
|
4686 } |
|
4687 break; |
|
4688 |
|
4689 } |
|
4690 if ( buttonText ) |
|
4691 { |
|
4692 CleanupStack::PushL( buttonText ); |
|
4693 iSortButton->SetTextL( *buttonText ); |
|
4694 CleanupStack::PopAndDestroy( buttonText ); |
|
4695 } |
|
4696 if ( iCurrentSortCriteria.iOrder == EFSMailAscending ) |
|
4697 { |
|
4698 iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarAscendingArrowTexture ), ECBElemIconB ); |
|
4699 } |
|
4700 else |
|
4701 { |
|
4702 iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarDescendingArrowTexture ), ECBElemIconB ); |
|
4703 } |
|
4704 } |
|
4705 |
|
4706 // --------------------------------------------------------------------------- |
|
4707 // |
|
4708 // |
|
4709 // --------------------------------------------------------------------------- |
|
4710 // |
|
4711 void CFSEmailUiMailListVisualiser::SetMailListLayoutAnchors() |
|
4712 { |
|
4713 FUNC_LOG; |
|
4714 // Set anchors so that list leaves space for control bar |
|
4715 iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 0, |
|
4716 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
4717 EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricRelativeToSize, |
|
4718 TAlfTimedPoint(0, 0 )); |
|
4719 iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 0, |
|
4720 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
4721 EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricAbsolute, |
|
4722 TAlfTimedPoint(1, iAppUi.LayoutHandler()->ControlBarHeight() )); |
|
4723 |
|
4724 // <cmail> Platform layout changes |
|
4725 TRect listRect = iAppUi.LayoutHandler()->GetListRect(); |
|
4726 // Set anchors so that list leaves space for control bar |
|
4727 iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1, |
|
4728 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
4729 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
|
4730 TAlfTimedPoint(listRect.iTl.iX, listRect.iTl.iY)); |
|
4731 iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1, |
|
4732 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
4733 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
|
4734 TAlfTimedPoint(listRect.iBr.iX, listRect.iBr.iY)); |
|
4735 // </cmail> Platform layout changes |
|
4736 |
|
4737 // Set anchors for connection icon |
|
4738 |
|
4739 // <cmail> Platform layout changes |
|
4740 TRect connectionIconRect( iAppUi.LayoutHandler()->GetControlBarConnectionIconRect() ); |
|
4741 const TPoint& tl( connectionIconRect.iTl ); |
|
4742 iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 2, |
|
4743 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
4744 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
|
4745 TAlfTimedPoint( tl.iX, tl.iY )); |
|
4746 const TPoint& br( connectionIconRect.iBr ); |
|
4747 iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 2, |
|
4748 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
4749 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
|
4750 TAlfTimedPoint( br.iX, br.iY )); |
|
4751 // </cmail> Platform layout changes |
|
4752 |
|
4753 iScreenAnchorLayout->UpdateChildrenLayout(); |
|
4754 } |
|
4755 |
|
4756 // --------------------------------------------------------------------------- |
|
4757 // |
|
4758 // |
|
4759 // --------------------------------------------------------------------------- |
|
4760 // |
|
4761 void CFSEmailUiMailListVisualiser::ChangeReadStatusOfHighlightedL( TBool aRead ) |
|
4762 { |
|
4763 FUNC_LOG; |
|
4764 ChangeReadStatusOfIndexL( aRead, HighlightedIndex() ); |
|
4765 } |
|
4766 |
|
4767 // --------------------------------------------------------------------------- |
|
4768 // ChangeReadStatusOfMarkedL |
|
4769 // |
|
4770 // --------------------------------------------------------------------------- |
|
4771 // |
|
4772 void CFSEmailUiMailListVisualiser::ChangeReadStatusOfMarkedL( TBool aRead ) |
|
4773 { |
|
4774 FUNC_LOG; |
|
4775 RFsTreeItemIdList markedEntries; |
|
4776 CleanupClosePushL( markedEntries ); |
|
4777 iMailList->GetMarkedItemsL( markedEntries ); |
|
4778 for ( TInt i=0; i<markedEntries.Count();i++ ) |
|
4779 { |
|
4780 TInt msgIndex = ModelIndexFromListId( markedEntries[i] ); |
|
4781 ChangeReadStatusOfIndexL( aRead, msgIndex ); |
|
4782 } |
|
4783 UnmarkAllItemsL(); |
|
4784 CleanupStack::PopAndDestroy( &markedEntries ); |
|
4785 } |
|
4786 |
|
4787 void CFSEmailUiMailListVisualiser::ChangeReadStatusOfIndexL( TBool aRead, TInt aIndex ) |
|
4788 { |
|
4789 FUNC_LOG; |
|
4790 // <cmail> |
|
4791 if ( iModel->Count() ) |
|
4792 // </cmail> |
|
4793 { |
|
4794 CFSEmailUiMailListModelItem* selectedItem = |
|
4795 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( aIndex )); |
|
4796 CFSMailMessage& msgPtr = selectedItem->MessagePtr(); |
|
4797 TBool msgWasReadBefore = msgPtr.IsFlagSet( EFSMsgFlag_Read ); |
|
4798 if ( aRead != msgWasReadBefore ) |
|
4799 { |
|
4800 if ( aRead ) |
|
4801 { |
|
4802 // Send flags, local and server |
|
4803 msgPtr.SetFlag( EFSMsgFlag_Read ); |
|
4804 } |
|
4805 else |
|
4806 { |
|
4807 // Send flags, local and server |
|
4808 msgPtr.ResetFlag( EFSMsgFlag_Read ); |
|
4809 } |
|
4810 msgPtr.SaveMessageL(); // Save flag |
|
4811 |
|
4812 // Switch icon to correct one |
|
4813 UpdateMsgIconAndBoldingL( aIndex ); |
|
4814 |
|
4815 if ( iCurrentSortCriteria.iField == EFSMailSortByUnread ) |
|
4816 { |
|
4817 // Attribute affecting the current sorting order has been changed. |
|
4818 // Thus, the list order may now be incorrect. |
|
4819 iListOrderMayBeOutOfDate = ETrue; |
|
4820 } |
|
4821 } |
|
4822 } |
|
4823 } |
|
4824 |
|
4825 // --------------------------------------------------------------------------- |
|
4826 // DeleteMessagesL |
|
4827 // |
|
4828 // --------------------------------------------------------------------------- |
|
4829 // |
|
4830 void CFSEmailUiMailListVisualiser::DeleteMessagesL() |
|
4831 { |
|
4832 FUNC_LOG; |
|
4833 TInt markedCount = CountMarkedItemsL(); |
|
4834 |
|
4835 // Delete either marked items or the focused one |
|
4836 if ( markedCount ) |
|
4837 { |
|
4838 DeleteMarkedMessagesL(); |
|
4839 } |
|
4840 else |
|
4841 { |
|
4842 DeleteFocusedMessageL(); |
|
4843 } |
|
4844 |
|
4845 // Set highlight to control bar if no items after delete |
|
4846 // <cmail> |
|
4847 if ( iModel->Count() == 0 ) |
|
4848 // </cmail> |
|
4849 { |
|
4850 iFocusedControl = EControlBarComponent; |
|
4851 iMailList->SetFocusedL( EFalse ); |
|
4852 iControlBarControl->SetFocusL(); |
|
4853 } |
|
4854 } |
|
4855 |
|
4856 // --------------------------------------------------------------------------- |
|
4857 // UpdateItemAtIndexL |
|
4858 // Reload message pointer from mail client and update list item contents to |
|
4859 // match it. Item is removed if it isn't valid anymore. |
|
4860 // --------------------------------------------------------------------------- |
|
4861 // |
|
4862 void CFSEmailUiMailListVisualiser::UpdateItemAtIndexL( TInt aIndex ) |
|
4863 { |
|
4864 FUNC_LOG; |
|
4865 // <cmail> |
|
4866 |
|
4867 if ( aIndex >= 0 && aIndex < iModel->Count() ) |
|
4868 // </cmail> |
|
4869 { |
|
4870 CFSEmailUiMailListModelItem* modelItem = |
|
4871 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( aIndex ) ); |
|
4872 if ( modelItem->ModelItemType() == ETypeMailItem ) |
|
4873 { |
|
4874 // This is beacause message deleted event migh have occured. |
|
4875 CFSMailMessage* confirmedMsgPtr = NULL; |
|
4876 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
|
4877 iMailFolder->GetFolderId(), |
|
4878 modelItem->MessagePtr().GetMessageId() , |
|
4879 EFSMsgDataEnvelope ) ); |
|
4880 if ( confirmedMsgPtr ) |
|
4881 { |
|
4882 // Replace message pointer in model with newly fetched one |
|
4883 Model()->ReplaceMessagePtr( aIndex, confirmedMsgPtr ); |
|
4884 |
|
4885 const SMailListItem& item = iTreeItemArray[aIndex]; |
|
4886 |
|
4887 // Update the list item contents and formating to match the message pointer |
|
4888 CFsTreePlainTwoLineItemData* itemData = |
|
4889 static_cast<CFsTreePlainTwoLineItemData*>( item.iTreeItemData ); |
|
4890 CFsTreePlainTwoLineItemVisualizer* itemVis = |
|
4891 static_cast<CFsTreePlainTwoLineItemVisualizer*>( item.iTreeItemVisualiser ); |
|
4892 |
|
4893 UpdateItemDataL( itemData, confirmedMsgPtr ); |
|
4894 UpdatePreviewPaneTextForItemL( itemData, confirmedMsgPtr ); |
|
4895 UpdateMsgIconAndBoldingL( itemData, itemVis, confirmedMsgPtr ); |
|
4896 iMailTreeListVisualizer->UpdateItemL( item.iListItemId ); |
|
4897 } |
|
4898 else |
|
4899 { |
|
4900 // No confirmed message for highlighted, remove from list also |
|
4901 iMailList->RemoveL( iTreeItemArray[aIndex].iListItemId ); // remove from list |
|
4902 iTreeItemArray.Remove( aIndex ); // remove from internal array. |
|
4903 iModel->RemoveAndDestroy( aIndex ); // Remove from model |
|
4904 if ( iNodesInUse ) |
|
4905 { |
|
4906 RemoveUnnecessaryNodesL(); |
|
4907 } |
|
4908 } |
|
4909 } |
|
4910 } |
|
4911 } |
|
4912 |
|
4913 // --------------------------------------------------------------------------- |
|
4914 // CheckValidityOfHighlightedMsgL |
|
4915 // Check validity of highlighted msg, and remove from list if needed |
|
4916 // Typically called after view is returned from editot or viewer. |
|
4917 // --------------------------------------------------------------------------- |
|
4918 // |
|
4919 TBool CFSEmailUiMailListVisualiser::CheckValidityOfHighlightedMsgL() |
|
4920 { |
|
4921 FUNC_LOG; |
|
4922 TBool ret(EFalse); |
|
4923 // <cmail> |
|
4924 if ( iModel->Count() ) |
|
4925 // </cmail> |
|
4926 { |
|
4927 CFSEmailUiMailListModelItem* item = |
|
4928 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( HighlightedIndex() ) ); |
|
4929 if ( item->ModelItemType() == ETypeMailItem ) |
|
4930 { |
|
4931 // This is beacause message deleted event migh have occured. |
|
4932 CFSMailMessage* confirmedMsgPtr = NULL; |
|
4933 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
|
4934 iMailFolder->GetFolderId(), |
|
4935 item->MessagePtr().GetMessageId() , |
|
4936 EFSMsgDataEnvelope ) ); |
|
4937 if ( confirmedMsgPtr ) |
|
4938 { |
|
4939 ret = ETrue; |
|
4940 delete confirmedMsgPtr; |
|
4941 confirmedMsgPtr = NULL; |
|
4942 } |
|
4943 else |
|
4944 { |
|
4945 // No confirmed message for highlighted, remove from list also |
|
4946 ret = EFalse; |
|
4947 SMailListItem item; |
|
4948 item.iListItemId = iMailList->FocusedItem(); |
|
4949 TInt IndexToBeDestroyed = iTreeItemArray.Find( item ); |
|
4950 iTreeItemArray.Remove( IndexToBeDestroyed ); // remove from internal array. |
|
4951 iModel->RemoveAndDestroy( IndexToBeDestroyed ); // Remove from model |
|
4952 iMailList->RemoveL( iMailList->FocusedItem() ); // remove from list |
|
4953 if ( iNodesInUse ) |
|
4954 { |
|
4955 RemoveUnnecessaryNodesL(); |
|
4956 } |
|
4957 } |
|
4958 } |
|
4959 } |
|
4960 return ret; |
|
4961 } |
|
4962 |
|
4963 // --------------------------------------------------------------------------- |
|
4964 // UpdateMsgIconAndBoldingL |
|
4965 // Updates our own message object with the data from a given message object. |
|
4966 // The messages are matched with the message ID. |
|
4967 // --------------------------------------------------------------------------- |
|
4968 void CFSEmailUiMailListVisualiser::UpdateMsgIconAndBoldingL( CFSMailMessage* aMsgPtr ) |
|
4969 { |
|
4970 FUNC_LOG; |
|
4971 // <cmail> |
|
4972 if ( aMsgPtr && iModel->Count() ) |
|
4973 // </cmail> |
|
4974 { |
|
4975 TInt mailItemIdx = ItemIndexFromMessageId( aMsgPtr->GetMessageId() ); |
|
4976 if ( mailItemIdx >= 0 ) |
|
4977 { |
|
4978 CFSEmailUiMailListModelItem* item = |
|
4979 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( mailItemIdx ) ); |
|
4980 |
|
4981 // Update all flags |
|
4982 TUint32 prevFlags = item->MessagePtr().GetFlags(); |
|
4983 TUint32 newFlags = aMsgPtr->GetFlags(); |
|
4984 if ( prevFlags != newFlags ) |
|
4985 { |
|
4986 item->MessagePtr().ResetFlag( prevFlags ); |
|
4987 item->MessagePtr().SetFlag( newFlags ); |
|
4988 |
|
4989 // Save changed flags in internal model array |
|
4990 item->MessagePtr().SaveMessageL(); |
|
4991 } |
|
4992 |
|
4993 // Update the list item graphics |
|
4994 UpdateMsgIconAndBoldingL( mailItemIdx ); |
|
4995 } |
|
4996 } |
|
4997 } |
|
4998 |
|
4999 // --------------------------------------------------------------------------- |
|
5000 // UpdateMsgIconAndBoldingL |
|
5001 // Updates list item at given index to match the state of the message object |
|
5002 // --------------------------------------------------------------------------- |
|
5003 // |
|
5004 void CFSEmailUiMailListVisualiser::UpdateMsgIconAndBoldingL( TInt aListIndex, TBool aRefreshItem ) |
|
5005 { |
|
5006 FUNC_LOG; |
|
5007 CFSEmailUiMailListModelItem* item = |
|
5008 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(aListIndex) ); |
|
5009 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
5010 { |
|
5011 CFSMailMessage* msgPtr = &item->MessagePtr(); |
|
5012 CFsTreePlainTwoLineItemData* itemData = |
|
5013 static_cast<CFsTreePlainTwoLineItemData*>( iTreeItemArray[aListIndex].iTreeItemData ); |
|
5014 CFsTreePlainTwoLineItemVisualizer* itemVis = |
|
5015 static_cast<CFsTreePlainTwoLineItemVisualizer*>( iTreeItemArray[aListIndex].iTreeItemVisualiser ); |
|
5016 |
|
5017 UpdateMsgIconAndBoldingL( itemData, itemVis, msgPtr ); |
|
5018 |
|
5019 //refresh item if requested |
|
5020 if ( aRefreshItem ) |
|
5021 { |
|
5022 iMailTreeListVisualizer->UpdateItemL( iTreeItemArray[aListIndex].iListItemId ); |
|
5023 } |
|
5024 } |
|
5025 } |
|
5026 |
|
5027 // --------------------------------------------------------------------------- |
|
5028 // UpdateMsgIconAndBoldingL |
|
5029 // Updates list item at given index to match the state of the message object |
|
5030 // --------------------------------------------------------------------------- |
|
5031 // |
|
5032 void CFSEmailUiMailListVisualiser::UpdateMsgIconAndBoldingL( CFsTreePlainTwoLineItemData* aItemData, |
|
5033 CFsTreePlainTwoLineItemVisualizer* aItemVis, |
|
5034 CFSMailMessage* aMsgPtr ) |
|
5035 { |
|
5036 FUNC_LOG; |
|
5037 |
|
5038 if ( aItemData && aItemVis && aMsgPtr ) |
|
5039 { |
|
5040 CAlfTexture* itemTexture = &TFsEmailUiUtility::GetMsgIcon( aMsgPtr, *iAppUi.FsTextureManager() ); |
|
5041 |
|
5042 aItemData->SetIcon( *itemTexture ); |
|
5043 |
|
5044 // Set font according the read status |
|
5045 if ( aMsgPtr->IsFlagSet( EFSMsgFlag_Read ) ) |
|
5046 { |
|
5047 CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( EFSFontTypeSmall ); |
|
5048 aItemVis->SetTextStyleId ( textStyle->Id() ); |
|
5049 aItemVis->SetTextBold( EFalse ); |
|
5050 } |
|
5051 else |
|
5052 { |
|
5053 CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( EFSFontTypeSmallBold ); |
|
5054 aItemVis->SetTextStyleId ( textStyle->Id() ); |
|
5055 aItemVis->SetTextBold( ETrue ); |
|
5056 } |
|
5057 |
|
5058 // Set follow up flag icon |
|
5059 if ( aMsgPtr->IsFlagSet( EFSMsgFlag_FollowUp ) ) |
|
5060 { |
|
5061 aItemData->SetFlagIcon( iAppUi.FsTextureManager()->TextureByIndex( EFollowUpFlagList ) ); |
|
5062 aItemVis->SetFlagIconVisible( ETrue ); |
|
5063 } |
|
5064 else if ( aMsgPtr->IsFlagSet( EFSMsgFlag_FollowUpComplete ) ) |
|
5065 { |
|
5066 aItemData->SetFlagIcon( iAppUi.FsTextureManager()->TextureByIndex( EFollowUpFlagCompleteList ) ); |
|
5067 aItemVis->SetFlagIconVisible( ETrue ); |
|
5068 } |
|
5069 else |
|
5070 { |
|
5071 aItemVis->SetFlagIconVisible( EFalse ); |
|
5072 } |
|
5073 } |
|
5074 } |
|
5075 |
|
5076 // --------------------------------------------------------------------------- |
|
5077 // RemoveMsgItemsFromListIfFoundL |
|
5078 // Message removing from list if found. Does not panic or return found status. |
|
5079 // --------------------------------------------------------------------------- |
|
5080 // |
|
5081 void CFSEmailUiMailListVisualiser::RemoveMsgItemsFromListIfFoundL( const RArray<TFSMailMsgId>& aEntryIds ) |
|
5082 { |
|
5083 FUNC_LOG; |
|
5084 for ( TInt i=0 ; i<aEntryIds.Count() ; ++i ) |
|
5085 { |
|
5086 const TFSMailMsgId& entryId = aEntryIds[i]; |
|
5087 if ( !entryId.IsNullId() ) |
|
5088 { |
|
5089 TInt idx = ItemIndexFromMessageId( entryId ); |
|
5090 if ( idx >= 0 ) |
|
5091 { |
|
5092 iMailList->RemoveL( iTreeItemArray[idx].iListItemId ); // remove from list |
|
5093 iTreeItemArray.Remove( idx ); // remove from internal array. |
|
5094 iModel->RemoveAndDestroy( idx ); // Remove from model |
|
5095 } |
|
5096 } |
|
5097 } |
|
5098 if ( iNodesInUse ) |
|
5099 { |
|
5100 RemoveUnnecessaryNodesL(); |
|
5101 } |
|
5102 |
|
5103 // Set highligh to control bar if no items left after |
|
5104 // deleted items have been revoved from the list |
|
5105 // Otherwise mail list takes care of highlight |
|
5106 // <cmail> |
|
5107 if ( iModel->Count() == 0 ) |
|
5108 // </cmail> |
|
5109 { |
|
5110 iFocusedControl = EControlBarComponent; |
|
5111 iMailList->SetFocusedL( EFalse ); |
|
5112 iControlBarControl->SetFocusL(); |
|
5113 } |
|
5114 } |
|
5115 |
|
5116 // --------------------------------------------------------------------------- |
|
5117 // DeleteFocusedMessageL |
|
5118 // |
|
5119 // --------------------------------------------------------------------------- |
|
5120 // |
|
5121 void CFSEmailUiMailListVisualiser::DeleteFocusedMessageL() |
|
5122 { |
|
5123 FUNC_LOG; |
|
5124 TInt currentItemIndex = HighlightedIndex(); |
|
5125 if ( Model()->Count() ) |
|
5126 { |
|
5127 CFSEmailUiMailListModelItem* item = |
|
5128 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(currentItemIndex) ); |
|
5129 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
5130 { |
|
5131 CFSMailMessage& messagePtr = item->MessagePtr(); |
|
5132 |
|
5133 TInt okToDelete(ETrue); |
|
5134 if ( iAppUi.GetCRHandler()->WarnBeforeDelete() ) |
|
5135 { |
|
5136 TInt queryTextId(0); |
|
5137 if ( messagePtr.IsFlagSet( EFSMsgFlag_CalendarMsg )) |
|
5138 { |
|
5139 queryTextId = R_FREESTYLE_EMAIL_DELETE_CALEVENT_NOTE; |
|
5140 } |
|
5141 else |
|
5142 { |
|
5143 queryTextId = R_FREESTYLE_EMAIL_DELETE_MAIL_NOTE; |
|
5144 } |
|
5145 HBufC* msgSubject = TFsEmailUiUtility::CreateSubjectTextLC( &messagePtr ); |
|
5146 |
|
5147 okToDelete = TFsEmailUiUtility::ShowConfirmationQueryL( queryTextId, *msgSubject ); |
|
5148 |
|
5149 CleanupStack::PopAndDestroy( msgSubject ); |
|
5150 } |
|
5151 |
|
5152 if ( okToDelete ) |
|
5153 { |
|
5154 // Delete message from framework, and perform internal housekeeping |
|
5155 TFSMailMsgId msgId = messagePtr.GetMessageId(); |
|
5156 RArray<TFSMailMsgId> msgIds; |
|
5157 CleanupClosePushL( msgIds ); |
|
5158 msgIds.Append( msgId ); |
|
5159 TFSMailMsgId folderId = FolderId(); |
|
5160 TFSMailMsgId mailBox = iAppUi.GetActiveMailbox()->GetId(); |
|
5161 iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds ); |
|
5162 RemoveMsgItemsFromListIfFoundL( msgIds ); |
|
5163 CleanupStack::PopAndDestroy( &msgIds ); |
|
5164 } |
|
5165 } |
|
5166 } |
|
5167 } |
|
5168 |
|
5169 // --------------------------------------------------------------------------- |
|
5170 // DeleteMarkedMessagesL |
|
5171 // |
|
5172 // --------------------------------------------------------------------------- |
|
5173 // |
|
5174 void CFSEmailUiMailListVisualiser::DeleteMarkedMessagesL() |
|
5175 { |
|
5176 FUNC_LOG; |
|
5177 RFsTreeItemIdList markedEntries; |
|
5178 CleanupClosePushL( markedEntries ); |
|
5179 iMailList->GetMarkedItemsL( markedEntries ); |
|
5180 TInt okToDelete( ETrue ); |
|
5181 |
|
5182 if ( iAppUi.GetCRHandler()->WarnBeforeDelete() ) |
|
5183 { |
|
5184 HBufC* noteText( NULL ); |
|
5185 // The note depends on the amount and type of message(s) |
|
5186 if ( markedEntries.Count() == 1 ) |
|
5187 { |
|
5188 CFSMailMessage& msgPtr = MsgPtrFromListIdL( markedEntries[0] ); |
|
5189 |
|
5190 HBufC* msgSubject = TFsEmailUiUtility::CreateSubjectTextLC( &msgPtr ); |
|
5191 if ( msgPtr.IsFlagSet( EFSMsgFlag_CalendarMsg )) |
|
5192 { |
|
5193 noteText = StringLoader::LoadL( R_FREESTYLE_EMAIL_DELETE_CALEVENT_NOTE, *msgSubject ); |
|
5194 } |
|
5195 else |
|
5196 { |
|
5197 noteText = StringLoader::LoadL( R_FREESTYLE_EMAIL_DELETE_MAIL_NOTE, *msgSubject ); |
|
5198 } |
|
5199 CleanupStack::PopAndDestroy( msgSubject ); |
|
5200 CleanupStack::PushL( noteText ); |
|
5201 } |
|
5202 else // markedEntries.Count() > 1 |
|
5203 { |
|
5204 noteText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_DELETE_N_MAILS_NOTE, markedEntries.Count() ); |
|
5205 } |
|
5206 |
|
5207 // Show the note |
|
5208 okToDelete = TFsEmailUiUtility::ShowConfirmationQueryL( *noteText ); |
|
5209 CleanupStack::PopAndDestroy( noteText ); |
|
5210 } |
|
5211 |
|
5212 if ( okToDelete ) |
|
5213 { |
|
5214 if ( markedEntries.Count() > KMsgDeletionWaitNoteAmount ) |
|
5215 { |
|
5216 TFsEmailUiUtility::ShowWaitNoteL( iDeletingWaitNote, R_FSE_WAIT_DELETING_TEXT, EFalse, ETrue ); |
|
5217 } |
|
5218 |
|
5219 // <cmail> |
|
5220 if ( iAsyncCallback ) |
|
5221 { |
|
5222 // Call actual deletion asynchronously because we must give wait |
|
5223 // note time to show up before deletion begins. |
|
5224 iAsyncCallback->Cancel(); |
|
5225 iAsyncCallback->Set( TCallBack(DoDeleteMarkedMessages, this) ); |
|
5226 iAsyncCallback->CallBack(); |
|
5227 } |
|
5228 // </cmail> |
|
5229 } |
|
5230 |
|
5231 CleanupStack::PopAndDestroy( &markedEntries ); |
|
5232 } |
|
5233 |
|
5234 // --------------------------------------------------------------------------- |
|
5235 // DoDeleteMarkedMessages |
|
5236 // |
|
5237 // --------------------------------------------------------------------------- |
|
5238 // |
|
5239 TInt CFSEmailUiMailListVisualiser::DoDeleteMarkedMessages( TAny* aSelfPtr ) |
|
5240 { |
|
5241 FUNC_LOG; |
|
5242 CFSEmailUiMailListVisualiser* self = |
|
5243 static_cast<CFSEmailUiMailListVisualiser*>( aSelfPtr ); |
|
5244 |
|
5245 TRAPD( err, |
|
5246 RFsTreeItemIdList markedEntries; |
|
5247 CleanupClosePushL( markedEntries ); |
|
5248 self->iMailList->GetMarkedItemsL( markedEntries ); |
|
5249 |
|
5250 // Delete from FW first |
|
5251 RArray<TFSMailMsgId> msgIds; |
|
5252 CleanupClosePushL( msgIds ); |
|
5253 for ( TInt i=0 ; i<markedEntries.Count() ; i++ ) |
|
5254 { |
|
5255 msgIds.Append( self->MsgIdFromListId( markedEntries[i] ) ); |
|
5256 } |
|
5257 TFSMailMsgId folderId = self->FolderId(); |
|
5258 TFSMailMsgId mailBox = self->iAppUi.GetActiveMailboxId(); |
|
5259 self->iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds ); |
|
5260 |
|
5261 // Remove from mail list if not already removed by mailbox events |
|
5262 self->RemoveMsgItemsFromListIfFoundL( msgIds ); |
|
5263 |
|
5264 CleanupStack::PopAndDestroy( &msgIds ); |
|
5265 CleanupStack::PopAndDestroy( &markedEntries ); |
|
5266 ); |
|
5267 |
|
5268 // Close wait note if it was used |
|
5269 if ( self->iDeletingWaitNote ) |
|
5270 { |
|
5271 TRAP_IGNORE( self->iDeletingWaitNote->ProcessFinishedL() ); |
|
5272 } |
|
5273 |
|
5274 return err; |
|
5275 } |
|
5276 |
|
5277 // --------------------------------------------------------------------------- |
|
5278 // RemoveUnnecessaryNodesL |
|
5279 // |
|
5280 // --------------------------------------------------------------------------- |
|
5281 // |
|
5282 void CFSEmailUiMailListVisualiser::RemoveUnnecessaryNodesL() |
|
5283 { |
|
5284 FUNC_LOG; |
|
5285 RArray<TInt> nodesToBeRemoved; |
|
5286 CleanupClosePushL( nodesToBeRemoved ); |
|
5287 for ( TInt i=0;i<iTreeItemArray.Count();i++) |
|
5288 { |
|
5289 if ( iMailList->IsNode( iTreeItemArray[i].iListItemId ) ) |
|
5290 { |
|
5291 if ( iMailList->CountChildren( iTreeItemArray[i].iListItemId ) == 0) |
|
5292 { |
|
5293 nodesToBeRemoved.Append( iTreeItemArray[i].iListItemId ); |
|
5294 } |
|
5295 } |
|
5296 } |
|
5297 // Remove from the list itself and from iTreeItemArray |
|
5298 for ( TInt a = 0; a < nodesToBeRemoved.Count(); a++ ) |
|
5299 { |
|
5300 iMailList->RemoveL( nodesToBeRemoved[a] ); |
|
5301 SMailListItem item; |
|
5302 item.iListItemId = nodesToBeRemoved[a]; |
|
5303 TInt IndexToBeDestroyed = iTreeItemArray.Find( item ); |
|
5304 iTreeItemArray.Remove( IndexToBeDestroyed ); // remove from internal array. |
|
5305 // Remove from model |
|
5306 iModel->RemoveAndDestroy( IndexToBeDestroyed ); |
|
5307 } |
|
5308 CleanupStack::PopAndDestroy( &nodesToBeRemoved ); |
|
5309 } |
|
5310 |
|
5311 // --------------------------------------------------------------------------- |
|
5312 // MsgIdFromIndex |
|
5313 // Helper function to get message id from list index |
|
5314 // --------------------------------------------------------------------------- |
|
5315 // |
|
5316 TFSMailMsgId CFSEmailUiMailListVisualiser::MsgIdFromIndex( TInt aItemIdx ) const |
|
5317 { |
|
5318 FUNC_LOG; |
|
5319 TFSMailMsgId msgId; // constructs null ID |
|
5320 // <cmail> |
|
5321 if ( 0 <= aItemIdx && aItemIdx < iModel->Count() ) |
|
5322 // </cmail> |
|
5323 { |
|
5324 CFSEmailUiMailListModelItem* item = |
|
5325 static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(aItemIdx)); |
|
5326 if ( item->ModelItemType() == ETypeMailItem ) |
|
5327 { |
|
5328 msgId = item->MessagePtr().GetMessageId(); |
|
5329 } |
|
5330 } |
|
5331 |
|
5332 return msgId; |
|
5333 } |
|
5334 |
|
5335 // --------------------------------------------------------------------------- |
|
5336 // MsgIdFromListId |
|
5337 // Get message ID corresponding given list ID. If the list ID is for a node, |
|
5338 // the message ID of its first child is returned |
|
5339 // --------------------------------------------------------------------------- |
|
5340 // |
|
5341 TFSMailMsgId CFSEmailUiMailListVisualiser::MsgIdFromListId( TFsTreeItemId aListId ) const |
|
5342 { |
|
5343 FUNC_LOG; |
|
5344 TFSMailMsgId msgId; // constructs null ID |
|
5345 |
|
5346 if ( aListId != KFsTreeNoneID ) |
|
5347 { |
|
5348 // Substitute node ID with ID of its first child |
|
5349 if ( iMailList->IsNode( aListId ) && iMailList->CountChildren( aListId ) ) |
|
5350 { |
|
5351 aListId = iMailList->Child( aListId, 0 ); |
|
5352 } |
|
5353 |
|
5354 // Find corresponding message from the model |
|
5355 for ( TInt i=0 ; i<iModel->Count() ; i++ ) |
|
5356 { |
|
5357 CFSEmailUiMailListModelItem* item = |
|
5358 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) ); |
|
5359 if ( item->ModelItemType() == ETypeMailItem && |
|
5360 aListId == item->CorrespondingListId() ) |
|
5361 { |
|
5362 msgId = item->MessagePtr().GetMessageId(); |
|
5363 break; |
|
5364 } |
|
5365 } |
|
5366 } |
|
5367 |
|
5368 return msgId; |
|
5369 } |
|
5370 |
|
5371 // --------------------------------------------------------------------------- |
|
5372 // MsgPtrFromListIdL |
|
5373 // |
|
5374 // --------------------------------------------------------------------------- |
|
5375 // |
|
5376 CFSMailMessage& CFSEmailUiMailListVisualiser::MsgPtrFromListIdL( TFsTreeItemId aListId ) |
|
5377 { |
|
5378 FUNC_LOG; |
|
5379 TInt index = ModelIndexFromListId( aListId ); |
|
5380 if ( index >= 0 ) |
|
5381 { |
|
5382 CFSEmailUiMailListModelItem* item = |
|
5383 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(index) ); |
|
5384 return item->MessagePtr(); |
|
5385 } |
|
5386 else |
|
5387 { |
|
5388 // Leave if no message found. As the function returns a reference, it is not |
|
5389 // possible to return any meaningful null value. |
|
5390 User::Leave( KErrNotFound ); |
|
5391 } |
|
5392 |
|
5393 CFSMailMessage* dummy = NULL; |
|
5394 return *dummy; // to surpress warning about missing return value; this is not really ever run |
|
5395 } |
|
5396 |
|
5397 // --------------------------------------------------------------------------- |
|
5398 // MsgPtrFromListIdL |
|
5399 // |
|
5400 // --------------------------------------------------------------------------- |
|
5401 // |
|
5402 const CFSMailMessage& CFSEmailUiMailListVisualiser::MsgPtrFromListIdL( TFsTreeItemId aListId ) const |
|
5403 { |
|
5404 FUNC_LOG; |
|
5405 TInt index = ModelIndexFromListId( aListId ); |
|
5406 if ( index >= 0 ) |
|
5407 { |
|
5408 CFSEmailUiMailListModelItem* item = |
|
5409 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(index) ); |
|
5410 return item->MessagePtr(); |
|
5411 } |
|
5412 else |
|
5413 { |
|
5414 // Leave if no message found. As the function returns a reference, it is not |
|
5415 // possible to return any meaningful null value. |
|
5416 User::Leave( KErrNotFound ); |
|
5417 } |
|
5418 |
|
5419 const CFSMailMessage* dummy = NULL; |
|
5420 return *dummy; // to surpress warning about missing return value; this is not really ever run |
|
5421 } |
|
5422 |
|
5423 // --------------------------------------------------------------------------- |
|
5424 // ItemDataFromItemId |
|
5425 // Function returns a valid pointer to list item data based on item id |
|
5426 // --------------------------------------------------------------------------- |
|
5427 // |
|
5428 MFsTreeItemData* CFSEmailUiMailListVisualiser::ItemDataFromItemId( TFsTreeItemId aItemId ) |
|
5429 { |
|
5430 FUNC_LOG; |
|
5431 MFsTreeItemData* itemData = NULL; |
|
5432 if ( aItemId != KFsTreeNoneID ) |
|
5433 { |
|
5434 itemData = &iMailList->ItemData( aItemId ); |
|
5435 } |
|
5436 return itemData; |
|
5437 } |
|
5438 |
|
5439 // --------------------------------------------------------------------------- |
|
5440 // ItemVisualiserFromItemId |
|
5441 // Function returns a valid pointer to list item visualiser based on item id |
|
5442 // --------------------------------------------------------------------------- |
|
5443 // |
|
5444 MFsTreeItemVisualizer* CFSEmailUiMailListVisualiser::ItemVisualiserFromItemId( TFsTreeItemId aItemId ) |
|
5445 { |
|
5446 FUNC_LOG; |
|
5447 MFsTreeItemVisualizer* itemVis = NULL; |
|
5448 if ( aItemId != KFsTreeNoneID ) |
|
5449 { |
|
5450 itemVis = &iMailList->ItemVisualizer( aItemId ); |
|
5451 } |
|
5452 return itemVis; |
|
5453 } |
|
5454 |
|
5455 // --------------------------------------------------------------------------- |
|
5456 // ItemIndexFromMessageId |
|
5457 // Function returns list index based on message pointer. KErrNotFound if |
|
5458 // ID is not included in the list |
|
5459 // --------------------------------------------------------------------------- |
|
5460 // |
|
5461 TInt CFSEmailUiMailListVisualiser::ItemIndexFromMessageId( const TFSMailMsgId& aMessageId ) const |
|
5462 { |
|
5463 FUNC_LOG; |
|
5464 TInt idx = KErrNotFound; |
|
5465 |
|
5466 // Check first the special case; if searched id is null id, there's no |
|
5467 // point to loop the whole list. There shouldn't be any null id's in |
|
5468 // the model anyway. There is currently also an error in FW's equality |
|
5469 // operator implementation; it doesn't check the iNullId flag at all. |
|
5470 if( !aMessageId.IsNullId() ) |
|
5471 { |
|
5472 for ( TInt i=0; i<iModel->Count() ; i++ ) |
|
5473 { |
|
5474 CFSEmailUiMailListModelItem* item = |
|
5475 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) ); |
|
5476 if ( item->ModelItemType() == ETypeMailItem && |
|
5477 aMessageId == item->MessagePtr().GetMessageId() ) |
|
5478 { |
|
5479 idx = i; |
|
5480 break; |
|
5481 } |
|
5482 } |
|
5483 } |
|
5484 return idx; |
|
5485 } |
|
5486 |
|
5487 // --------------------------------------------------------------------------- |
|
5488 // NextMessageIndex |
|
5489 // Function returns next message index from highlighted index |
|
5490 // KErrNotFound if there is no next message |
|
5491 // --------------------------------------------------------------------------- |
|
5492 // |
|
5493 TInt CFSEmailUiMailListVisualiser::NextMessageIndex( TInt aCurMsgIdx ) const |
|
5494 { |
|
5495 FUNC_LOG; |
|
5496 TInt idx = KErrNotFound; |
|
5497 for ( TInt i=aCurMsgIdx+1 ; i<iModel->Count() ; i++ ) |
|
5498 { |
|
5499 CFSEmailUiMailListModelItem* item = |
|
5500 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) ); |
|
5501 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
5502 { |
|
5503 idx = i; |
|
5504 break; |
|
5505 } |
|
5506 } |
|
5507 |
|
5508 return idx; |
|
5509 } |
|
5510 |
|
5511 // --------------------------------------------------------------------------- |
|
5512 // PreviousMessageIndex |
|
5513 // Function returns previous message index from highlighted index |
|
5514 // KErrNotFound if there is no previous message |
|
5515 // --------------------------------------------------------------------------- |
|
5516 // |
|
5517 TInt CFSEmailUiMailListVisualiser::PreviousMessageIndex( TInt aCurMsgIdx ) const |
|
5518 { |
|
5519 FUNC_LOG; |
|
5520 TInt idx( KErrNotFound ); |
|
5521 if ( aCurMsgIdx < iModel->Count() ) |
|
5522 { |
|
5523 for ( TInt i=aCurMsgIdx-1 ; i>=0 ; i-- ) |
|
5524 { |
|
5525 CFSEmailUiMailListModelItem* item = |
|
5526 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) ); |
|
5527 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
5528 { |
|
5529 idx = i; |
|
5530 break; |
|
5531 } |
|
5532 } |
|
5533 } |
|
5534 return idx; |
|
5535 } |
|
5536 |
|
5537 // --------------------------------------------------------------------------- |
|
5538 // ModelIndexFromListId |
|
5539 // Function returns a model index corresponding the given tree list item ID |
|
5540 // --------------------------------------------------------------------------- |
|
5541 // |
|
5542 TInt CFSEmailUiMailListVisualiser::ModelIndexFromListId( TFsTreeItemId aItemId ) const |
|
5543 { |
|
5544 FUNC_LOG; |
|
5545 TInt ret = KErrNotFound; |
|
5546 const TInt count = iModel->Count(); |
|
5547 for ( TInt i=0; i < count; i++ ) |
|
5548 { |
|
5549 const CFSEmailUiMailListModelItem* item = |
|
5550 static_cast<const CFSEmailUiMailListModelItem*>( iModel->Item(i) ); |
|
5551 if ( aItemId == item->CorrespondingListId() ) |
|
5552 { |
|
5553 ret = i; |
|
5554 break; |
|
5555 } |
|
5556 } |
|
5557 return ret; |
|
5558 } |
|
5559 |
|
5560 // --------------------------------------------------------------------------- |
|
5561 // FolderSelectedL |
|
5562 // Folder list selection callback. Function updates list when folder is changed |
|
5563 // --------------------------------------------------------------------------- |
|
5564 // |
|
5565 void CFSEmailUiMailListVisualiser::FolderSelectedL( |
|
5566 TFSMailMsgId aSelectedFolderId, |
|
5567 TFSEmailUiCtrlBarResponse aResponse ) |
|
5568 { |
|
5569 FUNC_LOG; |
|
5570 // hide selector if keys are not pressed |
|
5571 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
5572 if ( iMoveToFolderOngoing ) |
|
5573 { |
|
5574 iMoveToFolderOngoing = EFalse; |
|
5575 switch ( aResponse ) |
|
5576 { |
|
5577 case EFSEmailUiCtrlBarResponseCancel: |
|
5578 SetMskL(); |
|
5579 return; |
|
5580 case EFSEmailUiCtrlBarResponseSelect: |
|
5581 { |
|
5582 MoveMsgsToFolderL( aSelectedFolderId ); |
|
5583 SetMskL(); |
|
5584 } |
|
5585 break; |
|
5586 default: |
|
5587 break; |
|
5588 } |
|
5589 } |
|
5590 else |
|
5591 { |
|
5592 // Ignore if cancel selected |
|
5593 switch ( aResponse ) |
|
5594 { |
|
5595 case EFSEmailUiCtrlBarResponseSwitchList: |
|
5596 { |
|
5597 TFSFolderType folderType; |
|
5598 if ( iMailFolder ) |
|
5599 { |
|
5600 folderType = iMailFolder->GetFolderType(); |
|
5601 } |
|
5602 else |
|
5603 { |
|
5604 folderType = EFSInbox; |
|
5605 } |
|
5606 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
|
5607 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
5608 /* <cmail> Sorting empty list enabled |
|
5609 // Show sort list only if maiil list is not empty |
|
5610 if ( iModel->Count() ) |
|
5611 </cmail> */ |
|
5612 { |
|
5613 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton ); |
|
5614 } |
|
5615 } |
|
5616 return; |
|
5617 case EFSEmailUiCtrlBarResponseCancel: |
|
5618 SetMskL(); |
|
5619 // <cmail> Touch |
|
5620 //Set touchmanager back to active |
|
5621 DisableMailList(EFalse); |
|
5622 // </cmail> |
|
5623 return; |
|
5624 case EFSEmailUiCtrlBarResponseSelect: |
|
5625 SetMskL(); |
|
5626 // <cmail> Touch |
|
5627 //Set touchmanager back to active |
|
5628 DisableMailList(EFalse); |
|
5629 // </cmail> |
|
5630 default: |
|
5631 break; |
|
5632 } |
|
5633 |
|
5634 if ( !iMailFolder || ( iMailFolder && iMailFolder->GetFolderId() != aSelectedFolderId ) ) |
|
5635 { |
|
5636 delete iMailFolder; |
|
5637 iMailFolder = NULL; |
|
5638 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( iAppUi.GetActiveMailboxId(), aSelectedFolderId ); |
|
5639 |
|
5640 if ( !iMailFolder ) |
|
5641 { |
|
5642 // Do nothing if can't get the folder object |
|
5643 return; |
|
5644 } |
|
5645 |
|
5646 // Set new text to folder button in control bar |
|
5647 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
|
5648 iFolderListButton->SetTextL( *newFolderName ); |
|
5649 CleanupStack::PopAndDestroy( newFolderName ); |
|
5650 |
|
5651 // Set initial sort criteria when folder has changed |
|
5652 iCurrentSortCriteria.iField = EFSMailSortByDate; |
|
5653 iCurrentSortCriteria.iOrder = EFSMailDescending; |
|
5654 // reload node state because in file sort mode this is disabled even when globally enabled |
|
5655 iNodesInUse = iAppUi.GetCRHandler()->TitleDividers(); |
|
5656 SetSortButtonTextAndIconL(); |
|
5657 |
|
5658 // Update the mail list contents |
|
5659 UpdateMailListModelL(); |
|
5660 RefreshL(); |
|
5661 } |
|
5662 iFocusedControl = EControlBarComponent; |
|
5663 SetListAndCtrlBarFocusL(); |
|
5664 iMoveToFolderOngoing = EFalse; |
|
5665 } |
|
5666 SetMskL(); |
|
5667 } |
|
5668 |
|
5669 // --------------------------------------------------------------------------- |
|
5670 // MailboxSelectedL |
|
5671 // Mailbox selection callback. Function updates list when mailbox is changed |
|
5672 // --------------------------------------------------------------------------- |
|
5673 // |
|
5674 void CFSEmailUiMailListVisualiser::MailboxSelectedL( TFSMailMsgId aSelectedMailboxId ) |
|
5675 { |
|
5676 FUNC_LOG; |
|
5677 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
5678 //Set touchmanager back to active |
|
5679 DisableMailList(EFalse); |
|
5680 iAppUi.SetActiveMailboxL( aSelectedMailboxId ); |
|
5681 delete iMailFolder; |
|
5682 iMailFolder = NULL; |
|
5683 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( iAppUi.GetActiveMailboxId(), iAppUi.GetActiveBoxInboxId() ); |
|
5684 |
|
5685 // Set initial sort criteria when folder has changed |
|
5686 iCurrentSortCriteria.iField = EFSMailSortByDate; |
|
5687 iCurrentSortCriteria.iOrder = EFSMailDescending; |
|
5688 // reload node state because in file sort mode this is disabled even when globally enabled |
|
5689 iNodesInUse = iAppUi.GetCRHandler()->TitleDividers(); |
|
5690 SetSortButtonTextAndIconL(); |
|
5691 |
|
5692 // Set folder name to the control bar button |
|
5693 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
|
5694 iFolderListButton->SetTextL( *newFolderName ); |
|
5695 CleanupStack::PopAndDestroy( newFolderName ); |
|
5696 |
|
5697 // Set mailbox name and icons |
|
5698 SetMailboxNameToStatusPaneL(); |
|
5699 SetBrandedListWatermarkL(); |
|
5700 SetBrandedMailBoxIconL(); |
|
5701 |
|
5702 // Update model |
|
5703 UpdateMailListModelL(); |
|
5704 iMailList->RemoveAllL(); |
|
5705 RefreshDeferred(); |
|
5706 |
|
5707 // Check sync icon timer and sync status |
|
5708 ConnectionIconHandling(); |
|
5709 iFocusedControl = EControlBarComponent; |
|
5710 } |
|
5711 |
|
5712 // --------------------------------------------------------------------------- |
|
5713 // FolderButtonRect |
|
5714 // Getter for folder button rectangle. Folder popup needs to get this |
|
5715 // information when screen layout changes. |
|
5716 // --------------------------------------------------------------------------- |
|
5717 // |
|
5718 TRect CFSEmailUiMailListVisualiser::FolderButtonRect() |
|
5719 { |
|
5720 FUNC_LOG; |
|
5721 const TPoint& buttonPos = iFolderListButton->Pos().Target(); |
|
5722 const TPoint& buttonSize = iFolderListButton->Size().Target(); |
|
5723 TRect buttonRect( buttonPos, buttonSize.AsSize() ); |
|
5724 return buttonRect; |
|
5725 } |
|
5726 |
|
5727 // --------------------------------------------------------------------------- |
|
5728 // SortOrderChangedL |
|
5729 // Sort order selection callback. Function updates list when sorting is changed |
|
5730 // --------------------------------------------------------------------------- |
|
5731 // |
|
5732 void CFSEmailUiMailListVisualiser::SortOrderChangedL( |
|
5733 TFSMailSortField aSortField, TFSEmailUiCtrlBarResponse aResponse ) |
|
5734 { |
|
5735 FUNC_LOG; |
|
5736 // Ignore if cancel selected |
|
5737 switch( aResponse ) |
|
5738 { |
|
5739 case EFSEmailUiCtrlBarResponseSwitchList: |
|
5740 { |
|
5741 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
5742 iControlBarControl->SetFocusByIdL( iFolderListButtonId ); |
|
5743 iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton ); |
|
5744 } |
|
5745 return; |
|
5746 case EFSEmailUiCtrlBarResponseCancel: |
|
5747 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
5748 SetMskL(); |
|
5749 // <cmail> Touch |
|
5750 //Set touchmanager back to active |
|
5751 DisableMailList(EFalse); |
|
5752 return; |
|
5753 |
|
5754 case EFSEmailUiCtrlBarResponseSelect: |
|
5755 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
5756 //Set touchmanager back to active |
|
5757 DisableMailList(EFalse); |
|
5758 // </cmail> |
|
5759 default: |
|
5760 break; |
|
5761 } |
|
5762 |
|
5763 // Check is the selected sort field same as the previous one |
|
5764 if( iCurrentSortCriteria.iField == aSortField ) |
|
5765 { |
|
5766 // If same sort field selected, switch the sorting order |
|
5767 if( iCurrentSortCriteria.iOrder == EFSMailAscending ) |
|
5768 { |
|
5769 iCurrentSortCriteria.iOrder = EFSMailDescending; |
|
5770 } |
|
5771 else |
|
5772 { |
|
5773 iCurrentSortCriteria.iOrder = EFSMailAscending; |
|
5774 } |
|
5775 } |
|
5776 else if ( aSortField == EFSMailSortBySubject || |
|
5777 aSortField == EFSMailSortBySender || |
|
5778 aSortField == EFSMailSortByUnread || // <cmail> |
|
5779 aSortField == EFSMailSortByRecipient ) |
|
5780 { |
|
5781 iCurrentSortCriteria.iOrder = EFSMailAscending; |
|
5782 } |
|
5783 else |
|
5784 { |
|
5785 iCurrentSortCriteria.iOrder = EFSMailDescending; |
|
5786 } |
|
5787 |
|
5788 iCurrentSortCriteria.iField = aSortField; |
|
5789 |
|
5790 // Size sorting does not use nodes, so disable those, otherwise check from CR |
|
5791 iNodesInUse = iAppUi.GetCRHandler()->TitleDividers(); |
|
5792 SetSortButtonTextAndIconL(); |
|
5793 |
|
5794 iFocusedControl = EControlBarComponent; |
|
5795 iMailList->SetFocusedL( EFalse ); |
|
5796 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
|
5797 |
|
5798 // <cmail> |
|
5799 if ( iMailListUpdater ) |
|
5800 { |
|
5801 // Start updating mail list with sorting parameter. |
|
5802 iMailListUpdater->StartL( ETrue ); |
|
5803 } |
|
5804 // </cmail> |
|
5805 SetMskL(); |
|
5806 } |
|
5807 |
|
5808 // --------------------------------------------------------------------------- |
|
5809 // SortButtonRect |
|
5810 // Getter for sort button rectangle. Sort popup needs to get this |
|
5811 // information when screen layout changes. |
|
5812 // --------------------------------------------------------------------------- |
|
5813 // |
|
5814 TRect CFSEmailUiMailListVisualiser::SortButtonRect() |
|
5815 { |
|
5816 FUNC_LOG; |
|
5817 const TPoint& buttonPos = iSortButton->Pos().Target(); |
|
5818 const TPoint& buttonSize = iSortButton->Size().Target(); |
|
5819 TRect buttonRect( buttonPos, buttonSize.AsSize() ); |
|
5820 return buttonRect; |
|
5821 } |
|
5822 |
|
5823 // --------------------------------------------------------------------------- |
|
5824 // OpenHighlightedMailL |
|
5825 // Function opens highlighted mail either to internal viewer or to mrui if |
|
5826 // message type is meeting |
|
5827 // --------------------------------------------------------------------------- |
|
5828 // |
|
5829 void CFSEmailUiMailListVisualiser::OpenHighlightedMailL() |
|
5830 { |
|
5831 FUNC_LOG; |
|
5832 OpenMailItemL( iMailList->FocusedItem() ); |
|
5833 } |
|
5834 |
|
5835 // --------------------------------------------------------------------------- |
|
5836 // OpenHighlightedMailL |
|
5837 // Function opens given mail item either to internal viewer or to mrui if |
|
5838 // message type is meeting |
|
5839 // --------------------------------------------------------------------------- |
|
5840 // |
|
5841 void CFSEmailUiMailListVisualiser::OpenMailItemL( TFsTreeItemId aMailItem ) |
|
5842 { |
|
5843 FUNC_LOG; |
|
5844 TInt idx = ModelIndexFromListId( aMailItem ); |
|
5845 if ( idx >= 0 ) |
|
5846 { |
|
5847 CFSEmailUiMailListModelItem* item = |
|
5848 static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(idx) ); |
|
5849 if ( item->ModelItemType() == ETypeMailItem ) |
|
5850 { |
|
5851 // First make sure that the highlighted message really exists in the store |
|
5852 // Get confirmed msg ptr |
|
5853 CFSMailMessage* confirmedMsgPtr(0); |
|
5854 confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), |
|
5855 iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope ); |
|
5856 if ( confirmedMsgPtr ) |
|
5857 { |
|
5858 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
5859 // Pointer confirmed, store Id and delete not needed anymore |
|
5860 TFSMailMsgId confirmedId = confirmedMsgPtr->GetMessageId(); |
|
5861 TBool isCalMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_CalendarMsg ); |
|
5862 TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read ); |
|
5863 delete confirmedMsgPtr; |
|
5864 // Open to editor from drafts |
|
5865 if ( iMailFolder->GetFolderType() == EFSDraftsFolder ) |
|
5866 { |
|
5867 if ( !isCalMessage ) // Open only normal messages for now |
|
5868 { |
|
5869 TEditorLaunchParams params; |
|
5870 params.iMailboxId = iAppUi.GetActiveMailboxId(); |
|
5871 params.iActivatedExternally = EFalse; |
|
5872 params.iMsgId = confirmedId; |
|
5873 params.iFolderId = iMailFolder->GetFolderId(); |
|
5874 iAppUi.LaunchEditorL( KEditorCmdOpen, params ); |
|
5875 } |
|
5876 else |
|
5877 { |
|
5878 //Try to open to editor if support for that is needed |
|
5879 } |
|
5880 } |
|
5881 else if ( iMailFolder->GetFolderType() == EFSOutbox ) |
|
5882 { |
|
5883 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_OPEN_FROM_OUTBOX_NOTE, ETrue ); |
|
5884 } |
|
5885 else |
|
5886 { |
|
5887 THtmlViewerActivationData htmlData; |
|
5888 htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage; |
|
5889 htmlData.iMailBoxId = iAppUi.GetActiveMailbox()->GetId(); |
|
5890 htmlData.iFolderId = FolderId(); |
|
5891 htmlData.iMessageId = confirmedId; |
|
5892 TPckgBuf<THtmlViewerActivationData> pckgData( htmlData ); |
|
5893 |
|
5894 // Change read status only if needed |
|
5895 if ( !isReadMessage ) |
|
5896 { |
|
5897 ChangeReadStatusOfHighlightedL( ETrue ); |
|
5898 } |
|
5899 |
|
5900 // Opening viewer seems to take more time than other views, |
|
5901 // so we do longer fade out in this case |
|
5902 SetNextTransitionOutLong( ETrue ); |
|
5903 |
|
5904 iAppUi.EnterFsEmailViewL( HtmlViewerId, KHtmlViewerOpenNew, pckgData ); |
|
5905 } |
|
5906 } |
|
5907 } |
|
5908 } |
|
5909 } |
|
5910 |
|
5911 // --------------------------------------------------------------------------- |
|
5912 // From MFSEmailUiContactHandlerObserver |
|
5913 // The ownership of the CLS items in the contacts array is transferred to the |
|
5914 // observer, and they must be deleted by the observer. |
|
5915 // --------------------------------------------------------------------------- |
|
5916 // |
|
5917 void CFSEmailUiMailListVisualiser::OperationCompleteL( |
|
5918 TContactHandlerCmd /*aCmd*/, const RPointerArray<CFSEmailUiClsItem>& /*aContacts*/ ) |
|
5919 { |
|
5920 FUNC_LOG; |
|
5921 } |
|
5922 |
|
5923 // --------------------------------------------------------------------------- |
|
5924 // From MFSEmailUiContactHandlerObserver |
|
5925 // Handles error in contact handler operation. |
|
5926 // --------------------------------------------------------------------------- |
|
5927 // |
|
5928 void CFSEmailUiMailListVisualiser::OperationErrorL( TContactHandlerCmd /*aCmd*/, |
|
5929 TInt /*aError*/ ) |
|
5930 { |
|
5931 FUNC_LOG; |
|
5932 } |
|
5933 |
|
5934 // --------------------------------------------------------------------------- |
|
5935 // NotifyDateChangedL |
|
5936 // Called when CDateChangeTimer completes. This happens when either when date |
|
5937 // changes or when user alters the system time. Redraws the list to ensure |
|
5938 // that time stamp texts in emails and nodes are up-to-date. |
|
5939 // --------------------------------------------------------------------------- |
|
5940 // |
|
5941 void CFSEmailUiMailListVisualiser::NotifyDateChangedL() |
|
5942 { |
|
5943 FUNC_LOG; |
|
5944 iDateChanged = ETrue; |
|
5945 if ( iAppUi.IsForeground() ) |
|
5946 { |
|
5947 HandleForegroundEventL(); |
|
5948 } |
|
5949 } |
|
5950 |
|
5951 // --------------------------------------------------------------------------- |
|
5952 // CreateFolderNameLC |
|
5953 // Creates folder name from folder ptr. Localised if standard folder. |
|
5954 // --------------------------------------------------------------------------- |
|
5955 // |
|
5956 HBufC* CFSEmailUiMailListVisualiser::CreateFolderNameLC( const CFSMailFolder* aFolder ) const |
|
5957 { |
|
5958 FUNC_LOG; |
|
5959 TInt resourceId(0); |
|
5960 HBufC* ret(0); |
|
5961 if ( !aFolder || aFolder->GetFolderId().IsNullId() ) |
|
5962 { |
|
5963 // INBOX FOR NULL ID |
|
5964 resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX; |
|
5965 } |
|
5966 else |
|
5967 { |
|
5968 TInt folderType = aFolder->GetFolderType(); |
|
5969 switch ( folderType ) |
|
5970 { |
|
5971 case EFSInbox: |
|
5972 { |
|
5973 resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX; |
|
5974 } |
|
5975 break; |
|
5976 case EFSOutbox: |
|
5977 { |
|
5978 resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_OUTBOX; |
|
5979 } |
|
5980 break; |
|
5981 case EFSDraftsFolder: |
|
5982 { |
|
5983 resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DRAFTS; |
|
5984 } |
|
5985 break; |
|
5986 case EFSSentFolder: |
|
5987 { |
|
5988 resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_SENT; |
|
5989 } |
|
5990 break; |
|
5991 case EFSDeleted: |
|
5992 { |
|
5993 resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DELETED; |
|
5994 } |
|
5995 break; |
|
5996 default: |
|
5997 // Not a standard folder |
|
5998 break; |
|
5999 } |
|
6000 } |
|
6001 if ( resourceId ) |
|
6002 { |
|
6003 ret = StringLoader::LoadLC( resourceId ); |
|
6004 } |
|
6005 else |
|
6006 { |
|
6007 ret = aFolder->GetFolderName().AllocLC(); |
|
6008 } |
|
6009 return ret; |
|
6010 } |
|
6011 |
|
6012 // --------------------------------------------------------------------------- |
|
6013 // LaunchActionMenuL |
|
6014 // Function launches action menu based on the highlighted or marked messages |
|
6015 // --------------------------------------------------------------------------- |
|
6016 // |
|
6017 void CFSEmailUiMailListVisualiser::LaunchActionMenuL() |
|
6018 { |
|
6019 FUNC_LOG; |
|
6020 // Get marked entries |
|
6021 RFsTreeItemIdList markedEntries; |
|
6022 CleanupClosePushL( markedEntries ); |
|
6023 iMailList->GetMarkedItemsL( markedEntries ); |
|
6024 TInt markedCount = markedEntries.Count(); |
|
6025 |
|
6026 // Remove old items from action menu |
|
6027 CFSEmailUiActionMenu::RemoveAllL(); |
|
6028 // Construct item list |
|
6029 RFsEActionMenuIdList itemList; |
|
6030 CleanupClosePushL( itemList ); |
|
6031 // Check support for object mail iten moving |
|
6032 TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ); |
|
6033 |
|
6034 if ( markedCount == 0 || markedCount == 1 ) // Action menu for a single item |
|
6035 { |
|
6036 // Get pointer to the single message we are dealing with |
|
6037 TFsTreeItemId listItemId; |
|
6038 if ( markedCount == 0 ) |
|
6039 { |
|
6040 listItemId = iMailList->FocusedItem(); |
|
6041 } |
|
6042 else // ( markedCount == 1) |
|
6043 { |
|
6044 listItemId = markedEntries[0]; |
|
6045 } |
|
6046 CFSMailMessage* msgPtr = &MsgPtrFromListIdL( listItemId ); |
|
6047 |
|
6048 if ( iMailFolder->GetFolderType() == EFSOutbox ) |
|
6049 { |
|
6050 if ( supportsMoving ) |
|
6051 { |
|
6052 itemList.AppendL( FsEActionMenuMoveToDrafts ); |
|
6053 } |
|
6054 } |
|
6055 else if( iMailFolder->GetFolderType() == EFSDraftsFolder ) |
|
6056 { |
|
6057 // Create mark unread / mark read flag |
|
6058 if ( msgPtr->IsFlagSet( EFSMsgFlag_Read ) ) |
|
6059 { |
|
6060 itemList.AppendL( FsEActionMenuMarkUnread ); |
|
6061 } |
|
6062 else |
|
6063 { |
|
6064 itemList.AppendL( FsEActionMenuMarkRead ); |
|
6065 } |
|
6066 // Add Move message item if applicable |
|
6067 if ( supportsMoving ) |
|
6068 { |
|
6069 itemList.AppendL( FsEActionMenuMove ); |
|
6070 } |
|
6071 } |
|
6072 else |
|
6073 { |
|
6074 // Construct menu for calendar message based on resolved mr object |
|
6075 // and whether the MRUI object is available |
|
6076 if ( msgPtr->IsFlagSet( EFSMsgFlag_CalendarMsg ) && iAppUi.MrViewerInstanceL() ) |
|
6077 { |
|
6078 TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown ); |
|
6079 TRAP_IGNORE( mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *msgPtr ) ); |
|
6080 switch ( mrMethod ) |
|
6081 { |
|
6082 case EESMRMeetingRequestMethodRequest: |
|
6083 { |
|
6084 if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox && |
|
6085 iMailFolder->GetFolderType() != EFSDraftsFolder ) |
|
6086 { |
|
6087 // No choices in outbox in outbox or drafts |
|
6088 itemList.AppendL( FsEActionMenuAccept ); |
|
6089 itemList.AppendL( FsEActionMenuTentative ); |
|
6090 itemList.AppendL( FsEActionMenuDecline ); |
|
6091 } |
|
6092 } |
|
6093 break; |
|
6094 case EESMRMeetingRequestMethodCancellation: |
|
6095 { |
|
6096 // No "remove from calendar" in outbox or drafts |
|
6097 if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox && |
|
6098 iMailFolder->GetFolderType() != EFSDraftsFolder ) |
|
6099 { |
|
6100 TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar ); |
|
6101 if( supportsRemove ) |
|
6102 { |
|
6103 itemList.AppendL( FsEActionMenuRemoveFormCal ); |
|
6104 } |
|
6105 } |
|
6106 } |
|
6107 break; |
|
6108 case EESMRMeetingRequestMethodUnknown: |
|
6109 case EESMRMeetingRequestMethodResponse: |
|
6110 default: |
|
6111 { |
|
6112 // Only "Open" options is available for responses and when MR method |
|
6113 // cannot be resolved without opening the message (this is the case with IMAP) |
|
6114 itemList.AppendL( FsEActionMenuOpenCalendarEvent ); |
|
6115 } |
|
6116 break; |
|
6117 } |
|
6118 } |
|
6119 // No mrui object or message is typical mail |
|
6120 // Append normal menu commands |
|
6121 else |
|
6122 { |
|
6123 itemList.AppendL( FsEActionMenuReply ); |
|
6124 // Show ReplyAll if more than 1 recepient |
|
6125 TInt numRecipients(0); |
|
6126 if ( msgPtr ) |
|
6127 { |
|
6128 //Get # of recipients |
|
6129 numRecipients =TFsEmailUiUtility::CountRecepients( msgPtr ); |
|
6130 if ( numRecipients == 1 ) |
|
6131 { |
|
6132 //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the |
|
6133 //email is a distribution list and we need to inc num of Recipients so that "Reply ALL" option appears in UI. |
|
6134 if ( msgPtr->GetToRecipients().Count() ) |
|
6135 { |
|
6136 if( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetToRecipients()[0]->GetEmailAddress()) ) |
|
6137 { |
|
6138 numRecipients++; |
|
6139 } |
|
6140 } |
|
6141 if ( msgPtr->GetCCRecipients().Count() ) |
|
6142 { |
|
6143 if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetCCRecipients()[0]->GetEmailAddress()) ) |
|
6144 { |
|
6145 numRecipients++; |
|
6146 } |
|
6147 } |
|
6148 if( msgPtr->GetBCCRecipients().Count() ) |
|
6149 { |
|
6150 if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetBCCRecipients()[0]->GetEmailAddress()) ) |
|
6151 { |
|
6152 numRecipients++; |
|
6153 } |
|
6154 } |
|
6155 } |
|
6156 } |
|
6157 |
|
6158 if ( numRecipients > 1 ) |
|
6159 { |
|
6160 itemList.AppendL( FsEActionMenuReplyAll ); |
|
6161 } |
|
6162 itemList.AppendL( FsEActionMenuForward ); |
|
6163 } |
|
6164 |
|
6165 // Add mark as read/unread options |
|
6166 if ( IsMarkAsUnreadAvailableL() ) |
|
6167 { |
|
6168 itemList.AppendL( FsEActionMenuMarkUnread ); |
|
6169 } |
|
6170 if ( IsMarkAsReadAvailableL() ) |
|
6171 { |
|
6172 itemList.AppendL( FsEActionMenuMarkRead ); |
|
6173 } |
|
6174 |
|
6175 // Add Move message item if applicable |
|
6176 if ( supportsMoving ) |
|
6177 { |
|
6178 itemList.AppendL( FsEActionMenuMove ); |
|
6179 } |
|
6180 } |
|
6181 itemList.AppendL( FsEActionMenuDelete ); |
|
6182 |
|
6183 // Execute action list and handle the menu command |
|
6184 TFSMailMsgId oldMsgId = msgPtr->GetMessageId(); |
|
6185 |
|
6186 // <cmail> Touch |
|
6187 TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList, EFscCustom, 0, this ); |
|
6188 // </cmail> |
|
6189 |
|
6190 // Make sure that focus or marking is still on the same item as when Action menu was launched. |
|
6191 // This is beacause message added/deleted event migh have occured and deleted the original meessage or |
|
6192 // resulted in complete redraw of the message list. |
|
6193 TInt newItemIdx = ItemIndexFromMessageId( oldMsgId ); |
|
6194 if ( newItemIdx >= 0 ) // items still exists |
|
6195 { |
|
6196 TFsTreeItemId newItemListId = iTreeItemArray[ newItemIdx ].iListItemId; |
|
6197 if ( markedCount ) |
|
6198 { |
|
6199 // Item was marked. Make sure it's marked now. |
|
6200 iMailList->MarkItemL( newItemListId, ETrue ); |
|
6201 } |
|
6202 else |
|
6203 { |
|
6204 // No items were marked. Make sure the focus is on the same item as before. |
|
6205 if ( iMailList->FocusedItem() != newItemListId ) |
|
6206 { |
|
6207 iMailList->SetFocusedItemL( newItemListId ); |
|
6208 } |
|
6209 } |
|
6210 HandleActionMenuCommandL( itemId ); |
|
6211 } |
|
6212 } |
|
6213 else // Multiple items marked |
|
6214 { |
|
6215 // Add mark as read/unread options |
|
6216 if ( IsMarkAsUnreadAvailableL() ) |
|
6217 { |
|
6218 itemList.AppendL( FsEActionMenuMarkUnread ); |
|
6219 } |
|
6220 if ( IsMarkAsReadAvailableL() ) |
|
6221 { |
|
6222 itemList.AppendL( FsEActionMenuMarkRead ); |
|
6223 } |
|
6224 |
|
6225 if ( iMailFolder->GetFolderType() == EFSOutbox ) // Append move to drafts in outbox |
|
6226 { |
|
6227 if ( supportsMoving ) |
|
6228 { |
|
6229 itemList.AppendL( FsEActionMenuMoveToDrafts ); |
|
6230 } |
|
6231 } |
|
6232 else // Append move in any other cases dirtectly if supported |
|
6233 { |
|
6234 if ( supportsMoving ) |
|
6235 { |
|
6236 itemList.AppendL( FsEActionMenuMove ); |
|
6237 } |
|
6238 } |
|
6239 itemList.AppendL( FsEActionMenuDelete ); |
|
6240 TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList ); |
|
6241 iMailList->GetMarkedItemsL( markedEntries ); |
|
6242 if ( markedEntries.Count() ) // Safety check |
|
6243 { |
|
6244 HandleActionMenuCommandL( itemId ); |
|
6245 } |
|
6246 } |
|
6247 CleanupStack::PopAndDestroy( &itemList ); |
|
6248 CleanupStack::PopAndDestroy( &markedEntries ); |
|
6249 } |
|
6250 |
|
6251 // --------------------------------------------------------------------------- |
|
6252 // HandleActionMenuCommandL |
|
6253 // Action menu command callback handler |
|
6254 // --------------------------------------------------------------------------- |
|
6255 // |
|
6256 void CFSEmailUiMailListVisualiser::HandleActionMenuCommandL( TActionMenuCustomItemId itemId ) |
|
6257 { |
|
6258 FUNC_LOG; |
|
6259 // Map each Action Menu ID to correcponding command ID. |
|
6260 TInt commandId = KErrNotFound; |
|
6261 |
|
6262 switch( itemId ) |
|
6263 { |
|
6264 case FsEActionMenuOpenCalendarEvent: |
|
6265 case FsEActionMenuOpen: |
|
6266 commandId = EFsEmailUiCmdOpen; |
|
6267 break; |
|
6268 case FsEActionMenuAccept: |
|
6269 commandId = EFsEmailUiCmdCalActionsAccept; |
|
6270 break; |
|
6271 case FsEActionMenuTentative: |
|
6272 commandId = EFsEmailUiCmdCalActionsTentative; |
|
6273 break; |
|
6274 case FsEActionMenuDecline: |
|
6275 commandId = EFsEmailUiCmdCalActionsDecline; |
|
6276 break; |
|
6277 case FsEActionMenuRemoveFormCal: |
|
6278 commandId = EFsEmailUiCmdCalRemoveFromCalendar; |
|
6279 break; |
|
6280 case FsEActionMenuMarkRead: |
|
6281 commandId = EFsEmailUiCmdMarkAsRead; |
|
6282 break; |
|
6283 case FsEActionMenuMarkUnread: |
|
6284 commandId = EFsEmailUiCmdMarkAsUnread; |
|
6285 break; |
|
6286 case FsEActionMenuDelete: |
|
6287 commandId = EFsEmailUiCmdActionsDelete; |
|
6288 break; |
|
6289 case FsEActionMenuReply: |
|
6290 commandId = EFsEmailUiCmdActionsReply; |
|
6291 break; |
|
6292 case FsEActionMenuReplyAll: |
|
6293 commandId = EFsEmailUiCmdActionsReplyAll; |
|
6294 break; |
|
6295 case FsEActionMenuForward: |
|
6296 commandId = EFsEmailUiCmdActionsForward; |
|
6297 break; |
|
6298 case FsEActionMenuMove: |
|
6299 commandId = EFsEmailUiCmdActionsMoveMessage; |
|
6300 break; |
|
6301 case FsEActionMenuMoveToDrafts: |
|
6302 commandId = EFsEmailUiCmdActionsMoveToDrafts; |
|
6303 break; |
|
6304 case FsEActionMenuDismissed: |
|
6305 commandId = KErrCancel; |
|
6306 break; |
|
6307 default: |
|
6308 __ASSERT_DEBUG( EFalse, Panic(EFSEmailUiUnexpectedValue) ); |
|
6309 break; |
|
6310 } |
|
6311 |
|
6312 if ( commandId >= 0 ) |
|
6313 { |
|
6314 HandleCommandL( commandId ); |
|
6315 } |
|
6316 } |
|
6317 |
|
6318 // --------------------------------------------------------------------------- |
|
6319 // LaunchStylusPopupMenuL |
|
6320 // Function launches avkon stylus popup menu based on the selected message item/items |
|
6321 // --------------------------------------------------------------------------- |
|
6322 // |
|
6323 void CFSEmailUiMailListVisualiser::LaunchStylusPopupMenuL() |
|
6324 { |
|
6325 // Irrelevant items for focused mail list item get dimmed at runtime |
|
6326 |
|
6327 // Check mail list item's type |
|
6328 CFSEmailUiMailListModelItem* item = |
|
6329 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
6330 if ( item && item->ModelItemType() == ETypeMailItem ) |
|
6331 { |
|
6332 // Add mark as read / unread options |
|
6333 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() ); |
|
6334 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() ); |
|
6335 |
|
6336 // Check support for object mail iten moving |
|
6337 TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ); |
|
6338 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, !supportsMoving ); |
|
6339 |
|
6340 // Hide / show follow up |
|
6341 TBool supportsFlag = TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ); |
|
6342 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsFlag, !supportsFlag ); |
|
6343 |
|
6344 // Hide mark if applicable |
|
6345 if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) |
|
6346 { |
|
6347 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMark, ETrue ); |
|
6348 } |
|
6349 |
|
6350 // Hide collapse / expand all |
|
6351 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, ETrue ); |
|
6352 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, ETrue ); |
|
6353 } |
|
6354 else if ( item->ModelItemType() == ETypeSeparator ) |
|
6355 { |
|
6356 // Hide mark as read / unread options |
|
6357 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue ); |
|
6358 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue ); |
|
6359 |
|
6360 // Hide move & follow up |
|
6361 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue ); |
|
6362 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue ); |
|
6363 |
|
6364 // Hide collapse / expand all when applicable |
|
6365 if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() ) |
|
6366 { |
|
6367 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, ETrue ); |
|
6368 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, ETrue ); |
|
6369 } |
|
6370 else |
|
6371 { |
|
6372 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() ); |
|
6373 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() ); |
|
6374 } |
|
6375 } |
|
6376 |
|
6377 // Set the position for the popup |
|
6378 iStylusPopUpMenu->SetPosition( ActionMenuPosition() ); |
|
6379 |
|
6380 // Display the popup |
|
6381 iStylusPopUpMenu->ShowMenu(); |
|
6382 } |
|
6383 |
|
6384 // --------------------------------------------------------------------------- |
|
6385 // CreateNewMsgL |
|
6386 // Launches editor. |
|
6387 // --------------------------------------------------------------------------- |
|
6388 // |
|
6389 void CFSEmailUiMailListVisualiser::CreateNewMsgL() |
|
6390 { |
|
6391 FUNC_LOG; |
|
6392 TEditorLaunchParams params; |
|
6393 params.iMailboxId = iAppUi.GetActiveMailboxId(); |
|
6394 params.iActivatedExternally = EFalse; |
|
6395 iAppUi.LaunchEditorL( KEditorCmdCreateNew, params ); |
|
6396 } |
|
6397 |
|
6398 void CFSEmailUiMailListVisualiser::ReplyL( CFSMailMessage* aMsgPtr ) |
|
6399 { |
|
6400 FUNC_LOG; |
|
6401 DoReplyForwardL( KEditorCmdReply, aMsgPtr ); |
|
6402 } |
|
6403 |
|
6404 void CFSEmailUiMailListVisualiser::ReplyAllL( CFSMailMessage* aMsgPtr ) |
|
6405 { |
|
6406 FUNC_LOG; |
|
6407 DoReplyForwardL( KEditorCmdReplyAll, aMsgPtr ); |
|
6408 } |
|
6409 |
|
6410 void CFSEmailUiMailListVisualiser::ForwardL( CFSMailMessage* aMsgPtr ) |
|
6411 { |
|
6412 FUNC_LOG; |
|
6413 DoReplyForwardL( KEditorCmdForward, aMsgPtr ); |
|
6414 } |
|
6415 |
|
6416 // --------------------------------------------------------------------------- |
|
6417 // DoReplyForwardL |
|
6418 // Launches editor with either reply all forward command |
|
6419 // --------------------------------------------------------------------------- |
|
6420 // |
|
6421 void CFSEmailUiMailListVisualiser::DoReplyForwardL( TEditorLaunchMode aMode, CFSMailMessage* aMsgPtr ) |
|
6422 { |
|
6423 FUNC_LOG; |
|
6424 // Reply, reply all, and forward commands are inavailable in the outbox |
|
6425 // <cmail> |
|
6426 if ( iModel->Count() && iMailFolder && iMailFolder->GetFolderType() != EFSOutbox ) |
|
6427 // </cmail> |
|
6428 { |
|
6429 CFSMailMessage* messagePointer = aMsgPtr; |
|
6430 if ( !messagePointer ) |
|
6431 { |
|
6432 RFsTreeItemIdList targetEntries; |
|
6433 CleanupClosePushL( targetEntries ); |
|
6434 GetActionsTargetEntriesL( targetEntries ); |
|
6435 // action is possible only when there's exactly one marked or focused mail item |
|
6436 if ( targetEntries.Count() == 1 ) |
|
6437 { |
|
6438 messagePointer = &MsgPtrFromListIdL( targetEntries[0] ); |
|
6439 } |
|
6440 CleanupStack::PopAndDestroy( &targetEntries ); |
|
6441 } |
|
6442 if ( messagePointer ) |
|
6443 { |
|
6444 // Opening editor is slower than opening most other views. |
|
6445 // Use longer transition effect to mask this. |
|
6446 SetNextTransitionOutLong( ETrue ); |
|
6447 |
|
6448 TEditorLaunchParams params; |
|
6449 params.iMailboxId = iAppUi.GetActiveMailboxId(); |
|
6450 params.iActivatedExternally = EFalse; |
|
6451 params.iMsgId = messagePointer->GetMessageId(); |
|
6452 iAppUi.LaunchEditorL( aMode, params ); |
|
6453 } |
|
6454 } |
|
6455 } |
|
6456 |
|
6457 // --------------------------------------------------------------------------- |
|
6458 // HandleMailBoxEventL |
|
6459 // Mailbox event handler, responds to events sent by the plugin. |
|
6460 // --------------------------------------------------------------------------- |
|
6461 // |
|
6462 void CFSEmailUiMailListVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent, |
|
6463 TFSMailMsgId aMailboxId, TAny* aParam1, TAny* aParam2, TAny* aParam3 ) |
|
6464 { |
|
6465 FUNC_LOG; |
|
6466 |
|
6467 // Complete any pending asynchronous redrawing before handling the event |
|
6468 // to make sure that all the arrays are in consistent state |
|
6469 CompletePendingRefresh(); |
|
6470 |
|
6471 // Handle the event |
|
6472 if ( iFirstStartCompleted && |
|
6473 aMailboxId == iAppUi.GetActiveMailboxId() ) // Safety, in list events that only concern active mailbox are handled |
|
6474 { |
|
6475 if ( aEvent == TFSEventFoldersDeleted ) |
|
6476 { |
|
6477 // Check whether the current folder gets deleted |
|
6478 // Change mail item icon or read status |
|
6479 RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>( aParam1 ); |
|
6480 if ( iMailFolder && removedEntries && removedEntries->Count() ) |
|
6481 { |
|
6482 TFSMailMsgId currentFolderId = iMailFolder->GetFolderId(); |
|
6483 for ( TInt i = 0; i < removedEntries->Count(); i++ ) |
|
6484 { |
|
6485 TFSMailMsgId entryId = (*removedEntries)[i]; |
|
6486 if ( entryId == currentFolderId ) |
|
6487 { |
|
6488 // Current folder deleted, try to revert back to standard folder inbox. |
|
6489 delete iMailFolder; |
|
6490 iMailFolder = NULL; |
|
6491 TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox ); |
|
6492 if ( !inboxId.IsNullId() ) |
|
6493 { |
|
6494 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, inboxId ); |
|
6495 UpdateMailListModelL(); |
|
6496 RefreshL(); |
|
6497 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
|
6498 iFolderListButton->SetTextL( *newFolderName ); |
|
6499 CleanupStack::PopAndDestroy( newFolderName ); |
|
6500 } |
|
6501 else |
|
6502 { |
|
6503 // No standard folder inbox, go back to grid as a last option |
|
6504 HandleCommandL( EAknSoftkeyBack ); |
|
6505 } |
|
6506 break; |
|
6507 } |
|
6508 } |
|
6509 } |
|
6510 } |
|
6511 else if ( aEvent == TFSEventMailboxRenamed ) |
|
6512 { |
|
6513 if ( iThisViewActive ) |
|
6514 { |
|
6515 SetMailboxNameToStatusPaneL(); |
|
6516 } |
|
6517 } |
|
6518 else if ( aEvent == TFSEventMailDeleted && iMailFolder ) // <cmail> Added iMailFolder null safety check </cmail> |
|
6519 { |
|
6520 // Change mail item icon or read status |
|
6521 RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>(aParam1); |
|
6522 if ( removedEntries && removedEntries->Count() ) |
|
6523 { |
|
6524 TFSMailMsgId* parentFolderId = static_cast<TFSMailMsgId*>( aParam2 ); |
|
6525 TFSMailMsgId currentFolderId = iMailFolder->GetFolderId(); |
|
6526 if ( parentFolderId && ( *parentFolderId == currentFolderId ) ) |
|
6527 { |
|
6528 // Refresh mailfolder to get correct actual data |
|
6529 delete iMailFolder; |
|
6530 iMailFolder = NULL; |
|
6531 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, currentFolderId ); |
|
6532 RemoveMsgItemsFromListIfFoundL( *removedEntries ); |
|
6533 } |
|
6534 } |
|
6535 } |
|
6536 else if ( aEvent == TFSEventNewMail ) |
|
6537 { |
|
6538 // Switch to standardfolder inbox if we have null folderid. |
|
6539 // This is usually the case with first time sync. |
|
6540 if ( FolderId().IsNullId() ) |
|
6541 { |
|
6542 // Refresh mailfolder to standard folder inbox in case of zero id |
|
6543 delete iMailFolder; |
|
6544 iMailFolder = NULL; |
|
6545 TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox ); |
|
6546 if ( !inboxId.IsNullId() ) |
|
6547 { |
|
6548 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, inboxId ); |
|
6549 // Check that mailfolder fetching succeeded |
|
6550 if ( iMailFolder ) |
|
6551 { |
|
6552 HBufC* newFolderName = CreateFolderNameLC( iMailFolder ); |
|
6553 iFolderListButton->SetTextL( *newFolderName ); |
|
6554 CleanupStack::PopAndDestroy( newFolderName ); |
|
6555 } |
|
6556 } |
|
6557 } |
|
6558 // Null pointer check is needed here because of special cases such as new mail |
|
6559 // creation in POP/IMAP before first sync where folder does not exists |
|
6560 if ( iMailFolder ) |
|
6561 { |
|
6562 RArray<TFSMailMsgId>* newMessages = static_cast< RArray<TFSMailMsgId>* >( aParam1 ); |
|
6563 TFSMailMsgId* parentFolderId = static_cast<TFSMailMsgId*>( aParam2 ); |
|
6564 TFSMailMsgId currentFolderId = iMailFolder->GetFolderId(); |
|
6565 // Update the mail list only if the event is related to the currently open folder |
|
6566 if ( *parentFolderId == currentFolderId ) |
|
6567 { |
|
6568 InsertNewMessagesL( *newMessages ); |
|
6569 } |
|
6570 } |
|
6571 } |
|
6572 else if ( aEvent == TFSEventMailMoved && iMailFolder ) // Added iMailFolder null safety check |
|
6573 { |
|
6574 // If message was moved FROM this folder, just remove the entry from the list. |
|
6575 // If message is moved TO this folder, update the list completely. |
|
6576 // Otherwise, the event does not have an influence on the current folder. |
|
6577 RArray<TFSMailMsgId>* entries = static_cast< RArray<TFSMailMsgId>* >( aParam1 ); |
|
6578 TFSMailMsgId* toFolderId = static_cast<TFSMailMsgId*>( aParam2 ); |
|
6579 TFSMailMsgId* fromFolderId = static_cast<TFSMailMsgId*>( aParam3 ); |
|
6580 TFSMailMsgId currentFolderId = iMailFolder->GetFolderId(); |
|
6581 |
|
6582 if ( toFolderId && ( currentFolderId == *toFolderId ) ) |
|
6583 { |
|
6584 InsertNewMessagesL( *entries ); |
|
6585 } |
|
6586 else if ( fromFolderId && ( currentFolderId == *fromFolderId ) ) |
|
6587 { |
|
6588 // Refresh mailfolder to get correct actual data |
|
6589 delete iMailFolder; |
|
6590 iMailFolder = NULL; |
|
6591 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, currentFolderId ); |
|
6592 RemoveMsgItemsFromListIfFoundL( *entries ); |
|
6593 } |
|
6594 else |
|
6595 { |
|
6596 // event is not related to the current folder => do nothing |
|
6597 } |
|
6598 } |
|
6599 else if ( aEvent == TFSEventMailChanged && iMailFolder ) // Added iMailFolder null safety check |
|
6600 { |
|
6601 // Change mail item icon or read status |
|
6602 RArray<TFSMailMsgId>* entries = static_cast<RArray<TFSMailMsgId>*>( aParam1 ); |
|
6603 TFSMailMsgId* parentFolderId = static_cast<TFSMailMsgId*>( aParam2 ); |
|
6604 TFSMailMsgId currentFolderId = iMailFolder->GetFolderId(); |
|
6605 if ( *parentFolderId == currentFolderId ) |
|
6606 { |
|
6607 // Refresh mailfolder to get correct actual data |
|
6608 delete iMailFolder; |
|
6609 iMailFolder = NULL; |
|
6610 iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, currentFolderId ); |
|
6611 for ( TInt i=0 ; i<entries->Count() ; i++ ) |
|
6612 { |
|
6613 TFSMailMsgId msgId = (*entries)[i]; |
|
6614 TInt idx = ItemIndexFromMessageId( msgId ); |
|
6615 if ( idx >= 0 ) |
|
6616 { |
|
6617 UpdateItemAtIndexL( idx ); |
|
6618 } |
|
6619 } |
|
6620 } |
|
6621 } |
|
6622 else if ( aEvent == TFSEventMailboxSyncStateChanged ) |
|
6623 { |
|
6624 TSSMailSyncState* newSyncState = static_cast<TSSMailSyncState*>( aParam1 ); |
|
6625 if ( newSyncState != 0 && *newSyncState != 0 ) |
|
6626 { |
|
6627 switch ( *newSyncState ) |
|
6628 { |
|
6629 case StartingSync: |
|
6630 { |
|
6631 //If sync was started by user, show the synchronisation indicator |
|
6632 if ( iManualMailBoxSync ) |
|
6633 { |
|
6634 CFSMailBox* mb = iAppUi.GetActiveMailbox(); |
|
6635 TDesC* mbName = &mb->GetName(); |
|
6636 ManualMailBoxSync(EFalse); |
|
6637 } |
|
6638 } |
|
6639 break; |
|
6640 } |
|
6641 } |
|
6642 } |
|
6643 } |
|
6644 } |
|
6645 |
|
6646 void CFSEmailUiMailListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId ) |
|
6647 { |
|
6648 FUNC_LOG; |
|
6649 if ( aEvent == MFsTreeListObserver::EFsTreeListItemWillGetFocused && aId != KFsTreeNoneID ) |
|
6650 {//EFalse - do not call UpdateItem directly, new text will be drawn when item gets focus |
|
6651 UpdatePreviewPaneTextIfNecessaryL( aId, EFalse ); |
|
6652 } |
|
6653 else if ( aEvent == MFsTreeListObserver::EFsTreeListItemTouchFocused ) |
|
6654 { |
|
6655 |
|
6656 } |
|
6657 } |
|
6658 |
|
6659 // --------------------------------------------------------------------------- |
|
6660 // UpdateMailListSettingsL |
|
6661 // Function reads and updates mail list specific settings from the cen rep |
|
6662 // --------------------------------------------------------------------------- |
|
6663 // |
|
6664 void CFSEmailUiMailListVisualiser::UpdateMailListSettingsL() |
|
6665 { |
|
6666 FUNC_LOG; |
|
6667 if ( iAppUi.GetCRHandler() ) |
|
6668 { |
|
6669 iNodesInUse = iAppUi.GetCRHandler()->TitleDividers(); |
|
6670 TInt lineValue = iAppUi.GetCRHandler()->MessageListLayout(); |
|
6671 TInt bodyPreviewValue = iAppUi.GetCRHandler()->BodyPreview(); |
|
6672 if ( lineValue == 1 ) // 1-line layouts |
|
6673 { |
|
6674 if ( bodyPreviewValue == 0 ) |
|
6675 { |
|
6676 iListMode = EListControlTypeSingleLinePreviewOff; |
|
6677 } |
|
6678 else |
|
6679 { |
|
6680 iListMode = EListControlTypeSingleLinePreviewOn; |
|
6681 } |
|
6682 } |
|
6683 else // |
|
6684 { |
|
6685 if ( bodyPreviewValue == 0 ) |
|
6686 { |
|
6687 iListMode = EListControlTypeDoubleLinePreviewOff; |
|
6688 } |
|
6689 else |
|
6690 { |
|
6691 iListMode = EListControlTypeDoubleLinePreviewOn; |
|
6692 } |
|
6693 } |
|
6694 } |
|
6695 else |
|
6696 { |
|
6697 iNodesInUse = EListControlSeparatorDisabled; |
|
6698 iListMode = EListControlTypeDoubleLinePreviewOff; |
|
6699 } |
|
6700 } |
|
6701 |
|
6702 void CFSEmailUiMailListVisualiser::UpdateMailListTimeDateSettings() |
|
6703 { |
|
6704 FUNC_LOG; |
|
6705 TLocale currentLocaleSettings; |
|
6706 iDateFormats.iTimeFormat = currentLocaleSettings.TimeFormat(); |
|
6707 iDateFormats.iDateFormat = currentLocaleSettings.DateFormat(); |
|
6708 iDateFormats.iAmPmPosition = currentLocaleSettings.AmPmSymbolPosition(); |
|
6709 // Second time separartor |
|
6710 iDateFormats.iTimeSeparator = currentLocaleSettings.TimeSeparator( 1 ); |
|
6711 // Second date separartor |
|
6712 iDateFormats.iDateSeparator = currentLocaleSettings.DateSeparator( 1 ); |
|
6713 } |
|
6714 |
|
6715 STimeDateFormats CFSEmailUiMailListVisualiser::MailListTimeDateSettings() |
|
6716 { |
|
6717 FUNC_LOG; |
|
6718 return iDateFormats; |
|
6719 } |
|
6720 |
|
6721 |
|
6722 void CFSEmailUiMailListVisualiser::SetMailboxNameToStatusPaneL() |
|
6723 { |
|
6724 FUNC_LOG; |
|
6725 iAppUi.SetActiveMailboxNameToStatusPaneL(); |
|
6726 } |
|
6727 |
|
6728 void CFSEmailUiMailListVisualiser::SetBrandedMailBoxIconL() |
|
6729 { |
|
6730 FUNC_LOG; |
|
6731 // Get and draw branded mailbox icon |
|
6732 MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL(); |
|
6733 CGulIcon* mailBoxIcon(0); |
|
6734 TRAPD( err, mailBoxIcon = brandManager.GetGraphicL( EFSMailboxIcon, iAppUi.GetActiveMailboxId() ) ); |
|
6735 if ( err == KErrNone && mailBoxIcon ) |
|
6736 { |
|
6737 CleanupStack::PushL( mailBoxIcon ); |
|
6738 //<cmail> |
|
6739 TSize defaultIconSize(iAppUi.LayoutHandler()->GetControlBarMailboxIconSize()); |
|
6740 //</cmail> |
|
6741 AknIconUtils::SetSize(mailBoxIcon->Bitmap(), defaultIconSize); |
|
6742 AknIconUtils::SetSize(mailBoxIcon->Mask(), defaultIconSize); |
|
6743 // Create texture into TextureManager, If not already existing |
|
6744 iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailBoxIcon, |
|
6745 iAppUi.GetActiveMailboxId().PluginId(), |
|
6746 iAppUi.GetActiveMailboxId().Id(), |
|
6747 defaultIconSize ); |
|
6748 // Get branded mailbox icon |
|
6749 iMailBoxIconTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iAppUi.GetActiveMailboxId().PluginId(), |
|
6750 iAppUi.GetActiveMailboxId().Id(), |
|
6751 defaultIconSize ); |
|
6752 iIconButton->SetIconL( *iMailBoxIconTexture ); |
|
6753 CleanupStack::PopAndDestroy( mailBoxIcon ); |
|
6754 } |
|
6755 else |
|
6756 { |
|
6757 iIconButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) ); |
|
6758 } |
|
6759 } |
|
6760 |
|
6761 |
|
6762 void CFSEmailUiMailListVisualiser::SetBrandedListWatermarkL() |
|
6763 { |
|
6764 FUNC_LOG; |
|
6765 MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL(); |
|
6766 CGulIcon* mailBoxWatermarkIcon(0); |
|
6767 TRAPD( err, mailBoxWatermarkIcon = brandManager.GetGraphicL( EFSWatermark, iAppUi.GetActiveMailboxId() ) ); |
|
6768 if ( err == KErrNone && mailBoxWatermarkIcon ) |
|
6769 { |
|
6770 CleanupStack::PushL( mailBoxWatermarkIcon ); |
|
6771 TRect mainPaneRect; |
|
6772 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
6773 TInt xPos = mainPaneRect.iBr.iX/100*40; // 40% of main pane width |
|
6774 TInt yPos = mainPaneRect.iBr.iY/100*40; // 40% of main pane height |
|
6775 TSize defaultWaterMarkSize(xPos,yPos); |
|
6776 AknIconUtils::SetSize(mailBoxWatermarkIcon->Bitmap(), defaultWaterMarkSize); |
|
6777 AknIconUtils::SetSize(mailBoxWatermarkIcon->Mask(), defaultWaterMarkSize); |
|
6778 if ( !iMailBoxWatermarkTexture ) |
|
6779 { |
|
6780 // iMailBoxWatermarkTexture = CAlfTexture::NewL( *iEnv, Id() ); // DOLATER - Replaced by line below, creates blank texture until UploadL's replaced by something |
|
6781 iMailBoxWatermarkTexture = &CAlfStatic::Env().TextureManager().BlankTexture(); |
|
6782 } |
|
6783 // DOLATER - Gone from Alfred, needs to be replaced with something |
|
6784 //iMailBoxWatermarkTexture->UploadL( *mailBoxWatermarkIcon->Bitmap(), mailBoxWatermarkIcon->Mask() ); |
|
6785 CleanupStack::PopAndDestroy( mailBoxWatermarkIcon ); |
|
6786 TPoint watermarkPosition( mainPaneRect.iBr.iX-xPos-20, mainPaneRect.iBr.iY-yPos-20 ); |
|
6787 iMailTreeListVisualizer->SetWatermarkPos( watermarkPosition ); |
|
6788 iMailTreeListVisualizer->SetWatermarkSize( defaultWaterMarkSize ); |
|
6789 iMailTreeListVisualizer->SetWatermarkOpacity( 0.3 ); |
|
6790 iMailTreeListVisualizer->SetWatermarkL( iMailBoxWatermarkTexture ); |
|
6791 } |
|
6792 else |
|
6793 { |
|
6794 // Not found, hide watermark |
|
6795 iMailTreeListVisualizer->SetWatermarkOpacity( 0 ); |
|
6796 } |
|
6797 } |
|
6798 |
|
6799 TFsTreeItemId CFSEmailUiMailListVisualiser::ParentNode( TFsTreeItemId aItemId ) const |
|
6800 { |
|
6801 FUNC_LOG; |
|
6802 if ( iNodesInUse ) |
|
6803 { |
|
6804 TFsTreeItemId parentNodeId = iMailList->Parent( aItemId ); |
|
6805 if ( iMailList->IsNode( parentNodeId ) ) |
|
6806 { |
|
6807 return parentNodeId; |
|
6808 } |
|
6809 } |
|
6810 return KErrNotFound; |
|
6811 } |
|
6812 |
|
6813 TBool CFSEmailUiMailListVisualiser::DoScrollMarkUnmarkL() |
|
6814 { |
|
6815 FUNC_LOG; |
|
6816 TBool ret = EFalse; |
|
6817 |
|
6818 // <cmail> |
|
6819 if ( iFocusedControl == EMailListComponent && iModel->Count() ) |
|
6820 // </cmail> |
|
6821 { |
|
6822 CFSEmailUiMailListModelItem* item = |
|
6823 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) ); |
|
6824 |
|
6825 if ( item->ModelItemType() == ETypeMailItem ) // Separators are not markable |
|
6826 { |
|
6827 if ( !iListMarkItemsState ) |
|
6828 { |
|
6829 iMailList->MarkItemL( iMailList->FocusedItem(), EFalse ); |
|
6830 } |
|
6831 else |
|
6832 { |
|
6833 iMailList->MarkItemL( iMailList->FocusedItem(), ETrue ); |
|
6834 } |
|
6835 ret = ETrue; |
|
6836 } |
|
6837 } |
|
6838 |
|
6839 return ret; |
|
6840 } |
|
6841 |
|
6842 // Mark / unmark all items under current separator |
|
6843 void CFSEmailUiMailListVisualiser::MarkItemsUnderSeparatorL( TBool aMarked, TInt aSeparatorId ) |
|
6844 { |
|
6845 FUNC_LOG; |
|
6846 |
|
6847 if ( iTreeItemArray.Count() ) |
|
6848 { |
|
6849 // Find all items under wanted separator. |
|
6850 for ( TInt i = aSeparatorId + 1; i < iTreeItemArray.Count(); i++ ) |
|
6851 { |
|
6852 CFSEmailUiMailListModelItem* item = |
|
6853 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) ); |
|
6854 |
|
6855 // Mark / unmark mail items. |
|
6856 if ( item && |
|
6857 item->ModelItemType() == ETypeMailItem && |
|
6858 !iMailList->IsNode( iTreeItemArray[i].iListItemId ) ) |
|
6859 { |
|
6860 iMailList->MarkItemL( iTreeItemArray[i].iListItemId, aMarked ); |
|
6861 } |
|
6862 else |
|
6863 { |
|
6864 // Stop iteration since another iterator was reached. |
|
6865 break; |
|
6866 } |
|
6867 } |
|
6868 } |
|
6869 } |
|
6870 // Navigation functions, used mainly from viewer |
|
6871 TBool CFSEmailUiMailListVisualiser::IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId, |
|
6872 TFSMailMsgId& aFoundNextMsgId, |
|
6873 TFSMailMsgId& aFoundNextMsgFolder ) const |
|
6874 { |
|
6875 FUNC_LOG; |
|
6876 TBool ret(EFalse); |
|
6877 TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId ); |
|
6878 if ( curIdx >= 0 ) |
|
6879 { |
|
6880 TInt nextIdx = NextMessageIndex(curIdx); |
|
6881 if ( nextIdx >= 0 ) |
|
6882 { |
|
6883 ret = ETrue; |
|
6884 aFoundNextMsgId = MsgIdFromIndex(nextIdx); |
|
6885 aFoundNextMsgFolder = iMailFolder->GetFolderId(); |
|
6886 } |
|
6887 } |
|
6888 |
|
6889 return ret; |
|
6890 } |
|
6891 |
|
6892 TBool CFSEmailUiMailListVisualiser::IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, |
|
6893 TFSMailMsgId& aFoundPreviousMsgId, |
|
6894 TFSMailMsgId& aFoundPrevMsgFolder ) const |
|
6895 { |
|
6896 FUNC_LOG; |
|
6897 TBool ret(EFalse); |
|
6898 TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId ); |
|
6899 if ( curIdx >= 0 ) |
|
6900 { |
|
6901 TInt prevIdx = PreviousMessageIndex(curIdx); |
|
6902 if ( prevIdx >= 0 ) |
|
6903 { |
|
6904 ret = ETrue; |
|
6905 aFoundPreviousMsgId = MsgIdFromIndex(prevIdx); |
|
6906 aFoundPrevMsgFolder = iMailFolder->GetFolderId(); |
|
6907 } |
|
6908 } |
|
6909 |
|
6910 return ret; |
|
6911 } |
|
6912 |
|
6913 TInt CFSEmailUiMailListVisualiser::MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId ) |
|
6914 { |
|
6915 FUNC_LOG; |
|
6916 TInt ret(KErrNotFound); |
|
6917 |
|
6918 TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId ); |
|
6919 TInt nextIdx = NextMessageIndex( curIdx ); |
|
6920 |
|
6921 if ( curIdx >= 0 && nextIdx >= 0 ) |
|
6922 { |
|
6923 // Focus the new message |
|
6924 // <cmail> |
|
6925 iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[nextIdx].iListItemId, EFalse ); |
|
6926 // </cmail> |
|
6927 ChangeReadStatusOfHighlightedL( ETrue ); |
|
6928 |
|
6929 aFoundNextMsgId = MsgIdFromIndex( nextIdx ); |
|
6930 ret = KErrNone; |
|
6931 } |
|
6932 if ( ret == KErrNone ) |
|
6933 { |
|
6934 OpenHighlightedMailL(); |
|
6935 } |
|
6936 return ret; |
|
6937 } |
|
6938 |
|
6939 TInt CFSEmailUiMailListVisualiser::MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId ) |
|
6940 { |
|
6941 FUNC_LOG; |
|
6942 TInt ret(KErrNotFound); |
|
6943 |
|
6944 TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId ); |
|
6945 TInt prevIdx = PreviousMessageIndex( curIdx ); |
|
6946 |
|
6947 if ( curIdx >= 0 && prevIdx >= 0 ) |
|
6948 { |
|
6949 // Focus the new message |
|
6950 // <cmail> |
|
6951 iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[prevIdx].iListItemId, EFalse ); |
|
6952 // </cmail> |
|
6953 ChangeReadStatusOfHighlightedL( ETrue ); |
|
6954 aFoundPreviousMsgId = MsgIdFromIndex( prevIdx ); |
|
6955 ret = KErrNone; |
|
6956 } |
|
6957 if ( ret == KErrNone ) |
|
6958 { |
|
6959 OpenHighlightedMailL(); |
|
6960 } |
|
6961 return ret; |
|
6962 } |
|
6963 |
|
6964 |
|
6965 void CFSEmailUiMailListVisualiser::ManualMailBoxSync( TBool aManualMailBoxSync ) |
|
6966 { |
|
6967 FUNC_LOG; |
|
6968 iManualMailBoxSync = aManualMailBoxSync; |
|
6969 } |
|
6970 |
|
6971 TBool CFSEmailUiMailListVisualiser::GetLatestSyncState() |
|
6972 { |
|
6973 FUNC_LOG; |
|
6974 CFSMailBox* activeMailbox = iAppUi.GetActiveMailbox(); |
|
6975 |
|
6976 TBool ret = EFalse; |
|
6977 |
|
6978 if ( activeMailbox ) |
|
6979 { |
|
6980 TSSMailSyncState latestSyncstate = activeMailbox->CurrentSyncState(); |
|
6981 if(latestSyncstate == InboxSyncing || |
|
6982 latestSyncstate == StartingSync || |
|
6983 latestSyncstate == EmailSyncing || |
|
6984 latestSyncstate == OutboxSyncing || |
|
6985 latestSyncstate == SentItemsSyncing || |
|
6986 latestSyncstate == DraftsSyncing || |
|
6987 latestSyncstate == CalendarSyncing || |
|
6988 latestSyncstate == ContactsSyncing || |
|
6989 latestSyncstate == TasksSyncing || |
|
6990 latestSyncstate == NotesSyncing || |
|
6991 latestSyncstate == FilesSyncing || |
|
6992 latestSyncstate == DataSyncStarting ) |
|
6993 { |
|
6994 ret = ETrue; |
|
6995 } |
|
6996 } |
|
6997 |
|
6998 return ret; |
|
6999 } |
|
7000 |
|
7001 void CFSEmailUiMailListVisualiser::ConnectionIconHandling() |
|
7002 { |
|
7003 FUNC_LOG; |
|
7004 iAppUi.UpdateTitlePaneConnectionStatus(); |
|
7005 } |
|
7006 |
|
7007 void CFSEmailUiMailListVisualiser::SetListAndCtrlBarFocusL() |
|
7008 { |
|
7009 FUNC_LOG; |
|
7010 if ( iFocusedControl == EMailListComponent ) |
|
7011 { |
|
7012 iMailList->SetFocusedL( ETrue ); |
|
7013 iControlBarControl->SetFocusL( EFalse ); |
|
7014 } |
|
7015 else |
|
7016 { |
|
7017 iMailList->SetFocusedL( EFalse ); |
|
7018 TInt focusedBtnId = KErrNotFound; |
|
7019 MFsControlButtonInterface* focusedBtn = iControlBarControl->GetFocusedButton(); |
|
7020 if ( focusedBtn ) |
|
7021 { |
|
7022 focusedBtnId = focusedBtn->Id(); |
|
7023 } |
|
7024 iControlBarControl->MakeSelectorVisible( IsFocusShown() ); |
|
7025 iControlBarControl->SetFocusL( ETrue ); |
|
7026 if ( focusedBtnId != KErrNotFound ) |
|
7027 { |
|
7028 iControlBarControl->SetFocusByIdL( focusedBtnId ); |
|
7029 } |
|
7030 } |
|
7031 } |
|
7032 |
|
7033 // <cmail> |
|
7034 // --------------------------------------------------------------------------- |
|
7035 // ActionMenuPosition |
|
7036 // --------------------------------------------------------------------------- |
|
7037 // |
|
7038 TPoint CFSEmailUiMailListVisualiser::ActionMenuPosition() |
|
7039 { |
|
7040 RFsTreeItemIdList markedEntries; |
|
7041 TRAP_IGNORE(iMailList->GetMarkedItemsL( markedEntries )); |
|
7042 TInt markedCount = markedEntries.Count(); |
|
7043 TFsTreeItemId listItemId; |
|
7044 if ( markedCount == 0 ) |
|
7045 { |
|
7046 listItemId = iMailList->FocusedItem(); |
|
7047 } |
|
7048 else // ( markedCount == 1) |
|
7049 { |
|
7050 listItemId = markedEntries[0]; |
|
7051 } |
|
7052 TAlfRealRect focusRect; |
|
7053 iMailList->GetItemDisplayRectTarget(listItemId, focusRect); |
|
7054 markedEntries.Close(); |
|
7055 return focusRect.iTl; |
|
7056 } |
|
7057 // </cmail> |
|
7058 |
|
7059 void CFSEmailUiMailListVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const |
|
7060 { |
|
7061 aLayoutArray.AppendL( iScreenAnchorLayout ); |
|
7062 aLayoutArray.AppendL( iControlBarControl->Visual() ); |
|
7063 } |
|
7064 |
|
7065 |
|
7066 ////////////////////////////////////////////////////////////////// |
|
7067 // Class implementation CMailListUpdater |
|
7068 /////////////////////////////////////////////////////////////////// |
|
7069 |
|
7070 |
|
7071 // ----------------------------------------------------------------------------- |
|
7072 // CMailListUpdater::NewL |
|
7073 // NewL function. Returns timer object. |
|
7074 // ----------------------------------------------------------------------------- |
|
7075 // |
|
7076 CMailListUpdater* CMailListUpdater::NewL( CFSEmailUiMailListVisualiser* aMailListVisualiser ) |
|
7077 { |
|
7078 FUNC_LOG; |
|
7079 CMailListUpdater* self = new (ELeave) CMailListUpdater( aMailListVisualiser ); |
|
7080 CleanupStack::PushL( self ); |
|
7081 self->ConstructL(); |
|
7082 CleanupStack::Pop( self ); |
|
7083 return self; |
|
7084 } |
|
7085 |
|
7086 // ----------------------------------------------------------------------------- |
|
7087 // CMailListUpdater::~CMailListUpdater |
|
7088 // D'tor |
|
7089 // ----------------------------------------------------------------------------- |
|
7090 // |
|
7091 CMailListUpdater::~CMailListUpdater() |
|
7092 { |
|
7093 FUNC_LOG; |
|
7094 Cancel(); |
|
7095 } |
|
7096 |
|
7097 // ----------------------------------------------------------------------------- |
|
7098 // CMailListUpdater::CMailListUpdater |
|
7099 // C'tor |
|
7100 // ----------------------------------------------------------------------------- |
|
7101 // |
|
7102 CMailListUpdater::CMailListUpdater( CFSEmailUiMailListVisualiser* aMailListVisualiser ) |
|
7103 : CTimer( EPriorityStandard ), |
|
7104 iMailListVisualiser( aMailListVisualiser ) |
|
7105 { |
|
7106 FUNC_LOG; |
|
7107 CActiveScheduler::Add( this ); |
|
7108 } |
|
7109 |
|
7110 // ----------------------------------------------------------------------------- |
|
7111 // CMailListUpdater::RunL |
|
7112 // Timer trigger function. |
|
7113 // ----------------------------------------------------------------------------- |
|
7114 // |
|
7115 void CMailListUpdater::RunL() |
|
7116 { |
|
7117 FUNC_LOG; |
|
7118 if ( iIsSorting ) |
|
7119 { |
|
7120 iMailListVisualiser->UpdateMailListModelL(); |
|
7121 iMailListVisualiser->RefreshL(); |
|
7122 // Sorting is completed |
|
7123 iIsSorting = EFalse; |
|
7124 // Dismiss wait note. |
|
7125 if ( iWaitNote ) |
|
7126 { |
|
7127 iWaitNote->ProcessFinishedL(); |
|
7128 } |
|
7129 } |
|
7130 else |
|
7131 { |
|
7132 // Store the list of marked items. The markings are erased when the list |
|
7133 // is repopulated and, hence, the markings need to be reset after the |
|
7134 // refreshing is done. The marked items must be identified by the message |
|
7135 // ID rather than with the list ID because refreshing may change the list IDs. |
|
7136 RArray<TFSMailMsgId> markedMessages; |
|
7137 CleanupClosePushL( markedMessages ); |
|
7138 iMailListVisualiser->GetMarkedMessagesL( markedMessages ); |
|
7139 |
|
7140 // Store the message ID of the focused item |
|
7141 TFSMailMsgId msgIdBeforeRefresh; |
|
7142 TFsTreeItemId firstVisibleListId = iMailListVisualiser->iMailTreeListVisualizer->FirstVisibleItem(); |
|
7143 TInt modelFirstIndexBeforeUpdate = iMailListVisualiser->ModelIndexFromListId( firstVisibleListId ); |
|
7144 TInt highlightedIndexBeforeUpdate = iMailListVisualiser->HighlightedIndex(); |
|
7145 TInt modelCountBeforeUpdate = iMailListVisualiser->iModel->Count(); |
|
7146 if ( iMailListVisualiser->iModel->Count() ) |
|
7147 { |
|
7148 CFSEmailUiMailListModelItem* item = |
|
7149 static_cast<CFSEmailUiMailListModelItem*>(iMailListVisualiser->iModel->Item( highlightedIndexBeforeUpdate ) ); |
|
7150 if ( item->ModelItemType() == ETypeMailItem ) |
|
7151 { |
|
7152 msgIdBeforeRefresh = item->MessagePtr().GetMessageId(); |
|
7153 } |
|
7154 } |
|
7155 |
|
7156 iMailListVisualiser->UpdateMailListModelL(); |
|
7157 iMailListVisualiser->RefreshL( &msgIdBeforeRefresh ); |
|
7158 |
|
7159 // Focus is set to last focused item. After this, try to keep the same first item that previous |
|
7160 // Check how many messages have been added |
|
7161 TInt modelIndexDifference = highlightedIndexBeforeUpdate-modelFirstIndexBeforeUpdate; // 0 or more |
|
7162 if ( modelIndexDifference < 0 ) |
|
7163 { |
|
7164 modelIndexDifference = 0; // safety |
|
7165 } |
|
7166 TInt toBeFirstIdx = iMailListVisualiser->HighlightedIndex() - modelIndexDifference; |
|
7167 CFSEmailUiMailListModelItem* toBeFirstVisItem = |
|
7168 static_cast<CFSEmailUiMailListModelItem*>( iMailListVisualiser->iModel->Item(toBeFirstIdx) ); |
|
7169 if ( toBeFirstVisItem ) |
|
7170 { |
|
7171 // <cmail> |
|
7172 iMailListVisualiser->iMailTreeListVisualizer->SetFirstVisibleItemL( toBeFirstVisItem->CorrespondingListId() ); |
|
7173 // </cmail> |
|
7174 } |
|
7175 |
|
7176 // Restore the marking status |
|
7177 iMailListVisualiser->MarkMessagesIfFoundL( markedMessages ); |
|
7178 CleanupStack::PopAndDestroy( &markedMessages ); |
|
7179 } |
|
7180 Cancel(); |
|
7181 } |
|
7182 |
|
7183 // ----------------------------------------------------------------------------- |
|
7184 // CMailListUpdater::Start |
|
7185 // Timer starting function. |
|
7186 // ----------------------------------------------------------------------------- |
|
7187 // |
|
7188 void CMailListUpdater::StartL( TBool aIsSorting ) |
|
7189 { |
|
7190 FUNC_LOG; |
|
7191 if ( iWaitNote ) |
|
7192 { |
|
7193 iWaitNote->ProcessFinishedL(); |
|
7194 } |
|
7195 |
|
7196 iIsSorting = aIsSorting; |
|
7197 Cancel(); |
|
7198 if ( iIsSorting ) |
|
7199 { |
|
7200 // Start wait note |
|
7201 TFsEmailUiUtility::ShowWaitNoteL( iWaitNote, R_FSE_WAIT_SORTING_TEXT, EFalse, ETrue ); |
|
7202 After( 10 ); // Update shortly after selection has been made. |
|
7203 } |
|
7204 else |
|
7205 { |
|
7206 // Mail added update |
|
7207 After( KMsgUpdaterTimerDelay ); // Update after 1,5 seconds |
|
7208 } |
|
7209 } |
|
7210 |
|
7211 // ----------------------------------------------------------------------------- |
|
7212 // CMailListUpdater::Stop |
|
7213 // Timer stopping function |
|
7214 // ----------------------------------------------------------------------------- |
|
7215 // |
|
7216 void CMailListUpdater::Stop() |
|
7217 { |
|
7218 FUNC_LOG; |
|
7219 Cancel(); |
|
7220 } |
|
7221 |
|
7222 |
|
7223 |
|
7224 ////////////////////////////////////////////////////////////////// |
|
7225 // Class implementation CMsgMovedNoteTimer |
|
7226 /////////////////////////////////////////////////////////////////// |
|
7227 |
|
7228 |
|
7229 // ----------------------------------------------------------------------------- |
|
7230 // CMsgMovedNoteTimer::NewL |
|
7231 // NewL function. Returns timer object. |
|
7232 // ----------------------------------------------------------------------------- |
|
7233 // |
|
7234 CMsgMovedNoteTimer* CMsgMovedNoteTimer::NewL( CFreestyleEmailUiAppUi* aAppUi, CFSEmailUiMailListVisualiser* aMailListVisualiser ) |
|
7235 { |
|
7236 FUNC_LOG; |
|
7237 CMsgMovedNoteTimer* self = new (ELeave) CMsgMovedNoteTimer( aAppUi, aMailListVisualiser ); |
|
7238 CleanupStack::PushL( self ); |
|
7239 self->ConstructL(); |
|
7240 CleanupStack::Pop( self ); |
|
7241 return self; |
|
7242 } |
|
7243 |
|
7244 // ----------------------------------------------------------------------------- |
|
7245 // CMsgMovedNoteTimer::CMsgMovedNoteTimer |
|
7246 // D'tor |
|
7247 // ----------------------------------------------------------------------------- |
|
7248 // |
|
7249 CMsgMovedNoteTimer::~CMsgMovedNoteTimer() |
|
7250 { |
|
7251 FUNC_LOG; |
|
7252 Cancel(); |
|
7253 } |
|
7254 |
|
7255 // ----------------------------------------------------------------------------- |
|
7256 // CMailListUpdater::CMailListUpdater |
|
7257 // C'tor |
|
7258 // ----------------------------------------------------------------------------- |
|
7259 // |
|
7260 CMsgMovedNoteTimer::CMsgMovedNoteTimer( CFreestyleEmailUiAppUi* aAppUi, CFSEmailUiMailListVisualiser* aMailListVisualiser ) |
|
7261 : CTimer( EPriorityStandard ), |
|
7262 iAppUi( aAppUi), |
|
7263 iMailListVisualiser( aMailListVisualiser ) |
|
7264 { |
|
7265 FUNC_LOG; |
|
7266 CActiveScheduler::Add( this ); |
|
7267 } |
|
7268 |
|
7269 // ----------------------------------------------------------------------------- |
|
7270 // CMsgMovedNoteTimer::RunL |
|
7271 // Timer trigger function. |
|
7272 // ----------------------------------------------------------------------------- |
|
7273 // |
|
7274 void CMsgMovedNoteTimer::RunL() |
|
7275 { |
|
7276 FUNC_LOG; |
|
7277 TFsEmailUiUtility::DisplayMsgsMovedNoteL( iMsgCount, iDestinationFolderId, EFalse ); |
|
7278 Cancel(); |
|
7279 } |
|
7280 |
|
7281 // ----------------------------------------------------------------------------- |
|
7282 // CMsgMovedNoteTimer::Start |
|
7283 // Timer starting function. |
|
7284 // ----------------------------------------------------------------------------- |
|
7285 // |
|
7286 void CMsgMovedNoteTimer::Start( TInt aMsgCount, const TFSMailMsgId aDestinationFolderId ) |
|
7287 { |
|
7288 FUNC_LOG; |
|
7289 Cancel(); |
|
7290 iMsgCount = aMsgCount, |
|
7291 iDestinationFolderId = aDestinationFolderId; |
|
7292 TInt viewSlideinTime = iAppUi->LayoutHandler()->ViewSlideEffectTime(); |
|
7293 if ( viewSlideinTime == 0 ) |
|
7294 { |
|
7295 viewSlideinTime = 100; |
|
7296 } |
|
7297 After( viewSlideinTime ); |
|
7298 } |
|
7299 |
|
7300 // ----------------------------------------------------------------------------- |
|
7301 // CMsgMovedNoteTimer::Stop |
|
7302 // Timer stopping function |
|
7303 // ----------------------------------------------------------------------------- |
|
7304 // |
|
7305 void CMsgMovedNoteTimer::Stop() |
|
7306 { |
|
7307 FUNC_LOG; |
|
7308 Cancel(); |
|
7309 } |
|
7310 |
|
7311 |
|
7312 ////////////////////////////////////////////////////////////////// |
|
7313 // Class implementation CDateChnageTimer |
|
7314 /////////////////////////////////////////////////////////////////// |
|
7315 |
|
7316 // ----------------------------------------------------------------------------- |
|
7317 // CMsgMovedNoteTimer::NewL |
|
7318 // Two phased constructor |
|
7319 // ----------------------------------------------------------------------------- |
|
7320 // |
|
7321 CDateChangeTimer* CDateChangeTimer::NewL( CFSEmailUiMailListVisualiser& aMailListVisualiser ) |
|
7322 { |
|
7323 FUNC_LOG; |
|
7324 CDateChangeTimer* self = new ( ELeave ) CDateChangeTimer( aMailListVisualiser ); |
|
7325 CleanupStack::PushL( self ); |
|
7326 self->ConstructL(); |
|
7327 CleanupStack::Pop( self ); |
|
7328 return self; |
|
7329 } |
|
7330 |
|
7331 // ----------------------------------------------------------------------------- |
|
7332 // CMsgMovedNoteTimer::CDateChangeTimer |
|
7333 // First phase constructor |
|
7334 // ----------------------------------------------------------------------------- |
|
7335 // |
|
7336 CDateChangeTimer::CDateChangeTimer( CFSEmailUiMailListVisualiser& aMailListVisualiser ) |
|
7337 : CTimer( EPriorityStandard ), iMailListVisualiser( aMailListVisualiser ) |
|
7338 { |
|
7339 FUNC_LOG; |
|
7340 CActiveScheduler::Add( this ); |
|
7341 } |
|
7342 |
|
7343 // ----------------------------------------------------------------------------- |
|
7344 // CMsgMovedNoteTimer::~CDateChangeTimer |
|
7345 // Destructor |
|
7346 // ----------------------------------------------------------------------------- |
|
7347 // |
|
7348 CDateChangeTimer::~CDateChangeTimer() |
|
7349 { |
|
7350 FUNC_LOG; |
|
7351 // no implementation needed |
|
7352 } |
|
7353 |
|
7354 // ----------------------------------------------------------------------------- |
|
7355 // CMsgMovedNoteTimer::Start |
|
7356 // Request event at 00:00 tomorrow |
|
7357 // ----------------------------------------------------------------------------- |
|
7358 // |
|
7359 void CDateChangeTimer::Start() |
|
7360 { |
|
7361 FUNC_LOG; |
|
7362 TTime now; |
|
7363 now.HomeTime(); |
|
7364 |
|
7365 // Construct target time |
|
7366 TTime eventTime = now + TTimeIntervalDays( 1 ); |
|
7367 TDateTime eventDateTime = eventTime.DateTime(); |
|
7368 eventDateTime.SetHour(0); |
|
7369 eventDateTime.SetMinute(0); |
|
7370 eventDateTime.SetSecond(0); |
|
7371 eventDateTime.SetMicroSecond(0); |
|
7372 eventTime = TTime( eventDateTime ); |
|
7373 |
|
7374 // Issue the request |
|
7375 At( eventTime ); |
|
7376 } |
|
7377 |
|
7378 // ----------------------------------------------------------------------------- |
|
7379 // CMsgMovedNoteTimer::RunL |
|
7380 // Function gets called when system time reaches the 00:00 in the next day or |
|
7381 // when the system time has been changed by the user. Both cases can be handled |
|
7382 // in the same way. |
|
7383 // ----------------------------------------------------------------------------- |
|
7384 // |
|
7385 void CDateChangeTimer::RunL() |
|
7386 { |
|
7387 FUNC_LOG; |
|
7388 // Update mail list and reissue the request for timer event |
|
7389 iMailListVisualiser.NotifyDateChangedL(); |
|
7390 Start(); |
|
7391 } |