23 _LIT( KMimeTypeTextPlain, "text/plain" ); |
23 _LIT( KMimeTypeTextPlain, "text/plain" ); |
24 _LIT( KMimeTypeTextHtml, "text/html" ); |
24 _LIT( KMimeTypeTextHtml, "text/html" ); |
25 _LIT( KMimeTypeTextRtf, "text/rtf" ); |
25 _LIT( KMimeTypeTextRtf, "text/rtf" ); |
26 _LIT( KSlash, "/" ); |
26 _LIT( KSlash, "/" ); |
27 |
27 |
|
28 // <cmail> |
28 _LIT( KCharSemicolon, ";" ); |
29 _LIT( KCharSemicolon, ";" ); |
29 _LIT( KCharEquals, "=" ); |
30 _LIT( KCharEquals, "=" ); |
30 _LIT( KCharsetTag, "CHARSET" ); |
31 _LIT( KCharsetTag, "CHARSET" ); |
31 _LIT( KMessageExtension, ".eml" ); |
32 // </cmail> |
32 |
33 |
33 // Supported multipart content types |
34 // Supported multipart content types |
34 _LIT( KMimeTypeMultipartRelated, "multipart/related" ); |
35 _LIT( KMimeTypeMultipartRelated, "multipart/related" ); |
35 _LIT( KMimeTypeMultipartMixed, "multipart/mixed" ); |
36 _LIT( KMimeTypeMultipartMixed, "multipart/mixed" ); |
36 _LIT( KMimeTypeMultipartAlternative, "multipart/alternative" ); |
37 _LIT( KMimeTypeMultipartAlternative, "multipart/alternative" ); |
42 _LIT( KMimeTypeMultipartParallel, "multipart/parallel" ); |
43 _LIT( KMimeTypeMultipartParallel, "multipart/parallel" ); |
43 |
44 |
44 const TInt KCharEscape = 0x5C; |
45 const TInt KCharEscape = 0x5C; |
45 const TInt KCharNonPrintable = 0x1F; |
46 const TInt KCharNonPrintable = 0x1F; |
46 const TInt KCharAt = 0x40; |
47 const TInt KCharAt = 0x40; |
|
48 // <cmail> |
47 const TInt KMaxContentTypeLength = 200; |
49 const TInt KMaxContentTypeLength = 200; |
48 const TInt KEmbeddedMsgExtensionLength = 4; |
50 // </cmail> |
49 |
51 |
50 // ======== CONSTRUCTORS & DESTRUCTOR ======== |
52 // ======== CONSTRUCTORS & DESTRUCTOR ======== |
51 |
53 |
52 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
53 // CIpsPlgMsgMapper::NewL() |
55 // CIpsPlgMsgMapper::NewL() |
120 TFSMailMsgId msgId( iPlugin.PluginId(), aEntry.Entry().Id() ); |
122 TFSMailMsgId msgId( iPlugin.PluginId(), aEntry.Entry().Id() ); |
121 CFSMailMessage* fsMsg = CFSMailMessage::NewLC( msgId ); |
123 CFSMailMessage* fsMsg = CFSMailMessage::NewLC( msgId ); |
122 |
124 |
123 fsMsg->SetFolderId( |
125 fsMsg->SetFolderId( |
124 TFSMailMsgId( iPlugin.PluginId(), aEntry.Entry().Parent() ) ); |
126 TFSMailMsgId( iPlugin.PluginId(), aEntry.Entry().Parent() ) ); |
125 // ERLN-7YUEX3 |
127 |
126 fsMsg->SetMailBoxId(TFSMailMsgId( iPlugin.PluginId(), aEntry.Entry().iServiceId )); |
|
127 // End ERLN-7YUEX3 |
|
128 |
|
129 CMsvStore* store( NULL ); |
128 CMsvStore* store( NULL ); |
130 |
129 |
131 if ( aEntry.HasStoreL() ) |
130 if ( aEntry.HasStoreL() ) |
132 { |
131 { |
133 store = aEntry.ReadStoreL(); |
132 store = aEntry.ReadStoreL(); |
191 { |
190 { |
192 CMsvStore* store( NULL ); |
191 CMsvStore* store( NULL ); |
193 CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); |
192 CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); |
194 CleanupStack::PushL( cEntry ); |
193 CleanupStack::PushL( cEntry ); |
195 |
194 |
196 if ( cEntry ) |
195 if ( cEntry && cEntry->HasStoreL() ) |
197 { |
196 { |
198 if ( cEntry->HasStoreL() ) |
197 store = cEntry->ReadStoreL(); |
199 { |
198 CleanupStack::PushL( store ); |
200 store = cEntry->ReadStoreL(); |
199 } |
201 CleanupStack::PushL( store ); |
200 |
202 } |
201 SetEnvelopeL( cEntry, store, *result ); |
203 |
202 |
204 SetEnvelopeL( cEntry, store, *result ); |
203 // Apparently, this should be done only with |
205 |
204 // EFSMsgDataStructure, but EFSMsgDataEnvelope is currently |
206 // Apparently, this should be done only with |
205 // used by assuming that it reads also the content-type of |
207 // EFSMsgDataStructure, but EFSMsgDataEnvelope is currently |
206 // the message |
208 // used by assuming that it reads also the content-type of |
207 SetStructureL( cEntry, *result ); |
209 // the message |
208 |
210 SetStructureL( cEntry, *result ); |
209 if ( store ) |
211 |
210 { |
212 if ( store ) |
211 CleanupStack::PopAndDestroy( store ); |
213 { |
212 } |
214 CleanupStack::PopAndDestroy( store ); |
213 CleanupStack::PopAndDestroy( cEntry ); |
215 } |
|
216 CleanupStack::PopAndDestroy( cEntry ); |
|
217 } |
|
218 break; |
214 break; |
219 } |
215 } |
220 case EFSMsgDataIdOnly: |
216 case EFSMsgDataIdOnly: |
221 default: |
217 default: |
222 break; |
218 break; |
273 result = ConvertFolderEntry2MessagePartL( tEntry, |
269 result = ConvertFolderEntry2MessagePartL( tEntry, |
274 aMailBoxId, aMessageId ); |
270 aMailBoxId, aMessageId ); |
275 break; |
271 break; |
276 } |
272 } |
277 case KUidMsvAttachmentEntryValue: |
273 case KUidMsvAttachmentEntryValue: |
278 case KUidMsvMessageEntryValue: |
|
279 { |
274 { |
280 result = ConvertAttachmentEntry2MessagePartL( tEntry, |
275 result = ConvertAttachmentEntry2MessagePartL( tEntry, |
281 aMailBoxId, aMessageId ); |
276 aMailBoxId, aMessageId ); |
|
277 break; |
|
278 } |
|
279 case KUidMsvMessageEntryValue: |
|
280 { |
282 break; |
281 break; |
283 } |
282 } |
284 case KUidMsvEmailTextEntryValue: |
283 case KUidMsvEmailTextEntryValue: |
285 case KUidMsvEmailHtmlEntryValue: |
284 case KUidMsvEmailHtmlEntryValue: |
286 case KUidMsvEmailExternalBodyEntryValue: |
285 case KUidMsvEmailExternalBodyEntryValue: |
690 if ( aEntry.ICalendar() ) |
684 if ( aEntry.ICalendar() ) |
691 { |
685 { |
692 // <cmail> implementation changed due to cs warning |
686 // <cmail> implementation changed due to cs warning |
693 TInt attCount = 0; |
687 TInt attCount = 0; |
694 TRAPD ( err, attCount = GetAttachmentCountL( aEntry ) ); |
688 TRAPD ( err, attCount = GetAttachmentCountL( aEntry ) ); |
695 if ( err == KErrNone && attCount == 1 ) |
689 if ( err == KErrNone && attCount < 2 ) |
696 { |
690 { |
697 CMsvEntry* cEntry = NULL; |
691 // Only text/calendar part included as attachment |
698 TRAPD ( err2, cEntry = iSession.GetEntryL( aEntry.Id() ) ); |
692 aMsg.ResetFlag( EFSMsgFlag_Attachments ); |
699 if ( err2 == KErrNone && cEntry->Count() == 1 ) |
693 //Set Attachment flag for CMsvEntry (needed for sorting) |
700 { |
694 TRAP_IGNORE( SetAttachmentFlagL( aEntry, EFalse ) ); |
701 TMsvEmailEntry tEntry = (*cEntry)[0]; |
|
702 TImEmailFolderType ft = tEntry.MessageFolderType(); |
|
703 if ( tEntry.iType == KUidMsvFolderEntry && ft == EFolderTypeMixed ) |
|
704 { |
|
705 // Message with calendar object. But based on content type |
|
706 // (multipart/mixed) we know that this is meeting request |
|
707 // forwarded as email, so it must be seen as normal email. |
|
708 forwardedMeetingRequest = ETrue; |
|
709 aMsg.ResetFlag( EFSMsgFlag_CalendarMsg ); |
|
710 aMsg.SetFlag( EFSMsgFlag_Attachments ); |
|
711 } |
|
712 else |
|
713 { |
|
714 // Only text/calendar part included as attachment |
|
715 aMsg.ResetFlag( EFSMsgFlag_Attachments ); |
|
716 //Set Attachment flag for CMsvEntry (needed for sorting) |
|
717 TRAP_IGNORE( SetAttachmentFlagL( aEntry, EFalse ) ); |
|
718 } |
|
719 } |
|
720 delete cEntry; |
|
721 cEntry = NULL; |
|
722 } |
695 } |
723 // </cmail> |
696 // </cmail> |
724 } |
697 } |
725 } |
698 } |
726 else |
699 else |
774 } |
747 } |
775 } |
748 } |
776 |
749 |
777 // --------------------------------------------------------------------------- |
750 // --------------------------------------------------------------------------- |
778 // --------------------------------------------------------------------------- |
751 // --------------------------------------------------------------------------- |
779 void CIpsPlgMsgMapper::SetFetchStateL( |
752 void CIpsPlgMsgMapper::SetFetchState( |
780 const TMsvEmailEntry& aEntry, |
753 const TMsvEmailEntry& aEntry, |
781 TMsvId aMsgMainId, |
754 TMsvId aMsgMainId, |
782 TBool aIsAtta, |
755 TBool aIsAtta, |
783 CFSMailMessagePart& aMessage ) |
756 CFSMailMessagePart& aMessage ) |
784 { |
757 { |
785 FUNC_LOG; |
758 FUNC_LOG; |
786 if ( aEntry.iMtm.iUid == KSenduiMtmPop3UidValue && |
759 if ( aEntry.iMtm.iUid == KSenduiMtmPop3UidValue |
787 aEntry.Id() != aMsgMainId && |
760 && aEntry.Id() != aMsgMainId ) |
788 !aIsAtta ) |
|
789 { |
761 { |
790 TInt error = KErrNone; |
762 TInt error = KErrNone; |
791 TMsvEmailEntry emlEntry; |
763 TMsvEmailEntry emlEntry; |
792 TMsvId dummy; |
764 TMsvId dummy; |
793 |
765 |
794 error = iSession.GetEntry( aMsgMainId , dummy, emlEntry ); |
766 error = iSession.GetEntry( aMsgMainId , dummy, emlEntry ); |
795 |
767 |
796 if ( error == KErrNone ) |
768 if ( error == KErrNone ) |
797 { |
769 { |
798 DoSetFetchStateL( emlEntry, aMsgMainId, aIsAtta, aMessage ); |
770 SetFetchStateImap( emlEntry, aMsgMainId, aIsAtta ,aMessage ); |
799 } |
771 } |
800 else |
772 else |
801 { |
773 { |
802 aMessage.SetMessagePartsStatus( EFSEmailStructureUnknown ); |
774 aMessage.SetMessagePartsStatus( EFSEmailStructureUnknown ); |
803 } |
775 } |
804 } |
776 } |
805 else |
777 else |
806 { |
778 { |
807 DoSetFetchStateL( aEntry, aMsgMainId, aIsAtta, aMessage ); |
779 SetFetchStateImap( aEntry, aMsgMainId, aIsAtta, aMessage ); |
808 } |
780 } |
809 } |
781 } |
810 |
782 |
811 // --------------------------------------------------------------------------- |
783 // --------------------------------------------------------------------------- |
812 // --------------------------------------------------------------------------- |
784 // --------------------------------------------------------------------------- |
813 void CIpsPlgMsgMapper::DoSetFetchStateL( |
785 void CIpsPlgMsgMapper::SetFetchStateImap( |
814 const TMsvEmailEntry& aEntry, |
786 const TMsvEmailEntry& aEntry, |
815 TMsvId aMsgMainId, |
787 TMsvId aMsgMainId, |
816 TBool aIsAtta, |
788 TBool aIsAtta, |
817 CFSMailMessagePart& aMessage ) |
789 CFSMailMessagePart& aMessage ) |
818 { |
790 { |
819 FUNC_LOG; |
791 FUNC_LOG; |
820 if ( aEntry.PartialDownloaded() ) |
792 if ( aEntry.PartialDownloaded() ) |
821 { |
793 { |
822 aMessage.SetMessagePartsStatus( EFSPartial ); |
794 aMessage.SetMessagePartsStatus( EFSPartial ); |
823 } |
795 } |
824 else if ( aEntry.BodyTextComplete() && !aIsAtta ) |
796 else if ( aEntry.Complete() || (aEntry.BodyTextComplete() && !aIsAtta) ) |
825 { |
797 { |
826 aMessage.SetMessagePartsStatus( EFSFull ); |
798 aMessage.SetMessagePartsStatus( EFSFull ); |
827 } |
|
828 else if ( aEntry.Complete() && !aIsAtta ) |
|
829 { |
|
830 aMessage.SetMessagePartsStatus( EFSFull ); |
|
831 } |
|
832 else if ( aEntry.Complete() && aIsAtta ) |
|
833 { |
|
834 CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); |
|
835 |
|
836 CleanupStack::PushL( cEntry ); |
|
837 |
|
838 TBool hasStore = cEntry->HasStoreL(); |
|
839 |
|
840 if ( hasStore ) |
|
841 { |
|
842 CMsvStore* store = cEntry->EditStoreL(); |
|
843 |
|
844 CleanupStack::PushL( store ); |
|
845 |
|
846 MMsvAttachmentManager& attMgr = store->AttachmentManagerL(); |
|
847 |
|
848 if ( attMgr.AttachmentCount() ) |
|
849 { |
|
850 aMessage.SetMessagePartsStatus( EFSFull ); |
|
851 } |
|
852 else |
|
853 { |
|
854 aMessage.SetMessagePartsStatus( EFSNone ); |
|
855 } |
|
856 |
|
857 CleanupStack::PopAndDestroy( store ); |
|
858 } |
|
859 |
|
860 CleanupStack::PopAndDestroy( cEntry ); |
|
861 } |
799 } |
862 else if ( aEntry.Id() != aMsgMainId ) |
800 else if ( aEntry.Id() != aMsgMainId ) |
863 { |
801 { |
864 // fetch state of some message part, then we sure know |
802 // fetch state of some message part, then we sure know |
865 // structure, but its not complete nor partial so state must be |
803 // structure, but its not complete nor partial so state must be |
1287 { |
1226 { |
1288 CImMimeHeader* mimeHeader = CImMimeHeader::NewLC(); |
1227 CImMimeHeader* mimeHeader = CImMimeHeader::NewLC(); |
1289 mimeHeader->RestoreL( *store ); |
1228 mimeHeader->RestoreL( *store ); |
1290 |
1229 |
1291 // Content-type |
1230 // Content-type |
1292 if ( aEntry.iType.iUid == KUidMsvMessageEntryValue ) |
1231 SetContentTypeL( *mimeHeader, *result ); |
1293 { |
|
1294 result->SetContentType( KMimeTypeMultipartRfc822 ); |
|
1295 } |
|
1296 else |
|
1297 { |
|
1298 SetContentTypeL( *mimeHeader, *result ); |
|
1299 } |
|
1300 |
1232 |
1301 // Content-description |
1233 // Content-description |
1302 buffer = HBufC::NewLC( |
1234 buffer = HBufC::NewLC( |
1303 mimeHeader->ContentDescription().Length ( ) ); |
1235 mimeHeader->ContentDescription().Length ( ) ); |
1304 buffer->Des().Copy ( mimeHeader->ContentDescription ( ) ); |
1236 buffer->Des().Copy ( mimeHeader->ContentDescription ( ) ); |
1339 // Content-class: not supported by Symbian (non-standard field) |
1271 // Content-class: not supported by Symbian (non-standard field) |
1340 |
1272 |
1341 CleanupStack::PopAndDestroy( mimeHeader ); |
1273 CleanupStack::PopAndDestroy( mimeHeader ); |
1342 } |
1274 } |
1343 // Name |
1275 // Name |
1344 if ( aEntry.iType.iUid == KUidMsvMessageEntryValue ) |
1276 result->SetAttachmentNameL( aEntry.iDetails ); |
1345 { |
|
1346 HBufC* att = HBufC::NewLC( aEntry.iDescription.Length() + KEmbeddedMsgExtensionLength ); |
|
1347 att->Des().Copy( aEntry.iDescription ); |
|
1348 att->Des().Append( KMessageExtension ); |
|
1349 result->SetAttachmentNameL( att->Des() ); |
|
1350 CleanupStack::PopAndDestroy( att ); |
|
1351 } |
|
1352 else |
|
1353 { |
|
1354 result->SetAttachmentNameL( aEntry.iDetails ); |
|
1355 } |
|
1356 |
1277 |
1357 // Size |
1278 // Size |
1358 result->SetContentSize( aEntry.iSize ); |
1279 result->SetContentSize( aEntry.iSize ); |
1359 |
1280 |
1360 if ( aEntry.Complete() ) |
1281 if ( aEntry.Complete() ) |
1512 CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); |
1432 CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); |
1513 CleanupStack::PushL( cEntry ); |
1433 CleanupStack::PushL( cEntry ); |
1514 // Only text/calendar part included as attachment |
1434 // Only text/calendar part included as attachment |
1515 TMsvEmailEntry entryToBeChanged( aEntry ); |
1435 TMsvEmailEntry entryToBeChanged( aEntry ); |
1516 entryToBeChanged.SetAttachment( aHasAttachment ); |
1436 entryToBeChanged.SetAttachment( aHasAttachment ); |
1517 CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewLC(); |
1437 cEntry->ChangeL( entryToBeChanged ); |
1518 CMsvOperation* ops = cEntry->ChangeL( entryToBeChanged, waiter->iStatus ); |
1438 |
1519 CleanupStack::PushL( ops ); |
1439 CleanupStack::PopAndDestroy( cEntry ); |
1520 waiter->Start(); |
|
1521 CleanupStack::PopAndDestroy( 3, cEntry ); |
|
1522 } |
1440 } |
1523 // </cmail> |
1441 // </cmail> |
1524 |
1442 |
1525 // <cmail> |
1443 // <cmail> |
1526 // --------------------------------------------------------------------------- |
1444 // --------------------------------------------------------------------------- |