|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CLocalDocument |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __LOCALDOCUMENT__ |
|
22 #define __LOCALDOCUMENT__ |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "XdmDocument.h" |
|
26 |
|
27 _LIT( KTimeStampFileExt, ".tmsp"); |
|
28 _LIT( KDateFormat, "%1-%2-%3"); |
|
29 _LIT( KTimeFormat, "%H:%T:%S"); |
|
30 const TInt KDateTimeMaxSize = 200; |
|
31 const TInt KDateBufferMaxSize = 50; |
|
32 |
|
33 //FORWARD DECLARATIONS |
|
34 class CXdmNamespace; |
|
35 class MXdmOperation; |
|
36 class CLocalProtocol; |
|
37 class CLocalDocumentNode; |
|
38 class CXdmOperationFactory; |
|
39 |
|
40 //CLASS DECLARATION |
|
41 class CLocalDocument : public CXdmDocument |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Symbian OS default constructor. |
|
47 * @param TInt Default Access Point ID |
|
48 * @return CXdmDocOperation* |
|
49 */ |
|
50 static CLocalDocument* NewL( CXdmEngine& aXdmEngine, |
|
51 const TDesC& aDocumentName, |
|
52 CLocalProtocol& aLocalProtocol ); |
|
53 |
|
54 /** |
|
55 * Symbian OS default constructor. |
|
56 * @param TInt Default Access Point ID |
|
57 * @return CXdmDocOperation* |
|
58 */ |
|
59 //static CLocalDocument* NewL( const TDesC8& aDocumentName ); |
|
60 |
|
61 /** |
|
62 * Symbian OS default constructor. |
|
63 * @param TInt Default Access Point ID |
|
64 * @return CXdmDocOperation* |
|
65 */ |
|
66 void StartInternalL( TRequestStatus& aStatus ); |
|
67 |
|
68 /** |
|
69 * Symbian OS default constructor. |
|
70 * @param TInt Default Access Point ID |
|
71 * @return CXdmDocOperation* |
|
72 */ |
|
73 void CancelUpdate(); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CLocalDocument(); |
|
79 |
|
80 public: //Exported methods |
|
81 |
|
82 /** |
|
83 * Symbian OS default constructor. |
|
84 * @param TInt Default Access Point ID |
|
85 * @return CXdmDocOperation* |
|
86 */ |
|
87 IMPORT_C CLocalDocument* TempCopyL(); |
|
88 |
|
89 /** |
|
90 * Symbian OS default constructor. |
|
91 * @param TInt Default Access Point ID |
|
92 * @return CXdmDocOperation* |
|
93 */ |
|
94 IMPORT_C TPtrC XmlFilePath() const; |
|
95 |
|
96 /** |
|
97 * Symbian OS default constructor. |
|
98 * @param TInt Default Access Point ID |
|
99 * @return CXdmDocOperation* |
|
100 */ |
|
101 IMPORT_C TBool IsSubset() const; |
|
102 |
|
103 /** |
|
104 * Symbian OS default constructor. |
|
105 * @param TInt Default Access Point ID |
|
106 * @return CXdmDocOperation* |
|
107 */ |
|
108 IMPORT_C virtual void ResetSubset(); |
|
109 |
|
110 /** |
|
111 * Symbian OS default constructor. |
|
112 * @param TInt Default Access Point ID |
|
113 * @return CXdmDocOperation* |
|
114 */ |
|
115 IMPORT_C void RemoveData( CLocalDocumentNode* aDocumentNode ); |
|
116 |
|
117 public: //From CXdmDocument |
|
118 |
|
119 /** |
|
120 * Return the root element of this document |
|
121 * |
|
122 * @return CXdmDocumentNode The root element of the document |
|
123 * |
|
124 * NOTE: The returning node may or may not contain any data, |
|
125 * since, in the case that this document model does not |
|
126 * have content yet, the element is a simple "entry point" |
|
127 * to the whole document. Thus, for instance, if the client |
|
128 * application requests the Xdm Engine to fetch a particular |
|
129 * document, the root element points to nothing until the |
|
130 * request has been completed. |
|
131 * |
|
132 */ |
|
133 CXdmDocumentNode* DocumentRoot() const; |
|
134 |
|
135 private: //From CXdmDocument |
|
136 |
|
137 /** |
|
138 * Construct an "anonymous" entry point for this document. |
|
139 * This node effectively becomes the root of this document. |
|
140 * |
|
141 */ |
|
142 CXdmDocumentNode* CreateRootL(); |
|
143 |
|
144 /* |
|
145 * Reset the contents of this document model. |
|
146 */ |
|
147 void ResetContents(); |
|
148 |
|
149 /** |
|
150 * Return the time stamp for this document |
|
151 * |
|
152 * @return TTime |
|
153 */ |
|
154 TTime TimeStamp() const; |
|
155 |
|
156 /** |
|
157 * Return an error document for a failed update |
|
158 * |
|
159 * NOTE: Error document is not supported in this |
|
160 * protocol. The returning pointer will be NULL. |
|
161 * |
|
162 * @return CXdmDocument* The error document |
|
163 */ |
|
164 CXdmDocumentNode* ErrorRoot(); |
|
165 |
|
166 /** |
|
167 * Append an element to the path identifying the |
|
168 * the current document subset |
|
169 * @return void |
|
170 */ |
|
171 void AppendPathPartL( const TDesC& aString ); |
|
172 |
|
173 /** |
|
174 * Return the current document subset (including descendants) |
|
175 * @return void |
|
176 */ |
|
177 CXdmDocumentNode* CurrentExtent() const; |
|
178 |
|
179 /** |
|
180 * Construct an "anonymous" entry point for this document. |
|
181 * This node effectively becomes the root of this document. |
|
182 */ |
|
183 TXdmDocType DocumentType() const; |
|
184 |
|
185 private: //From MXdmNamespaceContainer |
|
186 |
|
187 /** |
|
188 * Return the number of namespace declarations |
|
189 * @return TInt Namespace declaration count |
|
190 */ |
|
191 TInt Count() const; |
|
192 |
|
193 /** |
|
194 * Copies the request data |
|
195 * @param aRequestData Data to be sent |
|
196 */ |
|
197 void AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix ); |
|
198 |
|
199 /** |
|
200 * Remove a namespace from the document |
|
201 * @param TDesC8& URI of the namespace |
|
202 * @param TDesC8& Prefix of the namespace |
|
203 */ |
|
204 void RemoveNamespace( const TDesC8& aUri ); |
|
205 |
|
206 /** |
|
207 * Copies the request data |
|
208 * @param aRequestData Data to be sent |
|
209 */ |
|
210 TPtrC8 Uri( const TDesC8& aPrefix ) const; |
|
211 |
|
212 /** |
|
213 * Fetch the aIndex-th URI |
|
214 * @param TInt The index of the desired URI string |
|
215 * @return TPtrC URI string |
|
216 */ |
|
217 TPtrC8 Uri( TInt aIndex ) const; |
|
218 |
|
219 /** |
|
220 * Fetch the aIndex-th prefix |
|
221 * @param TDesC8 The index of the desired prefix string |
|
222 * @return TPtrC Prefix string |
|
223 */ |
|
224 TPtrC8 Prefix( TInt aIndex ) const; |
|
225 |
|
226 /** |
|
227 * Resets namespaces from the document |
|
228 */ |
|
229 void ResetNamespaces( ); |
|
230 |
|
231 private: |
|
232 |
|
233 /** |
|
234 * Symbian OS default constructor. |
|
235 * @param TInt Default Access Point ID |
|
236 * @return CXdmDocOperation* |
|
237 */ |
|
238 CLocalDocument( CXdmEngine& aXdmEngine, |
|
239 CLocalProtocol& aLocalProtocol ); |
|
240 |
|
241 /** |
|
242 * From CActive. |
|
243 * @return void |
|
244 */ |
|
245 void RunL(); |
|
246 |
|
247 /** |
|
248 * From CActive. |
|
249 * @return void |
|
250 */ |
|
251 void DoCancel(); |
|
252 |
|
253 /** |
|
254 * From CActive. |
|
255 * @return void |
|
256 */ |
|
257 void FinaliseOperation( TInt aIndex ); |
|
258 |
|
259 /** |
|
260 * Symbian OS default constructor. |
|
261 * @param TInt Default Access Point ID |
|
262 * @return CXdmDocOperation* |
|
263 */ |
|
264 void StartUpdateL(); |
|
265 |
|
266 /** |
|
267 * Symbian OS default constructor. |
|
268 * @param TInt Default Access Point ID |
|
269 * @return CXdmDocOperation* |
|
270 */ |
|
271 void SaveClientStatus( TRequestStatus& aStatus ); |
|
272 |
|
273 /** |
|
274 * _DEBUG |
|
275 */ |
|
276 void DumpResponseBodyL( const TDesC8& aResponseBody ) const; |
|
277 |
|
278 /** |
|
279 * Symbian OS default constructor. |
|
280 * @param TInt Default Access Point ID |
|
281 * @return CXdmDocOperation* |
|
282 */ |
|
283 void ConstructL(); |
|
284 |
|
285 /** |
|
286 * Symbian OS default constructor. |
|
287 * @param TInt Default Access Point ID |
|
288 * @return CXdmDocOperation* |
|
289 */ |
|
290 void ConstructL( const TDesC8& aDocumentName ); |
|
291 |
|
292 /** |
|
293 * Symbian OS default constructor. |
|
294 * @param TInt Default Access Point ID |
|
295 * @return CXdmDocOperation* |
|
296 */ |
|
297 void FetchTimeStampL(); |
|
298 |
|
299 private: //Data |
|
300 |
|
301 enum TLocalOperation |
|
302 { |
|
303 EFetch = 0, |
|
304 EReplace, |
|
305 EInsert, |
|
306 EFetchPartial, |
|
307 EInsertPartial, |
|
308 EReplacePartial, |
|
309 }; |
|
310 |
|
311 enum TLocalDocumentState |
|
312 { |
|
313 EXdmDocIdle = 0, |
|
314 EXdmDocUpdating, |
|
315 EResolvingAsyncConflict, |
|
316 }; |
|
317 |
|
318 TInt iDataLength; |
|
319 TInt iUpdateIndex; |
|
320 TInt iOperationCount; |
|
321 TInt iOperationError; |
|
322 TTime iLastAccess; |
|
323 TTime iLastModification; |
|
324 TBool iWholeDoc; |
|
325 HBufC* iFullPath; |
|
326 HBufC* iDocSubsetPath; |
|
327 TLocalOperation iOperationType; |
|
328 CLocalProtocol& iLocalProtocol; |
|
329 CLocalDocumentNode* iDocumentRoot; |
|
330 TLocalDocumentState iDocumentState; |
|
331 RPointerArray<CXdmNamespace> iNamespaces; |
|
332 }; |
|
333 |
|
334 #endif //__XCAPDOCUMENT__ |
|
335 |
|
336 // End of File |