474 : iMailBoxId( aMailBoxId ), iMessageId( aMessageId ), |
475 : iMailBoxId( aMailBoxId ), iMessageId( aMessageId ), |
475 iMessagePartId( aMessagePartId ), iContentLength( aContentLength ), |
476 iMessagePartId( aMessagePartId ), iContentLength( aContentLength ), |
476 iStepOne( EFalse ) |
477 iStepOne( EFalse ) |
477 { |
478 { |
478 } |
479 } |
|
480 |
|
481 /////////////////////////////////////////////////// |
|
482 // CDelayedMessageStorerOp // |
|
483 /////////////////////////////////////////////////// |
|
484 |
|
485 /** |
|
486 * |
|
487 */ |
|
488 /*public static */ CDelayedMessageStorerOp* CDelayedMessageStorerOp::NewLC( |
|
489 const TFSMailMsgId& aMailBox, |
|
490 RPointerArray<CFSMailMessage> &messages, |
|
491 MFSMailRequestObserver& aOperationObserver, |
|
492 const TInt aRequestId) |
|
493 { |
|
494 CDelayedMessageStorerOp* self = new (ELeave) CDelayedMessageStorerOp( |
|
495 aMailBox, messages, aOperationObserver,aRequestId); |
|
496 CleanupStack::PushL( self ); |
|
497 self->ConstructL( ); |
|
498 return self; |
|
499 } |
|
500 |
|
501 /** |
|
502 * |
|
503 */ |
|
504 /*public static */ CDelayedMessageStorerOp* CDelayedMessageStorerOp::NewLC( |
|
505 RPointerArray<CFSMailMessagePart>& aMessageParts, |
|
506 MFSMailRequestObserver& aOperationObserver, |
|
507 const TInt aRequestId) |
|
508 { |
|
509 CDelayedMessageStorerOp* self = new (ELeave) CDelayedMessageStorerOp( |
|
510 aMessageParts, aOperationObserver, aRequestId); |
|
511 CleanupStack::PushL( self ); |
|
512 self->ConstructL( ); |
|
513 return self; |
|
514 } |
|
515 |
|
516 /** |
|
517 * |
|
518 */ |
|
519 /*public virtual*/ CDelayedMessageStorerOp::~CDelayedMessageStorerOp() |
|
520 { |
|
521 __LOG_DESTRUCT |
|
522 iMessages.Reset(); |
|
523 iMessageParts.Reset(); |
|
524 if (iDataBuffer) |
|
525 { |
|
526 delete iDataBuffer; |
|
527 iDataBuffer = NULL; |
|
528 } |
|
529 } |
|
530 |
|
531 /** |
|
532 * |
|
533 */ |
|
534 /*private*/ |
|
535 void CDelayedMessageStorerOp::ConstructL( ) |
|
536 { |
|
537 __LOG_CONSTRUCT( "baseplugin", "CDelayedMessageStorerOp" ); |
|
538 |
|
539 } |
|
540 |
|
541 /** |
|
542 * |
|
543 */ |
|
544 /*private*/ CDelayedMessageStorerOp::CDelayedMessageStorerOp( |
|
545 const TFSMailMsgId& aMailBox, |
|
546 RPointerArray<CFSMailMessage> &messages, |
|
547 MFSMailRequestObserver& aOperationObserver, |
|
548 const TInt aRequestId) |
|
549 : iMailBox( aMailBox ), |
|
550 iOperationObserver( aOperationObserver ), |
|
551 iRequestId( aRequestId ), |
|
552 iType(EHeaders) |
|
553 { |
|
554 for(TInt i=0; i < messages.Count(); i++) |
|
555 { |
|
556 iMessages.Append(messages[i]); |
|
557 } |
|
558 } |
|
559 |
|
560 /** |
|
561 * |
|
562 */ |
|
563 /*private*/ CDelayedMessageStorerOp::CDelayedMessageStorerOp( |
|
564 RPointerArray<CFSMailMessagePart>& aMessageParts, |
|
565 MFSMailRequestObserver& aOperationObserver, |
|
566 const TInt aRequestId) |
|
567 :iOperationObserver( aOperationObserver ), |
|
568 iRequestId( aRequestId ), |
|
569 iType(EParts) |
|
570 { |
|
571 for(TInt i=0; i < aMessageParts.Count(); i++) |
|
572 { |
|
573 iMessageParts.Append(aMessageParts[i]); |
|
574 } |
|
575 } |
|
576 |
|
577 /** |
|
578 * |
|
579 */ |
|
580 /*private*/ void CDelayedMessageStorerOp::ExecuteOpL() |
|
581 { |
|
582 __LOG_ENTER( "ExecuteOpL" ); |
|
583 |
|
584 TFSProgress progress = { TFSProgress::EFSStatus_RequestCancelled, 0, 0, 0 }; |
|
585 progress.iError = KErrNotFound; |
|
586 TInt err(KErrNone); |
|
587 |
|
588 switch( iType ) |
|
589 { |
|
590 case EHeaders: |
|
591 { |
|
592 for ( TInt i = 0; i < iMessages.Count(); i++ ) |
|
593 { |
|
594 TRAP(err, GetPlugin().StoreMessageL(iMailBox, *iMessages[i] )); |
|
595 if(err!=KErrNone) |
|
596 { |
|
597 break; |
|
598 } |
|
599 } |
|
600 break; |
|
601 } |
|
602 |
|
603 case EParts: |
|
604 { |
|
605 for ( TInt i = 0; i < iMessageParts.Count(); i++ ) |
|
606 { |
|
607 CFSMailMessagePart& part= *iMessageParts[i]; |
|
608 TFSMailMsgId messageId= part.GetMessageId(); |
|
609 TFSMailMsgId folderId= part.GetFolderId(); |
|
610 |
|
611 if (part.GetContentType().Compare(KFSMailContentTypeTextPlain) == 0 || |
|
612 part.GetContentType().Compare(KFSMailContentTypeTextHtml) == 0) |
|
613 { |
|
614 TRAP(err,StorePartL(&part)); |
|
615 if(err!=KErrNone) |
|
616 { |
|
617 break; |
|
618 } |
|
619 TRAP(err, GetPlugin().StoreMessagePartL( part.GetMailBoxId(), folderId, messageId, part )); |
|
620 } |
|
621 else |
|
622 { |
|
623 TRAP(err, GetPlugin().StoreMessagePartL( part.GetMailBoxId(), folderId, messageId, part )); |
|
624 } |
|
625 if(err!=KErrNone) |
|
626 { |
|
627 break; |
|
628 } |
|
629 } |
|
630 } |
|
631 |
|
632 default: |
|
633 break; |
|
634 } |
|
635 |
|
636 if( err == KErrNone ) |
|
637 { |
|
638 progress.iError = KErrNone; |
|
639 progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete; |
|
640 } |
|
641 |
|
642 iOperationObserver.RequestResponseL( progress, iRequestId ); |
|
643 |
|
644 __LOG_EXIT; |
|
645 } |
|
646 |
|
647 |
|
648 /** |
|
649 * |
|
650 */ |
|
651 void CDelayedMessageStorerOp::StorePartL( |
|
652 CFSMailMessagePart* aPart) |
|
653 { |
|
654 User::LeaveIfNull(aPart); |
|
655 |
|
656 // Text buffer for html text content |
|
657 HBufC* data16 = aPart->GetLocalTextContentLC(); |
|
658 |
|
659 TPtrC8 ptr8(reinterpret_cast<const TUint8*>( data16->Ptr() ), |
|
660 data16->Size() ); |
|
661 |
|
662 //get msgstore part |
|
663 CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL( aPart->GetMailBoxId().Id() ); |
|
664 |
|
665 CMsgStoreMessage* msg = mailBox().FetchMessageL( |
|
666 aPart->GetMessageId().Id(), KMsgStoreInvalidId ); |
|
667 CleanupStack::PushL( msg ); |
|
668 |
|
669 CMsgStoreMessagePart* part= msg->ChildPartL( aPart->GetPartId().Id(), ETrue ); |
|
670 |
|
671 CleanupStack::PopAndDestroy( msg ); |
|
672 CleanupStack::PushL( part ); |
|
673 |
|
674 //replace content |
|
675 part->ReplaceContentL(ptr8); |
|
676 |
|
677 CleanupStack::PopAndDestroy( part ); |
|
678 CleanupStack::PopAndDestroy( data16 ); |
|
679 |
|
680 } |
|
681 |
|
682 |
|
683 /////////////////////////////////////////////////// |
|
684 // CDelayedMessageToSendOp // |
|
685 /////////////////////////////////////////////////// |
|
686 |
|
687 /** |
|
688 * |
|
689 */ |
|
690 /*public static */ CDelayedMessageToSendOp* CDelayedMessageToSendOp::NewLC( |
|
691 CBasePlugin& aPlugin, |
|
692 const TFSMailMsgId& aMailBox, |
|
693 MFSMailRequestObserver& aOperationObserver, |
|
694 const TInt aRequestId) |
|
695 { |
|
696 CDelayedMessageToSendOp* self = new (ELeave) CDelayedMessageToSendOp( |
|
697 aPlugin,aMailBox, aOperationObserver,aRequestId); |
|
698 CleanupStack::PushL( self ); |
|
699 self->ConstructL( ); |
|
700 return self; |
|
701 } |
|
702 |
|
703 |
|
704 /** |
|
705 * |
|
706 */ |
|
707 /*public virtual*/ CDelayedMessageToSendOp::~CDelayedMessageToSendOp() |
|
708 { |
|
709 __LOG_DESTRUCT |
|
710 } |
|
711 |
|
712 /** |
|
713 * |
|
714 */ |
|
715 /*private*/ |
|
716 void CDelayedMessageToSendOp::ConstructL( ) |
|
717 { |
|
718 __LOG_CONSTRUCT( "baseplugin", "CDelayedMessageToSendOp" ); |
|
719 |
|
720 } |
|
721 |
|
722 /** |
|
723 * |
|
724 */ |
|
725 /*private*/ CDelayedMessageToSendOp::CDelayedMessageToSendOp( |
|
726 CBasePlugin& aPlugin, |
|
727 const TFSMailMsgId& aMailBox, |
|
728 MFSMailRequestObserver& aOperationObserver, |
|
729 const TInt aRequestId) |
|
730 : iBasePlugin(aPlugin), |
|
731 iMailBox( aMailBox ), |
|
732 iOperationObserver( aOperationObserver ), |
|
733 iRequestId( aRequestId ) |
|
734 { |
|
735 |
|
736 } |
|
737 |
|
738 |
|
739 /** |
|
740 * |
|
741 */ |
|
742 /*private*/ void CDelayedMessageToSendOp::ExecuteOpL() |
|
743 { |
|
744 __LOG_ENTER( "ExecuteOpL" ); |
|
745 |
|
746 TFSProgress progress = { TFSProgress::EFSStatus_RequestCancelled, 0, 0, 0 }; |
|
747 progress.iError = KErrNotFound; |
|
748 TInt err(KErrNone); |
|
749 |
|
750 TRAP(err, progress.iParam = iBasePlugin.CreateMessageToSendL( iMailBox )); |
|
751 |
|
752 if( err == KErrNone ) |
|
753 { |
|
754 progress.iError = KErrNone; |
|
755 progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete; |
|
756 } |
|
757 |
|
758 iOperationObserver.RequestResponseL( progress, iRequestId ); |
|
759 |
|
760 __LOG_EXIT; |
|
761 } |