emailservices/emailclientapi/src/emailmessage.cpp
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
--- a/emailservices/emailclientapi/src/emailmessage.cpp	Tue Aug 31 15:04:17 2010 +0300
+++ b/emailservices/emailclientapi/src/emailmessage.cpp	Wed Sep 01 12:28:57 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -33,13 +33,9 @@
 #include "emailtextcontent.h"
 #include "emailmultipart.h"
 #include "emailattachment.h"
-#include "CFSMailPlugin.h"
-#include "CFSMailClient.h"
-
-#include <xqservicerequest.h>
-#include "email_services_api.h"
-
-const TInt KSendMessageRequestId = 100;
+#include "cfsmailplugin.h"
+#include "FreestyleEmailUiConstants.h"
+#include "cfsmailclient.h"
 
 // -----------------------------------------------------------------------------
 // 
@@ -51,14 +47,14 @@
     CEmailMessage* message = new ( ELeave ) CEmailMessage( aPluginData, aFsMessage, aOwner );
     CleanupStack::PushL( message );
     message->ConstructL();
-    CleanupStack::Pop( message );
+    CleanupStack::Pop();
     return message;
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
-CEmailMessage::CEmailMessage(
+CEmailMessage::CEmailMessage( 
         CPluginData& aPluginData,
         CFSMailMessage *aFsMessage,
         const TDataOwner aOwner)
@@ -70,8 +66,7 @@
 // 
 // -----------------------------------------------------------------------------
 void CEmailMessage::ConstructL()
-    {
-    User::LeaveIfNull( iPluginMessage );
+    {    
     iPlugin = iPluginData.ClaimInstanceL();
     if ( iPluginMessage )
         {
@@ -79,7 +74,7 @@
             iPluginMessage->GetMessageId().Id(),
             iPluginMessage->GetFolderId().Id(), 
             iPluginMessage->GetMailBoxId().Id() );
-
+        
         // Copy the message flags
         InitializeFlagValues();
         }
@@ -90,7 +85,7 @@
 // -----------------------------------------------------------------------------
 CEmailMessage::~CEmailMessage()
     {
-    delete iPluginMessage;
+    delete iPluginMessage;    
     delete iSender;
     delete iReplyTo;
     delete iTextContent;
@@ -114,10 +109,10 @@
     {
     if ( iOwner == EClientOwns )
         {
-        delete this;
+        delete this;        
         }
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
@@ -125,18 +120,16 @@
     {
     return iMessageId;
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
 MEmailAddress* CEmailMessage::SenderAddressL() const
     {
-    User::LeaveIfNull( iPluginMessage );
-
     CFSMailAddress* fsAddress = iPluginMessage->GetSender();
-    if ( fsAddress )
+    if (fsAddress)
         {
-        if ( !iSender )
+        if (!iSender)
             {
             iSender = CEmailAddress::NewL( MEmailAddress::ESender, EAPIOwns );
             }
@@ -151,18 +144,16 @@
         }
     return iSender;
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
 MEmailAddress* CEmailMessage::ReplyToAddressL() const
     {
-    User::LeaveIfNull( iPluginMessage );
-
     const CFSMailAddress& fsAddress = iPluginMessage->GetReplyToAddress();
     if ( &fsAddress )
         {
-        if ( !iReplyTo )
+        if (!iReplyTo)
             {
             iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns );
             }
@@ -176,18 +167,16 @@
         }
     return iReplyTo;
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
 void CEmailMessage::SetReplyToAddressL( const MEmailAddress& aSender )
     {
-    User::LeaveIfNull( iPluginMessage );
-    
     CFSMailAddress *fsAddress = CFSMailAddress::NewLC();
-    if ( !iReplyTo )
+    if (!iReplyTo)
         {
-        iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns );
+        iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns);
         }
     fsAddress->SetDisplayName( aSender.DisplayName() );
     fsAddress->SetEmailAddress( aSender.Address() );
@@ -195,8 +184,8 @@
     iReplyTo->SetAddressL( fsAddress->GetEmailAddress() );
     iReplyTo->SetDisplayNameL( fsAddress->GetDisplayName() );
     CleanupStack::Pop();
-    }
-
+    }       
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
@@ -204,18 +193,16 @@
         REmailAddressArray& aRecipients ) const
     {
     if( aRole == MEmailAddress::EReplyTo ||
-        aRole == MEmailAddress::ESender )
+        aRole == MEmailAddress::ESender    )
         {
         User::Leave( KErrArgument );
         }
-    else 
+    else
         {
-        User::LeaveIfNull( iPluginMessage );
-        
         if( aRole == MEmailAddress::ETo || 
             aRole == MEmailAddress::EUndefined )
             {
-            const RPointerArray<CFSMailAddress>& toRecipients =
+            RPointerArray<CFSMailAddress>& toRecipients = 
                 iPluginMessage->GetToRecipients();
             ConvertAddressArrayL( 
                     MEmailAddress::ETo, 
@@ -224,7 +211,7 @@
         if( aRole == MEmailAddress::ECc || 
             aRole == MEmailAddress::EUndefined )
             {
-            const RPointerArray<CFSMailAddress>& ccRecipients =
+            RPointerArray<CFSMailAddress>& ccRecipients = 
                 iPluginMessage->GetCCRecipients();
             ConvertAddressArrayL( 
                     MEmailAddress::ECc, 
@@ -233,7 +220,7 @@
         if( aRole == MEmailAddress::EBcc || 
             aRole == MEmailAddress::EUndefined )
             {
-            const RPointerArray<CFSMailAddress>& bccRecipients =
+            RPointerArray<CFSMailAddress>& bccRecipients = 
                 iPluginMessage->GetBCCRecipients();
             ConvertAddressArrayL( 
                     MEmailAddress::EBcc, 
@@ -241,16 +228,16 @@
             }
         }
     return aRecipients.Count();
-    }
+    }            
     
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
-void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole,
+void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole, 
         REmailAddressArray& aRecipients )
     {
     TInt count( aRecipients.Count() );
-
+    
     for( TInt i=0;i<count;i++ )
         {
         const MEmailAddress* address = aRecipients[i];
@@ -258,8 +245,6 @@
         fsAddress->SetEmailAddress( address->Address() );
         fsAddress->SetDisplayName( address->DisplayName() );
         
-        User::LeaveIfNull( iPluginMessage );
-        
         if( aRole == MEmailAddress::ETo )
             {
             iPluginMessage->AppendToRecipient( fsAddress );
@@ -279,46 +264,65 @@
         CleanupStack::Pop( fsAddress );
         }
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
-void CEmailMessage::RemoveRecipientL( const MEmailAddress& /*aRecipient*/ )
+void CEmailMessage::RemoveRecipientL( const MEmailAddress& aRecipient )
     {
-    User::Leave( KErrNotSupported );
+    TInt err( KErrNotFound );
+    RPointerArray<CFSMailAddress>* recipients = NULL;
+
+    switch (aRecipient.Role())
+        {
+        case MEmailAddress::ETo:
+            recipients = &iPluginMessage->GetToRecipients();
+            break;
+        case MEmailAddress::ECc:
+            recipients = &iPluginMessage->GetCCRecipients();
+            break;
+        case MEmailAddress::EBcc:
+            recipients = &iPluginMessage->GetBCCRecipients();
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    
+    for( TInt i = 0; i < recipients->Count(); i++ )
+        {
+        if ( !aRecipient.Address().Compare( (*recipients)[i]->GetEmailAddress() ) )
+            {
+            recipients->Remove(i);
+            err = KErrNone;
+            // We could break now. But let's loop if there are several entries
+            }
+        }
+    User::LeaveIfError( err );
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
 TPtrC CEmailMessage::Subject() const
     {
-    if ( !iPluginMessage )
-        return KNullDesC();
     return iPluginMessage->GetSubject();
     }
 
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
-void  CEmailMessage::SetSubjectL( const TPtrC& aSubject )
+void  CEmailMessage::SetSubjectL( const TPtrC& aSubject)
     {
-    User::LeaveIfNull( iPluginMessage );
     iPluginMessage->SetSubject( aSubject );
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
 TTime CEmailMessage::Date() const
     {
-    TTime time;
-
-    if ( iPluginMessage ) {
-        time = iPluginMessage->GetDate();
-    }
-
-    return time;
+    return iPluginMessage->GetDate();
     }
 
 // -----------------------------------------------------------------------------
@@ -336,10 +340,9 @@
     {
     iFlags |= aFlag;
     TUint flag = MapFlags( aFlag );
-    if ( iPluginMessage )
-        iPluginMessage->SetFlag( flag );
+    iPluginMessage->SetFlag( flag );
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
@@ -347,8 +350,7 @@
     {
     iFlags &= ~aFlag;
     TUint flag = MapFlags( aFlag );
-    if ( iPluginMessage )
-        iPluginMessage->ResetFlag( flag );
+    iPluginMessage->ResetFlag( flag );
     }
 
 // -----------------------------------------------------------------------------
@@ -356,8 +358,6 @@
 // -----------------------------------------------------------------------------
 void CEmailMessage::InitializeFlagValues()
     {
-    if ( !iPluginMessage )
-        return;
     // 1st reset member value, then start copying different flags
     iFlags = 0;
     
@@ -494,17 +494,15 @@
 // -----------------------------------------------------------------------------
 MEmailMessageContent* CEmailMessage::ContentL() const
     {
-    if ( iTextContent )
+    if (iTextContent)
         {
-        return iTextContent;
+        return iTextContent;        
         }
-    if ( iContent )
+    if (iContent)
         {
         return iContent;
         }
 
-    User::LeaveIfNull( iPluginMessage );
-    
     RPointerArray<CFSMailMessagePart> parts;
     CleanupResetAndDestroyPushL( parts );
     iPluginMessage->ChildPartsL( parts );
@@ -516,14 +514,14 @@
         return NULL;
         }
     CFSMailMessagePart* part = parts[0];
-    TContentType contentType( part->GetContentType() );
-    TMessageContentId msgContentId = TMessageContentId(
+    TContentType contentType( part->GetContentType() ); 
+    TMessageContentId msgContentId = TMessageContentId( 
                         part->GetPartId().Id(),
                         iMessageId.iId,
                         iMessageId.iFolderId.iId,
-                        iMessageId.iFolderId.iMailboxId );
+                        iMessageId.iFolderId.iMailboxId ); 
 
-    if ( contentType.Equals( KFSMailContentTypeTextPlain ) ||
+    if ( contentType.Equals( KFSMailContentTypeTextPlain ) || 
         contentType.Equals( KFSMailContentTypeTextHtml ) )
         {                                
         iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns );
@@ -540,10 +538,10 @@
         }
 
     CleanupStack::PopAndDestroy( &parts ); // parts
-
+    
     if (iTextContent)
         {
-        return iTextContent;
+        return iTextContent;        
         }
     return iContent;
     }
@@ -553,69 +551,69 @@
 // -----------------------------------------------------------------------------
 void CEmailMessage::SetContentL( const MEmailMessageContent*  aContent )
     {
-    User::LeaveIfNull( aContent );
     MEmailTextContent* textContent = aContent->AsTextContentOrNull();
-    if ( textContent )
+    if (textContent)
         {
-        if ( iTextContent )
+        if (iTextContent)
             {
             delete iTextContent; // Destroy old content
             }
-        iTextContent = dynamic_cast<CEmailTextContent*>( textContent );
-        if ( iTextContent )
-            {
-            iTextContent->SetOwner( EAPIOwns );
-            }
+        iTextContent = dynamic_cast<CEmailTextContent*>(textContent);
+		if ( iTextContent )
+			{
+			iTextContent->SetOwner( EAPIOwns );
+			}
         return;
         }
     MEmailMultipart* mPart = aContent->AsMultipartOrNull();
-    if ( mPart )
+    if (mPart)
         {
-        if ( iContent )
+        if (iContent)
             {
             delete iContent;
             }
-        iContent = dynamic_cast<CEmailMultipart*>( mPart );
-        if ( iContent )
-            {
-            iContent->SetOwner( EAPIOwns );
-            }
+        iContent = dynamic_cast<CEmailMultipart*>(mPart);
+		if ( iContent )
+			{
+			iContent->SetOwner( EAPIOwns );
+			}
         }    
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
 void CEmailMessage::SetPlainTextBodyL( const TDesC& aPlainText )
     {
-    if ( iTextContent )
+    if (iTextContent)
         {
         iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText );
         return;
         }
-
-    User::LeaveIfNull( iPluginMessage );
-
     CFSMailMessagePart* msgTextPart = iPluginMessage->PlainTextBodyPartL();
     
     if( !msgTextPart )
         {
-        msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain );
+        msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain );        
         }
     CleanupStack::PushL( msgTextPart );
-
-    TMessageContentId msgContentId = MessageContentId( msgTextPart->GetPartId().Id() );
-
-    msgTextPart->SetContentType( KFSMailContentTypeTextPlain );
+    
+    TMessageContentId msgContentId = TMessageContentId( 
+                        msgTextPart->GetPartId().Id(),
+                        iMessageId.iId,
+                        iMessageId.iFolderId.iId,
+                        iMessageId.iFolderId.iMailboxId );
+    
+    msgTextPart->SetContentType( KFSMailContentTypeTextPlain );    
     iTextContent = CEmailTextContent::NewL( iPluginData, msgContentId, msgTextPart, EAPIOwns );
     if (iTextContent)
         {
         iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText );
         }
-    CleanupStack::Pop( msgTextPart );
-
+    CleanupStack::Pop(); // msgTextPart
+    
     return;
-
+    
     }
 
 // -----------------------------------------------------------------------------
@@ -623,31 +621,28 @@
 // -----------------------------------------------------------------------------
 MEmailAttachment* CEmailMessage::AddAttachmentL( const TDesC& aFullPath )
     {
-    User::LeaveIfNull( iPluginMessage );
-
-    CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFullPath, TFSMailMsgId() );
+    CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL(aFullPath, TFSMailMsgId());
     CleanupStack::PushL( part );    
-    CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns );
+    CEmailAttachment* att = CEmailAttachment::NewLC(iPluginData, iMsgContentId, part, EAPIOwns);
     iAttachments.AppendL( att );
-    CleanupStack::Pop( 2, part );
-
+    CleanupStack::Pop(2); // part, att
+    
     return att;
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
+
 MEmailAttachment* CEmailMessage::AddAttachmentL( RFile& aFile )
     {
-    User::LeaveIfNull( iPluginMessage );
     TBufC8 <1> mime;
-    CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFile, mime );
+    CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL(aFile, mime);
     CleanupStack::PushL( part );
-    CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns );
+    CEmailAttachment* att = CEmailAttachment::NewLC(iPluginData, iMsgContentId, part, EAPIOwns);
     iAttachments.AppendL( att );
-
-    CleanupStack::Pop( 2, part );
-
+    CleanupStack::Pop(2); // part, att
+    
     return att;
     }
 
@@ -656,31 +651,32 @@
 // -----------------------------------------------------------------------------
 TInt CEmailMessage::GetAttachmentsL( REmailAttachmentArray& aAttachments )
     {
-    User::LeaveIfNull( iPluginMessage );
-
     RPointerArray<CFSMailMessagePart> attachments;
     CleanupResetAndDestroyPushL( attachments );
-    iPluginMessage->AttachmentListL( attachments );
+    iPluginMessage->AttachmentListL(attachments);
     const TInt count( attachments.Count() );
     for (TInt i = 0; i < count; i++)
         {
-        TMessageContentId msgContentId = MessageContentId( attachments[i]->GetPartId().Id() );
-
-        CEmailAttachment* att = CEmailAttachment::NewL( 
-            iPluginData, msgContentId, attachments[i], EClientOwns );
+            TMessageContentId msgContentId = TMessageContentId( 
+                            attachments[i]->GetPartId().Id(),
+                            iMessageId.iId,
+                            iMessageId.iFolderId.iId,
+                            iMessageId.iFolderId.iMailboxId ); 
 
-        aAttachments.AppendL( att );
+            CEmailAttachment* att = CEmailAttachment::NewL(iPluginData, msgContentId, attachments[i], EClientOwns);
+            
+            aAttachments.AppendL(att);
         }
-    CleanupStack::Pop( &attachments );
-    return count;
+    CleanupStack::Pop(); // attachments
+    return count;    
     }
-
+    
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
-void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& /*aAttachment*/ )
+void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& aAttachment  )
     {
-    User::Leave( KErrNotSupported );
+    iPluginMessage->RemoveChildPartL(FsMsgId( iPluginData, aAttachment.Id()));
     }
 
 // -----------------------------------------------------------------------------
@@ -696,8 +692,6 @@
 // -----------------------------------------------------------------------------
 void CEmailMessage::SaveChangesL()
     {
-    User::LeaveIfNull( iPluginMessage );
-    
     TFSMailMsgId mailboxId( 
             FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ) );
     
@@ -709,37 +703,16 @@
 // -----------------------------------------------------------------------------
 void CEmailMessage::SendL()
     {
-    User::LeaveIfNull( iPluginMessage );
-    
-    if ( iEventLoop.isRunning() )
-        User::Leave( KErrInUse );
-    
     SaveChangesL();
-    iError = KErrNone;
-    iPlugin->SendMessageL( *iPluginMessage, *this, KSendMessageRequestId );
-    iEventLoop.exec();
-
-    User::LeaveIfError( iError );
+    iPlugin->SendMessageL( *iPluginMessage );
     }
 
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
-void CEmailMessage::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
-    {
-    iError = aEvent.iError;
-
-    if ( aRequestId == KSendMessageRequestId &&
-            aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
-        iEventLoop.quit();
-    }
-
-// -----------------------------------------------------------------------------
-// 
-// -----------------------------------------------------------------------------
-void CEmailMessage::ConvertAddressArrayL(
+void CEmailMessage::ConvertAddressArrayL( 
         const MEmailAddress::TRole aRole,
-        const RPointerArray<CFSMailAddress>& aSrc,
+        RPointerArray<CFSMailAddress>& aSrc, 
         REmailAddressArray& aDst ) const
     {
     for ( TInt i=0; i<aSrc.Count(); i++ )
@@ -753,7 +726,8 @@
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
-CEmailAddress* CEmailMessage::CreateAddressLC(
+//
+CEmailAddress* CEmailMessage::CreateAddressLC( 
         const MEmailAddress::TRole aRole, 
         CFSMailAddress& aFsAddress ) const
     {
@@ -774,6 +748,7 @@
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
+//
 TUint CEmailMessage::MapFlags( const TUint& aFlag )
     {
     TUint flag = 0;
@@ -827,66 +802,63 @@
     return flag;
     }
 
-// -----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-void CEmailMessage::ShowMessageViewerL()
+void CEmailMessage::ShowMessageViewerL( )
     {   
-    bool syncronous;
-
-    XQServiceRequest request(
-       emailInterfaceNameMessage,
-       emailOperationViewMessage,
-       syncronous );
+    THtmlViewerActivationData htmlData;
+    htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage;
+    htmlData.iMailBoxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId);
+    htmlData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId);
+    htmlData.iMessageId = FsMsgId(iPluginData, iMessageId);
+    TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
+    CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
+    viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, HtmlViewerId), KHtmlViewerOpenNew, pckgData);
+    CleanupStack::PopAndDestroy();
+    }    
 
-    TFSMailMsgId mailboxId = FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId );
-    TFSMailMsgId folderId = FsMsgId( iPluginData, iMessageId.iFolderId );
-    TFSMailMsgId messageId = FsMsgId( iPluginData, iMessageId );
-
-    QList<QVariant> list;
-    list.append( mailboxId.Id() );
-    list.append( folderId.Id() );
-    list.append( messageId.Id() );
-    request.setArguments( list );
-
-    QVariant returnValue;
-    if ( !request.send( returnValue ) )
-        User::Leave( KErrGeneral );
+/** 
+ * Launches Email application and new reply message in editor. 
+ * The method follows "fire and forget" pattern, returns immediately.
+ */
+void CEmailMessage::ReplyToMessageL( const TBool aReplyToAll )
+    {
+    TEditorLaunchParams editorLaunchData;
+    editorLaunchData.iExtra = NULL;
+    editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId);
+    editorLaunchData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId);
+    editorLaunchData.iMsgId = FsMsgId(iPluginData, iMessageId);
+    editorLaunchData.iActivatedExternally = ETrue; 
+    
+    TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData );
+    CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
+    TUid command = TUid::Uid(KEditorCmdReplyAll);
+    if ( !aReplyToAll )
+        {
+        command = TUid::Uid(KEditorCmdReply);
+        }
+    viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData);
+    CleanupStack::PopAndDestroy();   
     }
 
