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