1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/e32/src/T_TCommCapsV02Data.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,250 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +#include "T_TCommCapsV02Data.h"
1.22 +
1.23 +/*@{*/
1.24 +_LIT(KStrNull, " ");
1.25 +
1.26 +_LIT(KStrKCapsFlowControlStatusSupported, "KCapsFlowControlStatusSupported");
1.27 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV02Data::iEnumTableFlowControlCaps[] =
1.28 + {
1.29 +// Enum as a descriptor Enum
1.30 + KStrKCapsFlowControlStatusSupported, KCapsFlowControlStatusSupported,
1.31 + KStrNull, -1
1.32 + };
1.33 +
1.34 +_LIT(KStrKNotifySignalsChangeSupported, "KNotifySignalsChangeSupported");
1.35 +_LIT(KStrKNotifyRateChangeSupported, "KNotifyRateChangeSupported");
1.36 +_LIT(KStrKNotifyDataFormatChangeSupported, "KNotifyDataFormatChangeSupported");
1.37 +_LIT(KStrKNotifyHandshakeChangeSupported, "KNotifyHandshakeChangeSupported");
1.38 +_LIT(KStrKNotifyBreakSupported, "KNotifyBreakSupported");
1.39 +_LIT(KStrKNotifyFlowControlChangeSupported, "KNotifyFlowControlChangeSupported");
1.40 +_LIT(KStrKNotifyDataAvailableSupported, "KNotifyDataAvailableSupported");
1.41 +_LIT(KStrKNotifyOutputEmptySupported, "KNotifyOutputEmptySupported");
1.42 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV02Data::iEnumTableNotificationCaps[] =
1.43 + {
1.44 +// Enum as a descriptor Enum
1.45 + KStrKNotifySignalsChangeSupported, KNotifySignalsChangeSupported,
1.46 + KStrKNotifyRateChangeSupported, KNotifyRateChangeSupported,
1.47 + KStrKNotifyDataFormatChangeSupported, KNotifyDataFormatChangeSupported,
1.48 + KStrKNotifyHandshakeChangeSupported, KNotifyHandshakeChangeSupported,
1.49 + KStrKNotifyBreakSupported, KNotifyBreakSupported,
1.50 + KStrKNotifyFlowControlChangeSupported, KNotifyFlowControlChangeSupported,
1.51 + KStrKNotifyDataAvailableSupported, KNotifyDataAvailableSupported,
1.52 + KStrKNotifyOutputEmptySupported, KNotifyOutputEmptySupported,
1.53 + KStrNull, -1
1.54 + };
1.55 +
1.56 +_LIT(KStrKCapsRoleSwitchSupported, "KCapsRoleSwitchSupported");
1.57 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV02Data::iEnumTableRoleCaps[] =
1.58 + {
1.59 +// Enum as a descriptor Enum
1.60 + KStrKCapsRoleSwitchSupported, KCapsRoleSwitchSupported,
1.61 + KStrNull, -1
1.62 + };
1.63 +
1.64 +_LIT(KCmdConstructor, "new");
1.65 +_LIT(KCmdDestructor, "~");
1.66 +_LIT(KCmdiFlowControlCaps, "iFlowControlCaps");
1.67 +_LIT(KCmdiNotificationCaps, "iNotificationCaps");
1.68 +_LIT(KCmdiRoleCaps, "iRoleCaps");
1.69 +
1.70 +_LIT(KFldExpected, "expected");
1.71 +
1.72 +_LIT(KLogError, "Error=%d");
1.73 +/*@}*/
1.74 +
1.75 +//////////////////////////////////////////////////////////////////////
1.76 +// Construction/Destruction
1.77 +//////////////////////////////////////////////////////////////////////
1.78 +
1.79 +CT_TCommCapsV02Data::CT_TCommCapsV02Data()
1.80 +: CT_TCommCapsV01Data()
1.81 +, iCommCaps2(NULL)
1.82 + {
1.83 + }
1.84 +
1.85 +CT_TCommCapsV02Data::~CT_TCommCapsV02Data()
1.86 +/**
1.87 + * Public destructor
1.88 + */
1.89 + {
1.90 + DestroyData();
1.91 + }
1.92 +
1.93 +void CT_TCommCapsV02Data::DestroyData()
1.94 + {
1.95 + delete iCommCaps2;
1.96 + iCommCaps2=NULL;
1.97 + }
1.98 +
1.99 +TDes8* CT_TCommCapsV02Data::Descriptor()
1.100 +/**
1.101 + * Return a pointer to the buffer
1.102 + *
1.103 + * @return pointer to the buffer
1.104 + */
1.105 + {
1.106 + return iCommCaps2;
1.107 + }
1.108 +
1.109 +TAny* CT_TCommCapsV02Data::GetObject()
1.110 +/**
1.111 + * Return a pointer to the object that the data wraps
1.112 + *
1.113 + * @return pointer to the object that the data wraps
1.114 + */
1.115 + {
1.116 + return iCommCaps2;
1.117 + }
1.118 +
1.119 +TBool CT_TCommCapsV02Data::ReadFlowControlCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aFlowControlCaps)
1.120 + {
1.121 + return GetOrFromConfig(aSection, aKeyName, iEnumTableFlowControlCaps, aFlowControlCaps);
1.122 + }
1.123 +
1.124 +TBool CT_TCommCapsV02Data::ReadNotificationCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aNotificationCaps)
1.125 + {
1.126 + return GetOrFromConfig(aSection, aKeyName, iEnumTableNotificationCaps, aNotificationCaps);
1.127 + }
1.128 +
1.129 +TBool CT_TCommCapsV02Data::ReadRoleCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aRoleCaps)
1.130 + {
1.131 + return GetOrFromConfig(aSection, aKeyName, iEnumTableRoleCaps, aRoleCaps);
1.132 + }
1.133 +
1.134 +TBool CT_TCommCapsV02Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.135 +/**
1.136 + * Process a command read from the ini file
1.137 + *
1.138 + * @param aCommand The command to process
1.139 + * @param aSection The section in the ini containing data for the command
1.140 + * @param aAsyncErrorIndex Command index for async calls to return errors to
1.141 + *
1.142 + * @return ETrue if the command is processed
1.143 + *
1.144 + * @leave System wide error
1.145 + */
1.146 + {
1.147 + TBool ret=ETrue;
1.148 + TInt err=KErrNone;
1.149 +
1.150 + if ( aCommand==KCmdConstructor )
1.151 + {
1.152 + err=DoCmdConstructor();
1.153 + }
1.154 + else if ( aCommand==KCmdDestructor )
1.155 + {
1.156 + DoCmdDestructor();
1.157 + }
1.158 + else if ( aCommand==KCmdiFlowControlCaps )
1.159 + {
1.160 + DoCmdiFlowControlCaps(aSection);
1.161 + }
1.162 + else if ( aCommand==KCmdiNotificationCaps )
1.163 + {
1.164 + DoCmdiNotificationCaps(aSection);
1.165 + }
1.166 + else if ( aCommand==KCmdiRoleCaps )
1.167 + {
1.168 + DoCmdiRoleCaps(aSection);
1.169 + }
1.170 + else
1.171 + {
1.172 + ret=CT_TCommCapsV01Data::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
1.173 + }
1.174 +
1.175 + if ( err!=KErrNone )
1.176 + {
1.177 + ERR_PRINTF2(KLogError, err);
1.178 + SetError(err);
1.179 + }
1.180 +
1.181 + return ret;
1.182 + }
1.183 +
1.184 +TCommCapsV01& CT_TCommCapsV02Data::GetCommCapsV01()
1.185 + {
1.186 + return (*iCommCaps2)();
1.187 + }
1.188 +
1.189 +TCommCapsV02& CT_TCommCapsV02Data::GetCommCapsV02()
1.190 + {
1.191 + return (*iCommCaps2)();
1.192 + }
1.193 +
1.194 +TInt CT_TCommCapsV02Data::DoCmdConstructor()
1.195 + {
1.196 + DestroyData();
1.197 + TRAPD(err, iCommCaps2=new (ELeave) TCommCaps2());
1.198 + iCommCaps2->FillZ();
1.199 + return err;
1.200 + }
1.201 +
1.202 +void CT_TCommCapsV02Data::DoCmdDestructor()
1.203 + {
1.204 + DestroyData();
1.205 + }
1.206 +
1.207 +void CT_TCommCapsV02Data::DoCmdiFlowControlCaps(const TDesC& aSection)
1.208 + {
1.209 + TUint actual=GetCommCapsV02().iFlowControlCaps;
1.210 + INFO_PRINTF2(_L("iFlowControlCaps : 0x%x"), actual);
1.211 +
1.212 + TUint expected;
1.213 + if ( ReadFlowControlCaps(aSection, KFldExpected(), expected) )
1.214 + {
1.215 + if ( expected!=actual )
1.216 + {
1.217 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.218 + SetBlockResult(EFail);
1.219 + }
1.220 + }
1.221 + }
1.222 +
1.223 +void CT_TCommCapsV02Data::DoCmdiNotificationCaps(const TDesC& aSection)
1.224 + {
1.225 + TUint actual=GetCommCapsV02().iNotificationCaps;
1.226 + INFO_PRINTF2(_L("iNotificationCaps : 0x%x"), actual);
1.227 +
1.228 + TUint expected;
1.229 + if ( ReadNotificationCaps(aSection, KFldExpected(), expected) )
1.230 + {
1.231 + if ( expected!=actual )
1.232 + {
1.233 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.234 + SetBlockResult(EFail);
1.235 + }
1.236 + }
1.237 + }
1.238 +
1.239 +void CT_TCommCapsV02Data::DoCmdiRoleCaps(const TDesC& aSection)
1.240 + {
1.241 + TUint actual=GetCommCapsV02().iRoleCaps;
1.242 + INFO_PRINTF2(_L("iRoleCaps : 0x%x"), actual);
1.243 +
1.244 + TUint expected;
1.245 + if ( ReadRoleCaps(aSection, KFldExpected(), expected) )
1.246 + {
1.247 + if ( expected!=actual )
1.248 + {
1.249 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.250 + SetBlockResult(EFail);
1.251 + }
1.252 + }
1.253 + }