|
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: Attribute fetch processor. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPENGFETCHPROCESSOR_H__ |
|
19 #define CPENGFETCHPROCESSOR_H__ |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include <E32base.h> |
|
24 #include <BaDescA.h> |
|
25 #include "MPEngAttrFetchProcessor.h" |
|
26 #include "PEngWVCspVersion.h" |
|
27 |
|
28 |
|
29 |
|
30 //FORWARD DECLARATION |
|
31 class CPEngAttributeTypeStack; |
|
32 class MPEngAdvTransactionStatus2; |
|
33 class MPEngPresenceAttrManager; |
|
34 class MPEngPresenceAttrModel2; |
|
35 class MPEngXMLParser; |
|
36 class MPEngXMLSerializer; |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * Processor to handle presence attribute fetch XML request |
|
45 * generation and response decoding. |
|
46 * |
|
47 * @lib PEngAttrLib |
|
48 * @since 3.0 |
|
49 */ |
|
50 NONSHARABLE_CLASS( CPEngFetchProcessor ) : public CBase, |
|
51 public MPEngAttrFetchProcessor |
|
52 { |
|
53 public: // Constructors and destructor |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * |
|
58 * @param aAttrManager The attribute manger to use in |
|
59 * attribute handling. |
|
60 * @param aFetchedPresenceIds The presence ID's to fetch. |
|
61 * @param aFetchedAttributes The presence attributes to fetch. |
|
62 * @param aDomain The user domain where the fetching happens. |
|
63 * @param aTransactionOperation The transaction operation id. |
|
64 * @param aCspVersion The CSP version for request. |
|
65 */ |
|
66 static CPEngFetchProcessor* NewL( MPEngPresenceAttrManager& aAttrManager, |
|
67 const MDesCArray& aFetchedPresenceIds, |
|
68 const TArray< TUint32 > aFetchedAttributes, |
|
69 const TDesC& aDomain, |
|
70 TInt aTransactionOperation, |
|
71 TPEngWVCspVersion aCspVersion ); |
|
72 |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 virtual ~CPEngFetchProcessor(); |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 private: //Constructors |
|
83 |
|
84 /** |
|
85 * C++ constructor. |
|
86 */ |
|
87 CPEngFetchProcessor( MPEngPresenceAttrManager& aAttrManager, |
|
88 TInt aTransactionOperation, |
|
89 TPEngWVCspVersion aCspVersion ); |
|
90 |
|
91 /** |
|
92 * Symbian 2nd phase constructor. |
|
93 */ |
|
94 void ConstructL( const MDesCArray& aFetchedPresenceIds, |
|
95 const TArray< TUint32 > aFetchedAttributes, |
|
96 const TDesC& aDomain ); |
|
97 |
|
98 |
|
99 |
|
100 public: //From MPEngAttrFetchProcessor |
|
101 |
|
102 |
|
103 /** |
|
104 * @see MPEngAttrFetchProcessor |
|
105 */ |
|
106 void GenerateRequestL( TDes8& aSendBuffer ); |
|
107 |
|
108 |
|
109 /** |
|
110 * @see MPEngAttrFetchProcessor |
|
111 */ |
|
112 void InitResponseProcessingL( const TDesC8& aResponse, |
|
113 RPointerArray< MPEngPresenceAttrModel2 >& aResultModels, |
|
114 MPEngAdvTransactionStatus2& aResultStatus ); |
|
115 |
|
116 /** |
|
117 * @see MPEngAttrFetchProcessor |
|
118 */ |
|
119 TBool ProcessStepL(); |
|
120 |
|
121 |
|
122 |
|
123 private: //Request helpers |
|
124 |
|
125 |
|
126 /** |
|
127 * Request generation helper. |
|
128 * |
|
129 * @since 3.0 |
|
130 * @param aSerializer The serializer to write request. |
|
131 * @param aFetchedPresenceIds List of fetched presence ids. |
|
132 * @param aFechedAttributeTypes Fetched attributes. |
|
133 * @param aCspVersion The CSP version for request. |
|
134 */ |
|
135 static void GenerateRequestL( |
|
136 MPEngXMLSerializer& aSerializer, |
|
137 const CDesC16ArraySeg& aFetchedPresenceIds, |
|
138 const CPEngAttributeTypeStack& aFechedAttributeTypes, |
|
139 TPEngWVCspVersion aCspVersion ); |
|
140 |
|
141 |
|
142 |
|
143 /** |
|
144 * Parsing helper. |
|
145 * |
|
146 * Checks the transaction status from network response |
|
147 * Handles also partial failure, by removing the unknown presence |
|
148 * id's from the list of requested presence ids. In case of complete |
|
149 * failure, adds all requested presence id's as detailed results |
|
150 * to transaction status. |
|
151 * |
|
152 * @since 3.0 |
|
153 * @param aResponse Get presence response to check. |
|
154 * @param aDomain The domain where fetch takes its place. |
|
155 * @param aTransactionOperation The transaction operation id. |
|
156 * @param aParser XML parser to use in parsing. |
|
157 * @param aParsedModels Array where to append the parsed models. |
|
158 * @param aTransactionStatus The transaction status container to fill. |
|
159 * @param aRequestedPresenceIds The list of requested presence IDs. |
|
160 * @return Transaction continue status. ETrue if response should |
|
161 * be parsed further. EFalse if no need for further processing. |
|
162 */ |
|
163 static TBool CheckResultFromFromResponseL( |
|
164 const TDesC8& aResponse, |
|
165 const TDesC& aDomain, |
|
166 TInt aTransactionOperation, |
|
167 MPEngXMLParser& aParser, |
|
168 MPEngAdvTransactionStatus2& aTransactionStatus, |
|
169 CDesC16Array& aRequestedPresenceIds ); |
|
170 |
|
171 |
|
172 /** |
|
173 * Parsing helper. |
|
174 * |
|
175 * Parses presence blocks from complete Get-Presence-Response. |
|
176 * Appends found presence blocks to given array. |
|
177 * |
|
178 * @since 3.0 |
|
179 * @param aResponse Get presence response to parse. |
|
180 * @param aParser XML parser to use in parsing. |
|
181 * @paramaPresenceBlocks Array to append the parsed blocks. |
|
182 */ |
|
183 static void LocatePresenceBlocksFromResponseL( |
|
184 const TDesC8& aResponse, |
|
185 MPEngXMLParser& aParser, |
|
186 CDesC8Array& aPresenceBlocks ); |
|
187 |
|
188 |
|
189 /** |
|
190 * Parses attribute models from presence block |
|
191 * (XML fragment divided by <Presence> tags). |
|
192 * |
|
193 * Parsing produces only those attributes models which |
|
194 * are listed in given aAttributeTypes and which are |
|
195 * found from network response. |
|
196 * |
|
197 * @since 3.0 |
|
198 * @param aPresenceBlock One presence id's presence XML fragment. |
|
199 * @param aAttrManager The attribute manager to use in model construction. |
|
200 * @param aParser XML parser to use in parsing. |
|
201 * @param aFetchedPresenceIds ID's which are fetched. |
|
202 * Handled presence ID's are removed from the array. |
|
203 * @param aDomain The domain where fetch takes its place. |
|
204 * @param aAttributeTypes Ordered attribute types. |
|
205 * @param aResultModels Array where to append the parsed result models. |
|
206 */ |
|
207 static void ParseModelsFromBlockL( |
|
208 const TDesC8& aPresenceBlock, |
|
209 MPEngPresenceAttrManager& aAttrManager, |
|
210 MPEngXMLParser& aParser, |
|
211 CDesC16Array& aFetchedPresenceIds, |
|
212 const TDesC& aDomain, |
|
213 const CPEngAttributeTypeStack& aAttributeTypes, |
|
214 RPointerArray<MPEngPresenceAttrModel2>& aResultModels, |
|
215 TInt aOperation ); |
|
216 |
|
217 |
|
218 private: // Data |
|
219 |
|
220 |
|
221 //REF: Attribute Manager |
|
222 MPEngPresenceAttrManager& iAttributeManager; |
|
223 |
|
224 //OWN: Operation id |
|
225 const TInt iTransactionOperation; |
|
226 |
|
227 //OWN: WV CSP version |
|
228 const TPEngWVCspVersion iCspVersion; |
|
229 |
|
230 //OWN: Array of fetched presence ID's |
|
231 CDesC16ArraySeg iFetchedPresenceIds; |
|
232 |
|
233 //OWN: Attribute type stack for fetched attributes |
|
234 CPEngAttributeTypeStack* iFechedAttributeTypes; |
|
235 |
|
236 //OWN: XML parser |
|
237 MPEngXMLParser* iXmlParser; |
|
238 |
|
239 //OWN: Operation domain |
|
240 HBufC* iDomain; |
|
241 |
|
242 //OWN: Presence blocks. |
|
243 CDesC8ArraySeg iPresenceBlocks; |
|
244 |
|
245 //REF: Decoded attribute models |
|
246 RPointerArray< MPEngPresenceAttrModel2 >* iFetchedModels; |
|
247 |
|
248 //REF: Fetcher transaction status |
|
249 MPEngAdvTransactionStatus2* iTransactionStatus; |
|
250 |
|
251 }; |
|
252 |
|
253 #endif // CPENGFETCHPROCESSOR_H__ |
|
254 |
|
255 |
|
256 |
|
257 // End of File |
|
258 |