bluetoothapitest/bluetoothsvs/T_BTSdpAPI/src/T_DataCSdpAttrValueURL.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_DataCSdpAttrValueURL.h"
       
    19 
       
    20 /*@{*/
       
    21 //Commands
       
    22 _LIT(KCmdNewURLL,		"NewURLL");
       
    23 _LIT(KCmdDestructor,	"~");
       
    24 
       
    25 //Parameters
       
    26 _LIT(KNewObject,		"object");
       
    27 /*@}*/
       
    28 
       
    29 //////////////////////////////////////////////////////////////////////
       
    30 // Construction/Destruction
       
    31 //////////////////////////////////////////////////////////////////////
       
    32 
       
    33 CT_DataCSdpAttrValueURL* CT_DataCSdpAttrValueURL::NewL()
       
    34 	{
       
    35 	CT_DataCSdpAttrValueURL*	ret=new (ELeave) CT_DataCSdpAttrValueURL();
       
    36 	CleanupStack::PushL(ret);
       
    37 	ret->ConstructL();
       
    38 	CleanupStack::Pop(ret);
       
    39 	return ret;
       
    40 	}
       
    41 
       
    42 CT_DataCSdpAttrValueURL::CT_DataCSdpAttrValueURL()
       
    43 :	iAttrValueURL(NULL)
       
    44 	{
       
    45 	}
       
    46 
       
    47 void CT_DataCSdpAttrValueURL::ConstructL()
       
    48 	{
       
    49 	}
       
    50 
       
    51 CSdpAttrValue* CT_DataCSdpAttrValueURL::GetSdpAttrValue() const
       
    52 	{
       
    53 	return iAttrValueURL;
       
    54 	}
       
    55 
       
    56 CT_DataCSdpAttrValueURL::~CT_DataCSdpAttrValueURL()
       
    57 	{
       
    58 	DestroyData();
       
    59 	}
       
    60 
       
    61 void CT_DataCSdpAttrValueURL::SetObjectL(TAny* aAny)
       
    62 	{
       
    63 	DestroyData();
       
    64 	iAttrValueURL = static_cast<CSdpAttrValueURL*> (aAny);
       
    65 	}
       
    66 
       
    67 void CT_DataCSdpAttrValueURL::DisownObjectL()
       
    68 	{
       
    69 	iAttrValueURL = NULL;
       
    70 	}
       
    71 
       
    72 void CT_DataCSdpAttrValueURL::DestroyData()
       
    73 	{
       
    74 	delete iAttrValueURL;
       
    75 	iAttrValueURL=NULL;	
       
    76 	}
       
    77 
       
    78 inline TCleanupOperation CT_DataCSdpAttrValueURL::CleanupOperation()
       
    79 	{
       
    80 	return CleanupOperation;
       
    81 	}
       
    82 
       
    83 void CT_DataCSdpAttrValueURL::CleanupOperation(TAny* aAny)
       
    84 	{
       
    85 	CSdpAttrValueURL* valueURL=static_cast<CSdpAttrValueURL*>(aAny);
       
    86 	delete valueURL;
       
    87 	}
       
    88 
       
    89 /**
       
    90  * Process a command read from the ini file
       
    91  *
       
    92  * @param aCommand			The command to process
       
    93  * @param aSection			The section in the ini containing data for the command
       
    94  * @param aAsyncErrorIndex	Command index for async calls to return errors to
       
    95  *
       
    96  * @return					ETrue if the command is processed
       
    97  *
       
    98  * @leave					System wide error
       
    99  */
       
   100 TBool CT_DataCSdpAttrValueURL::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   101 	{
       
   102 	TBool	ret=ETrue;
       
   103 
       
   104 	if ( aCommand==KCmdNewURLL )
       
   105 		{
       
   106 		DoCmdNewURLL(aSection);
       
   107 		}
       
   108 	else if ( aCommand==KCmdDestructor )
       
   109 		{
       
   110 		DoCmdDestructor();
       
   111 		}
       
   112 	else
       
   113 		{
       
   114 		ret=CT_DataSdpAttrValue::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   115 		}
       
   116 
       
   117 	return ret;
       
   118 	}
       
   119 
       
   120 
       
   121 /**
       
   122 Test NewURLL()
       
   123 */
       
   124 void CT_DataCSdpAttrValueURL::DoCmdNewURLL(const TDesC& aSection)
       
   125 	{
       
   126 
       
   127 	DestroyData();
       
   128 	TPtrC	theString;
       
   129 	if ( GetStringFromConfig(aSection, KNewObject(), theString) )
       
   130 		{
       
   131 		HBufC8*	string8 = HBufC8::NewLC(theString.Length());
       
   132 		string8->Des().Copy(theString);
       
   133 		TPtrC8 stringPtr = string8->Des();
       
   134 		TRAPD(err, iAttrValueURL = CSdpAttrValueURL::NewURLL(stringPtr));
       
   135 		if ( err!=KErrNone )
       
   136 			{
       
   137 			ERR_PRINTF2(_L("CSdpAttrValueURL NewURLL failed with error %d"), err);
       
   138 			SetError(err);
       
   139 			}
       
   140 		CleanupStack::PopAndDestroy(string8);
       
   141 		}
       
   142 	else
       
   143 		{
       
   144 		ERR_PRINTF2(_L("Missing parameter %S"), &KNewObject());
       
   145 		SetBlockResult(EFail);
       
   146 		}
       
   147 	}
       
   148 
       
   149 /**
       
   150 Test ~CSdpAttrValueURL()
       
   151 */
       
   152 void CT_DataCSdpAttrValueURL::DoCmdDestructor()
       
   153 	{
       
   154 	INFO_PRINTF1(_L("CSdpAttrValueURL Destructor Call"));
       
   155 
       
   156 	DestroyData();
       
   157 	}