|
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 |
|
17 #include "cimaplogout.h" |
|
18 |
|
19 #include "moutputstream.h" |
|
20 #include "cimapsessionconsts.h" |
|
21 #include "imappaniccodes.h" |
|
22 |
|
23 _LIT8(KTxtLogoutFormat, "%d LOGOUT\r\n"); |
|
24 const TInt KLogoutFormatEscapeCharCount = 2; // for %d |
|
25 |
|
26 // Construction and Destruction |
|
27 CImapLogout* CImapLogout::NewL(CImapFolderInfo* aSelectedFolderData, TInt aLogId) |
|
28 // static method |
|
29 { |
|
30 CImapLogout* self = new(ELeave)CImapLogout(aSelectedFolderData, aLogId); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CImapLogout::CImapLogout(CImapFolderInfo* aSelectedFolderData, TInt aLogId) |
|
35 : CImapCommandEx(aSelectedFolderData, aLogId) |
|
36 { |
|
37 } |
|
38 |
|
39 CImapLogout::~CImapLogout() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 /** |
|
45 Responsible for sending the IMAP logout command to the remote server. |
|
46 The data will be sent to the remote server on the output stream provided. |
|
47 It is assumed the output stream has already been set up and ready to use. |
|
48 |
|
49 @param aTagId Used to generate the IMAP tag that identifies the message. |
|
50 @param aStream The output stream on which the message will be sent. |
|
51 */ |
|
52 void CImapLogout::SendMessageL(TInt aTagId, MOutputStream& aStream) |
|
53 // Send the line "<tag> LOGOUT" |
|
54 { |
|
55 iTagId = aTagId; |
|
56 TInt bufferLength = KTxtLogoutFormat.iTypeLength - KLogoutFormatEscapeCharCount + TagLength(aTagId); |
|
57 |
|
58 __ASSERT_DEBUG(iOutputBuffer==NULL, TImapServerPanic::ImapPanic(TImapServerPanic::ECommandOutputBufferNotNull)); |
|
59 iOutputBuffer = HBufC8::NewL(bufferLength); |
|
60 iOutputBuffer->Des().Format(KTxtLogoutFormat, iTagId); |
|
61 |
|
62 // Send the data on the output stream |
|
63 aStream.SendDataReq(*iOutputBuffer); |
|
64 } |