|
1 /* |
|
2 * Copyright (c) 2005-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "T_DataSdpElementBuilder.h" |
|
19 |
|
20 /*@{*/ |
|
21 //Parameters |
|
22 _LIT(KType, "type"); |
|
23 _LIT(KSizeDesc, "sizedesc"); |
|
24 _LIT(KData, "data"); |
|
25 _LIT(KUint, "uint"); |
|
26 _LIT(KInt, "int"); |
|
27 _LIT(KUUID, "uuid"); |
|
28 _LIT(KBool, "bool"); |
|
29 _LIT(KString, "string"); |
|
30 _LIT(KUrl, "url"); |
|
31 _LIT(KSdpIntBufObj, "sdpintbufobj"); |
|
32 |
|
33 //Commands |
|
34 _LIT(KCmdBuildUnknownL, "BuildUnknownL"); |
|
35 _LIT(KCmdBuildNilL, "BuildNilL"); |
|
36 _LIT(KCmdBuildUintL, "BuildUintL"); |
|
37 _LIT(KCmdBuildIntL, "BuildIntL"); |
|
38 _LIT(KCmdBuildUUIDL, "BuildUUIDL"); |
|
39 _LIT(KCmdBuildBooleanL, "BuildBooleanL"); |
|
40 _LIT(KCmdBuildStringL, "BuildStringL"); |
|
41 _LIT(KCmdBuildDESL, "BuildDESL"); |
|
42 _LIT(KCmdBuildDEAL, "BuildDEAL"); |
|
43 _LIT(KCmdStartListL, "StartListL"); |
|
44 _LIT(KCmdEndListL, "EndListL"); |
|
45 _LIT(KCmdBuildURLL, "BuildURLL"); |
|
46 _LIT(KCmdMSEB_ExtensionInterfaceL, "MSEB_ExtensionInterfaceL"); |
|
47 /*@}*/ |
|
48 |
|
49 |
|
50 ////////////////////////////////////////////////////////////////////// |
|
51 // Construction/Destruction |
|
52 ////////////////////////////////////////////////////////////////////// |
|
53 |
|
54 CT_DataSdpElementBuilder::CT_DataSdpElementBuilder(CDataWrapper& aDataWrapper) |
|
55 : iDataWrapper(aDataWrapper) |
|
56 { |
|
57 } |
|
58 |
|
59 CT_DataSdpElementBuilder::~CT_DataSdpElementBuilder() |
|
60 { |
|
61 } |
|
62 |
|
63 /** |
|
64 * Process a command read from the ini file |
|
65 * |
|
66 * @param aCommand The command to process |
|
67 * @param aSection The section in the ini containing data for the command |
|
68 * @param aAsyncErrorIndex Command index for async calls to return errors to |
|
69 * |
|
70 * @return ETrue if the command is processed |
|
71 * |
|
72 * @leave System wide error |
|
73 */ |
|
74 TBool CT_DataSdpElementBuilder::DoCommandL(MSdpElementBuilder& aElementBuilder, const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
75 { |
|
76 TBool ret = ETrue; |
|
77 |
|
78 if ( aCommand==KCmdBuildUnknownL ) |
|
79 { |
|
80 DoCmdBuildUnknownL(aElementBuilder, aSection); |
|
81 } |
|
82 else if ( aCommand==KCmdBuildNilL ) |
|
83 { |
|
84 DoCmdBuildNilL(aElementBuilder); |
|
85 } |
|
86 else if ( aCommand==KCmdBuildUintL ) |
|
87 { |
|
88 DoCmdBuildUintL(aElementBuilder, aSection); |
|
89 } |
|
90 else if ( aCommand==KCmdBuildIntL ) |
|
91 { |
|
92 DoCmdBuildIntL(aElementBuilder, aSection); |
|
93 } |
|
94 else if ( aCommand==KCmdBuildUUIDL ) |
|
95 { |
|
96 DoCmdBuildUUIDL(aElementBuilder, aSection); |
|
97 } |
|
98 else if ( aCommand==KCmdBuildBooleanL ) |
|
99 { |
|
100 DoCmdBuildBooleanL(aElementBuilder, aSection); |
|
101 } |
|
102 else if ( aCommand==KCmdBuildStringL ) |
|
103 { |
|
104 DoCmdBuildStringL(aElementBuilder, aSection); |
|
105 } |
|
106 else if ( aCommand==KCmdBuildDESL ) |
|
107 { |
|
108 DoCmdBuildDESL(aElementBuilder); |
|
109 } |
|
110 else if ( aCommand==KCmdBuildDEAL ) |
|
111 { |
|
112 DoCmdBuildDEAL(aElementBuilder); |
|
113 } |
|
114 else if ( aCommand==KCmdStartListL ) |
|
115 { |
|
116 DoCmdStartListL(aElementBuilder); |
|
117 } |
|
118 else if ( aCommand==KCmdEndListL ) |
|
119 { |
|
120 DoCmdEndListL(aElementBuilder); |
|
121 } |
|
122 else if ( aCommand==KCmdBuildURLL ) |
|
123 { |
|
124 DoCmdBuildURLL(aElementBuilder, aSection); |
|
125 } |
|
126 else if ( aCommand==KCmdMSEB_ExtensionInterfaceL ) |
|
127 { |
|
128 DoCmdMSEB_ExtensionInterfaceL(aElementBuilder); |
|
129 } |
|
130 else |
|
131 { |
|
132 ret=EFalse; |
|
133 } |
|
134 |
|
135 return ret; |
|
136 } |
|
137 |
|
138 /** |
|
139 Test MSdpElementBuilder::BuildUnknownL() |
|
140 */ |
|
141 void CT_DataSdpElementBuilder::DoCmdBuildUnknownL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
142 { |
|
143 TInt theValue; |
|
144 if( iDataWrapper.GetIntFromConfig(aSection, KType(), theValue) ) |
|
145 { |
|
146 TUint8 type = theValue; |
|
147 |
|
148 if( iDataWrapper.GetIntFromConfig(aSection, KSizeDesc(), theValue) ) |
|
149 { |
|
150 TUint8 sizeDesc = theValue; |
|
151 |
|
152 TPtrC theString; |
|
153 if( iDataWrapper.GetStringFromConfig(aSection, KData(), theString) ) |
|
154 { |
|
155 HBufC8* theString8 = HBufC8::NewLC(theString.Length()); |
|
156 theString8->Des().Copy(theString); |
|
157 TPtrC8 stringPtr=theString8->Des(); |
|
158 TRAPD(err, aElementBuilder.BuildUnknownL(type, sizeDesc, stringPtr)); |
|
159 if(err != KErrNone) |
|
160 { |
|
161 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildUnknownL failed with error %d"), err); |
|
162 iDataWrapper.SetError(err); |
|
163 } |
|
164 CleanupStack::PopAndDestroy(theString8); |
|
165 } |
|
166 else |
|
167 { |
|
168 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData()); |
|
169 iDataWrapper.SetBlockResult(EFail); |
|
170 } |
|
171 } |
|
172 else |
|
173 { |
|
174 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData()); |
|
175 iDataWrapper.SetBlockResult(EFail); |
|
176 } |
|
177 } |
|
178 else |
|
179 { |
|
180 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData()); |
|
181 iDataWrapper.SetBlockResult(EFail); |
|
182 } |
|
183 } |
|
184 |
|
185 |
|
186 /** |
|
187 Test MSdpElementBuilder::BuildNilL() |
|
188 */ |
|
189 void CT_DataSdpElementBuilder::DoCmdBuildNilL(MSdpElementBuilder& aElementBuilder) |
|
190 { |
|
191 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildNilL Call")); |
|
192 |
|
193 TRAPD(err, aElementBuilder.BuildNilL()); |
|
194 if(err != KErrNone) |
|
195 { |
|
196 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildNilL failed with error %d"), err); |
|
197 iDataWrapper.SetError(err); |
|
198 } |
|
199 } |
|
200 |
|
201 |
|
202 /** |
|
203 Test MSdpElementBuilder::BuildUintL() |
|
204 */ |
|
205 void CT_DataSdpElementBuilder::DoCmdBuildUintL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
206 { |
|
207 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildUintL Call")); |
|
208 |
|
209 TPtrC theString; |
|
210 TPtrC sdpIntBufName; |
|
211 TBool foundParameter=EFalse; |
|
212 if( iDataWrapper.GetStringFromConfig(aSection, KUint(), theString) ) |
|
213 { |
|
214 foundParameter=ETrue; |
|
215 HBufC8* theString8 = HBufC8::NewLC(theString.Length()); |
|
216 theString8->Des().Copy(theString); |
|
217 TPtrC8 stringPtr = theString8->Des(); |
|
218 TRAPD(err, aElementBuilder.BuildUintL(stringPtr)); |
|
219 if(err != KErrNone) |
|
220 { |
|
221 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildUintL failed with error %d"), err); |
|
222 iDataWrapper.SetError(err); |
|
223 } |
|
224 CleanupStack::PopAndDestroy(theString8); |
|
225 } |
|
226 |
|
227 if ( iDataWrapper.GetStringFromConfig(aSection, KSdpIntBufObj(), sdpIntBufName) ) |
|
228 { |
|
229 foundParameter=ETrue; |
|
230 TAny* object=iDataWrapper.GetDataObjectL(sdpIntBufName); |
|
231 TSdpIntBuf<TUint8>* sdpIntBuf = static_cast<TSdpIntBuf<TUint8>*>(object); |
|
232 TSdpIntBuf<TUint8> sdpIntObj = *sdpIntBuf; |
|
233 const TUint8 *tmp=&sdpIntObj[0]; |
|
234 TPtrC8 bufferPtr(tmp, sdpIntObj.Length()); |
|
235 TRAPD(err, aElementBuilder.BuildUintL(bufferPtr)); |
|
236 if ( err!=KErrNone ) |
|
237 { |
|
238 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildUintL failed with error %d"), err); |
|
239 iDataWrapper.SetError(err); |
|
240 } |
|
241 } |
|
242 |
|
243 if (!foundParameter) |
|
244 { |
|
245 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KSdpIntBufObj()); |
|
246 iDataWrapper.SetBlockResult(EFail); |
|
247 } |
|
248 } |
|
249 |
|
250 |
|
251 /** |
|
252 Test MSdpElementBuilder::BuildIntL() |
|
253 */ |
|
254 void CT_DataSdpElementBuilder::DoCmdBuildIntL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
255 { |
|
256 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildIntL Call")); |
|
257 |
|
258 TPtrC theString; |
|
259 TPtrC sdpIntBufName; |
|
260 TBool foundParameter=EFalse; |
|
261 if( iDataWrapper.GetStringFromConfig(aSection, KInt(), theString) ) |
|
262 { |
|
263 foundParameter=ETrue; |
|
264 HBufC8* theString8 = HBufC8::NewLC(theString.Length()); |
|
265 theString8->Des().Copy(theString); |
|
266 TPtrC8 stringPtr = theString8->Des(); |
|
267 TRAPD(err, aElementBuilder.BuildIntL(stringPtr)); |
|
268 if(err != KErrNone) |
|
269 { |
|
270 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildIntL failed with error %d"), err); |
|
271 iDataWrapper.SetError(err); |
|
272 } |
|
273 CleanupStack::PopAndDestroy(theString8); |
|
274 } |
|
275 |
|
276 if ( iDataWrapper.GetStringFromConfig(aSection, KSdpIntBufObj(), sdpIntBufName) ) |
|
277 { |
|
278 foundParameter=ETrue; |
|
279 TAny* object=iDataWrapper.GetDataObjectL(sdpIntBufName); |
|
280 TSdpIntBuf<TUint8>* sdpIntBuf = static_cast<TSdpIntBuf<TUint8>*>(object); |
|
281 TSdpIntBuf<TUint8> sdpIntObj = *sdpIntBuf; |
|
282 const TUint8 *tmp=&sdpIntObj[0]; |
|
283 TPtrC8 bufferPtr(tmp, sdpIntObj.Length()); |
|
284 TRAPD(err, aElementBuilder.BuildIntL(bufferPtr)); |
|
285 if ( err!=KErrNone ) |
|
286 { |
|
287 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildIntL failed with error %d"), err); |
|
288 iDataWrapper.SetError(err); |
|
289 } |
|
290 } |
|
291 |
|
292 if (!foundParameter) |
|
293 { |
|
294 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KSdpIntBufObj()); |
|
295 iDataWrapper.SetBlockResult(EFail); |
|
296 } |
|
297 } |
|
298 |
|
299 |
|
300 /** |
|
301 Test MSdpElementBuilder::BuildUUIDL() |
|
302 */ |
|
303 void CT_DataSdpElementBuilder::DoCmdBuildUUIDL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
304 { |
|
305 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildUUIDL Call")); |
|
306 |
|
307 TInt theValue; |
|
308 if( iDataWrapper.GetIntFromConfig(aSection, KUUID(), theValue) ) |
|
309 { |
|
310 TUUID theUUID(theValue); |
|
311 |
|
312 TRAPD(err, aElementBuilder.BuildUUIDL(theUUID)); |
|
313 if(err != KErrNone) |
|
314 { |
|
315 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildUUIDL failed with error %d"), err); |
|
316 iDataWrapper.SetError(err); |
|
317 } |
|
318 } |
|
319 else |
|
320 { |
|
321 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KUUID()); |
|
322 iDataWrapper.SetBlockResult(EFail); |
|
323 } |
|
324 } |
|
325 |
|
326 |
|
327 /** |
|
328 Test MSdpElementBuilder::BuildBooleanL() |
|
329 */ |
|
330 void CT_DataSdpElementBuilder::DoCmdBuildBooleanL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
331 { |
|
332 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildBooleanL Call")); |
|
333 |
|
334 TBool boolValue = 0; |
|
335 if( iDataWrapper.GetBoolFromConfig(aSection, KBool(), boolValue) ) |
|
336 { |
|
337 TRAPD(err, aElementBuilder.BuildBooleanL(boolValue)); |
|
338 if(err != KErrNone) |
|
339 { |
|
340 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildBooleanL failed with error %d"), err); |
|
341 iDataWrapper.SetError(err); |
|
342 } |
|
343 } |
|
344 else |
|
345 { |
|
346 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KBool()); |
|
347 iDataWrapper.SetBlockResult(EFail); |
|
348 } |
|
349 } |
|
350 |
|
351 |
|
352 /** |
|
353 Test MSdpElementBuilder::BuildStringL() |
|
354 */ |
|
355 void CT_DataSdpElementBuilder::DoCmdBuildStringL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
356 { |
|
357 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildStringL Call")); |
|
358 |
|
359 TPtrC theString; |
|
360 if( iDataWrapper.GetStringFromConfig(aSection, KString(), theString) ) |
|
361 { |
|
362 HBufC8* theString8=HBufC8::NewLC(theString.Length()); |
|
363 theString8->Des().Copy(theString); |
|
364 TPtrC8 stringPtr = theString8->Des(); |
|
365 TRAPD(err, aElementBuilder.BuildStringL(stringPtr)); |
|
366 if(err != KErrNone) |
|
367 { |
|
368 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildStringL failed with error %d"), err); |
|
369 iDataWrapper.SetError(err); |
|
370 } |
|
371 CleanupStack::PopAndDestroy(theString8); |
|
372 } |
|
373 else |
|
374 { |
|
375 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KString()); |
|
376 iDataWrapper.SetBlockResult(EFail); |
|
377 } |
|
378 } |
|
379 |
|
380 /** |
|
381 Test MSdpElementBuilder::BuildDESL() |
|
382 */ |
|
383 void CT_DataSdpElementBuilder::DoCmdBuildDESL(MSdpElementBuilder& aElementBuilder) |
|
384 { |
|
385 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildDESL Call")); |
|
386 |
|
387 TRAPD(err, aElementBuilder.BuildDESL()); |
|
388 if(err != KErrNone) |
|
389 { |
|
390 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildDESL failed with error %d"), err); |
|
391 iDataWrapper.SetError(err); |
|
392 } |
|
393 } |
|
394 |
|
395 |
|
396 /** |
|
397 Test MSdpElementBuilder::BuildDEAL() |
|
398 */ |
|
399 void CT_DataSdpElementBuilder::DoCmdBuildDEAL(MSdpElementBuilder& aElementBuilder) |
|
400 { |
|
401 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildDEAL Call")); |
|
402 |
|
403 TRAPD(err, aElementBuilder.BuildDEAL()); |
|
404 if(err != KErrNone) |
|
405 { |
|
406 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildDEAL failed with error %d"), err); |
|
407 iDataWrapper.SetError(err); |
|
408 } |
|
409 } |
|
410 |
|
411 |
|
412 /** |
|
413 Test MSdpElementBuilder::StartListL() |
|
414 */ |
|
415 void CT_DataSdpElementBuilder::DoCmdStartListL(MSdpElementBuilder& aElementBuilder) |
|
416 { |
|
417 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder StartListL Call")); |
|
418 |
|
419 TRAPD(err, aElementBuilder.StartListL()); |
|
420 if(err != KErrNone) |
|
421 { |
|
422 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder StartListL failed with error %d"), err); |
|
423 iDataWrapper.SetError(err); |
|
424 } |
|
425 } |
|
426 |
|
427 |
|
428 /** |
|
429 Test MSdpElementBuilder::EndListL() |
|
430 */ |
|
431 void CT_DataSdpElementBuilder::DoCmdEndListL(MSdpElementBuilder& aElementBuilder) |
|
432 { |
|
433 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder EndListL Call")); |
|
434 |
|
435 TRAPD(err, aElementBuilder.EndListL()); |
|
436 if(err != KErrNone) |
|
437 { |
|
438 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder EndListL failed with error %d"), err); |
|
439 iDataWrapper.SetError(err); |
|
440 } |
|
441 } |
|
442 |
|
443 |
|
444 /** |
|
445 Test MSdpElementBuilder::BuildURLL() |
|
446 */ |
|
447 void CT_DataSdpElementBuilder::DoCmdBuildURLL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) |
|
448 { |
|
449 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildURLL Call")); |
|
450 |
|
451 TPtrC theString; |
|
452 if( iDataWrapper.GetStringFromConfig(aSection, KUrl(), theString) ) |
|
453 { |
|
454 HBufC8* theString8=HBufC8::NewLC(theString.Length()); |
|
455 theString8->Des().Copy(theString); |
|
456 TPtrC8 stringPtr = theString8->Des(); |
|
457 TRAPD(err, aElementBuilder.BuildURLL(stringPtr)); |
|
458 if(err != KErrNone) |
|
459 { |
|
460 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildURLL failed with error %d"), err); |
|
461 iDataWrapper.SetError(err); |
|
462 } |
|
463 CleanupStack::PopAndDestroy(theString8); |
|
464 } |
|
465 else |
|
466 { |
|
467 iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KUrl()); |
|
468 iDataWrapper.SetBlockResult(EFail); |
|
469 } |
|
470 } |
|
471 |
|
472 |
|
473 /** |
|
474 Test MSdpElementBuilder::MSEB_ExtensionInterfaceL() |
|
475 */ |
|
476 void CT_DataSdpElementBuilder::DoCmdMSEB_ExtensionInterfaceL(MSdpElementBuilder& aElementBuilder) |
|
477 { |
|
478 iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder MSEB_ExtensionInterfaceL Call")); |
|
479 |
|
480 void* tmpVoid; |
|
481 TRAPD(err, aElementBuilder.MSEB_ExtensionInterfaceL(KNullUid, tmpVoid)); |
|
482 if(err != KErrNone) |
|
483 { |
|
484 iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder MSEB_ExtensionInterfaceL failed with error %d"), err); |
|
485 iDataWrapper.SetError(err); |
|
486 } |
|
487 } |