|
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 |
|
19 #include "T_BTSockAddrData.h" |
|
20 #include "T_BTServiceSecurityData.h" |
|
21 #include "T_BTDevAddrData.h" |
|
22 |
|
23 |
|
24 //Constant Literals used. |
|
25 |
|
26 //Parameters |
|
27 _LIT(KFamily, "family"); |
|
28 _LIT(KBTAddr, "btaddr"); |
|
29 _LIT(KUserlen, "userlen"); |
|
30 _LIT(KPort, "port"); |
|
31 _LIT(KTSockAddr, "sockaddr"); |
|
32 _LIT(KTBTSockAddr, "btsockaddr"); |
|
33 _LIT(KSecurity, "security"); |
|
34 _LIT(KExpectedCompResult, "exp_cmp_res"); |
|
35 _LIT(KTBTDevAddr, "tbtdevaddr"); |
|
36 |
|
37 _LIT(KHexBTAddrL, "hex_btaddr_l"); |
|
38 _LIT(KHexBTAddrR, "hex_btaddr_r"); |
|
39 |
|
40 _LIT(KSection, "section"); |
|
41 _LIT(KConfigHexBTAddrL, "hex_btaddr_l"); |
|
42 _LIT(KConfigHexBTAddrR, "hex_btaddr_r"); |
|
43 |
|
44 // TBTSockAddr |
|
45 _LIT(KCmdConstruct, "Construct"); |
|
46 _LIT(KCmdCastFromTSockAddr, "CastFromTSockAddr"); |
|
47 _LIT(KCmdSetBTAddr, "SetBTAddr"); |
|
48 _LIT(KCmdBTAddr, "BTAddr"); |
|
49 _LIT(KCmdSetSecurity, "SetSecurity"); |
|
50 _LIT(KCmdBTSecurity, "BTSecurity"); |
|
51 _LIT(KCmdSetFamily, "SetFamily"); |
|
52 _LIT(KCmdFamily, "Family"); |
|
53 _LIT(KCmdSetPort, "SetPort"); |
|
54 _LIT(KCmdPort, "Port"); |
|
55 _LIT(KCmdCmpPort, "CmpPort"); |
|
56 _LIT(KCmdGetUserLen, "GetUserLen"); |
|
57 _LIT(KCmdDistructor, "~"); |
|
58 |
|
59 //Use of Protected methods |
|
60 _LIT(KCmdPROTECTEDSetUserLen, "PROTECTED-SetUserLen"); |
|
61 _LIT(KCmdPROTECTEDUserPtr, "PROTECTED-UserPtr"); |
|
62 _LIT(KCmdPROTECTEDEndBTSockAddrPtr, "PROTECTED-EndBTSockAddrPtr"); |
|
63 |
|
64 /*@}*/ |
|
65 |
|
66 CT_BTSockAddrData* CT_BTSockAddrData::NewL() |
|
67 { |
|
68 CT_BTSockAddrData* ret=new (ELeave) CT_BTSockAddrData(); |
|
69 return ret; |
|
70 } |
|
71 |
|
72 CT_BTSockAddrData::CT_BTSockAddrData() |
|
73 : iTBTSockAddr(NULL), iTBTSockAddrOwned(EFalse) |
|
74 { |
|
75 } |
|
76 |
|
77 CT_BTSockAddrData::~CT_BTSockAddrData() |
|
78 { |
|
79 Cleanup(); |
|
80 } |
|
81 |
|
82 void CT_BTSockAddrData::Cleanup() |
|
83 { |
|
84 if (iTBTSockAddrOwned) |
|
85 { |
|
86 delete iTBTSockAddr; |
|
87 } |
|
88 iTBTSockAddr=NULL; |
|
89 } |
|
90 |
|
91 TBool CT_BTSockAddrData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
92 { |
|
93 TBool retVal=ETrue; |
|
94 |
|
95 if ( aCommand==KCmdConstruct ) |
|
96 { |
|
97 TBTSockAddrConstruct(aSection); |
|
98 } |
|
99 else if ( aCommand==KCmdCastFromTSockAddr ) |
|
100 { |
|
101 TBTSockAddrCastFromTSockAddr(aSection); |
|
102 } |
|
103 else if ( aCommand==KCmdSetBTAddr ) |
|
104 { |
|
105 TBTSockAddrSetBTAddr(aSection); |
|
106 } |
|
107 else if ( aCommand==KCmdBTAddr ) |
|
108 { |
|
109 TBTSockAddrBTAddr(aSection); |
|
110 } |
|
111 else if ( aCommand==KCmdSetSecurity ) |
|
112 { |
|
113 TBTSockAddrSetSecurity(aSection); |
|
114 } |
|
115 else if ( aCommand==KCmdBTSecurity ) |
|
116 { |
|
117 TBTSockAddrBTSecurity(aSection); |
|
118 } |
|
119 else if ( aCommand==KCmdSetFamily ) |
|
120 { |
|
121 TBTSockAddrSetFamily(aSection); |
|
122 } |
|
123 else if ( aCommand==KCmdFamily ) |
|
124 { |
|
125 TBTSockAddrFamily(aSection); |
|
126 } |
|
127 else if ( aCommand==KCmdSetPort ) |
|
128 { |
|
129 TBTSockAddrSetPort(aSection); |
|
130 } |
|
131 else if ( aCommand==KCmdPort ) |
|
132 { |
|
133 TBTSockAddrPort(aSection); |
|
134 } |
|
135 else if ( aCommand==KCmdCmpPort ) |
|
136 { |
|
137 TBTSockAddrCmpPort(aSection); |
|
138 } |
|
139 else if ( aCommand==KCmdGetUserLen ) |
|
140 { |
|
141 TBTSockAddrGetUserLen(aSection); |
|
142 } |
|
143 else if ( aCommand==KCmdDistructor ) |
|
144 { |
|
145 Cleanup(); |
|
146 } |
|
147 |
|
148 //------------------------------------------------------------------------- |
|
149 // Test of protected members |
|
150 //------------------------------------------------------------------------- |
|
151 |
|
152 else if ( aCommand==KCmdPROTECTEDSetUserLen ) |
|
153 { |
|
154 TBTSockAddrPROTECTEDSetUserLen(aSection); |
|
155 } |
|
156 else if ( aCommand==KCmdPROTECTEDUserPtr ) |
|
157 { |
|
158 TBTSockAddrPROTECTEDUserPtr(); |
|
159 } |
|
160 else if ( aCommand==KCmdPROTECTEDEndBTSockAddrPtr ) |
|
161 { |
|
162 TBTSockAddrPROTECTEDEndBTSockAddrPtr(); |
|
163 } |
|
164 else |
|
165 { |
|
166 retVal=EFalse; |
|
167 } |
|
168 |
|
169 return retVal; |
|
170 } |
|
171 |
|
172 void CT_BTSockAddrData::TBTSockAddrConstruct(const TDesC& aSection) |
|
173 { |
|
174 INFO_PRINTF1(_L("TBTSockAddr Constructor Call")); |
|
175 TPtrC myTSockAddrName; |
|
176 TSockAddr* myTSockAddr=NULL; |
|
177 if ( !GetStringFromConfig(aSection, KTSockAddr(), myTSockAddrName) ) |
|
178 { |
|
179 //Use default constructor |
|
180 Cleanup(); |
|
181 TRAPD( err, iTBTSockAddr = new (ELeave)T_TBTSockAddrChild() ); |
|
182 if ( err ) |
|
183 { |
|
184 SetError(err); |
|
185 } |
|
186 else |
|
187 { |
|
188 iTBTSockAddrOwned=ETrue; |
|
189 } |
|
190 } |
|
191 else |
|
192 { |
|
193 TRAPD( err, myTSockAddr=static_cast<TSockAddr*>(GetDataObjectL(myTSockAddrName)) ); |
|
194 if ( (!err ) && (myTSockAddr!=NULL) ) |
|
195 { |
|
196 Cleanup(); |
|
197 TRAPD( err ,iTBTSockAddr = new (ELeave) T_TBTSockAddrChild(*myTSockAddr) ); |
|
198 if ( err ) |
|
199 { |
|
200 SetError(err); |
|
201 } |
|
202 else |
|
203 { |
|
204 iTBTSockAddrOwned=ETrue; |
|
205 } |
|
206 } |
|
207 else |
|
208 { |
|
209 ERR_PRINTF1(_L("TSockAddr pointer is NULL")); |
|
210 SetBlockResult(EFail); |
|
211 } |
|
212 } |
|
213 } |
|
214 |
|
215 |
|
216 void CT_BTSockAddrData::TBTSockAddrCastFromTSockAddr(const TDesC& aSection) |
|
217 { |
|
218 INFO_PRINTF1(_L("TBTSockAddr Cast from TSockAddr Call")); |
|
219 TPtrC myTSockAddrName; |
|
220 TSockAddr* myTSockAddr=NULL; |
|
221 if ( !GetStringFromConfig(aSection, KTSockAddr(), myTSockAddrName) ) |
|
222 { |
|
223 ERR_PRINTF2(_L("No %S"), &KTSockAddr()); |
|
224 SetBlockResult(EFail); |
|
225 } |
|
226 else |
|
227 { |
|
228 myTSockAddr=static_cast<TSockAddr*>(GetDataObjectL(myTSockAddrName)); |
|
229 } |
|
230 if ( myTSockAddr!=NULL ) |
|
231 { |
|
232 Cleanup(); |
|
233 iTBTSockAddr = &T_TBTSockAddrChild::Cast(*myTSockAddr); |
|
234 iTBTSockAddrOwned=EFalse; |
|
235 } |
|
236 else |
|
237 { |
|
238 ERR_PRINTF1(_L("TSockAddr pointer is NULL")); |
|
239 SetBlockResult(EFail); |
|
240 } |
|
241 } |
|
242 |
|
243 void CT_BTSockAddrData::TBTSockAddrSetBTAddr(const TDesC& aSection) |
|
244 { |
|
245 TInt devId; |
|
246 if( GetIntFromConfig(aSection, KBTAddr(), devId)) |
|
247 { |
|
248 INFO_PRINTF2(_L("TBTSockAddr SetBTAddr (%d)"), devId); |
|
249 iTBTSockAddr->SetBTAddr(devId); |
|
250 } |
|
251 else |
|
252 { |
|
253 TPtrC configSectionName; |
|
254 if( GetStringFromConfig(aSection, KSection(), configSectionName)) |
|
255 { |
|
256 INFO_PRINTF2(_L("Getting BT Adress from config section: (%S)"), &configSectionName); |
|
257 TInt lhs; |
|
258 TInt rhs; |
|
259 if ( !GetHexFromConfig(configSectionName, KConfigHexBTAddrL(), lhs )) |
|
260 { |
|
261 ERR_PRINTF1(_L("TBTSockAddrSetBTAddr GetHexFromConfig failed")); |
|
262 SetBlockResult(EFail); |
|
263 } |
|
264 if ( !GetHexFromConfig(configSectionName, KConfigHexBTAddrR(), rhs )) |
|
265 { |
|
266 ERR_PRINTF1(_L("TBTSockAddrSetBTAddr GetHexFromConfig failed")); |
|
267 SetBlockResult(EFail); |
|
268 } |
|
269 TBTDevAddr btDevAddr (MAKE_TINT64(lhs, rhs)); |
|
270 iTBTSockAddr->SetBTAddr(btDevAddr); |
|
271 } |
|
272 else |
|
273 { |
|
274 TPtrC myTBTDevAddrName; |
|
275 if( GetStringFromConfig(aSection, KTBTDevAddr(), myTBTDevAddrName)) |
|
276 { |
|
277 CT_BTDevAddrData* myTBTDevAddrData=static_cast<CT_BTDevAddrData*>(GetDataWrapperL(myTBTDevAddrName)); |
|
278 iTBTSockAddr->SetBTAddr(*myTBTDevAddrData->GetAddress()); |
|
279 } |
|
280 else |
|
281 { |
|
282 TInt lhs; |
|
283 TInt rhs; |
|
284 if ( !GetHexFromConfig(aSection, KHexBTAddrL(), lhs )) |
|
285 { |
|
286 ERR_PRINTF1(_L("TBTSockAddrSetBTAddr GetHexFromConfig failed")); |
|
287 SetBlockResult(EFail); |
|
288 } |
|
289 if ( !GetHexFromConfig(aSection, KHexBTAddrR(), rhs )) |
|
290 { |
|
291 ERR_PRINTF1(_L("TBTSockAddrSetBTAddr GetHexFromConfig failed")); |
|
292 SetBlockResult(EFail); |
|
293 } |
|
294 TBTDevAddr btDevAddr (MAKE_TINT64(lhs, rhs)); |
|
295 iTBTSockAddr->SetBTAddr(btDevAddr); |
|
296 } |
|
297 } |
|
298 } |
|
299 } |
|
300 |
|
301 void CT_BTSockAddrData::TBTSockAddrBTAddr(const TDesC& aSection) |
|
302 { |
|
303 TInt devId; |
|
304 |
|
305 TBTDevAddr retrivedDevAddr = iTBTSockAddr->BTAddr(); |
|
306 TBuf<KMaxSockAddrSize> tmpBuf; |
|
307 retrivedDevAddr.GetReadable(tmpBuf); |
|
308 INFO_PRINTF2(_L("Bluetooth address: actual = 0x%S"),&tmpBuf); |
|
309 |
|
310 if( GetIntFromConfig(aSection, KBTAddr(), devId)) |
|
311 { |
|
312 TBTDevAddr devAddr= TBTDevAddr(devId); |
|
313 TBuf<KMaxSockAddrSize> tmpBuf2; |
|
314 devAddr.GetReadable(tmpBuf2); |
|
315 INFO_PRINTF2(_L("Bluetooth address: expected = 0x%S"),&tmpBuf2); |
|
316 |
|
317 |
|
318 if(devAddr != retrivedDevAddr) |
|
319 { |
|
320 ERR_PRINTF1(_L("BTAddr is not as expected!")); |
|
321 SetBlockResult(EFail); |
|
322 } |
|
323 else |
|
324 { |
|
325 INFO_PRINTF1(_L("TBTSockAddr BTAddr as expected")); |
|
326 } |
|
327 } |
|
328 else |
|
329 { |
|
330 TPtrC configSectionName; |
|
331 if( GetStringFromConfig(aSection, KSection(), configSectionName)) |
|
332 { |
|
333 INFO_PRINTF2(_L("Getting BT Adress from config section: (%S)"), &configSectionName); |
|
334 TInt lhs; |
|
335 TInt rhs; |
|
336 if ( !GetHexFromConfig(configSectionName, KConfigHexBTAddrL(), lhs )) |
|
337 { |
|
338 ERR_PRINTF1(_L("TBTSockAddrSetBTAddr GetHexFromConfig failed")); |
|
339 SetBlockResult(EFail); |
|
340 } |
|
341 if ( !GetHexFromConfig(configSectionName, KConfigHexBTAddrR(), rhs )) |
|
342 { |
|
343 ERR_PRINTF1(_L("TBTSockAddrSetBTAddr GetHexFromConfig failed")); |
|
344 SetBlockResult(EFail); |
|
345 } |
|
346 TBTDevAddr devAddr (MAKE_TINT64(lhs, rhs)); |
|
347 if(devAddr != retrivedDevAddr) |
|
348 { |
|
349 ERR_PRINTF1(_L("BTAddr is not as expected!")); |
|
350 SetBlockResult(EFail); |
|
351 } |
|
352 else |
|
353 { |
|
354 INFO_PRINTF1(_L("TBTSockAddr BTAddr as expected")); |
|
355 } |
|
356 } |
|
357 |
|
358 else |
|
359 { |
|
360 TPtrC myTBTDevAddrName; |
|
361 if( GetStringFromConfig(aSection, KTBTDevAddr(), myTBTDevAddrName)) |
|
362 { |
|
363 CT_BTDevAddrData* myTBTDevAddrData=static_cast<CT_BTDevAddrData*>(GetDataWrapperL(myTBTDevAddrName)); |
|
364 TBTDevAddr btDevAddr = *myTBTDevAddrData->GetAddress(); |
|
365 TBuf<KMaxSockAddrSize> tmpBuf2; |
|
366 btDevAddr.GetReadable(tmpBuf2); |
|
367 if (tmpBuf2 != tmpBuf) |
|
368 { |
|
369 ERR_PRINTF3(_L("Expected address (%S) != actual address (%S)"),&tmpBuf2,&tmpBuf); |
|
370 SetBlockResult(EFail); |
|
371 } |
|
372 } |
|
373 else |
|
374 { |
|
375 TInt lhs; |
|
376 TInt rhs; |
|
377 if ( GetHexFromConfig(aSection, KHexBTAddrL(), lhs )) |
|
378 { |
|
379 if ( !GetHexFromConfig(aSection, KHexBTAddrR(), rhs )) |
|
380 { |
|
381 ERR_PRINTF1(_L("TBTSockAddrBTAddr GetHexFromConfig failed")); |
|
382 SetBlockResult(EFail); |
|
383 } |
|
384 TBTDevAddr devAddr (MAKE_TINT64(lhs, rhs)); |
|
385 if(devAddr != retrivedDevAddr) |
|
386 { |
|
387 ERR_PRINTF1(_L("BTAddr is not as expected!")); |
|
388 SetBlockResult(EFail); |
|
389 } |
|
390 else |
|
391 { |
|
392 INFO_PRINTF1(_L("TBTSockAddr BTAddr as expected")); |
|
393 } |
|
394 } |
|
395 } |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 void CT_BTSockAddrData::TBTSockAddrSetSecurity(const TDesC& aSection) |
|
401 { |
|
402 INFO_PRINTF1(_L("TBTSockAddr SetSecurity to current iBTServiceSecurity")); |
|
403 TPtrC myBTServiceSecurityName; |
|
404 TBTServiceSecurity* myBTServiceSecurity=NULL; |
|
405 if ( !GetStringFromConfig(aSection, KSecurity(), myBTServiceSecurityName) ) |
|
406 { |
|
407 ERR_PRINTF2(_L("No %S"), &KSecurity()); |
|
408 SetBlockResult(EFail); |
|
409 } |
|
410 else |
|
411 { |
|
412 myBTServiceSecurity=static_cast<TBTServiceSecurity*>(GetDataObjectL(myBTServiceSecurityName)); |
|
413 } |
|
414 if ( myBTServiceSecurity!=NULL ) |
|
415 { |
|
416 iTBTSockAddr->SetSecurity(*myBTServiceSecurity); |
|
417 } |
|
418 else |
|
419 { |
|
420 ERR_PRINTF1(_L("TBTSockAddrSetSecurity BTServiceSecurity is NULL")); |
|
421 SetBlockResult(EFail); |
|
422 } |
|
423 } |
|
424 |
|
425 void CT_BTSockAddrData::TBTSockAddrBTSecurity(const TDesC& aSection) |
|
426 { |
|
427 INFO_PRINTF1(_L("TBTSockAddr set iBTServiceSecurity from BTSecurity")); |
|
428 TPtrC myBTServiceSecurityName; |
|
429 CT_BTServiceSecurityData* myBTServiceSecurityData=NULL; |
|
430 if ( !GetStringFromConfig(aSection, KSecurity(), myBTServiceSecurityName) ) |
|
431 { |
|
432 ERR_PRINTF2(_L("No %S"), &KSecurity()); |
|
433 SetBlockResult(EFail); |
|
434 } |
|
435 else |
|
436 { |
|
437 myBTServiceSecurityData=static_cast<CT_BTServiceSecurityData*>(GetDataWrapperL(myBTServiceSecurityName)); |
|
438 } |
|
439 if ( myBTServiceSecurityData!=NULL ) |
|
440 { |
|
441 TBTServiceSecurity tmp = iTBTSockAddr->BTSecurity(); |
|
442 myBTServiceSecurityData->CopyObjectL(&tmp); |
|
443 } |
|
444 else |
|
445 { |
|
446 ERR_PRINTF1(_L("TBTSockAddrBTSecurity BTServiceSecurity is NULL")); |
|
447 SetBlockResult(EFail); |
|
448 } |
|
449 } |
|
450 |
|
451 void CT_BTSockAddrData::TBTSockAddrSetFamily(const TDesC& aSection) |
|
452 { |
|
453 TInt family; |
|
454 if( GetIntFromConfig(aSection, KFamily(), family)) |
|
455 { |
|
456 INFO_PRINTF2(_L("TBTSockAddr SetFamily (%d)"), family); |
|
457 iTBTSockAddr->SetFamily(family); |
|
458 } |
|
459 else |
|
460 { |
|
461 ERR_PRINTF1(_L("TBTSockAddrSetFamily GetIntFromConfig failed")); |
|
462 SetBlockResult(EFail); |
|
463 } |
|
464 } |
|
465 |
|
466 void CT_BTSockAddrData::TBTSockAddrFamily(const TDesC& aSection) |
|
467 { |
|
468 TInt family; |
|
469 |
|
470 TInt familyReceived = static_cast<TInt>(iTBTSockAddr->Family()); |
|
471 INFO_PRINTF2(_L("TBTSockAddr Family: actual (%d)" ), familyReceived); |
|
472 |
|
473 if( GetIntFromConfig(aSection, KFamily(), family)) |
|
474 { |
|
475 INFO_PRINTF2(_L("TBTSockAddr Family: expected (%d)" ), family); |
|
476 |
|
477 if(family != familyReceived) |
|
478 { |
|
479 ERR_PRINTF1(_L("Family is not as expected!")); |
|
480 SetBlockResult(EFail); |
|
481 } |
|
482 } |
|
483 else |
|
484 { |
|
485 ERR_PRINTF1(_L("TBTSockAddrFamily GetIntFromConfig failed")); |
|
486 SetBlockResult(EFail); |
|
487 } |
|
488 } |
|
489 |
|
490 void CT_BTSockAddrData::TBTSockAddrSetPort(const TDesC& aSection) |
|
491 { |
|
492 TInt port; |
|
493 if( GetIntFromConfig(aSection, KPort(), port)) |
|
494 { |
|
495 INFO_PRINTF2(_L("TBTSockAddr SetPort (%d)"), port); |
|
496 iTBTSockAddr->SetPort(port); |
|
497 } |
|
498 else |
|
499 { |
|
500 ERR_PRINTF1(_L("TBTSockAddrSetPort GetIntFromConfig failed")); |
|
501 SetBlockResult(EFail); |
|
502 } |
|
503 } |
|
504 |
|
505 void CT_BTSockAddrData::TBTSockAddrPort(const TDesC& aSection) |
|
506 { |
|
507 TInt port; |
|
508 |
|
509 TInt portReceived = static_cast<TInt>(iTBTSockAddr->Port()); |
|
510 INFO_PRINTF2(_L("TBTSockAddr Port: actual (%d)" ), portReceived); |
|
511 |
|
512 if( GetIntFromConfig(aSection, KPort(), port)) |
|
513 { |
|
514 INFO_PRINTF2(_L("TBTSockAddr Port: expected (%d)" ), port); |
|
515 if(port != portReceived) |
|
516 { |
|
517 ERR_PRINTF1(_L("Port is not as expected!")); |
|
518 SetBlockResult(EFail); |
|
519 } |
|
520 } |
|
521 else |
|
522 { |
|
523 ERR_PRINTF1(_L("TBTSockAddrPort GetIntFromConfig failed")); |
|
524 SetBlockResult(EFail); |
|
525 } |
|
526 } |
|
527 |
|
528 void CT_BTSockAddrData::TBTSockAddrCmpPort(const TDesC& aSection) |
|
529 { |
|
530 INFO_PRINTF1(_L("TBTSockAddrCmpPort")); |
|
531 TPtrC myTBTSockAddrName; |
|
532 TBTSockAddr* myTBTSockAddr=NULL; |
|
533 |
|
534 TUint portReceived = iTBTSockAddr->Port(); |
|
535 TUint familyReceived = iTBTSockAddr->Family(); |
|
536 INFO_PRINTF3(_L("TBTSockAddrCmpPort Port: actual (%d), Family: actual (%d)"), portReceived, familyReceived ); |
|
537 |
|
538 if ( !GetStringFromConfig(aSection, KTBTSockAddr(), myTBTSockAddrName) ) |
|
539 { |
|
540 ERR_PRINTF2(_L("No %S"), &KTBTSockAddr()); |
|
541 SetBlockResult(EFail); |
|
542 } |
|
543 else |
|
544 { |
|
545 myTBTSockAddr=static_cast<TBTSockAddr*>(GetDataObjectL(myTBTSockAddrName)); |
|
546 } |
|
547 if ( myTBTSockAddr!=NULL ) |
|
548 { |
|
549 |
|
550 TUint port = myTBTSockAddr->Port(); |
|
551 TUint family = myTBTSockAddr->Family(); |
|
552 |
|
553 INFO_PRINTF3(_L("TBTSockAddrCmpPort Port: expected (%d), Family: expected (%d)"), port, family ); |
|
554 |
|
555 TBool expectedCompResult =ETrue; |
|
556 |
|
557 GetBoolFromConfig(aSection, KExpectedCompResult(), expectedCompResult); |
|
558 TBool actualCompResult = myTBTSockAddr->CmpPort(*iTBTSockAddr); |
|
559 INFO_PRINTF3(_L("TBTSockAddrCmpPort Compare result expected (%d), actual (%d)"), expectedCompResult, actualCompResult ); |
|
560 if( actualCompResult != expectedCompResult) |
|
561 { |
|
562 ERR_PRINTF1(_L("TBTSockAddrCmpPort failed")); |
|
563 SetBlockResult(EFail); |
|
564 } |
|
565 } |
|
566 else |
|
567 { |
|
568 ERR_PRINTF1(_L("TBTSockAddr is NULL")); |
|
569 SetBlockResult(EFail); |
|
570 } |
|
571 } |
|
572 |
|
573 void CT_BTSockAddrData::TBTSockAddrGetUserLen(const TDesC& aSection) |
|
574 { |
|
575 TInt userLen; |
|
576 |
|
577 TInt userLenReceived = static_cast<TInt>(iTBTSockAddr->GetUserLen()); |
|
578 INFO_PRINTF2(_L("TBTSockAddr Protected UserLen: actual (%d)"), userLenReceived); |
|
579 |
|
580 if( GetIntFromConfig(aSection, KUserlen(), userLen)) |
|
581 { |
|
582 INFO_PRINTF2(_L("TBTSockAddr Protected UserLen: expected (%d)" ), userLen); |
|
583 if(userLen != userLenReceived) |
|
584 { |
|
585 ERR_PRINTF1(_L("UserLen is not as expected!")); |
|
586 SetBlockResult(EFail); |
|
587 } |
|
588 } |
|
589 else |
|
590 { |
|
591 ERR_PRINTF1(_L("TBTSockAddrGetUserLen GetIntFromConfig failed")); |
|
592 SetBlockResult(EFail); |
|
593 } |
|
594 } |
|
595 |
|
596 void CT_BTSockAddrData::TBTSockAddrPROTECTEDSetUserLen(const TDesC& aSection) |
|
597 { |
|
598 TInt userLen; |
|
599 if( GetIntFromConfig(aSection, KUserlen(), userLen)) |
|
600 { |
|
601 INFO_PRINTF2(_L("TBTSockAddr Protected SetUserLen (%d)"), userLen); |
|
602 iTBTSockAddr->T_SetUserLen(userLen); |
|
603 } |
|
604 else |
|
605 { |
|
606 ERR_PRINTF1(_L("TBTSockAddrPROTECTEDSetUserLen GetIntFromConfig failed")); |
|
607 SetBlockResult(EFail); |
|
608 } |
|
609 } |
|
610 |
|
611 void CT_BTSockAddrData::TBTSockAddrPROTECTEDUserPtr() |
|
612 { |
|
613 TUint8* userPtr = iTBTSockAddr->T_UserPtr(); |
|
614 INFO_PRINTF2(_L("TBTSockAddr Protected userPtr: (%d)" ), userPtr); |
|
615 if(!userPtr) |
|
616 { |
|
617 ERR_PRINTF1(_L("Null pointer retrived!")); |
|
618 SetBlockResult(EFail); |
|
619 } |
|
620 } |
|
621 |
|
622 void CT_BTSockAddrData::TBTSockAddrPROTECTEDEndBTSockAddrPtr() |
|
623 { |
|
624 TAny * endBTSockAddrPtr = iTBTSockAddr->T_EndBTSockAddrPtr(); |
|
625 INFO_PRINTF2(_L("TBTSockAddr Protected EndBTSockAddrPtr: (%d)" ), endBTSockAddrPtr); |
|
626 if(!endBTSockAddrPtr) |
|
627 { |
|
628 ERR_PRINTF1(_L("Null pointer retrived!")); |
|
629 SetBlockResult(EFail); |
|
630 } |
|
631 } |
|
632 |
|
633 |
|
634 TAny* CT_BTSockAddrData::GetObject() |
|
635 { |
|
636 return iTBTSockAddr; |
|
637 } |
|
638 |
|
639 |
|
640 void CT_BTSockAddrData::SetObject(T_TBTSockAddrChild* aTBTSockAddr, TBool aTransferOwnership) |
|
641 { |
|
642 iTBTSockAddr = aTBTSockAddr; |
|
643 iTBTSockAddrOwned = aTransferOwnership; |
|
644 } |