|
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: SyncML document generator class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // ------------------------------------------------------------------------------------------------ |
|
20 // Include |
|
21 // ------------------------------------------------------------------------------------------------ |
|
22 #include "WBXMLSyncMLGenerator.h" |
|
23 #include "WBXMLGeneratorError.h" |
|
24 #include "XMLWorkspace.h" |
|
25 |
|
26 #include "smlsyncmltags.h" |
|
27 #include "smlmetinftags.h" |
|
28 #include "smldevinftags.h" //1.2 CHANGES: Property |
|
29 |
|
30 // ------------------------------------------------------------------------------------------------ |
|
31 // CWBXMLSyncMLGenerator |
|
32 // ------------------------------------------------------------------------------------------------ |
|
33 //1.2 CHANGES: publicId, Streaming |
|
34 EXPORT_C CWBXMLSyncMLGenerator::CWBXMLSyncMLGenerator( TInt32 aPublicId ) : |
|
35 iPublicId( aPublicId ), iContentLength(-1) |
|
36 { |
|
37 } |
|
38 |
|
39 EXPORT_C void CWBXMLSyncMLGenerator::CreateWorkspaceL( TInt aBufferSize ) |
|
40 { |
|
41 CWBXMLGenerator::CreateStaticWorkspaceL(aBufferSize); |
|
42 } |
|
43 |
|
44 // ------------------------------------------------------------------------------------------------ |
|
45 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlStartMessage( SmlSyncHdrPtr_t aContent ) |
|
46 { |
|
47 Reset(); |
|
48 Workspace()->BeginTransaction(); |
|
49 TRAPD(result, DoSmlStartMessageL(aContent)); |
|
50 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
51 } |
|
52 |
|
53 // ------------------------------------------------------------------------------------------------ |
|
54 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlEndMessage( Boolean_t aFinal ) |
|
55 { |
|
56 Workspace()->BeginTransaction(); |
|
57 TRAPD(result, DoSmlEndMessageL(aFinal)); |
|
58 return HandleResult(result); // No safe treshold as this is end of packet |
|
59 } |
|
60 |
|
61 // ------------------------------------------------------------------------------------------------ |
|
62 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlStartSync( SmlSyncPtr_t aContent ) |
|
63 { |
|
64 Workspace()->BeginTransaction(); |
|
65 TRAPD(result, AppendSyncL(aContent)); |
|
66 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
67 } |
|
68 |
|
69 // ------------------------------------------------------------------------------------------------ |
|
70 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlEndSync() |
|
71 { |
|
72 Workspace()->BeginTransaction(); |
|
73 TRAPD(result, EndElementL()); |
|
74 return HandleResult(result); |
|
75 } |
|
76 |
|
77 // ------------------------------------------------------------------------------------------------ |
|
78 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlAddCmd( SmlAddPtr_t aContent ) |
|
79 { |
|
80 Workspace()->BeginTransaction(); |
|
81 TRAPD(result, AppendAddCmdL(aContent)); |
|
82 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
83 } |
|
84 |
|
85 // ------------------------------------------------------------------------------------------------ |
|
86 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlReplaceCmd( SmlReplacePtr_t aContent ) |
|
87 { |
|
88 Workspace()->BeginTransaction(); |
|
89 TRAPD(result, AppendReplaceCmdL(aContent)); |
|
90 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
91 } |
|
92 |
|
93 // ------------------------------------------------------------------------------------------------ |
|
94 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlCopyCmd( SmlCopyPtr_t aContent ) |
|
95 { |
|
96 Workspace()->BeginTransaction(); |
|
97 TRAPD(result, AppendCopyCmdL(aContent)); |
|
98 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
99 } |
|
100 |
|
101 // ------------------------------------------------------------------------------------------------ |
|
102 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlDeleteCmd( SmlDeletePtr_t aContent ) |
|
103 { |
|
104 Workspace()->BeginTransaction(); |
|
105 TRAPD(result, AppendDeleteCmdL(aContent)); |
|
106 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
107 } |
|
108 |
|
109 //1.2 CHANGES: Move command |
|
110 // ------------------------------------------------------------------------------------------------ |
|
111 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlMoveCmd( SmlMovePtr_t aContent ) |
|
112 { |
|
113 Workspace()->BeginTransaction(); |
|
114 TRAPD(result, AppendMoveCmdL(aContent)); |
|
115 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
116 } |
|
117 // Changes end |
|
118 |
|
119 // ------------------------------------------------------------------------------------------------ |
|
120 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlAlertCmd( SmlAlertPtr_t aContent ) |
|
121 { |
|
122 Workspace()->BeginTransaction(); |
|
123 TRAPD(result, AppendAlertCmdL(aContent)); |
|
124 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
125 } |
|
126 |
|
127 // ------------------------------------------------------------------------------------------------ |
|
128 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlGetCmd( SmlPutPtr_t aContent ) |
|
129 { |
|
130 Workspace()->BeginTransaction(); |
|
131 TRAPD(result, AppendGetCmdL(aContent)); |
|
132 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
133 } |
|
134 |
|
135 // ------------------------------------------------------------------------------------------------ |
|
136 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlPutCmd( SmlPutPtr_t aContent ) |
|
137 { |
|
138 Workspace()->BeginTransaction(); |
|
139 TRAPD(result, AppendPutCmdL(aContent)); |
|
140 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
141 } |
|
142 |
|
143 // ------------------------------------------------------------------------------------------------ |
|
144 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlMapCmd( SmlMapPtr_t aContent ) |
|
145 { |
|
146 Workspace()->BeginTransaction(); |
|
147 TRAPD(result, AppendMapCmdL(aContent)); |
|
148 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
149 } |
|
150 |
|
151 // ------------------------------------------------------------------------------------------------ |
|
152 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlResultsCmd( SmlResultsPtr_t aContent ) |
|
153 { |
|
154 Workspace()->BeginTransaction(); |
|
155 TRAPD(result, AppendResultsCmdL(aContent)); |
|
156 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
157 } |
|
158 |
|
159 // ------------------------------------------------------------------------------------------------ |
|
160 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlStatusCmd( SmlStatusPtr_t aContent ) |
|
161 { |
|
162 Workspace()->BeginTransaction(); |
|
163 TRAPD(result, AppendStatusCmdL(aContent)); |
|
164 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
165 } |
|
166 |
|
167 // ------------------------------------------------------------------------------------------------ |
|
168 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlStartAtomic( SmlAtomicPtr_t aContent ) |
|
169 { |
|
170 Workspace()->BeginTransaction(); |
|
171 TRAPD(result, AppendStartAtomicL(aContent)); |
|
172 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
173 } |
|
174 |
|
175 // ------------------------------------------------------------------------------------------------ |
|
176 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlEndAtomic() |
|
177 { |
|
178 Workspace()->BeginTransaction(); |
|
179 TRAPD(result, AppendEndAtomicL()); |
|
180 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
181 } |
|
182 |
|
183 // ------------------------------------------------------------------------------------------------ |
|
184 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlStartSequence( SmlSequencePtr_t aContent ) |
|
185 { |
|
186 Workspace()->BeginTransaction(); |
|
187 TRAPD(result, AppendStartSequenceL(aContent)); |
|
188 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
189 } |
|
190 |
|
191 // ------------------------------------------------------------------------------------------------ |
|
192 EXPORT_C Ret_t CWBXMLSyncMLGenerator::smlEndSequence() |
|
193 { |
|
194 Workspace()->BeginTransaction(); |
|
195 TRAPD(result, AppendEndSequenceL()); |
|
196 return HandleResult(result, KNSmlBufferSafeTreshold); |
|
197 } |
|
198 |
|
199 // Data chunk functionality |
|
200 |
|
201 // ------------------------------------------------------------------------------------------------ |
|
202 EXPORT_C void CWBXMLSyncMLGenerator::SetTruncate( TBool aEnabled ) |
|
203 { |
|
204 iUseTruncation = aEnabled; |
|
205 } |
|
206 |
|
207 // ------------------------------------------------------------------------------------------------ |
|
208 EXPORT_C TInt CWBXMLSyncMLGenerator::ItemIndex() const |
|
209 { |
|
210 return iItemIndex; |
|
211 } |
|
212 |
|
213 // ------------------------------------------------------------------------------------------------ |
|
214 EXPORT_C TInt CWBXMLSyncMLGenerator::DataConsumed() const |
|
215 { |
|
216 return iDataConsumed; |
|
217 } |
|
218 |
|
219 // ------------------------------------------------------------------------------------------------ |
|
220 EXPORT_C TBool CWBXMLSyncMLGenerator::WasTruncated() |
|
221 { |
|
222 TBool was(iItemWasTruncated); |
|
223 iItemWasTruncated = EFalse; |
|
224 return was; |
|
225 } |
|
226 |
|
227 //1.2 CHANGES: Streaming |
|
228 EXPORT_C void CWBXMLSyncMLGenerator::SetContentLength(TInt aContentLength) |
|
229 { |
|
230 iContentLength = aContentLength; |
|
231 } |
|
232 //end changes |
|
233 // ------------------------------------------------------------------------------------------------ |
|
234 void CWBXMLSyncMLGenerator::DoSmlStartMessageL( SmlSyncHdrPtr_t aContent ) |
|
235 { |
|
236 //1.2 CHANGES: Publicid |
|
237 BeginDocumentL(KNSmlSyncMLVersion, iPublicId, KNSmlSyncMLUTF8); |
|
238 //Changes end |
|
239 BeginElementL(ESyncML, ETrue); |
|
240 AppendSyncHrdL(aContent); |
|
241 BeginElementL(ESyncBody, ETrue); |
|
242 } |
|
243 |
|
244 // ------------------------------------------------------------------------------------------------ |
|
245 void CWBXMLSyncMLGenerator::DoSmlEndMessageL( Boolean_t aFinal ) |
|
246 { |
|
247 if( aFinal ) |
|
248 { |
|
249 BeginElementL(EFinal); |
|
250 } |
|
251 EndElementL(); // SyncBody |
|
252 EndElementL(); // SyncML |
|
253 } |
|
254 |
|
255 // ------------------------------------------------------------------------------------------------ |
|
256 void CWBXMLSyncMLGenerator::AppendSyncHrdL( SmlSyncHdrPtr_t aContent ) |
|
257 { |
|
258 BeginElementL(ESyncHdr, ETrue); |
|
259 AppendPCDataL(EVerDTD, aContent->version); |
|
260 AppendPCDataL(EVerProto, aContent->proto); |
|
261 AppendPCDataL(ESessionID, aContent->sessionID); |
|
262 AppendPCDataL(EMsgID, aContent->msgID); |
|
263 AppendTargetL(aContent->target); |
|
264 AppendSourceL(aContent->source); |
|
265 AppendPCDataL(ERespURI, aContent->respURI); |
|
266 if( aContent->flags & SmlNoResp_f ) |
|
267 { |
|
268 BeginElementL(ENoResp); |
|
269 } |
|
270 AppendCredL(aContent->cred); |
|
271 AppendMetaL(aContent->meta); |
|
272 EndElementL(); // ESyncHdr |
|
273 } |
|
274 |
|
275 // 1.2 CHANGES: Source and Target separated |
|
276 // ------------------------------------------------------------------------------------------------ |
|
277 void CWBXMLSyncMLGenerator::DoAppendTargetL( SmlTargetPtr_t aContent ) |
|
278 { |
|
279 AppendPCDataL(ELocURI, aContent->locURI); |
|
280 AppendPCDataL(ELocName, aContent->locName); |
|
281 AppendFilterL(aContent->filter); //1.2 CHANGES: Filter |
|
282 } |
|
283 |
|
284 // ------------------------------------------------------------------------------------------------ |
|
285 void CWBXMLSyncMLGenerator::DoAppendSourceL( SmlSourcePtr_t aContent ) |
|
286 { |
|
287 AppendPCDataL(ELocURI, aContent->locURI); |
|
288 AppendPCDataL(ELocName, aContent->locName); |
|
289 } |
|
290 // Changes end |
|
291 |
|
292 // ------------------------------------------------------------------------------------------------ |
|
293 void CWBXMLSyncMLGenerator::AppendTargetL( SmlTargetPtr_t aContent ) |
|
294 { |
|
295 if( !aContent ) |
|
296 { |
|
297 return; |
|
298 } |
|
299 BeginElementL(ETarget, ETrue); |
|
300 DoAppendTargetL(aContent); |
|
301 EndElementL(); // ETarget |
|
302 } |
|
303 |
|
304 // ------------------------------------------------------------------------------------------------ |
|
305 void CWBXMLSyncMLGenerator::AppendSourceL( SmlSourcePtr_t aContent ) |
|
306 { |
|
307 if( !aContent ) |
|
308 { |
|
309 return; |
|
310 } |
|
311 BeginElementL(ESource, ETrue); |
|
312 // 1.2 CHANGES: Source and Target separated |
|
313 DoAppendSourceL(aContent); |
|
314 // Changes end |
|
315 EndElementL(); // ETarget |
|
316 } |
|
317 |
|
318 //1.2 CHANGES: Source & Target parent |
|
319 // ------------------------------------------------------------------------------------------------ |
|
320 void CWBXMLSyncMLGenerator::DoAppendSourceOrTargetParentL( SmlSourceOrTargetParentPtr_t aContent ) |
|
321 { |
|
322 AppendPCDataL(ELocURI, aContent->locURI); |
|
323 } |
|
324 |
|
325 // ------------------------------------------------------------------------------------------------ |
|
326 void CWBXMLSyncMLGenerator::AppendSourceParentL( SmlSourceParentPtr_t aContent ) |
|
327 { |
|
328 if( !aContent ) |
|
329 { |
|
330 return; |
|
331 } |
|
332 BeginElementL(ESourceParent, ETrue); |
|
333 DoAppendSourceOrTargetParentL(aContent); |
|
334 EndElementL(); // ESourceParent |
|
335 } |
|
336 |
|
337 // ------------------------------------------------------------------------------------------------ |
|
338 void CWBXMLSyncMLGenerator::AppendTargetParentL( SmlTargetParentPtr_t aContent ) |
|
339 { |
|
340 if( !aContent ) |
|
341 { |
|
342 return; |
|
343 } |
|
344 BeginElementL(ETargetParent, ETrue); |
|
345 DoAppendSourceOrTargetParentL(aContent); |
|
346 EndElementL(); // ETargetParent |
|
347 } |
|
348 //Changes end |
|
349 |
|
350 // ------------------------------------------------------------------------------------------------ |
|
351 void CWBXMLSyncMLGenerator::AppendCredL( SmlCredPtr_t aContent ) |
|
352 { |
|
353 if( !aContent ) |
|
354 { |
|
355 return; |
|
356 } |
|
357 BeginElementL(ECred, ETrue); |
|
358 AppendMetaL(aContent->meta); |
|
359 AppendPCDataL(EData, aContent->data); |
|
360 EndElementL(); // ECred |
|
361 } |
|
362 |
|
363 // ------------------------------------------------------------------------------------------------ |
|
364 void CWBXMLSyncMLGenerator::AppendSyncL( SmlSyncPtr_t aContent ) |
|
365 { |
|
366 BeginElementL(ESync, ETrue); |
|
367 AppendPCDataL(ECmdID, aContent->cmdID); |
|
368 if( aContent->flags & SmlNoResp_f ) |
|
369 { |
|
370 BeginElementL(ENoResp); |
|
371 } |
|
372 AppendCredL(aContent->cred); |
|
373 AppendTargetL(aContent->target); |
|
374 AppendSourceL(aContent->source); |
|
375 AppendMetaL(aContent->meta); |
|
376 AppendPCDataL(ENumberOfChanges, aContent->noc); |
|
377 } |
|
378 |
|
379 // ------------------------------------------------------------------------------------------------ |
|
380 void CWBXMLSyncMLGenerator::DoAppendGenericCmdL( SmlGenericCmdPtr_t aContent, Flag_t aMask ) |
|
381 { |
|
382 AppendPCDataL(ECmdID, aContent->cmdID); |
|
383 if( (aContent->flags & SmlNoResp_f) & aMask ) |
|
384 { |
|
385 BeginElementL(ENoResp); |
|
386 } |
|
387 if( (aContent->flags & SmlArchive_f) & aMask ) |
|
388 { |
|
389 BeginElementL(EArchive); |
|
390 } |
|
391 if( (aContent->flags & SmlSftDel_f) & aMask ) |
|
392 { |
|
393 BeginElementL(ESftDel); |
|
394 } |
|
395 AppendCredL(aContent->cred); |
|
396 AppendMetaL(aContent->meta); |
|
397 AppendItemListL(aContent->itemList); |
|
398 } |
|
399 |
|
400 // ------------------------------------------------------------------------------------------------ |
|
401 void CWBXMLSyncMLGenerator::AppendAddCmdL( SmlAddPtr_t aContent ) |
|
402 { |
|
403 BeginElementL(EAdd, ETrue); |
|
404 DoAppendGenericCmdL(aContent, SmlNoResp_f); |
|
405 EndElementL(); // EAdd |
|
406 } |
|
407 |
|
408 // ------------------------------------------------------------------------------------------------ |
|
409 void CWBXMLSyncMLGenerator::AppendReplaceCmdL( SmlReplacePtr_t aContent ) |
|
410 { |
|
411 BeginElementL(EReplace, ETrue); |
|
412 DoAppendGenericCmdL(aContent, SmlNoResp_f); |
|
413 EndElementL(); // EReplace |
|
414 } |
|
415 |
|
416 // ------------------------------------------------------------------------------------------------ |
|
417 void CWBXMLSyncMLGenerator::AppendCopyCmdL( SmlCopyPtr_t aContent ) |
|
418 { |
|
419 BeginElementL(ECopy, ETrue); |
|
420 DoAppendGenericCmdL(aContent, SmlNoResp_f); |
|
421 EndElementL(); // ECopy |
|
422 } |
|
423 |
|
424 // ------------------------------------------------------------------------------------------------ |
|
425 void CWBXMLSyncMLGenerator::AppendDeleteCmdL( SmlDeletePtr_t aContent ) |
|
426 { |
|
427 BeginElementL(EDelete, ETrue); |
|
428 DoAppendGenericCmdL(aContent, SmlNoResp_f|SmlArchive_f|SmlSftDel_f); |
|
429 EndElementL(); // EDelete |
|
430 } |
|
431 |
|
432 //1.2 CHANGES: Move command |
|
433 // ------------------------------------------------------------------------------------------------ |
|
434 void CWBXMLSyncMLGenerator::AppendMoveCmdL( SmlMovePtr_t aContent ) |
|
435 { |
|
436 BeginElementL(EMove, ETrue); |
|
437 DoAppendGenericCmdL(aContent, SmlNoResp_f); |
|
438 EndElementL(); // EMove |
|
439 } |
|
440 // Changes end |
|
441 |
|
442 // ------------------------------------------------------------------------------------------------ |
|
443 void CWBXMLSyncMLGenerator::AppendAlertCmdL( SmlAlertPtr_t aContent ) |
|
444 { |
|
445 BeginElementL(EAlert, ETrue); |
|
446 AppendPCDataL(ECmdID, aContent->cmdID); |
|
447 if( aContent->flags & SmlNoResp_f ) |
|
448 { |
|
449 BeginElementL(ENoResp); |
|
450 } |
|
451 AppendCredL(aContent->cred); |
|
452 AppendPCDataL(EData, aContent->data); |
|
453 // FOTA |
|
454 AppendPCDataL(ECorrelator, aContent->correlator); |
|
455 // FOTA end |
|
456 AppendItemListL(aContent->itemList); |
|
457 EndElementL(); // EAlert |
|
458 } |
|
459 |
|
460 // ------------------------------------------------------------------------------------------------ |
|
461 void CWBXMLSyncMLGenerator::AppendGetCmdL( SmlGetPtr_t aContent ) |
|
462 { |
|
463 BeginElementL(EGet, ETrue); |
|
464 DoAppendPutGetL(aContent); |
|
465 EndElementL(); // EPut |
|
466 } |
|
467 |
|
468 // ------------------------------------------------------------------------------------------------ |
|
469 void CWBXMLSyncMLGenerator::AppendPutCmdL( SmlPutPtr_t aContent ) |
|
470 { |
|
471 BeginElementL(EPut, ETrue); |
|
472 DoAppendPutGetL(aContent); |
|
473 EndElementL(); // EPut |
|
474 } |
|
475 |
|
476 // ------------------------------------------------------------------------------------------------ |
|
477 void CWBXMLSyncMLGenerator::DoAppendPutGetL( SmlPutPtr_t aContent ) |
|
478 { |
|
479 AppendPCDataL(ECmdID, aContent->cmdID); |
|
480 if( aContent->flags & SmlNoResp_f ) |
|
481 { |
|
482 BeginElementL(ENoResp); |
|
483 } |
|
484 AppendPCDataL(ELang, aContent->lang); |
|
485 AppendCredL(aContent->cred); |
|
486 AppendMetaL(aContent->meta); |
|
487 AppendItemListL(aContent->itemList); |
|
488 } |
|
489 |
|
490 // ------------------------------------------------------------------------------------------------ |
|
491 void CWBXMLSyncMLGenerator::AppendMapCmdL( SmlMapPtr_t aContent ) |
|
492 { |
|
493 BeginElementL(EMap, ETrue); |
|
494 AppendPCDataL(ECmdID, aContent->cmdID); |
|
495 AppendTargetL(aContent->target); |
|
496 AppendSourceL(aContent->source); |
|
497 AppendCredL(aContent->cred); |
|
498 AppendMetaL(aContent->meta); |
|
499 AppendMapItemListL(aContent->mapItemList); |
|
500 EndElementL(); // EMap |
|
501 } |
|
502 |
|
503 // ------------------------------------------------------------------------------------------------ |
|
504 void CWBXMLSyncMLGenerator::AppendResultsCmdL( SmlResultsPtr_t aContent ) |
|
505 { |
|
506 BeginElementL(EResults, ETrue); |
|
507 AppendPCDataL(ECmdID, aContent->cmdID); |
|
508 AppendPCDataL(EMsgRef, aContent->msgRef); |
|
509 AppendPCDataL(ECmdRef, aContent->cmdRef); |
|
510 AppendMetaL(aContent->meta); |
|
511 AppendPCDataL(ETargetRef, aContent->targetRef); |
|
512 AppendPCDataL(ESourceRef, aContent->sourceRef); |
|
513 AppendItemListL(aContent->itemList); |
|
514 EndElementL(); // EResults |
|
515 } |
|
516 |
|
517 // ------------------------------------------------------------------------------------------------ |
|
518 void CWBXMLSyncMLGenerator::AppendStatusCmdL( SmlStatusPtr_t aContent ) |
|
519 { |
|
520 BeginElementL(EStatus, ETrue); |
|
521 AppendPCDataL(ECmdID, aContent->cmdID); |
|
522 AppendPCDataL(EMsgRef, aContent->msgRef); |
|
523 AppendPCDataL(ECmdRef, aContent->cmdRef); |
|
524 AppendPCDataL(ECmd, aContent->cmd); |
|
525 if( aContent->targetRefList ) |
|
526 { |
|
527 AppendTargetRefListL(aContent->targetRefList); |
|
528 } |
|
529 if( aContent->sourceRefList ) |
|
530 { |
|
531 AppendSourceRefListL(aContent->sourceRefList); |
|
532 } |
|
533 AppendCredL(aContent->cred); |
|
534 AppendChalL(aContent->chal); |
|
535 AppendPCDataL(EData, aContent->data); |
|
536 if( aContent->itemList ) |
|
537 { |
|
538 AppendItemListL(aContent->itemList); |
|
539 } |
|
540 EndElementL(); // EStatus |
|
541 } |
|
542 |
|
543 // ------------------------------------------------------------------------------------------------ |
|
544 void CWBXMLSyncMLGenerator::AppendStartAtomicOrSequenceL( SmlAtomicPtr_t aContent ) |
|
545 { |
|
546 AppendPCDataL(ECmdID, aContent->cmdID); |
|
547 if( aContent->flags & SmlNoResp_f ) |
|
548 { |
|
549 BeginElementL(ENoResp); |
|
550 } |
|
551 AppendMetaL(aContent->meta); |
|
552 } |
|
553 |
|
554 // ------------------------------------------------------------------------------------------------ |
|
555 void CWBXMLSyncMLGenerator::AppendStartAtomicL( SmlAtomicPtr_t aContent ) |
|
556 { |
|
557 BeginElementL(EAtomic, ETrue); |
|
558 AppendStartAtomicOrSequenceL(aContent); |
|
559 } |
|
560 |
|
561 // ------------------------------------------------------------------------------------------------ |
|
562 void CWBXMLSyncMLGenerator::AppendEndAtomicL() |
|
563 { |
|
564 EndElementL(); // EAtomic |
|
565 } |
|
566 |
|
567 // ------------------------------------------------------------------------------------------------ |
|
568 void CWBXMLSyncMLGenerator::AppendStartSequenceL( SmlSequencePtr_t aContent ) |
|
569 { |
|
570 BeginElementL(ESequence, ETrue); |
|
571 AppendStartAtomicOrSequenceL(aContent); |
|
572 } |
|
573 |
|
574 // ------------------------------------------------------------------------------------------------ |
|
575 void CWBXMLSyncMLGenerator::AppendEndSequenceL() |
|
576 { |
|
577 EndElementL(); // ESequence |
|
578 } |
|
579 |
|
580 //1.2 CHANGES: Field |
|
581 // ------------------------------------------------------------------------------------------------ |
|
582 void CWBXMLSyncMLGenerator::AppendFieldL( SmlFieldPtr_t aContent ) |
|
583 { |
|
584 if( !aContent ) |
|
585 { |
|
586 return; |
|
587 } |
|
588 BeginElementL(EField, ETrue); |
|
589 AppendItemL( aContent->item ); |
|
590 EndElementL(); |
|
591 } |
|
592 |
|
593 //1.2 CHANGES: Record |
|
594 // ------------------------------------------------------------------------------------------------ |
|
595 void CWBXMLSyncMLGenerator::AppendRecordL( SmlRecordPtr_t aContent ) |
|
596 { |
|
597 if( !aContent ) |
|
598 { |
|
599 return; |
|
600 } |
|
601 BeginElementL(ERecord, ETrue); |
|
602 AppendItemL( aContent->item ); |
|
603 EndElementL(); |
|
604 } |
|
605 |
|
606 //1.2 CHANGES: Filter support |
|
607 // ------------------------------------------------------------------------------------------------ |
|
608 void CWBXMLSyncMLGenerator::AppendFilterL( SmlFilterPtr_t aContent ) |
|
609 { |
|
610 if( !aContent ) |
|
611 { |
|
612 return; |
|
613 } |
|
614 BeginElementL(EFilter, ETrue); |
|
615 AppendMetaL( aContent->meta ); |
|
616 AppendFieldL( aContent->field ); |
|
617 AppendRecordL( aContent->record ); |
|
618 |
|
619 AppendPCDataL( EFilterType, aContent->filterType ); |
|
620 EndElementL(); |
|
621 } |
|
622 //Changes end |
|
623 |
|
624 // ------------------------------------------------------------------------------------------------ |
|
625 void CWBXMLSyncMLGenerator::AppendPCDataL( TUint8 aElement, SmlPcdataPtr_t aContent, TInt aAmount ) |
|
626 { |
|
627 if( !aContent ) |
|
628 { |
|
629 return; |
|
630 } |
|
631 |
|
632 TInt contentLength(aAmount == -1 ? aContent->length : aAmount); |
|
633 |
|
634 if( aContent->extension == SML_EXT_METINF ) |
|
635 { |
|
636 BeginElementL(aElement, ETrue); |
|
637 DoAppendMetaL(SmlMetInfMetInfPtr_t(aContent->content)); |
|
638 EndElementL(); |
|
639 } |
|
640 //1.2 CHANGES: Property |
|
641 else if( aContent->extension == SML_EXT_DEVINFPROP ) |
|
642 { |
|
643 BeginElementL(aElement, ETrue); |
|
644 AppendPropertyListL(SmlDevInfPropertyListPtr_t(aContent->content)); |
|
645 EndElementL(); |
|
646 } |
|
647 // Changes end |
|
648 else if( aContent->contentType == SML_PCDATA_OPAQUE ) |
|
649 { |
|
650 AddElementL(aElement, TPtrC8((TUint8*)aContent->content, contentLength)); |
|
651 } |
|
652 else |
|
653 { |
|
654 AddElementL(aElement, TPtrC8((TUint8*)aContent->content, contentLength), EWBXMLContentFormatInlineString); |
|
655 } |
|
656 } |
|
657 |
|
658 // ------------------------------------------------------------------------------------------------ |
|
659 void CWBXMLSyncMLGenerator::AppendPCDataListL( TUint8 aElement, SmlPcdataListPtr_t aList ) |
|
660 { |
|
661 for( SmlPcdataListPtr_t p = aList; p && p->data; p = p->next ) |
|
662 { |
|
663 AppendPCDataL(aElement, p->data); |
|
664 } |
|
665 } |
|
666 |
|
667 // ------------------------------------------------------------------------------------------------ |
|
668 void CWBXMLSyncMLGenerator::FreeItemSizeAndMetaIfNeeded( SmlItemPtr_t aItem ) |
|
669 { |
|
670 if( aItem->meta ) |
|
671 { |
|
672 // if size element was created by generator -> delete it |
|
673 if( aItem->generatorFlags & SML_PE_SIZE_CREATED_BY_GENERATOR ) |
|
674 { |
|
675 aItem->generatorFlags &= ~SML_PE_SIZE_CREATED_BY_GENERATOR; |
|
676 delete SmlMetInfMetInfPtr_t(aItem->meta->content)->size; |
|
677 SmlMetInfMetInfPtr_t(aItem->meta->content)->size = 0; |
|
678 } |
|
679 |
|
680 // if meta element was created by generator -> delete it |
|
681 if( aItem->generatorFlags & SML_PE_META_CREATED_BY_GENERATOR ) |
|
682 { |
|
683 aItem->generatorFlags &= ~SML_PE_META_CREATED_BY_GENERATOR; |
|
684 delete aItem->meta; |
|
685 aItem->meta = 0; |
|
686 } |
|
687 } |
|
688 } |
|
689 |
|
690 // ------------------------------------------------------------------------------------------------ |
|
691 void CWBXMLSyncMLGenerator::AppendItemListL( SmlItemListPtr_t aList ) |
|
692 { |
|
693 iItemWasTruncated = EFalse; |
|
694 |
|
695 for( SmlItemListPtr_t p = aList, iItemIndex = 0; p && p->item; p = p->next, iItemIndex++ ) |
|
696 { |
|
697 Workspace()->BeginTransaction(); |
|
698 |
|
699 TRAPD(err, AppendItemL(p->item)); |
|
700 |
|
701 if( ((Workspace()->FreeSize() < KNSmlBufferSafeTreshold) || (err == KErrTooBig)) && iUseTruncation ) |
|
702 { |
|
703 // Rollback everything that was written into buffer |
|
704 Workspace()->Rollback(); |
|
705 |
|
706 SmlItemPtr_t item(p->item); |
|
707 |
|
708 // if this item does not have MoreData flag on --> put it on and add size to meta |
|
709 if( !(item->generatorFlags & SML_PE_SIZE_SENT) ) |
|
710 { |
|
711 if( !item->meta ) |
|
712 { |
|
713 item->generatorFlags |= SML_PE_META_CREATED_BY_GENERATOR; |
|
714 item->meta = new (ELeave) SmlPcdata_t(/*SML_PCDATA_EXTENSION, SML_EXT_METINF*/); |
|
715 item->meta->contentType = SML_PCDATA_EXTENSION; |
|
716 item->meta->extension = SML_EXT_METINF; |
|
717 item->meta->content = new (ELeave) SmlMetInfMetInf_t(); |
|
718 } |
|
719 |
|
720 if( !SmlMetInfMetInfPtr_t(item->meta->content)->size ) |
|
721 { |
|
722 item->generatorFlags |= SML_PE_SIZE_CREATED_BY_GENERATOR; |
|
723 SmlMetInfMetInfPtr_t(item->meta->content)->size = new (ELeave) SmlPcdata_t(); |
|
724 //1.2 CHANGES: Streaming |
|
725 if (iContentLength == -1) |
|
726 { |
|
727 iBuffer.Num(TInt(item->data->length)); |
|
728 } |
|
729 else |
|
730 { |
|
731 iBuffer.Num(iContentLength); |
|
732 iContentLength = -1; |
|
733 } |
|
734 //end changes |
|
735 SmlMetInfMetInfPtr_t(item->meta->content)->size->SetDataL(iBuffer); |
|
736 |
|
737 } |
|
738 } |
|
739 |
|
740 Workspace()->BeginTransaction(); |
|
741 TRAPD(err, AppendItemBeginL(item)); |
|
742 FreeItemSizeAndMetaIfNeeded(item); |
|
743 |
|
744 if( (err != KErrNone) || (Workspace()->FreeSize() < 3*KNSmlBufferSafeTreshold) ) |
|
745 { |
|
746 // Not enough space to add rest of item data --> Rollback changes |
|
747 Workspace()->Rollback(); |
|
748 User::Leave(KErrTooBig); |
|
749 } |
|
750 Workspace()->Commit(); |
|
751 |
|
752 // At this point size was really sent --> mark it down |
|
753 item->generatorFlags |= SML_PE_SIZE_SENT; |
|
754 |
|
755 // Set dataconsume length |
|
756 iDataConsumed = Workspace()->FreeSize() - 2*KNSmlBufferSafeTreshold - 1; |
|
757 |
|
758 // Now we write data in buffer |
|
759 AppendItemDataL(item, iDataConsumed); |
|
760 |
|
761 // End item nicely |
|
762 AppendItemEndL(ETrue); |
|
763 |
|
764 iItemWasTruncated = ETrue; |
|
765 break; |
|
766 } |
|
767 else if( err != KErrNone ) |
|
768 { |
|
769 // Other error --> remove changes |
|
770 Workspace()->Rollback(); |
|
771 User::Leave(err); |
|
772 } |
|
773 |
|
774 // Item added ok -> commit this item |
|
775 Workspace()->Commit(); |
|
776 } |
|
777 } |
|
778 |
|
779 // ------------------------------------------------------------------------------------------------ |
|
780 void CWBXMLSyncMLGenerator::AppendItemBeginL( SmlItemPtr_t aContent ) |
|
781 { |
|
782 BeginElementL(EItem, ETrue); |
|
783 AppendTargetL(aContent->target); |
|
784 AppendSourceL(aContent->source); |
|
785 //1.2 Changes: SourceTarget & sourceParent |
|
786 AppendSourceParentL(aContent->sourceParent); |
|
787 AppendTargetParentL(aContent->targetParent); |
|
788 //Changes end |
|
789 AppendMetaL(aContent->meta); |
|
790 } |
|
791 |
|
792 // ------------------------------------------------------------------------------------------------ |
|
793 void CWBXMLSyncMLGenerator::AppendItemEndL( TBool aMoreData ) |
|
794 { |
|
795 //if( aContent->flags & SmlMoreData_f ) |
|
796 if( aMoreData ) |
|
797 { |
|
798 BeginElementL(EMoreData); |
|
799 } |
|
800 EndElementL(); // EItem |
|
801 } |
|
802 |
|
803 // ------------------------------------------------------------------------------------------------ |
|
804 void CWBXMLSyncMLGenerator::AppendItemDataL( SmlItemPtr_t aContent, TInt aAmount ) |
|
805 { |
|
806 AppendPCDataL(EData, aContent->data, aAmount); |
|
807 } |
|
808 |
|
809 // ------------------------------------------------------------------------------------------------ |
|
810 void CWBXMLSyncMLGenerator::AppendItemL( SmlItemPtr_t aContent ) |
|
811 { |
|
812 AppendItemBeginL(aContent); |
|
813 AppendItemDataL(aContent); |
|
814 AppendItemEndL(); |
|
815 } |
|
816 |
|
817 // ------------------------------------------------------------------------------------------------ |
|
818 void CWBXMLSyncMLGenerator::AppendTargetRefListL( SmlTargetRefListPtr_t aList ) |
|
819 { |
|
820 AppendPCDataListL(ETargetRef, (SmlPcdataListPtr_t)aList); |
|
821 } |
|
822 |
|
823 // ------------------------------------------------------------------------------------------------ |
|
824 void CWBXMLSyncMLGenerator::AppendSourceRefListL( SmlSourceRefListPtr_t aList ) |
|
825 { |
|
826 AppendPCDataListL(ESourceRef, (SmlPcdataListPtr_t)aList); |
|
827 } |
|
828 |
|
829 // ------------------------------------------------------------------------------------------------ |
|
830 void CWBXMLSyncMLGenerator::AppendChalL( SmlChalPtr_t aContent ) |
|
831 { |
|
832 if( !aContent ) |
|
833 { |
|
834 return; |
|
835 } |
|
836 BeginElementL(EChal, ETrue); |
|
837 AppendMetaL(aContent->meta); |
|
838 EndElementL(); // EChal |
|
839 } |
|
840 |
|
841 // ------------------------------------------------------------------------------------------------ |
|
842 void CWBXMLSyncMLGenerator::AppendMapItemListL( SmlMapItemListPtr_t aList ) |
|
843 { |
|
844 for( SmlMapItemListPtr_t p = aList; p && p->mapItem; p = p->next ) |
|
845 { |
|
846 AppendMapItemL(p->mapItem); |
|
847 } |
|
848 } |
|
849 |
|
850 // ------------------------------------------------------------------------------------------------ |
|
851 void CWBXMLSyncMLGenerator::AppendMapItemL( SmlMapItemPtr_t aContent ) |
|
852 { |
|
853 BeginElementL(EMapItem, ETrue); |
|
854 AppendTargetL(aContent->target); |
|
855 AppendSourceL(aContent->source); |
|
856 EndElementL(); // EMapItem |
|
857 } |
|
858 |
|
859 // ------------------------------------------------------------------------------------------------ |
|
860 void CWBXMLSyncMLGenerator::AppendMetaL( SmlPcdataPtr_t aContent ) |
|
861 { |
|
862 if( !aContent ) |
|
863 { |
|
864 return; |
|
865 } |
|
866 SmlMetInfMetInfPtr_t meta = (SmlMetInfMetInfPtr_t)aContent->content; |
|
867 AppendMetaL(meta); |
|
868 } |
|
869 |
|
870 // ------------------------------------------------------------------------------------------------ |
|
871 void CWBXMLSyncMLGenerator::AppendMetaL( SmlMetInfMetInfPtr_t aMeta ) |
|
872 { |
|
873 BeginElementL(EMeta, ETrue); |
|
874 DoAppendMetaL(aMeta); |
|
875 EndElementL(); // EMeta |
|
876 } |
|
877 |
|
878 // ------------------------------------------------------------------------------------------------ |
|
879 void CWBXMLSyncMLGenerator::DoAppendMetaL( SmlMetInfMetInfPtr_t aMeta ) |
|
880 { |
|
881 SwitchCodePageL(ECodePageMetInf); |
|
882 AppendPCDataL(EFieldLevel, aMeta->fieldLevel); // 1.2 CHANGES: FieldLevel |
|
883 AppendPCDataL(EMetFormat, aMeta->format); |
|
884 AppendPCDataL(EMetType, aMeta->type); |
|
885 AppendPCDataL(EMetMark, aMeta->mark); |
|
886 AppendPCDataL(EMetSize, aMeta->size); |
|
887 |
|
888 if( aMeta->anchor ) |
|
889 { |
|
890 AppendMetAnchorL(aMeta->anchor); |
|
891 } |
|
892 |
|
893 AppendPCDataL(EMetVersion, aMeta->version); |
|
894 AppendPCDataL(EMetNextNonce, aMeta->nextnonce); |
|
895 AppendPCDataL(EMetMaxMsgSize, aMeta->maxmsgsize); |
|
896 AppendPCDataL(EMetMaxObjSize, aMeta->maxobjsize); |
|
897 |
|
898 if( aMeta->emi ) |
|
899 { |
|
900 AppendPCDataListL(EMetEMI, aMeta->emi); |
|
901 } |
|
902 if( aMeta->mem ) |
|
903 { |
|
904 AppendMetMemL(aMeta->mem); |
|
905 } |
|
906 |
|
907 SwitchCodePageL(ECodePageSyncML); |
|
908 } |
|
909 |
|
910 // ------------------------------------------------------------------------------------------------ |
|
911 void CWBXMLSyncMLGenerator::AppendMetMemL( SmlMetInfMemPtr_t aContent ) |
|
912 { |
|
913 BeginElementL(EMetMem, ETrue); |
|
914 AppendPCDataL(EMetSharedMem, aContent->shared); |
|
915 AppendPCDataL(EMetFreeMem, aContent->free); |
|
916 AppendPCDataL(EMetFreeID, aContent->freeid); |
|
917 EndElementL(); // EMetMem |
|
918 } |
|
919 |
|
920 // ------------------------------------------------------------------------------------------------ |
|
921 void CWBXMLSyncMLGenerator::AppendMetAnchorL( SmlMetInfAnchorPtr_t aContent ) |
|
922 { |
|
923 BeginElementL(EMetAnchor, ETrue); |
|
924 AppendPCDataL(EMetLast, aContent->last); |
|
925 AppendPCDataL(EMetNext, aContent->next); |
|
926 EndElementL(); // EMetAnchor |
|
927 } |
|
928 |
|
929 // 1.2 CHANGES: new elements propparam and property |
|
930 // ------------------------------------------------------------------------------------------------ |
|
931 void CWBXMLSyncMLGenerator::AppendPropParamL(SmlDevInfPropParamPtr_t aContent) |
|
932 { |
|
933 BeginElementL(EDevPropParam, ETrue); |
|
934 AppendPCDataL(EDevParamName, aContent->paramname); |
|
935 AppendPCDataL(EDevDataType, aContent->datatype); |
|
936 AppendPCDataListL(EDevValEnum, aContent->valenum); |
|
937 AppendPCDataL(EDevDisplayName, aContent->displayname); |
|
938 EndElementL(); // EDevPropParam |
|
939 } |
|
940 |
|
941 // ------------------------------------------------------------------------------------------------ |
|
942 void CWBXMLSyncMLGenerator::AppendPropParamListL(SmlDevInfPropParamListPtr_t aContent) |
|
943 { |
|
944 if (aContent && aContent->data) |
|
945 { |
|
946 for( SmlDevInfPropParamListPtr_t p = aContent; p && p->data; p = p->next ) |
|
947 { |
|
948 AppendPropParamL(p->data); |
|
949 } |
|
950 } |
|
951 } |
|
952 |
|
953 // ------------------------------------------------------------------------------------------------ |
|
954 void CWBXMLSyncMLGenerator::AppendPropertyL( SmlDevInfPropertyPtr_t aContent) |
|
955 { |
|
956 BeginElementL(EDevProperty, ETrue); |
|
957 AppendPCDataL(EDevPropName, aContent->propname); |
|
958 AppendPCDataL(EDevDataType, aContent->datatype); |
|
959 AppendPCDataL(EDevMaxOccur, aContent->maxoccur); |
|
960 AppendPCDataL(EDevMaxSize, aContent->maxsize); |
|
961 if (aContent->notruncate) |
|
962 { |
|
963 BeginElementL(EDevNoTruncate); |
|
964 } |
|
965 AppendPCDataListL(EDevValEnum, aContent->valenum); |
|
966 AppendPCDataL(EDevDisplayName, aContent->displayname); |
|
967 AppendPropParamListL(aContent->propparam); |
|
968 EndElementL(); // EDevProperty |
|
969 } |
|
970 |
|
971 |
|
972 // ------------------------------------------------------------------------------------------------ |
|
973 void CWBXMLSyncMLGenerator::AppendPropertyListL( SmlDevInfPropertyListPtr_t aContent ) |
|
974 { |
|
975 SwitchCodePageL(ECodePageDevInf); |
|
976 for( SmlDevInfPropertyListPtr_t p = aContent; p && p->data; p = p->next ) |
|
977 { |
|
978 AppendPropertyL(p->data); |
|
979 } |
|
980 SwitchCodePageL(ECodePageSyncML); |
|
981 } |
|
982 |
|
983 // Changes end |
|
984 |
|
985 // End of File |