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