|
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 control for the attachment list view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include "emailtrace.h" |
|
21 #include <pathinfo.h> |
|
22 //<cmail> |
|
23 #include "fstreelist.h" // for attachment visual list |
|
24 #include <DocumentHandler.h> // for file opening |
|
25 #include <apmstd.h> // for TDataType |
|
26 #include <gulicon.h> // icons |
|
27 #include <AknIconUtils.h> // icons |
|
28 #include <AknWaitDialog.h> |
|
29 #include <freestyleemailui.mbg> |
|
30 #include <FreestyleEmailUi.rsg> |
|
31 #include <CommonContentPolicy.h> |
|
32 #include <aknnotewrappers.h> |
|
33 #include <StringLoader.h> |
|
34 #include "cfsmailclient.h" |
|
35 #include <CVPbkContactManager.h> // Virtual phonebook contact manager |
|
36 // <cmail> SF |
|
37 #include <alf/alfevent.h> |
|
38 // </cmail> |
|
39 |
|
40 // for action menu |
|
41 #include "cfsccontactactionservice.h" |
|
42 #include "cfsccontactactionmenu.h" |
|
43 #include "mfsccontactactionmenumodel.h" |
|
44 #include "cfsccontactactionmenuitem.h" |
|
45 #include "fsccontactactionmenuuids.hrh" |
|
46 #include "fsccontactactionmenudefines.h" |
|
47 //</cmail> |
|
48 |
|
49 // LOCAL INCLUDES |
|
50 #include "FreestyleEmailUiSendAttachmentsListControl.h" |
|
51 #include "FreestyleEmailUiSendAttachmentsListVisualiser.h" |
|
52 #include "FreestyleEmailUiSendAttachmentsListModel.h" |
|
53 #include "FreestyleEmailUiAppui.h" |
|
54 #include "FreestyleEmailUiTextureManager.h" |
|
55 #include "FreestyleEmailUiAttachmentsListModel.h" |
|
56 #include "FreestyleEmailUiUtilities.h" |
|
57 #include "FreestyleEmailUiShortcutBinding.h" |
|
58 #include "ncscomposeview.h" |
|
59 |
|
60 |
|
61 // CONSTANTS |
|
62 |
|
63 // CLASS IMPLEMENTATION |
|
64 |
|
65 const TInt KBigAttachmentSize = 200000; // in Bytes - Attachment is big when it's over this size |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Two-phased constructor. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CFreestyleEmailUiSendAttachmentsListControl* CFreestyleEmailUiSendAttachmentsListControl::NewL( |
|
72 CAlfEnv& aEnv, |
|
73 CFSEmailUiSendAttachmentsListVisualiser* aVisualiser, |
|
74 CFreestyleEmailUiAppUi* aAppUi ) |
|
75 { |
|
76 FUNC_LOG; |
|
77 CFreestyleEmailUiSendAttachmentsListControl* self = |
|
78 CFreestyleEmailUiSendAttachmentsListControl::NewLC( aEnv, aVisualiser, aAppUi ); |
|
79 CleanupStack::Pop(self); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Two-phased constructor. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CFreestyleEmailUiSendAttachmentsListControl* CFreestyleEmailUiSendAttachmentsListControl::NewLC( |
|
88 CAlfEnv& aEnv, |
|
89 CFSEmailUiSendAttachmentsListVisualiser* aVisualiser, |
|
90 CFreestyleEmailUiAppUi* aAppUi ) |
|
91 { |
|
92 FUNC_LOG; |
|
93 CFreestyleEmailUiSendAttachmentsListControl* self = |
|
94 new (ELeave) CFreestyleEmailUiSendAttachmentsListControl( aVisualiser, aAppUi ); |
|
95 CleanupStack::PushL(self); |
|
96 self->ConstructL(aEnv); |
|
97 return self; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 //C++ constructor. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CFreestyleEmailUiSendAttachmentsListControl::CFreestyleEmailUiSendAttachmentsListControl( |
|
105 CFSEmailUiSendAttachmentsListVisualiser* aVisualiser, |
|
106 CFreestyleEmailUiAppUi* aAppUi ) |
|
107 : CAlfControl(), |
|
108 iVisualiser( aVisualiser ), |
|
109 iAppUi( aAppUi ) |
|
110 { |
|
111 FUNC_LOG; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // Two-phased constructor. |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CFreestyleEmailUiSendAttachmentsListControl::ConstructL( CAlfEnv& aEnv ) |
|
119 { |
|
120 FUNC_LOG; |
|
121 CAlfControl::ConstructL( aEnv ); |
|
122 iService = CFscContactActionService::NewL( iAppUi->GetVPbkManagerL() ); |
|
123 iModel = CFSEmailUiSendAttachmentsListModel::NewL( iAppUi, Env(), this ); |
|
124 iAttachmentAddingLocked = EFalse; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Virtual destructor. |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 CFreestyleEmailUiSendAttachmentsListControl::~CFreestyleEmailUiSendAttachmentsListControl() |
|
132 { |
|
133 FUNC_LOG; |
|
134 delete iService; |
|
135 } |
|
136 |
|
137 // <cmail> |
|
138 // --------------------------------------------------------------------------- |
|
139 // Verify file selection (e.g. DRM) |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 TBool CFreestyleEmailUiSendAttachmentsListControl::VerifySelectionL( const MDesCArray* /*aSelectedFiles*/ ) |
|
143 { |
|
144 return ETrue; |
|
145 } |
|
146 // </cmail> |
|
147 |
|
148 void CFreestyleEmailUiSendAttachmentsListControl::DeleteModel() |
|
149 { |
|
150 FUNC_LOG; |
|
151 delete iModel; |
|
152 iModel = NULL; |
|
153 } |
|
154 |
|
155 //<cmail> touch |
|
156 void CFreestyleEmailUiSendAttachmentsListControl::SetMskL() |
|
157 { |
|
158 iVisualiser->SetMskL(); |
|
159 } |
|
160 //</cmail> |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // OfferEventL |
|
164 // called by ALF |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CFreestyleEmailUiSendAttachmentsListControl::OfferEventL( const TAlfEvent& aEvent ) |
|
168 { |
|
169 FUNC_LOG; |
|
170 TBool result( EFalse ); |
|
171 iVisualiser->SetMskL(); |
|
172 // handle key events |
|
173 if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey ) |
|
174 { |
|
175 |
|
176 TInt scanCode = aEvent.KeyEvent().iScanCode; |
|
177 // Swap right and left controls in mirrored layout |
|
178 if ( AknLayoutUtils::LayoutMirrored() ) |
|
179 { |
|
180 if (scanCode == EStdKeyRightArrow) |
|
181 { |
|
182 scanCode = EStdKeyLeftArrow; |
|
183 } |
|
184 else if ( scanCode == EStdKeyLeftArrow ) |
|
185 { |
|
186 scanCode = EStdKeyRightArrow; |
|
187 } |
|
188 } |
|
189 |
|
190 switch ( scanCode ) |
|
191 { |
|
192 case EStdKeyDevice3: |
|
193 case EStdKeyEnter: |
|
194 { |
|
195 iModel->HandleActionL(); |
|
196 result = ETrue; |
|
197 break; |
|
198 } |
|
199 case EStdKeyUpArrow: |
|
200 { |
|
201 // do not highlight header |
|
202 if ( !iModel->CanSelectPreviousItem() ) |
|
203 { |
|
204 // Check that this works correctly! |
|
205 // If previous item is header, mark the event consumed |
|
206 // so that it is not forwarded to list's control. |
|
207 result = ETrue; |
|
208 //result = iModel->AttachmentList()->TreeControl()->OfferEventL( aEvent ); |
|
209 } |
|
210 break; |
|
211 } |
|
212 case EStdKeyLeftArrow: |
|
213 //hide action menu (automatic) |
|
214 break; |
|
215 case EStdKeyRightArrow: |
|
216 { |
|
217 // show action menu when we are on list item |
|
218 CFSEmailUiSendAttachmentsListModelItem* item = NULL; |
|
219 |
|
220 item = iModel->GetSelectedItem(); |
|
221 |
|
222 if ( item ) |
|
223 { |
|
224 ShowActionMenuL( item ); |
|
225 } |
|
226 |
|
227 break; |
|
228 } |
|
229 default : |
|
230 // Check keyboard shortcuts. |
|
231 TInt shortcutCommand = |
|
232 iAppUi->ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(), |
|
233 CFSEmailUiShortcutBinding::EContextSendAttachmentList ); |
|
234 if ( shortcutCommand != KErrNotFound ) |
|
235 { |
|
236 HandleCommandL( shortcutCommand ); |
|
237 result = ETrue; |
|
238 } |
|
239 /* |
|
240 else |
|
241 { |
|
242 result = iModel->AttachmentList()->TreeControl()->OfferEventL( aEvent ); |
|
243 } |
|
244 */ |
|
245 break; |
|
246 } |
|
247 } |
|
248 else if (aEvent.IsPointerEvent()) |
|
249 { |
|
250 result = iModel->AttachmentList()->TreeControl()->OfferEventL(aEvent); |
|
251 } |
|
252 |
|
253 return result; |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // HandleCommandL |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CFreestyleEmailUiSendAttachmentsListControl::HandleCommandL( TInt aCommand ) |
|
261 { |
|
262 FUNC_LOG; |
|
263 switch ( aCommand ) |
|
264 { |
|
265 case EAknSoftkeyOpen: |
|
266 case ESendAttachmentMenuOpen: |
|
267 OpenHighlightedFileL(); |
|
268 break; |
|
269 case EFsEmailUiCmdGoToTop: |
|
270 { |
|
271 iModel->GoToTopL(); |
|
272 } |
|
273 break; |
|
274 case EFsEmailUiCmdGoToBottom: |
|
275 { |
|
276 iModel->GoToBottomL(); |
|
277 } |
|
278 break; |
|
279 case EFsEmailUiCmdCollapse: |
|
280 { |
|
281 iModel->CollapseL(); |
|
282 } |
|
283 break; |
|
284 case EFsEmailUiCmdExpand: |
|
285 { |
|
286 iModel->ExpandL(); |
|
287 } |
|
288 break; |
|
289 case EFsEmailUiCmdActionsCollapseExpandAllToggle: |
|
290 { |
|
291 iModel->CollapseExpandAllToggleL(); |
|
292 } |
|
293 break; |
|
294 default: |
|
295 { |
|
296 if ( iVisualiser ) // Offer aCommand to view |
|
297 { |
|
298 return iVisualiser->HandleCommandL( aCommand ); |
|
299 } |
|
300 } |
|
301 break; |
|
302 } |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // LoadModelContent |
|
307 // |
|
308 // Load model content for list |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 void CFreestyleEmailUiSendAttachmentsListControl::LoadModelContentL() |
|
312 { |
|
313 FUNC_LOG; |
|
314 // Check if saved mail has attachments included |
|
315 |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // Model |
|
320 // |
|
321 // return pointer to current item model |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 CFSEmailUiSendAttachmentsListModel* CFreestyleEmailUiSendAttachmentsListControl::Model() |
|
325 { |
|
326 FUNC_LOG; |
|
327 return iModel; |
|
328 } |
|
329 |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // IsAttachmentAddingLocked |
|
333 // |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 TBool CFreestyleEmailUiSendAttachmentsListControl::IsAttachmentAddingLocked() const |
|
337 { |
|
338 FUNC_LOG; |
|
339 return iAttachmentAddingLocked; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // AppendAttachmentToListL |
|
344 // |
|
345 // Open files selection dialog and append given filename to attachment list |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 TBool CFreestyleEmailUiSendAttachmentsListControl::AppendAttachmentToListL(MsgAttachmentUtils::TMsgAttachmentFetchType aType) |
|
349 { |
|
350 FUNC_LOG; |
|
351 TBool ret = EFalse; |
|
352 TFileName filePath; |
|
353 // <cmail> |
|
354 TBool fetchOK = EFalse; |
|
355 |
|
356 if(iAttachmentAddingLocked) |
|
357 { |
|
358 return ret; |
|
359 } |
|
360 |
|
361 if (aType != MsgAttachmentUtils::EUnknown) |
|
362 { |
|
363 CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); |
|
364 |
|
365 CDesCArrayFlat* files = new( ELeave ) CDesC16ArrayFlat( 1 ); |
|
366 CleanupStack::PushL( files ); |
|
367 |
|
368 // MsgAttachmentUtils messes up the display area, save it and set back after the call |
|
369 TRect visibleArea = CAlfEnv::Static()->PrimaryDisplay().VisibleArea(); |
|
370 fetchOK = MsgAttachmentUtils::FetchFileL( aType, |
|
371 *files, |
|
372 paramList, |
|
373 EFalse, // disk space checked in VerifySelectionL or CUniEditorInsertOperation, if image scaled/compressed |
|
374 EFalse, |
|
375 this ); |
|
376 CAlfEnv::Static()->PrimaryDisplay().SetVisibleArea(visibleArea); |
|
377 |
|
378 if (files->MdcaCount() > 0) |
|
379 { |
|
380 filePath = files->MdcaPoint( 0 ); |
|
381 //when the filepath contains the Drive letter (ie. "e:\\") in lower case then RecognizeData of class RApaLsSession fails. |
|
382 //RecognizeData is used by FS framework to detect the content type of the attachment. To fix this possible failure, |
|
383 //we change the drive letter to upper case here. |
|
384 TBuf<1> driveLetter; |
|
385 driveLetter=filePath.Left(1); |
|
386 driveLetter.CopyUC(driveLetter); |
|
387 filePath.Replace(0,1,driveLetter); |
|
388 } |
|
389 CleanupStack::PopAndDestroy(2, paramList); |
|
390 } |
|
391 else |
|
392 { |
|
393 fetchOK = TFsEmailUiUtility::ShowSelectFileDialogL( filePath ); |
|
394 } |
|
395 |
|
396 iAttachmentAddingLocked = ETrue; |
|
397 |
|
398 if( fetchOK ) |
|
399 { |
|
400 TInt size(0); |
|
401 TInt err(KErrNone); |
|
402 // check if dialog could be shown if the attachment is not protected and have a propper size |
|
403 RFile file; |
|
404 err = file.Open( CCoeEnv::Static()->FsSession(), filePath, EFileShareReadersOnly ); |
|
405 if( err == KErrNone ) |
|
406 { |
|
407 CleanupClosePushL( file ); |
|
408 fetchOK = !FileDrmProtectedL( file ); // it's ok if it is NOT protected |
|
409 file.Size(size); //get size in bytes |
|
410 CleanupStack::PopAndDestroy( &file ); |
|
411 } |
|
412 |
|
413 // show dialog for multiple files or |
|
414 // show if file is not protected and it's considered as the Big Attachment |
|
415 if(( fetchOK && size > KBigAttachmentSize ) || err != KErrNone ) |
|
416 { |
|
417 TFsEmailUiUtility::ShowWaitNoteL( iWaitNote, R_FSE_WAIT_INSERTING_TEXT, EFalse,ETrue ); |
|
418 iWaitNote->DrawNow(); |
|
419 iWaitNote->FocusChanged(EDrawNow); |
|
420 } |
|
421 } |
|
422 |
|
423 |
|
424 if ( fetchOK && filePath.Length() > 0 ) // </cmail> |
|
425 { |
|
426 if ( !FileDrmProtectedL( filePath ) ) |
|
427 { |
|
428 // add file as a email message part |
|
429 CFSMailMessagePart* msgPart = NULL; |
|
430 |
|
431 CNcsComposeView* composeView = |
|
432 static_cast<CNcsComposeView*>( iAppUi->View(MailEditorId) ); |
|
433 |
|
434 TFSMailMsgId nullId; |
|
435 TInt err( KErrNone ); |
|
436 if ( composeView->NewMessage() ) |
|
437 { |
|
438 // use composeview NewMessage if available |
|
439 TRAP( err, msgPart = composeView->NewMessage()->AddNewAttachmentL( filePath, nullId )); |
|
440 } |
|
441 else |
|
442 { |
|
443 // Open message from framework and append attachment |
|
444 CFSMailClient* mailClient = iAppUi->GetMailClient(); // not owned |
|
445 CFSMailMessage* msg = mailClient->GetMessageByUidL( |
|
446 iVisualiser->EditorParams().iMailboxId, |
|
447 iVisualiser->EditorParams().iFolderId, |
|
448 iVisualiser->EditorParams().iMsgId, |
|
449 EFSMsgDataStructure ); |
|
450 CleanupStack::PushL( msg ); |
|
451 TRAP( err, msgPart = msg->AddNewAttachmentL( filePath, nullId )); |
|
452 CleanupStack::PopAndDestroy( msg ); |
|
453 } |
|
454 CleanupStack::PushL( msgPart ); |
|
455 if( KErrNone != err) |
|
456 { |
|
457 if( iWaitNote ) |
|
458 { |
|
459 iWaitNote->ProcessFinishedL(); |
|
460 } |
|
461 iAttachmentAddingLocked = EFalse; |
|
462 User::Leave( err ); |
|
463 } |
|
464 msgPart->SaveL(); |
|
465 |
|
466 // append file to list model |
|
467 const TPtrC fileName = TParsePtrC( filePath ).NameAndExt(); |
|
468 TFileType fileType = TFsEmailUiUtility::GetFileType( fileName, msgPart->GetContentType() ); |
|
469 AppendFileToModelL( msgPart->GetPartId(), |
|
470 fileName, |
|
471 msgPart->ContentSize(), |
|
472 fileType ); |
|
473 |
|
474 // free resources |
|
475 CleanupStack::PopAndDestroy( msgPart ); |
|
476 |
|
477 // add new tree list item and update header content |
|
478 CFSEmailUiSendAttachmentsListModelItem* newItem = |
|
479 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( iModel->Item( iModel->Count()-1 ) ); |
|
480 iModel->AppendItemToAttachmentListL( newItem ); |
|
481 iModel->UpdateHeaderItemTextL(); |
|
482 |
|
483 ret = ETrue; |
|
484 } |
|
485 } |
|
486 |
|
487 if( iWaitNote ) |
|
488 { |
|
489 iWaitNote->ProcessFinishedL(); |
|
490 } |
|
491 iAttachmentAddingLocked = EFalse; |
|
492 |
|
493 return ret; |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------------------------- |
|
497 // FileDrmProtectedL |
|
498 // |
|
499 // Check if file is DRM protected |
|
500 // --------------------------------------------------------------------------- |
|
501 // |
|
502 TBool CFreestyleEmailUiSendAttachmentsListControl::FileDrmProtectedL( RFile& aFile ) |
|
503 { |
|
504 FUNC_LOG; |
|
505 TBool isProtected( EFalse ); |
|
506 CCommonContentPolicy* ccp = CCommonContentPolicy::NewLC(); |
|
507 isProtected = ccp->IsClosedFileL( aFile ); |
|
508 if ( isProtected ) |
|
509 { |
|
510 TFsEmailUiUtility::ShowErrorNoteL( R_FS_EMAILUI_SENDATTACHMENTS_ITEM_DRM_PROTECTED_TXT, ETrue ); |
|
511 } |
|
512 CleanupStack::PopAndDestroy( ccp ); |
|
513 return isProtected; |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------------------------- |
|
517 // FileDrmProtectedL |
|
518 // |
|
519 // Check if file is DRM protected |
|
520 // --------------------------------------------------------------------------- |
|
521 // |
|
522 TBool CFreestyleEmailUiSendAttachmentsListControl::FileDrmProtectedL( const TDesC& aFilePath ) |
|
523 { |
|
524 TBool isProtected( EFalse ); |
|
525 |
|
526 RFile file; |
|
527 TInt err = file.Open( CCoeEnv::Static()->FsSession(), |
|
528 aFilePath, |
|
529 EFileShareReadersOnly ); |
|
530 User::LeaveIfError( err ); |
|
531 CleanupClosePushL( file ); |
|
532 isProtected = FileDrmProtectedL( file ); |
|
533 CleanupStack::PopAndDestroy( &file ); |
|
534 |
|
535 return isProtected; |
|
536 } |
|
537 |
|
538 // --------------------------------------------------------------------------- |
|
539 // AppendFileToModelL |
|
540 // |
|
541 // Append given file to attachment list model |
|
542 // |
|
543 // --------------------------------------------------------------------------- |
|
544 // |
|
545 void CFreestyleEmailUiSendAttachmentsListControl::AppendFileToModelL( |
|
546 const TFSMailMsgId aPartId, |
|
547 const TDesC& aFileName, |
|
548 TInt aSize, |
|
549 TFileType aFileType /*= EUnidentifiedType*/, |
|
550 TBool aReadOnly /*= EFalse*/, |
|
551 TBool aRemoteFile /*= EFalse*/ ) |
|
552 { |
|
553 FUNC_LOG; |
|
554 // add item to model |
|
555 CFSEmailUiSendAttachmentsListModelItem* newItem = |
|
556 CFSEmailUiSendAttachmentsListModelItem::NewL( |
|
557 aFileName, |
|
558 aSize, |
|
559 aFileType, |
|
560 aRemoteFile, |
|
561 aReadOnly ); |
|
562 newItem->SetMailMsgPartId( aPartId ); |
|
563 |
|
564 iModel->AppendL( newItem ); |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // RemoveAttachmentFromListL |
|
569 // |
|
570 // removes item by given index |
|
571 // or |
|
572 // removes currently higlighted item from attachment list and model |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 void CFreestyleEmailUiSendAttachmentsListControl::RemoveAttachmentFromListL( |
|
576 const TInt aIndex ) |
|
577 { |
|
578 FUNC_LOG; |
|
579 TInt index = ( aIndex < 0 ? iModel->HighlightedIndex() : aIndex ); |
|
580 |
|
581 if ( index >= 0 ) |
|
582 { |
|
583 CFSEmailUiSendAttachmentsListModelItem* item = |
|
584 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( iModel->Item( index ) ); |
|
585 |
|
586 if ( !item->IsReadOnly() ) |
|
587 { |
|
588 iModel->RemoveItemByIndexL( index ); |
|
589 iModel->UpdateHeaderItemTextL(); |
|
590 } |
|
591 } |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // RemoveAllAttachmentsL |
|
596 // |
|
597 // removes all items from attachment list and model |
|
598 // --------------------------------------------------------------------------- |
|
599 // |
|
600 void CFreestyleEmailUiSendAttachmentsListControl::RemoveAllAttachmentsL() |
|
601 { |
|
602 FUNC_LOG; |
|
603 TFsEmailUiUtility::ShowWaitNoteL( iWaitNote, R_FSE_WAIT_REMOVING_TEXT, EFalse ); |
|
604 iModel->RemoveAllAttachmentsL(); |
|
605 iWaitNote->ProcessFinishedL(); |
|
606 } |
|
607 |
|
608 // --------------------------------------------------------------------------- |
|
609 // OpenHighlightedFile |
|
610 // |
|
611 // Opens highklighted list item with its corresponding handler |
|
612 // --------------------------------------------------------------------------- |
|
613 // |
|
614 void CFreestyleEmailUiSendAttachmentsListControl::OpenHighlightedFileL() |
|
615 { |
|
616 FUNC_LOG; |
|
617 TInt index = iModel->HighlightedIndex(); |
|
618 if ( index >= 0 ) |
|
619 { |
|
620 CFSEmailUiSendAttachmentsListModelItem* item = |
|
621 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( iModel->Item( index ) ); |
|
622 |
|
623 if ( !item->IsRemote() ) |
|
624 { |
|
625 // Open message using the IDs |
|
626 TEditorLaunchParams editorParams = iVisualiser->EditorParams(); |
|
627 TPartData attachmentPart( editorParams.iMailboxId, |
|
628 editorParams.iFolderId, |
|
629 editorParams.iMsgId, |
|
630 item->MailMsgPartId() ); |
|
631 TFsEmailUiUtility::OpenAttachmentL( attachmentPart ); |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // ShowActionMenu |
|
638 // |
|
639 // Displays action menu and handles selection |
|
640 // --------------------------------------------------------------------------- |
|
641 // |
|
642 void CFreestyleEmailUiSendAttachmentsListControl::ShowActionMenuL( CFSEmailUiSendAttachmentsListModelItem* aItem ) |
|
643 { |
|
644 FUNC_LOG; |
|
645 // Remove old items from action menu |
|
646 CFSEmailUiActionMenu::RemoveAllL(); |
|
647 |
|
648 // Construct item list |
|
649 RFsEActionMenuIdList itemList; |
|
650 CleanupClosePushL( itemList ); |
|
651 |
|
652 if ( !aItem->IsRemote() ) |
|
653 { |
|
654 itemList.AppendL( FsEActionAttachmentOpen ); |
|
655 } |
|
656 |
|
657 itemList.AppendL( FsEActionAttachmentAdd ); |
|
658 |
|
659 if ( !aItem->IsReadOnly() ) |
|
660 { |
|
661 itemList.AppendL( FsEActionAttachmentRemove ); |
|
662 } |
|
663 |
|
664 if ( iModel->Count() > 1 && !iModel->HasReadOnlyAttachments() ) |
|
665 { |
|
666 itemList.AppendL( FsEActionAttachmentRemoveAll ); |
|
667 } |
|
668 |
|
669 |
|
670 //<cmail> touch |
|
671 // Execute action list |
|
672 TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList, EFscCustom, 0, this ); |
|
673 //</cmail> |
|
674 CleanupStack::PopAndDestroy( &itemList ); |
|
675 |
|
676 // Handle action menu selection |
|
677 switch ( itemId ) |
|
678 { |
|
679 case FsEActionAttachmentOpen: |
|
680 HandleCommandL( ESendAttachmentMenuOpen ); |
|
681 break; |
|
682 case FsEActionAttachmentRemove: |
|
683 HandleCommandL( ESendAttachmentMenuRemoveAttachment ); |
|
684 break; |
|
685 case FsEActionAttachmentRemoveAll: |
|
686 HandleCommandL( ESendAttachmentMenuRemoveAllAttachments ); |
|
687 break; |
|
688 case FsEActionAttachmentAdd: |
|
689 HandleCommandL( ESendAttachmentMenuAddAttachment ); |
|
690 break; |
|
691 default: |
|
692 break; |
|
693 } |
|
694 } |
|
695 |
|
696 // <cmail> |
|
697 TPoint CFreestyleEmailUiSendAttachmentsListControl::ActionMenuPosition() |
|
698 { |
|
699 TAlfRealRect focusRect; |
|
700 TFsTreeItemId listItemId = iModel->GetVisualizer()->FocusedItem(); |
|
701 iModel->GetVisualizer()->GetItemDisplayRectTarget(listItemId, focusRect); |
|
702 return focusRect.iTl; |
|
703 } |
|
704 // </cmail> |
|
705 |