bluetoothapitest/bluetoothsvs/T_BTSdpAPI/src/T_DataSdpIntBuf32.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 #include "T_DataSdpIntBuf32.h"
       
    19 
       
    20 /*@{*/
       
    21 //Parameters
       
    22 _LIT(KInputInt,				"inputInt");
       
    23 
       
    24 //Commands
       
    25 _LIT(KCmdTSDPIntBuf32, 		"NewIntBuf");
       
    26 /*@}*/
       
    27 
       
    28 //////////////////////////////////////////////////////////////////////
       
    29 // Construction/Destruction
       
    30 //////////////////////////////////////////////////////////////////////
       
    31 
       
    32 CT_DataSdpIntBuf32* CT_DataSdpIntBuf32::NewL()
       
    33 	{
       
    34 	CT_DataSdpIntBuf32*	ret=new (ELeave) CT_DataSdpIntBuf32();
       
    35 	CleanupStack::PushL(ret);
       
    36 	ret->ConstructL();
       
    37 	CleanupStack::Pop(ret);
       
    38 	return ret;
       
    39 	}
       
    40 
       
    41 CT_DataSdpIntBuf32::CT_DataSdpIntBuf32()
       
    42 :	iSdpIntBuf32(NULL)
       
    43 	{
       
    44 	}
       
    45 
       
    46 void CT_DataSdpIntBuf32::ConstructL()
       
    47 	{
       
    48 	}
       
    49 
       
    50 CT_DataSdpIntBuf32::~CT_DataSdpIntBuf32()
       
    51 	{
       
    52 	DestroyData();
       
    53 	}
       
    54 
       
    55 
       
    56 void CT_DataSdpIntBuf32::DestroyData()
       
    57 	{
       
    58 	delete iSdpIntBuf32;
       
    59 	iSdpIntBuf32=NULL;
       
    60 	}
       
    61 	
       
    62 void CT_DataSdpIntBuf32::SetObjectL(TAny* aAny)
       
    63 	{
       
    64 	DestroyData();
       
    65 	iSdpIntBuf32 = static_cast<TSdpIntBuf<TUint32>*> (aAny);
       
    66 	}
       
    67 
       
    68 void CT_DataSdpIntBuf32::DisownObjectL()
       
    69 	{
       
    70 	iSdpIntBuf32 = NULL;
       
    71 	}
       
    72 	
       
    73 inline TCleanupOperation CT_DataSdpIntBuf32::CleanupOperation()
       
    74 	{
       
    75 	return CleanupOperation;
       
    76 	}
       
    77 
       
    78 void CT_DataSdpIntBuf32::CleanupOperation(TAny* aAny)
       
    79 	{
       
    80 	TSdpIntBuf<TUint32>* arg=static_cast<TSdpIntBuf<TUint32>*>(aAny);
       
    81 	delete arg;
       
    82 	}
       
    83 
       
    84 /**
       
    85  * Process a command read from the ini file
       
    86  *
       
    87  * @param aCommand			The command to process
       
    88  * @param aSection			The section in the ini containing data for the command
       
    89  * @param aAsyncErrorIndex	Command index for async calls to return errors to
       
    90  *
       
    91  * @return					ETrue if the command is processed
       
    92  *
       
    93  * @leave					System wide error
       
    94  */
       
    95 TBool CT_DataSdpIntBuf32::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
    96 	{
       
    97 	TBool	ret=ETrue;
       
    98 
       
    99 	if ( aCommand==KCmdTSDPIntBuf32 )
       
   100 		{
       
   101 		DoCmdNewIntBuf32L(aSection);
       
   102 		}
       
   103 	else
       
   104 		{
       
   105 		ret=EFalse;
       
   106 		}
       
   107 
       
   108 	return ret;
       
   109 	}
       
   110 
       
   111 void CT_DataSdpIntBuf32::DoCmdNewIntBuf32L(const TDesC & aSection)
       
   112 	{
       
   113 	TInt	theValue=0;
       
   114 
       
   115 	if( GetIntFromConfig(aSection, KInputInt(), theValue))
       
   116 		{
       
   117 		iSdpIntBuf32 = new (ELeave) TSdpIntBuf<TUint32>((TUint32)theValue);
       
   118 		INFO_PRINTF5(_L("TSdpIntBuf32 Object Call: 1st byte:(%d),2nd byte:(%d),3rd byte:(%d),4th byte:(%d)"),(*iSdpIntBuf32)[0],(*iSdpIntBuf32)[1],(*iSdpIntBuf32)[2],(*iSdpIntBuf32)[3]);
       
   119 
       
   120 		TUint8 tempPtr[sizeof(TUint32)];
       
   121 		TUint8 tempValue;
       
   122 		TUint32 numValue = theValue;
       
   123 
       
   124 		for (TInt numRange = sizeof(TUint32) -1; numRange >= 0; numRange--)
       
   125 			{
       
   126 			tempValue = numValue & 0xFF; // transfer the lowest byte..
       
   127 			tempPtr[numRange] = tempValue; //.. into the right hand side of the descriptor
       
   128 			numValue >>= 8;
       
   129 			if ( tempPtr[numRange]!=(*iSdpIntBuf32)[numRange] )
       
   130 				{
       
   131 				ERR_PRINTF1(_L("Data is not as expected!"));
       
   132 				SetBlockResult(EFail);
       
   133 				}
       
   134 			}
       
   135 
       
   136 		INFO_PRINTF5(_L("TSdpIntBuf32:1st byte:(%d),2nd byte:(%d),3rd byte:(%d),4th byte:(%d)"),tempPtr[0],tempPtr[1],tempPtr[2],tempPtr[3]);
       
   137 		
       
   138 		}
       
   139 	else
       
   140 		{
       
   141 		ERR_PRINTF2(_L("Missing parameter %S"), &KInputInt());
       
   142 		SetBlockResult(EFail);
       
   143 		}
       
   144 	}
       
   145 
       
   146 
       
   147 
       
   148