165 delete iReplyTo; |
174 delete iReplyTo; |
166 iReplyTo = NULL; |
175 iReplyTo = NULL; |
167 } |
176 } |
168 return iReplyTo; |
177 return iReplyTo; |
169 } |
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 // ----------------------------------------------------------------------------- |
|
183 void CEmailMessage::SetReplyToAddressL( const MEmailAddress& aSender ) |
|
184 { |
|
185 User::LeaveIfNull( iPluginMessage ); |
170 |
186 |
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 // ----------------------------------------------------------------------------- |
|
174 void CEmailMessage::SetReplyToAddressL( const MEmailAddress& aSender ) |
|
175 { |
|
176 CFSMailAddress *fsAddress = CFSMailAddress::NewLC(); |
187 CFSMailAddress *fsAddress = CFSMailAddress::NewLC(); |
177 if (!iReplyTo) |
188 if ( !iReplyTo ) |
178 { |
189 { |
179 iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns); |
190 iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns ); |
180 } |
191 } |
181 fsAddress->SetDisplayName( aSender.DisplayName() ); |
192 fsAddress->SetDisplayName( aSender.DisplayName() ); |
182 fsAddress->SetEmailAddress( aSender.Address() ); |
193 fsAddress->SetEmailAddress( aSender.Address() ); |
183 iPluginMessage->SetReplyToAddress( fsAddress ); |
194 iPluginMessage->SetReplyToAddress( fsAddress ); |
184 iReplyTo->SetAddressL( fsAddress->GetEmailAddress() ); |
195 iReplyTo->SetAddressL( fsAddress->GetEmailAddress() ); |
185 iReplyTo->SetDisplayNameL( fsAddress->GetDisplayName() ); |
196 iReplyTo->SetDisplayNameL( fsAddress->GetDisplayName() ); |
186 CleanupStack::Pop(); |
197 CleanupStack::Pop(); |
187 } |
198 } |
188 |
199 |
189 // ----------------------------------------------------------------------------- |
200 // ----------------------------------------------------------------------------- |
190 // |
201 // |
191 // ----------------------------------------------------------------------------- |
202 // ----------------------------------------------------------------------------- |
192 TInt CEmailMessage::GetRecipientsL( const MEmailAddress::TRole aRole, |
203 TInt CEmailMessage::GetRecipientsL( const MEmailAddress::TRole aRole, |
193 REmailAddressArray& aRecipients ) const |
204 REmailAddressArray& aRecipients ) const |
194 { |
205 { |
195 if( aRole == MEmailAddress::EReplyTo || |
206 if( aRole == MEmailAddress::EReplyTo || |
196 aRole == MEmailAddress::ESender ) |
207 aRole == MEmailAddress::ESender ) |
197 { |
208 { |
198 User::Leave( KErrArgument ); |
209 User::Leave( KErrArgument ); |
199 } |
210 } |
200 else |
211 else |
201 { |
212 { |
|
213 User::LeaveIfNull( iPluginMessage ); |
|
214 |
202 if( aRole == MEmailAddress::ETo || |
215 if( aRole == MEmailAddress::ETo || |
203 aRole == MEmailAddress::EUndefined ) |
216 aRole == MEmailAddress::EUndefined ) |
204 { |
217 { |
205 RPointerArray<CFSMailAddress>& toRecipients = |
218 const RPointerArray<CFSMailAddress>& toRecipients = |
206 iPluginMessage->GetToRecipients(); |
219 iPluginMessage->GetToRecipients(); |
207 ConvertAddressArrayL( |
220 ConvertAddressArrayL( |
208 MEmailAddress::ETo, |
221 MEmailAddress::ETo, |
209 toRecipients, aRecipients ); |
222 toRecipients, aRecipients ); |
210 } |
223 } |
211 if( aRole == MEmailAddress::ECc || |
224 if( aRole == MEmailAddress::ECc || |
212 aRole == MEmailAddress::EUndefined ) |
225 aRole == MEmailAddress::EUndefined ) |
213 { |
226 { |
214 RPointerArray<CFSMailAddress>& ccRecipients = |
227 const RPointerArray<CFSMailAddress>& ccRecipients = |
215 iPluginMessage->GetCCRecipients(); |
228 iPluginMessage->GetCCRecipients(); |
216 ConvertAddressArrayL( |
229 ConvertAddressArrayL( |
217 MEmailAddress::ECc, |
230 MEmailAddress::ECc, |
218 ccRecipients, aRecipients ); |
231 ccRecipients, aRecipients ); |
219 } |
232 } |
220 if( aRole == MEmailAddress::EBcc || |
233 if( aRole == MEmailAddress::EBcc || |
221 aRole == MEmailAddress::EUndefined ) |
234 aRole == MEmailAddress::EUndefined ) |
222 { |
235 { |
223 RPointerArray<CFSMailAddress>& bccRecipients = |
236 const RPointerArray<CFSMailAddress>& bccRecipients = |
224 iPluginMessage->GetBCCRecipients(); |
237 iPluginMessage->GetBCCRecipients(); |
225 ConvertAddressArrayL( |
238 ConvertAddressArrayL( |
226 MEmailAddress::EBcc, |
239 MEmailAddress::EBcc, |
227 bccRecipients, aRecipients ); |
240 bccRecipients, aRecipients ); |
228 } |
241 } |
229 } |
242 } |
230 return aRecipients.Count(); |
243 return aRecipients.Count(); |
231 } |
244 } |
232 |
245 |
233 // ----------------------------------------------------------------------------- |
246 // ----------------------------------------------------------------------------- |
234 // |
247 // |
235 // ----------------------------------------------------------------------------- |
248 // ----------------------------------------------------------------------------- |
236 void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole, |
249 void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole, |
237 REmailAddressArray& aRecipients ) |
250 REmailAddressArray& aRecipients ) |
238 { |
251 { |
239 TInt count( aRecipients.Count() ); |
252 TInt count( aRecipients.Count() ); |
240 |
253 |
241 for( TInt i=0;i<count;i++ ) |
254 for( TInt i=0;i<count;i++ ) |
242 { |
255 { |
243 const MEmailAddress* address = aRecipients[i]; |
256 const MEmailAddress* address = aRecipients[i]; |
244 CFSMailAddress* fsAddress = CFSMailAddress::NewLC(); |
257 CFSMailAddress* fsAddress = CFSMailAddress::NewLC(); |
245 fsAddress->SetEmailAddress( address->Address() ); |
258 fsAddress->SetEmailAddress( address->Address() ); |
246 fsAddress->SetDisplayName( address->DisplayName() ); |
259 fsAddress->SetDisplayName( address->DisplayName() ); |
247 |
260 |
|
261 User::LeaveIfNull( iPluginMessage ); |
|
262 |
248 if( aRole == MEmailAddress::ETo ) |
263 if( aRole == MEmailAddress::ETo ) |
249 { |
264 { |
250 iPluginMessage->AppendToRecipient( fsAddress ); |
265 iPluginMessage->AppendToRecipient( fsAddress ); |
251 } |
266 } |
252 else if( aRole == MEmailAddress::ECc ) |
267 else if( aRole == MEmailAddress::ECc ) |
262 User::Leave( KErrArgument ); |
277 User::Leave( KErrArgument ); |
263 } |
278 } |
264 CleanupStack::Pop( fsAddress ); |
279 CleanupStack::Pop( fsAddress ); |
265 } |
280 } |
266 } |
281 } |
267 |
282 |
268 // ----------------------------------------------------------------------------- |
283 // ----------------------------------------------------------------------------- |
269 // |
284 // |
270 // ----------------------------------------------------------------------------- |
285 // ----------------------------------------------------------------------------- |
271 void CEmailMessage::RemoveRecipientL( const MEmailAddress& aRecipient ) |
286 void CEmailMessage::RemoveRecipientL( const MEmailAddress& /*aRecipient*/ ) |
272 { |
287 { |
273 TInt err( KErrNotFound ); |
288 User::Leave( KErrNotSupported ); |
274 RPointerArray<CFSMailAddress>* recipients = NULL; |
289 } |
275 |
290 |
276 switch (aRecipient.Role()) |
|
277 { |
|
278 case MEmailAddress::ETo: |
|
279 recipients = &iPluginMessage->GetToRecipients(); |
|
280 break; |
|
281 case MEmailAddress::ECc: |
|
282 recipients = &iPluginMessage->GetCCRecipients(); |
|
283 break; |
|
284 case MEmailAddress::EBcc: |
|
285 recipients = &iPluginMessage->GetBCCRecipients(); |
|
286 break; |
|
287 default: |
|
288 User::Leave( KErrArgument ); |
|
289 break; |
|
290 } |
|
291 |
|
292 for( TInt i = 0; i < recipients->Count(); i++ ) |
|
293 { |
|
294 if ( !aRecipient.Address().Compare( (*recipients)[i]->GetEmailAddress() ) ) |
|
295 { |
|
296 recipients->Remove(i); |
|
297 err = KErrNone; |
|
298 // We could break now. But let's loop if there are several entries |
|
299 } |
|
300 } |
|
301 User::LeaveIfError( err ); |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
291 // ----------------------------------------------------------------------------- |
305 // |
292 // |
306 // ----------------------------------------------------------------------------- |
293 // ----------------------------------------------------------------------------- |
307 TPtrC CEmailMessage::Subject() const |
294 TPtrC CEmailMessage::Subject() const |
308 { |
295 { |
|
296 if ( !iPluginMessage ) |
|
297 return KNullDesC(); |
309 return iPluginMessage->GetSubject(); |
298 return iPluginMessage->GetSubject(); |
310 } |
299 } |
311 |
300 |
312 // ----------------------------------------------------------------------------- |
301 // ----------------------------------------------------------------------------- |
313 // |
302 // |
314 // ----------------------------------------------------------------------------- |
303 // ----------------------------------------------------------------------------- |
315 void CEmailMessage::SetSubjectL( const TPtrC& aSubject) |
304 void CEmailMessage::SetSubjectL( const TPtrC& aSubject ) |
316 { |
305 { |
|
306 User::LeaveIfNull( iPluginMessage ); |
317 iPluginMessage->SetSubject( aSubject ); |
307 iPluginMessage->SetSubject( aSubject ); |
318 } |
308 } |
319 |
309 |
320 // ----------------------------------------------------------------------------- |
310 // ----------------------------------------------------------------------------- |
321 // |
311 // |
322 // ----------------------------------------------------------------------------- |
312 // ----------------------------------------------------------------------------- |
323 TTime CEmailMessage::Date() const |
313 TTime CEmailMessage::Date() const |
324 { |
314 { |
325 return iPluginMessage->GetDate(); |
315 TTime time; |
|
316 |
|
317 if ( iPluginMessage ) { |
|
318 time = iPluginMessage->GetDate(); |
|
319 } |
|
320 |
|
321 return time; |
326 } |
322 } |
327 |
323 |
328 // ----------------------------------------------------------------------------- |
324 // ----------------------------------------------------------------------------- |
329 // |
325 // |
330 // ----------------------------------------------------------------------------- |
326 // ----------------------------------------------------------------------------- |
536 iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns); |
538 iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns); |
537 parts[0] = NULL; // ownership of part transferred |
539 parts[0] = NULL; // ownership of part transferred |
538 } |
540 } |
539 |
541 |
540 CleanupStack::PopAndDestroy( &parts ); // parts |
542 CleanupStack::PopAndDestroy( &parts ); // parts |
541 |
543 |
542 if (iTextContent) |
544 if (iTextContent) |
543 { |
545 { |
544 return iTextContent; |
546 return iTextContent; |
545 } |
547 } |
546 return iContent; |
548 return iContent; |
547 } |
549 } |
548 |
550 |
549 // ----------------------------------------------------------------------------- |
551 // ----------------------------------------------------------------------------- |
550 // |
552 // |
551 // ----------------------------------------------------------------------------- |
553 // ----------------------------------------------------------------------------- |
552 void CEmailMessage::SetContentL( const MEmailMessageContent* aContent ) |
554 void CEmailMessage::SetContentL( const MEmailMessageContent* aContent ) |
553 { |
555 { |
|
556 User::LeaveIfNull( aContent ); |
554 MEmailTextContent* textContent = aContent->AsTextContentOrNull(); |
557 MEmailTextContent* textContent = aContent->AsTextContentOrNull(); |
555 if (textContent) |
558 if ( textContent ) |
556 { |
559 { |
557 if (iTextContent) |
560 if ( iTextContent ) |
558 { |
561 { |
559 delete iTextContent; // Destroy old content |
562 delete iTextContent; // Destroy old content |
560 } |
563 } |
561 iTextContent = dynamic_cast<CEmailTextContent*>(textContent); |
564 iTextContent = dynamic_cast<CEmailTextContent*>( textContent ); |
562 if ( iTextContent ) |
565 if ( iTextContent ) |
563 { |
566 { |
564 iTextContent->SetOwner( EAPIOwns ); |
567 iTextContent->SetOwner( EAPIOwns ); |
565 } |
568 } |
566 return; |
569 return; |
567 } |
570 } |
568 MEmailMultipart* mPart = aContent->AsMultipartOrNull(); |
571 MEmailMultipart* mPart = aContent->AsMultipartOrNull(); |
569 if (mPart) |
572 if ( mPart ) |
570 { |
573 { |
571 if (iContent) |
574 if ( iContent ) |
572 { |
575 { |
573 delete iContent; |
576 delete iContent; |
574 } |
577 } |
575 iContent = dynamic_cast<CEmailMultipart*>(mPart); |
578 iContent = dynamic_cast<CEmailMultipart*>( mPart ); |
576 if ( iContent ) |
579 if ( iContent ) |
577 { |
580 { |
578 iContent->SetOwner( EAPIOwns ); |
581 iContent->SetOwner( EAPIOwns ); |
579 } |
582 } |
580 } |
583 } |
581 } |
584 } |
582 |
585 |
583 // ----------------------------------------------------------------------------- |
586 // ----------------------------------------------------------------------------- |
584 // |
587 // |
585 // ----------------------------------------------------------------------------- |
588 // ----------------------------------------------------------------------------- |
586 void CEmailMessage::SetPlainTextBodyL( const TDesC& aPlainText ) |
589 void CEmailMessage::SetPlainTextBodyL( const TDesC& aPlainText ) |
587 { |
590 { |
588 if (iTextContent) |
591 if ( iTextContent ) |
589 { |
592 { |
590 iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText ); |
593 iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText ); |
591 return; |
594 return; |
592 } |
595 } |
|
596 |
|
597 User::LeaveIfNull( iPluginMessage ); |
|
598 |
593 CFSMailMessagePart* msgTextPart = iPluginMessage->PlainTextBodyPartL(); |
599 CFSMailMessagePart* msgTextPart = iPluginMessage->PlainTextBodyPartL(); |
594 |
600 |
595 if( !msgTextPart ) |
601 if( !msgTextPart ) |
596 { |
602 { |
597 msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain ); |
603 msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain ); |
598 } |
604 } |
599 CleanupStack::PushL( msgTextPart ); |
605 CleanupStack::PushL( msgTextPart ); |
600 |
606 |
601 TMessageContentId msgContentId = TMessageContentId( |
607 TMessageContentId msgContentId = MessageContentId( msgTextPart->GetPartId().Id() ); |
602 msgTextPart->GetPartId().Id(), |
608 |
603 iMessageId.iId, |
609 msgTextPart->SetContentType( KFSMailContentTypeTextPlain ); |
604 iMessageId.iFolderId.iId, |
|
605 iMessageId.iFolderId.iMailboxId ); |
|
606 |
|
607 msgTextPart->SetContentType( KFSMailContentTypeTextPlain ); |
|
608 iTextContent = CEmailTextContent::NewL( iPluginData, msgContentId, msgTextPart, EAPIOwns ); |
610 iTextContent = CEmailTextContent::NewL( iPluginData, msgContentId, msgTextPart, EAPIOwns ); |
609 if (iTextContent) |
611 if (iTextContent) |
610 { |
612 { |
611 iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText ); |
613 iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText ); |
612 } |
614 } |
613 CleanupStack::Pop(); // msgTextPart |
615 CleanupStack::Pop( msgTextPart ); |
614 |
616 |
615 return; |
617 return; |
616 |
618 |
617 } |
619 } |
618 |
620 |
619 // ----------------------------------------------------------------------------- |
621 // ----------------------------------------------------------------------------- |
620 // |
622 // |
621 // ----------------------------------------------------------------------------- |
623 // ----------------------------------------------------------------------------- |
622 MEmailAttachment* CEmailMessage::AddAttachmentL( const TDesC& aFullPath ) |
624 MEmailAttachment* CEmailMessage::AddAttachmentL( const TDesC& aFullPath ) |
623 { |
625 { |
624 CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL(aFullPath, TFSMailMsgId()); |
626 User::LeaveIfNull( iPluginMessage ); |
|
627 |
|
628 CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFullPath, TFSMailMsgId() ); |
625 CleanupStack::PushL( part ); |
629 CleanupStack::PushL( part ); |
626 CEmailAttachment* att = CEmailAttachment::NewLC(iPluginData, iMsgContentId, part, EAPIOwns); |
630 CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns ); |
627 iAttachments.AppendL( att ); |
631 iAttachments.AppendL( att ); |
628 CleanupStack::Pop(2); // part, att |
632 CleanupStack::Pop( 2, part ); |
629 |
633 |
630 return att; |
634 return att; |
631 } |
635 } |
632 |
636 |
633 // ----------------------------------------------------------------------------- |
637 // ----------------------------------------------------------------------------- |
634 // |
638 // |
635 // ----------------------------------------------------------------------------- |
639 // ----------------------------------------------------------------------------- |
636 |
|
637 MEmailAttachment* CEmailMessage::AddAttachmentL( RFile& aFile ) |
640 MEmailAttachment* CEmailMessage::AddAttachmentL( RFile& aFile ) |
638 { |
641 { |
|
642 User::LeaveIfNull( iPluginMessage ); |
639 TBufC8 <1> mime; |
643 TBufC8 <1> mime; |
640 CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL(aFile, mime); |
644 CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFile, mime ); |
641 CleanupStack::PushL( part ); |
645 CleanupStack::PushL( part ); |
642 CEmailAttachment* att = CEmailAttachment::NewLC(iPluginData, iMsgContentId, part, EAPIOwns); |
646 CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns ); |
643 iAttachments.AppendL( att ); |
647 iAttachments.AppendL( att ); |
644 CleanupStack::Pop(2); // part, att |
648 |
645 |
649 CleanupStack::Pop( 2, part ); |
|
650 |
646 return att; |
651 return att; |
647 } |
652 } |
648 |
653 |
649 // ----------------------------------------------------------------------------- |
654 // ----------------------------------------------------------------------------- |
650 // |
655 // |
651 // ----------------------------------------------------------------------------- |
656 // ----------------------------------------------------------------------------- |
652 TInt CEmailMessage::GetAttachmentsL( REmailAttachmentArray& aAttachments ) |
657 TInt CEmailMessage::GetAttachmentsL( REmailAttachmentArray& aAttachments ) |
653 { |
658 { |
|
659 User::LeaveIfNull( iPluginMessage ); |
|
660 |
654 RPointerArray<CFSMailMessagePart> attachments; |
661 RPointerArray<CFSMailMessagePart> attachments; |
655 CleanupResetAndDestroyPushL( attachments ); |
662 CleanupResetAndDestroyPushL( attachments ); |
656 iPluginMessage->AttachmentListL(attachments); |
663 iPluginMessage->AttachmentListL( attachments ); |
657 const TInt count( attachments.Count() ); |
664 const TInt count( attachments.Count() ); |
658 for (TInt i = 0; i < count; i++) |
665 for (TInt i = 0; i < count; i++) |
659 { |
666 { |
660 TMessageContentId msgContentId = TMessageContentId( |
667 TMessageContentId msgContentId = MessageContentId( attachments[i]->GetPartId().Id() ); |
661 attachments[i]->GetPartId().Id(), |
668 |
662 iMessageId.iId, |
669 CEmailAttachment* att = CEmailAttachment::NewL( |
663 iMessageId.iFolderId.iId, |
670 iPluginData, msgContentId, attachments[i], EClientOwns ); |
664 iMessageId.iFolderId.iMailboxId ); |
671 |
665 |
672 aAttachments.AppendL( att ); |
666 CEmailAttachment* att = CEmailAttachment::NewL(iPluginData, msgContentId, attachments[i], EClientOwns); |
673 } |
667 |
674 CleanupStack::Pop( &attachments ); |
668 aAttachments.AppendL(att); |
675 return count; |
669 } |
676 } |
670 CleanupStack::Pop(); // attachments |
677 |
671 return count; |
678 // ----------------------------------------------------------------------------- |
672 } |
679 // |
|
680 // ----------------------------------------------------------------------------- |
|
681 void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& /*aAttachment*/ ) |
|
682 { |
|
683 User::Leave( KErrNotSupported ); |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // |
|
688 // ----------------------------------------------------------------------------- |
|
689 const TFolderId& CEmailMessage::ParentFolderId() const |
|
690 { |
|
691 return iMessageId.iFolderId; |
|
692 } |
|
693 |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 // ----------------------------------------------------------------------------- |
|
697 void CEmailMessage::SaveChangesL() |
|
698 { |
|
699 User::LeaveIfNull( iPluginMessage ); |
673 |
700 |
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 // ----------------------------------------------------------------------------- |
|
677 void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& aAttachment ) |
|
678 { |
|
679 iPluginMessage->RemoveChildPartL(FsMsgId( iPluginData, aAttachment.Id())); |
|
680 } |
|
681 |
|
682 // ----------------------------------------------------------------------------- |
|
683 // |
|
684 // ----------------------------------------------------------------------------- |
|
685 const TFolderId& CEmailMessage::ParentFolderId() const |
|
686 { |
|
687 return iMessageId.iFolderId; |
|
688 } |
|
689 |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 // ----------------------------------------------------------------------------- |
|
693 void CEmailMessage::SaveChangesL() |
|
694 { |
|
695 TFSMailMsgId mailboxId( |
701 TFSMailMsgId mailboxId( |
696 FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ) ); |
702 FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ) ); |
697 |
703 |
698 iPlugin->StoreMessageL( mailboxId, *iPluginMessage ); |
704 iPlugin->StoreMessageL( mailboxId, *iPluginMessage ); |
699 } |
705 } |
701 // ----------------------------------------------------------------------------- |
707 // ----------------------------------------------------------------------------- |
702 // |
708 // |
703 // ----------------------------------------------------------------------------- |
709 // ----------------------------------------------------------------------------- |
704 void CEmailMessage::SendL() |
710 void CEmailMessage::SendL() |
705 { |
711 { |
|
712 User::LeaveIfNull( iPluginMessage ); |
|
713 |
|
714 if ( iEventLoop.isRunning() ) |
|
715 User::Leave( KErrInUse ); |
|
716 |
706 SaveChangesL(); |
717 SaveChangesL(); |
707 iPlugin->SendMessageL( *iPluginMessage ); |
718 iError = KErrNone; |
708 } |
719 iPlugin->SendMessageL( *iPluginMessage, *this, KSendMessageRequestId ); |
709 |
720 iEventLoop.exec(); |
710 // ----------------------------------------------------------------------------- |
721 |
711 // |
722 User::LeaveIfError( iError ); |
712 // ----------------------------------------------------------------------------- |
723 } |
713 void CEmailMessage::ConvertAddressArrayL( |
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // |
|
727 // ----------------------------------------------------------------------------- |
|
728 void CEmailMessage::RequestResponseL( TFSProgress aEvent, TInt aRequestId ) |
|
729 { |
|
730 iError = aEvent.iError; |
|
731 |
|
732 if ( aRequestId == KSendMessageRequestId && |
|
733 aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete ) |
|
734 iEventLoop.quit(); |
|
735 } |
|
736 |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 // ----------------------------------------------------------------------------- |
|
740 void CEmailMessage::ConvertAddressArrayL( |
714 const MEmailAddress::TRole aRole, |
741 const MEmailAddress::TRole aRole, |
715 RPointerArray<CFSMailAddress>& aSrc, |
742 const RPointerArray<CFSMailAddress>& aSrc, |
716 REmailAddressArray& aDst ) const |
743 REmailAddressArray& aDst ) const |
717 { |
744 { |
718 for ( TInt i=0; i<aSrc.Count(); i++ ) |
745 for ( TInt i=0; i<aSrc.Count(); i++ ) |
719 { |
746 { |
720 CEmailAddress* recipient = CreateAddressLC( aRole, *aSrc[i] ); |
747 CEmailAddress* recipient = CreateAddressLC( aRole, *aSrc[i] ); |
800 break; |
825 break; |
801 } |
826 } |
802 return flag; |
827 return flag; |
803 } |
828 } |
804 |
829 |
805 void CEmailMessage::ShowMessageViewerL( ) |
830 // ----------------------------------------------------------------------------- |
|
831 // |
|
832 // ----------------------------------------------------------------------------- |
|
833 void CEmailMessage::ShowMessageViewerL() |
806 { |
834 { |
807 THtmlViewerActivationData htmlData; |
835 bool syncronous; |
808 htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage; |
836 |
809 htmlData.iMailBoxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId); |
837 XQServiceRequest request( |
810 htmlData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId); |
838 emailInterfaceNameMessage, |
811 htmlData.iMessageId = FsMsgId(iPluginData, iMessageId); |
839 emailOperationViewMessage, |
812 TPckgBuf<THtmlViewerActivationData> pckgData( htmlData ); |
840 syncronous ); |
813 CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC(); |
841 |
814 viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, HtmlViewerId), KHtmlViewerOpenNew, pckgData); |
842 TFSMailMsgId mailboxId = FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ); |
815 CleanupStack::PopAndDestroy(); |
843 TFSMailMsgId folderId = FsMsgId( iPluginData, iMessageId.iFolderId ); |
816 } |
844 TFSMailMsgId messageId = FsMsgId( iPluginData, iMessageId ); |
817 |
845 |
818 /** |
846 QList<QVariant> list; |
819 * Launches Email application and new reply message in editor. |
847 list.append( mailboxId.Id() ); |
820 * The method follows "fire and forget" pattern, returns immediately. |
848 list.append( folderId.Id() ); |
821 */ |
849 list.append( messageId.Id() ); |
822 void CEmailMessage::ReplyToMessageL( const TBool aReplyToAll ) |
850 request.setArguments( list ); |
823 { |
851 |
824 TEditorLaunchParams editorLaunchData; |
852 QVariant returnValue; |
825 editorLaunchData.iExtra = NULL; |
853 if ( !request.send( returnValue ) ) |
826 editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId); |
854 User::Leave( KErrGeneral ); |
827 editorLaunchData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId); |
855 } |
828 editorLaunchData.iMsgId = FsMsgId(iPluginData, iMessageId); |
856 |
829 editorLaunchData.iActivatedExternally = ETrue; |
857 // ----------------------------------------------------------------------------- |
830 |
858 // Launches Email application and new reply message in editor. |
831 TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData ); |
859 // The method follows "fire and forget" pattern, returns immediately. |
832 CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC(); |
860 // ----------------------------------------------------------------------------- |
833 TUid command = TUid::Uid(KEditorCmdReplyAll); |
861 void CEmailMessage::ReplyToMessageL( const TBool /*aReplyToAll*/ ) |
834 if ( !aReplyToAll ) |
862 { |
835 { |
863 User::Leave( KErrNotSupported ); |
836 command = TUid::Uid(KEditorCmdReply); |
864 } |
837 } |
865 |
838 viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData); |
866 // ----------------------------------------------------------------------------- |
839 CleanupStack::PopAndDestroy(); |
867 // |
840 } |
868 // ----------------------------------------------------------------------------- |
841 |
|
842 void CEmailMessage::ForwardMessageL() |
869 void CEmailMessage::ForwardMessageL() |
843 { |
870 { |
844 TEditorLaunchParams editorLaunchData; |
871 User::Leave( KErrNotSupported ); |
845 editorLaunchData.iExtra = NULL; |
|
846 editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId); |
|
847 editorLaunchData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId); |
|
848 editorLaunchData.iMsgId = FsMsgId(iPluginData, iMessageId); |
|
849 editorLaunchData.iActivatedExternally = ETrue; |
|
850 |
|
851 TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData ); |
|
852 CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC(); |
|
853 TUid command = TUid::Uid(KEditorCmdForward); |
|
854 viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData); |
|
855 CleanupStack::PopAndDestroy(); |
|
856 } |
872 } |
857 |
873 |
858 // ----------------------------------------------------------------------------- |
874 // ----------------------------------------------------------------------------- |
859 // |
875 // |
860 // ----------------------------------------------------------------------------- |
876 // ----------------------------------------------------------------------------- |
|
877 TMessageContentId CEmailMessage::MessageContentId( TEntryId aContentId ) const |
|
878 { |
|
879 TMessageContentId msgContentId = TMessageContentId( |
|
880 aContentId, |
|
881 iMessageId.iId, |
|
882 iMessageId.iFolderId.iId, |
|
883 iMessageId.iFolderId.iMailboxId ); |
|
884 return msgContentId; |
|
885 } |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
861 // |
888 // |
|
889 // ----------------------------------------------------------------------------- |
862 TContentType::TContentType( const TDesC& aContentType ) : iContentType( aContentType ) |
890 TContentType::TContentType( const TDesC& aContentType ) : iContentType( aContentType ) |
863 { |
891 { |
864 _LIT( KSeparator, ";" ); |
892 _LIT( KSeparator, ";" ); |
865 TInt end = aContentType.Find( KSeparator ); |
893 TInt end = aContentType.Find( KSeparator ); |
866 if ( end != KErrNotFound ) |
894 if ( end != KErrNotFound ) |