email/imap4mtm/imapsession/src/cimapexamine.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 #include "cimapexamine.h"
       
    17 #include "moutputstream.h"
       
    18 #include "cimapfolderinfo.h"
       
    19 #include "imappaniccodes.h"
       
    20 
       
    21 _LIT8(KTxtExamineFormat, "%d EXAMINE %S\r\n");
       
    22 const TInt KExamineFormatEscapeCharCount = 4; // for "%d" and %S
       
    23 
       
    24 /**
       
    25 The factory constructor. Part of two phased construction.
       
    26 */
       
    27 CImapExamine* CImapExamine::NewL(CImapFolderInfo* aSelectedFolderData, TInt aLogId)
       
    28 	{
       
    29 	CImapExamine* self = new(ELeave) CImapExamine(aSelectedFolderData, aLogId);
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL();
       
    32 	CleanupStack::Pop(self);
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 /**
       
    37 Second phase constructor.
       
    38 Calling the base class ConstructL().
       
    39 */
       
    40 void CImapExamine::ConstructL()
       
    41 	{
       
    42 	CImapSelect::ConstructL();
       
    43 	}
       
    44 
       
    45 /**
       
    46 Constructor.
       
    47 */
       
    48 CImapExamine::CImapExamine(CImapFolderInfo* aSelectedFolderData, TInt aLogId)
       
    49 	: CImapSelect(aSelectedFolderData, aLogId)
       
    50 	{
       
    51 	// Default to "read only"
       
    52 	// This will override the setting made in CImapSelect's constructor.
       
    53 	aSelectedFolderData->SetReadWrite(EFalse);
       
    54 	}
       
    55 	
       
    56 /**
       
    57 Destructor.
       
    58 */
       
    59 CImapExamine::~CImapExamine()
       
    60 	{}
       
    61 	
       
    62 /**
       
    63 Formats and sends the IMAP EXAMINE command.
       
    64 @param aTagId Command sequence id which will be sent along with the IMAP command.
       
    65 @param aStream A wrapper for the outbound stream of a connected socket, using which
       
    66 the command will be send to the server
       
    67 */	
       
    68 void CImapExamine::SendMessageL(TInt aTagId, MOutputStream& aStream)
       
    69 	{
       
    70 	HBufC8* mailbox = EncodeMailboxNameForSendL(iSelectedFolderData->Name());
       
    71 	CleanupStack::PushL(mailbox);
       
    72 	
       
    73 	iTagId = aTagId;
       
    74 	TInt bufferLength = KTxtExamineFormat().Length() - KExamineFormatEscapeCharCount + TagLength(aTagId) + mailbox->Length();
       
    75 	
       
    76 	__ASSERT_DEBUG(iOutputBuffer==NULL, TImapServerPanic::ImapPanic(TImapServerPanic::ECommandOutputBufferNotNull));
       
    77 	iOutputBuffer = HBufC8::NewL(bufferLength);
       
    78 	iOutputBuffer->Des().Format(KTxtExamineFormat, iTagId, mailbox);
       
    79 	
       
    80 	CleanupStack::PopAndDestroy(mailbox);
       
    81 		
       
    82 	// Send the data on the output stream
       
    83 	aStream.SendDataReq(*iOutputBuffer);
       
    84 	}
       
    85 
       
    86