bluetoothapitest/bluetoothsvs/T_BTSdpAPI/src/T_DataSdpIntBuf8.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_DataSdpIntBuf8.h"
       
    19 
       
    20 /*@{*/
       
    21 //Parameters
       
    22 _LIT(KInputInt,				"inputInt");
       
    23 
       
    24 //Commands
       
    25 _LIT(KCmdTSDPIntBuf8, 		"NewIntBuf");
       
    26 /*@}*/
       
    27 
       
    28 //////////////////////////////////////////////////////////////////////
       
    29 // Construction/Destruction
       
    30 //////////////////////////////////////////////////////////////////////
       
    31 
       
    32 CT_DataSdpIntBuf8* CT_DataSdpIntBuf8::NewL()
       
    33 	{
       
    34 	CT_DataSdpIntBuf8*	ret=new (ELeave) CT_DataSdpIntBuf8();
       
    35 	CleanupStack::PushL(ret);
       
    36 	ret->ConstructL();
       
    37 	CleanupStack::Pop(ret);
       
    38 	return ret;
       
    39 	}
       
    40 
       
    41 CT_DataSdpIntBuf8::CT_DataSdpIntBuf8()
       
    42 :	iSdpIntBuf8(NULL)
       
    43 	{
       
    44 	}
       
    45 
       
    46 void CT_DataSdpIntBuf8::ConstructL()
       
    47 	{
       
    48 	}
       
    49 
       
    50 CT_DataSdpIntBuf8::~CT_DataSdpIntBuf8()
       
    51 	{
       
    52 	DestroyData();
       
    53 	}
       
    54 
       
    55 
       
    56 void CT_DataSdpIntBuf8::DestroyData()
       
    57 	{
       
    58 	delete iSdpIntBuf8;
       
    59 	iSdpIntBuf8=NULL;
       
    60 	}
       
    61 	
       
    62 void CT_DataSdpIntBuf8::SetObjectL(TAny* aAny)
       
    63 	{
       
    64 	DestroyData();
       
    65 	iSdpIntBuf8 = static_cast<TSdpIntBuf<TUint8>*> (aAny);
       
    66 	}
       
    67 
       
    68 void CT_DataSdpIntBuf8::DisownObjectL()
       
    69 	{
       
    70 	iSdpIntBuf8 = NULL;
       
    71 	}
       
    72 	
       
    73 inline TCleanupOperation CT_DataSdpIntBuf8::CleanupOperation()
       
    74 	{
       
    75 	return CleanupOperation;
       
    76 	}
       
    77 
       
    78 void CT_DataSdpIntBuf8::CleanupOperation(TAny* aAny)
       
    79 	{
       
    80 	TSdpIntBuf<TUint8>* arg=static_cast<TSdpIntBuf<TUint8>*>(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_DataSdpIntBuf8::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
    96 	{
       
    97 	TBool	ret=ETrue;
       
    98 
       
    99 	if ( aCommand==KCmdTSDPIntBuf8 )
       
   100 		{
       
   101 		DoCmdNewIntBuf8L(aSection);
       
   102 		}
       
   103 	else
       
   104 		{
       
   105 		ret=EFalse;
       
   106 		}
       
   107 
       
   108 	return ret;
       
   109 	}
       
   110 
       
   111 
       
   112 void CT_DataSdpIntBuf8::DoCmdNewIntBuf8L(const TDesC & aSection)
       
   113 	{
       
   114 	TInt	theValue=0;
       
   115 	DestroyData();
       
   116 	if( GetIntFromConfig(aSection, KInputInt(), theValue))
       
   117 		{
       
   118 		iSdpIntBuf8 = new (ELeave) TSdpIntBuf<TUint8>((TUint8)theValue);
       
   119 		INFO_PRINTF2(_L("TSdpIntBuf8 input value:(%d)"), theValue);
       
   120 		INFO_PRINTF2(_L("TSdpIntBuf8 Object Call: 1st byte:(%d)"), (*iSdpIntBuf8)[0]);
       
   121 		TUint8 	firstByte=theValue & 0xFF;
       
   122     		
       
   123 		if( firstByte!=(*iSdpIntBuf8)[0] )
       
   124 			{
       
   125 			ERR_PRINTF1(_L("Data is not as expected!"));
       
   126 			SetBlockResult(EFail);
       
   127 			}
       
   128 		INFO_PRINTF2(_L("TSdpIntBuf8 Call: 1st byte:(%d)"), firstByte);
       
   129 		}
       
   130 	else
       
   131 		{
       
   132 		ERR_PRINTF2(_L("Missing parameter %S"), &KInputInt());
       
   133 		SetBlockResult(EFail);
       
   134 		}
       
   135 	}
       
   136 
       
   137 
       
   138 
       
   139