bluetoothapitest/bluetoothsvs/T_BTSdpAPI/src/T_DataSdpAttrValueDES.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_DataSdpAttrValueDES.h"
       
    19 #include "T_BTUtil.h"
       
    20 
       
    21 /*@{*/
       
    22 //Parameters
       
    23 _LIT(KObjectName,			"objectname");
       
    24 _LIT(KTypeName,				"typename");
       
    25 //Commands
       
    26 _LIT(KCmdNewDESL,			"NewDESL");
       
    27 /*@}*/
       
    28 
       
    29 //////////////////////////////////////////////////////////////////////
       
    30 // Construction/Destruction
       
    31 //////////////////////////////////////////////////////////////////////
       
    32 
       
    33 CT_DataSdpAttrValueDES* CT_DataSdpAttrValueDES::NewL()
       
    34 	{
       
    35 	CT_DataSdpAttrValueDES* ret=new (ELeave) CT_DataSdpAttrValueDES();
       
    36 	CleanupStack::PushL(ret);
       
    37 	ret->ConstructL();
       
    38 	CleanupStack::Pop(ret);
       
    39 	return ret;
       
    40 	}
       
    41 
       
    42 
       
    43 CT_DataSdpAttrValueDES::CT_DataSdpAttrValueDES()
       
    44 :	CT_DataSdpAttrValueList()
       
    45 ,	iAttrValueDES(NULL)
       
    46 	{
       
    47 	}
       
    48 
       
    49 void CT_DataSdpAttrValueDES::ConstructL()
       
    50 	{
       
    51 	CT_DataSdpAttrValueList::ConstructL();
       
    52 	}
       
    53 
       
    54 CSdpAttrValueList* CT_DataSdpAttrValueDES::GetSdpAttrValueList() const
       
    55 	{
       
    56 	return iAttrValueDES;
       
    57 	}
       
    58 
       
    59 void CT_DataSdpAttrValueDES::SetObjectL(TAny* aAny)
       
    60 	{
       
    61 	DestroyData();
       
    62 	iAttrValueDES = static_cast<CSdpAttrValueDES*> (aAny);
       
    63 	}
       
    64 
       
    65 void CT_DataSdpAttrValueDES::DisownObjectL()
       
    66 	{
       
    67 	iAttrValueDES = NULL;
       
    68 	}
       
    69 
       
    70 CT_DataSdpAttrValueDES::~CT_DataSdpAttrValueDES()
       
    71 	{
       
    72 	DestroyData();
       
    73 	}
       
    74 
       
    75 
       
    76 void CT_DataSdpAttrValueDES::DestroyData()
       
    77 	{
       
    78 	delete iAttrValueDES;
       
    79 	iAttrValueDES=NULL;
       
    80 	}
       
    81 
       
    82 inline TCleanupOperation CT_DataSdpAttrValueDES::CleanupOperation()
       
    83 	{
       
    84 	return CleanupOperation;
       
    85 	}
       
    86 
       
    87 void CT_DataSdpAttrValueDES::CleanupOperation(TAny* aAny)
       
    88 	{
       
    89 	CSdpAttrValueDES* arg=static_cast<CSdpAttrValueDES*>(aAny);
       
    90 	delete arg;
       
    91 	}
       
    92 
       
    93 /**
       
    94  * Process a command read from the ini file
       
    95  *
       
    96  * @param aCommand			The command to process
       
    97  * @param aSection			The section in the ini containing data for the command
       
    98  * @param aAsyncErrorIndex	Command index for async calls to return errors to
       
    99  *
       
   100  * @return					ETrue if the command is processed
       
   101  *
       
   102  * @leave					System wide error
       
   103  */
       
   104 TBool CT_DataSdpAttrValueDES::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   105 	{
       
   106 	TBool	ret=ETrue;
       
   107 
       
   108 	if ( aCommand==KCmdNewDESL )
       
   109 		{
       
   110 		DoCmdNewDESL(aSection);
       
   111 		}
       
   112 	else
       
   113 		{
       
   114 		ret=CT_DataSdpAttrValueList::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   115 		}
       
   116 
       
   117 	return ret;
       
   118 	}
       
   119 
       
   120 
       
   121 /**
       
   122  Test CSdpAttrValueDES's NewDESL() function
       
   123 */
       
   124 void CT_DataSdpAttrValueDES::DoCmdNewDESL(const TDesC& aSection)
       
   125 	{
       
   126 	DestroyData();
       
   127 	
       
   128 	MSdpElementBuilder*					elementBuilder = NULL;
       
   129 	TPtrC 								objectName;
       
   130 	TPtrC								objectType;
       
   131 	if ( GetStringFromConfig(aSection, KObjectName(), objectName) )
       
   132 		{
       
   133 		if ( GetStringFromConfig(aSection, KTypeName(), objectType) )
       
   134 			{
       
   135 			elementBuilder = CT_BTUtil::ElementBuilderCastL(*this, objectName, objectType);
       
   136 			INFO_PRINTF1(_L("Create a nested list using CSdpAttrValueDES::NewDESL()"));
       
   137 			TRAPD( err, iAttrValueDES=CSdpAttrValueDES::NewDESL(elementBuilder) );
       
   138 			if (err!=KErrNone)
       
   139 				{
       
   140 				ERR_PRINTF2(_L("CSdpAttrValueDES::NewDESL function failed with error (%d)"), err);
       
   141 				SetError(err);
       
   142 				}
       
   143 			}
       
   144 		else
       
   145 			{
       
   146 			ERR_PRINTF2(_L("Missing parameter %S"), &KTypeName());
       
   147 			SetBlockResult(EFail);	
       
   148 			}
       
   149 		}
       
   150 	else
       
   151 		{
       
   152 		INFO_PRINTF1(_L("Create a list is not nested using CSdpAttrValueDES::NewDESL(NULL)"));
       
   153 		TRAPD( errCode, iAttrValueDES=CSdpAttrValueDES::NewDESL(elementBuilder) );
       
   154 		if (errCode!=KErrNone)
       
   155 			{
       
   156 			ERR_PRINTF2(_L("CSdpAttrValueDES::NewDESL function failed with error (%d)"), errCode);
       
   157 			SetError(errCode);
       
   158 			}
       
   159 		}
       
   160 	}