email/imap4mtm/imapsession/src/cimapfetchresponse.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 // this class
       
    17 #include "cimapfetchresponse.h"
       
    18 
       
    19 // user includes
       
    20 #include "cimapbodystructure.h"
       
    21 #include "cimaprfc822headerfields.h"
       
    22 
       
    23 	
       
    24 EXPORT_C CImapFetchResponse* CImapFetchResponse::NewL()
       
    25 // static method
       
    26 // no non-trivial construction is needed as objects are constructed on demand.
       
    27 	{
       
    28 	return new(ELeave)CImapFetchResponse();
       
    29 	}
       
    30 
       
    31 CImapFetchResponse::~CImapFetchResponse()
       
    32 	{
       
    33 	delete iHeaderFields;
       
    34 	delete iBodyStructure;		
       
    35 	delete iBodyStructureData;
       
    36 	}
       
    37 
       
    38 /**
       
    39 Returns the header information.
       
    40 @return A pointer to the header information object or NULL.  Ownership is NOT transferred.
       
    41 */	
       
    42 EXPORT_C CImapRfc822HeaderFields* CImapFetchResponse::HeaderFields()
       
    43 	{
       
    44 	return iHeaderFields;
       
    45 	}
       
    46 
       
    47 /**
       
    48 Returns the body structure.
       
    49 @return A pointer to the body structure or NULL.  Ownership is NOT transferred.
       
    50 */
       
    51 EXPORT_C CImapBodyStructure* CImapFetchResponse::BodyStructure()
       
    52 	{
       
    53 	return iBodyStructure;
       
    54 	}
       
    55 
       
    56 /**
       
    57 Sets the bodystructure and its data - and takes ownership of both parameters.
       
    58 This operation will panic if the bodystructure or data are already set.
       
    59 @param aBodyStructure The root body structure object
       
    60 @param aBodyStructureData The data buffer that the bodystructure object points into
       
    61 */
       
    62 void CImapFetchResponse::SetBodyStructure(CImapBodyStructure* aBodyStructure, HBufC8* aBodyStructureData)
       
    63 	{
       
    64 	if(iBodyStructure != NULL)
       
    65 		return;
       
    66 	// Don't allow data overwrite
       
    67 	ASSERT(iBodyStructure == NULL);
       
    68 	ASSERT(iBodyStructureData == NULL);
       
    69 	
       
    70 	// BOTH parameters must be non-null (otherwise they are inconsistent)
       
    71 	ASSERT(aBodyStructure != NULL);
       
    72 	ASSERT(aBodyStructureData != NULL);
       
    73 	
       
    74 	iBodyStructure = aBodyStructure;
       
    75 	iBodyStructureData = aBodyStructureData;
       
    76 	}
       
    77 	
       
    78 /**
       
    79 Sets the header fields object and takes ownership of it.
       
    80 This operation will panic if the header fields object is already set.
       
    81 @param aHeaderFields The header fields object, representing RFC822 header information.
       
    82 */
       
    83 void CImapFetchResponse::SetHeaderFields(CImapRfc822HeaderFields* aHeaderFields)
       
    84 	{
       
    85 	// Don't allow data overwrite
       
    86 	ASSERT(iHeaderFields == NULL);
       
    87 	
       
    88 	iHeaderFields = aHeaderFields;
       
    89 	}
       
    90 
       
    91 /**
       
    92 Copies the supplied message flag and uid info into this object
       
    93 @param the supplied message flag and uid info
       
    94 */
       
    95 void CImapFetchResponse::SetMessageFlagInfo(const TMessageFlagInfo& aMessageFlagInfo)
       
    96 	{
       
    97 	iMessageFlagInfo = aMessageFlagInfo;
       
    98 	}
       
    99 
       
   100 /**
       
   101 @return The Uid of the message that was fetched.
       
   102 */
       
   103 EXPORT_C TUint CImapFetchResponse::MessageUid() const
       
   104 	{
       
   105 	return iMessageFlagInfo.MessageUid();
       
   106 	}
       
   107 
       
   108 /**
       
   109 @return The message flags information for this response.
       
   110 */
       
   111 EXPORT_C TMessageFlagInfo& CImapFetchResponse::MessageFlagInfo()
       
   112 	{
       
   113 	return iMessageFlagInfo;
       
   114 	}