haitest/bspsvs/suite/e32/src/T_TCommConfigV02Data.cpp
changeset 0 cec860690d41
equal deleted inserted replaced
-1:000000000000 0:cec860690d41
       
     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_TCommConfigV02Data.h"
       
    19 
       
    20 /*@{*/
       
    21 _LIT(KCmdConstructor,						"new");
       
    22 _LIT(KCmdDestructor,						"~");
       
    23 _LIT(KCmdiTxShutdownTimeout,				"iTxShutdownTimeout");
       
    24 
       
    25 _LIT(KFldExpected,							"expected");
       
    26 _LIT(KFldValue,								"value");
       
    27 
       
    28 _LIT(KLogError,								"Error=%d");
       
    29 /*@}*/
       
    30 
       
    31 //////////////////////////////////////////////////////////////////////
       
    32 // Construction/Destruction
       
    33 //////////////////////////////////////////////////////////////////////
       
    34 
       
    35 CT_TCommConfigV02Data::CT_TCommConfigV02Data()
       
    36 :	CT_TCommConfigV01Data()
       
    37 ,	iCommConfig2(NULL)
       
    38 	{
       
    39 	}
       
    40 
       
    41 CT_TCommConfigV02Data::~CT_TCommConfigV02Data()
       
    42 /**
       
    43  * Public destructor
       
    44  */
       
    45 	{
       
    46 	DestroyData();
       
    47 	}
       
    48 
       
    49 void CT_TCommConfigV02Data::DestroyData()
       
    50 	{
       
    51 	delete iCommConfig2;
       
    52 	iCommConfig2=NULL;
       
    53 	}
       
    54 
       
    55 TDes8* CT_TCommConfigV02Data::Descriptor()
       
    56 /**
       
    57  * Return a pointer to the buffer
       
    58  *
       
    59  * @return	pointer to the buffer
       
    60  */
       
    61 	{
       
    62 	return iCommConfig2;
       
    63 	}
       
    64 
       
    65 TAny* CT_TCommConfigV02Data::GetObject()
       
    66 /**
       
    67  * Return a pointer to the object that the data wraps
       
    68  *
       
    69  * @return	pointer to the object that the data wraps
       
    70  */
       
    71 	{
       
    72 	return iCommConfig2;
       
    73 	}
       
    74 
       
    75 TBool CT_TCommConfigV02Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
    76 /**
       
    77  * Process a command read from the ini file
       
    78  *
       
    79  * @param aCommand			The command to process
       
    80  * @param aSection			The section in the ini containing data for the command
       
    81  * @param aAsyncErrorIndex	Command index for async calls to return errors to
       
    82  *
       
    83  * @return					ETrue if the command is processed
       
    84  *
       
    85  * @leave					System wide error
       
    86  */
       
    87 	{
       
    88 	TBool	ret=ETrue;
       
    89 	TInt	err=KErrNone;
       
    90 
       
    91 	if ( aCommand==KCmdConstructor )
       
    92 		{
       
    93 		err=DoCmdConstructor();
       
    94 		}
       
    95 	else if ( aCommand==KCmdDestructor )
       
    96 		{
       
    97 		DoCmdDestructor();
       
    98 		}
       
    99 	else if ( aCommand==KCmdiTxShutdownTimeout )
       
   100 		{
       
   101 		DoCmdiTxShutdownTimeout(aSection);
       
   102 		}
       
   103 	else
       
   104 		{
       
   105 		err=CT_TCommConfigV01Data::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   106 		}
       
   107 
       
   108 	if ( err!=KErrNone )
       
   109 		{
       
   110 		ERR_PRINTF2(KLogError, err);
       
   111 		SetError(err);
       
   112 		}
       
   113 
       
   114 	return ret;
       
   115 	}
       
   116 
       
   117 TCommConfigV01& CT_TCommConfigV02Data::GetCommConfigV01()
       
   118 	{
       
   119 	return (*iCommConfig2)();
       
   120 	}
       
   121 
       
   122 TCommConfigV02& CT_TCommConfigV02Data::GetCommConfigV02()
       
   123 	{
       
   124 	return (*iCommConfig2)();
       
   125 	}
       
   126 
       
   127 TInt CT_TCommConfigV02Data::DoCmdConstructor()
       
   128 	{
       
   129 	DestroyData();
       
   130 	TRAPD(err, iCommConfig2=new (ELeave) TCommConfig2());
       
   131 	iCommConfig2->FillZ();
       
   132 	return err;
       
   133 	}
       
   134 
       
   135 void CT_TCommConfigV02Data::DoCmdDestructor()
       
   136 	{
       
   137 	DestroyData();
       
   138 	}
       
   139 
       
   140 void CT_TCommConfigV02Data::DoCmdiTxShutdownTimeout(const TDesC& aSection)
       
   141 	{
       
   142 	TInt	actual=GetCommConfigV02().iTxShutdownTimeout;
       
   143 	INFO_PRINTF2(_L("iTxShutdownTimeout : %d"), actual);
       
   144 
       
   145 	TInt	expected;
       
   146 	if( GetIntFromConfig(aSection, KFldExpected(), expected) )
       
   147 		{
       
   148 		if ( expected!=actual )
       
   149 			{
       
   150 			ERR_PRINTF1(_L("Expected Value does not match actual"));
       
   151 			SetBlockResult(EFail);
       
   152 			}
       
   153 		}
       
   154 
       
   155 	TInt	value;
       
   156 	if( GetIntFromConfig(aSection, KFldValue(), value) )
       
   157 		{
       
   158 		GetCommConfigV02().iTxShutdownTimeout=value;
       
   159 		}
       
   160 	}