emailservices/emailstore/base_plugin/src/BasePlugin.cpp
branchRCL_3
changeset 63 d189ee25cf9d
parent 24 b5fbb9b25d57
child 64 3533d4323edc
--- a/emailservices/emailstore/base_plugin/src/BasePlugin.cpp	Thu Aug 19 09:38:05 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/BasePlugin.cpp	Tue Aug 31 15:04:17 2010 +0300
@@ -18,35 +18,42 @@
 
 //MsgStore.
 //<cmail>
-#include "msgstore.h"
-#include "msgstoreaccount.h"
-#include "msgstoremailbox.h"
-#include "msgstoremessage.h"
-#include "msgstorefolder.h"
-#include "msgstorepropertycontainer.h"
-#include "msgstorepropertykeys.h"
-#include "msgstoresortcriteria.h"
-#include "msgstoresortresultiterator.h"
+#include "MsgStore.h"
+#include "MsgStoreAccount.h"
+#include "MsgStoreMailBox.h"
+#include "MsgStoreMessage.h"
+#include "MsgStoreFolder.h"
+#include "MsgStorePropertyContainer.h"
+#include "MsgStorePropertyKeys.h"
+#include "MsgStoreSortCriteria.h"
+#include "MsgStoreSortResultIterator.h"
 //Freestyle.
-#include "cfsmailcommon.h"
-#include "cfsmailmessage.h"
+#include "CFSMailCommon.h"
+#include "CFSMailMessage.h"
 #include "cmrcalendarinfo.h" 
 //</cmail>
 //Base plugin.
-#include "baseplugin.h"
-#include "basepluginpanic.h"
+#include "BasePlugin.h"
+#include "BasePluginPanic.h"
 #include "baseplugincommonutils.h"
-#include "mailiterator.h"
+#include "MailIterator.h"
 #include "baseplugindelayedopsprivate.h"
+
+//<qmail>
+#include "CFSMailFolder.h"
+#include "baseplugindef.h"
+//</qmail>
+
 // Other
 #include <e32base.h>
 #include <utf.h>
 #include <calsession.h>
 
+//<qmail>
 //<cmail>
-#include "FreestyleEmailUiConstants.h"
+//#include "freestyleemailuiconstants.h" // removed from 10.1
 //</cmail>
-
+//</qmail>
 //size of the read buffer when reading body content from the quoted
 //message when replying/forwarding.
 const TInt KQuotedReadBufferSize = 1024*64;
