|
1 /* |
|
2 * Copyright (c) 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: Device information document generator implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // ------------------------------------------------------------------------------------------------ |
|
20 // Include |
|
21 // ------------------------------------------------------------------------------------------------ |
|
22 #include "WBXMLDevInfGenerator.h" |
|
23 #include "WBXMLGeneratorError.h" |
|
24 #include "XMLWorkspace.h" |
|
25 |
|
26 #include "smlsyncmltags.h" |
|
27 #include "smldevinftags.h" |
|
28 |
|
29 // ------------------------------------------------------------------------------------------------ |
|
30 // CWBXMLDevInfGenerator |
|
31 // ------------------------------------------------------------------------------------------------ |
|
32 EXPORT_C void CWBXMLDevInfGenerator::CreateWorkspaceL() |
|
33 { |
|
34 CWBXMLGenerator::CreateDynamicWorkspaceL(); |
|
35 } |
|
36 |
|
37 // ------------------------------------------------------------------------------------------------ |
|
38 EXPORT_C Ret_t CWBXMLDevInfGenerator::smlDeviceInfo( SmlDevInfDevInfPtr_t aContent ) |
|
39 { |
|
40 Reset(); |
|
41 Workspace()->BeginTransaction(); |
|
42 TRAPD(result, AppendDeviceInfoL(aContent)); |
|
43 return HandleResult(result); |
|
44 } |
|
45 |
|
46 // ------------------------------------------------------------------------------------------------ |
|
47 void CWBXMLDevInfGenerator::AppendPCDataL( TUint8 aElement, SmlPcdataPtr_t aContent ) |
|
48 { |
|
49 if( !aContent ) |
|
50 { |
|
51 return; |
|
52 } |
|
53 |
|
54 if( aContent->contentType == SML_PCDATA_OPAQUE ) |
|
55 { |
|
56 AddElementL(aElement, TPtrC8((TUint8*)aContent->content, aContent->length)); |
|
57 } |
|
58 else |
|
59 { |
|
60 AddElementL(aElement, TPtrC8((TUint8*)aContent->content, aContent->length), EWBXMLContentFormatInlineString); |
|
61 } |
|
62 } |
|
63 |
|
64 // ------------------------------------------------------------------------------------------------ |
|
65 void CWBXMLDevInfGenerator::AppendPCDataListL( TUint8 aElement, SmlPcdataListPtr_t aList ) |
|
66 { |
|
67 for( SmlPcdataListPtr_t p = aList; p && p->data; p = p->next ) |
|
68 { |
|
69 AppendPCDataL(aElement, p->data); |
|
70 } |
|
71 } |
|
72 |
|
73 // ------------------------------------------------------------------------------------------------ |
|
74 void CWBXMLDevInfGenerator::AppendXmitL( TUint8 aTag, SmlDevInfXmitPtr_t aContent ) |
|
75 { |
|
76 BeginElementL(aTag, ETrue); |
|
77 AppendPCDataL(EDevCTType, aContent->cttype); |
|
78 AppendPCDataL(EDevVerCT, aContent->verct); |
|
79 EndElementL(); // aTag |
|
80 } |
|
81 |
|
82 // ------------------------------------------------------------------------------------------------ |
|
83 void CWBXMLDevInfGenerator::AppendXmitListL( TUint8 aTag, SmlDevInfXmitListPtr_t aContent ) |
|
84 { |
|
85 |
|
86 for( SmlDevInfXmitListPtr_t p = aContent; p && p->data; p = p->next ) |
|
87 { |
|
88 AppendXmitL(aTag, p->data); |
|
89 } |
|
90 } |
|
91 |
|
92 |
|
93 // ------------------------------------------------------------------------------------------------ |
|
94 void CWBXMLDevInfGenerator::AppendExtL( SmlDevInfExtPtr_t aContent ) |
|
95 { |
|
96 BeginElementL(EDevExt, ETrue); |
|
97 AppendPCDataL(EDevXNam, aContent->xnam); |
|
98 AppendPCDataListL(EDevXVal, aContent->xval); |
|
99 EndElementL(); // EDevExt |
|
100 } |
|
101 |
|
102 // ------------------------------------------------------------------------------------------------ |
|
103 void CWBXMLDevInfGenerator::AppendExtListL( SmlDevInfExtListPtr_t aContent ) |
|
104 { |
|
105 for( SmlDevInfExtListPtr_t p = aContent; p && p->data; p = p->next ) |
|
106 { |
|
107 AppendExtL(p->data); |
|
108 } |
|
109 } |
|
110 |
|
111 // 1.2 CHANGES: new element FilterCap |
|
112 // ------------------------------------------------------------------------------------------------ |
|
113 void CWBXMLDevInfGenerator::AppendFilterCapL( SmlDevInfFilterCapPtr_t aContent ) |
|
114 { |
|
115 BeginElementL(EDevFilterCap, ETrue); |
|
116 AppendPCDataL(EDevCTType, aContent->cttype); |
|
117 AppendPCDataL(EDevVerCT, aContent->verct); |
|
118 AppendPCDataListL(EDevFilterKeyword, aContent->filterkeyword); |
|
119 AppendPCDataListL(EDevPropName, aContent->propname); |
|
120 EndElementL(); // EDevPropParam |
|
121 } |
|
122 |
|
123 // ------------------------------------------------------------------------------------------------ |
|
124 void CWBXMLDevInfGenerator::AppendFilterCapListL( SmlDevInfFilterCapListPtr_t aContent ) |
|
125 { |
|
126 if (aContent && aContent->data) |
|
127 { |
|
128 for( SmlDevInfFilterCapListPtr_t p = aContent; p && p->data; p = p->next ) |
|
129 { |
|
130 AppendFilterCapL(p->data); |
|
131 } |
|
132 } |
|
133 } |
|
134 // Changes end |
|
135 |
|
136 // ------------------------------------------------------------------------------------------------ |
|
137 void CWBXMLDevInfGenerator::AppendSyncCapL( SmlDevInfSyncCapPtr_t aContent ) |
|
138 { |
|
139 BeginElementL(EDevSyncCap, ETrue); |
|
140 AppendPCDataListL(EDevSyncType, aContent->synctype); |
|
141 EndElementL(); // EDevSyncCap |
|
142 } |
|
143 |
|
144 // ------------------------------------------------------------------------------------------------ |
|
145 void CWBXMLDevInfGenerator::AppendDSMemL( SmlDevInfDSMemPtr_t aContent ) |
|
146 { |
|
147 if( !aContent ) |
|
148 { |
|
149 return; |
|
150 } |
|
151 BeginElementL(EDevDSMem, ETrue); |
|
152 if (aContent->shared) |
|
153 { |
|
154 BeginElementL(EDevSharedMem); |
|
155 } |
|
156 AppendPCDataL(EDevMaxMem, aContent->maxmem); |
|
157 AppendPCDataL(EDevMaxID, aContent->maxid); |
|
158 EndElementL(); // EDevDSMem |
|
159 } |
|
160 |
|
161 // 1.2 CHANGES: new elements PropParam and Property |
|
162 // ------------------------------------------------------------------------------------------------ |
|
163 void CWBXMLDevInfGenerator::AppendPropParamL(SmlDevInfPropParamPtr_t aContent) |
|
164 { |
|
165 BeginElementL(EDevPropParam, ETrue); |
|
166 AppendPCDataL(EDevParamName, aContent->paramname); |
|
167 AppendPCDataL(EDevDataType, aContent->datatype); |
|
168 AppendPCDataListL(EDevValEnum, aContent->valenum); |
|
169 AppendPCDataL(EDevDisplayName, aContent->displayname); |
|
170 EndElementL(); // EDevPropParam |
|
171 } |
|
172 |
|
173 // ------------------------------------------------------------------------------------------------ |
|
174 void CWBXMLDevInfGenerator::AppendPropParamListL(SmlDevInfPropParamListPtr_t aContent) |
|
175 { |
|
176 if (aContent && aContent->data) |
|
177 { |
|
178 for( SmlDevInfPropParamListPtr_t p = aContent; p && p->data; p = p->next ) |
|
179 { |
|
180 AppendPropParamL(p->data); |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 // ------------------------------------------------------------------------------------------------ |
|
186 void CWBXMLDevInfGenerator::AppendPropertyL( SmlDevInfPropertyPtr_t aContent) |
|
187 { |
|
188 BeginElementL(EDevProperty, ETrue); |
|
189 AppendPCDataL(EDevPropName, aContent->propname); |
|
190 AppendPCDataL(EDevDataType, aContent->datatype); |
|
191 AppendPCDataL(EDevMaxOccur, aContent->maxoccur); |
|
192 AppendPCDataL(EDevMaxSize, aContent->maxsize); |
|
193 if (aContent->notruncate) |
|
194 { |
|
195 BeginElementL(EDevNoTruncate); |
|
196 } |
|
197 AppendPCDataListL(EDevValEnum, aContent->valenum); |
|
198 AppendPCDataL(EDevDisplayName, aContent->displayname); |
|
199 AppendPropParamListL(aContent->propparam); |
|
200 EndElementL(); // EDevProperty |
|
201 } |
|
202 |
|
203 |
|
204 // ------------------------------------------------------------------------------------------------ |
|
205 void CWBXMLDevInfGenerator::AppendPropertyListL( SmlDevInfPropertyListPtr_t aContent ) |
|
206 { |
|
207 for( SmlDevInfPropertyListPtr_t p = aContent; p && p->data; p = p->next ) |
|
208 { |
|
209 AppendPropertyL(p->data); |
|
210 } |
|
211 } |
|
212 // Changes end |
|
213 |
|
214 // ------------------------------------------------------------------------------------------------ |
|
215 void CWBXMLDevInfGenerator::AppendCTDataL( TUint8 aTag, SmlDevInfCTDataPtr_t aContent ) |
|
216 { |
|
217 AppendPCDataL(aTag, aContent->name); |
|
218 if( aContent->valenum ) |
|
219 { |
|
220 AppendPCDataListL(EDevValEnum, aContent->valenum); |
|
221 } |
|
222 else |
|
223 { |
|
224 AppendPCDataL(EDevDataType, aContent->datatype); |
|
225 AppendPCDataL(EDevMaxSize, aContent->size); //1.2 CHANGES: EDevSize -> EDevMaxSize |
|
226 } |
|
227 AppendPCDataL(EDevDisplayName, aContent->dname); |
|
228 } |
|
229 |
|
230 // ------------------------------------------------------------------------------------------------ |
|
231 void CWBXMLDevInfGenerator::AppendCTDataPropL( SmlDevInfCTDataPropPtr_t aContent ) |
|
232 { |
|
233 AppendCTDataL(EDevPropName, aContent->prop); |
|
234 AppendCTDataListL(aContent->param); |
|
235 } |
|
236 |
|
237 // ------------------------------------------------------------------------------------------------ |
|
238 void CWBXMLDevInfGenerator::AppendCTDataListL( SmlDevInfCTDataListPtr_t aContent ) |
|
239 { |
|
240 for( SmlDevInfCTDataListPtr_t p = aContent; p && p->data; p = p->next ) |
|
241 { |
|
242 AppendCTDataL(EDevParamName, p->data); |
|
243 } |
|
244 } |
|
245 |
|
246 // ------------------------------------------------------------------------------------------------ |
|
247 void CWBXMLDevInfGenerator::AppendCTDataPropListL( SmlDevInfCTDataPropListPtr_t aContent ) |
|
248 { |
|
249 for( SmlDevInfCTDataPropListPtr_t p = aContent; p && p->data; p = p->next ) |
|
250 { |
|
251 AppendCTDataPropL(p->data); |
|
252 } |
|
253 } |
|
254 |
|
255 // 1.2 CHANGES: version 1.1 and 1.2 support |
|
256 // ------------------------------------------------------------------------------------------------ |
|
257 void CWBXMLDevInfGenerator::AppendCtCapL( SmlDevInfCtCapPtr_t aContent ) |
|
258 { |
|
259 if (iVerDtd == KDtDVersion12) |
|
260 { |
|
261 BeginElementL(EDevCTCap, ETrue); |
|
262 AppendPCDataL(EDevCTType, aContent->cttype); |
|
263 AppendPCDataL(EDevVerCT, aContent->verct); |
|
264 if (aContent->fieldlevel) |
|
265 { |
|
266 BeginElementL(EDevFieldLevel); |
|
267 } |
|
268 AppendPropertyListL(aContent->property); |
|
269 EndElementL(); // EDevCTCap |
|
270 } |
|
271 else |
|
272 { |
|
273 AppendPCDataL(EDevCTType, aContent->cttype); |
|
274 AppendCTDataPropListL(aContent->prop); |
|
275 } |
|
276 } |
|
277 // changes end |
|
278 |
|
279 |
|
280 // 1.2 CHANGES: version 1.1 and 1.2 support |
|
281 // ------------------------------------------------------------------------------------------------ |
|
282 void CWBXMLDevInfGenerator::AppendCtCapListL( SmlDevInfCtCapListPtr_t aContent ) |
|
283 { |
|
284 if (iVerDtd == KDtDVersion11) |
|
285 { |
|
286 BeginElementL(EDevCTCap, ETrue); |
|
287 } |
|
288 for( SmlDevInfCtCapListPtr_t p = aContent; p && p->data; p = p->next ) |
|
289 { |
|
290 AppendCtCapL(p->data); |
|
291 } |
|
292 if (iVerDtd == KDtDVersion11) |
|
293 { |
|
294 EndElementL(); // EDevCtCap |
|
295 } |
|
296 } |
|
297 // changes end |
|
298 |
|
299 //1.2 CHANGES: version 1.1 and 1.2 support |
|
300 // new elements supportHierarchicalSync, FilterRx and FilterCap in version 1.2 |
|
301 // CtCap inside Datastore -element in version 1.2 |
|
302 // ------------------------------------------------------------------------------------------------ |
|
303 void CWBXMLDevInfGenerator::AppendDatastoreL( SmlDevInfDatastorePtr_t aContent ) |
|
304 { |
|
305 BeginElementL(EDevDataStore, ETrue); |
|
306 AppendPCDataL(EDevSourceRef, aContent->sourceref); |
|
307 AppendPCDataL(EDevDisplayName, aContent->displayname); |
|
308 AppendPCDataL(EDevMaxGUIDSize, aContent->maxguidsize); |
|
309 AppendXmitL(EDevRxPref, aContent->rxpref); |
|
310 AppendXmitListL(EDevRx, aContent->rx); |
|
311 AppendXmitL(EDevTxPref, aContent->txpref); |
|
312 AppendXmitListL(EDevTx, aContent->tx); |
|
313 if ( iVerDtd == KDtDVersion12 ) |
|
314 { |
|
315 AppendCtCapListL(aContent->ctcap); |
|
316 } |
|
317 AppendDSMemL(aContent->dsmem); |
|
318 if (( iVerDtd == KDtDVersion12 ) && ( aContent->supportHierarchicalSync )) |
|
319 { |
|
320 BeginElementL(EDevSupportHierarchicalSync); |
|
321 } |
|
322 AppendSyncCapL(aContent->synccap); |
|
323 if ( iVerDtd == KDtDVersion12 ) |
|
324 { |
|
325 AppendXmitListL(EDevFilterRx, aContent->filterrx); |
|
326 AppendFilterCapListL(aContent->filtercap); |
|
327 } |
|
328 EndElementL(); // EDevDataStore |
|
329 } |
|
330 // changes end |
|
331 |
|
332 // ------------------------------------------------------------------------------------------------ |
|
333 void CWBXMLDevInfGenerator::AppendDatastoreListL( SmlDevInfDatastoreListPtr_t aContent ) |
|
334 { |
|
335 for( SmlDevInfDatastoreListPtr_t p = aContent; p && p->data; p = p->next ) |
|
336 { |
|
337 AppendDatastoreL(p->data); |
|
338 } |
|
339 } |
|
340 |
|
341 //1.2 CHANGES: version 1.1 and 1.2 support |
|
342 // in version 1.1. CtCap element inside DeviceInfo -element |
|
343 // ------------------------------------------------------------------------------------------------ |
|
344 void CWBXMLDevInfGenerator::AppendDeviceInfoL( SmlDevInfDevInfPtr_t aContent ) |
|
345 { |
|
346 |
|
347 TPtrC8 ver; |
|
348 ver.Set(aContent->verdtd->Data()); |
|
349 |
|
350 if ( ver.FindC(_L8("1.1")) == KErrNone ) |
|
351 { |
|
352 iVerDtd = KDtDVersion11; |
|
353 BeginDocumentL(KNSmlDevInfVersion, KNSmlDevInfPublicId, KNSmlDevInfUTF8); |
|
354 } |
|
355 else |
|
356 { |
|
357 iVerDtd = KDtDVersion12; |
|
358 BeginDocumentL(KNSmlDevInfVersion, KNSmlDevInfPublicId12, KNSmlDevInfUTF8); |
|
359 } |
|
360 |
|
361 BeginElementL(EDevDevInf, ETrue); |
|
362 AppendPCDataL(EDevVerDTD, aContent->verdtd); |
|
363 AppendPCDataL(EDevMan, aContent->man); |
|
364 AppendPCDataL(EDevMod, aContent->mod); |
|
365 AppendPCDataL(EDevOEM, aContent->oem); |
|
366 AppendPCDataL(EDevFwV, aContent->fwv); |
|
367 AppendPCDataL(EDevSwV, aContent->swv); |
|
368 AppendPCDataL(EDevHwV, aContent->hwv); |
|
369 AppendPCDataL(EDevDevID, aContent->devid); |
|
370 AppendPCDataL(EDevDevTyp, aContent->devtyp); |
|
371 if( aContent->flags & SmlUTC_f ) |
|
372 { |
|
373 BeginElementL(EDevUTC); |
|
374 } |
|
375 if( aContent->flags & SmlSupportLargeObjects_f ) |
|
376 { |
|
377 BeginElementL(EDevSupportLargeObjs); |
|
378 } |
|
379 if( aContent->flags & SmlSupportNumberOfChanges_f ) |
|
380 { |
|
381 BeginElementL(EDevSupportNumberOfChanges); |
|
382 } |
|
383 AppendDatastoreListL(aContent->datastore); |
|
384 if (iVerDtd == KDtDVersion11) |
|
385 { |
|
386 AppendCtCapListL(aContent->ctcap); |
|
387 } |
|
388 AppendExtListL(aContent->ext); |
|
389 EndElementL(); // EDevDevInf |
|
390 } |
|
391 // changes end |