-// -----------------------------------------------------------------------------
-// Launches Email application and new reply message in editor. 
-// The method follows "fire and forget" pattern, returns immediately.
-// -----------------------------------------------------------------------------
-void CEmailMessage::ReplyToMessageL( const TBool /*aReplyToAll*/ )
+void CEmailMessage::ForwardMessageL()
     {
-    User::Leave( KErrNotSupported );
+    TEditorLaunchParams editorLaunchData;
+    editorLaunchData.iExtra = NULL;
+    editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId);
+    editorLaunchData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId);
+    editorLaunchData.iMsgId = FsMsgId(iPluginData, iMessageId);
+    editorLaunchData.iActivatedExternally = ETrue; 
+    
+    TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData );
+    CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
+    TUid command = TUid::Uid(KEditorCmdForward);
+    viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData);
+    CleanupStack::PopAndDestroy();   
     }
 
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
-void CEmailMessage::ForwardMessageL()
-    {
-    User::Leave( KErrNotSupported );
-    }
-
-// -----------------------------------------------------------------------------
 //
-// -----------------------------------------------------------------------------
-TMessageContentId CEmailMessage::MessageContentId( TEntryId aContentId ) const
-    {
-    TMessageContentId msgContentId = TMessageContentId( 
-                    aContentId,
-                    iMessageId.iId,
-                    iMessageId.iFolderId.iId,
-                    iMessageId.iFolderId.iMailboxId );
-    return msgContentId;
-    }
-
-// -----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
 TContentType::TContentType( const TDesC& aContentType ) : iContentType( aContentType )
     {
     _LIT( KSeparator, ";" );
@@ -900,13 +872,14 @@
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
+//
 TBool TContentType::Equals( const TDesC& aContentType )
     {
-    TBool ret = iContentType.CompareF( aContentType );
+	TBool ret = iContentType.CompareF( aContentType );
     if ( ret == 0  )
-        return ETrue;
+    	return ETrue;
     else
-        return EFalse;
+    	return EFalse;
     }
 
-// End of file
+// End of file.