|
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: for dbcaps streaming and converting to CSmlDataStoreFormat. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <stringpool.h> |
|
20 #include <s32strm.h> |
|
21 |
|
22 #include <nsmlunicodeconverter.h> |
|
23 #include "nsmldbcaps.h" |
|
24 #include "smldevinfdtd.h" |
|
25 #include "smlmetinfdtd.h" |
|
26 #include "smldevinftags.h" |
|
27 #include "NSmldbcapsSerializer.h" |
|
28 |
|
29 // ------------------------------------------------------------------------------------------------ |
|
30 // Constants |
|
31 // ------------------------------------------------------------------------------------------------ |
|
32 _LIT8( KNSmlFolderType, "application/vnd.omads-folder+xml" ); |
|
33 _LIT8( KNSmlFolderVersion, "1.2" ); |
|
34 |
|
35 const TInt KNSml32BitNumLength = 12; |
|
36 |
|
37 // ------------------------------------------------------------------------------------------------ |
|
38 // TNSmlDbCapsSerializer::CNSmlFilterCapabilityData::NewLC() |
|
39 // constructs CNSmlFilterCapabilityData |
|
40 // ------------------------------------------------------------------------------------------------ |
|
41 TNSmlDbCapsSerializer::CNSmlFilterCapabilityData* TNSmlDbCapsSerializer::CNSmlFilterCapabilityData::NewLC() |
|
42 { |
|
43 CNSmlFilterCapabilityData* self = new ( ELeave ) CNSmlFilterCapabilityData(); |
|
44 CleanupDeletePushL( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ------------------------------------------------------------------------------------------------ |
|
49 // TNSmlDbCapsSerializer::CNSmlFilterCapabilityData::~CNSmlFilterCapabilityData() |
|
50 // C++ destructor |
|
51 // ------------------------------------------------------------------------------------------------ |
|
52 TNSmlDbCapsSerializer::CNSmlFilterCapabilityData::~CNSmlFilterCapabilityData() |
|
53 { |
|
54 iFilterCapabilities.ResetAndDestroy(); |
|
55 iMimeVersion.Close(); |
|
56 iMimeType.Close(); |
|
57 |
|
58 for (TInt i = 0; i < iKeywordList.Count(); i++ ) |
|
59 { |
|
60 iKeywordList[i].Close(); |
|
61 } |
|
62 iKeywordList.Reset(); |
|
63 |
|
64 for (TInt i = 0; i < iPropertyList.Count(); i++) |
|
65 { |
|
66 iPropertyList[i].Close(); |
|
67 } |
|
68 iPropertyList.Reset(); |
|
69 } |
|
70 |
|
71 // ------------------------------------------------------------------------------------------------ |
|
72 // TNSmlDbCapsSerializer::CNSmlFilterCapabilityData::MakeL() |
|
73 // C++ destructor |
|
74 // ------------------------------------------------------------------------------------------------ |
|
75 void TNSmlDbCapsSerializer::CNSmlFilterCapabilityData::MakeL( |
|
76 const RStringPool& aStringPool, const CArrayFix<TNSmlFilterCapData>& aFilterInfoArr ) |
|
77 { |
|
78 |
|
79 if ( &aFilterInfoArr == NULL ) |
|
80 { |
|
81 return; |
|
82 } |
|
83 |
|
84 for( TInt i = 0 ; i < aFilterInfoArr.Count(); i++ ) |
|
85 { |
|
86 const TNSmlFilterCapData& fcd = aFilterInfoArr[i]; |
|
87 switch( fcd.iTag ) |
|
88 { |
|
89 case TNSmlFilterCapData::ECtType: |
|
90 iMimeType = aStringPool.OpenFStringL( fcd.iValue ); |
|
91 break; |
|
92 case TNSmlFilterCapData::EVerCt: |
|
93 iMimeVersion = aStringPool.OpenFStringL( fcd.iValue ); |
|
94 break; |
|
95 case TNSmlFilterCapData::EFilterKeyword: |
|
96 { |
|
97 RString tmprstr( aStringPool.OpenStringL( fcd.iValue ) ); |
|
98 CleanupClosePushL( tmprstr ); |
|
99 iKeywordList.AppendL( tmprstr ); |
|
100 CleanupStack::Pop(); //tmprstr |
|
101 } |
|
102 break; |
|
103 case TNSmlFilterCapData::EPropName: |
|
104 { |
|
105 RString tmprstr( aStringPool.OpenStringL( fcd.iValue ) ); |
|
106 CleanupClosePushL( tmprstr ); |
|
107 iPropertyList.AppendL( tmprstr ); |
|
108 CleanupStack::Pop(); //tmprstr |
|
109 } |
|
110 break; |
|
111 default: |
|
112 User::Leave( KErrArgument ); |
|
113 } |
|
114 } |
|
115 CSmlFilterCapability* fc = CSmlFilterCapability::NewLC(); |
|
116 |
|
117 fc->SetMimeTypeL( iMimeType ); |
|
118 fc->SetMimeVersionL( iMimeVersion ); |
|
119 fc->SetPropertiesListL( iPropertyList ); |
|
120 fc->SetKeyWordListL( iKeywordList ); |
|
121 |
|
122 iFilterCapabilities.AppendL( fc ); |
|
123 CleanupStack::Pop( fc ); |
|
124 } |
|
125 // ------------------------------------------------------------------------------------------------ |
|
126 // TNSmlDbCapsSerializer::CSmlDataFieldFromDbCaps::NewLC() |
|
127 // constructs CSmlDataField from parameters |
|
128 // ------------------------------------------------------------------------------------------------ |
|
129 CSmlDataField* TNSmlDbCapsSerializer::CNSmlDataFieldFromDbCaps::NewLC( |
|
130 const RStringPool& aStringPool, |
|
131 const TPtrC8& aDisplayName, |
|
132 const TPtrC8& aPropName, |
|
133 const TPtrC8& aDataType, |
|
134 const sml_pcdata_list_s* aValEnums ) |
|
135 { |
|
136 CNSmlDataFieldFromDbCaps* self = new ( ELeave ) CNSmlDataFieldFromDbCaps(); |
|
137 CleanupStack::PushL( self ); |
|
138 |
|
139 //display name |
|
140 NSmlUnicodeConverter::HBufC16InUnicodeLC( aDisplayName, self->iDisplayName ); |
|
141 CleanupStack::Pop( self->iDisplayName ); // self->iDisplayName |
|
142 |
|
143 //name |
|
144 self->iName = aStringPool.OpenStringL( aPropName ); |
|
145 |
|
146 //data type |
|
147 self->iDataType = aStringPool.OpenStringL( aDataType ); |
|
148 |
|
149 //value enums |
|
150 for ( ; aValEnums; aValEnums = aValEnums->next ) |
|
151 { |
|
152 const SmlPcdataPtr_t val = aValEnums->data; |
|
153 if ( val ) |
|
154 { |
|
155 RString tmprstr( aStringPool.OpenStringL( TNSmlDbCapsSerializer::SafePtr( val ) ) ); |
|
156 CleanupClosePushL( tmprstr ); |
|
157 self->iEnumValues.AppendL( tmprstr ); |
|
158 CleanupStack::Pop(); // tmprstr |
|
159 } |
|
160 } |
|
161 |
|
162 return self; |
|
163 } |
|
164 |
|
165 // ------------------------------------------------------------------------------------------------ |
|
166 // TNSmlDbCapsSerializer::CSmlDataPropertyParamFromDbCaps::NewLC() |
|
167 // constructs CSmlDataPropertyParam from parameters |
|
168 // ------------------------------------------------------------------------------------------------ |
|
169 CSmlDataPropertyParam* TNSmlDbCapsSerializer::CNSmlDataPropertyParamFromDbCaps::NewLC( |
|
170 const RStringPool& aStringPool, |
|
171 const sml_devinf_propparam_s* aDipp ) |
|
172 { |
|
173 CNSmlDataPropertyParamFromDbCaps* self = new ( ELeave ) CNSmlDataPropertyParamFromDbCaps(); |
|
174 CleanupStack::PushL( self ); |
|
175 |
|
176 //diplay name, property name, datatype, value enums -> iField |
|
177 self->iField = CNSmlDataFieldFromDbCaps::NewLC( aStringPool, |
|
178 TNSmlDbCapsSerializer::SafePtr( aDipp->displayname ), |
|
179 TNSmlDbCapsSerializer::SafePtr( aDipp->paramname ), |
|
180 TNSmlDbCapsSerializer::SafePtr( aDipp->datatype ), |
|
181 aDipp->valenum ); |
|
182 |
|
183 CleanupStack::Pop( self->iField ); // self->iField |
|
184 |
|
185 return self; |
|
186 } |
|
187 |
|
188 // ------------------------------------------------------------------------------------------------ |
|
189 // TNSmlDbCapsSerializer::CSmlDataPropertyFromDbCaps::NewLC() |
|
190 // constructs CSmlDataProperty from parameters |
|
191 // ------------------------------------------------------------------------------------------------ |
|
192 CSmlDataProperty* TNSmlDbCapsSerializer::CNSmlDataPropertyFromDbCaps::NewLC( |
|
193 const RStringPool& aStringPool, |
|
194 const sml_devinf_property_s* aDip ) |
|
195 { |
|
196 CNSmlDataPropertyFromDbCaps* self = new ( ELeave ) CNSmlDataPropertyFromDbCaps(); |
|
197 CleanupStack::PushL( self ); |
|
198 |
|
199 //max occur |
|
200 if( aDip->maxoccur ) |
|
201 { |
|
202 TLex8 lex( aDip->maxoccur->Data() ); |
|
203 User::LeaveIfError( lex.Val( self->iMaxOccur, EDecimal ) ); |
|
204 self->iFlags |= KSmlDataProperty_HasMaxOccur; |
|
205 } |
|
206 |
|
207 //max size |
|
208 if ( aDip->maxsize ) |
|
209 { |
|
210 TLex8 lex( aDip->maxsize->Data() ); |
|
211 User::LeaveIfError( lex.Val( self->iMaxSize, EDecimal ) ); |
|
212 self->iFlags |= KSmlDataProperty_HasMaxSize; |
|
213 } |
|
214 |
|
215 //options |
|
216 if ( aDip->notruncate ) |
|
217 { |
|
218 self->iFlags |= KSmlDataProperty_NoTruncate; |
|
219 } |
|
220 |
|
221 //diplay name, property name, datatype, value enums -> iField |
|
222 self->iField = CNSmlDataFieldFromDbCaps::NewLC( aStringPool, |
|
223 TNSmlDbCapsSerializer::SafePtr( aDip->displayname ), |
|
224 TNSmlDbCapsSerializer::SafePtr( aDip->propname ), |
|
225 TNSmlDbCapsSerializer::SafePtr( aDip->datatype ), |
|
226 aDip->valenum ); |
|
227 |
|
228 CleanupStack::Pop( self->iField ); // self->iField |
|
229 |
|
230 SmlDevInfPropParamListPtr_t dippl = aDip->propparam; |
|
231 |
|
232 for ( ; dippl; dippl = dippl->next ) |
|
233 { |
|
234 SmlDevInfPropParamPtr_t dipp = dippl->data; |
|
235 if ( dipp ) |
|
236 { |
|
237 CSmlDataPropertyParam* temppoint = CNSmlDataPropertyParamFromDbCaps::NewLC( aStringPool, dipp ); |
|
238 self->iParams.AppendL( temppoint ); |
|
239 CleanupStack::Pop(); // temppoint |
|
240 } |
|
241 } |
|
242 |
|
243 return self; |
|
244 } |
|
245 |
|
246 // ------------------------------------------------------------------------------------------------ |
|
247 // TNSmlDbCapsSerializer::CSmlFilterCapabilityFromDbCaps::NewLC() |
|
248 // constructs CSmlFilterCapability from parameters |
|
249 // ------------------------------------------------------------------------------------------------ |
|
250 CSmlFilterCapability* TNSmlDbCapsSerializer::CNSmlFilterCapabilityFromDbCaps::NewLC( |
|
251 const RStringPool& aStringPool, |
|
252 const sml_devinf_filtercap_s* aFtCap ) |
|
253 { |
|
254 CNSmlFilterCapabilityFromDbCaps* self = new ( ELeave ) CNSmlFilterCapabilityFromDbCaps(); |
|
255 CleanupStack::PushL( self ); |
|
256 |
|
257 //mime type |
|
258 self->iMimeType = aStringPool.OpenFStringL( TNSmlDbCapsSerializer::SafePtr( aFtCap->cttype ) ); |
|
259 |
|
260 //mime version |
|
261 self->iMimeVersion = aStringPool.OpenFStringL( TNSmlDbCapsSerializer::SafePtr( aFtCap->verct ) ); |
|
262 |
|
263 //keywords |
|
264 SmlPcdataListPtr_t keys = aFtCap->filterkeyword; |
|
265 for( ; keys; keys = keys->next ) |
|
266 { |
|
267 if ( keys->data ) |
|
268 { |
|
269 const TDesC8& key = keys->data->Data(); |
|
270 RString rkey( aStringPool.OpenStringL( key ) ); |
|
271 CleanupClosePushL( rkey ); |
|
272 self->iKeywordList.AppendL( rkey ); |
|
273 CleanupStack::Pop(); // rkey |
|
274 } |
|
275 } |
|
276 |
|
277 //properties |
|
278 SmlPcdataListPtr_t props = aFtCap->propname; |
|
279 for( ; props; props = props->next ) |
|
280 { |
|
281 if ( props->data ) |
|
282 { |
|
283 const TDesC8& prop = props->data->Data(); |
|
284 RString rprop( aStringPool.OpenStringL( prop ) ); |
|
285 CleanupClosePushL( rprop ); |
|
286 self->iPropertyList.AppendL( rprop ); |
|
287 CleanupStack::Pop(); // rkey |
|
288 } |
|
289 } |
|
290 |
|
291 return self; |
|
292 } |
|
293 |
|
294 // ------------------------------------------------------------------------------------------------ |
|
295 // TNSmlDbCapsSerializer::CSmlMimeFormatFromDbCaps::NewLC() |
|
296 // constructs CSmlMimeFormat from parameters |
|
297 // ------------------------------------------------------------------------------------------------ |
|
298 CSmlMimeFormat* TNSmlDbCapsSerializer::CNSmlMimeFormatFromDbCaps::NewLC( |
|
299 const RStringPool& aStringPool, |
|
300 const sml_devinf_ctcap_s& aDic ) |
|
301 { |
|
302 CNSmlMimeFormatFromDbCaps* self = new ( ELeave ) CNSmlMimeFormatFromDbCaps(); |
|
303 CleanupStack::PushL( self ); |
|
304 |
|
305 //mime type |
|
306 self->iMimeType = aStringPool.OpenFStringL( TNSmlDbCapsSerializer::SafePtr( aDic.cttype ) ); |
|
307 |
|
308 //mime version |
|
309 self->iMimeVersion = aStringPool.OpenFStringL( TNSmlDbCapsSerializer::SafePtr( aDic.verct ) ); |
|
310 |
|
311 //field level |
|
312 self->iFieldLevel = EFalse; |
|
313 if ( aDic.fieldlevel ) |
|
314 { |
|
315 self->iFieldLevel = ETrue; |
|
316 } |
|
317 |
|
318 //properties |
|
319 SmlDevInfPropertyListPtr_t dipl = aDic.property; |
|
320 for ( ; dipl; dipl = dipl->next ) |
|
321 { |
|
322 const SmlDevInfPropertyPtr_t dip = dipl->data; |
|
323 if ( dip ) |
|
324 { |
|
325 CSmlDataProperty *temppoint = CNSmlDataPropertyFromDbCaps::NewLC( aStringPool, dip ); |
|
326 self->iProperties.AppendL( temppoint ); |
|
327 CleanupStack::Pop(); // temppoint |
|
328 } |
|
329 } |
|
330 |
|
331 return self; |
|
332 } |
|
333 |
|
334 // ------------------------------------------------------------------------------------------------ |
|
335 // TNSmlDbCapsSerializer::CSmlDataStoreFormatFromDbCaps::NewLC() |
|
336 // constructs CSmlDataStoreFormat from parameters |
|
337 // ------------------------------------------------------------------------------------------------ |
|
338 CSmlDataStoreFormat* TNSmlDbCapsSerializer::CNSmlDataStoreFormatFromDbCaps::NewLC( |
|
339 const RStringPool& aStringPool, |
|
340 const CNSmlDbCaps& aDbCaps ) |
|
341 { |
|
342 CNSmlDataStoreFormatFromDbCaps* self = new ( ELeave ) CNSmlDataStoreFormatFromDbCaps(); |
|
343 CleanupStack::PushL( self ); |
|
344 const sml_devinf_datastore_s* dds = aDbCaps.Datastore(); |
|
345 |
|
346 //display name |
|
347 NSmlUnicodeConverter::HBufC16InUnicodeLC( |
|
348 TNSmlDbCapsSerializer::SafePtr( dds->displayname ), self->iDisplayName ); |
|
349 CleanupStack::Pop( self->iDisplayName ); // self->iDisplayName |
|
350 |
|
351 //sync types |
|
352 TSmlSyncTypeMask& synctype( self->iSyncTypeMask ); |
|
353 |
|
354 if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::ETwoWaySync ) ) |
|
355 { |
|
356 synctype.SetSupported( ESmlTwoWay ); |
|
357 } |
|
358 else |
|
359 { |
|
360 synctype.SetNotSupported( ESmlTwoWay ); |
|
361 } |
|
362 |
|
363 if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::EOneWaySyncFromServer ) ) |
|
364 { |
|
365 synctype.SetSupported( ESmlOneWayFromServer ); |
|
366 } |
|
367 else |
|
368 { |
|
369 synctype.SetNotSupported( ESmlOneWayFromServer ); |
|
370 } |
|
371 |
|
372 if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::EOneWaySyncFromClient ) ) |
|
373 { |
|
374 synctype.SetSupported( ESmlOneWayFromClient ); |
|
375 } |
|
376 else |
|
377 { |
|
378 synctype.SetNotSupported( ESmlOneWayFromClient ); |
|
379 } |
|
380 |
|
381 if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::ESlowTwoWaySync ) ) |
|
382 { |
|
383 synctype.SetSupported( ESmlSlowSync ); |
|
384 } |
|
385 else |
|
386 { |
|
387 synctype.SetNotSupported( ESmlSlowSync ); |
|
388 } |
|
389 |
|
390 if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::ERefreshSyncFromServer ) ) |
|
391 { |
|
392 synctype.SetSupported( ESmlRefreshFromServer ); |
|
393 } |
|
394 else |
|
395 { |
|
396 synctype.SetNotSupported( ESmlRefreshFromServer ); |
|
397 } |
|
398 |
|
399 if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::ERefreshSyncFromClient ) ) |
|
400 { |
|
401 synctype.SetSupported( ESmlRefreshFromClient ); |
|
402 } |
|
403 else |
|
404 { |
|
405 synctype.SetNotSupported( ESmlRefreshFromClient ); |
|
406 } |
|
407 |
|
408 if ( dds->dsmem ) |
|
409 { |
|
410 //max size |
|
411 if ( dds->dsmem->maxmem ) |
|
412 { |
|
413 TLex8 lex( dds->dsmem->maxmem->Data() ); |
|
414 User::LeaveIfError( lex.Val( self->iMaxSize, EDecimal ) ); |
|
415 self->iFlags |= KSmlDataStore_HasMaxSize; |
|
416 } |
|
417 |
|
418 //max items |
|
419 if ( dds->dsmem->maxid ) |
|
420 { |
|
421 TLex8 lex( dds->dsmem->maxid->Data() ); |
|
422 User::LeaveIfError( lex.Val( self->iMaxItems, EDecimal ) ); |
|
423 self->iFlags |= KSmlDataStore_HasMaxItems; |
|
424 } |
|
425 } |
|
426 |
|
427 //options |
|
428 if ( dds->supportHierarchicalSync ) |
|
429 { |
|
430 self->iFlags |= KSmlDataStore_Hierarchical; |
|
431 } |
|
432 |
|
433 //filter caps |
|
434 const sml_devinf_filtercaplist_s* filterList = aDbCaps.FilterCapsList(); |
|
435 |
|
436 for ( ; filterList; filterList = filterList->next ) |
|
437 { |
|
438 const SmlDevInfFilterCapPtr_t ft = filterList->data; |
|
439 if (ft) |
|
440 { |
|
441 CSmlFilterCapability* fc = CNSmlFilterCapabilityFromDbCaps::NewLC( aStringPool, ft ); |
|
442 self->iFilterCapabilities.AppendL( fc ); |
|
443 CleanupStack::Pop(); // fc |
|
444 } |
|
445 } |
|
446 |
|
447 // CSmlMimeFormat |
|
448 RPointerArray<CSmlMimeFormat> mimeFormatArray; |
|
449 CleanupClosePushL( mimeFormatArray ); |
|
450 // First search all mime types that server supports at receiving |
|
451 // RX-pref |
|
452 CSmlMimeFormat* tempFormatRX = CSmlMimeFormat::NewLC(); |
|
453 const TPtrC8& ctTypeRX = TNSmlDbCapsSerializer::SafePtr( dds->rxpref->cttype ); |
|
454 const TPtrC8& verCtRX = TNSmlDbCapsSerializer::SafePtr( dds->rxpref->verct ); |
|
455 if ( ctTypeRX.Compare( KNullDesC8 ) != 0 && verCtRX.Compare( KNullDesC8 ) != 0 ) |
|
456 { |
|
457 RStringF mimeFormatRX = aStringPool.OpenFStringL( ctTypeRX ); |
|
458 RStringF mimeVersionRX = aStringPool.OpenFStringL( verCtRX ); |
|
459 tempFormatRX->SetMimeTypeL( mimeFormatRX ); |
|
460 tempFormatRX->SetMimeVersionL( mimeVersionRX ); |
|
461 mimeFormatArray.AppendL( tempFormatRX ); |
|
462 CleanupStack::Pop(); // tempFormatRX |
|
463 } |
|
464 else |
|
465 { |
|
466 CleanupStack::PopAndDestroy(); // tempFormatRX |
|
467 } |
|
468 // RXs |
|
469 if ( dds ) |
|
470 { |
|
471 SmlDevInfXmitListPtr_t rx = dds->rx; |
|
472 for ( ; rx ; rx = rx->next ) |
|
473 { |
|
474 CSmlMimeFormat* tempFormat = CSmlMimeFormat::NewLC(); |
|
475 const TPtrC8& ctType = TNSmlDbCapsSerializer::SafePtr( rx->data->cttype ); |
|
476 const TPtrC8& verCt = TNSmlDbCapsSerializer::SafePtr( rx->data->verct ); |
|
477 if ( ctType.Compare( KNullDesC8 ) != 0 && verCt.Compare( KNullDesC8 ) != 0 ) |
|
478 { |
|
479 RStringF mimeFormat = aStringPool.OpenFStringL( ctType ); |
|
480 RStringF mimeVersion = aStringPool.OpenFStringL( verCt ); |
|
481 tempFormat->SetMimeTypeL( mimeFormat ); |
|
482 tempFormat->SetMimeVersionL( mimeVersion ); |
|
483 mimeFormatArray.AppendL( tempFormat ); |
|
484 CleanupStack::Pop(); // tempFormat |
|
485 } |
|
486 else |
|
487 { |
|
488 CleanupStack::PopAndDestroy(); // tempFormat |
|
489 } |
|
490 } |
|
491 } |
|
492 |
|
493 const sml_devinf_ctcaplist_s* ctCapList = dds->ctcap; |
|
494 if ( ctCapList == 0 ) |
|
495 { |
|
496 ctCapList = aDbCaps.CtCaps(); |
|
497 } |
|
498 // Then add CTCaps to correct mime types |
|
499 if ( ctCapList != 0 ) |
|
500 { |
|
501 for (; ctCapList; ctCapList = ctCapList->next ) |
|
502 { |
|
503 const SmlDevInfCtCapPtr_t ctCap = ctCapList->data; |
|
504 if ( ctCap->cttype->Data() == KNSmlFolderType ) |
|
505 { |
|
506 SmlDevInfPropertyListPtr_t dipl = ctCap->property; |
|
507 for ( ; dipl; dipl = dipl->next ) |
|
508 { |
|
509 const SmlDevInfPropertyPtr_t dip = dipl->data; |
|
510 if ( dip ) |
|
511 { |
|
512 CSmlDataProperty *temppoint = CNSmlDataPropertyFromDbCaps::NewLC( aStringPool, dip ); |
|
513 self->iFolderProperties.AppendL( temppoint ); |
|
514 CleanupStack::Pop(); // temppoint |
|
515 } |
|
516 } |
|
517 } |
|
518 else |
|
519 { |
|
520 for ( TInt j(0); j < mimeFormatArray.Count(); j++ ) |
|
521 { |
|
522 if ( mimeFormatArray[j]->MimeType().DesC().Compare( ctCap->cttype->Data() ) == 0 ) |
|
523 { |
|
524 // Mime version is only in rx-pref or in rx so it must be copied to new mime format |
|
525 CSmlMimeFormat* temppoint = CNSmlMimeFormatFromDbCaps::NewLC( aStringPool, *ctCap ); |
|
526 RStringF newMimeVersion = aStringPool.OpenFStringL( mimeFormatArray[j]->MimeVersion().DesC() ); |
|
527 temppoint->SetMimeVersionL( newMimeVersion ); |
|
528 delete mimeFormatArray[j]; |
|
529 mimeFormatArray[j] = NULL; |
|
530 mimeFormatArray[j] = temppoint; |
|
531 CleanupStack::Pop(); // temppoint |
|
532 } |
|
533 } |
|
534 } |
|
535 } |
|
536 } |
|
537 self->SetMimeFormatsL( mimeFormatArray ); |
|
538 mimeFormatArray.ResetAndDestroy(); |
|
539 CleanupStack::PopAndDestroy(); // mimeFormatArray |
|
540 return self; |
|
541 } |
|
542 |
|
543 // ------------------------------------------------------------------------------------------------ |
|
544 // TNSmlDbCapsSerializer::TNSmlDbCapsSerializer() |
|
545 // C++ constructor |
|
546 // ------------------------------------------------------------------------------------------------ |
|
547 EXPORT_C TNSmlDbCapsSerializer::TNSmlDbCapsSerializer() |
|
548 { |
|
549 } |
|
550 |
|
551 // ------------------------------------------------------------------------------------------------ |
|
552 // TNSmlDbCapsSerializer::InternalizeL( RReadStream& aDataStoreFormatStream ) |
|
553 // Internalizes from data store stream to dbcaps instance. |
|
554 // ------------------------------------------------------------------------------------------------ |
|
555 EXPORT_C CNSmlDbCaps* TNSmlDbCapsSerializer::InternalizeL( RReadStream& aDataStoreFormatStream ) const |
|
556 { |
|
557 CNSmlDbCaps* dbcaps = CNSmlDbCaps::NewLC(); |
|
558 |
|
559 RStringPool pool; |
|
560 pool.OpenL(); |
|
561 CleanupClosePushL( pool ); |
|
562 const CSmlDataStoreFormat* dsf = CSmlDataStoreFormat::NewLC( pool, aDataStoreFormatStream ); |
|
563 SetFromL( *dsf, *dbcaps ); |
|
564 |
|
565 CleanupStack::PopAndDestroy( 2 ); //dsf, pool |
|
566 CleanupStack::Pop(); // dbcaps |
|
567 return dbcaps; |
|
568 } |
|
569 |
|
570 // ------------------------------------------------------------------------------------------------ |
|
571 // TNSmlDbCapsSerializer::ExternalizeL() |
|
572 // externalizes from dbcaps to data store stream |
|
573 // ------------------------------------------------------------------------------------------------ |
|
574 EXPORT_C void TNSmlDbCapsSerializer::ExternalizeL( const CNSmlDbCaps& aDbCaps, RWriteStream& aDataStoreFormatStream ) const |
|
575 { |
|
576 RStringPool pool; |
|
577 pool.OpenL(); |
|
578 CleanupClosePushL( pool ); |
|
579 CSmlDataStoreFormat* dsf = CNSmlDataStoreFormatFromDbCaps::NewLC( pool, aDbCaps ); |
|
580 dsf->ExternalizeL( aDataStoreFormatStream ); |
|
581 CleanupStack::PopAndDestroy( 2 ); //dsf, pool |
|
582 } |
|
583 |
|
584 // ------------------------------------------------------------------------------------------------ |
|
585 // TNSmlDbCapsSerializer::ExternalizeL() |
|
586 // externalizes from dbcaps to data store stream |
|
587 // ------------------------------------------------------------------------------------------------ |
|
588 EXPORT_C void TNSmlDbCapsSerializer::ExternalizeL( const CNSmlDbCaps& aDbCaps, const CArrayFix<TNSmlFilterCapData>& aFilterInfoArr, RWriteStream& aDataStoreFormatStream ) const |
|
589 { |
|
590 RStringPool pool; |
|
591 pool.OpenL(); |
|
592 CleanupClosePushL( pool ); |
|
593 CSmlDataStoreFormat* dsf = CNSmlDataStoreFormatFromDbCaps::NewLC( pool, aDbCaps ); |
|
594 CNSmlFilterCapabilityData* fcd = CNSmlFilterCapabilityData::NewLC(); |
|
595 |
|
596 fcd->MakeL( pool, aFilterInfoArr ); |
|
597 dsf->SetFilterCapabilitiesL( fcd->iFilterCapabilities ); |
|
598 dsf->ExternalizeL( aDataStoreFormatStream ); |
|
599 |
|
600 CleanupStack::PopAndDestroy( 3 ); //fcd, dsf, pool |
|
601 } |
|
602 |
|
603 // ------------------------------------------------------------------------------------------------ |
|
604 // TNSmlDbCapsSerializer::SafePtr() |
|
605 // checks for null before returning data pointer |
|
606 // ------------------------------------------------------------------------------------------------ |
|
607 TPtrC8 TNSmlDbCapsSerializer::SafePtr( sml_pcdata_s* aPcdata ) |
|
608 { |
|
609 if ( aPcdata == NULL ) |
|
610 { |
|
611 return TPtrC8( NULL, 0 ); |
|
612 } |
|
613 else |
|
614 { |
|
615 return aPcdata->Data(); |
|
616 } |
|
617 } |
|
618 |
|
619 // ------------------------------------------------------------------------------------------------ |
|
620 // TNSmlDbCapsSerializer::SetFromL( const CSmlDataStoreFormat& aFrom, CNSmlDbCaps& aTo ) |
|
621 // copies and converts data from aFrom to aTo |
|
622 // ------------------------------------------------------------------------------------------------ |
|
623 void TNSmlDbCapsSerializer::SetFromL( const CSmlDataStoreFormat& aFrom, CNSmlDbCaps& aTo ) const |
|
624 { |
|
625 const TDesC& dispName( aFrom.DisplayName() ); |
|
626 HBufC8* dispName8 = NULL; |
|
627 NSmlUnicodeConverter::HBufC8InUTF8LC( dispName, dispName8 ); |
|
628 aTo.SetDisplayNameL( *dispName8 ); // display name |
|
629 CleanupStack::PopAndDestroy(); // dispName8 |
|
630 |
|
631 //max size |
|
632 _LIT8( KNSmlMaxGuidSize, "8" ); |
|
633 aTo.SetMaxGuidSizeL( KNSmlMaxGuidSize ); |
|
634 |
|
635 if ( aFrom.IsSupported( CSmlDataStoreFormat::EOptionHasMaxSize ) ) |
|
636 { |
|
637 TBuf8<KNSml32BitNumLength> maxSizeDes; |
|
638 maxSizeDes.Num( aFrom.MaxSize() ); |
|
639 aTo.SetMaxSizeL( maxSizeDes ); |
|
640 } |
|
641 |
|
642 if ( aFrom.IsSupported( CSmlDataStoreFormat::EOptionHasMaxItems ) ) |
|
643 { |
|
644 TBuf8<KNSml32BitNumLength> maxItemsDes; |
|
645 maxItemsDes.Num( aFrom.MaxItems() ); |
|
646 aTo.SetMaxItemsL( maxItemsDes ); |
|
647 } |
|
648 |
|
649 //sync types |
|
650 TSmlSyncTypeMask synctypes( aFrom.SyncTypes() ); |
|
651 |
|
652 if ( synctypes.IsSupported( ESmlTwoWay ) ) |
|
653 { |
|
654 aTo.SetSyncType( CNSmlDbCaps::ETwoWaySync ); |
|
655 } |
|
656 if ( synctypes.IsSupported( ESmlOneWayFromServer ) ) |
|
657 { |
|
658 aTo.SetSyncType( CNSmlDbCaps::EOneWaySyncFromServer ); |
|
659 } |
|
660 if ( synctypes.IsSupported( ESmlOneWayFromClient ) ) |
|
661 { |
|
662 aTo.SetSyncType( CNSmlDbCaps::EOneWaySyncFromClient ); |
|
663 } |
|
664 if ( synctypes.IsSupported( ESmlSlowSync ) ) |
|
665 { |
|
666 aTo.SetSyncType( CNSmlDbCaps::ESlowTwoWaySync ); |
|
667 } |
|
668 if ( synctypes.IsSupported( ESmlRefreshFromServer ) ) |
|
669 { |
|
670 aTo.SetSyncType( CNSmlDbCaps::ERefreshSyncFromServer ); |
|
671 } |
|
672 if ( synctypes.IsSupported( ESmlRefreshFromClient ) ) |
|
673 { |
|
674 aTo.SetSyncType( CNSmlDbCaps::ERefreshSyncFromClient ); |
|
675 } |
|
676 |
|
677 //options |
|
678 if ( aFrom.IsSupported( CSmlDataStoreFormat::EOptionHierarchial ) ) |
|
679 { |
|
680 aTo.SetSupportHierarchicalSyncL(); |
|
681 } |
|
682 |
|
683 //CNSmlCtCap / CSmlMimeFormat |
|
684 TInt rxPref( aFrom.MimeFormatRxPref() ); |
|
685 TInt txPref( aFrom.MimeFormatTxPref() ); |
|
686 |
|
687 for( TInt i = 0; i < aFrom.MimeFormatCount(); i++ ) |
|
688 { |
|
689 const CSmlMimeFormat& mf = aFrom.MimeFormat( i ); |
|
690 CNSmlCtCap* ctcap = aTo.AddCtCapLC(); |
|
691 SetFromL( mf, *ctcap ); |
|
692 CleanupStack::PopAndDestroy(); // ctcap |
|
693 |
|
694 const TDesC8& ctType = mf.MimeType().DesC(); |
|
695 const TDesC8& verCt = mf.MimeVersion().DesC(); |
|
696 |
|
697 if ( i == rxPref && i == txPref ) |
|
698 { |
|
699 aTo.SetRxPrefL( ctType, verCt ); |
|
700 aTo.SetTxPrefL( ctType, verCt ); |
|
701 } |
|
702 else if ( i == txPref ) |
|
703 { |
|
704 aTo.SetTxPrefL( ctType, verCt ); |
|
705 aTo.AddRxL( ctType, verCt ); |
|
706 } |
|
707 else if ( i == rxPref ) |
|
708 { |
|
709 aTo.SetRxPrefL( ctType, verCt ); |
|
710 aTo.AddTxL( ctType, verCt ); |
|
711 } |
|
712 else |
|
713 { |
|
714 aTo.AddRxL( ctType, verCt ); |
|
715 aTo.AddTxL( ctType, verCt ); |
|
716 } |
|
717 } |
|
718 |
|
719 // CNSmlCtCap / CSmlDataProperty |
|
720 // folder properties |
|
721 if ( aFrom.FolderPropertyCount() > 0 ) |
|
722 { |
|
723 aTo.AddRxL( KNSmlFolderType, KNSmlFolderVersion ); |
|
724 aTo.AddTxL( KNSmlFolderType, KNSmlFolderVersion ); |
|
725 |
|
726 CNSmlCtCap* ctcap = aTo.AddCtCapLC(); |
|
727 ctcap->SetCtTypeL( KNSmlFolderType ); |
|
728 ctcap->SetVerCtL( KNSmlFolderVersion ); |
|
729 |
|
730 for( TInt i = 0; i < aFrom.FolderPropertyCount(); i++ ) |
|
731 { |
|
732 const CSmlDataProperty& fp = aFrom.FolderProperty( i ); |
|
733 |
|
734 CNSmlDevInfProp* dip = ctcap->AddDevInfPropLC( fp.Field().Name().DesC() ); |
|
735 SetFromL( fp, *dip ); |
|
736 CleanupStack::PopAndDestroy(); // dip |
|
737 } |
|
738 CleanupStack::PopAndDestroy(); // ctcap |
|
739 } |
|
740 |
|
741 // CNSmlFilterCap / CSmlFilterCapability |
|
742 for( TInt i = 0; i < aFrom.FilterCapabilityCount(); i++ ) |
|
743 { |
|
744 const CSmlFilterCapability& fc = aFrom.FilterCapability( i ); |
|
745 const TDesC8& ctType = fc.MimeType().DesC(); |
|
746 const TDesC8& verCt = fc.MimeVersion().DesC(); |
|
747 CNSmlFilterCap* fcSet = aTo.AddFilterCapLC( ctType, verCt ); |
|
748 SetFromL( fc, *fcSet ); |
|
749 CleanupStack::PopAndDestroy(); // fcSet |
|
750 |
|
751 aTo.AddFilterRxL( ctType, verCt ); |
|
752 } |
|
753 } |
|
754 |
|
755 // ------------------------------------------------------------------------------------------------ |
|
756 // TNSmlDbCapsSerializer::SetFromL( const CSmlDataPropertyParam& aFrom, CNSmlPropParam& aTo ) |
|
757 // copies and converts data from aFrom to aTo |
|
758 // ------------------------------------------------------------------------------------------------ |
|
759 void TNSmlDbCapsSerializer::SetFromL( const CSmlDataPropertyParam& aFrom, CNSmlPropParam& aTo ) const |
|
760 { |
|
761 const CSmlDataField& field = aFrom.Field(); |
|
762 |
|
763 const TDesC& dispName( field.DisplayName() ); |
|
764 HBufC8* dispName8 = NULL; |
|
765 NSmlUnicodeConverter::HBufC8InUTF8LC( dispName, dispName8 ); |
|
766 aTo.SetDisplayNameL( *dispName8 ); // display name |
|
767 CleanupStack::PopAndDestroy(); // dispName8 |
|
768 |
|
769 //data type |
|
770 aTo.SetDataTypeL( field.DataType().DesC() ); |
|
771 |
|
772 //enum values |
|
773 for ( TInt i(0); i < field.EnumValueCount(); i++ ) |
|
774 { |
|
775 aTo.AddValEnumL( field.EnumValue( i ).DesC() ); |
|
776 } |
|
777 } |
|
778 |
|
779 // ------------------------------------------------------------------------------------------------ |
|
780 // TNSmlDbCapsSerializer::SetFromL( const CSmlDataProperty& aFrom, CNSmlDevInfProp& aTo ) |
|
781 // copies and converts data from aFrom to aTo |
|
782 // ------------------------------------------------------------------------------------------------ |
|
783 EXPORT_C void TNSmlDbCapsSerializer::SetFromL( const CSmlDataProperty& aFrom, CNSmlDevInfProp& aTo ) const |
|
784 { |
|
785 const CSmlDataField& field = aFrom.Field(); |
|
786 TBuf8<KNSml32BitNumLength> tdes; |
|
787 |
|
788 //max occur |
|
789 if ( aFrom.MaxOccur() != 0 ) |
|
790 { |
|
791 tdes.Num( aFrom.MaxOccur() ); |
|
792 aTo.SetMaxOccurL( tdes ); |
|
793 } |
|
794 |
|
795 //max size |
|
796 if ( aFrom.MaxSize() != 0 ) |
|
797 { |
|
798 tdes.Num( aFrom.MaxSize() ); |
|
799 aTo.SetMaxSizeL( tdes ); |
|
800 } |
|
801 |
|
802 //display name |
|
803 const TDesC& dispName( field.DisplayName() ); |
|
804 HBufC8* dispName8 = NULL; |
|
805 NSmlUnicodeConverter::HBufC8InUTF8LC( dispName, dispName8 ); |
|
806 aTo.SetDisplayNameL( *dispName8 ); // display name |
|
807 CleanupStack::PopAndDestroy(); // dispName8 |
|
808 |
|
809 //data type |
|
810 aTo.SetDataTypeL( field.DataType().DesC() ); |
|
811 |
|
812 //options |
|
813 if ( aFrom.IsSupported( CSmlDataProperty::EOptionNoTruncate ) ) |
|
814 { |
|
815 aTo.SetNoTruncateL(); |
|
816 } |
|
817 |
|
818 //param values |
|
819 for ( TInt i(0) ; i < aFrom.ParamCount(); i++ ) |
|
820 { |
|
821 const CSmlDataPropertyParam& dpp = aFrom.Param(i); |
|
822 CNSmlPropParam* pp = aTo.AddParamLC( dpp.Field().Name().DesC() ); |
|
823 SetFromL( dpp, *pp ); |
|
824 CleanupStack::PopAndDestroy(); // pp |
|
825 } |
|
826 |
|
827 //enum values |
|
828 for ( TInt i(0) ; i < field.EnumValueCount(); i++ ) |
|
829 { |
|
830 aTo.AddValEnumL( field.EnumValue( i ).DesC() ); |
|
831 } |
|
832 } |
|
833 |
|
834 // ------------------------------------------------------------------------------------------------ |
|
835 // TNSmlDbCapsSerializer::SetFromL( const CSmlMimeFormat& aFrom, CNSmlCtCap& aTo ) |
|
836 // copies and converts data from aFrom to aTo |
|
837 // ------------------------------------------------------------------------------------------------ |
|
838 void TNSmlDbCapsSerializer::SetFromL( const CSmlMimeFormat& aFrom, CNSmlCtCap& aTo ) const |
|
839 { |
|
840 //mime type |
|
841 aTo.SetCtTypeL( aFrom.MimeType().DesC() ); |
|
842 |
|
843 //mime version |
|
844 aTo.SetVerCtL( aFrom.MimeVersion().DesC() ); |
|
845 |
|
846 //field level |
|
847 if ( aFrom.FieldLevel() ) |
|
848 { |
|
849 aTo.SetFieldLevelL(); |
|
850 } |
|
851 |
|
852 //properties |
|
853 for ( TInt i(0);i < aFrom.PropertyCount(); i++ ) |
|
854 { |
|
855 const CSmlDataProperty& dp = aFrom.Property( i ); |
|
856 CNSmlDevInfProp* dip = aTo.AddDevInfPropLC( dp.Field().Name().DesC() ); |
|
857 SetFromL( dp, *dip ); |
|
858 CleanupStack::PopAndDestroy(); // dip |
|
859 } |
|
860 } |
|
861 // ------------------------------------------------------------------------------------------------ |
|
862 // TNSmlDbCapsSerializer::SetFromL( const CSmlFilterCapability& aFrom, CNSmlFilterCap& aTo ) |
|
863 // copies and converts data from aFrom to aTo |
|
864 // ------------------------------------------------------------------------------------------------ |
|
865 void TNSmlDbCapsSerializer::SetFromL( const CSmlFilterCapability& aFrom, CNSmlFilterCap& aTo ) const |
|
866 { |
|
867 //keywords |
|
868 for ( TInt i = 0; i < aFrom.KeywordCount(); i++ ) |
|
869 { |
|
870 aTo.AddFilterKeywordL( aFrom.Keyword(i).DesC() ); |
|
871 } |
|
872 |
|
873 //properties |
|
874 for ( TInt i = 0; i < aFrom.PropertyCount(); i++ ) |
|
875 { |
|
876 aTo.AddPropNameL( aFrom.PropertyName(i).DesC() ); |
|
877 } |
|
878 } |
|
879 |
|
880 // End of File |