1741 // ---------------------------------------------------------------------------- |
1758 // ---------------------------------------------------------------------------- |
1742 // ---------------------------------------------------------------------------- |
1759 // ---------------------------------------------------------------------------- |
1743 void CIpsPlgSosBasePlugin::DeleteMessagesByUidL( |
1760 void CIpsPlgSosBasePlugin::DeleteMessagesByUidL( |
1744 const TFSMailMsgId& /*aMailBoxId*/, |
1761 const TFSMailMsgId& /*aMailBoxId*/, |
1745 const TFSMailMsgId& /*aFolderId*/, |
1762 const TFSMailMsgId& /*aFolderId*/, |
1746 const RArray<TFSMailMsgId>& aMessages ) |
1763 const RArray<TFSMailMsgId>& aMessages ) |
1747 { |
1764 { |
1748 FUNC_LOG; |
1765 FUNC_LOG; |
1749 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection; |
1766 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection; |
1750 CleanupStack::PushL(sel); |
1767 CleanupStack::PushL(sel); |
1751 |
1768 |
1752 TInt count = aMessages.Count(); |
1769 TInt count = aMessages.Count(); |
1753 TMsvEntry tEntry; |
1770 TMsvEntry tEntry; |
1754 TMsvId service; |
1771 TMsvId service; |
1755 |
1772 |
1756 TMsvEntry parentEntry; |
1773 TMsvEntry parentEntry; |
1757 |
1774 |
1758 for(TInt i=0; i<count; i++) |
1775 // simulation of canceling deletion operation |
1759 { |
1776 if ( !count ) |
1760 iSession->GetEntry( aMessages[i].Id(), service, tEntry ); |
1777 { |
1761 |
1778 if ( iMsvOpDeleteMessage ) |
1762 //make sure that only messages get deleted. |
1779 { |
1763 if( tEntry.iType == KUidMsvMessageEntry ) |
1780 iMsvOpDeleteMessage->Cancel(); |
1764 { |
1781 } |
1765 iSession->GetEntry( tEntry.Parent( ), service, parentEntry ); |
1782 |
1766 |
1783 if ( iWaitDeleteMessage ) |
1767 CMsvEntry *cEntry = CMsvEntry::NewL( |
1784 { |
|
1785 iWaitDeleteMessage->Cancel(); |
|
1786 } |
|
1787 |
|
1788 delete iMsvOpDeleteMessage; |
|
1789 iMsvOpDeleteMessage = NULL; |
|
1790 delete iWaitDeleteMessage; |
|
1791 iWaitDeleteMessage = NULL; |
|
1792 delete icEntry; |
|
1793 icEntry = NULL; |
|
1794 } |
|
1795 else |
|
1796 { |
|
1797 for( TInt i = 0; i < count; i++ ) |
|
1798 { |
|
1799 iSession->GetEntry( aMessages[i].Id(), service, tEntry ); |
|
1800 |
|
1801 //make sure that only messages get deleted. |
|
1802 if( tEntry.iType == KUidMsvMessageEntry ) |
|
1803 { |
|
1804 if(iMsvOpDeleteMessage) |
|
1805 { |
|
1806 iMsvOpDeleteMessage->Cancel(); |
|
1807 delete iMsvOpDeleteMessage; |
|
1808 iMsvOpDeleteMessage = NULL; |
|
1809 } |
|
1810 |
|
1811 if ( iWaitDeleteMessage ) |
|
1812 { |
|
1813 iWaitDeleteMessage->Cancel(); |
|
1814 delete iWaitDeleteMessage; |
|
1815 iWaitDeleteMessage = NULL; |
|
1816 } |
|
1817 |
|
1818 delete icEntry; |
|
1819 icEntry = NULL; |
|
1820 |
|
1821 iSession->GetEntry( tEntry.Parent( ), service, parentEntry ); |
|
1822 |
|
1823 icEntry = CMsvEntry::NewL( |
1768 *iSession, tEntry.Id(), TMsvSelectionOrdering() ); |
1824 *iSession, tEntry.Id(), TMsvSelectionOrdering() ); |
1769 CleanupStack::PushL( cEntry ); |
1825 |
1770 CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC( ); |
1826 |
1771 // Sets bit 32 of iMtmData1, used when msg deleted in Offline |
1827 // priority slightly increased not to pause the function longer than needed |
1772 // and status hasn't updated to server (client entry still exists) |
1828 iWaitDeleteMessage = CIpsPlgOperationWait::NewL( CActive::EPriorityStandard+1 ); |
1773 tEntry.SetLocallyDeleted( ETrue ); |
1829 // Sets bit 32 of iMtmData1, used when msg deleted in Offline |
1774 CMsvOperation* msvOp = cEntry->ChangeL( tEntry, wait->iStatus ); |
1830 // and status hasn't updated to server (client entry still exists) |
1775 CleanupStack::PushL(msvOp); |
1831 tEntry.SetLocallyDeleted( ETrue ); |
1776 wait->Start(); |
1832 |
1777 sel->AppendL( tEntry.Id() ); |
1833 iMsvOpDeleteMessage = icEntry->ChangeL( tEntry, |
1778 CleanupStack::PopAndDestroy( 3, cEntry ); |
1834 iWaitDeleteMessage->iStatus ); |
1779 } |
1835 |
1780 } |
1836 iWaitDeleteMessage->Start(); |
1781 |
1837 |
1782 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this ); |
1838 sel->AppendL( tEntry.Id() ); |
1783 CleanupStack::PushL( watcher ); |
1839 } |
1784 CMsvOperation* op = CIpsPlgDeleteRemote::NewL( *iSession, |
1840 } |
1785 watcher->iStatus, *sel ); |
1841 |
1786 watcher->SetOperation( op ); |
1842 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC( *this ); |
1787 |
1843 |
1788 // make draft deletion synchronous so that empty drafts are not left after application close |
1844 CMsvOperation* op = CIpsPlgDeleteRemote::NewL( *iSession, |
1789 if ( parentEntry.Id() == KMsvDraftEntryIdValue && count == 1 ) |
1845 watcher->iStatus, *sel ); |
1790 { |
1846 watcher->SetOperation( op ); |
1791 iWait.Start(); |
1847 |
1792 CleanupStack::PopAndDestroy( watcher ); |
1848 // make draft deletion synchronous so that empty drafts are not left after application close |
1793 } |
1849 if ( parentEntry.Id() == KMsvDraftEntryIdValue && count == 1 ) |
1794 else |
1850 { |
1795 { |
1851 iWait.Start(); |
1796 iOperations.AppendL( watcher ); |
1852 CleanupStack::PopAndDestroy( watcher ); |
1797 CleanupStack::Pop( watcher ); |
1853 } |
1798 } |
1854 else |
1799 |
1855 { |
|
1856 iOperations.AppendL( watcher ); |
|
1857 CleanupStack::Pop( watcher ); |
|
1858 } |
|
1859 } |
|
1860 |
1800 CleanupStack::PopAndDestroy( sel ); |
1861 CleanupStack::PopAndDestroy( sel ); |
1801 } |
1862 } |
1802 |
1863 |
1803 // ---------------------------------------------------------------------------- |
1864 // ---------------------------------------------------------------------------- |
1804 // ---------------------------------------------------------------------------- |
1865 // ---------------------------------------------------------------------------- |
2175 TPtr hPtr( pckg().iHeader->Des() ); |
2236 TPtr hPtr( pckg().iHeader->Des() ); |
2176 HBufC* body = HBufC::NewLC( |
2237 HBufC* body = HBufC::NewLC( |
2177 textBodyPart->FetchedContentSize() ); |
2238 textBodyPart->FetchedContentSize() ); |
2178 TPtr bPtr( body->Des() ); |
2239 TPtr bPtr( body->Des() ); |
2179 origMsgTextBodyPart->GetContentToBufferL( bPtr, 0 ); |
2240 origMsgTextBodyPart->GetContentToBufferL( bPtr, 0 ); |
2180 HBufC* content = HBufC::NewLC( |
2241 TInt contentLength = hPtr.Length() + bPtr.Length() + |
2181 hPtr.Length() + bPtr.Length() ); |
2242 KLineFeed().Length(); |
2182 TPtr cPtr( content->Des() ); |
2243 HBufC* signatureText = NULL; |
|
2244 // if signature resolving leaves, ignore it, i.e., |
|
2245 // continue without signature adding |
|
2246 TRAP_IGNORE( signatureText = |
|
2247 ResolveSignatureTextL( aMailBoxId ) ); |
|
2248 if ( signatureText ) |
|
2249 { |
|
2250 CleanupStack::PushL( signatureText ); |
|
2251 contentLength += signatureText->Length() + |
|
2252 KLineFeed().Length(); |
|
2253 } |
|
2254 HBufC* content = HBufC::NewLC( contentLength ); |
|
2255 TPtr cPtr( content->Des() ); |
|
2256 if ( signatureText ) |
|
2257 { |
|
2258 cPtr.Append( *signatureText ); |
|
2259 // extra empty line between signature and original txt |
|
2260 cPtr.Append( KLineFeed ); |
|
2261 } |
|
2262 cPtr.Append( KLineFeed ); |
2183 cPtr.Append( hPtr ); |
2263 cPtr.Append( hPtr ); |
2184 cPtr.Append( bPtr ); |
2264 cPtr.Append( bPtr ); |
2185 textBodyPart->SetContent( cPtr ); |
2265 textBodyPart->SetContent( cPtr ); |
2186 textBodyPart->SaveL(); |
2266 textBodyPart->SaveL(); |
2187 CleanupStack::PopAndDestroy( content ); |
2267 CleanupStack::PopAndDestroy( content ); |
|
2268 if ( signatureText ) |
|
2269 { |
|
2270 CleanupStack::PopAndDestroy( signatureText ); |
|
2271 } |
2188 CleanupStack::PopAndDestroy( body ); |
2272 CleanupStack::PopAndDestroy( body ); |
2189 CleanupStack::PopAndDestroy( origMsgTextBodyPart ); |
2273 CleanupStack::PopAndDestroy( origMsgTextBodyPart ); |
2190 } |
2274 } |
2191 CleanupStack::PopAndDestroy( origMsg ); |
2275 CleanupStack::PopAndDestroy( origMsg ); |
2192 } |
2276 } |
2193 CleanupStack::PopAndDestroy( textBodyPart ); |
2277 CleanupStack::PopAndDestroy( textBodyPart ); |
2194 } |
2278 } |
|
2279 } |
|
2280 |
|
2281 // --------------------------------------------------------------------------- |
|
2282 // --------------------------------------------------------------------------- |
|
2283 HBufC* CIpsPlgSosBasePlugin::ResolveSignatureTextL( |
|
2284 const TFSMailMsgId& aMailBoxId ) |
|
2285 { |
|
2286 FUNC_LOG; |
|
2287 HBufC* signatureText = NULL; |
|
2288 |
|
2289 if ( iSettingsApi && iSession ) |
|
2290 { |
|
2291 TMsvEntry entry; |
|
2292 TMsvId serv; |
|
2293 iSession->GetEntry( aMailBoxId.Id(), serv, entry ); |
|
2294 signatureText = iSettingsApi->SignatureTextL( entry ); |
|
2295 } |
|
2296 |
|
2297 return signatureText; |
2195 } |
2298 } |
2196 |
2299 |
2197 // --------------------------------------------------------------------------- |
2300 // --------------------------------------------------------------------------- |
2198 // --------------------------------------------------------------------------- |
2301 // --------------------------------------------------------------------------- |
2199 void CIpsPlgSosBasePlugin::DisconnectL( |
2302 void CIpsPlgSosBasePlugin::DisconnectL( |