@@ -77,7 +84,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::ConstructL()
+ void CBasePlugin::ConstructL()
     {
     __LOG_CONSTRUCT( "baseplugin", "CBasePlugin" )
 
@@ -93,7 +100,7 @@
 /**
  *
  */
-EXPORT_C CBasePlugin::CBasePlugin()
+ CBasePlugin::CBasePlugin()
 : iMailboxes( RMap<TInt, CMailboxInfo>::CompareInt )
    {
    }
@@ -102,7 +109,7 @@
 /**
  *
  */
-EXPORT_C CBasePlugin::~CBasePlugin()
+CBasePlugin::~CBasePlugin()
     {
     //needs to be first thing to do as it might force execution of operations
     //that depend on the plugin's current state.
@@ -111,7 +118,9 @@
     iMailboxes.ResetAndDestroy();
     iMailboxes.Close();
 
-    if ( iObservers.Count() > 0 )
+//<qmail>
+    if ( iObservers.Count() > 0 && iMsgStore )
+//</qmail>
         {
         TRAP_IGNORE( iMsgStore->RemoveObserverL( this ) );
         }
@@ -121,7 +130,12 @@
 
     iReqs.ResetAndDestroy();
     iReqs.Close();
-    
+//<qmail>
+    // Note that all the ops in iDelayedOpReqs array (if any) have already been
+    // deleted in the destructor of CDelayedOpsManager class.
+    iDelayedOpReqs.Reset();
+    iDelayedOpReqs.Close();
+//</qmail>
     ResetCache();
 
     __LOG_DESTRUCT
@@ -135,7 +149,7 @@
  * Note that as the msgstore performs the delete immediately the observer will get
  * called from within this method.
  */
-EXPORT_C void CBasePlugin::DeleteMailBoxByUidL(
+ void CBasePlugin::DeleteMailBoxByUidL(
     const TFSMailMsgId& aMailBoxId,
     MFSMailRequestObserver& aOperationObserver,
 	const TInt aRequestId )
@@ -188,7 +202,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::ListMailBoxesL( RArray<TFSMailMsgId>& aMailboxes )
+ void CBasePlugin::ListMailBoxesL( RArray<TFSMailMsgId>& aMailboxes )
     {
     __LOG_ENTER( "ListMailBoxesL" )
     
@@ -230,7 +244,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C CFSMailBox* CBasePlugin::GetMailBoxByUidL( const TFSMailMsgId& aMailBox )
+ CFSMailBox* CBasePlugin::GetMailBoxByUidL( const TFSMailMsgId& aMailBox )
     {
     __LOG_ENTER( "GetMailBoxByUidL" )
 
@@ -304,7 +318,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C TFSMailMsgId CBasePlugin::GetStandardFolderIdL(
+ TFSMailMsgId CBasePlugin::GetStandardFolderIdL(
     const TFSMailMsgId& aMailBoxId,
     const TFSFolderType aFolderType )
     
@@ -332,7 +346,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C CFSMailFolder* CBasePlugin::GetFolderByUidL(
+ CFSMailFolder* CBasePlugin::GetFolderByUidL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aFolderId )
 
@@ -403,7 +417,7 @@
  * @param aMailBoxId if not found leaves with KErrNotFound.
  * @return if the folder already exists returns the existing one.
  */
-EXPORT_C CFSMailFolder* CBasePlugin::CreateFolderL(
+ CFSMailFolder* CBasePlugin::CreateFolderL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aParentFolderId,
     const TDesC& aFolderName,
@@ -449,7 +463,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C void CBasePlugin::DeleteFolderByUidL(
+ void CBasePlugin::DeleteFolderByUidL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aFolder )
     
@@ -465,7 +479,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::ListFoldersL(
+ void CBasePlugin::ListFoldersL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aFolderId,
     RPointerArray<CFSMailFolder>& aFolderList )
@@ -490,7 +504,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::ListFoldersL(
+ void CBasePlugin::ListFoldersL(
     const TFSMailMsgId& aMailBoxId,
     RPointerArray<CFSMailFolder>& aFolderList )
     
@@ -508,7 +522,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C MFSMailIterator* CBasePlugin::ListMessagesL(
+ MFSMailIterator* CBasePlugin::ListMessagesL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aFolderId,
     const TFSMailDetails aDetails,
@@ -587,7 +601,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C CFSMailMessage* CBasePlugin::GetMessageByUidL(
+ CFSMailMessage* CBasePlugin::GetMessageByUidL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& /*aFolderId*/,
     const TFSMailMsgId& aMessageId,
@@ -612,7 +626,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C void CBasePlugin::DeleteMessagesByUidL(
+ void CBasePlugin::DeleteMessagesByUidL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aFolderId,
     const RArray<TFSMailMsgId>& aMessages )
@@ -634,7 +648,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C CFSMailMessage* CBasePlugin::CreateMessageToSendL(
+ CFSMailMessage* CBasePlugin::CreateMessageToSendL(
     const TFSMailMsgId& aMailBox )
     
     {
@@ -738,6 +752,28 @@
         {
         CleanupStack::PopAndDestroy( signature );
         }
+    
+//<qmail> 
+    //create the text/html part.
+    props = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( props );
+    
+	props->AddPropertyL(
+        KMsgStorePropertyContentType, KFSMailContentTypeTextHtml );
+	
+    props->AddPropertyL( KMsgStorePropertyCharset, KMessageBodyCharset );
+
+    props->AddPropertyL(
+        KMsgStorePropertyContentDisposition, KMessageBodyDisposition );
+    
+    CMsgStoreMessagePart* htmlPlain = bodyPart->AddChildPartL( *props );
+    CleanupStack::PopAndDestroy( props );         
+    CleanupStack::PushL( htmlPlain );
+    htmlPlain->AppendToContentL(KNullDesC8);
+    CleanupStack::PopAndDestroy( htmlPlain );
+//</qmail>
+    
+    //delete body part
     CleanupStack::PopAndDestroy( bodyPart );
 	
 	//done.
@@ -757,11 +793,26 @@
     return result;
     }
 
-
+ // <qmail>
+ /**
+  *
+  */
+ void CBasePlugin::CreateMessageToSendL(
+    const TFSMailMsgId& aMailBoxId,
+    MFSMailRequestObserver& aOperationObserver,
+    const TInt aRequestId)
+    {
+     CDelayedMessageToSendOp* delayedOp = CDelayedMessageToSendOp::NewLC(
+    *this,aMailBoxId,aOperationObserver,aRequestId);
+    iDelayedOpsManager->EnqueueOpL( delayedOp );
+    iDelayedOpReqs.AppendL(delayedOp);
+    CleanupStack::Pop( delayedOp );      
+    }
+ // </qmail> 
 /**
  *
  */
-EXPORT_C CFSMailMessage* CBasePlugin::CreateForwardMessageL(
+ CFSMailMessage* CBasePlugin::CreateForwardMessageL(
     const TFSMailMsgId& aMailBox,
     const TFSMailMsgId& aOriginal,
     const TDesC& aHeaderDescriptor )
@@ -773,7 +824,7 @@
 /**
  * Relying on the UI for the subject and recipients.
  */
-EXPORT_C CFSMailMessage* CBasePlugin::CreateReplyMessageL(
+ CFSMailMessage* CBasePlugin::CreateReplyMessageL(
     const TFSMailMsgId& aMailBoxId,
     const TFSMailMsgId& aOriginalMessageId,
     const TBool aReplyToAll,
@@ -786,7 +837,7 @@
 /**
  *
  */
-EXPORT_C CFSMailMessage* CBasePlugin::CreateMrReplyMessageL(
+ CFSMailMessage* CBasePlugin::CreateMrReplyMessageL(
     const TFSMailMsgId& aMailBoxId,
     MMRInfoObject& /*aMeetingRequest*/,
     const TFSMailMsgId& aOriginalMessageId )
@@ -799,7 +850,7 @@
  *
  * @param aMailBoxId if not found leaves with KErrNotFound.
  */
-EXPORT_C void CBasePlugin::StoreMessageL(
+ void CBasePlugin::StoreMessageL(
     const TFSMailMsgId& aMailBoxId,
     CFSMailMessage& aMessage )
     
@@ -841,12 +892,62 @@
     __LOG_EXIT
     }
 
+// <qmail>
+/**
+ *
+ * @param aMailBoxId Mailbox id.
+ * @param aOperationObserver Operation observer.
+ * @param aRequestId The request id.
+ */
+ void CBasePlugin::StoreMessagesL(
+    const TFSMailMsgId& aMailBox,
+    RPointerArray<CFSMailMessage> &messages,
+    MFSMailRequestObserver& aOperationObserver,
+    const TInt aRequestId )
+    
+    {
+    __LOG_ENTER( "StoreMessagesL" )
+    
+    CDelayedMessageStorerOp* delayedOp = CDelayedMessageStorerOp::NewLC(
+    aMailBox,messages,aOperationObserver,aRequestId);
+    iDelayedOpsManager->EnqueueOpL( delayedOp );
+    CleanupStack::Pop( delayedOp );
+   
+     
+    __LOG_EXIT
+    }
+// </qmail>
+
+
+// <qmail>
+/**
+ * Asynchronous message part storing
+ *
+ * @param aMessagePart email parts data to be stored
+ * @param aOperationObserver Observer for the operation 
+ * @param aRequestId id of the operation
+ */
+ void CBasePlugin::StoreMessagePartsL(
+    RPointerArray<CFSMailMessagePart>& aMessageParts,
+    MFSMailRequestObserver& aOperationObserver,
+    const TInt aRequestId)
+{
+    __LOG_ENTER( "StoreMessagePartsL" )
+            
+    CDelayedMessageStorerOp* delayedOp = CDelayedMessageStorerOp::NewLC(
+    aMessageParts,aOperationObserver,aRequestId);
+    iDelayedOpsManager->EnqueueOpL( delayedOp );
+    CleanupStack::Pop( delayedOp );
+    
+    __LOG_EXIT
+}
+// <//qmail>
 
 /**
  * Async operation, starts fetching.
  * @param aRequestId
  */
-EXPORT_C void CBasePlugin::FetchMessagesL(
+ void CBasePlugin::FetchMessagesL(
     const TFSMailMsgId& /*aMailBox*/,
     const TFSMailMsgId& /*aFolder*/,
     const RArray<TFSMailMsgId>& /*aMessageIds*/,
@@ -862,7 +963,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::GetMessagesL(
+ void CBasePlugin::GetMessagesL(
     const TFSMailMsgId& /*aMailBoxId*/,
     const TFSMailMsgId& /*aParentFolderId*/,
     const RArray<TFSMailMsgId>& /*aMessageIds*/,
@@ -877,7 +978,7 @@
 /**
  * CFSMailPlugin::SendMessageL
  */
-EXPORT_C void CBasePlugin::SendMessageL( CFSMailMessage& aMessage )    
+ void CBasePlugin::SendMessageL( CFSMailMessage& aMessage )    
     {
     __LOG_ENTER( "SendMessageL1" )
 
@@ -907,7 +1008,7 @@
  * This allows for optimizing away of unnecessary writes to the msgstore.
  * @param aSentTime the sent time you want set for the message.
  */
-EXPORT_C void CBasePlugin::SendMessageL(
+ void CBasePlugin::SendMessageL(
     CMsgStoreMailBox& aMailBox,
     CMsgStoreMessage& aMsg,
     const TTime& aSentTime )    
@@ -939,7 +1040,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::MoveMessagesL(
+ void CBasePlugin::MoveMessagesL(
     const TFSMailMsgId& aMailBoxId,
     const RArray<TFSMailMsgId>& aMessageIds,
     const TFSMailMsgId& aSourceFolderId,
@@ -962,7 +1063,7 @@
 /**
  *
  */
-EXPORT_C void CBasePlugin::CopyMessagesL(
+ void CBasePlugin::CopyMessagesL(
     const TFSMailMsgId& aMailBoxId,
     const RArray<TFSMailMsgId>& aMessageIds,
     RArray<TFSMailMsgId>& aNewMessages,
@@ -996,7 +1097,7 @@
  *
  * @param aId mailbox id, if none can be found leaves with KErrNotFound.
  */
-EXPORT_C CMailboxInfo& CBasePlugin::GetMailboxInfoL(
+ CMailboxInfo& CBasePlugin::GetMailboxInfoL(
     TMsgStoreId aId )
     {
     
@@ -1156,7 +1257,7 @@
  * This methoed must be called before destruction of 
  * CBasePlugin derived class. To fix bug EIZU-7XVF2Z.
  */
-EXPORT_C void CBasePlugin::DeleteDelayedOpsManager()
+void CBasePlugin::DeleteDelayedOpsManager()
     {
     delete iDelayedOpsManager;
     iDelayedOpsManager = NULL;
@@ -1196,7 +1297,7 @@
 /**
  *
  */
-EXPORT_C CMsgStoreMessagePart* CBasePlugin::GetBodyPartL(
+ CMsgStoreMessagePart* CBasePlugin::GetBodyPartL(
     CMsgStoreMessage& aMessage,
     const TDesC& aContentType )
     {
@@ -1256,7 +1357,7 @@
 /**
  *
  */
-EXPORT_C CFSMailMessage* CBasePlugin::CreateForwardReplyMessageL(
+ CFSMailMessage* CBasePlugin::CreateForwardReplyMessageL(
     const TFSMailMsgId& aMailBox,
     const TFSMailMsgId& aOriginal,
     const TBool aReplyToAll,
@@ -1570,7 +1671,7 @@
  * RefreshMailboxCacheL - This will refresh the mailbox instance cache maintained within the base plugin.  
  *
  */
-EXPORT_C CMailboxInfo& CBasePlugin::RefreshMailboxCacheL( TMsgStoreId aMailBoxId )
+ CMailboxInfo& CBasePlugin::RefreshMailboxCacheL( TMsgStoreId aMailBoxId )
     {
     //save the observers
     CMailboxInfo& oldMailBox = GetMailboxInfoL( aMailBoxId );