1 /* |
|
2 * Copyright (c) 2002-2004 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: WebDAV PropFind method response body parser |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CRSFWPROPFINDPARSER_H |
|
20 #define CRSFWPROPFINDPARSER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <xml/contenthandler.h> |
|
24 #include <xml/attribute.h> // needed for RAttributeArray |
|
25 |
|
26 #include "rsfwdavfileinfo.h" |
|
27 #include "rsfwdirent.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KMaxNameSpaces = 10; |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CRsfwDirEnt; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 /** |
|
37 * WebDAV Lock operation response body parser. |
|
38 * Parses directory listing from WebDAV-server, which we got |
|
39 * as XML-body response to PROPFIND-query. |
|
40 * |
|
41 * FOR METADATA: |
|
42 * This comes from upper lever and are used to store relevant metadata |
|
43 * from directory listing. |
|
44 * Currently we want to extract the following to the entry |
|
45 * displayname |
|
46 * <creationdate>2002-12-19T13:51:16Z</creationdate> |
|
47 * <getlastmodified>Thu, 19 Dec 2002 13:51:16 GMT</getlastmodified> |
|
48 * <getcontentlength>2324</getcontentlength>; |
|
49 * |
|
50 * FOR CACHE CONCISTENCY: |
|
51 * We need to remember the ETag of searched directory |
|
52 * |
|
53 * @lib davaccess.lib |
|
54 * @since Series 60 3.1 |
|
55 */ |
|
56 |
|
57 class CRsfwPropFindParser : public CBase, public Xml::MContentHandler |
|
58 { |
|
59 // EName = parsing is inside <displayname> </displayname> etc., |
|
60 // ELooking = parsing is outside all tags of interest |
|
61 enum TState |
|
62 { |
|
63 EName, |
|
64 EResponse, |
|
65 ENameInDisplayName, |
|
66 EDate, |
|
67 EModified, |
|
68 ELength, |
|
69 EResourceType, |
|
70 EContentType, |
|
71 EETag, |
|
72 ELooking |
|
73 }; |
|
74 |
|
75 public: // Constructors and destructor |
|
76 /** |
|
77 * Two-phased constructor. |
|
78 */ |
|
79 static CRsfwPropFindParser* NewL(); |
|
80 static CRsfwPropFindParser* NewLC(); |
|
81 |
|
82 /** |
|
83 * Destructor. |
|
84 */ |
|
85 virtual ~CRsfwPropFindParser(); |
|
86 |
|
87 public: // Functions from base classes |
|
88 // Symbian parser |
|
89 // From XML::MContentHandler |
|
90 void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, |
|
91 TInt aErrorCode); |
|
92 void OnEndDocumentL(TInt aErrorCode); |
|
93 void OnStartElementL(const Xml::RTagInfo& aElement, |
|
94 const Xml::RAttributeArray& aAttributes, |
|
95 TInt aErrorCode); |
|
96 void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); |
|
97 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
98 void OnStartPrefixMappingL(const RString& aPrefix, |
|
99 const RString& aUri, |
|
100 TInt aErrorCode); |
|
101 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
102 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
103 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
104 void OnProcessingInstructionL(const TDesC8& aTarget, |
|
105 const TDesC8& aData, |
|
106 TInt aErrorCode); |
|
107 void OnError(TInt aErrorCode); |
|
108 TAny* GetExtendedInterface(const TInt32 aUid); |
|
109 |
|
110 public: // New functions |
|
111 // setters for the parser |
|
112 /** |
|
113 Set directory entry to be filled |
|
114 @param aDirEntArray directory entry array |
|
115 */ |
|
116 void SetDirEntArray(RPointerArray<CRsfwDirEnt>* aDirEntArray); |
|
117 |
|
118 /** |
|
119 Set target directory |
|
120 @param aPropFindPath Propfind resource path |
|
121 @param aDepth Propfind depth |
|
122 */ |
|
123 void SetTargetDirectory(const TDesC& aPropFindPath, TInt aDepth); |
|
124 |
|
125 /** |
|
126 Returns the error code if there was an error during parsing of |
|
127 the response. |
|
128 */ |
|
129 TInt GetLastError(); |
|
130 |
|
131 |
|
132 private: |
|
133 void ConstructL(); |
|
134 void ClearDirEntryL(); |
|
135 HBufC* DecodeL(const TDesC8& aData); |
|
136 |
|
137 private: // Data |
|
138 // Internal variables |
|
139 RPointerArray<CRsfwDirEnt>* iDirEntArray; // not owned by us |
|
140 const TDesC* iPropFindPath; // path |
|
141 HBufC8* iContentString; |
|
142 TInt iDepth; |
|
143 CRsfwDirEnt* iDirEntry; // metadata entry currently read |
|
144 TState iParseState; // internal state |
|
145 TBool iCurrentIsParent; |
|
146 TInt iError; // indicates a processing error |
|
147 }; |
|
148 |
|
149 #endif // CRSFWPROPFINDPARSER_H |
|
150 |
|
151 // End of File |
|