|
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 #ifndef __CIMAPFETCHBODYSTRUCTUREBASE_H__ |
|
17 #define __CIMAPFETCHBODYSTRUCTUREBASE_H__ |
|
18 |
|
19 #include "cimapcommand.h" |
|
20 #include "tmessageflaginfo.h" |
|
21 |
|
22 class CImapFetchResponse; |
|
23 class MOutputStream; |
|
24 class CImapBodyStructureBuilder; |
|
25 class CImapRfc822HeaderFieldsParser; |
|
26 |
|
27 /** |
|
28 @internalTechnology |
|
29 @prototype |
|
30 */ |
|
31 class CImapFetchBodyStructureBase : public CImapCommand |
|
32 { |
|
33 private: |
|
34 enum TState |
|
35 { |
|
36 /** |
|
37 Looking for the next data item(s), in the current line. |
|
38 This state can transition to EStateBodyStructureLiteral or EStateHeaderFieldsLiteral if |
|
39 either of these data items are found, or EStateComplete if no data items are found. |
|
40 */ |
|
41 EStateDataItemLine, |
|
42 /** |
|
43 Waiting for a literal that will be delivered to the body structure parser. |
|
44 This state will ALWAYS transition to EStateBodyStructureLine, so that the parser can |
|
45 search for the closing BODYSTRUCTURE bracket which is always delivered on a line. |
|
46 */ |
|
47 EStateBodyStructureLiteral, |
|
48 /** |
|
49 Waiting for a line that will be delivered to the body structure parser. |
|
50 This state can transition to EStateBodyStructureLiteral or EStateDataItemLine |
|
51 depending on whether the parser requests more data (which will be literal). |
|
52 */ |
|
53 EStateBodyStructureLine, |
|
54 /** |
|
55 Waiting for a literal that will be delivered to the header fields parser. |
|
56 This state will ALWAYS transition to EStateRequestDataItemLine, as header fields are always |
|
57 delivered as a block of literal data followed by a return to the data items line. |
|
58 */ |
|
59 EStateHeaderFieldsLiteral, |
|
60 /** |
|
61 This state occurs after EStateHeaderFieldsLiteral. It means that a data item line |
|
62 is expected, but it has yet to be fetched from the input stream. |
|
63 This differs to EStateDataItemLine, which means that the current block of data |
|
64 still has data items in it. |
|
65 */ |
|
66 EStateFetchNextDataItemLine, |
|
67 /** |
|
68 Either all data has been parsed, or the data was not recognised. |
|
69 */ |
|
70 EStateComplete, |
|
71 }; |
|
72 |
|
73 public: |
|
74 ~CImapFetchBodyStructureBase(); |
|
75 |
|
76 protected: |
|
77 CImapFetchBodyStructureBase(CImapFolderInfo* aSelectedFolderInfo, TInt aLogId, const TDesC8& aHeaderFields); |
|
78 |
|
79 // From CImapCommand |
|
80 TParseBlockResult DoParseBlockL(const TDesC8& aData); |
|
81 |
|
82 TBool UidDataItemFoundInResponse(); |
|
83 |
|
84 private: |
|
85 // From CImapCommand |
|
86 void SendMessageL(TInt aTagId, MOutputStream& aStream); |
|
87 |
|
88 TParseBlockResult ProcessStartL(); |
|
89 TParseBlockResult ProcessDataItemsL(); |
|
90 void ProcessFlagsL(); |
|
91 void ProcessUidL(); |
|
92 void ProcessBodyStructureL(); |
|
93 void ProcessBodyStructureL(const TDesC8& aData); |
|
94 void ProcessHeaderFieldsL(); |
|
95 void ProcessHeaderFieldsL(const TDesC8& aData); |
|
96 TBool GetAndStoreNextPart(); |
|
97 |
|
98 protected: |
|
99 const TDesC8* iSequenceSet; |
|
100 CImapFetchResponse* iFetchResponse; |
|
101 |
|
102 private: |
|
103 /** |
|
104 Whether the UID data item was found in the untagged response. |
|
105 If the UID data item was NOT found then the response is an unsolicited FETCH response caused |
|
106 by a server event (e.g. a user deleting some messages from some other client such as a PC), |
|
107 rather than a direct response to our UID FETCH command - which would have included the UID DATA item. |
|
108 |
|
109 Non-UID FETCH responses should not be returned as the result of a FetchBodystructure request. |
|
110 */ |
|
111 TBool iUidDataItemFoundInResponse; |
|
112 /** |
|
113 Stores the result of parsing the FLAGS data item and the UID data item. |
|
114 If both UID and FLAGS data items are included in the response, then the data in this |
|
115 object will be copied to the equivalent object in iFetchResponse. |
|
116 If only the FLAGS data item included in the response, then this is an unsolicited FETCH response |
|
117 and the data is discarded (so as not to corrupt the data in iFetchResponse) |
|
118 */ |
|
119 TMessageFlagInfo iMessageFlagInfo; |
|
120 TPtrC8 iCurrentPart; |
|
121 const TDesC8& iHeaderFields; |
|
122 TState iState; |
|
123 CImapBodyStructureBuilder* iBodyStructureBuilder; |
|
124 CImapRfc822HeaderFieldsParser* iHeaderFieldsParser; |
|
125 }; |
|
126 |
|
127 #endif // __CIMAPFETCHBODYSTRUCTUREBASE_H__ |