19 #include "emailtrace.h" |
19 #include "emailtrace.h" |
20 #include <aknnotewrappers.h> |
20 #include <aknnotewrappers.h> |
21 #include <NpdApi.h> |
21 #include <NpdApi.h> |
22 #include <StringLoader.h> |
22 #include <StringLoader.h> |
23 #include <txtrich.h> |
23 #include <txtrich.h> |
24 #include <AknWaitDialog.h> //<cmail> |
24 #include <AknWaitDialog.h> |
25 #include <MsgAttachmentUtils.h>//<cmail> |
25 #include <MsgAttachmentUtils.h> |
26 //<cmail> |
|
27 #include <featmgr.h> |
26 #include <featmgr.h> |
28 #include "CFSMailBox.h" |
27 #include "CFSMailBox.h" |
29 #include "CFSMailMessage.h" |
28 #include "CFSMailMessage.h" |
30 #include "CFSMailAddress.h" |
29 #include "CFSMailAddress.h" |
31 #include "CFSMailClient.h" |
30 #include "CFSMailClient.h" |
32 #include "CFSMailCommon.h" |
31 #include "CFSMailCommon.h" |
33 #include <csxhelp/cmail.hlp.hrh> |
32 #include <csxhelp/cmail.hlp.hrh> |
34 //</cmail> |
|
35 //<cmail> Touch |
|
36 #include <akntoolbar.h> |
33 #include <akntoolbar.h> |
37 #include <akntoolbarextension.h> |
34 #include <akntoolbarextension.h> |
38 #include <AknUtils.h> |
35 #include <AknUtils.h> |
39 //</cmail> Touch |
|
40 #include <FreestyleEmailUi.rsg> |
36 #include <FreestyleEmailUi.rsg> |
41 #include <freestyleemailui.mbg> |
37 #include <freestyleemailui.mbg> |
|
38 #include <aknstyluspopupmenu.h> |
42 |
39 |
43 #include "ncscomposeview.h" |
40 #include "ncscomposeview.h" |
44 #include "ncscomposeviewcontainer.h" |
41 #include "ncscomposeviewcontainer.h" |
45 #include "ncsconstants.h" |
42 #include "ncsconstants.h" |
46 #include "ncsutility.h" |
43 #include "ncsutility.h" |
144 |
145 |
145 BaseConstructL( R_NCS_COMPOSE_VIEW ); |
146 BaseConstructL( R_NCS_COMPOSE_VIEW ); |
146 iFirstStartCompleted = EFalse; |
147 iFirstStartCompleted = EFalse; |
147 } |
148 } |
148 |
149 |
149 // CFSEmailUiMsgDetailsVisualiser::DoFirstStartL() |
150 // ----------------------------------------------------------------------------- |
|
151 // CNcsComposeView::DoFirstStartL() |
150 // Purpose of this function is to do first start only when msg details is |
152 // Purpose of this function is to do first start only when msg details is |
151 // really needed to be shown. Implemented to make app startuo faster. |
153 // really needed to be shown. Implemented to make app startuo faster. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
152 void CNcsComposeView::DoFirstStartL() |
156 void CNcsComposeView::DoFirstStartL() |
153 { |
157 { |
154 FUNC_LOG; |
158 FUNC_LOG; |
155 // Attachment list for compose screen |
159 // Attachment list for compose screen, owned by AlfEnv |
156 CAlfControlGroup& attListControlGroup = iEnv.NewControlGroupL( KSendAttachmentManagerDisplayGroup ); // owned by AlfEnv |
160 CAlfControlGroup& attListControlGroup = |
|
161 iEnv.NewControlGroupL( KSendAttachmentManagerDisplayGroup ); |
157 CFSEmailUiSendAttachmentsListVisualiser* sendAttachmentVisualiser = |
162 CFSEmailUiSendAttachmentsListVisualiser* sendAttachmentVisualiser = |
158 CFSEmailUiSendAttachmentsListVisualiser::NewLC( |
163 CFSEmailUiSendAttachmentsListVisualiser::NewLC( |
159 iEnv, &iAppUi, attListControlGroup ); |
164 iEnv, &iAppUi, attListControlGroup ); |
160 iAppUi.AddViewL( sendAttachmentVisualiser ); |
165 iAppUi.AddViewL( sendAttachmentVisualiser ); |
161 CleanupStack::Pop( sendAttachmentVisualiser ); |
166 CleanupStack::Pop( sendAttachmentVisualiser ); |
210 { |
229 { |
211 TKeyEvent check = { EKeyEscape, EStdKeyNull, 0, 0 }; |
230 TKeyEvent check = { EKeyEscape, EStdKeyNull, 0, 0 }; |
212 TRAP_IGNORE( iDlg->OfferKeyEventL( check, EEventKey ) ); |
231 TRAP_IGNORE( iDlg->OfferKeyEventL( check, EEventKey ) ); |
213 iDlg = NULL; |
232 iDlg = NULL; |
214 |
233 |
215 iAsyncCallback->Cancel(); // cancel any outstanding callback just to be safe |
234 iAsyncCallback->Cancel(); // cancel any outstanding callback |
216 iAsyncCallback->Set( TCallBack( AsyncExit, this ) ); |
235 iAsyncCallback->Set( TCallBack( AsyncExit, this ) ); |
217 iAsyncCallback->CallBack(); |
236 iAsyncCallback->CallBack(); |
218 } |
237 } |
219 else if(iFakeSyncGoingOn || iExecutingDoExitL) //we starts this low priority active obj so that iwait in plugins finish |
238 else if( iFakeSyncGoingOn || iExecutingDoExitL ) |
220 { |
239 { |
|
240 // low priority active obj so that iwait in plugins finish |
221 iActiveHelper->Cancel(); |
241 iActiveHelper->Cancel(); |
222 iActiveHelper->Start(); |
242 iActiveHelper->Start(); |
223 } |
243 } |
224 else |
244 else |
225 { |
245 { |
226 DoSafeExit( ESaveDraft ); |
246 DoSafeExit( ESaveDraft ); |
227 //iAppUi.Exit(); |
247 } |
228 } |
248 |
229 |
249 if( iFetchLogic ) |
230 if(iFetchLogic) |
|
231 { |
250 { |
232 iFetchLogic->CancelFetchings(); |
251 iFetchLogic->CancelFetchings(); |
233 } |
252 } |
234 |
|
235 //ResetComposer(); // already done in DoExitL |
|
236 } |
253 } |
237 |
254 |
238 // ----------------------------------------------------------------------------- |
255 // ----------------------------------------------------------------------------- |
239 // CNcsComposeView::Id() |
256 // CNcsComposeView::Id() |
240 // Returns View's ID. |
257 // Returns View's ID. |
249 // ----------------------------------------------------------------------------- |
266 // ----------------------------------------------------------------------------- |
250 // CNcsComposeView::ChildDoActivateL() |
267 // CNcsComposeView::ChildDoActivateL() |
251 // Activate the Compose view |
268 // Activate the Compose view |
252 // ----------------------------------------------------------------------------- |
269 // ----------------------------------------------------------------------------- |
253 // |
270 // |
254 // <cmail> Toolbar |
|
255 /*void CNcsComposeView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
256 TUid aCustomMessageId, const TDesC8& aCustomMessage )*/ |
|
257 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId, |
271 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId, |
258 TUid aCustomMessageId, const TDesC8& aCustomMessage ) |
272 TUid aCustomMessageId, const TDesC8& aCustomMessage ) |
259 // </cmail> Toolbar |
|
260 { |
273 { |
261 FUNC_LOG; |
274 FUNC_LOG; |
262 if ( !iFirstStartCompleted ) |
275 if ( !iFirstStartCompleted ) |
263 { |
276 { |
264 DoFirstStartL(); |
277 DoFirstStartL(); |
265 } |
278 } |
266 Toolbar()->SetDimmed(ETrue); |
279 Toolbar()->SetDimmed( ETrue ); |
267 // Set status pane indicators |
280 // Set status pane indicators |
268 iStatusPaneIndicators = iAppUi.GetStatusPaneIndicatorContainer(); |
281 iStatusPaneIndicators = iAppUi.GetStatusPaneIndicatorContainer(); |
269 iStatusPaneIndicators->ShowStatusPaneIndicators(); |
282 iStatusPaneIndicators->ShowStatusPaneIndicators(); |
270 |
283 |
271 // Notify base class about view being entered unless we returned from another view |
284 // Notify base class about view being entered unless |
|
285 // returned from another view |
272 if ( aCustomMessageId.iUid != KEditorCmdReturnToPrevious ) |
286 if ( aCustomMessageId.iUid != KEditorCmdReturnToPrevious ) |
273 { |
287 { |
274 ViewEntered( aPrevViewId ); |
288 ViewEntered( aPrevViewId ); |
275 } |
289 } |
276 |
290 |
483 // ----------------------------------------------------------------------------- |
505 // ----------------------------------------------------------------------------- |
484 // |
506 // |
485 void CNcsComposeView::RefreshToolbar() |
507 void CNcsComposeView::RefreshToolbar() |
486 { |
508 { |
487 FUNC_LOG; |
509 FUNC_LOG; |
488 if (iContainer) |
510 if ( iContainer ) |
489 { |
511 { |
490 // DimAllOptions if remotesearch is in progress, cos it takes you in a different view |
512 // DimAllOptions if remotesearch is in progress, |
|
513 // because it takes you into a different view |
491 TBool dimAllOptions = iContainer->IsRemoteSearchInprogress(); |
514 TBool dimAllOptions = iContainer->IsRemoteSearchInprogress(); |
492 SetToolbarItemDimmed( EFsEmailUiTbCmdExpandInsert, dimAllOptions ); |
515 SetToolbarItemDimmed( EFsEmailUiTbCmdExpandInsert, dimAllOptions ); |
493 SetToolbarItemDimmed( EFsEmailUiTbCmdSend, |
516 SetToolbarItemDimmed( EFsEmailUiTbCmdSend, |
494 iContainer->AreAddressFieldsEmpty() ); |
517 iContainer->AreAddressFieldsEmpty() ); |
495 if ( (iContainer->IsFocusBcc() || iContainer->IsFocusCc() || iContainer->IsFocusTo()) && !dimAllOptions ) |
518 if ( (iContainer->IsFocusBcc() || |
|
519 iContainer->IsFocusCc() || |
|
520 iContainer->IsFocusTo() ) && !dimAllOptions ) |
496 { |
521 { |
497 SetToolbarItemDimmed( EFsEmailUiTbCmdAddRecipient, EFalse ); |
522 SetToolbarItemDimmed( EFsEmailUiTbCmdAddRecipient, EFalse ); |
498 } |
523 } |
499 else |
524 else |
500 { |
525 { |
501 SetToolbarItemDimmed( EFsEmailUiTbCmdAddRecipient, ETrue ); |
526 SetToolbarItemDimmed( EFsEmailUiTbCmdAddRecipient, ETrue ); |
502 } |
527 } |
503 } |
528 } |
504 } |
529 } |
505 // </cmail> Toolbar |
|
506 |
530 |
507 |
531 |
508 // ----------------------------------------------------------------------------- |
532 // ----------------------------------------------------------------------------- |
509 // CNcsComposeView::ChildDoDeactivate() |
533 // CNcsComposeView::ChildDoDeactivate() |
510 // Deactivate the Compose view |
534 // Deactivate the Compose view |
687 // Sending successful |
715 // Sending successful |
688 HBufC* confMessage = NULL; |
716 HBufC* confMessage = NULL; |
689 if ( !TFsEmailUiUtility::IsOfflineModeL() ) |
717 if ( !TFsEmailUiUtility::IsOfflineModeL() ) |
690 { |
718 { |
691 // when sync status is currently ONLINE |
719 // when sync status is currently ONLINE |
692 confMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED ); |
720 confMessage = StringLoader::LoadLC( |
|
721 R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED ); |
693 } |
722 } |
694 else |
723 else |
695 { |
724 { |
696 // when sync status is currently OFFLINE |
725 // when sync status is currently OFFLINE |
697 confMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_CONFIRM_NOTE_QUEUED_UNTIL_ONLINE ); |
726 confMessage = StringLoader::LoadLC( |
|
727 R_FREESTYLE_EMAIL_CONFIRM_NOTE_QUEUED_UNTIL_ONLINE ); |
698 } |
728 } |
699 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue ); //waiting |
729 CAknConfirmationNote* note = |
|
730 new (ELeave) CAknConfirmationNote( ETrue ); //waiting |
700 note->SetTimeout( CAknNoteDialog::ELongTimeout ); |
731 note->SetTimeout( CAknNoteDialog::ELongTimeout ); |
701 note->ExecuteLD( *confMessage ); |
732 note->ExecuteLD( *confMessage ); |
702 CleanupStack::PopAndDestroy( confMessage ); |
733 CleanupStack::PopAndDestroy( confMessage ); |
703 DoSafeExit(); // Exit after successful sending |
734 DoSafeExit(); // Exit after successful sending |
704 } |
735 } |
705 else if ( error == KErrBadName ) |
736 else if ( error == KErrBadName ) |
706 { |
737 { |
707 // sending failed because recipient address was invalid |
738 // sending failed because recipient address was invalid |
708 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_INVALID_EMAIL_ADDRESS, ETrue ); |
739 TFsEmailUiUtility::ShowErrorNoteL( |
|
740 R_FREESTYLE_EMAIL_CONFIRM_NOTE_INVALID_EMAIL_ADDRESS, |
|
741 ETrue ); |
709 } |
742 } |
710 else |
743 else |
711 { |
744 { |
712 // sending failed for some other reason |
745 // sending failed for some other reason |
713 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_MESSAGE_NOT_SENT, ETrue ); |
746 TFsEmailUiUtility::ShowErrorNoteL( |
714 DoSafeExit(); // Exit after sending failed for other reason than KErrBadName |
747 R_FREESTYLE_EMAIL_CONFIRM_NOTE_MESSAGE_NOT_SENT, |
|
748 ETrue ); |
|
749 // Exit after sending failed for other reason for other |
|
750 // reason than KErrBadName |
|
751 DoSafeExit(); |
715 } |
752 } |
716 } |
753 } |
717 break; |
754 break; |
718 case ENcsCmdAddAttachment: |
755 case ENcsCmdAddAttachment: |
719 { |
756 { |
720 //<cmail> Touch |
|
721 if ( AknLayoutUtils::PenEnabled() ) |
757 if ( AknLayoutUtils::PenEnabled() ) |
722 { |
758 { |
723 // show the toolbar |
759 // show the toolbar |
724 UpdateToolbarL(); |
760 UpdateToolbarL(); |
725 if ( Toolbar() && Toolbar()->ToolbarExtension() ) |
761 if ( Toolbar() && Toolbar()->ToolbarExtension() ) |
727 Toolbar()->ToolbarExtension()->SetShown( ETrue ); |
763 Toolbar()->ToolbarExtension()->SetShown( ETrue ); |
728 } |
764 } |
729 } |
765 } |
730 else |
766 else |
731 { |
767 { |
732 //</cmail> |
|
733 iAttachmentAddType = MsgAttachmentUtils::EUnknown; |
768 iAttachmentAddType = MsgAttachmentUtils::EUnknown; |
734 iAsyncAttachmentAdd->Cancel(); // cancel any outstanding callback just to be safe |
769 iAsyncAttachmentAdd->Cancel(); |
735 iAsyncAttachmentAdd->Set( TCallBack( AsyncAddAttachment, this ) ); |
770 iAsyncAttachmentAdd->Set( |
|
771 TCallBack( AsyncAddAttachment, this ) ); |
736 iAsyncAttachmentAdd->CallBack(); |
772 iAsyncAttachmentAdd->CallBack(); |
737 iContainer->SetMskL(); |
773 iContainer->SetMskL(); |
738 //<cmail> Touch |
|
739 } |
774 } |
740 //</cmail> |
|
741 } |
775 } |
742 break; |
776 break; |
743 case EFsEmailUiCmdOpenAttachment: |
777 case EFsEmailUiCmdOpenAttachment: |
744 case EFsEmailUiCmdOpenAttachmentList: |
778 case EFsEmailUiCmdOpenAttachmentList: |
745 { |
779 { |
746 DoOpenAttachmentListL(); |
780 DoOpenAttachmentListL(); |
747 } |
781 } |
748 break; |
782 break; |
749 case ENcsCmdRemoveAttachment: // remove one and only attachment |
783 case ENcsCmdRemoveAttachment: |
|
784 case EFsEmailUiCmdRemoveAttachment: |
|
785 { |
|
786 TInt index( iContainer->FocusedAttachmentLabelIndex() ); |
|
787 CFreestyleEmailUiSendAttachmentsListControl* ctrl = |
|
788 AttachmentsListControl(); |
|
789 if ( ctrl && KNoAttachmentLabelFocused != index ) |
|
790 { |
|
791 ctrl->RemoveAttachmentFromListL( index ); |
|
792 } |
|
793 SetAttachmentLabelContentL(); |
|
794 } |
|
795 break; |
750 case ENcsCmdRemoveAllAttachments: |
796 case ENcsCmdRemoveAllAttachments: |
751 { |
797 { |
752 AttachmentsListControl()->RemoveAllAttachmentsL(); |
798 CFreestyleEmailUiSendAttachmentsListControl* ctrl = |
|
799 AttachmentsListControl(); |
|
800 if ( ctrl ) |
|
801 { |
|
802 ctrl->RemoveAllAttachmentsL(); |
|
803 } |
753 SetAttachmentLabelContentL(); |
804 SetAttachmentLabelContentL(); |
754 } |
805 } |
755 break; |
806 break; |
756 case ENcsCmdPriorityHigh: |
807 case ENcsCmdPriorityHigh: |
757 { |
808 { |
758 iNewMessage->ResetFlag( EFSMsgFlag_Low ); |
809 iNewMessage->ResetFlag( EFSMsgFlag_Low ); |
759 iNewMessage->SetFlag( EFSMsgFlag_Important ); |
810 iNewMessage->SetFlag( EFSMsgFlag_Important ); |
760 iNewMessage->SaveMessageL(); |
811 iNewMessage->SaveMessageL(); |
761 iStatusPaneIndicators->SetPriorityFlag(EMsgPriorityHigh); |
812 iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityHigh ); |
762 } |
813 } |
763 break; |
814 break; |
764 case ENcsCmdPriorityNormal: |
815 case ENcsCmdPriorityNormal: |
765 { |
816 { |
766 iNewMessage->ResetFlag( EFSMsgFlag_Low ); |
817 iNewMessage->ResetFlag( EFSMsgFlag_Low ); |
767 iNewMessage->ResetFlag( EFSMsgFlag_Important ); |
818 iNewMessage->ResetFlag( EFSMsgFlag_Important ); |
768 iNewMessage->SaveMessageL(); |
819 iNewMessage->SaveMessageL(); |
769 iStatusPaneIndicators->SetPriorityFlag(EMsgPriorityNormal); |
820 iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityNormal ); |
770 } |
821 } |
771 break; |
822 break; |
772 case ENcsCmdPriorityLow: |
823 case ENcsCmdPriorityLow: |
773 { |
824 { |
774 iNewMessage->ResetFlag( EFSMsgFlag_Important ); |
825 iNewMessage->ResetFlag( EFSMsgFlag_Important ); |
775 iNewMessage->SetFlag( EFSMsgFlag_Low ); |
826 iNewMessage->SetFlag( EFSMsgFlag_Low ); |
776 iNewMessage->SaveMessageL(); |
827 iNewMessage->SaveMessageL(); |
777 iStatusPaneIndicators->SetPriorityFlag(EMsgPriorityLow); |
828 iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityLow ); |
778 } |
829 } |
779 break; |
830 break; |
780 case ENcsCmdShowCc: |
831 case ENcsCmdShowCc: |
781 { |
832 { |
782 iContainer->SetCcFieldVisibleL( ETrue ); |
833 iContainer->SetCcFieldVisibleL( ETrue ); |
992 TRAPD( saveError, SaveToDraftsL( ETrue ) ); |
1025 TRAPD( saveError, SaveToDraftsL( ETrue ) ); |
993 |
1026 |
994 if ( saveError == KErrNone ) |
1027 if ( saveError == KErrNone ) |
995 { |
1028 { |
996 // User wanted to save to Drafts and saving was successful |
1029 // User wanted to save to Drafts and saving was successful |
997 if(!iAppUi.AppUiExitOngoing()) //<cmail> |
1030 if( !iAppUi.AppUiExitOngoing() ) |
998 TFsEmailUiUtility::ShowInfoNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS, ETrue ); |
1031 TFsEmailUiUtility::ShowInfoNoteL( |
|
1032 R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS, |
|
1033 ETrue ); |
999 } |
1034 } |
1000 else |
1035 else |
1001 { |
1036 { |
1002 |
1037 |
1003 // error occured in saving -> show an error message |
1038 // error occured in saving -> show an error message |
1004 if(!iAppUi.AppUiExitOngoing()) //<cmail> |
1039 if( !iAppUi.AppUiExitOngoing() ) |
1005 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue ); |
1040 TFsEmailUiUtility::ShowErrorNoteL( |
|
1041 R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, |
|
1042 ETrue ); |
1006 |
1043 |
1007 // let's return EFalse so after completing this query |
1044 // let's return EFalse so after completing this query |
1008 // so the focus would stay in compose view (same behaviour as if Cancel was pressed ) |
1045 // so the focus would stay in compose view (same behaviour |
|
1046 // as if Cancel was pressed ) |
1009 result = EFalse; |
1047 result = EFalse; |
1010 } |
1048 } |
1011 } |
1049 } |
1012 break; |
1050 break; |
1013 case 1: |
1051 case 1: |
1014 { |
1052 { |
1015 TRAPD( error, SaveToDraftsL( ETrue ) ); |
1053 TRAPD( error, SaveToDraftsL( ETrue ) ); |
1016 if ( KErrNone != error ) |
1054 if ( KErrNone != error ) |
1017 { |
1055 { |
1018 } |
1056 } |
1019 iFakeSyncGoingOn = ETrue; //<cmail> for delete messages fake sync callscalls |
1057 // for delete messages fake sync calls |
|
1058 iFakeSyncGoingOn = ETrue; |
1020 error = NcsUtility::DeleteMessage( iMailClient, |
1059 error = NcsUtility::DeleteMessage( iMailClient, |
1021 iMailBox->GetId(), |
1060 iMailBox->GetId(), |
1022 iNewMessage->GetFolderId(), |
1061 iNewMessage->GetFolderId(), |
1023 iNewMessage->GetMessageId() ); |
1062 iNewMessage->GetMessageId() ); |
1024 |
1063 |
1025 if ( KErrNone == error && iMailBox->HasCapability( EFSMBoxCapaSupportsDeletedItemsFolder ) ) |
1064 if ( KErrNone == error && |
|
1065 iMailBox->HasCapability( |
|
1066 EFSMBoxCapaSupportsDeletedItemsFolder ) ) |
1026 { |
1067 { |
1027 error = NcsUtility::DeleteMessage( iMailClient, |
1068 error = NcsUtility::DeleteMessage( iMailClient, |
1028 iMailBox->GetId(), |
1069 iMailBox->GetId(), |
1029 iMailBox->GetStandardFolderId( EFSDeleted ), |
1070 iMailBox->GetStandardFolderId( EFSDeleted ), |
1030 iNewMessage->GetMessageId() ); |
1071 iNewMessage->GetMessageId() ); |
1031 } |
1072 } |
1032 iFakeSyncGoingOn = EFalse; //<cmail> |
1073 iFakeSyncGoingOn = EFalse; |
1033 |
1074 |
1034 if( !iAppUi.AppUiExitOngoing() ) |
1075 if( !iAppUi.AppUiExitOngoing() ) |
1035 { |
1076 { |
1036 if ( KErrNone != error ) |
1077 if ( KErrNone != error ) |
1037 { |
1078 { |
1038 // error occured in saving -> show an error message |
1079 // error occured in saving -> show an error message |
1039 TFsEmailUiUtility::ShowErrorNoteL( |
1080 TFsEmailUiUtility::ShowErrorNoteL( |
1040 R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue ); |
1081 R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, |
|
1082 ETrue ); |
1041 } |
1083 } |
1042 else |
1084 else |
1043 { |
1085 { |
1044 // Simulate delete event so that drafts folder is |
1086 // Simulate delete event so that drafts folder is |
1045 // updated correctly. |
1087 // updated correctly. |
1155 // ----------------------------------------------------------------------------- |
1200 // ----------------------------------------------------------------------------- |
1156 // |
1201 // |
1157 void CNcsComposeView::SetAttachmentLabelContentL() |
1202 void CNcsComposeView::SetAttachmentLabelContentL() |
1158 { |
1203 { |
1159 FUNC_LOG; |
1204 FUNC_LOG; |
1160 if ( iFirstStartCompleted ) // Safety |
1205 if ( iFirstStartCompleted && iContainer ) |
1161 { |
1206 { |
1162 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl; |
1207 CFreestyleEmailUiSendAttachmentsListControl* |
1163 attachmentControl = AttachmentsListControl(); |
1208 attachmentControl = AttachmentsListControl(); |
1164 |
1209 if ( !( attachmentControl && attachmentControl->Model() ) ) |
|
1210 { |
|
1211 return; |
|
1212 } |
|
1213 |
1165 // read number of attachments |
1214 // read number of attachments |
1166 TInt count = attachmentControl->Model()->Count(); |
1215 TInt count = attachmentControl->Model()->Count(); |
1167 |
1216 if ( count > 0 ) |
1168 if ( count > 1 ) |
1217 { |
1169 { |
1218 // Fill in the name and size descriptor arrays |
1170 TInt totalSizeInBytes = attachmentControl->Model()->TotalAttachmentSize(); |
1219 CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat( count ); |
1171 HBufC* stringBuf = NULL; |
1220 CleanupStack::PushL( nameArray ); |
1172 |
1221 CDesCArrayFlat* sizeArray = new (ELeave) CDesCArrayFlat( count ); |
1173 HBufC* sizeDesc = TFsEmailUiUtility::CreateSizeDescLC( totalSizeInBytes ); |
1222 CleanupStack::PushL( sizeArray ); |
1174 stringBuf = StringLoader::LoadL( R_NCS_ATTACHMENTS_FIELD_TEXT, |
1223 |
1175 *sizeDesc, count ); |
1224 for ( TInt i(0); i<count; ++i ) |
1176 CleanupStack::PopAndDestroy( sizeDesc ); |
1225 { |
1177 |
1226 CFSEmailUiSendAttachmentsListModelItem* item = |
1178 CleanupStack::PushL( stringBuf ); |
1227 static_cast<CFSEmailUiSendAttachmentsListModelItem*> |
1179 iContainer->SetAttachmentLabelTextL( *stringBuf ); |
1228 ( attachmentControl->Model()->Item( i ) ); |
1180 CleanupStack::PopAndDestroy( stringBuf ); |
1229 if ( item ) |
|
1230 { |
|
1231 nameArray->AppendL( item->FileName() ); |
|
1232 HBufC* sizeDesc = |
|
1233 TFsEmailUiUtility::CreateSizeDescLC( |
|
1234 item->FileSize() ); |
|
1235 sizeArray->AppendL( *sizeDesc ); |
|
1236 CleanupStack::PopAndDestroy( sizeDesc ); |
|
1237 } |
|
1238 } |
|
1239 iContainer->SetAttachmentLabelTextsLD( nameArray, sizeArray ); |
1181 iContainer->SetFocusToAttachmentField(); |
1240 iContainer->SetFocusToAttachmentField(); |
1182 } |
1241 |
1183 else if ( count == 1 ) |
1242 CleanupStack::Pop( sizeArray ); |
1184 { |
1243 CleanupStack::Pop( nameArray ); |
1185 CFSEmailUiSendAttachmentsListModelItem* item = |
|
1186 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( |
|
1187 attachmentControl->Model()->Item( 0 ) ); |
|
1188 |
|
1189 HBufC* sizeBuf = TFsEmailUiUtility::CreateSizeDescLC( item->FileSize() ); |
|
1190 iContainer->SetAttachmentLabelTextL( item->FileName(), *sizeBuf ); |
|
1191 CleanupStack::PopAndDestroy( sizeBuf ); |
|
1192 |
|
1193 iContainer->SetFocusToAttachmentField(); |
|
1194 } |
1244 } |
1195 else |
1245 else |
1196 { |
1246 { |
1197 iContainer->SetAttachmentLabelTextL( KNullDesC ); |
1247 iContainer->SetAttachmentLabelTextsLD( NULL, NULL ); |
1198 iContainer->HideAttachmentLabel(); |
1248 iContainer->HideAttachmentLabel(); |
1199 } |
1249 } |
1200 } |
1250 } |
1201 |
|
1202 } |
1251 } |
1203 |
1252 |
1204 |
1253 |
1205 // ----------------------------------------------------------------------------- |
1254 // ----------------------------------------------------------------------------- |
1206 // CNcsComposeView::AttachmentsListControl() |
1255 // CNcsComposeView::AttachmentsListControl() |
1207 // |
1256 // |
1208 // ----------------------------------------------------------------------------- |
1257 // ----------------------------------------------------------------------------- |
1209 // |
1258 // |
1210 CFreestyleEmailUiSendAttachmentsListControl* CNcsComposeView::AttachmentsListControl() |
1259 CFreestyleEmailUiSendAttachmentsListControl* |
|
1260 CNcsComposeView::AttachmentsListControl() |
1211 { |
1261 { |
1212 FUNC_LOG; |
1262 FUNC_LOG; |
1213 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl(0); |
1263 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl( NULL ); |
1214 if ( iFirstStartCompleted ) // Safety |
1264 if ( iFirstStartCompleted ) // Safety |
1215 { |
1265 { |
1216 CFSEmailUiSendAttachmentsListVisualiser* attachmentView = |
1266 CFSEmailUiSendAttachmentsListVisualiser* attachmentView = |
1217 static_cast<CFSEmailUiSendAttachmentsListVisualiser*>( |
1267 static_cast<CFSEmailUiSendAttachmentsListVisualiser*>( |
1218 iAvkonViewAppUi->View( SendAttachmentMngrViewId ) ); |
1268 iAvkonViewAppUi->View( SendAttachmentMngrViewId ) ); |
1219 attachmentControl = static_cast<CFreestyleEmailUiSendAttachmentsListControl*>( |
1269 if ( attachmentView ) |
1220 attachmentView->ViewerControl() ); |
1270 { |
|
1271 attachmentControl = |
|
1272 static_cast<CFreestyleEmailUiSendAttachmentsListControl*>( |
|
1273 attachmentView->ViewerControl() ); |
|
1274 } |
1221 } |
1275 } |
1222 return attachmentControl; |
1276 return attachmentControl; |
1223 } |
1277 } |
1224 |
1278 |
1225 // ----------------------------------------------------------------------------- |
1279 // ----------------------------------------------------------------------------- |
1249 iMailFetchingErrCode = KErrNone; |
1303 iMailFetchingErrCode = KErrNone; |
1250 |
1304 |
1251 if ( aCustomMessageId == TUid::Uid( KEditorCmdCreateNew ) ) |
1305 if ( aCustomMessageId == TUid::Uid( KEditorCmdCreateNew ) ) |
1252 { |
1306 { |
1253 iOrigMessage = NULL; |
1307 iOrigMessage = NULL; |
1254 iFakeSyncGoingOn = ETrue;//<cmail> this is actually a waited async method |
1308 iFakeSyncGoingOn = ETrue; |
1255 iNewMessage = iMailBox->CreateMessageToSend(); |
1309 iNewMessage = iMailBox->CreateMessageToSend(); |
1256 iFakeSyncGoingOn = EFalse; |
1310 iFakeSyncGoingOn = EFalse; |
1257 if ( !iNewMessage ) |
1311 if ( !iNewMessage ) |
1258 { |
1312 { |
1259 User::Leave( KErrGeneral ); |
1313 User::Leave( KErrGeneral ); |
1260 } |
1314 } |
1261 iFakeSyncGoingOn = ETrue; |
1315 iFakeSyncGoingOn = ETrue; |
1262 TFsEmailUiUtility::MoveMessageToDraftsL( *iMailBox, *iNewMessage ); |
1316 TFsEmailUiUtility::MoveMessageToDraftsL( *iMailBox, *iNewMessage ); |
1263 iFakeSyncGoingOn = EFalse;//<cmail> |
1317 iFakeSyncGoingOn = EFalse; |
1264 |
1318 |
1265 if ( iNewMessage->GetContentType() != KFSMailContentTypeMultipartMixed ) |
1319 if ( iNewMessage->GetContentType() != |
|
1320 KFSMailContentTypeMultipartMixed ) |
1266 { |
1321 { |
1267 iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed ); |
1322 iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed ); |
1268 iNewMessage->SaveMessageL(); |
1323 iNewMessage->SaveMessageL(); |
1269 } |
1324 } |
1270 |
1325 |
1271 TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart ); |
1326 TFsEmailUiUtility::CreatePlainTextPartL( |
|
1327 *iNewMessage, iNewMessageTextPart ); |
1272 IncludeMessageTextL( ETrue ); |
1328 IncludeMessageTextL( ETrue ); |
1273 AttachmentsListControl()->Model()->Clear(); |
1329 AttachmentsListControl()->Model()->Clear(); |
1274 iContainer->SelectAllToFieldTextL(); |
1330 iContainer->SelectAllToFieldTextL(); |
1275 } |
1331 } |
1276 else if ( aCustomMessageId == TUid::Uid( KEditorCmdReply ) || |
1332 else if ( aCustomMessageId == TUid::Uid( KEditorCmdReply ) || |
1277 aCustomMessageId == TUid::Uid( KEditorCmdReplyAll ) ) |
1333 aCustomMessageId == TUid::Uid( KEditorCmdReplyAll ) ) |
1278 { |
1334 { |
1279 |
1335 |
1280 iOrigMessage = iMailClient.GetMessageByUidL( iLaunchParams.iMailboxId, iLaunchParams.iFolderId, iLaunchParams.iMsgId, EFSMsgDataStructure ); |
1336 iOrigMessage = iMailClient.GetMessageByUidL( |
|
1337 iLaunchParams.iMailboxId, iLaunchParams.iFolderId, |
|
1338 iLaunchParams.iMsgId, EFSMsgDataStructure ); |
1281 if ( !iOrigMessage ) |
1339 if ( !iOrigMessage ) |
1282 { |
1340 { |
1283 User::Leave( KErrNotFound ); |
1341 User::Leave( KErrNotFound ); |
1284 } |
1342 } |
1285 |
1343 |
1286 SafeDelete( iFetchLogic ); |
1344 SafeDelete( iFetchLogic ); |
1287 iFetchLogic = CFsComposerFetchLogic::NewL( iMailClient, iLaunchParams.iMailboxId, |
1345 iFetchLogic = CFsComposerFetchLogic::NewL( |
1288 iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, *this, iAppUi ); |
1346 iMailClient, iLaunchParams.iMailboxId, |
|
1347 iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, |
|
1348 *this, iAppUi ); |
1289 ShowFetchingWaitNoteL(); |
1349 ShowFetchingWaitNoteL(); |
1290 iFetchLogic->RunReplyLogicL(); |
1350 iFetchLogic->RunReplyLogicL(); |
1291 |
1351 |
1292 // now fetch logic object runs its tasks and gives callback |
1352 // now fetch logic object runs its tasks and gives callback |
1293 // to CNcsComposeView::FetchLogicComplete when it is finished |
1353 // to CNcsComposeView::FetchLogicComplete when it is finished |
1294 } |
1354 } |
1295 else if ( aCustomMessageId == TUid::Uid( KEditorCmdForward ) ) |
1355 else if ( aCustomMessageId == TUid::Uid( KEditorCmdForward ) ) |
1296 { |
1356 { |
1297 |
1357 |
1298 iOrigMessage = iMailClient.GetMessageByUidL( iLaunchParams.iMailboxId, iLaunchParams.iFolderId, iLaunchParams.iMsgId, EFSMsgDataStructure ); |
1358 iOrigMessage = iMailClient.GetMessageByUidL( |
|
1359 iLaunchParams.iMailboxId, iLaunchParams.iFolderId, |
|
1360 iLaunchParams.iMsgId, EFSMsgDataStructure ); |
1299 if ( !iOrigMessage ) |
1361 if ( !iOrigMessage ) |
1300 { |
1362 { |
1301 User::Leave( KErrNotFound ); |
1363 User::Leave( KErrNotFound ); |
1302 } |
1364 } |
1303 |
1365 |
1304 SafeDelete( iFetchLogic ); |
1366 SafeDelete( iFetchLogic ); |
1305 iFetchLogic = CFsComposerFetchLogic::NewL( iMailClient, iLaunchParams.iMailboxId, |
1367 iFetchLogic = CFsComposerFetchLogic::NewL( |
1306 iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, *this, iAppUi ); |
1368 iMailClient, iLaunchParams.iMailboxId, |
|
1369 iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, |
|
1370 *this, iAppUi ); |
1307 ShowFetchingWaitNoteL(); |
1371 ShowFetchingWaitNoteL(); |
1308 iFetchLogic->RunForwardLogicL(); |
1372 iFetchLogic->RunForwardLogicL(); |
1309 |
1373 |
1310 // now fetch logic object runs its tasks and gives callback |
1374 // now fetch logic object runs its tasks and gives callback |
1311 // to CNcsComposeView::FetchLogicComplete when it is finished |
1375 // to CNcsComposeView::FetchLogicComplete when it is finished |
1312 } |
1376 } |
1313 else if ( aCustomMessageId == TUid::Uid( KEditorCmdOpen ) || |
1377 else if ( aCustomMessageId == TUid::Uid( KEditorCmdOpen ) || |
1314 aCustomMessageId == TUid::Uid( KEditorCmdReturnToPrevious ) ) // for now, we handle returning from attachments list just like any message opening |
1378 aCustomMessageId == TUid::Uid( KEditorCmdReturnToPrevious ) ) |
1315 { |
1379 { |
1316 |
1380 // for now, we handle returning from attachments list just like |
1317 iNewMessage = iMailClient.GetMessageByUidL( iLaunchParams.iMailboxId, iLaunchParams.iFolderId, iLaunchParams.iMsgId, EFSMsgDataStructure ); |
1381 // any message opening |
|
1382 iNewMessage = iMailClient.GetMessageByUidL( |
|
1383 iLaunchParams.iMailboxId, iLaunchParams.iFolderId, |
|
1384 iLaunchParams.iMsgId, EFSMsgDataStructure ); |
1318 if ( !iNewMessage ) |
1385 if ( !iNewMessage ) |
1319 { |
1386 { |
1320 User::Leave( KErrNotFound ); |
1387 User::Leave( KErrNotFound ); |
1321 } |
1388 } |
1322 |
1389 |
1323 // Show "Opening" wait note if the message body is large |
1390 // Show "Opening" wait note if the message body is large |
1324 TInt waitNoteId = KErrNotFound; |
1391 TInt waitNoteId = KErrNotFound; |
1325 if ( TFsEmailUiUtility::IsMessageBodyLargeL(iNewMessage) ) |
1392 if ( TFsEmailUiUtility::IsMessageBodyLargeL(iNewMessage) ) |
1326 { |
1393 { |
1327 waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( R_FSE_WAIT_OPENING_TEXT ); |
1394 waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( |
|
1395 R_FSE_WAIT_OPENING_TEXT ); |
1328 } |
1396 } |
1329 |
1397 |
1330 iOrigMessage = NULL; |
1398 iOrigMessage = NULL; |
1331 iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed ); |
1399 iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed ); |
1332 iNewMessage->SaveMessageL(); |
1400 iNewMessage->SaveMessageL(); |
1333 TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart ); |
1401 TFsEmailUiUtility::CreatePlainTextPartL( |
|
1402 *iNewMessage, iNewMessageTextPart ); |
1334 InitFieldsL(); |
1403 InitFieldsL(); |
1335 IncludeMessageTextL(); |
1404 IncludeMessageTextL(); |
1336 AttachmentsListControl()->Model()->Clear(); |
1405 AttachmentsListControl()->Model()->Clear(); |
1337 GetAttachmentsFromMailL(); |
1406 GetAttachmentsFromMailL(); |
1338 SetAttachmentLabelContentL(); |
1407 SetAttachmentLabelContentL(); |
1347 else if ( aCustomMessageId == TUid::Uid( KEditorCmdInternalMailto ) ) |
1416 else if ( aCustomMessageId == TUid::Uid( KEditorCmdInternalMailto ) ) |
1348 { |
1417 { |
1349 FUNC_LOG; |
1418 FUNC_LOG; |
1350 |
1419 |
1351 iOrigMessage = NULL; |
1420 iOrigMessage = NULL; |
1352 //<cmail> this is actually a waited async method |
|
1353 iFakeSyncGoingOn = ETrue; |
1421 iFakeSyncGoingOn = ETrue; |
1354 iNewMessage = iMailBox->CreateMessageToSend(); |
1422 iNewMessage = iMailBox->CreateMessageToSend(); |
1355 iFakeSyncGoingOn = EFalse; |
1423 iFakeSyncGoingOn = EFalse; |
1356 //</cmail> |
|
1357 if ( !iNewMessage ) |
1424 if ( !iNewMessage ) |
1358 { |
1425 { |
1359 User::Leave( KErrGeneral ); |
1426 User::Leave( KErrGeneral ); |
1360 } |
1427 } |
1361 iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed ); |
1428 iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed ); |
1362 iNewMessage->SaveMessageL(); |
1429 iNewMessage->SaveMessageL(); |
1363 |
1430 |
1364 TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart ); |
1431 TFsEmailUiUtility::CreatePlainTextPartL( |
|
1432 *iNewMessage, iNewMessageTextPart ); |
1365 |
1433 |
1366 IncludeMessageTextL( ETrue ); |
1434 IncludeMessageTextL( ETrue ); |
1367 |
1435 |
1368 CFSMailAddress* toAddress = static_cast<CFSMailAddress*>( iLaunchParams.iExtra ); // not owned |
1436 CFSMailAddress* toAddress = |
|
1437 static_cast<CFSMailAddress*>( iLaunchParams.iExtra ); // not owned |
1369 RPointerArray<CNcsEmailAddressObject> toRecipients; |
1438 RPointerArray<CNcsEmailAddressObject> toRecipients; |
1370 CleanupResetAndDestroyClosePushL( toRecipients ); |
1439 CleanupResetAndDestroyClosePushL( toRecipients ); |
1371 CNcsEmailAddressObject* ncsToAddress = NcsUtility::CreateNcsAddressL( *toAddress ); |
1440 CNcsEmailAddressObject* ncsToAddress = |
|
1441 NcsUtility::CreateNcsAddressL( *toAddress ); |
1372 CleanupStack::PushL( ncsToAddress ); |
1442 CleanupStack::PushL( ncsToAddress ); |
1373 toRecipients.AppendL( ncsToAddress ); |
1443 toRecipients.AppendL( ncsToAddress ); |
1374 CleanupStack::Pop( ncsToAddress ); // owned by toRecipients now |
1444 CleanupStack::Pop( ncsToAddress ); // owned by toRecipients now |
1375 iContainer->SetToFieldAddressesL( toRecipients ); |
1445 iContainer->SetToFieldAddressesL( toRecipients ); |
1376 CleanupStack::PopAndDestroy( &toRecipients ); |
1446 CleanupStack::PopAndDestroy( &toRecipients ); |
1447 FUNC_LOG; |
1519 FUNC_LOG; |
1448 |
1520 |
1449 __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) ); |
1521 __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) ); |
1450 |
1522 |
1451 // Get TO recipients |
1523 // Get TO recipients |
1452 RPointerArray<CFSMailAddress>& toRecipients = iNewMessage->GetToRecipients(); |
1524 RPointerArray<CFSMailAddress>& toRecipients = |
|
1525 iNewMessage->GetToRecipients(); |
1453 RPointerArray<CNcsEmailAddressObject> recipients; |
1526 RPointerArray<CNcsEmailAddressObject> recipients; |
1454 CleanupResetAndDestroyClosePushL( recipients ); |
1527 CleanupResetAndDestroyClosePushL( recipients ); |
1455 NcsUtility::ConvertAddressArrayL( toRecipients, recipients ); |
1528 NcsUtility::ConvertAddressArrayL( toRecipients, recipients ); |
1456 iContainer->SetToFieldAddressesL( recipients ); |
1529 iContainer->SetToFieldAddressesL( recipients ); |
1457 CleanupStack::PopAndDestroy( &recipients ); |
1530 CleanupStack::PopAndDestroy( &recipients ); |
1458 |
1531 |
1459 // Get CC recipients |
1532 // Get CC recipients |
1460 RPointerArray<CFSMailAddress>& ccRecipients = iNewMessage->GetCCRecipients(); |
1533 RPointerArray<CFSMailAddress>& ccRecipients = |
|
1534 iNewMessage->GetCCRecipients(); |
1461 NcsUtility::ConvertAddressArrayL( ccRecipients, recipients ); |
1535 NcsUtility::ConvertAddressArrayL( ccRecipients, recipients ); |
1462 iContainer->SetCcFieldAddressesL( recipients ); |
1536 iContainer->SetCcFieldAddressesL( recipients ); |
1463 recipients.ResetAndDestroy(); |
1537 recipients.ResetAndDestroy(); |
1464 |
1538 |
1465 // Get BCC recipients |
1539 // Get BCC recipients |
1466 RPointerArray<CFSMailAddress>& bccRecipients = iNewMessage->GetBCCRecipients(); |
1540 RPointerArray<CFSMailAddress>& bccRecipients = |
|
1541 iNewMessage->GetBCCRecipients(); |
1467 NcsUtility::ConvertAddressArrayL( bccRecipients, recipients ); |
1542 NcsUtility::ConvertAddressArrayL( bccRecipients, recipients ); |
1468 iContainer->SetBccFieldAddressesL( recipients ); |
1543 iContainer->SetBccFieldAddressesL( recipients ); |
1469 recipients.ResetAndDestroy(); |
1544 recipients.ResetAndDestroy(); |
1470 |
1545 |
1471 // Get subject line from original message |
1546 // Get subject line from original message |
1534 CleanupStack::PopAndDestroy( rawBody ); |
1611 CleanupStack::PopAndDestroy( rawBody ); |
1535 rawBody = NULL; |
1612 rawBody = NULL; |
1536 CleanupStack::PushL( body ); |
1613 CleanupStack::PushL( body ); |
1537 } |
1614 } |
1538 } |
1615 } |
1539 // If no modifications were needed, then just set body pointer to point the rawBody |
1616 // If no modifications were needed, then just set body pointer to point |
|
1617 // the rawBody |
1540 if ( !body ) |
1618 if ( !body ) |
1541 { |
1619 { |
1542 body = rawBody; |
1620 body = rawBody; |
1543 rawBody = NULL; |
1621 rawBody = NULL; |
1544 } |
1622 } |
1545 // Now we have possibly decorated message text in body pointer and in cleanup stack |
1623 // Now we have possibly decorated message text in body pointer and |
1546 |
1624 // in cleanup stack |
1547 // Divide the contents into normal body field and the read-only quote field |
1625 |
1548 TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2; // convert bytes to words |
1626 // Divide the contents into normal body and the read-only quote fields |
1549 TInt modifiableLength = body->Length() - readOnlyLength; |
1627 // Convert bytes length to words length |
1550 |
1628 TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2; |
1551 // Remove one newline from the end of the modifiable body if there's read-only quote present. |
1629 if ( body ) |
1552 // This is because the field boundary appears as newline on the screen. This newline |
1630 { |
1553 // is added back when saving the message. |
1631 TInt modifiableLength = body->Length() - readOnlyLength; |
1554 TInt lfLength = KIMSLineFeed().Length(); |
1632 |
1555 if ( readOnlyLength && modifiableLength >= lfLength && |
1633 // Remove one newline from the end of the modifiable body if there's |
1556 body->Mid( modifiableLength-lfLength, lfLength ) == KIMSLineFeed ) |
1634 // read-only quote present. This is because the field boundary appears |
1557 { |
1635 // as newline on the screen. This newline is added back when saving |
1558 modifiableLength -= lfLength; |
1636 // the message. |
1559 } |
1637 TInt lfLength = KIMSLineFeed().Length(); |
1560 |
1638 if ( readOnlyLength && modifiableLength >= lfLength && |
1561 iContainer->SetBodyContentL( body->Left( modifiableLength ), |
1639 body->Mid( modifiableLength-lfLength, lfLength ) == |
1562 body->Right( readOnlyLength ) ); |
1640 KIMSLineFeed ) |
|
1641 { |
|
1642 modifiableLength -= lfLength; |
|
1643 } |
|
1644 |
|
1645 iContainer->SetBodyContentL( body->Left( modifiableLength ), |
|
1646 body->Right( readOnlyLength ) ); |
|
1647 } |
1563 |
1648 |
1564 CleanupStack::PopAndDestroy( body ); |
1649 CleanupStack::PopAndDestroy( body ); |
1565 } |
1650 } |
1566 |
1651 |
1567 // ----------------------------------------------------------------------------- |
1652 // ----------------------------------------------------------------------------- |
1645 FUNC_LOG; |
1731 FUNC_LOG; |
1646 |
1732 |
1647 __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) ); |
1733 __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) ); |
1648 |
1734 |
1649 // to |
1735 // to |
1650 RPointerArray<CFSMailAddress>& toRecipients = iNewMessage->GetToRecipients(); |
1736 RPointerArray<CFSMailAddress>& toRecipients = |
|
1737 iNewMessage->GetToRecipients(); |
1651 RPointerArray<CNcsEmailAddressObject> ncsToRecipients; |
1738 RPointerArray<CNcsEmailAddressObject> ncsToRecipients; |
1652 CleanupResetAndDestroyClosePushL( ncsToRecipients ); |
1739 CleanupResetAndDestroyClosePushL( ncsToRecipients ); |
1653 NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients ); |
1740 NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients ); |
1654 iContainer->SetToFieldAddressesL( ncsToRecipients ); |
1741 iContainer->SetToFieldAddressesL( ncsToRecipients ); |
1655 CleanupStack::PopAndDestroy( &ncsToRecipients ); |
1742 CleanupStack::PopAndDestroy( &ncsToRecipients ); |
1656 |
1743 |
1657 // cc |
1744 // cc |
1658 RPointerArray<CFSMailAddress>& ccRecipients = iNewMessage->GetCCRecipients(); |
1745 RPointerArray<CFSMailAddress>& ccRecipients = |
|
1746 iNewMessage->GetCCRecipients(); |
1659 RPointerArray<CNcsEmailAddressObject> ncsCcRecipients; |
1747 RPointerArray<CNcsEmailAddressObject> ncsCcRecipients; |
1660 CleanupResetAndDestroyClosePushL( ncsCcRecipients ); |
1748 CleanupResetAndDestroyClosePushL( ncsCcRecipients ); |
1661 NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients ); |
1749 NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients ); |
1662 iContainer->SetCcFieldAddressesL( ncsCcRecipients ); |
1750 iContainer->SetCcFieldAddressesL( ncsCcRecipients ); |
1663 CleanupStack::PopAndDestroy( &ncsCcRecipients ); |
1751 CleanupStack::PopAndDestroy( &ncsCcRecipients ); |
1664 |
1752 |
1665 // bcc |
1753 // bcc |
1666 RPointerArray<CFSMailAddress>& bccRecipients = iNewMessage->GetBCCRecipients(); |
1754 RPointerArray<CFSMailAddress>& bccRecipients = |
|
1755 iNewMessage->GetBCCRecipients(); |
1667 RPointerArray<CNcsEmailAddressObject> ncsBccRecipients; |
1756 RPointerArray<CNcsEmailAddressObject> ncsBccRecipients; |
1668 CleanupResetAndDestroyClosePushL( ncsBccRecipients ); |
1757 CleanupResetAndDestroyClosePushL( ncsBccRecipients ); |
1669 NcsUtility::ConvertAddressArrayL( bccRecipients, ncsBccRecipients ); |
1758 NcsUtility::ConvertAddressArrayL( bccRecipients, ncsBccRecipients ); |
1670 iContainer->SetBccFieldAddressesL( ncsBccRecipients ); |
1759 iContainer->SetBccFieldAddressesL( ncsBccRecipients ); |
1671 CleanupStack::PopAndDestroy( &ncsBccRecipients ); |
1760 CleanupStack::PopAndDestroy( &ncsBccRecipients ); |
1754 if ( commitToField ) |
1844 if ( commitToField ) |
1755 { |
1845 { |
1756 // get addresses from UI to MSG object |
1846 // get addresses from UI to MSG object |
1757 RPointerArray<CFSMailAddress> toAddresses; |
1847 RPointerArray<CFSMailAddress> toAddresses; |
1758 CleanupResetAndDestroyClosePushL( toAddresses ); |
1848 CleanupResetAndDestroyClosePushL( toAddresses ); |
1759 NcsUtility::ConvertAddressArrayL( iContainer->GetToFieldAddressesL( aParseAddresses ), toAddresses ); |
1849 NcsUtility::ConvertAddressArrayL( |
|
1850 iContainer->GetToFieldAddressesL( aParseAddresses ), |
|
1851 toAddresses ); |
1760 iNewMessage->GetToRecipients().ResetAndDestroy(); |
1852 iNewMessage->GetToRecipients().ResetAndDestroy(); |
1761 for ( TInt i = 0 ; i < toAddresses.Count() ; i++ ) |
1853 for ( TInt i = 0 ; i < toAddresses.Count() ; i++ ) |
1762 { |
1854 { |
1763 iNewMessage->AppendToRecipient( toAddresses[i] ); |
1855 iNewMessage->AppendToRecipient( toAddresses[i] ); |
1764 // Ownership of the message pointer was transferred from our array to iNewMessage |
1856 // Ownership of the message pointer was transferred from our array |
|
1857 // to iNewMessage |
1765 toAddresses[i] = NULL; |
1858 toAddresses[i] = NULL; |
1766 } |
1859 } |
1767 CleanupStack::PopAndDestroy( &toAddresses ); |
1860 CleanupStack::PopAndDestroy( &toAddresses ); |
1768 } |
1861 } |
1769 |
1862 |
1770 if ( commitCcField ) |
1863 if ( commitCcField ) |
1771 { |
1864 { |
1772 RPointerArray<CFSMailAddress> ccAddresses; |
1865 RPointerArray<CFSMailAddress> ccAddresses; |
1773 CleanupResetAndDestroyClosePushL( ccAddresses ); |
1866 CleanupResetAndDestroyClosePushL( ccAddresses ); |
1774 NcsUtility::ConvertAddressArrayL( iContainer->GetCcFieldAddressesL( aParseAddresses ), ccAddresses ); |
1867 NcsUtility::ConvertAddressArrayL( |
|
1868 iContainer->GetCcFieldAddressesL( aParseAddresses ), |
|
1869 ccAddresses ); |
1775 iNewMessage->GetCCRecipients().ResetAndDestroy(); |
1870 iNewMessage->GetCCRecipients().ResetAndDestroy(); |
1776 for ( TInt i = 0 ; i < ccAddresses.Count() ; i++ ) |
1871 for ( TInt i = 0 ; i < ccAddresses.Count() ; i++ ) |
1777 { |
1872 { |
1778 iNewMessage->AppendCCRecipient( ccAddresses[i] ); |
1873 iNewMessage->AppendCCRecipient( ccAddresses[i] ); |
1779 // Ownership of the message pointer was transferred from our array to iNewMessage |
1874 // Ownership of the message pointer was transferred from |
|
1875 // our array to iNewMessage |
1780 ccAddresses[i] = NULL; |
1876 ccAddresses[i] = NULL; |
1781 } |
1877 } |
1782 CleanupStack::PopAndDestroy( &ccAddresses ); |
1878 CleanupStack::PopAndDestroy( &ccAddresses ); |
1783 } |
1879 } |
1784 |
1880 |
1785 if ( commitBccField ) |
1881 if ( commitBccField ) |
1786 { |
1882 { |
1787 RPointerArray<CFSMailAddress> bccAddresses; |
1883 RPointerArray<CFSMailAddress> bccAddresses; |
1788 CleanupResetAndDestroyClosePushL( bccAddresses ); |
1884 CleanupResetAndDestroyClosePushL( bccAddresses ); |
1789 NcsUtility::ConvertAddressArrayL( iContainer->GetBccFieldAddressesL( aParseAddresses ), bccAddresses ); |
1885 NcsUtility::ConvertAddressArrayL( |
|
1886 iContainer->GetBccFieldAddressesL( aParseAddresses ), |
|
1887 bccAddresses ); |
1790 iNewMessage->GetBCCRecipients().ResetAndDestroy(); |
1888 iNewMessage->GetBCCRecipients().ResetAndDestroy(); |
1791 for ( TInt i = 0; i < bccAddresses.Count() ; i++ ) |
1889 for ( TInt i = 0; i < bccAddresses.Count() ; i++ ) |
1792 { |
1890 { |
1793 iNewMessage->AppendBCCRecipient( bccAddresses[i] ); |
1891 iNewMessage->AppendBCCRecipient( bccAddresses[i] ); |
1794 // Ownership of the message pointer was transferred from our array to iNewMessage |
1892 // Ownership of the message pointer was transferred from |
|
1893 // our array to iNewMessage |
1795 bccAddresses[i] = NULL; |
1894 bccAddresses[i] = NULL; |
1796 } |
1895 } |
1797 CleanupStack::PopAndDestroy( &bccAddresses ); |
1896 CleanupStack::PopAndDestroy( &bccAddresses ); |
1798 } |
1897 } |
1799 |
1898 |
1800 if ( commitSubjectField ) |
1899 if ( commitSubjectField ) |
1801 { |
1900 { |
1802 // get subject from UI to MSG object |
1901 // get subject from UI to MSG object |
1803 HBufC* subject = iContainer->GetSubjectLC(); |
1902 HBufC* subject = iContainer->GetSubjectLC(); |
1804 TPtr ptr = subject->Des(); |
1903 TPtr ptr = subject->Des(); |
1805 // replace new line characters with spaces as Subject is normally one line only |
1904 // replace new line characters with spaces as Subject is normally |
1806 AknTextUtils::ReplaceCharacters( ptr, KLineSeparators, KReplacementChar ); |
1905 // one line only |
|
1906 AknTextUtils::ReplaceCharacters( |
|
1907 ptr, KLineSeparators, KReplacementChar ); |
1807 iNewMessage->SetSubject( *subject ); |
1908 iNewMessage->SetSubject( *subject ); |
1808 CleanupStack::PopAndDestroy( subject ); |
1909 CleanupStack::PopAndDestroy( subject ); |
1809 } |
1910 } |
1810 |
1911 |
1811 if ( commitBodyField ) |
1912 if ( commitBodyField ) |
1812 { |
1913 { |
1813 HBufC* body = iContainer->GetBodyContentLC(); |
1914 HBufC* body = iContainer->GetBodyContentLC(); |
1814 TPtr bodyPtr = body->Des(); // this TPtr is needed only because of incorrect argument type in FW API, can be removed when API fixed |
1915 TPtr bodyPtr = body->Des(); // this TPtr is needed only because of |
|
1916 // incorrect argument type in FW API, can be removed when API fixed |
1815 iNewMessageTextPart->SetContent( bodyPtr ); |
1917 iNewMessageTextPart->SetContent( bodyPtr ); |
1816 CleanupStack::PopAndDestroy( body ); |
1918 CleanupStack::PopAndDestroy( body ); |
1817 |
1919 |
1818 TInt error = KErrNone; |
1920 TInt error = KErrNone; |
1819 if ( iNewMessageTextPart ) |
1921 if ( iNewMessageTextPart ) |
1853 // ----------------------------------------------------------------------------- |
1955 // ----------------------------------------------------------------------------- |
1854 void CNcsComposeView::DoExitL( TExitMode aMode ) |
1956 void CNcsComposeView::DoExitL( TExitMode aMode ) |
1855 { |
1957 { |
1856 FUNC_LOG; |
1958 FUNC_LOG; |
1857 |
1959 |
1858 //<cmail> |
|
1859 TBool emptyMessage = ETrue; |
1960 TBool emptyMessage = ETrue; |
1860 |
1961 |
1861 if ( iAutoSaver && iContainer ) |
1962 if ( iAutoSaver && iContainer ) |
1862 { |
1963 { |
1863 iAutoSaver->Enable( EFalse ); |
1964 iAutoSaver->Enable( EFalse ); |
1864 |
1965 |
1865 // check that there's some user input in some header field or in message body |
1966 // check for some user input in some header field or in message body |
1866 TInt attaCount = AttachmentsListControl()->Model()->Count(); |
1967 TInt attaCount = AttachmentsListControl()->Model()->Count(); |
1867 emptyMessage = iContainer->AreAddressFieldsEmpty() && |
1968 emptyMessage = iContainer->AreAddressFieldsEmpty() && |
1868 iContainer->IsSubjectFieldEmpty() && |
1969 iContainer->IsSubjectFieldEmpty() && |
1869 iContainer->GetMessageFieldLength() < 1 && |
1970 iContainer->GetMessageFieldLength() < 1 && |
1870 attaCount <= 0; |
1971 attaCount <= 0; |
1871 } |
1972 } |
1872 //</cmail> |
|
1873 |
1973 |
1874 // Consider saving the draft if the message is not completely empty |
1974 // Consider saving the draft if the message is not completely empty |
1875 if ( !emptyMessage ) |
1975 if ( !emptyMessage ) |
1876 { |
1976 { |
1877 if ( aMode == ESaveDraftQuery && !iMailSent && !iMailSendFailed ) |
1977 if ( aMode == ESaveDraftQuery && !iMailSent && !iMailSendFailed ) |
1878 { |
1978 { |
1879 TBool actionSucceeded = EFalse; |
1979 TBool actionSucceeded = EFalse; |
1880 |
1980 |
1881 // DoSaveDraftL returns EFalse if the user query was cancelled or saving to Drafts failed |
1981 // DoSaveDraftL returns EFalse if the user query was cancelled |
|
1982 // or saving to Drafts failed |
1882 TRAPD( saveDraftError, actionSucceeded = DoSaveDraftL( ETrue ) ); |
1983 TRAPD( saveDraftError, actionSucceeded = DoSaveDraftL( ETrue ) ); |
1883 if ( saveDraftError == KErrNone ) |
1984 if ( saveDraftError == KErrNone ) |
1884 { |
1985 { |
1885 if ( !actionSucceeded ) |
1986 if ( !actionSucceeded ) |
1886 { |
1987 { |
1887 // return to normal action (cancel was pressed in the query) |
1988 // return to normal action |
|
1989 // (cancel was pressed in the query) |
1888 iAutoSaver->Enable( ETrue ); |
1990 iAutoSaver->Enable( ETrue ); |
1889 return; |
1991 return; |
1890 } |
1992 } |
1891 } |
1993 } |
1892 else |
1994 else |
1922 mailboxId, &messageIds, &folderId, NULL ); |
2026 mailboxId, &messageIds, &folderId, NULL ); |
1923 CleanupStack::PopAndDestroy( &messageIds ); |
2027 CleanupStack::PopAndDestroy( &messageIds ); |
1924 } |
2028 } |
1925 } |
2029 } |
1926 |
2030 |
1927 // <cmail> |
|
1928 // Clear attachment control now that message has been sent |
2031 // Clear attachment control now that message has been sent |
1929 // othewise this will kind of leak memory by leaving attachments |
2032 // othewise this will kind of leak memory by leaving attachments |
1930 // in the list, even if they have been sent. |
2033 // in the list, even if they have been sent. |
1931 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl; |
2034 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl; |
1932 attachmentControl = AttachmentsListControl(); |
2035 attachmentControl = AttachmentsListControl(); |
1933 if ( attachmentControl && attachmentControl->Model() ) |
2036 if ( attachmentControl && attachmentControl->Model() ) |
1934 { |
2037 { |
1935 attachmentControl->Model()->Clear(); |
2038 attachmentControl->Model()->Clear(); |
1936 } |
2039 } |
1937 // </cmail> |
|
1938 |
|
1939 ExitComposer(); |
2040 ExitComposer(); |
1940 |
|
1941 } |
2041 } |
1942 |
2042 |
1943 // ----------------------------------------------------------------------------- |
2043 // ----------------------------------------------------------------------------- |
1944 // CNcsComposeView::DoOpenAttachmentList |
2044 // CNcsComposeView::DoOpenAttachmentList |
1945 // Saves current editor message to drafts and opens attachment list view |
2045 // Opens the currently focused attachment |
1946 // ----------------------------------------------------------------------------- |
2046 // ----------------------------------------------------------------------------- |
1947 void CNcsComposeView::DoOpenAttachmentListL() |
2047 void CNcsComposeView::DoOpenAttachmentListL() |
1948 { |
2048 { |
1949 FUNC_LOG; |
2049 FUNC_LOG; |
1950 |
2050 |
1951 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl |
2051 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl |
1952 = AttachmentsListControl(); |
2052 = AttachmentsListControl(); |
1953 |
2053 |
1954 if ( attachmentControl->Model()->Count() == 1 ) |
2054 TInt index( iContainer ? iContainer->FocusedAttachmentLabelIndex() |
1955 { |
2055 : KNoAttachmentLabelFocused ); |
1956 CFSEmailUiSendAttachmentsListModelItem* item = |
2056 if ( KNoAttachmentLabelFocused != index && |
1957 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( |
2057 attachmentControl && attachmentControl->Model() ) |
1958 attachmentControl->Model()->Item( 0 ) ); |
2058 { |
1959 if ( !item->IsRemote() ) // we cannot open remote attachments |
2059 CFSEmailUiSendAttachmentsListModelItem* item = |
1960 { |
2060 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( |
1961 CFSMailMessagePart* msgPart = iNewMessage->ChildPartL( item->MailMsgPartId() ); |
2061 attachmentControl->Model()->Item( index ) ); |
1962 CleanupStack::PushL( msgPart ); |
2062 |
|
2063 if ( item && !item->IsRemote() ) // cannot open remote attachments |
|
2064 { |
|
2065 CFSMailMessagePart* msgPart = |
|
2066 iNewMessage->ChildPartL( item->MailMsgPartId() ); |
|
2067 CleanupStack::PushL( msgPart ); |
1963 TFsEmailUiUtility::OpenAttachmentL( *msgPart ); |
2068 TFsEmailUiUtility::OpenAttachmentL( *msgPart ); |
1964 CleanupStack::PopAndDestroy( msgPart ); |
2069 CleanupStack::PopAndDestroy( msgPart ); |
1965 } |
2070 } |
1966 } |
2071 } |
1967 // open attachment list |
|
1968 else |
|
1969 { |
|
1970 // set current email parameters to package buffer |
|
1971 TEditorLaunchParams editorParams; |
|
1972 editorParams.iMailboxId = iNewMessage->GetMailBoxId(); |
|
1973 editorParams.iMsgId = iNewMessage->GetMessageId(); |
|
1974 editorParams.iFolderId = iNewMessage->GetFolderId(); |
|
1975 editorParams.iActivatedExternally = EFalse; |
|
1976 TPckgBuf<TEditorLaunchParams> buf( editorParams ); |
|
1977 |
|
1978 // save email to drafts |
|
1979 iAttachmentListSaveDraft = ETrue; |
|
1980 TRAPD( saveDraftError, DoSaveDraftL( EFalse ) ); |
|
1981 if ( saveDraftError != KErrNone ) |
|
1982 { |
|
1983 // error occured in saving -> show an error message |
|
1984 if ( !iAppUi.AppUiExitOngoing() ) //<cmail> |
|
1985 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue ); |
|
1986 return; |
|
1987 } |
|
1988 |
|
1989 // open attachment list view |
|
1990 iAppUi.EnterFsEmailViewL( |
|
1991 SendAttachmentMngrViewId, |
|
1992 TUid::Uid( KEditorCmdOpenAttachmentsList ), |
|
1993 buf ); |
|
1994 } |
|
1995 |
|
1996 } |
2072 } |
1997 |
2073 |
1998 // ----------------------------------------------------------------------------- |
2074 // ----------------------------------------------------------------------------- |
1999 // CNcsComposeView::LaunchAttachmentActionMenuL |
2075 // CNcsComposeView::LaunchStylusPopupMenu |
2000 // Show action menu for the attachments line |
2076 // Show stylus popup menu for the attachments line |
2001 // ----------------------------------------------------------------------------- |
2077 // ----------------------------------------------------------------------------- |
2002 // |
2078 // |
2003 void CNcsComposeView::LaunchAttachmentActionMenuL() |
2079 void CNcsComposeView::LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation ) |
2004 { |
2080 { |
2005 FUNC_LOG; |
2081 FUNC_LOG; |
2006 |
2082 |
2007 // Remove old items from action menu |
2083 CFSEmailUiSendAttachmentsListModel* attachmentModel = |
2008 CFSEmailUiActionMenu::RemoveAllL(); |
2084 ( AttachmentsListControl() ? |
2009 |
2085 AttachmentsListControl()->Model() : NULL ); |
2010 // Construct item list |
2086 TInt count( attachmentModel ? attachmentModel->Count() : 0 ); |
2011 RFsEActionMenuIdList itemList; |
2087 TBool attachmentsInModel( count > 0 ); |
2012 CleanupClosePushL( itemList ); |
2088 CFSEmailUiSendAttachmentsListModelItem* item( NULL ); |
2013 |
2089 |
2014 CFreestyleEmailUiSendAttachmentsListControl* attachmentControl = |
2090 if ( attachmentsInModel ) |
2015 AttachmentsListControl(); |
2091 { |
2016 TInt count = attachmentControl->Model()->Count(); |
2092 item = static_cast<CFSEmailUiSendAttachmentsListModelItem*>( |
2017 TBool remoteAtt = AttachmentsListControl()->Model()->HasRemoteAttachments(); |
2093 attachmentModel->Item( |
2018 TBool readOnlyAtt = AttachmentsListControl()->Model()->HasReadOnlyAttachments(); |
2094 iContainer->FocusedAttachmentLabelIndex() ) ); |
2019 |
2095 if ( !item || item->IsRemote() ) |
2020 // Open/View all |
2096 { |
2021 if ( count == 1 && !remoteAtt ) |
2097 // Only non-remote attachments can be opened |
2022 { |
2098 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue ); |
2023 itemList.AppendL( FsEActionAttachmentOpen ); |
2099 } |
2024 } |
2100 } |
2025 else if ( count > 1 ) |
2101 |
2026 { |
2102 if ( !item || item->IsReadOnly() ) |
2027 itemList.AppendL( FsEActionAttachmentViewAll ); |
2103 { |
2028 } |
2104 // Only non-readonly attachments can be removed |
2029 |
2105 iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdRemoveAttachment, ETrue ); |
2030 // Add |
2106 } |
2031 itemList.AppendL( FsEActionAttachmentAdd ); |
2107 |
2032 |
2108 // Set the position for the popup |
2033 // Remove/Remove all |
2109 iStylusPopUpMenu->SetPosition( aPenEventScreenLocation ); |
2034 if ( !readOnlyAtt ) |
2110 |
2035 { |
2111 // Display the popup. |
2036 if ( count == 1 ) |
2112 iStylusPopUpMenu->ShowMenu(); |
2037 { |
2113 } |
2038 itemList.AppendL( FsEActionAttachmentRemove ); |
|
2039 } |
|
2040 else if ( count > 1 ) |
|
2041 { |
|
2042 itemList.AppendL( FsEActionAttachmentRemoveAll ); |
|
2043 } |
|
2044 } |
|
2045 |
|
2046 // Execute action list |
|
2047 TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList ); |
|
2048 CleanupStack::PopAndDestroy( &itemList ); |
|
2049 |
|
2050 // Handle action menu selection |
|
2051 switch ( itemId ) |
|
2052 { |
|
2053 case FsEActionAttachmentOpen: |
|
2054 HandleCommandL( EFsEmailUiCmdOpenAttachment ); |
|
2055 break; |
|
2056 case FsEActionAttachmentViewAll: |
|
2057 HandleCommandL( EFsEmailUiCmdOpenAttachmentList ); |
|
2058 break; |
|
2059 case FsEActionAttachmentRemove: |
|
2060 HandleCommandL( ENcsCmdRemoveAttachment ); |
|
2061 break; |
|
2062 case FsEActionAttachmentRemoveAll: |
|
2063 HandleCommandL( ENcsCmdRemoveAllAttachments ); |
|
2064 break; |
|
2065 case FsEActionAttachmentAdd: |
|
2066 HandleCommandL( ENcsCmdAddAttachment ); |
|
2067 break; |
|
2068 default: |
|
2069 break; |
|
2070 } |
|
2071 |
|
2072 } |
|
2073 |
|
2074 //<cmail> |
|
2075 // ----------------------------------------------------------------------------- |
|
2076 // CNcsComposeView::DismissAttachmentActionMenuL |
|
2077 // |
|
2078 // ----------------------------------------------------------------------------- |
|
2079 // |
|
2080 void CNcsComposeView::DismissAttachmentActionMenuL() |
|
2081 { |
|
2082 FUNC_LOG; |
|
2083 CFSEmailUiActionMenu::Dismiss( ETrue ); |
|
2084 } |
|
2085 //</cmail> |
|
2086 |
2114 |
2087 // ----------------------------------------------------------------------------- |
2115 // ----------------------------------------------------------------------------- |
2088 // CNcsComposeView::GetAttachmentsFromMail |
2116 // CNcsComposeView::GetAttachmentsFromMail |
2089 // ----------------------------------------------------------------------------- |
2117 // ----------------------------------------------------------------------------- |
2090 void CNcsComposeView::GetAttachmentsFromMailL() |
2118 void CNcsComposeView::GetAttachmentsFromMailL() |
2164 FUNC_LOG; |
2194 FUNC_LOG; |
2165 |
2195 |
2166 __ASSERT_DEBUG( iOrigMessage, Panic( ENcsBasicUi ) ); |
2196 __ASSERT_DEBUG( iOrigMessage, Panic( ENcsBasicUi ) ); |
2167 |
2197 |
2168 // separator line |
2198 // separator line |
2169 HBufC* separator = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_MESSAGE_LINE_SEPARATOR ); //1 |
2199 HBufC* separator = |
|
2200 StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_MESSAGE_LINE_SEPARATOR ); //1 |
2170 |
2201 |
2171 // from line |
2202 // from line |
2172 RPointerArray<CNcsEmailAddressObject> senderArray; |
2203 RPointerArray<CNcsEmailAddressObject> senderArray; |
2173 CleanupResetAndDestroyClosePushL( senderArray ); |
2204 CleanupResetAndDestroyClosePushL( senderArray ); |
2174 CFSMailAddress* sender = iOrigMessage->GetSender(); |
2205 CFSMailAddress* sender = iOrigMessage->GetSender(); |
2175 if ( sender ) |
2206 if ( sender ) |
2176 { |
2207 { |
2177 CNcsEmailAddressObject* ncsSender = NcsUtility::CreateNcsAddressL( *sender ); |
2208 CNcsEmailAddressObject* ncsSender = |
|
2209 NcsUtility::CreateNcsAddressL( *sender ); |
2178 CleanupStack::PushL( ncsSender ); |
2210 CleanupStack::PushL( ncsSender ); |
2179 senderArray.AppendL( ncsSender ); |
2211 senderArray.AppendL( ncsSender ); |
2180 CleanupStack::Pop( ncsSender ); // now owned by senderArray |
2212 CleanupStack::Pop( ncsSender ); // now owned by senderArray |
2181 } |
2213 } |
2182 HBufC* fromLine = NcsUtility::GenerateFromLineToMessageBodyL( senderArray ); |
2214 HBufC* fromLine = |
|
2215 NcsUtility::GenerateFromLineToMessageBodyL( senderArray ); |
2183 CleanupStack::PopAndDestroy( &senderArray ); |
2216 CleanupStack::PopAndDestroy( &senderArray ); |
2184 CleanupStack::PushL( fromLine ); //2 |
2217 CleanupStack::PushL( fromLine ); //2 |
2185 |
2218 |
2186 // sent line |
2219 // sent line |
2187 HBufC* sentLine = NcsUtility::GenerateSentLineToMessageBodyL( *iOrigMessage ); |
2220 HBufC* sentLine = |
|
2221 NcsUtility::GenerateSentLineToMessageBodyL( *iOrigMessage ); |
2188 CleanupStack::PushL( sentLine ); //3 |
2222 CleanupStack::PushL( sentLine ); //3 |
2189 |
2223 |
2190 // to line |
2224 // to line |
2191 RPointerArray<CNcsEmailAddressObject> ncsToRecipients; |
2225 RPointerArray<CNcsEmailAddressObject> ncsToRecipients; |
2192 CleanupResetAndDestroyClosePushL( ncsToRecipients ); |
2226 CleanupResetAndDestroyClosePushL( ncsToRecipients ); |
2193 RPointerArray<CFSMailAddress>& toRecipients = iOrigMessage->GetToRecipients(); |
2227 RPointerArray<CFSMailAddress>& toRecipients = |
|
2228 iOrigMessage->GetToRecipients(); |
2194 NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients ); |
2229 NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients ); |
2195 HBufC* toLine = NcsUtility::GenerateAddressLineToMessageBodyL( ncsToRecipients, NcsUtility::ERecipientTypeTo ); |
2230 HBufC* toLine = NcsUtility::GenerateAddressLineToMessageBodyL( |
|
2231 ncsToRecipients, NcsUtility::ERecipientTypeTo ); |
2196 CleanupStack::PopAndDestroy( &ncsToRecipients ); |
2232 CleanupStack::PopAndDestroy( &ncsToRecipients ); |
2197 CleanupStack::PushL( toLine ); //4 |
2233 CleanupStack::PushL( toLine ); //4 |
2198 |
2234 |
2199 // cc line |
2235 // cc line |
2200 RPointerArray<CFSMailAddress>& ccRecipients = iOrigMessage->GetCCRecipients(); |
2236 RPointerArray<CFSMailAddress>& ccRecipients = |
|
2237 iOrigMessage->GetCCRecipients(); |
2201 TBool hasCcLine = ( ccRecipients.Count() > 0 ); |
2238 TBool hasCcLine = ( ccRecipients.Count() > 0 ); |
2202 HBufC* ccLine = NULL; |
2239 HBufC* ccLine = NULL; |
2203 if ( hasCcLine ) |
2240 if ( hasCcLine ) |
2204 { |
2241 { |
2205 RPointerArray<CNcsEmailAddressObject> ncsCcRecipients; |
2242 RPointerArray<CNcsEmailAddressObject> ncsCcRecipients; |
2206 CleanupResetAndDestroyClosePushL( ncsCcRecipients ); |
2243 CleanupResetAndDestroyClosePushL( ncsCcRecipients ); |
2207 NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients ); |
2244 NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients ); |
2208 ccLine = NcsUtility::GenerateAddressLineToMessageBodyL( ncsCcRecipients, NcsUtility::ERecipientTypeCc ); |
2245 ccLine = NcsUtility::GenerateAddressLineToMessageBodyL( |
|
2246 ncsCcRecipients, NcsUtility::ERecipientTypeCc ); |
2209 CleanupStack::PopAndDestroy( &ncsCcRecipients ); |
2247 CleanupStack::PopAndDestroy( &ncsCcRecipients ); |
2210 CleanupStack::PushL( ccLine ); //5 |
2248 CleanupStack::PushL( ccLine ); //5 |
2211 } |
2249 } |
2212 |
2250 |
2213 // subject line |
2251 // subject line |
2214 HBufC* subjectLine = NcsUtility::GenerateSubjectLineToMessageBodyL( iOrigMessage->GetSubject() ); |
2252 HBufC* subjectLine = NcsUtility::GenerateSubjectLineToMessageBodyL( |
|
2253 iOrigMessage->GetSubject() ); |
2215 CleanupStack::PushL( subjectLine ); //6 |
2254 CleanupStack::PushL( subjectLine ); //6 |
2216 |
2255 |
2217 // Body |
2256 // Body |
2218 HBufC* body = NULL; |
2257 HBufC* body = NULL; |
2219 TBool hasBody = EFalse; |
2258 TBool hasBody = EFalse; |
2648 iFakeSyncGoingOn = EFalse; |
2685 iFakeSyncGoingOn = EFalse; |
2649 User::LeaveIfError( error ); |
2686 User::LeaveIfError( error ); |
2650 |
2687 |
2651 if ( !iAppUi.AppUiExitOngoing() ) |
2688 if ( !iAppUi.AppUiExitOngoing() ) |
2652 { |
2689 { |
2653 // Simulate a new mail event to ensure that saved message becomes visible in the |
2690 // Simulate a new mail event to ensure that saved message becomes |
2654 // mail list. All protocols do not send event automatically in this case. |
2691 // visible in the mail list. |
|
2692 // All protocols do not send event automatically in this case. |
2655 RArray<TFSMailMsgId> messageIdArray; |
2693 RArray<TFSMailMsgId> messageIdArray; |
2656 CleanupClosePushL( messageIdArray ); |
2694 CleanupClosePushL( messageIdArray ); |
2657 messageIdArray.Append( iNewMessage->GetMessageId() ); |
2695 messageIdArray.Append( iNewMessage->GetMessageId() ); |
2658 TFSMailMsgId folderId = iNewMessage->GetFolderId(); |
2696 TFSMailMsgId folderId = iNewMessage->GetFolderId(); |
2659 TFSMailMsgId mailboxId = iNewMessage->GetMailBoxId(); |
2697 TFSMailMsgId mailboxId = iNewMessage->GetMailBoxId(); |
2660 iAppUi.EventL( |
2698 iAppUi.EventL( |
2661 TFSEventNewMail, mailboxId, &messageIdArray, &folderId, NULL ); |
2699 TFSEventNewMail, mailboxId, &messageIdArray, &folderId, NULL ); |
2662 // Update displayed mail info if the mail was already created sooner |
2700 // Update displayed mail info if the mail was created previously |
2663 iAppUi.EventL( |
2701 iAppUi.EventL( |
2664 TFSEventMailChanged, mailboxId, &messageIdArray, &folderId, NULL ); |
2702 TFSEventMailChanged, mailboxId, &messageIdArray, |
|
2703 &folderId, NULL ); |
2665 CleanupStack::PopAndDestroy( &messageIdArray ); |
2704 CleanupStack::PopAndDestroy( &messageIdArray ); |
2666 } |
2705 } |
2667 } |
2706 } |
2668 } |
2707 } |
2669 |
2708 |
2670 // ----------------------------------------------------------------------------- |
2709 // ----------------------------------------------------------------------------- |
2671 // CNcsComposeView::FetchLogicComplete |
2710 // CNcsComposeView::FetchLogicComplete |
2672 // ----------------------------------------------------------------------------- |
2711 // ----------------------------------------------------------------------------- |
2673 // |
2712 // |
2674 TBool CNcsComposeView::FetchLogicComplete( TComposerFetchState /*aState*/, TInt aError ) |
2713 TBool CNcsComposeView::FetchLogicComplete( |
|
2714 TComposerFetchState /*aState*/, TInt aError ) |
2675 { |
2715 { |
2676 FUNC_LOG; |
2716 FUNC_LOG; |
2677 TBool result = EFalse; |
2717 TBool result = EFalse; |
2678 if ( iFirstStartCompleted ) // Safety |
2718 if ( iFirstStartCompleted ) // Safety |
2679 { |
2719 { |
2917 // --------------------------------------------------------------------------- |
2963 // --------------------------------------------------------------------------- |
2918 // |
2964 // |
2919 void CActiveHelper::Start() |
2965 void CActiveHelper::Start() |
2920 { |
2966 { |
2921 TRequestStatus* status = &iStatus; |
2967 TRequestStatus* status = &iStatus; |
2922 User::RequestComplete(status,KErrNone); |
2968 User::RequestComplete( status, KErrNone ); |
2923 SetActive(); |
2969 SetActive(); |
2924 } |
2970 } |
2925 |
2971 |
2926 // --------------------------------------------------------------------------- |
2972 // --------------------------------------------------------------------------- |
2927 // CActiveHelper::CActiveHelper() |
2973 // CActiveHelper::CActiveHelper() |
2928 // --------------------------------------------------------------------------- |
2974 // --------------------------------------------------------------------------- |
2929 // |
2975 // |
2930 CActiveHelper::CActiveHelper(CNcsComposeView* aSession ) : CActive(EPriorityLow) |
2976 CActiveHelper::CActiveHelper( CNcsComposeView* aSession ) |
|
2977 : CActive( EPriorityLow ) |
2931 { |
2978 { |
2932 iComposeView = aSession; |
2979 iComposeView = aSession; |
2933 } |
2980 } |
2934 |
2981 |
2935 // --------------------------------------------------------------------------- |
2982 // --------------------------------------------------------------------------- |
2936 // CActiveHelper::RunL() |
2983 // CActiveHelper::RunL() |
2937 // --------------------------------------------------------------------------- |
2984 // --------------------------------------------------------------------------- |
2938 // |
2985 // |
2939 void CActiveHelper::RunL() |
2986 void CActiveHelper::RunL() |
2940 { |
2987 { |
2941 if(iComposeView) |
2988 if( iComposeView ) |
2942 iComposeView->AsyncExitL(); |
2989 iComposeView->AsyncExitL(); |
2943 } |
2990 } |
2944 |
2991 |
2945 // --------------------------------------------------------------------------- |
2992 // --------------------------------------------------------------------------- |
2946 // CActiveHelper::DoCancel() |
2993 // CActiveHelper::DoCancel() |