|
1 /* |
|
2 * Copyright (c) 2002-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: Implementation of customization components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "TestDmDDFObject.h" |
|
23 #include "StifLogger.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 //extern ?external_data; |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 //extern ?external_function( ?arg_type,?arg_type ); |
|
30 |
|
31 // CONSTANTS |
|
32 //const ?type ?constant_var = ?constant; |
|
33 |
|
34 // MACROS |
|
35 //#define ?macro ?macro_def |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 //const ?type ?constant_var = ?constant; |
|
39 //#define ?macro_name ?macro_def |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 //enum ?declaration |
|
43 //typedef ?declaration |
|
44 |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 //?type ?function_name( ?arg_type, ?arg_type ); |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 //class ?FORWARD_CLASSNAME; |
|
50 |
|
51 // ============================= LOCAL FUNCTIONS =============================== |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 // ============================ MEMBER FUNCTIONS =============================== |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CTestDmDDFObject::CTestDmDDFObject |
|
60 // C++ default constructor can NOT contain any code, that |
|
61 // might leave. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CTestDmDDFObject::CTestDmDDFObject( CStifLogger *aLog ) |
|
65 : iName( 0 ) |
|
66 , iAccessTypes() |
|
67 , iDefaultValue( 0 ) |
|
68 , iDescription( 0 ) |
|
69 , iFormat( (TDFFormat)0 ) |
|
70 , iOccurence( (TOccurence)0 ) |
|
71 , iScope( (TScope)0 ) |
|
72 , iTitle ( 0 ) |
|
73 , iMimeType( 0 ) |
|
74 , iObjectGroup( EFalse ) |
|
75 // RPointerArray<CTestDmDDFObject> iChildren; |
|
76 , iLog( aLog ) |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CTestDmDDFObject::ConstructL |
|
82 // Symbian 2nd phase constructor can leave. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CTestDmDDFObject::ConstructL() |
|
86 { |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CTestDmDDFObject::NewL |
|
91 // Two-phased constructor. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CTestDmDDFObject* CTestDmDDFObject::NewL( CStifLogger *aLog ) |
|
95 { |
|
96 CTestDmDDFObject* self = CTestDmDDFObject::NewLC( aLog ); |
|
97 CleanupStack::Pop( self ); |
|
98 |
|
99 return self; |
|
100 } |
|
101 |
|
102 CTestDmDDFObject* CTestDmDDFObject::NewLC( CStifLogger *aLog ) |
|
103 { |
|
104 CTestDmDDFObject* self = new( ELeave ) CTestDmDDFObject( aLog ); |
|
105 |
|
106 CleanupStack::PushL( self ); |
|
107 self->ConstructL(); |
|
108 |
|
109 return self; |
|
110 } |
|
111 |
|
112 |
|
113 // Destructor |
|
114 CTestDmDDFObject::~CTestDmDDFObject() |
|
115 { |
|
116 delete iName; |
|
117 delete iDefaultValue; |
|
118 delete iDescription; |
|
119 delete iTitle; |
|
120 delete iMimeType; |
|
121 iChildren.ResetAndDestroy(); |
|
122 } |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CTestDmDDFObject::?member_function |
|
127 // ?implementation_description |
|
128 // (other items were commented in a header). |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 /*?type CTestDmDDFObject::?member_function( |
|
132 ?arg_type arg, |
|
133 ?arg_type arg ) |
|
134 { |
|
135 |
|
136 ?code |
|
137 |
|
138 } |
|
139 */ |
|
140 |
|
141 void CTestDmDDFObject::SetAccessTypesL( TSmlDmAccessTypes aAccessTypes ) |
|
142 { |
|
143 iLog->Log( _L8( "SetAccessTypesL, aAccessTypes=%d" ), aAccessTypes.GetACL() ); |
|
144 iAccessTypes = aAccessTypes; |
|
145 } |
|
146 |
|
147 void CTestDmDDFObject::SetDefaultValueL( const TDesC8& aDefaultValue ) |
|
148 { |
|
149 iLog->Log( _L8( "SetDefaultValueL, aDefaultValue='%S'" ), &aDefaultValue ); |
|
150 delete iDefaultValue; |
|
151 iDefaultValue = 0; |
|
152 iDefaultValue = aDefaultValue.AllocL(); |
|
153 } |
|
154 |
|
155 void CTestDmDDFObject::SetDescriptionL( const TDesC8& aDescription ) |
|
156 { |
|
157 iLog->Log( _L8( "SetDescriptionL, aDescription='%S'" ), &aDescription ); |
|
158 delete iDescription; |
|
159 iDescription = 0; |
|
160 iDescription = aDescription.AllocL(); |
|
161 } |
|
162 |
|
163 void CTestDmDDFObject::SetDFFormatL( TDFFormat aFormat ) |
|
164 { |
|
165 iLog->Log( _L8( "SetDFFormatL, aFormat=%d" ), aFormat ); |
|
166 iFormat = aFormat; |
|
167 } |
|
168 |
|
169 void CTestDmDDFObject::SetOccurenceL( TOccurence aOccurence ) |
|
170 { |
|
171 iLog->Log( _L8( "SetOccurenceL, aOccurence=%d" ), aOccurence ); |
|
172 iOccurence = aOccurence; |
|
173 } |
|
174 |
|
175 void CTestDmDDFObject::SetScopeL( TScope aScope ) |
|
176 { |
|
177 iLog->Log( _L8( "SetScopeL, aScope=%d" ), aScope ); |
|
178 iScope = aScope; |
|
179 } |
|
180 |
|
181 void CTestDmDDFObject::SetDFTitleL( const TDesC8& aTitle ) |
|
182 { |
|
183 iLog->Log( _L8( "SetDFTitleL, aTitle='%S'" ), &aTitle ); |
|
184 delete iTitle; |
|
185 iTitle = 0; |
|
186 iTitle = aTitle.AllocL(); |
|
187 } |
|
188 |
|
189 void CTestDmDDFObject::AddDFTypeMimeTypeL( const TDesC8& aMimeType ) |
|
190 { |
|
191 iLog->Log( _L8( "AddDFTypeMimeTypeL, aMimeType='%S'" ), &aMimeType ); |
|
192 delete iMimeType; |
|
193 iMimeType = 0; |
|
194 iMimeType = aMimeType.AllocL(); |
|
195 } |
|
196 |
|
197 void CTestDmDDFObject::SetAsObjectGroup() |
|
198 { |
|
199 iLog->Log( _L8( "SetAsObjectGroup, true" ) ); |
|
200 iObjectGroup = ETrue; |
|
201 } |
|
202 |
|
203 MSmlDmDDFObject& CTestDmDDFObject::AddChildObjectL(const TDesC8& aNodeName) |
|
204 { |
|
205 iLog->Log( _L8( "AddChildObjectL, aNodeName='%S'" ), &aNodeName ); |
|
206 CTestDmDDFObject* child = CTestDmDDFObject::NewLC( iLog ); //, aNodeName ); |
|
207 child->SetNameL( aNodeName ); |
|
208 iChildren.AppendL( child ); |
|
209 CleanupStack::Pop( child ); // Don't destroy |
|
210 return *child; |
|
211 } |
|
212 |
|
213 MSmlDmDDFObject& CTestDmDDFObject::AddChildObjectGroupL() |
|
214 { |
|
215 iLog->Log( _L8( "AddChildObjectGroupL, ''" ) ); |
|
216 CTestDmDDFObject* child = CTestDmDDFObject::NewLC( iLog ); //, KNullDesC ); |
|
217 child->SetAsObjectGroup(); |
|
218 iChildren.AppendL( child ); |
|
219 CleanupStack::Pop( child ); // Don't destroy |
|
220 return *child; |
|
221 } |
|
222 |
|
223 // Own functions |
|
224 |
|
225 void CTestDmDDFObject::SetNameL( const TDesC8& aName ) |
|
226 { |
|
227 delete iName; |
|
228 iName = 0; |
|
229 iName = aName.AllocL(); |
|
230 } |
|
231 |
|
232 void CTestDmDDFObject::DumpL( const TDesC8& aParentName, TBool aFullDump ) |
|
233 { |
|
234 TPtrC8 name( _L8("<X>") ); |
|
235 if (iName && iName->Length() > 0) |
|
236 { |
|
237 name.Set( *iName ); |
|
238 } |
|
239 |
|
240 HBufC8* fullName = HBufC8::NewLC( aParentName.Length() + name.Length() + 1 ); |
|
241 *fullName = aParentName; |
|
242 if (aParentName.Length() > 0 && aParentName[ aParentName.Length() - 1 ] != '/') |
|
243 { |
|
244 fullName->Des().Append( _L8("/")); |
|
245 } |
|
246 fullName->Des().Append( name ); |
|
247 |
|
248 /* Translate some members to text for dumping */ |
|
249 TBuf8<20> strAccessTypes; |
|
250 TUint8 accessTypes = iAccessTypes.GetACL(); |
|
251 if ((accessTypes & iAccessTypes.EAccessType_Add) != 0) |
|
252 { |
|
253 strAccessTypes.Append( _L8("A") ); |
|
254 } |
|
255 if ((accessTypes & iAccessTypes.EAccessType_Copy) != 0) |
|
256 { |
|
257 strAccessTypes.Append( _L8("C") ); |
|
258 } |
|
259 if ((accessTypes & iAccessTypes.EAccessType_Delete) != 0) |
|
260 { |
|
261 strAccessTypes.Append( _L8("D") ); |
|
262 } |
|
263 if ((accessTypes & iAccessTypes.EAccessType_Exec) != 0) |
|
264 { |
|
265 strAccessTypes.Append( _L8("E") ); |
|
266 } |
|
267 if ((accessTypes & iAccessTypes.EAccessType_Get) != 0) |
|
268 { |
|
269 strAccessTypes.Append( _L8("G") ); |
|
270 } |
|
271 if ((accessTypes & iAccessTypes.EAccessType_Replace) != 0) |
|
272 { |
|
273 strAccessTypes.Append( _L8("R") ); |
|
274 } |
|
275 |
|
276 TBuf8<20> strFormat; |
|
277 switch( iFormat ) |
|
278 { |
|
279 case EB64: |
|
280 strFormat = _L8("Base64"); |
|
281 break; |
|
282 case EBool: |
|
283 strFormat = _L8("Bool"); |
|
284 break; |
|
285 case EChr: |
|
286 strFormat = _L8("Chr"); |
|
287 break; |
|
288 case EInt: |
|
289 strFormat = _L8("Int"); |
|
290 break; |
|
291 case ENode: |
|
292 strFormat = _L8("Node"); |
|
293 break; |
|
294 case ENull: |
|
295 strFormat = _L8("Null"); |
|
296 break; |
|
297 case EXml: |
|
298 strFormat = _L8("Xml"); |
|
299 break; |
|
300 case EBin: |
|
301 strFormat = _L8("Bin"); |
|
302 break; |
|
303 default: |
|
304 break; |
|
305 } |
|
306 |
|
307 |
|
308 TBuf8<20> strOccurence; |
|
309 switch( iOccurence ) |
|
310 { |
|
311 case EOne: |
|
312 /** The node appears exactly once */ |
|
313 strOccurence = _L8("M:1"); |
|
314 break; |
|
315 case EZeroOrOne: |
|
316 /** The node is optional and may appear zero or once */ |
|
317 strOccurence = _L8("O:0-1"); |
|
318 break; |
|
319 case EZeroOrMore: |
|
320 /** The node is optional and may appear zero or more times */ |
|
321 strOccurence = _L8("O:0-*"); |
|
322 break; |
|
323 case EOneOrMore: |
|
324 /** The node is mandatory and may appear once or more times */ |
|
325 strOccurence = _L8("M:1-*"); |
|
326 break; |
|
327 case EZeroOrN: |
|
328 /** The node is optional and may appear between once and 'N' times */ |
|
329 strOccurence = _L8("O:1-N"); |
|
330 break; |
|
331 case EOneOrN: |
|
332 /** The node is mandatory and may appear between once and 'N' times */ |
|
333 strOccurence = _L8("M:1-N"); |
|
334 break; |
|
335 default: |
|
336 break; |
|
337 } |
|
338 |
|
339 |
|
340 TBuf8<20> strScope; |
|
341 switch( iScope) |
|
342 { |
|
343 case EPermanent: |
|
344 /** The node appears exactly once */ |
|
345 strScope = _L8("Permanent"); |
|
346 break; |
|
347 case EDynamic: |
|
348 /** The node is optional and may appear zero or once */ |
|
349 strScope = _L8("O:Dynamic"); |
|
350 break; |
|
351 default: |
|
352 break; |
|
353 } |
|
354 |
|
355 |
|
356 /* Dump main data */ |
|
357 if (aFullDump) |
|
358 { |
|
359 iLog->Log( _L8( "DDFObject: '%S'" ), fullName ); |
|
360 } |
|
361 else |
|
362 { |
|
363 iLog->Log( _L8( "DDFObject: '%S' (%S), %S, %S, %S" ), |
|
364 fullName, &strAccessTypes, &strFormat, &strOccurence, &strScope ); |
|
365 } |
|
366 |
|
367 /* Dump members */ |
|
368 if (aFullDump) |
|
369 { |
|
370 TPtrC8 empty( _L8( "<null>" ) ); |
|
371 #define CHK_NULL(a) ((a)==0?(TDesC8*)(&empty):(TDesC8*)(a)) |
|
372 |
|
373 iLog->Log( _L8( " iName=='%S'" ), iName ); |
|
374 iLog->Log( _L8( " iAccessTypes=%d (%S)" ), iAccessTypes.GetACL(), &strAccessTypes ); |
|
375 iLog->Log( _L8( " iDefaultValue='%S'" ), CHK_NULL(iDefaultValue)); |
|
376 iLog->Log( _L8( " iDescription='%S'" ), CHK_NULL(iDescription )); |
|
377 iLog->Log( _L8( " iFormat=%d (%S)" ), iFormat, &strFormat ); |
|
378 iLog->Log( _L8( " iOccurence=%d (%S)" ), iOccurence, &strOccurence ); |
|
379 iLog->Log( _L8( " iScope=%d (%S)" ), iScope, &strScope ); |
|
380 iLog->Log( _L8( " iTitle='%S'" ), CHK_NULL(iTitle )); |
|
381 iLog->Log( _L8( " iMimeType='%S'" ), CHK_NULL(iMimeType )); |
|
382 iLog->Log( _L8( "----------------------------------" ) ); |
|
383 } |
|
384 |
|
385 /* Dump children */ |
|
386 for (TInt i = 0 ; i < iChildren.Count() ; i++) |
|
387 { |
|
388 iChildren[i]->DumpL( *fullName, aFullDump ); |
|
389 } |
|
390 |
|
391 CleanupStack::PopAndDestroy( fullName ); |
|
392 } |
|
393 |
|
394 /* |
|
395 void CTestDmDDFObject::ExternalizeL(RWriteStream& aStream) const |
|
396 { |
|
397 X; |
|
398 aStream << *iName << eol; |
|
399 } |
|
400 */ |
|
401 |
|
402 const TDesC8& CTestDmDDFObject::Name() |
|
403 { |
|
404 return (iName != 0) ? *iName : KNullDesC8(); |
|
405 } |
|
406 |
|
407 TSmlDmAccessTypes CTestDmDDFObject::AccessTypes() |
|
408 { |
|
409 return iAccessTypes; |
|
410 } |
|
411 |
|
412 const TDesC8& CTestDmDDFObject::DefaultValue() |
|
413 { |
|
414 return (iDefaultValue != 0) ? *iDefaultValue : KNullDesC8(); |
|
415 } |
|
416 |
|
417 const TDesC8& CTestDmDDFObject::Description() |
|
418 { |
|
419 return (iDescription != 0) ? *iDescription : KNullDesC8(); |
|
420 } |
|
421 |
|
422 CTestDmDDFObject::TDFFormat CTestDmDDFObject::DFFormat() |
|
423 { |
|
424 return iFormat; |
|
425 } |
|
426 |
|
427 CTestDmDDFObject::TOccurence CTestDmDDFObject::Occurence() |
|
428 { |
|
429 return iOccurence; |
|
430 } |
|
431 |
|
432 CTestDmDDFObject::TScope CTestDmDDFObject::Scope() |
|
433 { |
|
434 return iScope; |
|
435 } |
|
436 |
|
437 const TDesC8& CTestDmDDFObject::DFTitle() |
|
438 { |
|
439 return (iTitle != 0) ? *iTitle : KNullDesC8(); |
|
440 } |
|
441 |
|
442 const TDesC8& CTestDmDDFObject::DFTypeMimeType() |
|
443 { |
|
444 return (iMimeType != 0) ? *iMimeType : KNullDesC8(); |
|
445 } |
|
446 |
|
447 TBool CTestDmDDFObject::ObjectGroup() |
|
448 { |
|
449 return iObjectGroup; |
|
450 } |
|
451 |
|
452 TInt CTestDmDDFObject::ChildObjectCount() |
|
453 { |
|
454 return iChildren.Count(); |
|
455 } |
|
456 |
|
457 CTestDmDDFObject& CTestDmDDFObject::ChildObject( TInt aIndex ) |
|
458 { |
|
459 return *iChildren[aIndex]; |
|
460 } |
|
461 |
|
462 CTestDmDDFObject* CTestDmDDFObject::FindChildObject( const TDesC8& aName ) |
|
463 { |
|
464 CTestDmDDFObject* foundObject = 0; |
|
465 |
|
466 for (TInt i = 0 ; i < iChildren.Count() ; i++) |
|
467 { |
|
468 if ( aName.CompareC( iChildren[i]->Name() ) == 0 ) |
|
469 { |
|
470 foundObject = iChildren[i]; |
|
471 break; |
|
472 } |
|
473 } |
|
474 |
|
475 return foundObject; |
|
476 } |
|
477 |
|
478 TInt CTestDmDDFObject::SubObjectsCount() |
|
479 { |
|
480 TInt count = 0; |
|
481 |
|
482 TInt i; |
|
483 for (i = 0 ; i < iChildren.Count() ; i++) |
|
484 { |
|
485 count += iChildren[i]->SubObjectsCount(); |
|
486 } |
|
487 count += i; |
|
488 |
|
489 return count; |
|
490 } |
|
491 |
|
492 /* |
|
493 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // ?function_name implements... |
|
497 // ?implementation_description. |
|
498 // Returns: ?value_1: ?description |
|
499 // ?value_n: ?description |
|
500 // ?description |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 ?type ?function_name( |
|
504 ?arg_type arg, // ?description |
|
505 ?arg_type arg ) // ?description |
|
506 { |
|
507 |
|
508 ?code |
|
509 |
|
510 } |
|
511 */ |
|
512 // End of File |