|
1 /* |
|
2 * Copyright (c) 2002 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: This dialog is used for Attachment handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "MsgMailViewerAttachmentsDlg.h" |
|
21 #include "MsgMailViewerAppUi.h" |
|
22 #include "msgmailviewer.hrh" |
|
23 #include "MsgMailUIDs.h" // Application Uid |
|
24 #include "MsgMailDRMHandler.h" |
|
25 #include "MailUtils.h" |
|
26 #include "MailLog.h" |
|
27 |
|
28 #include <CMailMessage.h> |
|
29 #include <CMessageData.h> |
|
30 |
|
31 #include <AiwGenericParam.h> |
|
32 #include <impicmds.h> |
|
33 #include <sendui.h> |
|
34 #include <SenduiMtmUids.h> // Send UI MTM uid's |
|
35 #include <StringLoader.h> |
|
36 #include <eiklbo.h> |
|
37 |
|
38 #include <MuiuMsvUiServiceUtilities.h> // DiskSpaceBelow |
|
39 #include <MsgAttachmentModel.h> |
|
40 #include <MsgAttachmentInfo.h> |
|
41 #include <MsgEditorAppUi.hrh> // EditorBase commands |
|
42 #include <MsgAttachmentModelObserver.h> |
|
43 #include <MsgEditorAppUi.rsg> // R_MEB_ATTACHMENTS_MENUPANE |
|
44 #include <MsgMailViewer.rsg> |
|
45 |
|
46 #include <hlplch.h> |
|
47 #include <csxhelp/mail.hlp.hrh> |
|
48 #include <featmgr.h> |
|
49 |
|
50 // CONSTANTS |
|
51 _LIT(KMessageMimeType, "message/rfc822"); |
|
52 const TInt KMSKControlID(3); |
|
53 |
|
54 enum TStatusFlags |
|
55 { |
|
56 EObserverAdded = KBit0 |
|
57 }; |
|
58 |
|
59 // ================= MEMBER FUNCTIONS ======================= |
|
60 |
|
61 CMsgMailViewerAttachmentsDlg* CMsgMailViewerAttachmentsDlg::NewL( |
|
62 TDesC& aTitle, CMsgAttachmentModel& aAttachmentModel, |
|
63 CMsgMailViewerDocument& aDocument, |
|
64 MMsgMailAttachmentDialogObserver& aDlgObserver ) |
|
65 { |
|
66 CMsgMailViewerAttachmentsDlg* self = |
|
67 new(ELeave) CMsgMailViewerAttachmentsDlg( |
|
68 aTitle, aAttachmentModel, aDocument, aDlgObserver ); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 |
|
72 CleanupStack::Pop( self ); |
|
73 return self; |
|
74 } |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CMsgMailViewerAttachmentsDlg |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CMsgMailViewerAttachmentsDlg::CMsgMailViewerAttachmentsDlg( |
|
80 TDesC& aTitle, CMsgAttachmentModel& aAttachmentModel, |
|
81 CMsgMailViewerDocument& aDocument, |
|
82 MMsgMailAttachmentDialogObserver& aDlgObserver ) |
|
83 :CMsgViewAttachmentsDialog(aTitle, |
|
84 R_VIEWER_ATTACHMENTS_MENU, aAttachmentModel), |
|
85 iDocument(aDocument), iFlags(0), iDlgObserver(aDlgObserver) |
|
86 { |
|
87 } |
|
88 |
|
89 CMsgMailViewerAttachmentsDlg::~CMsgMailViewerAttachmentsDlg() |
|
90 { |
|
91 LOG("CMsgMailViewerAttachmentsDlg: destructor"); |
|
92 |
|
93 // report to observer |
|
94 iDlgObserver.AttachmentDialogExit(); |
|
95 |
|
96 if ((iFlags & EObserverAdded)) |
|
97 { |
|
98 iDocument.Session().RemoveObserver(*this); |
|
99 } |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CMsgMailViewerAttachmentsDlg::NotifySizeChanged |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CMsgMailViewerAttachmentsDlg::NotifySizeChanged() |
|
107 { |
|
108 if(iListBox) |
|
109 { |
|
110 iListBox->SizeChanged(); |
|
111 } |
|
112 else |
|
113 { |
|
114 LOG("CMsgMailViewerAttachmentsDlg::NotifySizeChanged: iListBox NULL"); |
|
115 } |
|
116 |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CMsgMailViewerAttachmentsDlg::HandleListBoxEventL |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CMsgMailViewerAttachmentsDlg::HandleListBoxEventL( |
|
124 CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
125 { |
|
126 LOG("CMsgMailViewerAttachmentsDlg::HandleListBoxEventL"); |
|
127 if ( !MenuShowing() ) |
|
128 { |
|
129 if ( aEventType == EEventEnterKeyPressed || |
|
130 aEventType == EEventItemDoubleClicked ) |
|
131 { |
|
132 const TInt index(CurrentListItemIndex()); |
|
133 if ( index != KErrNotFound ) |
|
134 { |
|
135 UpdateMiddleSoftKeyL( index ); |
|
136 DoFetchOrOpenL( index ); |
|
137 } |
|
138 } |
|
139 else if ( aEventType == EEventItemClicked ) |
|
140 { |
|
141 const TInt index(CurrentListItemIndex()); |
|
142 if ( index != KErrNotFound ) |
|
143 { |
|
144 UpdateMiddleSoftKeyL( index ); |
|
145 } |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // ConstructL |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 void CMsgMailViewerAttachmentsDlg::ConstructL() |
|
155 { |
|
156 CMsgViewAttachmentsDialog::ConstructL(iDocument.CurrentEntry()); |
|
157 |
|
158 iDocument.Session().AddObserverL(*this); |
|
159 iFlags |= EObserverAdded; |
|
160 } |
|
161 |
|
162 // ---------------------------------------------------------------------------- |
|
163 // CMsgMailViewerAttachmentsDlg::DynInitMenuPaneL |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 void CMsgMailViewerAttachmentsDlg::DynInitMenuPaneL( |
|
167 TInt aMenuId, CEikMenuPane* aMenuPane) |
|
168 { |
|
169 CMsgViewAttachmentsDialog::DynInitMenuPaneL( aMenuId, aMenuPane ); |
|
170 const TInt index(CurrentListItemIndex()); |
|
171 |
|
172 if (aMenuId == R_MEB_ATTACHMENTS_MENUPANE) |
|
173 { |
|
174 // this shouldn't happen... |
|
175 if (index == KErrNotFound) |
|
176 { |
|
177 return; |
|
178 } |
|
179 |
|
180 CMsgAttachmentInfo& attaInfo = |
|
181 iAttachmentModel.AttachmentInfoAt(index); |
|
182 |
|
183 if (attaInfo.IsFetched()) |
|
184 { |
|
185 aMenuPane->SetItemDimmed(EMsgViewAttachmentCmdOpen, EFalse); |
|
186 aMenuPane->SetItemDimmed( |
|
187 EMsgViewAttachmentCmdRemove, |
|
188 !CanRemoveAttachment( attaInfo ) ); |
|
189 |
|
190 //Saving changed so that all files supported or unsupported |
|
191 //can be saved. |
|
192 //CDocumentHandler can still prevent saving, |
|
193 //but shouldn't do so. |
|
194 aMenuPane->SetItemDimmed( |
|
195 EMsgViewAttachmentCmdSave, |
|
196 ! (iDocument.CanSaveFileL( attaInfo.DataType() )) ); |
|
197 |
|
198 // attachment is not banned type |
|
199 if (!MailUtils::IsClosedMimeL(attaInfo.DataType().Des())) |
|
200 { |
|
201 // not a message type |
|
202 if (!attaInfo.DataType().Des().Compare(KMessageMimeType) == 0) |
|
203 { |
|
204 // -> display send via menu |
|
205 TInt index = 0; |
|
206 aMenuPane->ItemAndPos(EMsgViewAttachmentCmdOpen, index); |
|
207 |
|
208 TSendingCapabilities capabilities( |
|
209 0, 0, TSendingCapabilities::ESupportsAttachments); |
|
210 iDocument.SendUiL().AddSendMenuItemL( |
|
211 *aMenuPane, |
|
212 index+3, // CSI: 47 # third command below attachments. |
|
213 EMsgMailViewerFirstFreeCommandId, |
|
214 capabilities ); |
|
215 } |
|
216 } |
|
217 |
|
218 } |
|
219 else |
|
220 { |
|
221 aMenuPane->SetItemDimmed(EMsgViewAttachmentCmdFetch, EFalse); |
|
222 } |
|
223 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
224 { |
|
225 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
226 } |
|
227 } |
|
228 } |
|
229 |
|
230 // ---------------------------------------------------------------------------- |
|
231 // CMsgMailViewerAttachmentsDlg::FetchRemoteAttachmentL |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 void CMsgMailViewerAttachmentsDlg::FetchRemoteAttachmentL( TInt aIndex ) |
|
235 { |
|
236 CMsvEntry& currEntry = iDocument.CurrentEntry(); |
|
237 CMsgAttachmentInfo& modelInfo = iAttachmentModel.AttachmentInfoAt(aIndex); |
|
238 if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
239 currEntry.Session(), |
|
240 modelInfo.Size()) ) |
|
241 { |
|
242 User::Leave( KErrDiskFull ); |
|
243 } |
|
244 |
|
245 TInt status( MailUtils::EQueryAttachmentFetch ); |
|
246 if ( !iDocument.IsOnLineL() ) |
|
247 { |
|
248 status |= MailUtils::EConnectionOffline; |
|
249 } |
|
250 if ( MailUtils::LargeAttachmentQueryL( |
|
251 iAttachmentModel.AttachmentInfoAt(aIndex).Size(), |
|
252 status ) ) |
|
253 { |
|
254 iDocument.FetchAttachmentL( modelInfo.AttachmentId() ); |
|
255 // Now message is fetched?, we'll update datatype information in |
|
256 // the HandleSessionEventL |
|
257 } |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // CMsgMailViewerAttachmentsDlg::UpdateModelInfoL |
|
262 // ---------------------------------------------------------------------------- |
|
263 // |
|
264 void CMsgMailViewerAttachmentsDlg::UpdateModelInfoL( TInt aIndex ) |
|
265 { |
|
266 CMsgAttachmentInfo& modelInfo = |
|
267 iAttachmentModel.AttachmentInfoAt( aIndex ); |
|
268 if ( modelInfo.IsFetched() ) |
|
269 { |
|
270 RFile attachmentHandle = iAttachmentModel.GetAttachmentFileL( |
|
271 aIndex ); |
|
272 CleanupClosePushL( attachmentHandle ); |
|
273 |
|
274 TDataType dataType = iDocument.ResolveMimeType( attachmentHandle ); |
|
275 |
|
276 if(dataType.Des().Length()) |
|
277 { |
|
278 //Successful recognition. |
|
279 modelInfo.SetDataType(dataType); |
|
280 } |
|
281 |
|
282 MsgMailDRMHandler* drmHandler = MsgMailDRMHandler::NewL(); |
|
283 CleanupStack::PushL( drmHandler ); |
|
284 CMsgAttachmentInfo::TDRMDataType drmType = |
|
285 drmHandler->GetDRMDataTypeL( attachmentHandle ); |
|
286 modelInfo.SetDRMDataType( drmType ); |
|
287 CleanupStack::PopAndDestroy(2); // CSI: 47 # drmHandler, handle |
|
288 } |
|
289 } |
|
290 |
|
291 |
|
292 // ---------------------------------------------------------------------------- |
|
293 // CMsgMailViewerAttachmentsDlg::UpdateAttachmentsFetchFlags |
|
294 // ---------------------------------------------------------------------------- |
|
295 // |
|
296 void CMsgMailViewerAttachmentsDlg::UpdateAttachmentsFetchFlags() |
|
297 { |
|
298 //Update attachmentmodel to secure model is up to date. |
|
299 for(TInt itemIndex=0; itemIndex<iAttachmentModel.NumberOfItems(); itemIndex++) |
|
300 { |
|
301 CMsgAttachmentInfo& attInfo = |
|
302 iAttachmentModel.AttachmentInfoAt(itemIndex); |
|
303 |
|
304 TMsvEntry entry; |
|
305 TMsvId serviceId; |
|
306 |
|
307 if ( iDocument.CurrentEntry().Session().GetEntry( |
|
308 attInfo.AttachmentId(), serviceId, entry ) == KErrNone ) |
|
309 { |
|
310 //Update is not done for message entries. |
|
311 //This is done because for some reason we |
|
312 //can't get file handle for this type of attachment. |
|
313 //Also entry.Complete() flag doesn't work with them. |
|
314 //This shouldn't be a problem because attached messages (= KUidMsvMessageEntry type) |
|
315 //are fetched with original mail and updating of model info |
|
316 //isn't necessary. |
|
317 if(entry.iType != KUidMsvMessageEntry) |
|
318 { |
|
319 LOG( "CMsgMailViewerAttachmentsDlg::EMsvEntriesChanged: FOUND" ); |
|
320 attInfo.SetFetched( entry.Complete() ); |
|
321 //Old UpdateModelInfoL call was removed because it caused |
|
322 //Panic when exiting dialog too quicly. |
|
323 //Reason for Panic was MIME resolving which takes lot of time |
|
324 //and can return after dialog object is destroyed. |
|
325 } |
|
326 else |
|
327 { |
|
328 LOG("CMsgMailViewerAttachmentsDlg::UpdateAttachmentModelL: KUidMsvMessageEntry"); |
|
329 } |
|
330 } |
|
331 } |
|
332 |
|
333 //If there are attachments update the middle soft key |
|
334 //according to the first attachment |
|
335 if( iAttachmentModel.NumberOfItems() > 0 ) |
|
336 { |
|
337 TRAP_IGNORE( UpdateMiddleSoftKeyL(CurrentListItemIndex()) ); |
|
338 } |
|
339 } |
|
340 |
|
341 // ---------------------------------------------------------------------------- |
|
342 // CMsgMailViewerAttachmentsDlg::OfferKeyEventL |
|
343 // ---------------------------------------------------------------------------- |
|
344 // |
|
345 TKeyResponse CMsgMailViewerAttachmentsDlg::OfferKeyEventL( |
|
346 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
347 { |
|
348 // Consume send keys, so that they are not handled in the appui |
|
349 if( aType == EEventKey && aKeyEvent.iCode == EKeyYes ) |
|
350 { |
|
351 return EKeyWasConsumed; |
|
352 } |
|
353 |
|
354 TInt index( CurrentListItemIndex() ); |
|
355 if ( index != KErrNotFound && !MenuShowing() ) |
|
356 { |
|
357 if ( aType == EEventKey ) |
|
358 { |
|
359 if( aKeyEvent.iCode == EKeyOK ) |
|
360 { |
|
361 DoFetchOrOpenL( index ); |
|
362 return EKeyWasConsumed; |
|
363 } |
|
364 else if( aKeyEvent.iCode == EKeyBackspace ) |
|
365 { |
|
366 CMsgAttachmentInfo& attaInfo = |
|
367 iAttachmentModel.AttachmentInfoAt(index); |
|
368 if ( CanRemoveAttachment( attaInfo ) ) |
|
369 { |
|
370 ProcessCommandL(EMsgViewAttachmentCmdRemove); |
|
371 } |
|
372 return EKeyWasConsumed; |
|
373 } |
|
374 } |
|
375 else if ( aType == EEventKeyUp ) |
|
376 { |
|
377 UpdateMiddleSoftKeyL( index ); |
|
378 } |
|
379 } |
|
380 |
|
381 return CMsgViewAttachmentsDialog::OfferKeyEventL(aKeyEvent, aType); |
|
382 } |
|
383 |
|
384 |
|
385 // ---------------------------------------------------------------------------- |
|
386 // CMsgMailViewerAttachmentsDlg::ProcessCommandL |
|
387 // ---------------------------------------------------------------------------- |
|
388 // |
|
389 void CMsgMailViewerAttachmentsDlg::ProcessCommandL(TInt aCommandId) |
|
390 { |
|
391 MAIL_ALLOC_TEST( DoProcessCommandL( aCommandId ) ); |
|
392 } |
|
393 |
|
394 |
|
395 // ---------------------------------------------------------------------------- |
|
396 // CMsgMailViewAttachmentsDlg::GetHelpContext |
|
397 // This function is called when Help application is launched. |
|
398 // ---------------------------------------------------------------------------- |
|
399 // |
|
400 void CMsgMailViewerAttachmentsDlg::GetHelpContext( |
|
401 TCoeHelpContext& aContext) const |
|
402 { |
|
403 // Uses editor's UID because there's only one help file! |
|
404 aContext.iMajor = TUid::Uid( KUidMsgMailEditor ); |
|
405 aContext.iContext = KMAIL_HLP_ATTACHMENTS_VIEWER(); |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------------------------------- |
|
409 // CMsgMailViewAttachmentsDlg::OpenAttachmentL |
|
410 // ---------------------------------------------------------------------------- |
|
411 // |
|
412 void CMsgMailViewerAttachmentsDlg::OpenAttachmentL() |
|
413 { |
|
414 const TInt index(CurrentListItemIndex()); |
|
415 const CMsgAttachmentInfo& info = iAttachmentModel.AttachmentInfoAt(index); |
|
416 const TMsvId id(info.AttachmentId()); |
|
417 |
|
418 if ( !iDocument.OpenMessageEntryL( id ) ) |
|
419 { |
|
420 if ( info.IsSaved() ) |
|
421 { |
|
422 SetOpenParamList( NULL ); |
|
423 } |
|
424 else if( !OpenParamList() ) |
|
425 { |
|
426 TAiwVariant allowSaveVariant( ETrue ); |
|
427 TAiwGenericParam genericParamAllowSave( EGenericParamAllowSave, |
|
428 allowSaveVariant ); |
|
429 |
|
430 CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); |
|
431 paramList->AppendL( genericParamAllowSave ); |
|
432 SetOpenParamList( paramList ); |
|
433 CleanupStack::Pop( paramList ); |
|
434 } |
|
435 CMsgViewAttachmentsDialog::ProcessCommandL(EMsgViewAttachmentCmdOpen); |
|
436 } |
|
437 } |
|
438 |
|
439 // ---------------------------------------------------------------------------- |
|
440 // CMsgMailViewerAttachmentsDlg::DoFetchOrOpenL |
|
441 // ---------------------------------------------------------------------------- |
|
442 void CMsgMailViewerAttachmentsDlg::DoFetchOrOpenL( TInt aIndex ) |
|
443 { |
|
444 if ( !iAttachmentModel.AttachmentInfoAt(aIndex).IsFetched() ) |
|
445 { |
|
446 FetchRemoteAttachmentL( aIndex ); |
|
447 } |
|
448 else |
|
449 { |
|
450 OpenAttachmentL(); |
|
451 } |
|
452 } |
|
453 |
|
454 // ---------------------------------------------------------------------------- |
|
455 // CMsgMailViewerAttachmentsDlg::DoSendViaL |
|
456 // ---------------------------------------------------------------------------- |
|
457 void CMsgMailViewerAttachmentsDlg::DoProcessCommandL( TInt aCommandId ) |
|
458 { |
|
459 HideMenu(); |
|
460 const TInt index(CurrentListItemIndex()); |
|
461 |
|
462 switch (aCommandId) |
|
463 { |
|
464 // handle our own menu command. |
|
465 case EMsgViewAttachmentCmdFetch: |
|
466 FetchRemoteAttachmentL(index); |
|
467 break; |
|
468 case EMsgViewAttachmentCmdRemove: |
|
469 PurgeAttachmentL(index); |
|
470 break; |
|
471 case EMsgMailViewerCmdAttachmentCmdExit: |
|
472 TryExitL(EAknSoftkeyOk); |
|
473 break; |
|
474 case EMsgViewAttachmentCmdOpen: |
|
475 OpenAttachmentL(); |
|
476 break; |
|
477 case EAknCmdHelp: |
|
478 // Launch help |
|
479 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
480 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
481 break; |
|
482 case EMsgMailViewerFirstFreeCommandId: |
|
483 DoSendViaL(); |
|
484 break; |
|
485 default: |
|
486 // call parent class to process other commands. |
|
487 CMsgViewAttachmentsDialog::ProcessCommandL(aCommandId); |
|
488 break; |
|
489 } |
|
490 } |
|
491 |
|
492 // ---------------------------------------------------------------------------- |
|
493 // CMsgMailViewerAttachmentsDlg::DoSendViaL |
|
494 // ---------------------------------------------------------------------------- |
|
495 void CMsgMailViewerAttachmentsDlg::DoSendViaL() |
|
496 { |
|
497 CMessageData* messageData = CMessageData::NewL(); |
|
498 CleanupStack::PushL(messageData); |
|
499 |
|
500 RFile attachentHandle = iAttachmentModel.GetAttachmentFileL( |
|
501 CurrentListItemIndex() ); |
|
502 CleanupClosePushL( attachentHandle ); |
|
503 messageData->AppendAttachmentHandleL( attachentHandle ); |
|
504 CleanupStack::PopAndDestroy(); // attachentHandle |
|
505 |
|
506 TSendingCapabilities capabilities( |
|
507 0, 0, TSendingCapabilities::ESupportsAttachments); |
|
508 |
|
509 // Three services to dim |
|
510 CArrayFixFlat<TUid>* servicesToDim = new(ELeave) CArrayFixFlat<TUid>( 3 ); // CSI: 47 # See a comment above. |
|
511 CleanupStack::PushL( servicesToDim ); |
|
512 |
|
513 servicesToDim->AppendL( KSenduiMtmMmsUid ); |
|
514 servicesToDim->AppendL( KSenduiMtmSmtpUid ); |
|
515 |
|
516 iDocument.SendUiL().ShowQueryAndSendL( messageData, capabilities, servicesToDim ); |
|
517 |
|
518 CleanupStack::PopAndDestroy(2); // CSI: 47 # servicesToDim, messageData |
|
519 } |
|
520 |
|
521 // ---------------------------------------------------------------------------- |
|
522 // CMsgMailViewerAttachmentsDlg::PurgeAttachmentL |
|
523 // ---------------------------------------------------------------------------- |
|
524 void CMsgMailViewerAttachmentsDlg::PurgeAttachmentL( TInt aIndex ) |
|
525 { |
|
526 CMsgAttachmentInfo& attInfo = |
|
527 iAttachmentModel.AttachmentInfoAt(aIndex); |
|
528 TParsePtrC parser(attInfo.FileName()); |
|
529 HBufC* string = StringLoader::LoadLC(R_MAIL_VIEWER_REMOVE_ATTACHMENT, |
|
530 parser.NameAndExt(), iEikonEnv); |
|
531 |
|
532 if ( MailUtils::ConfirmationQueryL(*string) ) |
|
533 { |
|
534 iDocument.RemoveAttachmentL( attInfo.AttachmentId() ); |
|
535 attInfo.SetFetched(EFalse); |
|
536 UpdateIcon(aIndex); |
|
537 } |
|
538 CleanupStack::PopAndDestroy(); // string |
|
539 } |
|
540 |
|
541 // ---------------------------------------------------------------------------- |
|
542 // CMsgMailViewerAttachmentsDlg::CanRemoveAttachment |
|
543 // ---------------------------------------------------------------------------- |
|
544 // |
|
545 TBool CMsgMailViewerAttachmentsDlg::CanRemoveAttachment( |
|
546 CMsgAttachmentInfo& aInfo ) |
|
547 { |
|
548 // POP3 entry or IMAP local entry does not support purge attachment |
|
549 const CMsvEntry& messageEntry = iDocument.CurrentEntry(); |
|
550 |
|
551 return ( messageEntry.Entry().iMtm == KSenduiMtmImap4Uid && |
|
552 messageEntry.OwningService() != KMsvLocalServiceIndexEntryIdValue && |
|
553 aInfo.IsAttachedThisSession() && aInfo.IsFetched() ); |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------------------------- |
|
557 // CMsgMailViewerAttachmentsDlg::SetMiddleSoftKeyLabelL |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 void CMsgMailViewerAttachmentsDlg::SetMiddleSoftKeyLabelL( |
|
561 TInt aResourceId, TInt aCommandId ) |
|
562 { |
|
563 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
564 |
|
565 ButtonGroupContainer().AddCommandToStackL( |
|
566 KMSKControlID, |
|
567 aCommandId, |
|
568 *middleSKText ); |
|
569 CleanupStack::PopAndDestroy( middleSKText ); |
|
570 } |
|
571 |
|
572 // --------------------------------------------------------------------------- |
|
573 // CMsgMailViewerAttachmentsDlg::UpdateMiddleSoftKeyL |
|
574 // --------------------------------------------------------------------------- |
|
575 // |
|
576 void CMsgMailViewerAttachmentsDlg::UpdateMiddleSoftKeyL( TInt aIndex ) |
|
577 { |
|
578 ASSERT( aIndex >= 0 && aIndex < iAttachmentModel.NumberOfItems() ); |
|
579 CMsgAttachmentInfo& attInfo = |
|
580 iAttachmentModel.AttachmentInfoAt( aIndex ); |
|
581 |
|
582 if ( attInfo.IsFetched() ) |
|
583 { |
|
584 // switch command from "fetch" to "open" |
|
585 ButtonGroupContainer().RemoveCommandFromStack( |
|
586 KMSKControlID, EMsgViewAttachmentCmdFetch ); |
|
587 SetMiddleSoftKeyLabelL( |
|
588 R_QTN_MSK_OPEN, EAknSoftkeyOpen ); |
|
589 } |
|
590 else |
|
591 { |
|
592 // switch command from "open" to "fetch" |
|
593 ButtonGroupContainer().RemoveCommandFromStack( |
|
594 KMSKControlID, EAknSoftkeyOpen ); |
|
595 SetMiddleSoftKeyLabelL( |
|
596 R_QTN_MSK_FETCH, EMsgViewAttachmentCmdFetch ); |
|
597 } |
|
598 } |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // CMsgMailViewerAttachmentsDlg::HandleSessionEventL |
|
602 // ----------------------------------------------------------------------------- |
|
603 // |
|
604 void CMsgMailViewerAttachmentsDlg::HandleSessionEventL(TMsvSessionEvent aEvent, |
|
605 TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
606 { |
|
607 if ( aEvent == EMsvEntriesChanged && aArg1 ) |
|
608 { |
|
609 CMsvEntrySelection* changedEntries = |
|
610 static_cast<CMsvEntrySelection*>( aArg1 ); |
|
611 UpdateChangedAttachmentsL( *changedEntries ); |
|
612 } |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // CMsgMailViewerAttachmentsDlg::UpdateChangedAttachmentsL |
|
617 // Update model and UI e.g. due to attachment fetching. We cannot update |
|
618 // attached messages but that is not a problem since they are automatically |
|
619 // fetched along with the parent message. |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 void CMsgMailViewerAttachmentsDlg::UpdateChangedAttachmentsL( |
|
623 const CMsvEntrySelection& aChangedEntries ) |
|
624 { |
|
625 TInt changedCount( aChangedEntries.Count() ); |
|
626 for ( TInt changedIndex( 0 ); changedIndex < changedCount; ++changedIndex ) |
|
627 { |
|
628 TMsvId changedId( aChangedEntries[changedIndex] ); |
|
629 TInt attachmentCount( iAttachmentModel.NumberOfItems() ); |
|
630 for ( TInt attaIndex( 0 ); attaIndex < attachmentCount; ++attaIndex ) |
|
631 { |
|
632 CMsgAttachmentInfo& attaInfo = |
|
633 iAttachmentModel.AttachmentInfoAt( attaIndex ); |
|
634 if ( attaInfo.AttachmentId() == changedId ) |
|
635 { |
|
636 TMsvEntry entry; |
|
637 TMsvId serviceId; |
|
638 if ( iDocument.CurrentEntry().Session().GetEntry( |
|
639 changedId, serviceId, entry ) == KErrNone && |
|
640 entry.iType != KUidMsvMessageEntry ) |
|
641 { |
|
642 attaInfo.SetFetched( entry.Complete() ); |
|
643 UpdateModelInfoL( attaIndex ); |
|
644 UpdateMiddleSoftKeyL( attaIndex ); |
|
645 UpdateIcon( attaIndex ); |
|
646 } |
|
647 break; // continue with next changed entry |
|
648 } |
|
649 } |
|
650 } |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // CMsgMailViewerAttachmentsDlg::OkToExitL |
|
655 // ----------------------------------------------------------------------------- |
|
656 // |
|
657 TBool CMsgMailViewerAttachmentsDlg::OkToExitL(TInt aButtonId) |
|
658 { |
|
659 //Check if user has selected exit from menu |
|
660 // -> whole application shall be closed. |
|
661 if ( aButtonId == EAknSoftkeyOk ) |
|
662 { |
|
663 if ( CMsgViewAttachmentsDialog::OkToExitL(aButtonId) ) |
|
664 { |
|
665 CEikAppUi* appUi = iEikonEnv->EikAppUi(); |
|
666 static_cast<MEikCommandObserver*>(appUi)->ProcessCommandL( |
|
667 EAknCmdExit ); |
|
668 return ETrue; |
|
669 } |
|
670 else |
|
671 { |
|
672 return EFalse; |
|
673 } |
|
674 } |
|
675 |
|
676 else if ( aButtonId == EMsgViewAttachmentCmdFetch ) |
|
677 { |
|
678 DoProcessCommandL( aButtonId ); |
|
679 return EFalse; |
|
680 } |
|
681 |
|
682 //Let base class decide if it ok to exit |
|
683 return CMsgViewAttachmentsDialog::OkToExitL(aButtonId); |
|
684 } |
|
685 |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CMsgMailViewerAttachmentsDlg::UpdateAttatchmentListL |
|
689 // Update attatchmentlist |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 void CMsgMailViewerAttachmentsDlg::UpdateAttatchmentListL() |
|
693 { |
|
694 // Handles item addition |
|
695 ItemAddedL(); |
|
696 } |
|
697 |
|
698 // End of File |
|
699 |
|
700 |
|
701 |