emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp
changeset 54 997a02608b3a
parent 30 759dc5235cdb
child 59 16ed8d08d0b1
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
    70             "Error while executing delayed operation: %d.", err );
    70             "Error while executing delayed operation: %d.", err );
    71         }
    71         }
    72     
    72     
    73     //self-destroy.
    73     //self-destroy.
    74     iManager->DequeueOp( *this );
    74     iManager->DequeueOp( *this );
       
    75     
       
    76     //Remove this from iDelayedOpReqs as well.
       
    77     for ( TInt i = 0; i < iPlugin->iDelayedOpReqs.Count(); i++ )
       
    78         {
       
    79         if ( iPlugin->iDelayedOpReqs[i] == this )
       
    80             {
       
    81             iPlugin->iDelayedOpReqs.Remove( i );
       
    82             break;
       
    83             }
       
    84         }
    75     delete this;
    85     delete this;
    76     }
    86     }
    77     
    87     
    78 /**
    88 /**
    79  * 
    89  * 
   611     const TFSMailMsgId& aMailBox,
   621     const TFSMailMsgId& aMailBox,
   612     RPointerArray<CFSMailMessage> &messages,
   622     RPointerArray<CFSMailMessage> &messages,
   613     MFSMailRequestObserver& aOperationObserver,
   623     MFSMailRequestObserver& aOperationObserver,
   614     const TInt aRequestId)
   624     const TInt aRequestId)
   615     : iMailBox( aMailBox ), 
   625     : iMailBox( aMailBox ), 
   616       iOperationObserver( aOperationObserver ),
       
   617       iRequestId( aRequestId ),
       
   618       iType(EHeaders)
   626       iType(EHeaders)
   619     {
   627     {
       
   628     
       
   629     CDelayedOp::iOperationObserver = &aOperationObserver ;
       
   630     CDelayedOp::iRequestId =  aRequestId ;
       
   631        
   620     for(TInt i=0; i < messages.Count(); i++)
   632     for(TInt i=0; i < messages.Count(); i++)
   621         {
   633         {
   622         iMessages.Append(messages[i]);
   634         iMessages.Append(messages[i]);
   623         }
   635         }
   624     }
   636     }
   628  */
   640  */
   629 /*private*/ CDelayedMessageStorerOp::CDelayedMessageStorerOp(
   641 /*private*/ CDelayedMessageStorerOp::CDelayedMessageStorerOp(
   630     RPointerArray<CFSMailMessagePart>& aMessageParts,
   642     RPointerArray<CFSMailMessagePart>& aMessageParts,
   631     MFSMailRequestObserver& aOperationObserver,
   643     MFSMailRequestObserver& aOperationObserver,
   632     const TInt aRequestId)
   644     const TInt aRequestId)
   633     :iOperationObserver( aOperationObserver ),
   645     :iType(EParts)
   634     iRequestId( aRequestId ),
   646     {
   635     iType(EParts)
   647     
   636     {
   648     CDelayedOp::iOperationObserver = &aOperationObserver ;
       
   649     CDelayedOp::iRequestId =  aRequestId ;
       
   650     
   637     for(TInt i=0; i < aMessageParts.Count(); i++)
   651     for(TInt i=0; i < aMessageParts.Count(); i++)
   638         {
   652         {
   639         iMessageParts.Append(aMessageParts[i]);
   653         iMessageParts.Append(aMessageParts[i]);
   640         }
   654         }
   641     }
   655     }
   702     if( err == KErrNone )
   716     if( err == KErrNone )
   703         {
   717         {
   704         progress.iError = KErrNone;
   718         progress.iError = KErrNone;
   705         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
   719         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
   706         }
   720         }
   707 
   721 		
   708     iOperationObserver.RequestResponseL( progress, iRequestId );
   722 		if(iOperationObserver)
       
   723 			{
       
   724 				iOperationObserver->RequestResponseL( progress, iRequestId );
       
   725 			}
       
   726     
   709     
   727     
   710     __LOG_EXIT;
   728     __LOG_EXIT;
   711     }
   729     }
   712 
   730 
   713 
   731 
   714 /**
   732 /**
   715  * 
   733  * 
   716  */
   734  */
   717 void CDelayedMessageStorerOp::StorePartL(
   735 void CDelayedMessageStorerOp::StorePartL(CFSMailMessagePart* aPart)
   718         CFSMailMessagePart* aPart)
       
   719     {
   736     {
   720     User::LeaveIfNull(aPart);
   737     User::LeaveIfNull(aPart);
   721     
   738 
   722     // Text buffer for html text content
   739     // Text buffer for html text content
   723     HBufC* data16 = aPart->GetLocalTextContentLC();
   740     HBufC* data16 = aPart->GetLocalTextContentLC();
   724 
   741 
   725     TPtrC8 ptr8(reinterpret_cast<const TUint8*>( data16->Ptr() ),
   742     // Convert from 16 to 8 bit data -
   726             data16->Size() );
   743     HBufC8* dataBuffer = HBufC8::NewLC((data16->Length() * 2) + 1);
   727     
   744     TPtr8 ptr8(dataBuffer->Des());
       
   745     CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr8, *data16);
       
   746 
   728     //get msgstore part
   747     //get msgstore part
   729     CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL( aPart->GetMailBoxId().Id() );
   748     CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL(
   730     
   749             aPart->GetMailBoxId().Id());
       
   750 
   731     CMsgStoreMessage* msg = mailBox().FetchMessageL(
   751     CMsgStoreMessage* msg = mailBox().FetchMessageL(
   732             aPart->GetMessageId().Id(), KMsgStoreInvalidId );
   752             aPart->GetMessageId().Id(), KMsgStoreInvalidId);
   733     CleanupStack::PushL( msg );
   753     CleanupStack::PushL(msg);
   734     
   754 
   735     CMsgStoreMessagePart* part= msg->ChildPartL( aPart->GetPartId().Id(), ETrue );
   755     CMsgStoreMessagePart* part = msg->ChildPartL(aPart->GetPartId().Id(),
   736     
   756             ETrue);
   737     CleanupStack::PopAndDestroy( msg );
   757 
   738     CleanupStack::PushL( part );
   758     CleanupStack::PopAndDestroy(msg);
       
   759     CleanupStack::PushL(part);
   739 
   760 
   740     //replace content
   761     //replace content
   741     part->ReplaceContentL(ptr8);
   762     part->ReplaceContentL(ptr8);
   742     
   763 
   743     CleanupStack::PopAndDestroy( part );
   764     CleanupStack::PopAndDestroy(part);
   744     CleanupStack::PopAndDestroy( data16 );
   765     CleanupStack::PopAndDestroy(dataBuffer);
   745        
   766     CleanupStack::PopAndDestroy(data16);
       
   767 
   746     }
   768     }
   747 
   769 
   748 
   770 
   749 ///////////////////////////////////////////////////
   771 ///////////////////////////////////////////////////
   750 // CDelayedMessageToSendOp                      //
   772 // CDelayedMessageToSendOp                      //
   792     CBasePlugin& aPlugin,
   814     CBasePlugin& aPlugin,
   793     const TFSMailMsgId& aMailBox,
   815     const TFSMailMsgId& aMailBox,
   794     MFSMailRequestObserver& aOperationObserver,
   816     MFSMailRequestObserver& aOperationObserver,
   795     const TInt aRequestId)
   817     const TInt aRequestId)
   796     : iBasePlugin(aPlugin), 
   818     : iBasePlugin(aPlugin), 
   797       iMailBox( aMailBox ), 
   819       iMailBox( aMailBox )
   798       iOperationObserver( aOperationObserver ),
   820     {
   799       iRequestId( aRequestId )
   821     
   800     {
   822     CDelayedOp::iOperationObserver = &aOperationObserver ;
       
   823     CDelayedOp::iRequestId =  aRequestId ;
   801 
   824 
   802     }
   825     }
   803 
   826 
   804 
   827 
   805 /**
   828 /**
   819         {
   842         {
   820         progress.iError = KErrNone;
   843         progress.iError = KErrNone;
   821         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
   844         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
   822         }
   845         }
   823 
   846 
   824     iOperationObserver.RequestResponseL( progress, iRequestId );
   847 		if(iOperationObserver)
       
   848 			{
       
   849 				iOperationObserver->RequestResponseL( progress, iRequestId );
       
   850 			}
   825     
   851     
   826     __LOG_EXIT;
   852     __LOG_EXIT;
   827     }
   853     }
   828 
   854 
   829 
   855 
   883     const TInt aRequestId) :
   909     const TInt aRequestId) :
   884     iMailBoxId( aMailBoxId ),
   910     iMailBoxId( aMailBoxId ),
   885     iParentFolderId( aParentFolderId ),
   911     iParentFolderId( aParentFolderId ),
   886     iMessageId( aMessageId ),
   912     iMessageId( aMessageId ),
   887     iParentPartId( aParentPartId ),
   913     iParentPartId( aParentPartId ),
   888     iOperationObserver( aOperationObserver ),
       
   889     iRequestId( aRequestId ),
       
   890     iActionType( AddNewChild)
   914     iActionType( AddNewChild)
   891     {
   915     {
       
   916     CDelayedOp::iOperationObserver = &aOperationObserver ;
       
   917     CDelayedOp::iRequestId =  aRequestId ;
   892     }
   918     }
   893 
   919 
   894 /**
   920 /**
   895  * 
   921  * 
   896  */
   922  */
   905     iMailBoxId( aMailBoxId ),
   931     iMailBoxId( aMailBoxId ),
   906     iParentFolderId( aParentFolderId ),
   932     iParentFolderId( aParentFolderId ),
   907     iMessageId( aMessageId ),
   933     iMessageId( aMessageId ),
   908     iParentPartId( aParentPartId ),
   934     iParentPartId( aParentPartId ),
   909     iPartId( aPartId ),
   935     iPartId( aPartId ),
   910     iOperationObserver( aOperationObserver ),
       
   911     iRequestId( aRequestId ),
       
   912     iActionType( RemoveChild)
   936     iActionType( RemoveChild)
   913     {
   937     {
       
   938     CDelayedOp::iOperationObserver = &aOperationObserver ;
       
   939     CDelayedOp::iRequestId =  aRequestId ;
   914     }
   940     }
   915 
   941 
   916 /**
   942 /**
   917  * 
   943  * 
   918  */
   944  */
   976         GetPlugin().ResetCache();
  1002         GetPlugin().ResetCache();
   977         progress.iError = KErrNone;
  1003         progress.iError = KErrNone;
   978         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
  1004         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
   979         }
  1005         }
   980 		
  1006 		
   981     iOperationObserver.RequestResponseL( progress, iRequestId );
  1007 		if(iOperationObserver)
       
  1008 			{
       
  1009 				iOperationObserver->RequestResponseL( progress, iRequestId );
       
  1010 			}
   982     
  1011     
   983     __LOG_EXIT;
  1012     __LOG_EXIT;
   984     }
  1013     }
   985 //</qmail>
  1014 //</qmail>