diff -r ecc8def7944a -r 2dc6caa42ec3 ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp --- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp Mon May 03 12:23:15 2010 +0300 +++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp Fri May 14 15:41:10 2010 +0300 @@ -25,11 +25,10 @@ _LIT( KMimeTypeTextRtf, "text/rtf" ); _LIT( KSlash, "/" ); -// _LIT( KCharSemicolon, ";" ); _LIT( KCharEquals, "=" ); _LIT( KCharsetTag, "CHARSET" ); -// +_LIT( KMessageExtension, ".eml" ); // Supported multipart content types _LIT( KMimeTypeMultipartRelated, "multipart/related" ); @@ -45,9 +44,8 @@ const TInt KCharEscape = 0x5C; const TInt KCharNonPrintable = 0x1F; const TInt KCharAt = 0x40; -// const TInt KMaxContentTypeLength = 200; -// +const TInt KEmbeddedMsgExtensionLength = 4; // ======== CONSTRUCTORS & DESTRUCTOR ======== @@ -124,7 +122,10 @@ fsMsg->SetFolderId( TFSMailMsgId( iPlugin.PluginId(), aEntry.Entry().Parent() ) ); - + // ERLN-7YUEX3 + fsMsg->SetMailBoxId(TFSMailMsgId( iPlugin.PluginId(), aEntry.Entry().iServiceId )); + // End ERLN-7YUEX3 + CMsvStore* store( NULL ); if ( aEntry.HasStoreL() ) @@ -172,7 +173,7 @@ TFSMailMsgId( iPlugin.PluginId(), aEntry.Parent() ) ); SetFlags( aEntry, *result ); - SetFetchState( aEntry, aEntry.Id(), EFalse ,*result ); + SetFetchStateL( aEntry, aEntry.Id(), EFalse, *result ); switch( aDetails ) { @@ -190,27 +191,30 @@ { CMsvStore* store( NULL ); CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); - CleanupStack::PushL( cEntry ); - if ( cEntry && cEntry->HasStoreL() ) - { - store = cEntry->ReadStoreL(); - CleanupStack::PushL( store ); - } - - SetEnvelopeL( cEntry, store, *result ); + if ( cEntry ) + { + CleanupStack::PushL( cEntry ); + if ( cEntry->HasStoreL() ) + { + store = cEntry->ReadStoreL(); + CleanupStack::PushL( store ); + } - // Apparently, this should be done only with - // EFSMsgDataStructure, but EFSMsgDataEnvelope is currently - // used by assuming that it reads also the content-type of - // the message - SetStructureL( cEntry, *result ); - - if ( store ) - { - CleanupStack::PopAndDestroy( store ); - } - CleanupStack::PopAndDestroy( cEntry ); + SetEnvelopeL( cEntry, store, *result ); + + // Apparently, this should be done only with + // EFSMsgDataStructure, but EFSMsgDataEnvelope is currently + // used by assuming that it reads also the content-type of + // the message + SetStructureL( cEntry, *result ); + + if ( store ) + { + CleanupStack::PopAndDestroy( store ); + } + CleanupStack::PopAndDestroy( cEntry ); + } break; } case EFSMsgDataIdOnly: @@ -271,15 +275,12 @@ break; } case KUidMsvAttachmentEntryValue: + case KUidMsvMessageEntryValue: { result = ConvertAttachmentEntry2MessagePartL( tEntry, aMailBoxId, aMessageId ); break; } - case KUidMsvMessageEntryValue: - { - break; - } case KUidMsvEmailTextEntryValue: case KUidMsvEmailHtmlEntryValue: case KUidMsvEmailExternalBodyEntryValue: @@ -305,9 +306,11 @@ TInt msgFlags = aMessage.GetFlags(); TBool modified ( EFalse ); TBool unread( aEmlEntry.Unread() ); - + +// if ( !LogicalXor( unread, msgFlags & EFSMsgFlag_Read ) || !LogicalXor( unread, msgFlags & EFSMsgFlag_Read_Locally )) +// { aEmlEntry.SetUnread( !unread ); modified = ETrue; @@ -408,7 +411,9 @@ if ( isModified ) { +// Function called sync in Qmail cEntry->ChangeL( tEntry ); +// } CleanupStack::PopAndDestroy( cEntry ); @@ -624,6 +629,8 @@ { FUNC_LOG; + TBool forwardedMeetingRequest = EFalse; + // EFSMsgFlag_Read // EFSMsgFlag_Read_Locally if ( aEntry.Unread() ) @@ -686,12 +693,33 @@ // implementation changed due to cs warning TInt attCount = 0; TRAPD ( err, attCount = GetAttachmentCountL( aEntry ) ); - if ( err == KErrNone && attCount < 2 ) + if ( err == KErrNone && attCount == 1 ) { - // Only text/calendar part included as attachment - aMsg.ResetFlag( EFSMsgFlag_Attachments ); - //Set Attachment flag for CMsvEntry (needed for sorting) - TRAP_IGNORE( SetAttachmentFlagL( aEntry, EFalse ) ); + CMsvEntry* cEntry = NULL; + TRAPD ( err2, cEntry = iSession.GetEntryL( aEntry.Id() ) ); + if ( err2 == KErrNone && cEntry->Count() == 1 ) + { + TMsvEmailEntry tEntry = (*cEntry)[0]; + TImEmailFolderType ft = tEntry.MessageFolderType(); + if ( tEntry.iType == KUidMsvFolderEntry && ft == EFolderTypeMixed ) + { + // Message with calendar object. But based on content type + // (multipart/mixed) we know that this is meeting request + // forwarded as email, so it must be seen as normal email. + forwardedMeetingRequest = ETrue; + aMsg.ResetFlag( EFSMsgFlag_CalendarMsg ); + aMsg.SetFlag( EFSMsgFlag_Attachments ); + } + else + { + // Only text/calendar part included as attachment + aMsg.ResetFlag( EFSMsgFlag_Attachments ); + //Set Attachment flag for CMsvEntry (needed for sorting) + TRAP_IGNORE( SetAttachmentFlagL( aEntry, EFalse ) ); + } + } + delete cEntry; + cEntry = NULL; } // } @@ -708,7 +736,7 @@ // the index entry) // EFSMsgFlag_CalendarMsg - if ( aEntry.ICalendar() ) + if ( aEntry.ICalendar() && !forwardedMeetingRequest ) // { aMsg.SetFlag( EFSMsgFlag_CalendarMsg ); } @@ -749,15 +777,16 @@ // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- -void CIpsPlgMsgMapper::SetFetchState( +void CIpsPlgMsgMapper::SetFetchStateL( const TMsvEmailEntry& aEntry, TMsvId aMsgMainId, TBool aIsAtta, CFSMailMessagePart& aMessage ) { FUNC_LOG; - if ( aEntry.iMtm.iUid == KSenduiMtmPop3UidValue - && aEntry.Id() != aMsgMainId ) + if ( aEntry.iMtm.iUid == KSenduiMtmPop3UidValue && + aEntry.Id() != aMsgMainId && + !aIsAtta ) { TInt error = KErrNone; TMsvEmailEntry emlEntry; @@ -767,7 +796,7 @@ if ( error == KErrNone ) { - SetFetchStateImap( emlEntry, aMsgMainId, aIsAtta ,aMessage ); + DoSetFetchStateL( emlEntry, aMsgMainId, aIsAtta, aMessage ); } else { @@ -776,13 +805,13 @@ } else { - SetFetchStateImap( aEntry, aMsgMainId, aIsAtta, aMessage ); + DoSetFetchStateL( aEntry, aMsgMainId, aIsAtta, aMessage ); } } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- -void CIpsPlgMsgMapper::SetFetchStateImap( +void CIpsPlgMsgMapper::DoSetFetchStateL( const TMsvEmailEntry& aEntry, TMsvId aMsgMainId, TBool aIsAtta, @@ -793,10 +822,44 @@ { aMessage.SetMessagePartsStatus( EFSPartial ); } - else if ( aEntry.Complete() || (aEntry.BodyTextComplete() && !aIsAtta) ) + else if ( aEntry.BodyTextComplete() && !aIsAtta ) + { + aMessage.SetMessagePartsStatus( EFSFull ); + } + else if ( aEntry.Complete() && !aIsAtta ) { aMessage.SetMessagePartsStatus( EFSFull ); } + else if ( aEntry.Complete() && aIsAtta ) + { + CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() ); + + CleanupStack::PushL( cEntry ); + + TBool hasStore = cEntry->HasStoreL(); + + if ( hasStore ) + { + CMsvStore* store = cEntry->EditStoreL(); + + CleanupStack::PushL( store ); + + MMsvAttachmentManager& attMgr = store->AttachmentManagerL(); + + if ( attMgr.AttachmentCount() ) + { + aMessage.SetMessagePartsStatus( EFSFull ); + } + else + { + aMessage.SetMessagePartsStatus( EFSNone ); + } + + CleanupStack::PopAndDestroy( store ); + } + + CleanupStack::PopAndDestroy( cEntry ); + } else if ( aEntry.Id() != aMsgMainId ) { // fetch state of some message part, then we sure know @@ -1189,10 +1252,12 @@ CleanupStack::Pop( result ); } - SetFetchState( aEntry, aMessageId.Id(), EFalse, *result ); -// + if(result) // coverity error fix: result might be null + { + SetFetchStateL( aEntry, aMessageId.Id(), EFalse, *result ); + } + CleanupStack::PopAndDestroy( buf ); -// return result; } @@ -1208,7 +1273,8 @@ HBufC* buffer; CMsvEntry* cEntry; - __ASSERT_DEBUG( ( aEntry.iType == KUidMsvAttachmentEntry ), + __ASSERT_DEBUG( ( aEntry.iType == KUidMsvAttachmentEntry || + aEntry.iType == KUidMsvMessageEntry ), User::Panic( KIpsPlgPanicCategory, EIpsPlgInvalidEntry ) ); cEntry = iSession.GetEntryL( aEntry.Id() ); @@ -1228,7 +1294,14 @@ mimeHeader->RestoreL( *store ); // Content-type - SetContentTypeL( *mimeHeader, *result ); + if ( aEntry.iType.iUid == KUidMsvMessageEntryValue ) + { + result->SetContentType( KMimeTypeMultipartRfc822 ); + } + else + { + SetContentTypeL( *mimeHeader, *result ); + } // Content-description buffer = HBufC::NewLC( @@ -1273,7 +1346,18 @@ CleanupStack::PopAndDestroy( mimeHeader ); } // Name - result->SetAttachmentNameL( aEntry.iDetails ); + if ( aEntry.iType.iUid == KUidMsvMessageEntryValue ) + { + HBufC* att = HBufC::NewLC( aEntry.iDescription.Length() + KEmbeddedMsgExtensionLength ); + att->Des().Copy( aEntry.iDescription ); + att->Des().Append( KMessageExtension ); + result->SetAttachmentNameL( att->Des() ); + CleanupStack::PopAndDestroy( att ); + } + else + { + result->SetAttachmentNameL( aEntry.iDetails ); + } // Size result->SetContentSize( aEntry.iSize ); @@ -1288,9 +1372,10 @@ } result->SetMailBoxId( aMailBoxId ); CleanupStack::PopAndDestroy(store); + + SetFetchStateL( aEntry, aMessageId.Id(), ETrue, *result ); CleanupStack::Pop( result ); } - SetFetchState( aEntry, aMessageId.Id(), ETrue ,*result ); CleanupStack::PopAndDestroy( cEntry ); return result; @@ -1434,9 +1519,11 @@ // Only text/calendar part included as attachment TMsvEmailEntry entryToBeChanged( aEntry ); entryToBeChanged.SetAttachment( aHasAttachment ); + +// Function called sync in Qmail cEntry->ChangeL( entryToBeChanged ); - CleanupStack::PopAndDestroy( cEntry ); +// } //