|
1 // Copyright (c) 1999-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 #if !defined (__MIUTRSLV_H__) |
|
17 #define __MIUTRSLV_H__ |
|
18 |
|
19 #include <mentact.h> |
|
20 #include <msvstd.h> |
|
21 #include <msvapi.h> |
|
22 #include "MIUTHDR.H" |
|
23 |
|
24 class CImMhtmlUri : public CBase |
|
25 /** |
|
26 @internalComponent |
|
27 @released |
|
28 */ |
|
29 { |
|
30 public: |
|
31 static CImMhtmlUri* NewL(const TDesC& aUriText); |
|
32 static CImMhtmlUri* NewLC(const TDesC& aUriText); |
|
33 |
|
34 void MakeAbsoluteL(const CImMhtmlUri& aBaseUri); |
|
35 |
|
36 HBufC* TextL(TBool aIncludeScheme); |
|
37 |
|
38 TBool IsAbsolute() const; |
|
39 |
|
40 TBool CompareScheme(const TDesC& aScheme) const; |
|
41 |
|
42 HBufC* OriginalUriText(); |
|
43 |
|
44 ~CImMhtmlUri(); |
|
45 |
|
46 private: |
|
47 void ConstructL(const TDesC& aUriText); |
|
48 CImMhtmlUri(); |
|
49 inline void ParseL(); |
|
50 inline void Normalise(); |
|
51 |
|
52 enum TImUriDelimiterType |
|
53 { |
|
54 EImUriNotDelimiter, |
|
55 EImUriScheme, |
|
56 EImUriNetLoc, |
|
57 EImUriPath, |
|
58 EImUriParameter, |
|
59 EImUriQuery, |
|
60 EImUriFragment, |
|
61 EImUriEnd |
|
62 }; |
|
63 |
|
64 inline TImUriDelimiterType Delimiter(TInt& aIndex); |
|
65 void ChangeState(TImUriDelimiterType aDelimiterType); |
|
66 |
|
67 private: |
|
68 enum TImUriParseState |
|
69 { |
|
70 EParsingFirstString, |
|
71 EParsingScheme, |
|
72 EParsingNetLoc, |
|
73 EParsingPath, |
|
74 EParsingParameter, |
|
75 EParsingQuery, |
|
76 EParsingFragment, |
|
77 }; |
|
78 |
|
79 HBufC* iUriText; |
|
80 HBufC* iScheme; |
|
81 HBufC* iNetLoc; |
|
82 CDesCArray* iDirectoryPath; |
|
83 TBool iAbsolutePath; |
|
84 TBool iContainsFileName; |
|
85 HBufC* iParameters; |
|
86 HBufC* iQuery; |
|
87 HBufC* iFragment; |
|
88 |
|
89 TImUriParseState iState; |
|
90 }; |
|
91 |
|
92 /** |
|
93 This class holds URI Content_Location, Content_Id and corresponding Linked entry. These entries will be cached in an array, defined in the class CImMhtmlUriResolver. |
|
94 @internalComponent |
|
95 @released |
|
96 */ |
|
97 NONSHARABLE_CLASS(CImCacheUriEntry) : public CBase |
|
98 { |
|
99 public: |
|
100 static CImCacheUriEntry* NewL(const TDesC& aContentLocation, const TDesC& aContentId, TMsvId aEntry); |
|
101 ~CImCacheUriEntry(); |
|
102 |
|
103 HBufC* GetContentLocation(); |
|
104 HBufC* GetContentId(); |
|
105 TMsvId GetUriEntry(); |
|
106 |
|
107 private: |
|
108 void ConstructL(const TDesC& aContentLocation, const TDesC& aContentId, TMsvId aEntry); |
|
109 CImCacheUriEntry(); |
|
110 private: |
|
111 TMsvId iUriEntry; |
|
112 HBufC* iContentLocation; |
|
113 HBufC* iContentId; |
|
114 }; |
|
115 |
|
116 class CImMhtmlChildEntrySearcher : public CMsgActive |
|
117 /** |
|
118 @internalComponent |
|
119 @released |
|
120 */ |
|
121 { |
|
122 public: |
|
123 static CImMhtmlChildEntrySearcher* NewL(CMsvEntry& aEntry, RPointerArray<CImCacheUriEntry>& aUriCacheArray); |
|
124 |
|
125 void StartL(TMsvId aEntry, TDesC& aUri, TRequestStatus& aStatus); |
|
126 TBool SearchResult(TMsvId& aSearchResultEntry); |
|
127 TInt CheckCacheForEntryId(TMsvId aId); |
|
128 ~CImMhtmlChildEntrySearcher(); |
|
129 |
|
130 private: |
|
131 void DoRunL(); |
|
132 void DoComplete(TInt& ); |
|
133 |
|
134 void CheckCurrentEntryL(); |
|
135 inline TBool CheckContentDetailsL(const TDesC& aContentLocation, const TDesC& aContentId); |
|
136 |
|
137 CImMhtmlChildEntrySearcher(CMsvEntry &aEntry, RPointerArray<CImCacheUriEntry>& aUriCacheArray); |
|
138 |
|
139 private: |
|
140 CMsvEntry& iEntry; |
|
141 HBufC* iUri; |
|
142 CMsvEntrySelection* iChildEntries; |
|
143 TMsvId iChildEntryIndex; |
|
144 TBool iFound; |
|
145 RPointerArray<CImCacheUriEntry>& iUriCacheArray; |
|
146 }; |
|
147 |
|
148 |
|
149 |
|
150 class CImMhtmlFileFinder : public CMsgActive |
|
151 /** |
|
152 @internalComponent |
|
153 @released |
|
154 */ |
|
155 { |
|
156 public: |
|
157 static CImMhtmlFileFinder* NewL(CMsvEntry &aEntry, RPointerArray<CImCacheUriEntry>& aUriCacheArray); |
|
158 |
|
159 void FindL(const TDesC& aUri, TMsvId aBodyPartId,TBool aFileNameOnly, TRequestStatus &aStatus); |
|
160 TBool MatchFound() const; |
|
161 void Result(RFile& aFile, TMsvId& aEntryId) const; |
|
162 void Result(TFileName& aFileName, TMsvId& aEntryId) const; |
|
163 ~CImMhtmlFileFinder(); |
|
164 |
|
165 private: |
|
166 void DoFindL(); |
|
167 void DoCancel(); |
|
168 void ConstructL(RPointerArray<CImCacheUriEntry>& aUriCacheArray); |
|
169 |
|
170 void DoRunL(); |
|
171 void DoComplete(TInt& ); |
|
172 |
|
173 CImMhtmlFileFinder(CMsvEntry &aEntry); |
|
174 |
|
175 private: |
|
176 CMsvEntry& iCurrentEntry; |
|
177 TMsvId iCurrentBodyPartId; |
|
178 HBufC* iUri; |
|
179 TBool iMatchFound; |
|
180 CImMhtmlChildEntrySearcher* iChildEntrySearcher; |
|
181 TFileName iFileName; |
|
182 TMsvId iLinkedEntryId; |
|
183 mutable RFile iFile; |
|
184 TBool iFileNameOnly; |
|
185 }; |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 class CImMhtmlFirstPageFinder : public CMsgActive |
|
192 /** |
|
193 @internalComponent |
|
194 @released |
|
195 */ |
|
196 { |
|
197 public: |
|
198 static CImMhtmlFirstPageFinder* NewL(CMsvEntry& aEntry); |
|
199 void Result(RFile& aFile, TMsvId& aEntryId) const; |
|
200 void Result(TFileName& aFileName, TMsvId& aEntryId) const; |
|
201 |
|
202 ~CImMhtmlFirstPageFinder(); |
|
203 void FindL(TMsvId aRootMessage,TBool aFileNameOnly, TRequestStatus& aStatus); |
|
204 |
|
205 private: |
|
206 CImMhtmlFirstPageFinder(CMsvEntry& aEntry); |
|
207 void DoFindL(); |
|
208 |
|
209 void ConstructL(); |
|
210 |
|
211 void DoRunL(); |
|
212 void DoComplete(TInt& ); |
|
213 inline void SetStartParameterL(); |
|
214 private: |
|
215 CMsvEntry& iCurrentEntry; |
|
216 CMsvEntrySelection* iEntryStack; |
|
217 TInt iEntryStackIndex; |
|
218 TMsvId iCurrentBodyPartId; |
|
219 |
|
220 TBool iHtmlPartFound; |
|
221 TMsvId iFirstHtmlPartId; |
|
222 TFileName iFileName; |
|
223 |
|
224 TBool iUnrelatedHtmlPartFound; |
|
225 TMsvId iFirstUnrelatedHtmlPartId; |
|
226 |
|
227 HBufC8* iStartParameter; |
|
228 |
|
229 TInt iRelatedDepthCounter; |
|
230 CMsvEntrySelection* iNextUnrelatedEntryStack; |
|
231 mutable RFile iFile; |
|
232 TBool iFileNameOnly; |
|
233 }; |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 class CImMhtmlUriResolver : public CMsgActive |
|
239 /** |
|
240 @internalComponent |
|
241 @released |
|
242 */ |
|
243 { |
|
244 public: |
|
245 static CImMhtmlUriResolver* NewL(CMsvEntry& aEntry); |
|
246 static CImMhtmlUriResolver* NewLC(CMsvEntry& aEntry); |
|
247 |
|
248 void ResolveL(const TDesC& aURI, const TDesC& aHtmlBase, TMsvId aCurrentPartId, TBool aFileNameOnly, TRequestStatus &aStatus); |
|
249 void FindFirstL(TMsvId aRootMessageId, TBool aFileNameOnly,TRequestStatus &aStatus); |
|
250 ~CImMhtmlUriResolver(); |
|
251 HBufC* FileNameL() const; |
|
252 |
|
253 // On return, will have the parameter is set to file handle |
|
254 // and also returns the error code |
|
255 TInt FileHandle(RFile& aFile) const; |
|
256 TMsvId LinkedEntryId() const; |
|
257 TBool CheckCacheForLinkedEntryL(); |
|
258 |
|
259 protected: |
|
260 void ConstructL(); |
|
261 CImMhtmlUriResolver(CMsvEntry& aEntry); |
|
262 |
|
263 private: |
|
264 void ResolveL(const TDesC& aHtmlBase, TMsvId aCurrentPartId); |
|
265 HBufC* GetContentLocationL(TMsvId aEntryId); |
|
266 |
|
267 void DoRunL(); |
|
268 void DoComplete(TInt& ); |
|
269 void DoCancel(); |
|
270 |
|
271 private: |
|
272 enum TImMhtmlUriResolveState |
|
273 { |
|
274 EImResolvingUri, |
|
275 EImTryingWithoutResolve, |
|
276 EImFindingFirstUri, |
|
277 EImFindingFile |
|
278 }; |
|
279 |
|
280 TImMhtmlUriResolveState iState; |
|
281 |
|
282 CMsvEntry& iCurrentEntry; |
|
283 TMsvId iBodyPartId; |
|
284 CImMhtmlUri* iUri; |
|
285 |
|
286 TFileName iFileName; |
|
287 TMsvId iLinkedEntryId; |
|
288 TBool iResolved; |
|
289 |
|
290 TBool iTryingThisMessage; |
|
291 |
|
292 CImMhtmlFileFinder* iMhtmlFileFinder; |
|
293 CImMhtmlFirstPageFinder* iMhtmlFirstPageFinder; |
|
294 mutable RFile iFile; |
|
295 TBool iFileNameOnly; |
|
296 RPointerArray<CImCacheUriEntry> iUriCacheArray; |
|
297 }; |
|
298 |
|
299 #endif |
|
300 |