bluetoothapitest/bluetoothsvs/T_BTUserAPI/src/T_RfcommRPNTransactionData.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_RfcommRPNTransactionData.h"
       
    19 
       
    20 /*@{*/
       
    21 //Parameters
       
    22 _LIT(KParamMask,										"mask");
       
    23 _LIT(KObject,											"object");
       
    24 
       
    25 //Commands
       
    26 _LIT(KCmdRfcommRPNTransaction,							"TRfcommRPNTransaction");
       
    27 _LIT(KCmdParamMask,										"SetParamMask");
       
    28 _LIT(KCmdPortParams,									"SetPortParams");
       
    29 
       
    30 //	Logging
       
    31 _LIT(KLogMissingParameter,			"Missing parameter '%S'");
       
    32 /*@}*/
       
    33 
       
    34 //////////////////////////////////////////////////////////////////////
       
    35 // Construction/Destruction
       
    36 //////////////////////////////////////////////////////////////////////
       
    37 
       
    38 CT_RfcommRPNTransactionData* CT_RfcommRPNTransactionData::NewL()
       
    39 	{
       
    40 	CT_RfcommRPNTransactionData*	ret=new (ELeave) CT_RfcommRPNTransactionData();
       
    41 	CleanupStack::PushL(ret);
       
    42 	ret->ConstructL();
       
    43 	CleanupStack::Pop(ret);
       
    44 	return ret;
       
    45 	}
       
    46 
       
    47 CT_RfcommRPNTransactionData::CT_RfcommRPNTransactionData()
       
    48 :	iData(NULL)
       
    49 	{
       
    50 	}
       
    51 
       
    52 void CT_RfcommRPNTransactionData::ConstructL()
       
    53 	{
       
    54 	}
       
    55 
       
    56 CT_RfcommRPNTransactionData::~CT_RfcommRPNTransactionData()
       
    57 	{
       
    58 	DestroyData();
       
    59 	}
       
    60 
       
    61 TAny* CT_RfcommRPNTransactionData::GetObject()
       
    62 	{
       
    63 	return iData;
       
    64 	}
       
    65 
       
    66 void CT_RfcommRPNTransactionData::SetObjectL(TAny* aAny)
       
    67 	{
       
    68 	DestroyData();
       
    69 	iData = static_cast<TRfcommRPNTransaction*> (aAny);
       
    70 	}
       
    71 
       
    72 void CT_RfcommRPNTransactionData::DisownObjectL()
       
    73 	{
       
    74 	iData = NULL;
       
    75 	}
       
    76 
       
    77 void CT_RfcommRPNTransactionData::DestroyData()
       
    78 	{
       
    79 	delete iData;
       
    80 	iData=NULL;	
       
    81 	}
       
    82 
       
    83 inline TCleanupOperation CT_RfcommRPNTransactionData::CleanupOperation()
       
    84 	{
       
    85 	return CleanupOperation;
       
    86 	}
       
    87 
       
    88 void CT_RfcommRPNTransactionData::CleanupOperation(TAny* aAny)
       
    89 	{
       
    90 	//may be unnecessary
       
    91 	TRfcommRPNTransaction* arg=static_cast<TRfcommRPNTransaction*>(aAny);
       
    92 	delete arg;
       
    93 	}
       
    94 
       
    95 TBool CT_RfcommRPNTransactionData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
    96 	{
       
    97 	TBool	ret = ETrue;
       
    98 
       
    99 	if ( aCommand==KCmdRfcommRPNTransaction )
       
   100 		{
       
   101 		DoCmdTRfcommRPNTransaction();
       
   102 		}
       
   103 	else if ( aCommand==KCmdParamMask )
       
   104 		{
       
   105 		DoCmdParamMask(aSection);
       
   106 		}
       
   107 	else if ( aCommand==KCmdPortParams )
       
   108 		{
       
   109 		DoCmdPortParams(aSection);
       
   110 		}
       
   111 	else
       
   112 		{
       
   113 		ret=EFalse;
       
   114 		}
       
   115 
       
   116 	return ret;
       
   117 	}
       
   118 
       
   119 
       
   120 /**
       
   121 Test TRfcommRPNTransaction()
       
   122 */
       
   123 void CT_RfcommRPNTransactionData::DoCmdTRfcommRPNTransaction()
       
   124 	{
       
   125 	DestroyData();
       
   126 	INFO_PRINTF1(_L("TRfcommRPNTransaction Constructor Call"));
       
   127 	iData = new (ELeave) TRfcommRPNTransaction();
       
   128 	
       
   129 	if (iData == NULL) 
       
   130 		{
       
   131 		ERR_PRINTF1(_L("TRfcommRPNTransaction is NULL"));
       
   132 		SetBlockResult(EFail);
       
   133 		}
       
   134 	}
       
   135 
       
   136 
       
   137 /**
       
   138 Set iParaMask value
       
   139 */
       
   140 void CT_RfcommRPNTransactionData::DoCmdParamMask(const TDesC& aSection)
       
   141 	{
       
   142 	TInt dataInput = 0;
       
   143 	if(GetIntFromConfig(aSection, KParamMask(), dataInput) )
       
   144 		{
       
   145 		iData->iParamMask = (TUint16) dataInput;
       
   146 		INFO_PRINTF2(_L("iParamMask value (%d)"), iData->iParamMask);
       
   147 		}
       
   148 	else
       
   149 		{
       
   150 		ERR_PRINTF2(KLogMissingParameter, &KParamMask());
       
   151 		SetBlockResult(EFail);		
       
   152 		}
       
   153 	}
       
   154 
       
   155 /**
       
   156 Set iPortParams
       
   157 */
       
   158 void CT_RfcommRPNTransactionData::DoCmdPortParams(const TDesC& aSection)
       
   159 	{
       
   160 	TPtrC	object;
       
   161 	
       
   162 	if(GetStringFromConfig(aSection, KObject(), object) )
       
   163 		{
       
   164 		INFO_PRINTF1(_L("Create a TRfcommRemotePortParams object for iPortParams"));
       
   165 		TRfcommRemotePortParams* temp = static_cast<TRfcommRemotePortParams*>(GetDataObjectL(object));
       
   166 		iData->iPortParams = *temp;
       
   167 		}
       
   168 	else
       
   169 		{
       
   170 		ERR_PRINTF2(KLogMissingParameter, &KObject());
       
   171 		SetBlockResult(EFail);
       
   172 		}
       
   173 	}