emailservices/emailclientapi/src/emailmessage.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 3 a4d6f1ea0416
child 13 0396474f30f5
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
    31 #include "emailinterfacefactoryimpl.h"
    31 #include "emailinterfacefactoryimpl.h"
    32 #include "emailcontent.h"
    32 #include "emailcontent.h"
    33 #include "emailtextcontent.h"
    33 #include "emailtextcontent.h"
    34 #include "emailmultipart.h"
    34 #include "emailmultipart.h"
    35 #include "emailattachment.h"
    35 #include "emailattachment.h"
    36 #include "CFSMailPlugin.h"
    36 #include "cfsmailplugin.h"
    37 #include "FreestyleEmailUiConstants.h"
    37 #include "FreestyleEmailUiConstants.h"
    38 #include "CFSMailClient.h"
    38 #include "cfsmailclient.h"
    39 
    39 
    40 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    41 // 
    41 // 
    42 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    43 CEmailMessage* CEmailMessage::NewL( CPluginData& aPluginData,
    43 CEmailMessage* CEmailMessage::NewL( CPluginData& aPluginData,
    72         {
    72         {
    73         iMessageId = TMessageId( 
    73         iMessageId = TMessageId( 
    74             iPluginMessage->GetMessageId().Id(),
    74             iPluginMessage->GetMessageId().Id(),
    75             iPluginMessage->GetFolderId().Id(), 
    75             iPluginMessage->GetFolderId().Id(), 
    76             iPluginMessage->GetMailBoxId().Id() );
    76             iPluginMessage->GetMailBoxId().Id() );
       
    77         
       
    78         // Copy the message flags
       
    79         InitializeFlagValues();
    77         }
    80         }
    78     }
    81     }
    79 
    82 
    80 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    81 // 
    84 // 
   351     }
   354     }
   352 
   355 
   353 // -----------------------------------------------------------------------------
   356 // -----------------------------------------------------------------------------
   354 // 
   357 // 
   355 // -----------------------------------------------------------------------------
   358 // -----------------------------------------------------------------------------
       
   359 void CEmailMessage::InitializeFlagValues()
       
   360     {
       
   361     // 1st reset member value, then start copying different flags
       
   362     iFlags = 0;
       
   363     
       
   364     // EFlag_Read
       
   365     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Read ) )
       
   366         {
       
   367         iFlags |= EFlag_Read;
       
   368         }
       
   369     else
       
   370         {
       
   371         iFlags &= ~EFlag_Read;
       
   372         }
       
   373     //    EFlag_Read_Locally
       
   374     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Read_Locally ) )
       
   375         {
       
   376         iFlags |= EFlag_Read_Locally;
       
   377         }
       
   378     else
       
   379         {
       
   380         iFlags &= ~EFlag_Read_Locally;
       
   381         }    
       
   382     // EFlag_Low
       
   383     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Low ) )
       
   384         {
       
   385         iFlags |= EFlag_Low;
       
   386         }
       
   387     else
       
   388         {
       
   389         iFlags &= ~EFlag_Low;
       
   390         }
       
   391     // EFlag_Important
       
   392     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Important ) )
       
   393         {
       
   394         iFlags |= EFlag_Important;
       
   395         }
       
   396     else
       
   397         {
       
   398         iFlags &= ~EFlag_Important;
       
   399         }
       
   400     // EFlag_FollowUpComplete
       
   401     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
       
   402         {
       
   403         iFlags |= EFlag_FollowUpComplete;
       
   404         }
       
   405     else
       
   406         {
       
   407         iFlags &= ~EFlag_FollowUpComplete;
       
   408         }
       
   409     // EFlag_FollowUp
       
   410     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_FollowUp ) )
       
   411         {
       
   412         iFlags |= EFlag_FollowUp;
       
   413         }
       
   414     else
       
   415         {
       
   416         iFlags &= ~EFlag_FollowUp;
       
   417         }
       
   418     // EFlag_Attachments
       
   419     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Attachments ) )
       
   420         {
       
   421         iFlags |= EFlag_Attachments;
       
   422         }
       
   423     else
       
   424         {
       
   425         iFlags &= ~EFlag_Attachments;
       
   426         }
       
   427     // EFlag_Multiple
       
   428     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Multiple ) )
       
   429         {
       
   430         iFlags |= EFlag_Multiple;
       
   431         }
       
   432     else
       
   433         {
       
   434         iFlags &= ~EFlag_Multiple;
       
   435         }
       
   436     // EFlag_CalendarMsg
       
   437     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_CalendarMsg ) )
       
   438         {
       
   439         iFlags |= EFlag_CalendarMsg;
       
   440         }
       
   441     else
       
   442         {
       
   443         iFlags &= ~EFlag_CalendarMsg;
       
   444         }
       
   445     // EFlag_Answered
       
   446     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Answered ) )
       
   447         {
       
   448         iFlags |= EFlag_Answered;
       
   449         }
       
   450     else
       
   451         {
       
   452         iFlags &= ~EFlag_Answered;
       
   453         }
       
   454     // EFlag_Forwarded
       
   455     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Forwarded ) )
       
   456         {
       
   457         iFlags |= EFlag_Forwarded;
       
   458         }
       
   459     else
       
   460         {
       
   461         iFlags &= ~EFlag_Forwarded;
       
   462         }
       
   463     // EFlag_OnlyToMe
       
   464     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_OnlyToMe ) )
       
   465         {
       
   466         iFlags |= EFlag_OnlyToMe;
       
   467         }
       
   468     else
       
   469         {
       
   470         iFlags &= ~EFlag_OnlyToMe;
       
   471         }
       
   472     // EFlag_RemoteDeleted
       
   473     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_RemoteDeleted ) )
       
   474         {
       
   475         iFlags |= EFlag_RemoteDeleted;
       
   476         }
       
   477     else
       
   478         {
       
   479         iFlags &= ~EFlag_RemoteDeleted;
       
   480         }
       
   481     // EFlag_HasMsgSender 
       
   482     if ( iPluginMessage->IsFlagSet( EFSMsgFlag_HasMsgSender ) )
       
   483         {
       
   484         iFlags |= EFlag_HasMsgSender;
       
   485         }
       
   486     else
       
   487         {
       
   488         iFlags &= ~EFlag_HasMsgSender;
       
   489         }
       
   490     }
       
   491 
       
   492 // -----------------------------------------------------------------------------
       
   493 // 
       
   494 // -----------------------------------------------------------------------------
   356 MEmailMessageContent* CEmailMessage::ContentL() const
   495 MEmailMessageContent* CEmailMessage::ContentL() const
   357     {
   496     {
   358     if (iTextContent)
   497     if (iTextContent)
   359         {
   498         {
   360         return iTextContent;        
   499         return iTextContent;        
   380                         part->GetPartId().Id(),
   519                         part->GetPartId().Id(),
   381                         iMessageId.iId,
   520                         iMessageId.iId,
   382                         iMessageId.iFolderId.iId,
   521                         iMessageId.iFolderId.iId,
   383                         iMessageId.iFolderId.iMailboxId ); 
   522                         iMessageId.iFolderId.iMailboxId ); 
   384 
   523 
   385     if (!contentType.Compare(KFSMailContentTypeTextPlain) || 
   524     if (!contentType.Find(KFSMailContentTypeTextPlain) || 
   386         !contentType.Compare(KFSMailContentTypeTextHtml))
   525         !contentType.Find(KFSMailContentTypeTextHtml))
   387         {                                
   526         {                                
   388         iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns );        
   527         iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns );        
   389         }
   528         }
   390     else if (!contentType.Compare(KFSMailContentTypeMultipartMixed) ||
   529     else if (!contentType.Find(KFSMailContentTypeMultipartMixed) ||
   391              !contentType.Compare(KFSMailContentTypeMultipartAlternative) ||
   530              !contentType.Find(KFSMailContentTypeMultipartAlternative) ||
   392              !contentType.Compare(KFSMailContentTypeMultipartDigest) ||
   531              !contentType.Find(KFSMailContentTypeMultipartDigest) ||
   393              !contentType.Compare(KFSMailContentTypeMultipartRelated) ||
   532              !contentType.Find(KFSMailContentTypeMultipartRelated) ||
   394              !contentType.Compare(KFSMailContentTypeMultipartParallel))
   533              !contentType.Find(KFSMailContentTypeMultipartParallel))
   395         {
   534         {
   396         iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns);
   535         iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns);
   397         }
   536         }
   398     if (count == 2 )
   537     if (count == 2 )
   399         {
   538         {
   420         if (iTextContent)
   559         if (iTextContent)
   421             {
   560             {
   422             delete iTextContent; // Destroy old content
   561             delete iTextContent; // Destroy old content
   423             }
   562             }
   424         iTextContent = dynamic_cast<CEmailTextContent*>(textContent);
   563         iTextContent = dynamic_cast<CEmailTextContent*>(textContent);
   425         iTextContent->SetOwner( EAPIOwns );
   564 		if ( iTextContent )
       
   565 			{
       
   566 			iTextContent->SetOwner( EAPIOwns );
       
   567 			}
   426         return;
   568         return;
   427         }
   569         }
   428     MEmailMultipart* mPart = aContent->AsMultipartOrNull();
   570     MEmailMultipart* mPart = aContent->AsMultipartOrNull();
   429     if (mPart)
   571     if (mPart)
   430         {
   572         {
   431         if (iContent)
   573         if (iContent)
   432             {
   574             {
   433             delete iContent;
   575             delete iContent;
   434             }
   576             }
   435         iContent = dynamic_cast<CEmailMultipart*>(mPart);
   577         iContent = dynamic_cast<CEmailMultipart*>(mPart);
   436         iContent->SetOwner( EAPIOwns );
   578 		if ( iContent )
       
   579 			{
       
   580 			iContent->SetOwner( EAPIOwns );
       
   581 			}
   437         }    
   582         }    
   438     }
   583     }
   439     
   584     
   440 // -----------------------------------------------------------------------------
   585 // -----------------------------------------------------------------------------
   441 // 
   586 //