email/email/smtp/src/Local_imcvrecv.cpp
branchSymbian3
changeset 18 147b85a37c23
parent 6 c108117318cb
equal deleted inserted replaced
17:e3e31170f643 18:147b85a37c23
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
    16 
       
    17 
       
    18 /**
    16 /**
    19  @file
    17  @file
    20 */
    18 */
    21 
    19 
    22 
    20 
    34 #include <imcm.rsg>		// resource definition for IMCM
    32 #include <imcm.rsg>		// resource definition for IMCM
    35 
    33 
    36 #include <pop3set.h>	// For including KUidMsgTypePOP3
    34 #include <pop3set.h>	// For including KUidMsgTypePOP3
    37 #include <barsread.h>	// TResourceReader
    35 #include <barsread.h>	// TResourceReader
    38 
    36 
    39 #include <cmsvbodytext.h>
    37 #include "cmsvbodytext.h"
    40 
    38 
    41 #ifdef __WINS__
    39 #ifdef __WINS__
    42 #include <e32wins.h>    // for maxfilename lengths
    40 #include <e32wins.h>    // for maxfilename lengths
    43 #include <msvapi.h>
    41 #include <msvapi.h>
    44 #endif
    42 #endif
  1658 			addExtension=EFalse;
  1656 			addExtension=EFalse;
  1659 		}
  1657 		}
  1660 	if (addExtension)
  1658 	if (addExtension)
  1661 		AddFileExtension();
  1659 		AddFileExtension();
  1662 
  1660 
  1663 	CMsvStore* store = iServerEntry->EditStoreL(); 
  1661 	CMsvStore* store = iServerEntry->EditStoreL();	
  1664 	CleanupStack::PushL(store);
  1662 	CleanupStack::PushL(store);
  1665 	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
  1663 	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
  1666 	RFile file; 
  1664 	RFile file; 
  1667 	store->AttachmentManagerExtensionsL().CreateAttachmentL(iAttachmentName,file,attachment);
  1665 	store->AttachmentManagerExtensionsL().CreateAttachmentL(iAttachmentName,file,attachment);
  1668 	
  1666 	
  1746 			RECVLOG(KClosingAttachFile)
  1744 			RECVLOG(KClosingAttachFile)
  1747 			iAttachmentFile.CloseFile();	//file has to be closed before it can be deleted
  1745 			iAttachmentFile.CloseFile();	//file has to be closed before it can be deleted
  1748 			RECVLOG(KDeletingAttachFile)
  1746 			RECVLOG(KDeletingAttachFile)
  1749 			{ 
  1747 			{ 
  1750 			// NOTE - need the braces to stop error for re-definition of store
  1748 			// NOTE - need the braces to stop error for re-definition of store
  1751 			CMsvStore* store = iServerEntry->EditStoreL(); 
  1749 
       
  1750 			CMsvStore* store = iServerEntry->EditStoreL();	
  1752 			CleanupStack::PushL(store);
  1751 			CleanupStack::PushL(store);
  1753 		
  1752 		
  1754 			// Remove the attachment and commit the store.	
  1753 			// Remove the attachment and commit the store.	
  1755 			store->AttachmentManagerExtensionsL().RemoveAttachmentL(0);
  1754 			store->AttachmentManagerExtensionsL().RemoveAttachmentL(0);
  1756 			store->CommitL();
  1755 			store->CommitL();
  1782 
  1781 
  1783 
  1782 
  1784 			RECVLOG(KDeletingAttachFile)
  1783 			RECVLOG(KDeletingAttachFile)
  1785 			{ 
  1784 			{ 
  1786 			// NOTE - need the braces to stop error for re-definition of store
  1785 			// NOTE - need the braces to stop error for re-definition of store
  1787 			CMsvStore* store = iServerEntry->EditStoreL(); 
  1786 			CMsvStore* store = iServerEntry->EditStoreL();	
  1788 			CleanupStack::PushL(store);
  1787 			CleanupStack::PushL(store);
  1789 		
  1788 		
  1790 			// Remove the attachment and commit the store.	
  1789 			// Remove the attachment and commit the store.	
  1791 			store->AttachmentManagerExtensionsL().RemoveAttachmentL(0);
  1790 			store->AttachmentManagerExtensionsL().RemoveAttachmentL(0);
  1792 			store->CommitL();
  1791 			store->CommitL();
  2249 	RECVLOG(KStartStoringEntryStream);
  2248 	RECVLOG(KStartStoringEntryStream);
  2250 	if (iReceivingHeadersOnly==EFalse)
  2249 	if (iReceivingHeadersOnly==EFalse)
  2251 		{
  2250 		{
  2252 		CMsvStore* entryStore = NULL;
  2251 		CMsvStore* entryStore = NULL;
  2253 		TBool commitStore = EFalse;
  2252 		TBool commitStore = EFalse;
  2254 
  2253 		TRAPD(error, entryStore = iServerEntry->EditStoreL());	
  2255 		TRAPD(error, entryStore = iServerEntry->EditStoreL());
       
  2256 		if(error==KErrNone) // if store does not exist then the entry is the wrong type
  2254 		if(error==KErrNone) // if store does not exist then the entry is the wrong type
  2257 			{
  2255 			{
  2258 			CleanupStack::PushL(entryStore);
  2256 			CleanupStack::PushL(entryStore);
  2259 
  2257 
  2260 			if (aSettings & KStore822Header)
  2258 			if (aSettings & KStore822Header)
  2272 				RECVLOG(KStoringEntryStream);
  2270 				RECVLOG(KStoringEntryStream);
  2273 				entryStore->CommitL();
  2271 				entryStore->CommitL();
  2274 				}
  2272 				}
  2275 
  2273 
  2276 			StoreEntryDataL();
  2274 			StoreEntryDataL();
  2277 			CleanupStack::PopAndDestroy(); //entryStore		
  2275 			CleanupStack::PopAndDestroy(); //entryStore	
  2278 			}
  2276 			}
  2279 
  2277 		
  2280 		}
  2278 		}
  2281 	RECVLOG(KDoneStoringEntryStream);
  2279 	RECVLOG(KDoneStoringEntryStream);
  2282 	}
  2280 	}
  2283 
  2281 
  2284 
  2282 
  2504 				iOutputBody->AppendParagraphL();
  2502 				iOutputBody->AppendParagraphL();
  2505 				TInt length = iOutputBody->DocumentLength();
  2503 				TInt length = iOutputBody->DocumentLength();
  2506 				iOutputBody->InsertL(length,*msg);
  2504 				iOutputBody->InsertL(length,*msg);
  2507 				CleanupStack::PopAndDestroy(msg);
  2505 				CleanupStack::PopAndDestroy(msg);
  2508 				store=NULL;
  2506 				store=NULL;
  2509 				store = iServerEntry->EditStoreL();
  2507 				store = iServerEntry->EditStoreL();	
       
  2508 				
  2510 				CleanupStack::PushL(store);
  2509 				CleanupStack::PushL(store);
  2511 				store->StoreBodyTextL(*iOutputBody);
  2510 				store->StoreBodyTextL(*iOutputBody);
  2512 				store->Commit();
  2511 				store->Commit();
  2513 				CleanupStack::PopAndDestroy(store);
  2512 				CleanupStack::PopAndDestroy(store);
  2514 				}
  2513 				}
  4016 	else
  4015 	else
  4017 		{
  4016 		{
  4018 		return iServerEntry->Entry().Id();
  4017 		return iServerEntry->Entry().Id();
  4019 		}
  4018 		}
  4020 	}
  4019 	}
       
  4020