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