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