850 TBool hasStore = cEntry->HasStoreL(); |
857 TBool hasStore = cEntry->HasStoreL(); |
851 |
858 |
852 if ( hasStore ) |
859 if ( hasStore ) |
853 { |
860 { |
854 CMsvStore* store = cEntry->EditStoreL(); |
861 CMsvStore* store = cEntry->EditStoreL(); |
855 |
|
856 CleanupStack::PushL( store ); |
862 CleanupStack::PushL( store ); |
857 |
863 |
|
864 // For some reason, the attachment manager returns zero attachment |
|
865 // count with pop3 protocol, when the email contains another email |
|
866 // as an attachment. As a workaround, the attachment is set |
|
867 // fetched with pop3 protocol. |
858 MMsvAttachmentManager& attMgr = store->AttachmentManagerL(); |
868 MMsvAttachmentManager& attMgr = store->AttachmentManagerL(); |
859 |
869 if ( aEntry.iMtm == KSenduiMtmPop3Uid || attMgr.AttachmentCount() ) |
860 if ( attMgr.AttachmentCount() ) |
|
861 { |
870 { |
862 aMessage.SetMessagePartsStatus( EFSFull ); |
871 aMessage.SetMessagePartsStatus( EFSFull ); |
863 } |
872 } |
864 else |
873 else |
865 { |
874 { |
866 aMessage.SetMessagePartsStatus( EFSNone ); |
875 aMessage.SetMessagePartsStatus( EFSNone ); |
867 } |
876 } |
868 |
877 |
869 CleanupStack::PopAndDestroy( store ); |
878 CleanupStack::PopAndDestroy( store ); |
870 } |
879 } |
871 |
|
872 CleanupStack::PopAndDestroy( cEntry ); |
880 CleanupStack::PopAndDestroy( cEntry ); |
873 } |
881 } |
874 else if ( aEntry.Id() != aMsgMainId ) |
882 else if ( aEntry.Id() != aMsgMainId ) |
875 { |
883 { |
876 // fetch state of some message part, then we sure know |
884 // fetch state of some message part, then we sure know |
1593 CleanupStack::PopAndDestroy( store ); |
1605 CleanupStack::PopAndDestroy( store ); |
1594 } |
1606 } |
1595 CleanupStack::PopAndDestroy( cEntry ); |
1607 CleanupStack::PopAndDestroy( cEntry ); |
1596 } |
1608 } |
1597 // </cmail> |
1609 // </cmail> |
|
1610 |
|
1611 |
|
1612 // --------------------------------------------------------------------------- |
|
1613 // CIpsPlgMsgMapperHelper::OpCompleted |
|
1614 // --------------------------------------------------------------------------- |
|
1615 // |
|
1616 void CIpsPlgMsgMapperHelper::OpCompleted( |
|
1617 CIpsPlgSingleOpWatcher& aOpWatcher, |
|
1618 TInt aCompletionCode ) |
|
1619 { |
|
1620 FUNC_LOG; |
|
1621 |
|
1622 TInt opId = aOpWatcher.Operation().Id(); |
|
1623 TMsvId completedMsvId = aOpWatcher.Operation().Service(); |
|
1624 |
|
1625 if( iCurrentOperationWatcher ) |
|
1626 { |
|
1627 CMsvOperation& oper = iCurrentOperationWatcher->Operation(); |
|
1628 |
|
1629 //delete the iOngoingOperation when it has completed |
|
1630 if( oper.Id() == opId ) |
|
1631 { |
|
1632 delete iCurrentOperationWatcher; |
|
1633 iCurrentOperationWatcher = NULL; |
|
1634 } |
|
1635 } |
|
1636 |
|
1637 //remove the completed MsvId from the iNeedSetAttachFlagArray |
|
1638 for( TInt j = 0; j < iNeedSetAttachFlagArray.Count(); ++j ) |
|
1639 { |
|
1640 if( completedMsvId == iNeedSetAttachFlagArray[j] ) |
|
1641 { |
|
1642 iNeedSetAttachFlagArray.Remove( j ); |
|
1643 break; |
|
1644 } |
|
1645 } |
|
1646 //start next async process |
|
1647 iTimer.After( iStatus, 0 ); |
|
1648 SetActive(); |
|
1649 } |
|
1650 |
|
1651 |
|
1652 // --------------------------------------------------------------------------- |
|
1653 // CIpsPlgMsgMapperHelper::NewL |
|
1654 // --------------------------------------------------------------------------- |
|
1655 // |
|
1656 CIpsPlgMsgMapperHelper* CIpsPlgMsgMapperHelper::NewL( CMsvSession& aSession ) |
|
1657 { |
|
1658 FUNC_LOG; |
|
1659 |
|
1660 CIpsPlgMsgMapperHelper* self = new (ELeave) CIpsPlgMsgMapperHelper( aSession ); |
|
1661 CleanupStack::PushL(self); |
|
1662 self->ConstructL(); |
|
1663 CleanupStack::Pop(); |
|
1664 return self; |
|
1665 } |
|
1666 |
|
1667 // --------------------------------------------------------------------------- |
|
1668 // CIpsPlgMsgMapperHelper::~CIpsPlgMsgMapperHelper |
|
1669 // --------------------------------------------------------------------------- |
|
1670 // |
|
1671 CIpsPlgMsgMapperHelper::~CIpsPlgMsgMapperHelper() |
|
1672 { |
|
1673 FUNC_LOG; |
|
1674 |
|
1675 Cancel(); |
|
1676 //should delete the iOngoingOperation if it not completed |
|
1677 if( iCurrentOperationWatcher ) |
|
1678 { |
|
1679 delete iCurrentOperationWatcher; |
|
1680 iCurrentOperationWatcher = NULL; |
|
1681 } |
|
1682 iNeedSetAttachFlagArray.Reset(); |
|
1683 iNeedSetAttachFlagArray.Close(); |
|
1684 |
|
1685 Deque(); |
|
1686 iTimer.Close(); |
|
1687 } |
|
1688 |
|
1689 // --------------------------------------------------------------------------- |
|
1690 // CIpsPlgMsgMapperHelper::CIpsPlgMsgMapperHelper |
|
1691 // --------------------------------------------------------------------------- |
|
1692 // |
|
1693 CIpsPlgMsgMapperHelper::CIpsPlgMsgMapperHelper( CMsvSession& aSession ) |
|
1694 :CActive( EPriorityStandard ), iSession( aSession ), iPending( EFalse ), |
|
1695 iCurrentOperationWatcher( NULL ) |
|
1696 { |
|
1697 FUNC_LOG; |
|
1698 } |
|
1699 |
|
1700 // --------------------------------------------------------------------------- |
|
1701 // CIpsPlgMsgMapperHelper::ConstructL |
|
1702 // --------------------------------------------------------------------------- |
|
1703 // |
|
1704 void CIpsPlgMsgMapperHelper::ConstructL() |
|
1705 { |
|
1706 FUNC_LOG; |
|
1707 |
|
1708 User::LeaveIfError( iTimer.CreateLocal() ); |
|
1709 CActiveScheduler::Add(this); |
|
1710 } |
|
1711 |
|
1712 // inherited from CActive |
|
1713 // --------------------------------------------------------------------------- |
|
1714 // CIpsPlgMsgMapperHelper::RunL |
|
1715 // --------------------------------------------------------------------------- |
|
1716 // |
|
1717 void CIpsPlgMsgMapperHelper::RunL() |
|
1718 { |
|
1719 FUNC_LOG; |
|
1720 |
|
1721 User::LeaveIfError( iStatus.Int() ); |
|
1722 // always start the async process from the index 0 of iNeedSetAttachFlagArray |
|
1723 TInt currentIndex = 0; |
|
1724 |
|
1725 if( iNeedSetAttachFlagArray.Count() > 0 ) |
|
1726 { |
|
1727 TMsvId entry = iNeedSetAttachFlagArray[currentIndex]; |
|
1728 TMsvId serviceId; |
|
1729 TMsvEmailEntry entryToBeChanged; |
|
1730 //get enty by msvid |
|
1731 TBool result = iSession.GetEntry( entry, serviceId, entryToBeChanged); |
|
1732 |
|
1733 if( entryToBeChanged.Attachment() ) |
|
1734 { |
|
1735 // ignore this operation and delete when it has set the attach flag |
|
1736 iNeedSetAttachFlagArray.Remove( currentIndex ); |
|
1737 iTimer.After( iStatus, 0 ); |
|
1738 SetActive(); |
|
1739 return; |
|
1740 } |
|
1741 |
|
1742 CIpsPlgSingleOpWatcher* opW = CIpsPlgSingleOpWatcher::NewLC( *this ); |
|
1743 |
|
1744 CMsvEntry* cEntry = iSession.GetEntryL( entry ); |
|
1745 CleanupStack::PushL( cEntry ); |
|
1746 |
|
1747 entryToBeChanged.SetAttachment( ETrue ); |
|
1748 CMsvOperation* ops = cEntry->ChangeL( entryToBeChanged, opW->iStatus ); |
|
1749 CleanupStack::PopAndDestroy( cEntry ); |
|
1750 |
|
1751 if( ops ) |
|
1752 { |
|
1753 opW->SetOperation( ops ); |
|
1754 if( iCurrentOperationWatcher ) |
|
1755 { |
|
1756 delete iCurrentOperationWatcher; |
|
1757 iCurrentOperationWatcher = NULL; |
|
1758 } |
|
1759 iCurrentOperationWatcher = opW; |
|
1760 CleanupStack::Pop( opW ); |
|
1761 } |
|
1762 else |
|
1763 { |
|
1764 CleanupStack::PopAndDestroy( opW ); |
|
1765 } |
|
1766 } |
|
1767 else |
|
1768 { |
|
1769 //all these operation have processed |
|
1770 iPending = EFalse; |
|
1771 } |
|
1772 } |
|
1773 |
|
1774 // --------------------------------------------------------------------------- |
|
1775 // CIpsPlgMsgMapperHelper::RunError |
|
1776 // --------------------------------------------------------------------------- |
|
1777 // |
|
1778 TInt CIpsPlgMsgMapperHelper::RunError( TInt aError ) |
|
1779 { |
|
1780 FUNC_LOG; |
|
1781 |
|
1782 if ( KErrNone != aError ) |
|
1783 { |
|
1784 Cancel(); |
|
1785 } |
|
1786 return KErrNone; |
|
1787 } |
|
1788 |
|
1789 void CIpsPlgMsgMapperHelper::DoCancel() |
|
1790 { |
|
1791 FUNC_LOG; |
|
1792 if( iCurrentOperationWatcher ) |
|
1793 { |
|
1794 iCurrentOperationWatcher->Cancel(); |
|
1795 delete iCurrentOperationWatcher; |
|
1796 iCurrentOperationWatcher = NULL; |
|
1797 } |
|
1798 iTimer.Cancel(); |
|
1799 } |
|
1800 |
|
1801 // --------------------------------------------------------------------------- |
|
1802 // CIpsPlgMsgMapperHelper::StartSetAttchmentFlag |
|
1803 // --------------------------------------------------------------------------- |
|
1804 // |
|
1805 void CIpsPlgMsgMapperHelper::StartSetAttchmentFlag() |
|
1806 { |
|
1807 FUNC_LOG; |
|
1808 //should start the ao when not in pending status |
|
1809 if( !IsActive() && !iPending ) |
|
1810 { |
|
1811 iTimer.After( iStatus, 0 ); |
|
1812 SetActive(); |
|
1813 iPending = ETrue; |
|
1814 } |
|
1815 } |
|
1816 |
|
1817 // --------------------------------------------------------------------------- |
|
1818 // CIpsPlgMsgMapperHelper::AppendToArrayL |
|
1819 // --------------------------------------------------------------------------- |
|
1820 // |
|
1821 TBool CIpsPlgMsgMapperHelper::AppendMsvIdToArrayL( TMsvId aId ) |
|
1822 { |
|
1823 FUNC_LOG; |
|
1824 |
|
1825 TInt count = iNeedSetAttachFlagArray.Count(); |
|
1826 //check the MsvId if already exist in iNeedSetAttachFlagArray |
|
1827 for( TInt i = 0; i < count; ++i ) |
|
1828 { |
|
1829 TMsvId id = iNeedSetAttachFlagArray[i]; |
|
1830 if( id == aId ) |
|
1831 { |
|
1832 return EFalse; |
|
1833 } |
|
1834 } |
|
1835 |
|
1836 iNeedSetAttachFlagArray.AppendL( aId ); |
|
1837 return ETrue; |
|
1838 } |
|
1839 |
|
1840 |
|
1841 |