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