80
|
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 __CIMAPOPFETCHBODY_H__
|
|
17 |
#define __CIMAPOPFETCHBODY_H__
|
|
18 |
|
|
19 |
#include <e32std.h>
|
|
20 |
#include <msvstd.h>
|
|
21 |
#include "cimapoperation.h"
|
|
22 |
#include "cimapbodystructure.h" // for RAttributeValuePairList
|
|
23 |
#include "cimapenvelope.h" // for RArrayTAddress
|
|
24 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
25 |
#include <miuthdr.h>
|
|
26 |
#include <miutconv.h>
|
|
27 |
#endif
|
|
28 |
|
|
29 |
class CImapSession;
|
|
30 |
class CImapFolder;
|
|
31 |
class CMsgActive;
|
|
32 |
class CMsvServerEntry;
|
|
33 |
class TImImap4GetPartialMailInfo;
|
|
34 |
class CImapSettings;
|
|
35 |
class CImConvertHeader;
|
|
36 |
class CImapFetchResponse;
|
|
37 |
class CImapFetchBodyResponse;
|
|
38 |
class CImapRfc822HeaderFields;
|
|
39 |
class CFetchBodyInfo;
|
|
40 |
class CImapUtils;
|
|
41 |
class CCnvCharacterSetConverter;
|
|
42 |
class CImConvertCharconv;
|
|
43 |
class CImConvertHeader;
|
|
44 |
class CImCaf;
|
|
45 |
class CImapMailStore;
|
|
46 |
class CImapSyncManager;
|
|
47 |
|
|
48 |
|
|
49 |
/**
|
|
50 |
The CImapOpFetchBody class encapsulates fetching of body data from the remote
|
|
51 |
server to the local mirror. It is used when performing requested copy/move to
|
|
52 |
local or populate operations.
|
|
53 |
|
|
54 |
It is responsible for building the structure of the message in the messaging
|
|
55 |
store, according to the BODYSTRUCTURE returned by the remote server. The
|
|
56 |
BODYSTRUCTURE is requested, along with other message header parts, when first
|
|
57 |
populating a message.
|
|
58 |
|
|
59 |
From this structure (or during the construction of it), this class also
|
|
60 |
determines which parts of the message are to be fetched according to account
|
|
61 |
settings, or in the case of populate operations, the passed parameters.
|
|
62 |
|
|
63 |
For each body part to be fetched, a CFetchBodyInfo object is constructed and
|
|
64 |
populated with the information required by the CImapSession and CImapMailStore
|
|
65 |
to fetch and store the body part in the local mailstore. Once parsing of the
|
|
66 |
bodystructure is complete, each part is fetched in turn via the CImapSession.
|
|
67 |
|
|
68 |
Once a part has been fetched, this class is responsible for updating the
|
|
69 |
appropriate message flags indicating local message completeness.
|
|
70 |
|
|
71 |
@internalTechnology
|
|
72 |
@prototype
|
|
73 |
*/
|
|
74 |
class CImapOpFetchBody : public CImapOperation
|
|
75 |
{
|
|
76 |
public:
|
|
77 |
typedef RArray<TPtrC8> RArrayTPtrC8;
|
|
78 |
|
|
79 |
virtual ~CImapOpFetchBody();
|
|
80 |
|
|
81 |
static CImapOpFetchBody* NewL(CImapSession*& aSession, CImapSyncManager& aSyncManager, CMsvServerEntry& aEntry, CImapSettings& aImapSettings, CImapMailStore& aMailStore);
|
|
82 |
void FetchBodyL(TRequestStatus& aRequestStatus, const TMsvId aPart, const TImImap4GetPartialMailInfo& aGetPartialMailInfo);
|
|
83 |
void Progress(TImap4GenericProgress& aGenericProgress);
|
|
84 |
void CancelEnableResume();
|
|
85 |
|
|
86 |
private:
|
|
87 |
CImapOpFetchBody(CImapSession*& aSession, CImapSyncManager& aSyncManager, CMsvServerEntry& aEntry, CImapSettings& aImapSettings, CImapMailStore& aMailStore);
|
|
88 |
void ConstructL();
|
|
89 |
|
|
90 |
// fetch initialisation
|
|
91 |
void DoFetchL();
|
|
92 |
void CheckForPartialPopulate();
|
|
93 |
void FetchLargeHeaderL();
|
|
94 |
|
|
95 |
// methods for constructing an array of items to fetch
|
|
96 |
void DoBuildFetchListL();
|
|
97 |
void AddFetchItemL(CImMimeHeader& aMimeHeader, TMsvEmailEntry& aMessage, TBool aIsText, TInt32 aSizeToFetch);
|
|
98 |
void AddFilterFetchItemL(CImMimeHeader& aMimeHeader, TMsvEmailEntry& aEntry, TImap4GetMailOptions& aPartTypes);
|
|
99 |
void AddFilterFetchItemL(CImMimeHeader& aMimeHeader, TMsvEmailEntry& aEntry, TImImap4GetPartialMailInfo& aGetPartialMailInfo);
|
|
100 |
void BuildFetchListL(TMsvId aPart);
|
|
101 |
void RemoveHtmlPart(TMsvId aPart);
|
|
102 |
|
|
103 |
TInt32 Minimum(TInt32 aThisPartTypeSizeLimit, TInt32 aTotalMailSizeLimit);
|
|
104 |
|
|
105 |
// Requsts a specified item to be fetched.
|
|
106 |
TBool FetchPartL();
|
|
107 |
|
|
108 |
// Registers an application part with the CAF framework
|
|
109 |
void RegisterWithCafL(CFetchBodyInfo& fetchInfo);
|
|
110 |
|
|
111 |
// Header and bodystructure parsing
|
|
112 |
TBool ProcessBodyStructureL();
|
|
113 |
void PopulateImHeaderL(CImapRfc822HeaderFields& aHeaderFields, TMsvEmailEntry& aEntry, CImHeader& imHeader);
|
|
114 |
void BuildTreeL(TMsvId aParent, CImapBodyStructure* aBodyStructure, const TDesC8& aPath, const TMsvId aThisMessage, TInt& aAttachments, TBool& aIsMHTML, TInt& aRelatedAttachments, TBool aIsEmbed = EFalse);
|
|
115 |
void BuildContentEntryL(const TMsvId aParent, CImapBodyStructure* aBodyStructure, const TDesC8& aPath, const TMsvId aThisMessage, TInt& aAttachments, TBool& aIsMHTML, TInt& aRelatedAttachments);
|
|
116 |
void ProcessTextSubtypeL(CImapBodyStructure* aBodyStructure, CImMimeHeader& aMime, TMsvEmailEntry& aMessage, TBool& aIsMHTML);
|
|
117 |
void ProcessParameterListL(const CImapBodyStructure::RAttributeValuePairList& aParamList, CImMimeHeader& aMime, TMsvEmailEntry& aMessage, TFileName& aAttachmentFilename);
|
|
118 |
void ProcessExtendedFieldsL(CImapBodyStructure* aBodyStructure, CImMimeHeader& aMime, TMsvEmailEntry& aMessage, TFileName& aAttachmentFilename);
|
|
119 |
void BuildEmbeddedMessageL(CImapBodyStructure* aBodyStructure, CImMimeHeader& aMime, TMsvEmailEntry& aMessage, const TDesC8& aPath, TInt& aAttachments);
|
|
120 |
void BuildNonMessageEntryL(const TMsvId& aParent, CImMimeHeader& aMime, TMsvEmailEntry& aMessage, TInt& aAttachments, TInt& aRelatedAttachments);
|
|
121 |
|
|
122 |
void ProcessEnvelopeL(CImHeader* aHeader, TMsvEntry& aEntry, CImapEnvelope& aImapEnvelope);
|
|
123 |
void GetDefaultFilenameL(TDes& aName, const TMsvEmailEntry& aMessage, const CImMimeHeader* mime);
|
|
124 |
void ProcessAddressListL(CDesCArray& aWhere, const CImapEnvelope::RArrayTAddress& aAddressArray);
|
|
125 |
void ProcessAddressListL(CDesCArray& aWhere, const TDesC8& aAddresses);
|
|
126 |
TInt FindFilenameL(const CImMimeHeader& aMimeInfo, TPtrC8& aFilename);
|
|
127 |
void FindFilenameDecodeL(const CImMimeHeader& aMimeInfo, TFileName& aFileName);
|
|
128 |
void StripIllegalCharactersFromFileName(TDes16& aName);
|
|
129 |
void CreateAttachmentInfoL(const TMsvEntry& aMsvEmailEntry);
|
|
130 |
|
|
131 |
void StoreHeadersL(CImHeader* aImHeader, CImMimeHeader* aMimeHeader);
|
|
132 |
void UpdateBodyTextRemainingSizeForHtml();
|
|
133 |
|
|
134 |
static TPtrC8 StripAngledBrackets(const TDesC8& aString);
|
|
135 |
|
|
136 |
// Post BodyPart-fetch processing
|
|
137 |
void FetchPartCompleteL();
|
|
138 |
void PropagateCompleteFlagL(TMsvId aId, TBool aDoBodyText, TBool aPartialFetched);
|
|
139 |
|
|
140 |
// Server Error handling
|
|
141 |
TInt ProcessServerError();
|
|
142 |
|
|
143 |
// from CMsgActive
|
|
144 |
virtual void DoRunL();
|
|
145 |
void DoComplete(TInt& aErr);
|
|
146 |
void DoCancel();
|
|
147 |
|
|
148 |
void ClearFetchAttemptedL();
|
|
149 |
|
|
150 |
private:
|
|
151 |
// These steps are those that need to be performed to fetch all, or part of a message.
|
|
152 |
// The iNextStep data member is set when asynchronous calls are made to indicate the
|
|
153 |
// next step that is to be performed on completion of the service request.
|
|
154 |
enum TFetchSteps
|
|
155 |
{
|
|
156 |
EFinished,
|
|
157 |
EGetBodyStructure,
|
|
158 |
EProcessBodyStructure,
|
|
159 |
EBuildFetchList,
|
|
160 |
EFetchFirstPart,
|
|
161 |
EFetchNext
|
|
162 |
};
|
|
163 |
|
|
164 |
// Referenced components
|
|
165 |
CImapSyncManager& iSyncManager;
|
|
166 |
CImapSettings& iImapSettings;
|
|
167 |
CImapMailStore& iMailStore;
|
|
168 |
|
|
169 |
// State Machine Progress:
|
|
170 |
TInt iNextStep;
|
|
171 |
TInt iCurrentStep;
|
|
172 |
|
|
173 |
// Stored fetch parameters.
|
|
174 |
TImImap4GetPartialMailInfo iGetPartialMailInfo;
|
|
175 |
|
|
176 |
// Requested message/message-part information
|
|
177 |
TMsvId iRequestedPart;
|
|
178 |
TUint iMessageUid;
|
|
179 |
TMsvId iMessageMsvId;
|
|
180 |
|
|
181 |
// Header/bodystructure fetch response
|
|
182 |
CImapFetchResponse* iFetchResponse;
|
|
183 |
|
|
184 |
// Fetch body response information
|
|
185 |
CImapFetchBodyResponse* iFetchBodyResponse;
|
|
186 |
|
|
187 |
// Array of items to be fetched
|
|
188 |
RPointerArray<CFetchBodyInfo> iFetchList;
|
|
189 |
|
|
190 |
// Stats
|
|
191 |
TInt iPartsToDo;
|
|
192 |
TInt iPartsDone;
|
|
193 |
TInt iBytesToDo;
|
|
194 |
TInt iBytesDone;
|
|
195 |
TBool iHasTextParts;
|
|
196 |
|
|
197 |
// used for calculating parts to fetch when limits are being used
|
|
198 |
TInt32 iBodyTextSize;
|
|
199 |
TInt32 iHtmlEntrySize;
|
|
200 |
TInt32 iSizeOfToBeFetchedAttachments;
|
|
201 |
TInt32 iBodyPartRemainingSize;
|
|
202 |
TMsvId iHtmlEntryPart;
|
|
203 |
|
|
204 |
// things to spot when processing the bodystructure
|
|
205 |
TBool iFetchPartialMail;
|
|
206 |
TBool iIsVCalendar;
|
|
207 |
TBool iIsICalendar;
|
|
208 |
TInt iDecodedSizeOfAllParts;
|
|
209 |
TFileName iAttachmentName;
|
|
210 |
|
|
211 |
// converter objects
|
|
212 |
CCnvCharacterSetConverter* iCharacterConverter;
|
|
213 |
CImConvertCharconv* iCharConv;
|
|
214 |
CImConvertHeader* iHeaderConverter;
|
|
215 |
|
|
216 |
// CAF support
|
|
217 |
CImCaf* iCaf;
|
|
218 |
|
|
219 |
TBool iEmbed;
|
|
220 |
};
|
|
221 |
|
|
222 |
#endif //__CIMAPOPFETCHBODY_H__
|