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