First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_TCommCapsV02Data.h"
23 _LIT(KStrKCapsFlowControlStatusSupported, "KCapsFlowControlStatusSupported");
24 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV02Data::iEnumTableFlowControlCaps[] =
26 // Enum as a descriptor Enum
27 KStrKCapsFlowControlStatusSupported, KCapsFlowControlStatusSupported,
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[] =
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,
53 _LIT(KStrKCapsRoleSwitchSupported, "KCapsRoleSwitchSupported");
54 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV02Data::iEnumTableRoleCaps[] =
56 // Enum as a descriptor Enum
57 KStrKCapsRoleSwitchSupported, KCapsRoleSwitchSupported,
61 _LIT(KCmdConstructor, "new");
62 _LIT(KCmdDestructor, "~");
63 _LIT(KCmdiFlowControlCaps, "iFlowControlCaps");
64 _LIT(KCmdiNotificationCaps, "iNotificationCaps");
65 _LIT(KCmdiRoleCaps, "iRoleCaps");
67 _LIT(KFldExpected, "expected");
69 _LIT(KLogError, "Error=%d");
72 //////////////////////////////////////////////////////////////////////
73 // Construction/Destruction
74 //////////////////////////////////////////////////////////////////////
76 CT_TCommCapsV02Data::CT_TCommCapsV02Data()
77 : CT_TCommCapsV01Data()
82 CT_TCommCapsV02Data::~CT_TCommCapsV02Data()
90 void CT_TCommCapsV02Data::DestroyData()
96 TDes8* CT_TCommCapsV02Data::Descriptor()
98 * Return a pointer to the buffer
100 * @return pointer to the buffer
106 TAny* CT_TCommCapsV02Data::GetObject()
108 * Return a pointer to the object that the data wraps
110 * @return pointer to the object that the data wraps
116 TBool CT_TCommCapsV02Data::ReadFlowControlCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aFlowControlCaps)
118 return GetOrFromConfig(aSection, aKeyName, iEnumTableFlowControlCaps, aFlowControlCaps);
121 TBool CT_TCommCapsV02Data::ReadNotificationCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aNotificationCaps)
123 return GetOrFromConfig(aSection, aKeyName, iEnumTableNotificationCaps, aNotificationCaps);
126 TBool CT_TCommCapsV02Data::ReadRoleCaps(const TDesC& aSection, const TDesC& aKeyName, TUint& aRoleCaps)
128 return GetOrFromConfig(aSection, aKeyName, iEnumTableRoleCaps, aRoleCaps);
131 TBool CT_TCommCapsV02Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
133 * Process a command read from the ini file
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
139 * @return ETrue if the command is processed
141 * @leave System wide error
147 if ( aCommand==KCmdConstructor )
149 err=DoCmdConstructor();
151 else if ( aCommand==KCmdDestructor )
155 else if ( aCommand==KCmdiFlowControlCaps )
157 DoCmdiFlowControlCaps(aSection);
159 else if ( aCommand==KCmdiNotificationCaps )
161 DoCmdiNotificationCaps(aSection);
163 else if ( aCommand==KCmdiRoleCaps )
165 DoCmdiRoleCaps(aSection);
169 ret=CT_TCommCapsV01Data::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
174 ERR_PRINTF2(KLogError, err);
181 TCommCapsV01& CT_TCommCapsV02Data::GetCommCapsV01()
183 return (*iCommCaps2)();
186 TCommCapsV02& CT_TCommCapsV02Data::GetCommCapsV02()
188 return (*iCommCaps2)();
191 TInt CT_TCommCapsV02Data::DoCmdConstructor()
194 TRAPD(err, iCommCaps2=new (ELeave) TCommCaps2());
199 void CT_TCommCapsV02Data::DoCmdDestructor()
204 void CT_TCommCapsV02Data::DoCmdiFlowControlCaps(const TDesC& aSection)
206 TUint actual=GetCommCapsV02().iFlowControlCaps;
207 INFO_PRINTF2(_L("iFlowControlCaps : 0x%x"), actual);
210 if ( ReadFlowControlCaps(aSection, KFldExpected(), expected) )
212 if ( expected!=actual )
214 ERR_PRINTF1(_L("Expected Value does not match actual"));
215 SetBlockResult(EFail);
220 void CT_TCommCapsV02Data::DoCmdiNotificationCaps(const TDesC& aSection)
222 TUint actual=GetCommCapsV02().iNotificationCaps;
223 INFO_PRINTF2(_L("iNotificationCaps : 0x%x"), actual);
226 if ( ReadNotificationCaps(aSection, KFldExpected(), expected) )
228 if ( expected!=actual )
230 ERR_PRINTF1(_L("Expected Value does not match actual"));
231 SetBlockResult(EFail);
236 void CT_TCommCapsV02Data::DoCmdiRoleCaps(const TDesC& aSection)
238 TUint actual=GetCommCapsV02().iRoleCaps;
239 INFO_PRINTF2(_L("iRoleCaps : 0x%x"), actual);
242 if ( ReadRoleCaps(aSection, KFldExpected(), expected) )
244 if ( expected!=actual )
246 ERR_PRINTF1(_L("Expected Value does not match actual"));
247 SetBlockResult(EFail);