|
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 "cimapcreate.h" |
|
17 #include "moutputstream.h" |
|
18 #include "cimapsessionconsts.h" |
|
19 #include "imappaniccodes.h" |
|
20 |
|
21 // IMAP CREATE command |
|
22 _LIT8(KCommandCreate, "%d CREATE %S\r\n"); |
|
23 |
|
24 CImapCreate* CImapCreate::NewL(CImapFolderInfo* aSelectedFolderData, TInt aLogId, const TDesC& aMailboxName) |
|
25 // static method first phase construction |
|
26 { |
|
27 CImapCreate* self = new (ELeave) CImapCreate(aSelectedFolderData, aLogId); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(aMailboxName); |
|
30 CleanupStack::Pop(); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CImapCreate::CImapCreate(CImapFolderInfo* aSelectedFolderData, TInt aLogId) |
|
35 : CImapCommandEx(aSelectedFolderData, aLogId) |
|
36 { |
|
37 } |
|
38 |
|
39 void CImapCreate::ConstructL(const TDesC& aMailboxName) |
|
40 { |
|
41 iMailboxName = EncodeMailboxNameForSendL(aMailboxName); |
|
42 } |
|
43 |
|
44 CImapCreate::~CImapCreate() |
|
45 { |
|
46 delete iMailboxName; |
|
47 } |
|
48 |
|
49 /** |
|
50 Formats and sends the IMAP CREATE command. |
|
51 @param aTagId Command sequence id which will be send along with the IMAP command. |
|
52 @param aStream A wrapper for the outbound stream of a connected socket, using which |
|
53 the command will be send to the server |
|
54 */ |
|
55 void CImapCreate::SendMessageL(TInt aTagId, MOutputStream& aStream) |
|
56 { |
|
57 iTagId = aTagId; |
|
58 |
|
59 TInt bufLength = KCommandCreate().Length(); |
|
60 bufLength += iMailboxName->Length(); |
|
61 bufLength += TagLength(aTagId); |
|
62 |
|
63 __ASSERT_DEBUG(iOutputBuffer==NULL, TImapServerPanic::ImapPanic(TImapServerPanic::ECommandOutputBufferNotNull)); |
|
64 iOutputBuffer = HBufC8::NewL(bufLength); |
|
65 iOutputBuffer->Des().Format(KCommandCreate, aTagId, iMailboxName); |
|
66 |
|
67 //send the command to the server |
|
68 aStream.SendDataReq(*iOutputBuffer); |
|
69 } |