|
1 /* |
|
2 * Copyright (c) 2007 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 "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements visualiser for the download manager view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include "emailtrace.h" |
|
22 #include <FreestyleEmailUi.mbg> |
|
23 #include <aknutils.h> |
|
24 #include <gulicon.h> |
|
25 #include <StringLoader.h> |
|
26 #include <FreestyleEmailUi.rsg> |
|
27 // <cmail> SF |
|
28 #include <alf/alfframebrush.h> |
|
29 #include "fscontrolbar.h" |
|
30 #include "fscontrolbuttoninterface.h" |
|
31 #include "fstreelist.h" |
|
32 #include "fstreevisualizerbase.h" |
|
33 #include "fstreeplainonelineitemdata.h" |
|
34 #include "fstreeplainonelineitemvisualizer.h" |
|
35 #include "fstreeplainonelinenodedata.h" |
|
36 #include "fstreeplainonelinenodevisualizer.h" |
|
37 #include "fstreeplaintwolineitemdata.h" |
|
38 #include "fstreeplaintwolineitemvisualizer.h" |
|
39 // </cmail> |
|
40 #include <AknListQueryDialog.h> |
|
41 #include <caknfileselectiondialog.h> |
|
42 #include <caknmemoryselectiondialog.h> |
|
43 #include <pathinfo.h> |
|
44 #include <aknnotewrappers.h> |
|
45 // <cmail> SF |
|
46 #include <alf/alfdecklayout.h> |
|
47 #include <alf/alfevent.h> |
|
48 #include <alf/alfcontrolgroup.h> |
|
49 #include <csxhelp/cmail.hlp.hrh> |
|
50 #include "mfsmailbrandmanager.h" |
|
51 #include "cfsmailclient.h" |
|
52 //</cmail> |
|
53 #include <FeatMgr.h> |
|
54 //</cmail> |
|
55 |
|
56 // INTERNAL INCLUDES |
|
57 #include "FreestyleEmailUiAttachmentsListVisualiser.h" |
|
58 #include "FreestyleEmailUiLayoutHandler.h" |
|
59 #include "FreestyleEmailUiDownloadManagerModel.h" |
|
60 #include "FreestyleEmailUiDownloadManagerVisualiser.h" |
|
61 #include "FreestyleEmailUiDownloadManagerControl.h" |
|
62 #include "FreestyleEmailUiMsgDetailsVisualiser.h" |
|
63 #include "FreestyleEmailUiFileSystemInfo.h" |
|
64 #include "FreestyleEmailUiScrollbarClet.h" |
|
65 #include "FreestyleEmailUiAppUi.h" |
|
66 #include "FreestyleEmailUi.hrh" |
|
67 #include "FreestyleEmailUiTextureManager.h" |
|
68 #include "FreestyleEmailUiUtilities.h" |
|
69 #include "FreestyleEmailUiLiterals.h" |
|
70 #include "FreestyleEmailUiShortcutBinding.h" |
|
71 |
|
72 |
|
73 CFSEmailUiDownloadManagerVisualiser* CFSEmailUiDownloadManagerVisualiser::NewL( |
|
74 CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup ) |
|
75 { |
|
76 FUNC_LOG; |
|
77 CFSEmailUiDownloadManagerVisualiser* self = |
|
78 CFSEmailUiDownloadManagerVisualiser::NewLC( aEnv, aAppUi, aControlGroup ); |
|
79 CleanupStack::Pop( self ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 CFSEmailUiDownloadManagerVisualiser* CFSEmailUiDownloadManagerVisualiser::NewLC( |
|
84 CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup ) |
|
85 { |
|
86 FUNC_LOG; |
|
87 CFSEmailUiDownloadManagerVisualiser* self = |
|
88 new (ELeave) CFSEmailUiDownloadManagerVisualiser( aEnv, aAppUi, aControlGroup ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 return self; |
|
92 } |
|
93 |
|
94 void CFSEmailUiDownloadManagerVisualiser::ConstructL() |
|
95 { |
|
96 FUNC_LOG; |
|
97 |
|
98 BaseConstructL( R_FSEMAILUI_DOWNLOADMANAGER_VIEW ); |
|
99 |
|
100 // Create list screen (list) control |
|
101 iScreenControl = CFreestyleEmailUiDownloadManagerControl::NewL( iEnv, this ); |
|
102 |
|
103 // Create attachments list layout and set it to fill the main pane |
|
104 TRect screenRect; |
|
105 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect ); |
|
106 iListLayout = CAlfDeckLayout::AddNewL( *iScreenControl ); |
|
107 screenRect.Move(0,0); |
|
108 iListLayout->SetRect( screenRect ); |
|
109 |
|
110 // Create attachments list tree list component |
|
111 iDownloadManagerTreeListVisualizer = CFsTreeVisualizerBase::NewL(iScreenControl, *iListLayout); |
|
112 iDownloadManagerTreeListVisualizer->SetItemExpansionDelay( iAppUi.LayoutHandler()->ListItemExpansionDelay() ); |
|
113 |
|
114 iDownloadManagerList = CFsTreeList::NewL(*iDownloadManagerTreeListVisualizer, iEnv); |
|
115 iDownloadManagerList->SetScrollbarVisibilityL( EFsScrollbarAuto ); |
|
116 iDownloadManagerList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable ); |
|
117 iDownloadManagerList->SetIndentationL( 0 ); |
|
118 |
|
119 //<cmail> Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in |
|
120 // opposite order. |
|
121 ControlGroup().AppendL( iScreenControl ); |
|
122 ControlGroup().AppendL( iDownloadManagerList->TreeControl() ); |
|
123 //</cmail> |
|
124 |
|
125 iModel = CFSEmailUiDownloadManagerModel::NewL( iAppUi, *this ); |
|
126 //<cmail> S60 skin support |
|
127 //iDownloadManagerTreeListVisualizer->SetBackgroundTextureL( iAppUi.FsTextureManager()->TextureByIndex( EBackgroundTextureMailList ) ); |
|
128 //</cmail> |
|
129 iDownloadManagerTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) ); |
|
130 iDownloadManagerTreeListVisualizer->SetItemsAlwaysExtendedL( ETrue ); |
|
131 iDownloadManagerList->AddObserverL( *this ); |
|
132 |
|
133 iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iDownloadManagerList ); |
|
134 |
|
135 // Set page up and page down keys |
|
136 iDownloadManagerTreeListVisualizer->AddCustomPageUpKey( EStdKeyPageUp ); |
|
137 iDownloadManagerTreeListVisualizer->AddCustomPageDownKey( EStdKeyPageDown ); |
|
138 |
|
139 CAlfBrush* selectorBrush = iAppUi.FsTextureManager()->ListSelectorBrushL(); |
|
140 iDownloadManagerTreeListVisualizer->SetSelectorPropertiesL( selectorBrush, 1.0, CFsTreeVisualizerBase::EFsSelectorMoveSmoothly ); |
|
141 |
|
142 } |
|
143 |
|
144 |
|
145 CFSEmailUiDownloadManagerVisualiser::CFSEmailUiDownloadManagerVisualiser( |
|
146 CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup ) |
|
147 : CFsEmailUiViewBase( aControlGroup, *aAppUi ), iEnv( aEnv ) |
|
148 { |
|
149 FUNC_LOG; |
|
150 } |
|
151 |
|
152 CFSEmailUiDownloadManagerVisualiser::~CFSEmailUiDownloadManagerVisualiser() |
|
153 { |
|
154 FUNC_LOG; |
|
155 delete iModel; |
|
156 if ( iDownloadManagerList ) |
|
157 { |
|
158 iDownloadManagerList->RemoveObserver( *this ); |
|
159 } |
|
160 delete iDownloadManagerList; |
|
161 } |
|
162 |
|
163 |
|
164 TInt CFSEmailUiDownloadManagerVisualiser::HighlightedIndex() |
|
165 { |
|
166 FUNC_LOG; |
|
167 return 0; |
|
168 } |
|
169 |
|
170 TUid CFSEmailUiDownloadManagerVisualiser::Id() const |
|
171 { |
|
172 FUNC_LOG; |
|
173 return DownloadManagerViewId; |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CFSEmailUiDownloadManagerVisualiser::ChildDoActivateL |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 // <cmail> Toolbar |
|
181 /*void CFSEmailUiDownloadManagerVisualiser::DoActivateL( |
|
182 const TVwsViewId& aPrevViewId, |
|
183 TUid aCustomMessageId, |
|
184 const TDesC8& aCustomMessage )*/ |
|
185 void CFSEmailUiDownloadManagerVisualiser::ChildDoActivateL( |
|
186 const TVwsViewId& /*aPrevViewId*/, |
|
187 TUid /*aCustomMessageId*/, |
|
188 const TDesC8& /*aCustomMessage*/ ) |
|
189 // <cmail> Toolbar |
|
190 { |
|
191 FUNC_LOG; |
|
192 RefreshL(); |
|
193 iDownloadManagerList->ShowListL(); |
|
194 |
|
195 SetMailboxNameToStatusPaneL(); |
|
196 } |
|
197 |
|
198 void CFSEmailUiDownloadManagerVisualiser::SetMailboxNameToStatusPaneL() |
|
199 { |
|
200 FUNC_LOG; |
|
201 iAppUi.SetActiveMailboxNameToStatusPaneL(); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CFSEmailUiDownloadManagerVisualiser::ChildDoDeactivate |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CFSEmailUiDownloadManagerVisualiser::ChildDoDeactivate() |
|
209 { |
|
210 FUNC_LOG; |
|
211 if ( !iAppUi.AppUiExitOngoing() ) |
|
212 { |
|
213 iDownloadManagerTreeListVisualizer->NotifyControlVisibilityChange( EFalse ); |
|
214 } |
|
215 } |
|
216 |
|
217 CFSEmailUiDownloadManagerModel* CFSEmailUiDownloadManagerVisualiser::Model() |
|
218 { |
|
219 FUNC_LOG; |
|
220 return iModel; |
|
221 } |
|
222 |
|
223 void CFSEmailUiDownloadManagerVisualiser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
224 { |
|
225 FUNC_LOG; |
|
226 TAttachmentData* selectedItem = iModel->GetItem( iDownloadManagerList->FocusedItem() ); |
|
227 |
|
228 if ( aResourceId == R_FSEMAILUI_ATTACHMENTS_SUBMENU_ACTIONS ) |
|
229 { |
|
230 aMenuPane->SetItemDimmed( EFsEmailUiCmdOpen, |
|
231 !IsCommandAvailableOnItem(EFsEmailUiCmdOpen, selectedItem) ); |
|
232 |
|
233 aMenuPane->SetItemDimmed( EFsEmailUiCmdDownload, |
|
234 !IsCommandAvailableOnItem(EFsEmailUiCmdDownload, selectedItem) ); |
|
235 |
|
236 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelDownload, |
|
237 !IsCommandAvailableOnItem(EFsEmailUiCmdCancelDownload, selectedItem) ); |
|
238 |
|
239 aMenuPane->SetItemDimmed( EFsEmailUiCmdSave, |
|
240 !IsCommandAvailableOnItem(EFsEmailUiCmdSave, selectedItem) ); |
|
241 |
|
242 aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadAll, |
|
243 !IsCommandAvailableOnItem(EFsEmailUiCmdDownloadAll, selectedItem) ); |
|
244 |
|
245 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelAllDownloads, |
|
246 !IsCommandAvailableOnItem(EFsEmailUiCmdCancelAllDownloads, selectedItem) ); |
|
247 |
|
248 aMenuPane->SetItemDimmed( EFsEmailUiCmdSaveAll, |
|
249 !IsCommandAvailableOnItem(EFsEmailUiCmdSaveAll, selectedItem) ); |
|
250 |
|
251 aMenuPane->SetItemDimmed( EFsEmailUiCmdClearFetchedAttachment, |
|
252 !IsCommandAvailableOnItem(EFsEmailUiCmdClearFetchedAttachment, selectedItem) ); |
|
253 |
|
254 aMenuPane->SetItemDimmed( EFsEmailUiCmdRemoveAttachment, |
|
255 !IsCommandAvailableOnItem(EFsEmailUiCmdRemoveAttachment, selectedItem) ); |
|
256 } |
|
257 else if ( aResourceId == R_FSEMAILUI_DOWNLOADMANAGER_MENUPANE ) |
|
258 { |
|
259 if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) ) |
|
260 { |
|
261 // remove help support in pf5250 |
|
262 aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue); |
|
263 } |
|
264 |
|
265 aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, |
|
266 !IsCommandAvailableOnItem(EFsEmailUiCmdMailActions, selectedItem) ); |
|
267 |
|
268 // Hide message related commands if no message in focus. |
|
269 // This may happen when all attachments have been removed from open DM view. |
|
270 TPartData messageData; |
|
271 TRAPD( err, messageData = iModel->GetMessageL( iDownloadManagerList->FocusedItem() ) ); |
|
272 if ( err ) |
|
273 { |
|
274 aMenuPane->SetItemDimmed( EFSEmailUICmdViewMessage, ETrue ); |
|
275 aMenuPane->SetItemDimmed( EFsEmailUiCmdMsgDetails, ETrue ); |
|
276 } |
|
277 } |
|
278 |
|
279 // Add shortcut hints |
|
280 iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, |
|
281 CFSEmailUiShortcutBinding::EContextDownloadManager ); |
|
282 } |
|
283 |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // HandleMailBoxEventL |
|
287 // Mailbox event handler, responds to events sent by the plugin. |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 void CFSEmailUiDownloadManagerVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent, |
|
291 TFSMailMsgId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ ) |
|
292 { |
|
293 FUNC_LOG; |
|
294 // Safety, refresh only if this view is active, has model and mail deleted event has been received. |
|
295 if ( aEvent == TFSEventMailDeleted && iModel ) |
|
296 { |
|
297 // Remove deleted items from list. Refresh list if this view is active |
|
298 // and some item was removed. |
|
299 if ( iModel->ClearInvalidItemsL() && |
|
300 iAppUi.CurrentActiveView() == this ) |
|
301 { |
|
302 RefreshL(); |
|
303 SetMskL(); |
|
304 } |
|
305 } |
|
306 } |
|
307 |
|
308 |
|
309 void CFSEmailUiDownloadManagerVisualiser::RefreshL() |
|
310 { |
|
311 FUNC_LOG; |
|
312 TRect screenRect; |
|
313 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
314 iListLayout->SetRect( screenRect ); |
|
315 |
|
316 iDownloadManagerList->RemoveAllL(); |
|
317 |
|
318 CFsTreePlainTwoLineItemData* twoLineItemData = CFsTreePlainTwoLineItemData::NewL(); |
|
319 CleanupStack::PushL( twoLineItemData ); |
|
320 CFsTreePlainTwoLineItemVisualizer* twoLineItemVisualizer = |
|
321 CFsTreePlainTwoLineItemVisualizer::NewL( *iDownloadManagerList->TreeControl() ); |
|
322 CleanupStack::PushL( twoLineItemVisualizer ); |
|
323 // Set font height |
|
324 twoLineItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
325 // Set font bolding |
|
326 twoLineItemVisualizer->SetTextBold( ETrue ); |
|
327 // Set manual layout and make item non-focusable |
|
328 twoLineItemVisualizer->SetFlags( twoLineItemVisualizer->Flags() & ~KFsTreeListItemFocusable ); |
|
329 |
|
330 // Set correct skin text colors for the list items |
|
331 TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
332 TRgb normalItemColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
333 TRgb normalNodeColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
|
334 TRgb headerBgColor = iAppUi.LayoutHandler()->ListHeaderBackgroundColor(); |
|
335 |
|
336 twoLineItemVisualizer->SetFocusedStateTextColor( focusedColor ); |
|
337 twoLineItemVisualizer->SetNormalStateTextColor( normalItemColor ); |
|
338 twoLineItemVisualizer->SetBackgroundColor( headerBgColor ); |
|
339 |
|
340 const RArray<TMessageData>& modelData = iModel->GetModel(); |
|
341 HBufC* resourceString = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_HEADER_DOWNLOAD_MANAGER ); |
|
342 twoLineItemData->SetDataL( *resourceString ); |
|
343 CleanupStack::PopAndDestroy( resourceString ); |
|
344 |
|
345 resourceString = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_HEADER_TOTAL, iModel->AttachmentCount() ); |
|
346 twoLineItemData->SetSecondaryDataL( *resourceString ); |
|
347 CleanupStack::PopAndDestroy( resourceString ); |
|
348 twoLineItemData->SetIcon ( iAppUi.FsTextureManager()->TextureByIndex( EAttachmentIcon ) ); |
|
349 CleanupStack::Pop( twoLineItemVisualizer ); |
|
350 CleanupStack::Pop( twoLineItemData ); |
|
351 iHeaderItemId = iDownloadManagerList->InsertItemL( *twoLineItemData, *twoLineItemVisualizer, KFsTreeRootID ); |
|
352 |
|
353 TFsTreeItemId parentNode; |
|
354 for ( TInt i=0 ; i<modelData.Count() ; i++ ) |
|
355 { |
|
356 CFsTreePlainOneLineNodeData* separatorData = CFsTreePlainOneLineNodeData::NewL(); |
|
357 CleanupStack::PushL( separatorData ); |
|
358 CFsTreePlainOneLineNodeVisualizer* separatorVisualiser = |
|
359 CFsTreePlainOneLineNodeVisualizer::NewL( *iDownloadManagerList->TreeControl() ); |
|
360 CleanupStack::PushL( separatorVisualiser ); |
|
361 separatorData->SetDataL( *modelData[i].mailSubject ); |
|
362 // Set font height |
|
363 separatorVisualiser->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
364 // Set font bolding |
|
365 separatorVisualiser->SetTextBold( ETrue ); |
|
366 // Set correct skin text colors for the list items |
|
367 separatorVisualiser->SetFocusedStateTextColor( focusedColor ); |
|
368 separatorVisualiser->SetNormalStateTextColor( normalNodeColor ); |
|
369 separatorVisualiser->SetBackgroundColor( iAppUi.LayoutHandler()->ListNodeBackgroundColor() ); |
|
370 |
|
371 separatorVisualiser->SetExtendable( EFalse ); |
|
372 separatorData->SetIconExpanded( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeExpanded ) ); |
|
373 separatorData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed ) ); |
|
374 CleanupStack::Pop( separatorVisualiser ); |
|
375 CleanupStack::Pop( separatorData ); |
|
376 parentNode = iDownloadManagerList->InsertNodeL(*separatorData, *separatorVisualiser, KFsTreeRootID); |
|
377 iModel->SetNodeIdL( i, parentNode ); |
|
378 for (TInt j=0; j<modelData[i].mailAttachments.Count(); j++) |
|
379 { |
|
380 twoLineItemData = CFsTreePlainTwoLineItemData::NewL(); |
|
381 CleanupStack::PushL( twoLineItemData ); |
|
382 twoLineItemData->SetDataL( modelData[i].mailAttachments[j].fileName ); |
|
383 |
|
384 HBufC* secondLine = CreateSecondLineTextLC( modelData[i].mailAttachments[j] ); |
|
385 twoLineItemData->SetSecondaryDataL( *secondLine ); |
|
386 CleanupStack::PopAndDestroy( secondLine ); |
|
387 |
|
388 CAlfTexture& itemTexture = TFsEmailUiUtility::GetAttachmentIcon( modelData[i].mailAttachments[j].fileType, |
|
389 *iAppUi.FsTextureManager() ); |
|
390 twoLineItemData->SetIcon( itemTexture ); |
|
391 |
|
392 |
|
393 twoLineItemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL( *iDownloadManagerList->TreeControl()); |
|
394 CleanupStack::PushL( twoLineItemVisualizer ); |
|
395 twoLineItemVisualizer->SetExtendable(ETrue); |
|
396 twoLineItemVisualizer->SetFlags( twoLineItemVisualizer->Flags() | KFsTreeListItemHasMenu ); |
|
397 |
|
398 CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( EFSFontTypeSmall ); |
|
399 twoLineItemVisualizer->SetTextStyleId( textStyle->Id() ); |
|
400 |
|
401 // Set font height |
|
402 twoLineItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
403 // Set font bolding |
|
404 twoLineItemVisualizer->SetTextBold( EFalse ); |
|
405 // Set correct skin text colors for the list items |
|
406 twoLineItemVisualizer->SetFocusedStateTextColor( focusedColor ); |
|
407 twoLineItemVisualizer->SetNormalStateTextColor( normalItemColor ); |
|
408 |
|
409 |
|
410 TFsTreeItemId treeItemId = iDownloadManagerList->InsertItemL( *twoLineItemData, *twoLineItemVisualizer, parentNode); |
|
411 CleanupStack::Pop( twoLineItemVisualizer ); |
|
412 CleanupStack::Pop( twoLineItemData ); |
|
413 |
|
414 iModel->SetItemIdL( i, j, treeItemId ); |
|
415 } |
|
416 } |
|
417 } |
|
418 |
|
419 |
|
420 void CFSEmailUiDownloadManagerVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType ) |
|
421 { |
|
422 FUNC_LOG; |
|
423 iDownloadManagerList->HideListL(); |
|
424 if ( aType == CFsEmailUiViewBase::ESkinChanged ) |
|
425 { |
|
426 ResetColorsL(); |
|
427 iDownloadManagerList->ShowListL(); |
|
428 } |
|
429 else if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged ) |
|
430 { |
|
431 ReScaleUiL(); |
|
432 iDownloadManagerList->ShowListL(); |
|
433 } |
|
434 } |
|
435 |
|
436 void CFSEmailUiDownloadManagerVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType ) |
|
437 { |
|
438 FUNC_LOG; |
|
439 if ( aType == CFsEmailUiViewBase::ESkinChanged ) |
|
440 { |
|
441 ResetColorsL(); |
|
442 } |
|
443 } |
|
444 |
|
445 void CFSEmailUiDownloadManagerVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const |
|
446 { |
|
447 aLayoutArray.AppendL( iListLayout ); |
|
448 } |
|
449 |
|
450 void CFSEmailUiDownloadManagerVisualiser::HandleCommandL( TInt aCommand ) |
|
451 { |
|
452 FUNC_LOG; |
|
453 TFsTreeItemId focusedId = iDownloadManagerList->FocusedItem(); |
|
454 |
|
455 switch(aCommand) |
|
456 { |
|
457 case EFsEmailUiCmdEmpty: // used when focused item is being downloaded |
|
458 case EAknSoftkeyOpen: |
|
459 case EFsEmailUiCmdOpen: |
|
460 { |
|
461 TryToOpenItemL( focusedId ); |
|
462 } |
|
463 break; |
|
464 case EFsEmailUiCmdDownload: |
|
465 { |
|
466 iModel->StartDownloadL(focusedId); |
|
467 } |
|
468 break; |
|
469 case EFsEmailUiCmdDownloadAll: |
|
470 { |
|
471 iModel->DownloadAllAttachmentsL(); |
|
472 } |
|
473 break; |
|
474 case EFsEmailUiCmdCancelDownload: |
|
475 { |
|
476 TInt reallyCancel = |
|
477 TFsEmailUiUtility::ShowConfirmationQueryL( R_FSE_VIEWER_CANCEL_DOWNLOAD_QUERY ); |
|
478 if ( reallyCancel ) |
|
479 { |
|
480 iModel->CancelDownloadL( focusedId ); |
|
481 } |
|
482 } |
|
483 break; |
|
484 case EFsEmailUiCmdCancelAllDownloads: |
|
485 { |
|
486 TInt reallyCancel = |
|
487 TFsEmailUiUtility::ShowConfirmationQueryL( R_FSE_VIEWER_CANCEL_DOWNLOADS_QUERY ); |
|
488 if ( reallyCancel ) |
|
489 { |
|
490 iModel->CancelAllDownloadsL(); |
|
491 } |
|
492 } |
|
493 break; |
|
494 case EFsEmailUiCmdSave: |
|
495 { |
|
496 TFileName fileName; |
|
497 TInt savedCount( 0 ); |
|
498 if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) ) |
|
499 { |
|
500 iModel->SaveAttachmentL( focusedId, fileName, savedCount ); |
|
501 } |
|
502 if ( savedCount ) |
|
503 { |
|
504 TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount ); |
|
505 } |
|
506 } |
|
507 break; |
|
508 case EFsEmailUiCmdSaveAll: |
|
509 { |
|
510 TFileName fileName; |
|
511 if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) ) |
|
512 { |
|
513 iModel->SaveAllAttachmentsL( fileName ); |
|
514 } |
|
515 } |
|
516 break; |
|
517 case EFsEmailUiCmdClearFetchedAttachment: |
|
518 case EFsEmailUiCmdRemoveAttachment: |
|
519 case EFsEmailUiCmdActionsDelete: // from shortcut key |
|
520 { |
|
521 RemoveAttachmentL( focusedId ); |
|
522 } |
|
523 break; |
|
524 case EFsEmailUiCmdMsgDetails: |
|
525 { |
|
526 TPartData messageData = iModel->GetMessageL( focusedId ); |
|
527 |
|
528 TMsgDetailsActivationData msgDetailsData; |
|
529 msgDetailsData.iMailBoxId = messageData.iMailBoxId; |
|
530 msgDetailsData.iFolderId = messageData.iFolderId; |
|
531 msgDetailsData.iMessageId = messageData.iMessageId; |
|
532 |
|
533 const TPckgBuf<TMsgDetailsActivationData> pkgOut( msgDetailsData ); |
|
534 iAppUi.EnterFsEmailViewL( MsgDetailsViewId, KStartMsgDetailsToBeginning, pkgOut ); |
|
535 } |
|
536 break; |
|
537 case EFSEmailUICmdViewMessage: |
|
538 { |
|
539 TPartData messageData = iModel->GetMessageL( focusedId ); |
|
540 |
|
541 TMsgViewerActivationData msgViewerData; |
|
542 msgViewerData.iMailBoxId = messageData.iMailBoxId; |
|
543 msgViewerData.iFolderId = messageData.iFolderId; |
|
544 msgViewerData.iMessageId = messageData.iMessageId; |
|
545 msgViewerData.iDetails = EFSMsgDataStructure; |
|
546 const TPckgBuf<TMsgViewerActivationData> pkgOut( msgViewerData ); |
|
547 iAppUi.EnterFsEmailViewL( MailViewerId, KStartViewerWithMsgId, pkgOut ); |
|
548 } |
|
549 break; |
|
550 case EFsEmailUiCmdExit: |
|
551 { |
|
552 iAppUi.Exit(); |
|
553 } |
|
554 break; |
|
555 case EAknSoftkeyBack: |
|
556 { |
|
557 if ( !iAppUi.ViewSwitchingOngoing() ) |
|
558 { |
|
559 iAppUi.ReturnToPreviousViewL(); |
|
560 } |
|
561 } |
|
562 break; |
|
563 |
|
564 case EFsEmailUiCmdCollapse: |
|
565 { |
|
566 iDownloadManagerList->CollapseNodeL( focusedId ); |
|
567 ChangeMskCommandL( R_FSE_QTN_MSK_EXPAND ); |
|
568 } |
|
569 break; |
|
570 |
|
571 case EFsEmailUiCmdExpand: |
|
572 { |
|
573 iDownloadManagerList->ExpandNodeL( focusedId ); |
|
574 ChangeMskCommandL( R_FSE_QTN_MSK_COLLAPSE ); |
|
575 } |
|
576 break; |
|
577 case EFsEmailUiCmdActionsCollapseExpandAllToggle: |
|
578 { |
|
579 ShortcutCollapseExpandAllToggleL(); |
|
580 } |
|
581 break; |
|
582 case EFsEmailUiCmdGoToTop: |
|
583 { |
|
584 GoToTopL(); |
|
585 } |
|
586 break; |
|
587 case EFsEmailUiCmdGoToBottom: |
|
588 { |
|
589 GoToBottomL(); |
|
590 } |
|
591 break; |
|
592 case EFsEmailUiCmdPageUp: |
|
593 { |
|
594 TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 }; |
|
595 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey ); |
|
596 } |
|
597 break; |
|
598 case EFsEmailUiCmdPageDown: |
|
599 { |
|
600 TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 }; |
|
601 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey ); |
|
602 } |
|
603 break; |
|
604 case EFsEmailUiCmdHelp: |
|
605 { |
|
606 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID ); |
|
607 } |
|
608 break; |
|
609 default: |
|
610 break; |
|
611 } |
|
612 } |
|
613 |
|
614 void CFSEmailUiDownloadManagerVisualiser::SetMskL() |
|
615 { |
|
616 FUNC_LOG; |
|
617 TFsTreeItemId curId = iDownloadManagerList->FocusedItem(); |
|
618 if ( curId ) |
|
619 { |
|
620 if( iDownloadManagerList->IsNode( curId ) ) |
|
621 { |
|
622 if (iDownloadManagerList->IsExpanded( curId ) ) |
|
623 { |
|
624 ChangeMskCommandL( R_FSE_QTN_MSK_COLLAPSE ); |
|
625 } |
|
626 else |
|
627 { |
|
628 ChangeMskCommandL( R_FSE_QTN_MSK_EXPAND ); |
|
629 } |
|
630 } |
|
631 else // non-node item |
|
632 { |
|
633 TAttachmentData* selectedItem = iModel->GetItem( iDownloadManagerList->FocusedItem()); |
|
634 if ( selectedItem && IsCommandAvailableOnItem( EFsEmailUiCmdDownload, selectedItem ) ) |
|
635 { |
|
636 ChangeMskCommandL( R_FSE_QTN_MSK_DOWNLOAD ); |
|
637 } |
|
638 else if ( selectedItem && IsCommandAvailableOnItem( EFsEmailUiCmdOpen, selectedItem ) ) |
|
639 { |
|
640 ChangeMskCommandL( R_FSE_QTN_MSK_OPEN ); |
|
641 } |
|
642 else |
|
643 { |
|
644 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
645 } |
|
646 } |
|
647 } |
|
648 else |
|
649 { |
|
650 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
651 } |
|
652 } |
|
653 |
|
654 TBool CFSEmailUiDownloadManagerVisualiser::OfferEventL(const TAlfEvent& aEvent) |
|
655 { |
|
656 FUNC_LOG; |
|
657 TBool result( EFalse ); |
|
658 SetMskL(); |
|
659 if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey ) |
|
660 { |
|
661 TInt scanCode = aEvent.KeyEvent().iScanCode; |
|
662 // Swap right and left controls in mirrored layout |
|
663 if ( AknLayoutUtils::LayoutMirrored() ) |
|
664 { |
|
665 if (scanCode == EStdKeyRightArrow) scanCode = EStdKeyLeftArrow; |
|
666 else if (scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow; |
|
667 } |
|
668 |
|
669 if ( scanCode == EStdKeyRightArrow ) |
|
670 { |
|
671 LaunchActionMenuL(); |
|
672 result = ETrue; |
|
673 } |
|
674 else |
|
675 { |
|
676 // Check keyboard shortcuts. |
|
677 TInt shortcutCommand = |
|
678 iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(), |
|
679 CFSEmailUiShortcutBinding::EContextDownloadManager ); |
|
680 if ( shortcutCommand != KErrNotFound ) |
|
681 { |
|
682 HandleCommandL( shortcutCommand ); |
|
683 result = ETrue; |
|
684 } |
|
685 } |
|
686 } |
|
687 |
|
688 /* |
|
689 if (!result) |
|
690 { |
|
691 result = iDownloadManagerList->TreeControl()->OfferEventL(aEvent); |
|
692 } |
|
693 */ |
|
694 return result; |
|
695 } |
|
696 |
|
697 void CFSEmailUiDownloadManagerVisualiser::ReScaleUiL() |
|
698 { |
|
699 FUNC_LOG; |
|
700 TInt fontHeight = iAppUi.LayoutHandler()->ListItemFontHeightInTwips(); |
|
701 |
|
702 // Header item |
|
703 TFsTreeItemId headerId = iDownloadManagerList->Child( KFsTreeRootID, 0 ); |
|
704 MFsTreeItemVisualizer& headerVis = iDownloadManagerList->ItemVisualizer( headerId ); |
|
705 headerVis.SetFontHeight( fontHeight ); |
|
706 |
|
707 // Mail nodes and attachment items |
|
708 const RArray<TMessageData>& modelData = iModel->GetModel(); |
|
709 for ( TInt i=0 ; i<modelData.Count() ; ++i ) |
|
710 { |
|
711 const TMessageData& message = modelData[ i ]; |
|
712 |
|
713 MFsTreeItemVisualizer& messageVis = iDownloadManagerList->ItemVisualizer( message.treeId ); |
|
714 messageVis.SetFontHeight( fontHeight ); |
|
715 |
|
716 for ( TInt j=0 ; j<message.mailAttachments.Count() ; j++ ) |
|
717 { |
|
718 const TAttachmentData& attachment = message.mailAttachments[j]; |
|
719 |
|
720 MFsTreeItemVisualizer& attachmentVis = iDownloadManagerList->ItemVisualizer( attachment.treeId ); |
|
721 attachmentVis.SetFontHeight( fontHeight ); |
|
722 } |
|
723 } |
|
724 } |
|
725 |
|
726 void CFSEmailUiDownloadManagerVisualiser::ResetColorsL() |
|
727 { |
|
728 FUNC_LOG; |
|
729 TRgb normalTextColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
730 TRgb focusedTextColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
731 TRgb nodeTextColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
|
732 TRgb nodeBgColor = iAppUi.LayoutHandler()->ListNodeBackgroundColor(); |
|
733 TRgb headerBgColor = iAppUi.LayoutHandler()->ListHeaderBackgroundColor(); |
|
734 |
|
735 // Header item |
|
736 TFsTreeItemId headerId = iDownloadManagerList->Child( KFsTreeRootID, 0 ); |
|
737 MFsTreeItemVisualizer& headerVis = iDownloadManagerList->ItemVisualizer( headerId ); |
|
738 headerVis.SetNormalStateTextColor( normalTextColor ); |
|
739 headerVis.SetFocusedStateTextColor( focusedTextColor ); |
|
740 headerVis.SetBackgroundColor( headerBgColor ); |
|
741 |
|
742 // Mail nodes and attachment items |
|
743 const RArray<TMessageData>& modelData = iModel->GetModel(); |
|
744 for ( TInt i=0 ; i<modelData.Count() ; ++i ) |
|
745 { |
|
746 const TMessageData& message = modelData[ i ]; |
|
747 |
|
748 MFsTreeItemVisualizer& messageVis = iDownloadManagerList->ItemVisualizer( message.treeId ); |
|
749 messageVis.SetNormalStateTextColor( nodeTextColor ); |
|
750 messageVis.SetFocusedStateTextColor( focusedTextColor ); |
|
751 messageVis.SetBackgroundColor( nodeBgColor ); |
|
752 |
|
753 for ( TInt j=0 ; j<message.mailAttachments.Count() ; j++ ) |
|
754 { |
|
755 const TAttachmentData& attachment = message.mailAttachments[j]; |
|
756 |
|
757 MFsTreeItemVisualizer& attachmentVis = iDownloadManagerList->ItemVisualizer( attachment.treeId ); |
|
758 attachmentVis.SetNormalStateTextColor( normalTextColor ); |
|
759 attachmentVis.SetFocusedStateTextColor( focusedTextColor ); |
|
760 } |
|
761 } |
|
762 } |
|
763 |
|
764 CAlfControl* CFSEmailUiDownloadManagerVisualiser::ViewerControl() |
|
765 { |
|
766 FUNC_LOG; |
|
767 return iScreenControl; |
|
768 } |
|
769 |
|
770 TBool CFSEmailUiDownloadManagerVisualiser::IsCommandAvailableOnItem( TInt aCommandId, |
|
771 const TAttachmentData* aFocusedItem ) const |
|
772 { |
|
773 FUNC_LOG; |
|
774 TBool available = EFalse; |
|
775 |
|
776 const RArray<TMessageData>& model = iModel->GetModel(); |
|
777 |
|
778 switch ( aCommandId ) |
|
779 { |
|
780 case EFsEmailUiCmdOpen: |
|
781 case FsEActionAttachmentOpen: |
|
782 // <cmail> Disabled until plugins support this. |
|
783 //case EFsEmailUiCmdClearFetchedAttachment: |
|
784 //case FsEActionAttachmentClearFetchedContent: |
|
785 // </cmail> |
|
786 { |
|
787 if ( aFocusedItem && aFocusedItem->downloadProgress == KComplete ) |
|
788 { |
|
789 available = ETrue; |
|
790 } |
|
791 } |
|
792 break; |
|
793 |
|
794 // <cmail> |
|
795 case FsEActionAttachmentClearFetchedContent: |
|
796 case EFsEmailUiCmdClearFetchedAttachment: |
|
797 available = EFalse; |
|
798 break; |
|
799 // </cmail> |
|
800 |
|
801 case EFsEmailUiCmdDownload: |
|
802 case FsEActionAttachmentDownload: |
|
803 case EFsEmailUiCmdRemoveAttachment: |
|
804 case FsEActionAttachmentRemoveUnfetchedAttachment: |
|
805 { |
|
806 if ( iAppUi.DownloadInfoMediator() && aFocusedItem && aFocusedItem->downloadProgress == KNone && |
|
807 !iAppUi.DownloadInfoMediator()->IsDownloading( aFocusedItem->partData.iMessagePartId ) ) |
|
808 { |
|
809 available = ETrue; |
|
810 } |
|
811 } |
|
812 break; |
|
813 |
|
814 case EFsEmailUiCmdCancelDownload: |
|
815 case FsEActionAttachmentCancelDownload: |
|
816 { |
|
817 if ( iAppUi.DownloadInfoMediator() && aFocusedItem && |
|
818 iAppUi.DownloadInfoMediator()->IsDownloading( aFocusedItem->partData.iMessagePartId ) ) |
|
819 { |
|
820 available = ETrue; |
|
821 } |
|
822 } |
|
823 break; |
|
824 |
|
825 case EFsEmailUiCmdSave: |
|
826 case FsEActionAttachmentSave: |
|
827 { |
|
828 if ( iAppUi.DownloadInfoMediator() && aFocusedItem && |
|
829 !iAppUi.DownloadInfoMediator()->IsDownloading( aFocusedItem->partData.iMessagePartId ) ) |
|
830 { |
|
831 available = ETrue; |
|
832 } |
|
833 } |
|
834 break; |
|
835 |
|
836 case EFsEmailUiCmdSaveAll: |
|
837 case FsEActionAttachmentSaveAll: |
|
838 { |
|
839 // Save all is available if there is more than one attachment |
|
840 // and none of them are currently being downloaded |
|
841 if ( iModel->AttachmentCount() > 1 ) |
|
842 { |
|
843 available = ETrue; |
|
844 for ( TInt i=0; i<model.Count(); i++) |
|
845 { |
|
846 const RArray<TAttachmentData>& attachments = model[i].mailAttachments; |
|
847 for ( TInt j=0 ; j<attachments.Count() ; ++j ) |
|
848 { |
|
849 if ( iAppUi.DownloadInfoMediator() && |
|
850 iAppUi.DownloadInfoMediator()->IsDownloading( attachments[j].partData.iMessagePartId ) ) |
|
851 { |
|
852 available = EFalse; |
|
853 break; |
|
854 } |
|
855 } |
|
856 } |
|
857 } |
|
858 } |
|
859 break; |
|
860 |
|
861 case EFsEmailUiCmdCancelAllDownloads: |
|
862 case FsEActionAttachmentCancelAllDownloads: |
|
863 { |
|
864 // Cancel all is available if there is more than one ongoing download |
|
865 TInt downloads = 0; |
|
866 for ( TInt i=0; i<model.Count(); i++) |
|
867 { |
|
868 const RArray<TAttachmentData>& attachments = model[i].mailAttachments; |
|
869 for ( TInt j=0 ; j<attachments.Count() ; ++j ) |
|
870 { |
|
871 if ( iAppUi.DownloadInfoMediator() && |
|
872 iAppUi.DownloadInfoMediator()->IsDownloading( attachments[j].partData.iMessagePartId ) ) |
|
873 { |
|
874 downloads++; |
|
875 } |
|
876 } |
|
877 } |
|
878 if ( downloads > 1 ) |
|
879 { |
|
880 available = ETrue; |
|
881 } |
|
882 } |
|
883 break; |
|
884 |
|
885 case EFsEmailUiCmdDownloadAll: |
|
886 case FsEActionAttachmentDownloadAll: |
|
887 { |
|
888 // Download all is available there is more than one attachments for which |
|
889 // "Download" command is available. |
|
890 TInt downloadableFiles = 0; |
|
891 for ( TInt i=0; i<model.Count(); i++) |
|
892 { |
|
893 const RArray<TAttachmentData>& attachments = model[i].mailAttachments; |
|
894 for ( TInt j=0 ; j<attachments.Count() ; ++j ) |
|
895 { |
|
896 if ( IsCommandAvailableOnItem( EFsEmailUiCmdDownload, &attachments[j] ) ) |
|
897 { |
|
898 downloadableFiles++; |
|
899 } |
|
900 } |
|
901 } |
|
902 if ( downloadableFiles > 1 ) |
|
903 { |
|
904 available = ETrue; |
|
905 } |
|
906 } |
|
907 break; |
|
908 |
|
909 case EFsEmailUiCmdMailActions: |
|
910 { |
|
911 // Actions menu is available if any sub item is available |
|
912 available = |
|
913 IsCommandAvailableOnItem( EFsEmailUiCmdOpen, aFocusedItem ) || |
|
914 IsCommandAvailableOnItem( EFsEmailUiCmdDownload, aFocusedItem ) || |
|
915 IsCommandAvailableOnItem( EFsEmailUiCmdCancelDownload, aFocusedItem ) || |
|
916 IsCommandAvailableOnItem( EFsEmailUiCmdSave, aFocusedItem ) || |
|
917 IsCommandAvailableOnItem( EFsEmailUiCmdDownloadAll, aFocusedItem ) || |
|
918 IsCommandAvailableOnItem( EFsEmailUiCmdCancelAllDownloads, aFocusedItem ) || |
|
919 IsCommandAvailableOnItem( EFsEmailUiCmdSaveAll, aFocusedItem ) || |
|
920 IsCommandAvailableOnItem( EFsEmailUiCmdClearFetchedAttachment, aFocusedItem ); |
|
921 } |
|
922 break; |
|
923 |
|
924 default: |
|
925 // All commands not separately specified are always available |
|
926 available = ETrue; |
|
927 break; |
|
928 } |
|
929 |
|
930 return available; |
|
931 } |
|
932 |
|
933 HBufC* CFSEmailUiDownloadManagerVisualiser::CreateSecondLineTextLC( const TAttachmentData& aAttachment ) const |
|
934 { |
|
935 FUNC_LOG; |
|
936 // File extension |
|
937 TPtrC extString = TParsePtrC( aAttachment.fileName ).Ext(); |
|
938 // It seems to vary if preceeding dot is included in the file extension. Remove it if present. |
|
939 if ( extString.Length() && extString[0] == '.' ) |
|
940 { |
|
941 extString.Set( extString.Mid(1) ); |
|
942 } |
|
943 |
|
944 // File size |
|
945 HBufC* sizeString = iModel->CreateSizeDescLC( aAttachment.fileSize ); |
|
946 |
|
947 // Download progress |
|
948 HBufC* progressString = NULL; |
|
949 if ( iAppUi.DownloadInfoMediator() && iAppUi.DownloadInfoMediator()->IsDownloading( aAttachment.partData.iMessagePartId ) ) |
|
950 { |
|
951 progressString = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_LIST_DOWNLOADING, aAttachment.downloadProgress ); |
|
952 } |
|
953 else if ( aAttachment.downloadProgress == KComplete ) |
|
954 { |
|
955 progressString = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_LIST_DOWNLOADED_100 ); |
|
956 } |
|
957 else |
|
958 { |
|
959 progressString = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_LIST_DOWNLOADING_CANCELLED ); |
|
960 } |
|
961 |
|
962 // Combine the accumulated data to one buffer |
|
963 HBufC* result = HBufC::NewL( extString.Length() + |
|
964 KSpace().Length() + |
|
965 sizeString->Length() + |
|
966 KSpace().Length() + |
|
967 progressString->Length() ); |
|
968 TPtr resultPtr = result->Des(); |
|
969 resultPtr.Append( extString ); |
|
970 resultPtr.Append( KSpace ); |
|
971 resultPtr.Append( *sizeString ); |
|
972 resultPtr.Append( KSpace ); |
|
973 resultPtr.Append( *progressString ); |
|
974 |
|
975 CleanupStack::PopAndDestroy( progressString ); |
|
976 CleanupStack::PopAndDestroy( sizeString ); |
|
977 |
|
978 CleanupStack::PushL( result ); |
|
979 return result; |
|
980 } |
|
981 |
|
982 // --------------------------------------------------------------------------- |
|
983 // Attempt to open the focused item. Start downloading if the item is not |
|
984 // downloaded or show note if it's currently being downloaded. |
|
985 // --------------------------------------------------------------------------- |
|
986 // |
|
987 void CFSEmailUiDownloadManagerVisualiser::TryToOpenItemL( TFsTreeItemId aId ) |
|
988 { |
|
989 FUNC_LOG; |
|
990 TAttachmentData* attachment = NULL; |
|
991 |
|
992 TRAPD( err, attachment = &iModel->GetItemL( aId ) ); |
|
993 |
|
994 if( !err ) |
|
995 { |
|
996 if ( attachment ) |
|
997 { |
|
998 if ( iModel->IsDownloading( *attachment ) ) |
|
999 { |
|
1000 TFsEmailUiUtility::ShowInfoNoteL( R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS ); |
|
1001 } |
|
1002 else if ( attachment->downloadProgress != KComplete ) |
|
1003 { |
|
1004 TInt restartDownload = |
|
1005 TFsEmailUiUtility::ShowConfirmationQueryL( R_FSE_VIEWER_NOTE_ATTACHMENT_RESTART_DOWNLOADING ); |
|
1006 if ( restartDownload ) |
|
1007 { |
|
1008 HandleCommandL( EFsEmailUiCmdDownload ); |
|
1009 } |
|
1010 } |
|
1011 else |
|
1012 { |
|
1013 TFsEmailUiUtility::OpenAttachmentL( attachment->partData ); |
|
1014 } |
|
1015 } |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // Show confirmation note and remove contents of given attachment item |
|
1021 // if user accepts. Does nothing if given ID doesn't match an attachment item. |
|
1022 // --------------------------------------------------------------------------- |
|
1023 // |
|
1024 void CFSEmailUiDownloadManagerVisualiser::RemoveAttachmentL( TFsTreeItemId aId ) |
|
1025 { |
|
1026 FUNC_LOG; |
|
1027 TAttachmentData* item = iModel->GetItem( aId ); |
|
1028 |
|
1029 // show confirmation note only when removing fully fetched attachment |
|
1030 TInt reallyClear = EFalse; |
|
1031 if ( IsCommandAvailableOnItem( EFsEmailUiCmdClearFetchedAttachment, item ) ) |
|
1032 { |
|
1033 reallyClear = TFsEmailUiUtility::ShowConfirmationQueryL( R_FSE_VIEWER_CLEAR_FETCHED_QUERY ); |
|
1034 } |
|
1035 else if ( IsCommandAvailableOnItem( EFsEmailUiCmdRemoveAttachment, item ) ) |
|
1036 { |
|
1037 reallyClear = ETrue; |
|
1038 } |
|
1039 |
|
1040 if ( reallyClear ) |
|
1041 { |
|
1042 iModel->RemoveContentL( aId ); |
|
1043 // Remove item from DM only if contents were actually |
|
1044 // removed succesfully |
|
1045 if ( !iModel->IsCompletelyDownloadedL( *item ) ) |
|
1046 { |
|
1047 // remove model item, message item is also removed automatically if it becomes empty |
|
1048 iModel->RemoveItem( aId ); |
|
1049 |
|
1050 // remove list item |
|
1051 TFsTreeItemId parentId = iDownloadManagerList->Parent( aId ); |
|
1052 iDownloadManagerList->RemoveL( aId ); |
|
1053 // remove also the message node if it became empty |
|
1054 if ( iDownloadManagerList->IsEmpty(parentId) ) |
|
1055 { |
|
1056 iDownloadManagerList->RemoveL( parentId ); |
|
1057 } |
|
1058 |
|
1059 // focused item has changed => change MSK function |
|
1060 SetMskL(); |
|
1061 |
|
1062 // update title item |
|
1063 HBufC* attCountText = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_HEADER_TOTAL, iModel->AttachmentCount() ); |
|
1064 CFsTreePlainTwoLineItemData& headerData = |
|
1065 static_cast<CFsTreePlainTwoLineItemData&>( iDownloadManagerList->ItemData(iHeaderItemId) ); |
|
1066 headerData.SetSecondaryDataL( *attCountText ); |
|
1067 CleanupStack::PopAndDestroy( attCountText ); |
|
1068 iDownloadManagerTreeListVisualizer->UpdateItemL( iHeaderItemId ); |
|
1069 } |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 void CFSEmailUiDownloadManagerVisualiser::DownloadStatusChangedL( TInt aIndex ) |
|
1074 { |
|
1075 FUNC_LOG; |
|
1076 if ( iAppUi.CurrentActiveView() == this && |
|
1077 aIndex < iModel->GetModel().Count() && |
|
1078 !iAppUi.AppUiExitOngoing() ) |
|
1079 { |
|
1080 TRect screenRect; |
|
1081 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
1082 |
|
1083 TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
1084 TRgb normalItemColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); |
|
1085 TRgb normalNodeColor = iAppUi.LayoutHandler()->ListNodeTextColor(); |
|
1086 |
|
1087 const RArray<TMessageData>& modelData = iModel->GetModel(); |
|
1088 const TMessageData& message = modelData[ aIndex ]; |
|
1089 |
|
1090 // Insert the message node if it's not yet present |
|
1091 if ( message.treeId == KFsTreeNoneID ) |
|
1092 { |
|
1093 CFsTreePlainOneLineNodeData* separatorData = CFsTreePlainOneLineNodeData::NewL(); |
|
1094 CleanupStack::PushL( separatorData ); |
|
1095 CFsTreePlainOneLineNodeVisualizer* separatorVisualiser = |
|
1096 CFsTreePlainOneLineNodeVisualizer::NewL(*iDownloadManagerList->TreeControl()); |
|
1097 CleanupStack::PushL( separatorVisualiser ); |
|
1098 separatorData->SetDataL( *message.mailSubject ); |
|
1099 separatorVisualiser->SetExtendable(EFalse); |
|
1100 separatorVisualiser->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
1101 separatorVisualiser->SetTextBold( ETrue ); |
|
1102 separatorVisualiser->SetFocusedStateTextColor( focusedColor ); |
|
1103 separatorVisualiser->SetNormalStateTextColor( normalNodeColor ); |
|
1104 separatorVisualiser->SetBackgroundColor( iAppUi.LayoutHandler()->ListNodeBackgroundColor() ); |
|
1105 |
|
1106 separatorData->SetIconExpanded( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeExpanded ) ); |
|
1107 separatorData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed ) ); |
|
1108 CleanupStack::Pop( separatorVisualiser ); |
|
1109 CleanupStack::Pop( separatorData ); |
|
1110 TFsTreeItemId parentNode = |
|
1111 iDownloadManagerList->InsertNodeL( *separatorData, *separatorVisualiser, KFsTreeRootID, aIndex ); |
|
1112 iModel->SetNodeIdL( aIndex, parentNode ); |
|
1113 } |
|
1114 |
|
1115 // Insert or update the attachment items |
|
1116 for ( TInt j = 0 ; j < message.mailAttachments.Count() ; j++ ) |
|
1117 { |
|
1118 HBufC* secondLine = CreateSecondLineTextLC( message.mailAttachments[j] ); |
|
1119 |
|
1120 //is the item already drawn |
|
1121 TFsTreeItemId itemId = message.mailAttachments[j].treeId; |
|
1122 if ( itemId != KFsTreeNoneID ) |
|
1123 { |
|
1124 // Item is already present. Update the existing item but only if the second line data |
|
1125 // is actually changed. |
|
1126 CFsTreePlainTwoLineItemData& itemData = |
|
1127 static_cast<CFsTreePlainTwoLineItemData&>( iDownloadManagerList->ItemData( itemId ) ); |
|
1128 |
|
1129 if ( itemData.SecondaryData() != *secondLine ) |
|
1130 { |
|
1131 itemData.SetSecondaryDataL( *secondLine ); |
|
1132 iDownloadManagerTreeListVisualizer->UpdateItemL( itemId ); |
|
1133 |
|
1134 // Update the MSK label if the updated item happens to be the focused item |
|
1135 if ( itemId == iDownloadManagerList->FocusedItem() ) |
|
1136 { |
|
1137 SetMskL(); |
|
1138 } |
|
1139 } |
|
1140 } |
|
1141 else |
|
1142 { |
|
1143 //create and draw new item |
|
1144 CFsTreePlainTwoLineItemData* twoLineItemData = CFsTreePlainTwoLineItemData::NewL(); |
|
1145 CleanupStack::PushL( twoLineItemData ); |
|
1146 |
|
1147 twoLineItemData->SetDataL( message.mailAttachments[j].fileName ); |
|
1148 twoLineItemData->SetSecondaryDataL( *secondLine ); |
|
1149 |
|
1150 CAlfTexture& itemTexture = TFsEmailUiUtility::GetAttachmentIcon( message.mailAttachments[j].fileType, |
|
1151 *iAppUi.FsTextureManager() ); |
|
1152 twoLineItemData->SetIcon( itemTexture ); |
|
1153 |
|
1154 CFsTreePlainTwoLineItemVisualizer* twoLineItemVisualizer = |
|
1155 CFsTreePlainTwoLineItemVisualizer::NewL( *iDownloadManagerList->TreeControl() ); |
|
1156 CleanupStack::PushL( twoLineItemVisualizer ); |
|
1157 twoLineItemVisualizer->SetFlags( twoLineItemVisualizer->Flags() | KFsTreeListItemHasMenu ); |
|
1158 twoLineItemVisualizer->SetExtendable( ETrue ); |
|
1159 CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( EFSFontTypeSmall ); |
|
1160 twoLineItemVisualizer->SetTextStyleId( textStyle->Id() ); |
|
1161 // Set font height |
|
1162 twoLineItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() ); |
|
1163 // Set font bolding |
|
1164 twoLineItemVisualizer->SetTextBold( EFalse ); |
|
1165 // Set correct skin text colors for the list items |
|
1166 twoLineItemVisualizer->SetFocusedStateTextColor( focusedColor ); |
|
1167 twoLineItemVisualizer->SetNormalStateTextColor( normalItemColor ); |
|
1168 TFsTreeItemId treeItemId = |
|
1169 iDownloadManagerList->InsertItemL( *twoLineItemData, *twoLineItemVisualizer, message.treeId, j ); |
|
1170 CleanupStack::Pop( twoLineItemVisualizer ); // ownership transferred to TreeList |
|
1171 CleanupStack::Pop( twoLineItemData ); // ownership transferred to TreeList |
|
1172 iModel->SetItemIdL( aIndex, j, treeItemId ); |
|
1173 } |
|
1174 |
|
1175 CleanupStack::PopAndDestroy( secondLine ); |
|
1176 } |
|
1177 } |
|
1178 } |
|
1179 |
|
1180 // <cmail> Touch |
|
1181 void CFSEmailUiDownloadManagerVisualiser::TreeListEventL( |
|
1182 const TFsTreeListEvent aEvent, const TFsTreeItemId aId ) |
|
1183 // </cmail> |
|
1184 { |
|
1185 FUNC_LOG; |
|
1186 if ( aEvent == EFsTreeItemSelected ) |
|
1187 { |
|
1188 TRAPD( err, TryToOpenItemL( aId ) ); |
|
1189 if ( err != KErrNone ) |
|
1190 { |
|
1191 } |
|
1192 } |
|
1193 } |
|
1194 |
|
1195 void CFSEmailUiDownloadManagerVisualiser::LaunchActionMenuL() |
|
1196 { |
|
1197 FUNC_LOG; |
|
1198 |
|
1199 TAttachmentData* selectedItem = NULL; |
|
1200 |
|
1201 TRAPD( err, selectedItem = &iModel->GetItemL( iDownloadManagerList->FocusedItem() ) ); |
|
1202 |
|
1203 if ( !err ) |
|
1204 { |
|
1205 // Remove old items from action menu |
|
1206 CFSEmailUiActionMenu::RemoveAllL(); |
|
1207 |
|
1208 // Construct item list |
|
1209 RFsEActionMenuIdList itemList; |
|
1210 CleanupClosePushL( itemList ); |
|
1211 |
|
1212 if ( IsCommandAvailableOnItem( FsEActionAttachmentOpen, selectedItem ) ) |
|
1213 { |
|
1214 itemList.AppendL( FsEActionAttachmentOpen ); |
|
1215 } |
|
1216 |
|
1217 if ( IsCommandAvailableOnItem( FsEActionAttachmentDownload, selectedItem ) ) |
|
1218 { |
|
1219 itemList.AppendL( FsEActionAttachmentDownload ); |
|
1220 } |
|
1221 |
|
1222 if ( IsCommandAvailableOnItem( FsEActionAttachmentDownloadAll, selectedItem ) ) |
|
1223 { |
|
1224 itemList.AppendL( FsEActionAttachmentDownloadAll ); |
|
1225 } |
|
1226 |
|
1227 if ( IsCommandAvailableOnItem( FsEActionAttachmentCancelDownload, selectedItem ) ) |
|
1228 { |
|
1229 itemList.AppendL( FsEActionAttachmentCancelDownload ); |
|
1230 } |
|
1231 |
|
1232 if ( IsCommandAvailableOnItem( FsEActionAttachmentCancelAllDownloads, selectedItem ) ) |
|
1233 { |
|
1234 itemList.AppendL( FsEActionAttachmentCancelAllDownloads ); |
|
1235 } |
|
1236 |
|
1237 if ( IsCommandAvailableOnItem( FsEActionAttachmentSave, selectedItem ) ) |
|
1238 { |
|
1239 itemList.AppendL( FsEActionAttachmentSave ); |
|
1240 } |
|
1241 |
|
1242 if ( IsCommandAvailableOnItem( FsEActionAttachmentSaveAll, selectedItem ) ) |
|
1243 { |
|
1244 itemList.AppendL( FsEActionAttachmentSaveAll ); |
|
1245 } |
|
1246 |
|
1247 if ( IsCommandAvailableOnItem( FsEActionAttachmentClearFetchedContent, selectedItem ) ) |
|
1248 { |
|
1249 itemList.AppendL( FsEActionAttachmentClearFetchedContent ); |
|
1250 } |
|
1251 |
|
1252 if ( IsCommandAvailableOnItem( FsEActionAttachmentRemoveUnfetchedAttachment, selectedItem ) ) |
|
1253 { |
|
1254 itemList.AppendL( FsEActionAttachmentRemoveUnfetchedAttachment ); |
|
1255 } |
|
1256 |
|
1257 // Execute action list and handle the menu command |
|
1258 TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList ); |
|
1259 |
|
1260 CleanupStack::PopAndDestroy( &itemList ); |
|
1261 |
|
1262 switch( itemId ) |
|
1263 { |
|
1264 case FsEActionAttachmentOpen: |
|
1265 HandleCommandL( EFsEmailUiCmdOpen ); |
|
1266 break; |
|
1267 case FsEActionAttachmentDownload: |
|
1268 HandleCommandL( EFsEmailUiCmdDownload ); |
|
1269 break; |
|
1270 case FsEActionAttachmentCancelDownload: |
|
1271 HandleCommandL( EFsEmailUiCmdCancelDownload ); |
|
1272 break; |
|
1273 case FsEActionAttachmentSave: |
|
1274 HandleCommandL( EFsEmailUiCmdSave ); |
|
1275 break; |
|
1276 case FsEActionAttachmentDownloadAll: |
|
1277 HandleCommandL( EFsEmailUiCmdDownloadAll ); |
|
1278 break; |
|
1279 case FsEActionAttachmentCancelAllDownloads: |
|
1280 HandleCommandL( EFsEmailUiCmdCancelAllDownloads ); |
|
1281 break; |
|
1282 case FsEActionAttachmentSaveAll: |
|
1283 HandleCommandL( EFsEmailUiCmdSaveAll ); |
|
1284 break; |
|
1285 case FsEActionAttachmentClearFetchedContent: |
|
1286 HandleCommandL( EFsEmailUiCmdClearFetchedAttachment ); |
|
1287 break; |
|
1288 case FsEActionAttachmentRemoveUnfetchedAttachment: |
|
1289 HandleCommandL( EFsEmailUiCmdRemoveAttachment ); |
|
1290 break; |
|
1291 default: |
|
1292 break; |
|
1293 } |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 // --------------------------------------------------------------------------- |
|
1298 // If there is one or more expanded nodes, collapses all nodes. |
|
1299 // Otherwise expands all nodes. |
|
1300 // --------------------------------------------------------------------------- |
|
1301 // |
|
1302 void CFSEmailUiDownloadManagerVisualiser::ShortcutCollapseExpandAllToggleL() |
|
1303 { |
|
1304 FUNC_LOG; |
|
1305 TBool collapseAllNodes( EFalse ); |
|
1306 TInt count = iDownloadManagerList->CountChildren( KFsTreeRootID ); |
|
1307 for ( TInt i=0 ; i<count ; i++ ) |
|
1308 { |
|
1309 TFsTreeItemId curId = iDownloadManagerList->Child(KFsTreeRootID, i); |
|
1310 if ( iDownloadManagerList->IsNode( curId ) && |
|
1311 iDownloadManagerList->IsExpanded( curId ) ) |
|
1312 { |
|
1313 collapseAllNodes = ETrue; |
|
1314 break; |
|
1315 } |
|
1316 } |
|
1317 |
|
1318 if ( collapseAllNodes ) |
|
1319 { |
|
1320 iDownloadManagerTreeListVisualizer->CollapseAllL(); |
|
1321 } |
|
1322 else |
|
1323 { |
|
1324 TFsTreeItemId prevId = iDownloadManagerList->FocusedItem(); // the focus may fall out of the screen unless manually reset |
|
1325 iDownloadManagerTreeListVisualizer->ExpandAllL(); |
|
1326 iDownloadManagerTreeListVisualizer->SetFocusedItemL( prevId ); |
|
1327 } |
|
1328 } |
|
1329 |
|
1330 // --------------------------------------------------------------------------- |
|
1331 // Moves the focus to the topmost item |
|
1332 // --------------------------------------------------------------------------- |
|
1333 // |
|
1334 void CFSEmailUiDownloadManagerVisualiser::GoToTopL() |
|
1335 { |
|
1336 FUNC_LOG; |
|
1337 TInt topLevelCount = iDownloadManagerList->CountChildren( KFsTreeRootID ); |
|
1338 if ( topLevelCount > 1 ) |
|
1339 { |
|
1340 // the item #0 is the non-focusable header item |
|
1341 TFsTreeItemId topId = iDownloadManagerList->Child(KFsTreeRootID, 1); |
|
1342 iDownloadManagerTreeListVisualizer->SetFocusedItemL( topId ); |
|
1343 } |
|
1344 } |
|
1345 |
|
1346 // --------------------------------------------------------------------------- |
|
1347 // Moves the focus to the bottommost item |
|
1348 // --------------------------------------------------------------------------- |
|
1349 // |
|
1350 void CFSEmailUiDownloadManagerVisualiser::GoToBottomL() |
|
1351 { |
|
1352 FUNC_LOG; |
|
1353 TInt topLevelCount = iDownloadManagerList->CountChildren( KFsTreeRootID ); |
|
1354 if ( topLevelCount ) |
|
1355 { |
|
1356 TFsTreeItemId bottomId = iDownloadManagerList->Child(KFsTreeRootID, topLevelCount-1); |
|
1357 if ( iDownloadManagerList->IsNode(bottomId) ) |
|
1358 { |
|
1359 TInt childCount = iDownloadManagerList->CountChildren(bottomId); |
|
1360 if ( childCount && iDownloadManagerList->IsExpanded(bottomId) ) |
|
1361 { |
|
1362 // Focus the last child of the bottom node if the node is expanded. |
|
1363 bottomId = iDownloadManagerList->Child( bottomId, childCount-1 ); |
|
1364 } |
|
1365 } |
|
1366 iDownloadManagerTreeListVisualizer->SetFocusedItemL( bottomId ); |
|
1367 } |
|
1368 } |
|
1369 |
|
1370 |