haitest/bspsvs/suite/e32/src/T_TCommCapsV02Data.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_TCommCapsV02Data.h"
       
    19 
       
    20 /*@{*/
       
    21 _LIT(KStrNull,								" ");
       
    22 
       
    23 _LIT(KStrKCapsFlowControlStatusSupported,	"KCapsFlowControlStatusSupported");
       
    24 const CDataWrapperBase::TEnumEntryTable	CT_TCommCapsV02Data::iEnumTableFlowControlCaps[] =
       
    25 	{
       
    26 //	Enum as a descriptor					Enum
       
    27 	KStrKCapsFlowControlStatusSupported,	KCapsFlowControlStatusSupported,
       
    28 	KStrNull,								-1
       
    29 	};
       
    30 
       
    31 _LIT(KStrKNotifySignalsChangeSupported,		"KNotifySignalsChangeSupported");
       
    32 _LIT(KStrKNotifyRateChangeSupported,		"KNotifyRateChangeSupported");
       
    33 _LIT(KStrKNotifyDataFormatChangeSupported,	"KNotifyDataFormatChangeSupported");
       
    34 _LIT(KStrKNotifyHandshakeChangeSupported,	"KNotifyHandshakeChangeSupported");
       
    35 _LIT(KStrKNotifyBreakSupported,				"KNotifyBreakSupported");
       
    36 _LIT(KStrKNotifyFlowControlChangeSupported,	"KNotifyFlowControlChangeSupported");
       
    37 _LIT(KStrKNotifyDataAvailableSupported,		"KNotifyDataAvailableSupported");
       
    38 _LIT(KStrKNotifyOutputEmptySupported,		"KNotifyOutputEmptySupported");
       
    39 const CDataWrapperBase::TEnumEntryTable	CT_TCommCapsV02Data::iEnumTableNotificationCaps[] =
       
    40 	{
       
    41 //	Enum as a descriptor					Enum
       
    42 	KStrKNotifySignalsChangeSupported,		KNotifySignalsChangeSupported,
       
    43 	KStrKNotifyRateChangeSupported,			KNotifyRateChangeSupported,
       
    44 	KStrKNotifyDataFormatChangeSupported,	KNotifyDataFormatChangeSupported,
       
    45 	KStrKNotifyHandshakeChangeSupported,	KNotifyHandshakeChangeSupported,
       
    46 	KStrKNotifyBreakSupported,				KNotifyBreakSupported,
       
    47 	KStrKNotifyFlowControlChangeSupported,	KNotifyFlowControlChangeSupported,
       
    48 	KStrKNotifyDataAvailableSupported,		KNotifyDataAvailableSupported,
       
    49 	KStrKNotifyOutputEmptySupported,		KNotifyOutputEmptySupported,
       
    50 	KStrNull,								-1
       
    51 	};
       
    52 
       
    53 _LIT(KStrKCapsRoleSwitchSupported,			"KCapsRoleSwitchSupported");
       
    54 const CDataWrapperBase::TEnumEntryTable	CT_TCommCapsV02Data::iEnumTableRoleCaps[] =
       
    55 	{
       
    56 //	Enum as a descriptor					Enum
       
    57 	KStrKCapsRoleSwitchSupported,			KCapsRoleSwitchSupported,
       
    58 	KStrNull,								-1
       
    59 	};
       
    60 
       
    61 _LIT(KCmdConstructor,						"new");
       
    62 _LIT(KCmdDestructor,						"~");
       
    63 _LIT(KCmdiFlowControlCaps,					"iFlowControlCaps");
       
    64 _LIT(KCmdiNotificationCaps,					"iNotificationCaps");
       
    65 _LIT(KCmdiRoleCaps,							"iRoleCaps");
       
    66 
       
    67 _LIT(KFldExpected,							"expected");
       
    68 
       
    69 _LIT(KLogError,								"Error=%d");
       
    70 /*@}*/
       
    71 
       
    72 //////////////////////////////////////////////////////////////////////
       
    73 // Construction/Destruction
       
    74 //////////////////////////////////////////////////////////////////////
       
    75 
       
    76 CT_TCommCapsV02Data::CT_TCommCapsV02Data()
       
    77 :	CT_TCommCapsV01Data()
       
    78 ,	iCommCaps2(NULL)
       
    79 	{
       
    80 	}
       
    81 
       
    82 CT_TCommCapsV02Data::~CT_TCommCapsV02Data()
       
    83 /**
       
    84  * Public destructor
       
    85  */
       
    86 	{
       
    87 	DestroyData();
       
    88 	}
       
    89 
       
    90 void CT_TCommCapsV02Data::DestroyData()
       
    91 	{
       
    92 	delete iCommCaps2;
       
    93 	iCommCaps2=NULL;
       
    94 	}
       
    95 
       
    96 TDes8* CT_TCommCapsV02Data::Descriptor()
       
    97 /**
       
    98  * Return a pointer to the buffer
       
    99  *
       
   100  * @return	pointer to the buffer
       
   101  */
       
   102 	{
       
   103 	return iCommCaps2;
       
   104 	}
       
   105 
       
   106 TAny* CT_TCommCapsV02Data::GetObject()
       
   107 /**
       
   108  * Return a pointer to the object that the data wraps
       
   109  *
       
   110  * @return	pointer to the object that the data wraps
       
   111  */
       
   112 	{
       
   113 	return iCommCaps2;
       
   114 	}
       
   115 
       
   116 TBool CT_TCommCapsV02Data::ReadFlowControlCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aFlowControlCaps)
       
   117 	{
       
   118 	return GetOrFromConfig(aSection, aKeyName, iEnumTableFlowControlCaps, aFlowControlCaps);
       
   119 	}
       
   120 
       
   121 TBool CT_TCommCapsV02Data::ReadNotificationCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aNotificationCaps)
       
   122 	{
       
   123 	return GetOrFromConfig(aSection, aKeyName, iEnumTableNotificationCaps, aNotificationCaps);
       
   124 	}
       
   125 
       
   126 TBool CT_TCommCapsV02Data::ReadRoleCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aRoleCaps)
       
   127 	{
       
   128 	return GetOrFromConfig(aSection, aKeyName, iEnumTableRoleCaps, aRoleCaps);
       
   129 	}
       
   130 
       
   131 TBool CT_TCommCapsV02Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   132 /**
       
   133  * Process a command read from the ini file
       
   134  *
       
   135  * @param aCommand			The command to process
       
   136  * @param aSection			The section in the ini containing data for the command
       
   137  * @param aAsyncErrorIndex	Command index for async calls to return errors to
       
   138  *
       
   139  * @return					ETrue if the command is processed
       
   140  *
       
   141  * @leave					System wide error
       
   142  */
       
   143 	{
       
   144 	TBool	ret=ETrue;
       
   145 	TInt	err=KErrNone;
       
   146 
       
   147 	if ( aCommand==KCmdConstructor )
       
   148 		{
       
   149 		err=DoCmdConstructor();
       
   150 		}
       
   151 	else if ( aCommand==KCmdDestructor )
       
   152 		{
       
   153 		DoCmdDestructor();
       
   154 		}
       
   155 	else if ( aCommand==KCmdiFlowControlCaps )
       
   156 		{
       
   157 		DoCmdiFlowControlCaps(aSection);
       
   158 		}
       
   159 	else if ( aCommand==KCmdiNotificationCaps )
       
   160 		{
       
   161 		DoCmdiNotificationCaps(aSection);
       
   162 		}
       
   163 	else if ( aCommand==KCmdiRoleCaps )
       
   164 		{
       
   165 		DoCmdiRoleCaps(aSection);
       
   166 		}
       
   167 	else
       
   168 		{
       
   169 		ret=CT_TCommCapsV01Data::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   170 		}
       
   171 
       
   172 	if ( err!=KErrNone )
       
   173 		{
       
   174 		ERR_PRINTF2(KLogError, err);
       
   175 		SetError(err);
       
   176 		}
       
   177 
       
   178 	return ret;
       
   179 	}
       
   180 
       
   181 TCommCapsV01& CT_TCommCapsV02Data::GetCommCapsV01()
       
   182 	{
       
   183 	return (*iCommCaps2)();
       
   184 	}
       
   185 
       
   186 TCommCapsV02& CT_TCommCapsV02Data::GetCommCapsV02()
       
   187 	{
       
   188 	return (*iCommCaps2)();
       
   189 	}
       
   190 
       
   191 TInt CT_TCommCapsV02Data::DoCmdConstructor()
       
   192 	{
       
   193 	DestroyData();
       
   194 	TRAPD(err, iCommCaps2=new (ELeave) TCommCaps2());
       
   195 	iCommCaps2->FillZ();
       
   196 	return err;
       
   197 	}
       
   198 
       
   199 void CT_TCommCapsV02Data::DoCmdDestructor()
       
   200 	{
       
   201 	DestroyData();
       
   202 	}
       
   203 
       
   204 void CT_TCommCapsV02Data::DoCmdiFlowControlCaps(const TDesC& aSection)
       
   205 	{
       
   206 	TUint	actual=GetCommCapsV02().iFlowControlCaps;
       
   207 	INFO_PRINTF2(_L("iFlowControlCaps : 0x%x"), actual);
       
   208 
       
   209 	TUint	expected;
       
   210 	if ( ReadFlowControlCaps(aSection, KFldExpected(), expected) )
       
   211 		{
       
   212 		if ( expected!=actual )
       
   213 			{
       
   214 			ERR_PRINTF1(_L("Expected Value does not match actual"));
       
   215 			SetBlockResult(EFail);
       
   216 			}
       
   217 		}
       
   218 	}
       
   219 
       
   220 void CT_TCommCapsV02Data::DoCmdiNotificationCaps(const TDesC& aSection)
       
   221 	{
       
   222 	TUint	actual=GetCommCapsV02().iNotificationCaps;
       
   223 	INFO_PRINTF2(_L("iNotificationCaps : 0x%x"), actual);
       
   224 
       
   225 	TUint	expected;
       
   226 	if ( ReadNotificationCaps(aSection, KFldExpected(), expected) )
       
   227 		{
       
   228 		if ( expected!=actual )
       
   229 			{
       
   230 			ERR_PRINTF1(_L("Expected Value does not match actual"));
       
   231 			SetBlockResult(EFail);
       
   232 			}
       
   233 		}
       
   234 	}
       
   235 
       
   236 void CT_TCommCapsV02Data::DoCmdiRoleCaps(const TDesC& aSection)
       
   237 	{
       
   238 	TUint	actual=GetCommCapsV02().iRoleCaps;
       
   239 	INFO_PRINTF2(_L("iRoleCaps : 0x%x"), actual);
       
   240 
       
   241 	TUint	expected;
       
   242 	if ( ReadRoleCaps(aSection, KFldExpected(), expected) )
       
   243 		{
       
   244 		if ( expected!=actual )
       
   245 			{
       
   246 			ERR_PRINTF1(_L("Expected Value does not match actual"));
       
   247 			SetBlockResult(EFail);
       
   248 			}
       
   249 		}
       
   250 	}